]> git.baikalelectronics.ru Git - kernel.git/commit
net: ip6_gre: fix tunnel metadata device sharing.
authorWilliam Tu <u9012063@gmail.com>
Sat, 19 May 2018 02:22:28 +0000 (19:22 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 20 May 2018 03:32:12 +0000 (23:32 -0400)
commit9f1e593c02c3ea784da5a8f3b3f28047fb1660fb
treee36f7168049247c5950f6ba3465a74ec11b17d78
parent5d1b228942cadf3c3bea0aedb0345a2c32ffd034
net: ip6_gre: fix tunnel metadata device sharing.

Currently ip6gre and ip6erspan share single metadata mode device,
using 'collect_md_tun'.  Thus, when doing:
  ip link add dev ip6gre11 type ip6gretap external
  ip link add dev ip6erspan12 type ip6erspan external
  RTNETLINK answers: File exists
simply fails due to the 2nd tries to create the same collect_md_tun.

The patch fixes it by adding a separate collect md tunnel device
for the ip6erspan, 'collect_md_tun_erspan'.  As a result, a couple
of places need to refactor/split up in order to distinguish ip6gre
and ip6erspan.

First, move the collect_md check at ip6gre_tunnel_{unlink,link} and
create separate function {ip6gre,ip6ersapn}_tunnel_{link_md,unlink_md}.
Then before link/unlink, make sure the link_md/unlink_md is called.
Finally, a separate ndo_uninit is created for ip6erspan.  Tested it
using the samples/bpf/test_tunnel_bpf.sh.

Fixes: 1fad55ed3324 ("ip6_gre: add ip6 erspan collect_md mode")
Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/ip6_gre.c