Message ID | 1456867148-31883-4-git-send-email-andrew@lunn.ch (mailing list archive) |
---|---|
State | Superseded, archived |
Delegated to: | Marek Lindner |
Headers |
Return-Path: <b.a.t.m.a.n-bounces@lists.open-mesh.org> X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [127.0.0.1]) by open-mesh.org (Postfix) with ESMTP id 92FF180753; Tue, 1 Mar 2016 23:03:12 +0100 (CET) Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=178.209.37.122; helo=vps0.lunn.ch; envelope-from=andrew@lunn.ch; receiver=b.a.t.m.a.n@lists.open-mesh.net Authentication-Results: open-mesh.org; dmarc=none header.from=lunn.ch X-Greylist: delayed 2631 seconds by postgrey-1.35 at open-mesh.org; Tue, 01 Mar 2016 23:03:10 CET Received: from vps0.lunn.ch (vps0.lunn.ch [178.209.37.122]) by open-mesh.org (Postfix) with ESMTPS id 756E180753 for <b.a.t.m.a.n@lists.open-mesh.net>; Tue, 1 Mar 2016 23:03:10 +0100 (CET) Received: from andrew by vps0.lunn.ch with local (Exim 4.80) (envelope-from <andrew@lunn.ch>) id 1aarhN-0008JG-Nq; Tue, 01 Mar 2016 22:19:17 +0100 From: Andrew Lunn <andrew@lunn.ch> To: Antonio Quartulli <a@unstable.cc> Date: Tue, 1 Mar 2016 22:19:07 +0100 Message-Id: <1456867148-31883-4-git-send-email-andrew@lunn.ch> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1456867148-31883-1-git-send-email-andrew@lunn.ch> References: <1456867148-31883-1-git-send-email-andrew@lunn.ch> Cc: "B.A.T.M.A.N" <b.a.t.m.a.n@lists.open-mesh.net> Subject: [B.A.T.M.A.N.] [PATCHv2 3/4] batman-adv: Handle parent interfaces in a different netns X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking <b.a.t.m.a.n.lists.open-mesh.org> List-Unsubscribe: <https://lists.open-mesh.org/mm/options/b.a.t.m.a.n>, <mailto:b.a.t.m.a.n-request@lists.open-mesh.org?subject=unsubscribe> List-Archive: <http://lists.open-mesh.org/pipermail/b.a.t.m.a.n/> List-Post: <mailto:b.a.t.m.a.n@lists.open-mesh.org> List-Help: <mailto:b.a.t.m.a.n-request@lists.open-mesh.org?subject=help> List-Subscribe: <https://lists.open-mesh.org/mm/listinfo/b.a.t.m.a.n>, <mailto:b.a.t.m.a.n-request@lists.open-mesh.org?subject=subscribe> Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking <b.a.t.m.a.n@lists.open-mesh.org> Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" <b.a.t.m.a.n-bounces@lists.open-mesh.org> |
Commit Message
Andrew Lunn
March 1, 2016, 9:19 p.m. UTC
batman-adv tries to prevent the user from placing a batX soft interface into another batman mesh as a hard interface. It does this by walking up the devices list of parents and ensures they are all none batX interfaces. iflink can point to an interface in a different namespace, so also retrieve the parents name space when finding the parent and use it when doing the comparison. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Acked-by: Antonio Quartulli <a@untable.cc> --- net/batman-adv/hard-interface.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-)
Comments
On Tuesday 01 March 2016 22:19:07 Andrew Lunn wrote: > batman-adv tries to prevent the user from placing a batX soft > interface into another batman mesh as a hard interface. It does this > by walking up the devices list of parents and ensures they are all > none batX interfaces. iflink can point to an interface in a different > namespace, so also retrieve the parents name space when finding the > parent and use it when doing the comparison. > > Signed-off-by: Andrew Lunn <andrew@lunn.ch> > Acked-by: Antonio Quartulli <a@untable.cc> > --- > net/batman-adv/hard-interface.c | 31 ++++++++++++++++++++++++------- > 1 file changed, 24 insertions(+), 7 deletions(-) Include missing in net/batman-adv/hard-interface.c #include <net/rtnetlink.h> Does anyone (not only Andrew) have a proposal regarding the compat code? Patch 1+2 should be unproblematic (maybe these can already be applied?). This patch here is the first problematic one because it uses get_link_net which was first introduced in v4.0 with d37512a277df ("rtnl: add link netns id to interface messages"). I personally see some function substractions coming at us. But then it would be better to have this code in a smaller function to make "patching" easier (but I don't have a complete solution right now): dev_parent_net = default_net; if (dev->rtnl_link_ops && dev->rtnl_link_ops->get_link_net) dev_parent_net = dev->rtnl_link_ops->get_link_net(dev); The next problematic part in regards of compat stuff is the patch 4. linux/ns_common.h is missing (can be added without a problem in compat-includes). More problematic is the net::ns substruct (to be more precise the net::ns.inum) which was first introduced in 3.19 with 435d5f4bb2cc ("common object embedded into various struct ....ns") and was previously called net::proc_inum (3.8-3.18) and did not exist before v3.8 98f842e675f9 ("proc: Usable inode numbers for the namespace file descriptors."). Kind regards, Sven
Hi Andrew, Thanks for looking into this! It seems some compat code might be missing, compiling against a 3.19 kernel fails for me (4.0 to 4.4 compiles fine): ----- rm -f compat-autoconf.h* make -C /lib/modules/3.2.0-4-amd64/build M=/home/tux/dev/batman-adv-t_x/net/batman-adv CONFIG_BATMAN_ADV=m CONFIG_BATMAN_ADV_DEBUG=n CONFIG_BATMAN_ADV_BLA=y CONFIG_BATMAN_ADV_DAT=y CONFIG_BATMAN_ADV_NC=n CONFIG_BATMAN_ADV_MCAST=y CONFIG_BATMAN_ADV_BATMAN_V=n INSTALL_MOD_DIR=updates/net/batman-adv/ clean make[1]: Entering directory `/usr/src/linux-headers-3.2.0-4-amd64' CLEAN /home/tux/dev/batman-adv-t_x/net/batman-adv/.tmp_versions make[1]: Leaving directory `/usr/src/linux-headers-3.2.0-4-amd64' make clean 0,26s user 0,18s system 66% cpu 0,666 total /home/tux/dev/batman-adv-t_x/gen-compat-autoconf.sh /home/tux/dev/batman-adv-t_x/compat-autoconf.h /usr/bin/make -C /home/tux/dev/linux/headers/usr/src/linux-headers-3.19.0+ M=/home/tux/dev/batman-adv-t_x/net/batman-adv CONFIG_BATMAN_ADV=m CONFIG_BATMAN_ADV_DEBUG=n CONFIG_BATMAN_ADV_BLA=y CONFIG_BATMAN_ADV_DAT=y CONFIG_BATMAN_ADV_NC=n CONFIG_BATMAN_ADV_MCAST=y CONFIG_BATMAN_ADV_BATMAN_V=n INSTALL_MOD_DIR=updates/net/batman-adv/ modules make[1]: Entering directory `/home/tux/dev/linux/headers/usr/src/linux-headers-3.19.0+' CC [M] /home/tux/dev/batman-adv-t_x/net/batman-adv/bat_iv_ogm.o CC [M] /home/tux/dev/batman-adv-t_x/net/batman-adv/bitarray.o CC [M] /home/tux/dev/batman-adv-t_x/net/batman-adv/bridge_loop_avoidance.o CC [M] /home/tux/dev/batman-adv-t_x/net/batman-adv/debugfs.o CC [M] /home/tux/dev/batman-adv-t_x/net/batman-adv/distributed-arp-table.o CC [M] /home/tux/dev/batman-adv-t_x/net/batman-adv/fragmentation.o CC [M] /home/tux/dev/batman-adv-t_x/net/batman-adv/gateway_client.o CC [M] /home/tux/dev/batman-adv-t_x/net/batman-adv/gateway_common.o CC [M] /home/tux/dev/batman-adv-t_x/net/batman-adv/hard-interface.o /home/tux/dev/batman-adv-t_x/net/batman-adv/hard-interface.c: In function ‘batadv_mutual_parents’: /home/tux/dev/batman-adv-t_x/net/batman-adv/hard-interface.c:107:48: error: ‘const struct rtnl_link_ops’ has no member named ‘get_link_net’ /home/tux/dev/batman-adv-t_x/net/batman-adv/hard-interface.c:108:40: error: ‘const struct rtnl_link_ops’ has no member named ‘get_link_net’ /home/tux/dev/batman-adv-t_x/net/batman-adv/hard-interface.c:109:48: error: ‘const struct rtnl_link_ops’ has no member named ‘get_link_net’ /home/tux/dev/batman-adv-t_x/net/batman-adv/hard-interface.c:110:40: error: ‘const struct rtnl_link_ops’ has no member named ‘get_link_net’ /home/tux/dev/batman-adv-t_x/net/batman-adv/hard-interface.c: In function ‘batadv_is_on_batman_iface’: /home/tux/dev/batman-adv-t_x/net/batman-adv/hard-interface.c:150:54: error: ‘const struct rtnl_link_ops’ has no member named ‘get_link_net’ /home/tux/dev/batman-adv-t_x/net/batman-adv/hard-interface.c:151:38: error: ‘const struct rtnl_link_ops’ has no member named ‘get_link_net’ make[2]: *** [/home/tux/dev/batman-adv-t_x/net/batman-adv/hard-interface.o] Error 1 make[1]: *** [_module_/home/tux/dev/batman-adv-t_x/net/batman-adv] Error 2 make[1]: Leaving directory `/home/tux/dev/linux/headers/usr/src/linux-headers-3.19.0+' make: *** [all] Error 2 ----- Regards, Linus
On Mon, Mar 07, 2016 at 05:21:48AM +0100, Linus Lüssing wrote: > Hi Andrew, > > Thanks for looking into this! > > It seems some compat code might be missing, compiling against a > 3.19 kernel fails for me (4.0 to 4.4 compiles fine): Hi Linus I didn't look at compat code at all. I mostly work on net-next/master, and the last -rc series. Sven started a thread about this, and i can take a closer look to see if i can help. Andrew
On Fri, Mar 04, 2016 at 01:35:01PM +0100, Sven Eckelmann wrote: > On Tuesday 01 March 2016 22:19:07 Andrew Lunn wrote: > > batman-adv tries to prevent the user from placing a batX soft > > interface into another batman mesh as a hard interface. It does this > > by walking up the devices list of parents and ensures they are all > > none batX interfaces. iflink can point to an interface in a different > > namespace, so also retrieve the parents name space when finding the > > parent and use it when doing the comparison. > > > > Signed-off-by: Andrew Lunn <andrew@lunn.ch> > > Acked-by: Antonio Quartulli <a@untable.cc> > > --- > > net/batman-adv/hard-interface.c | 31 ++++++++++++++++++++++++------- > > 1 file changed, 24 insertions(+), 7 deletions(-) > > Include missing in net/batman-adv/hard-interface.c > > #include <net/rtnetlink.h> Hi Sven How are you determining this? It compiled fine for me, which is my usual test. > > Does anyone (not only Andrew) have a proposal regarding the compat code? > Patch 1+2 should be unproblematic (maybe these can already be applied?). I've not much history with netns. One thing which might be interesting it know, is when did it become mature enough to the usable? Maybe for kernels older than v4.0, deny that netns exists, and find a way for functions like get_link_net() to return the default net. compat.h could contain #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) #if IS_ENABLED(CONFIG_NET_NS) #error Network Namespaces not support with this vintage of kernel. Please disable #endif #endif You then know everything is going to be in the default namespace for these old kernels. > This patch here is the first problematic one because it uses get_link_net > which was first introduced in v4.0 with d37512a277df ("rtnl: add link netns > id to interface messages"). I personally see some function substractions > coming at us. But then it would be better to have this code in a smaller > function to make "patching" easier (but I don't have a complete solution > right now): > > dev_parent_net = default_net; > if (dev->rtnl_link_ops && dev->rtnl_link_ops->get_link_net) > dev_parent_net = dev->rtnl_link_ops->get_link_net(dev); Horrible, and i have no idea if it actually works, but how about #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) #define dev->rtnl_link_ops->get_link_net true #define dev->rtnl_link_ops->get_link_net(dev) init_net #endif so we get the default namespace. > The next problematic part in regards of compat stuff is the patch 4. > linux/ns_common.h is missing (can be added without a problem in > compat-includes). More problematic is the net::ns substruct (to be more > precise the net::ns.inum) which was first introduced in 3.19 with > 435d5f4bb2cc ("common object embedded into various struct ....ns") and > was previously called net::proc_inum (3.8-3.18) and did not exist > before v3.8 98f842e675f9 ("proc: Usable inode numbers for the > namespace file descriptors."). How about something along the lines of #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) #define init_net.ns.inum 42 #define net->ns.inum 42 #endif Andrew
On Monday 07 March 2016 15:31:30 Andrew Lunn wrote: > On Fri, Mar 04, 2016 at 01:35:01PM +0100, Sven Eckelmann wrote: > > On Tuesday 01 March 2016 22:19:07 Andrew Lunn wrote: > > > batman-adv tries to prevent the user from placing a batX soft > > > interface into another batman mesh as a hard interface. It does this > > > by walking up the devices list of parents and ensures they are all > > > none batX interfaces. iflink can point to an interface in a different > > > namespace, so also retrieve the parents name space when finding the > > > parent and use it when doing the comparison. > > > > > > Signed-off-by: Andrew Lunn <andrew@lunn.ch> > > > Acked-by: Antonio Quartulli <a@untable.cc> > > > --- > > > net/batman-adv/hard-interface.c | 31 ++++++++++++++++++++++++------- > > > 1 file changed, 24 insertions(+), 7 deletions(-) > > > > Include missing in net/batman-adv/hard-interface.c > > > > #include <net/rtnetlink.h> > > Hi Sven > > How are you determining this? It compiled fine for me, which is my > usual test. https://git.open-mesh.org/build_test.git/blob/a246d227882b7bc03ae602b41cf65053397f9cc8:/checkstuff.sh#l311 > > > > Does anyone (not only Andrew) have a proposal regarding the compat code? > > Patch 1+2 should be unproblematic (maybe these can already be applied?). > > I've not much history with netns. One thing which might be interesting > it know, is when did it become mature enough to the usable? Maybe for > kernels older than v4.0, deny that netns exists, and find a way for > functions like get_link_net() to return the default net. > compat.h could contain > > #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) > #if IS_ENABLED(CONFIG_NET_NS) > #error Network Namespaces not support with this vintage of kernel. Please disable > #endif > #endif > > You then know everything is going to be in the default namespace for > these old kernels. I think it is a good idea to deactivate it for too old kernels. But it will explode in everyones face when build against the distro kernel. But maybe letting some of the functions "fail" for old kernels might be possible. [...] > #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) > #define dev->rtnl_link_ops->get_link_net true > #define dev->rtnl_link_ops->get_link_net(dev) init_net > #endif [...] > #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) > #define init_net.ns.inum 42 > #define net->ns.inum 42 > #endif These defines should not work (I haven't actually tested them but they should not work with all the . and ->). The preprocessor should fail because it ends the preprocessor macro name with init_net and then doesn't expect '.' to follow (only '(' or tab/space). Kind regards, Sven
On Monday 07 March 2016 15:31:30 Andrew Lunn wrote: [...] > > right now): > > dev_parent_net = default_net; > > > > if (dev->rtnl_link_ops && dev->rtnl_link_ops->get_link_net) > > > > dev_parent_net = dev->rtnl_link_ops->get_link_net(dev); > > Horrible, and i have no idea if it actually works, but how about > > #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)) > #define dev->rtnl_link_ops->get_link_net true > #define dev->rtnl_link_ops->get_link_net(dev) init_net > #endif I have prepared a quick draft of a different idea [1]. You have to excuse me now but I have a longer meeting with my shower to get rid of the feeling that I have done something horrible/dirty. :) Kind regards, Sven [1] https://git.open-mesh.org/batman-adv.git/commit/fb7b5eb8c81969dc8bea356d0a3f0b5e72d2da49
On Sat, Mar 12, 2016 at 12:37:17AM +0100, Sven Eckelmann wrote:
> [1] https://git.open-mesh.org/batman-adv.git/commit/fb7b5eb8c81969dc8bea356d0a3f0b5e72d2da49
Sven, what is the README there for ?
Cheers,
On Saturday 12 March 2016 12:42:36 Antonio Quartulli wrote: > On Sat, Mar 12, 2016 at 12:37:17AM +0100, Sven Eckelmann wrote: > > [1] > > https://git.open-mesh.org/batman-adv.git/commit/fb7b5eb8c81969dc8bea356d0 > > a3f0b5e72d2da49 > Sven, what is the README there for ? It serves different purposes. It makes sure that the directory is created by git on checkout even when there is no patch in the directory. It also makes sure that the Makefile dependency glob for compat-patches/* is at least generating one dependency. But it should also be used to define the rules under which a patch in this directory is acceptable (of course, the rules are not yet defined - so I've just used a placeholder for this draft). The requirements for such a patch should be really high because patches tend to fail when the code or the surrounding code is changed. This is also the reason why I've combined the critical code to really small functions which avoids more patch chunks for more places in the code. Kind regards, Sven
On Saturday 12 March 2016 08:34:35 Sven Eckelmann wrote: > On Saturday 12 March 2016 12:42:36 Antonio Quartulli wrote: > > On Sat, Mar 12, 2016 at 12:37:17AM +0100, Sven Eckelmann wrote: > > > [1] > > > https://git.open-mesh.org/batman-adv.git/commit/fb7b5eb8c81969dc8bea356d > > > 0 > > > a3f0b5e72d2da49 > > > > Sven, what is the README there for ? > > It serves different purposes. It makes sure that the directory is created by > git on checkout even when there is no patch in the directory. It also makes > sure that the Makefile dependency glob for compat-patches/* is at least > generating one dependency. > > But it should also be used to define the rules under which a patch in this > directory is acceptable (of course, the rules are not yet defined - so I've > just used a placeholder for this draft). The requirements for such a patch > should be really high because patches tend to fail when the code or the > surrounding code is changed. This is also the reason why I've combined the > critical code to really small functions which avoids more patch chunks for > more places in the code. And maybe it should also describe how to generate patches for this directory git format-patch --abbrev=7 -U3 --diff-algorithm=histogram --no-signature --format=format:'From: %an <%ae>%nDate: %aD%nSubject: [PATCH] %B' -1 Kind regards, Sven
On Tuesday 01 March 2016 22:19:07 Andrew Lunn wrote: > batman-adv tries to prevent the user from placing a batX soft > interface into another batman mesh as a hard interface. It does this > by walking up the devices list of parents and ensures they are all > none batX interfaces. iflink can point to an interface in a different > namespace, so also retrieve the parents name space when finding the > parent and use it when doing the comparison. > > Signed-off-by: Andrew Lunn <andrew@lunn.ch> > Acked-by: Antonio Quartulli <a@untable.cc> > --- [...] > return (dev1_parent_iflink == dev2->ifindex) && > - (dev2_parent_iflink == dev1->ifindex); > + (dev2_parent_iflink == dev1->ifindex) && > + net_eq(dev1_parent_net, net2) && > + net_eq(dev2_parent_net, net1); > } Just spotted this: "(dev2_parent_iflink == dev1->ifindex) &&" and all following lines are not correctly aligned anymore (7 spaces vs 1 tab). [...] > + const struct net *dev1_parent_net = net1; > + const struct net *dev2_parent_net = net2; > + > + if (dev1->rtnl_link_ops && dev1->rtnl_link_ops->get_link_net) > + dev1_parent_net = dev1->rtnl_link_ops->get_link_net(dev1); > + if (dev2->rtnl_link_ops && dev2->rtnl_link_ops->get_link_net) > + dev2_parent_net = dev2->rtnl_link_ops->get_link_net(dev2); [...] > + struct net *parent_net = net; [...] > + if (net_dev->rtnl_link_ops && net_dev->rtnl_link_ops->get_link_net) > + parent_net = net_dev->rtnl_link_ops->get_link_net(net_dev); > + My proposal is there to move this in an extra function [1] so adding compat code is easier [2]. Already said this in an earlier mail but just for completeness: Include missing in net/batman-adv/hard-interface.c #include <net/rtnetlink.h> Kind regards, Sven [1] https://git.open-mesh.org/batman-adv.git/blob/aef6842ec0facda9ec52736f8a6ce8ca4110e91a:/net/batman-adv/hard-interface.c#l87 [2] https://git.open-mesh.org/batman-adv.git/blob/fb7b5eb8c81969dc8bea356d0a3f0b5e72d2da49:/compat-patches/0001-get_link_net.patch
> > + const struct net *dev1_parent_net = net1; > > + const struct net *dev2_parent_net = net2; > > + > > + if (dev1->rtnl_link_ops && dev1->rtnl_link_ops->get_link_net) > > + dev1_parent_net = dev1->rtnl_link_ops->get_link_net(dev1); > > + if (dev2->rtnl_link_ops && dev2->rtnl_link_ops->get_link_net) > > + dev2_parent_net = dev2->rtnl_link_ops->get_link_net(dev2); > [...] > > + struct net *parent_net = net; > [...] > > + if (net_dev->rtnl_link_ops && net_dev->rtnl_link_ops->get_link_net) > > + parent_net = net_dev->rtnl_link_ops->get_link_net(net_dev); > > + > > My proposal is there to move this in an extra function [1] so adding compat > code is easier [2]. Hi Sven Do you want to squash your compact changes in and add your own Signed-off-by? Andrew
On Sunday 13 March 2016 16:38:08 Andrew Lunn wrote: [...] > > My proposal is there to move this in an extra function [1] so adding > > compat > > code is easier [2]. [...] > Do you want to squash your compact changes in and add your own > Signed-off-by? You mean that I should finish the proposal [1] from Friday and resent it together with (slightly) polished versions of your patches? Yes, I can do that. Not sure if I will do it tonight or tomorrow. But you should see the new patches (v3) soon on the mailing list. Kind regards, Sven [1] https://lists.open-mesh.org/pipermail/b.a.t.m.a.n/2016-March/014661.html
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index b28eacc..51e9e68 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -85,24 +85,37 @@ out: /** * batadv_mutual_parents - check if two devices are each others parent - * @dev1: 1st net_device - * @dev2: 2nd net_device + * @dev1: 1st net dev + * @net1: 1st devices netns + * @dev2: 2nd net dev + * @net2: 2nd devices netns * * veth devices come in pairs and each is the parent of the other! * * Return: true if the devices are each others parent, otherwise false */ static bool batadv_mutual_parents(const struct net_device *dev1, - const struct net_device *dev2) + const struct net *net1, + const struct net_device *dev2, + const struct net *net2) { int dev1_parent_iflink = dev_get_iflink(dev1); int dev2_parent_iflink = dev_get_iflink(dev2); + const struct net *dev1_parent_net = net1; + const struct net *dev2_parent_net = net2; + + if (dev1->rtnl_link_ops && dev1->rtnl_link_ops->get_link_net) + dev1_parent_net = dev1->rtnl_link_ops->get_link_net(dev1); + if (dev2->rtnl_link_ops && dev2->rtnl_link_ops->get_link_net) + dev2_parent_net = dev2->rtnl_link_ops->get_link_net(dev2); if (!dev1_parent_iflink || !dev2_parent_iflink) return false; return (dev1_parent_iflink == dev2->ifindex) && - (dev2_parent_iflink == dev1->ifindex); + (dev2_parent_iflink == dev1->ifindex) && + net_eq(dev1_parent_net, net2) && + net_eq(dev2_parent_net, net1); } /** @@ -120,8 +133,9 @@ static bool batadv_mutual_parents(const struct net_device *dev1, */ static bool batadv_is_on_batman_iface(const struct net_device *net_dev) { - struct net_device *parent_dev; struct net *net = dev_net(net_dev); + struct net_device *parent_dev; + struct net *parent_net = net; bool ret; /* check if this is a batman-adv mesh interface */ @@ -133,13 +147,16 @@ static bool batadv_is_on_batman_iface(const struct net_device *net_dev) dev_get_iflink(net_dev) == net_dev->ifindex) return false; + if (net_dev->rtnl_link_ops && net_dev->rtnl_link_ops->get_link_net) + parent_net = net_dev->rtnl_link_ops->get_link_net(net_dev); + /* recurse over the parent device */ - parent_dev = __dev_get_by_index(net, dev_get_iflink(net_dev)); + parent_dev = __dev_get_by_index(parent_net, dev_get_iflink(net_dev)); /* if we got a NULL parent_dev there is something broken.. */ if (WARN(!parent_dev, "Cannot find parent device")) return false; - if (batadv_mutual_parents(net_dev, parent_dev)) + if (batadv_mutual_parents(net_dev, net, parent_dev, parent_net)) return false; ret = batadv_is_on_batman_iface(parent_dev);