[PATCH net 00/12] net: iflink and link-netnsid fixes
by Sabrina Dubroca
In a lot of places, we use this kind of comparison to detect if a
device has a lower link:
dev->ifindex != dev_get_iflink(dev)
This seems to be a leftover of the pre-netns days, when the ifindex
was unique over the whole system. Nowadays, with network namespaces,
it's very easy to create a device with the same ifindex as its lower
link:
ip netns add main
ip netns add peer
ip -net main link add dummy0 type dummy
ip -net main link add link dummy0 macvlan0 netns peer type macvlan
ip -net main link show type dummy
9: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop ...
ip -net peer link show type macvlan
9: macvlan0@if9: <BROADCAST,MULTICAST> mtu 1500 qdisc noop ...
To detect if a device has a lower link, we can simply check the
existence of the dev->netdev_ops->ndo_get_iflink operation, instead of
checking its return value. In particular, I attempted to fix one of
these checks in commit feadc4b6cf42 ("rtnetlink: always put IFLA_LINK
for links with a link-netnsid"), but this patch isn't correct, since
tunnel devices can export IFLA_LINK_NETNSID without IFLA_LINK. That
patch needs to be reverted.
This series will fix all those bogus comparisons, and export missing
IFLA_LINK_NETNSID attributes in bridge and ipv6 dumps.
ipvlan and geneve are also missing the get_link_net operation, so
userspace can't know when those device are cross-netns. There are a
couple of other device types that have an ndo_get_iflink op but no
get_link_net (virt_wifi, ipoib), and should probably also have a
get_link_net.
Sabrina Dubroca (12):
ipvlan: add get_link_net
geneve: add get_link_net
Revert "rtnetlink: always put IFLA_LINK for links with a link-netnsid"
rtnetlink: always put IFLA_LINK for links with ndo_get_iflink
bridge: always put IFLA_LINK for ports with ndo_get_iflink
bridge: advertise IFLA_LINK_NETNSID when dumping bridge ports
ipv6: always put IFLA_LINK for devices with ndo_get_iflink
ipv6: advertise IFLA_LINK_NETNSID when dumping ipv6 addresses
net: link_watch: fix operstate when the link has the same index as the
device
net: link_watch: fix detection of urgent events
batman-adv: fix iflink detection in batadv_is_on_batman_iface
batman-adv: fix detection of lower link in batadv_get_real_netdevice
drivers/net/can/vxcan.c | 2 +-
drivers/net/geneve.c | 8 ++++++++
drivers/net/ipvlan/ipvlan_main.c | 9 +++++++++
drivers/net/veth.c | 2 +-
include/net/rtnetlink.h | 4 ++++
net/batman-adv/hard-interface.c | 4 ++--
net/bridge/br_netlink.c | 4 +++-
net/core/link_watch.c | 4 ++--
net/core/rtnetlink.c | 25 ++++++++++++-------------
net/ipv6/addrconf.c | 11 ++++++++++-
10 files changed, 52 insertions(+), 21 deletions(-)
--
2.28.0
8 months, 3 weeks
[PATCH 4.9 0/2] batman-adv: Fixes for stable/linux-4.9.y
by Sven Eckelmann
Hi,
following two patches were backported "automatically" applied in
4.14.y, 4.19.y, 5.4.y, 5.10.y, 5.5.y and 5.16.y. But they failed
to apply cleanly in v4.9.y due to some changes in the patch context
and one missing function in the older batman-adv version.
These problems were now fixed manually.
Kind regards,
Sven
Sven Eckelmann (2):
batman-adv: Request iflink once in batadv-on-batadv check
batman-adv: Don't expect inter-netns unique iflink indices
net/batman-adv/hard-interface.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
--
2.30.2
10 months, 3 weeks
[PATCH net-next 00/10] net: Convert user to netif_rx(), part 3.
by Sebastian Andrzej Siewior
This is the third and last batch of converting netif_rx_ni() caller to
netif_rx(). The change making this possible is net-next and
netif_rx_ni() is a wrapper around netif_rx(). This is a clean up in
order to remove netif_rx_ni().
The micrel phy driver is patched twice within this series: the first is
is to replace netif_rx_ni() and second to move netif_rx() outside of the
IRQ-off section. It is probably simpler to keep it within this series.
Cc: Alexander Gordeev <agordeev(a)linux.ibm.com>
Cc: Alexandra Winter <wintera(a)linux.ibm.com>
Cc: Andrew Lunn <andrew(a)lunn.ch>
Cc: Antonio Quartulli <a(a)unstable.cc>
Cc: b.a.t.m.a.n(a)lists.open-mesh.org
Cc: Christian Borntraeger <borntraeger(a)linux.ibm.com>
Cc: Divya Koppera <Divya.Koppera(a)microchip.com>
Cc: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Cc: Heiko Carstens <hca(a)linux.ibm.com>
Cc: Heiner Kallweit <hkallweit1(a)gmail.com>
Cc: Johan Hedberg <johan.hedberg(a)gmail.com>
Cc: Jon Maloy <jmaloy(a)redhat.com>
Cc: linux-bluetooth(a)vger.kernel.org
Cc: linux-s390(a)vger.kernel.org
Cc: linux-staging(a)lists.linux.dev
Cc: Luiz Augusto von Dentz <luiz.dentz(a)gmail.com>
Cc: Marcel Holtmann <marcel(a)holtmann.org>
Cc: Marek Lindner <mareklindner(a)neomailbox.ch>
Cc: Remi Denis-Courmont <courmisch(a)gmail.com>
Cc: Russell King <linux(a)armlinux.org.uk>
Cc: Simon Wunderlich <sw(a)simonwunderlich.de>
Cc: Sven Eckelmann <sven(a)narfation.org>
Cc: Sven Schnelle <svens(a)linux.ibm.com>
Cc: tipc-discussion(a)lists.sourceforge.net
Cc: Vasily Gorbik <gor(a)linux.ibm.com>
Cc: Wenjia Zhang <wenjia(a)linux.ibm.com>
Cc: Ying Xue <ying.xue(a)windriver.com>
Sebastian
11 months
[PATCH 0/4] pull request for net-next: batman-adv 2022-03-02
by Simon Wunderlich
Hi Jakub, hi David,
here is a little cleanup pull request of batman-adv to go into net-next.
Please pull or let me know of any problem!
There might be a small merge conflict between the net and net-next pull
requests which I both send today, specifically those two commits:
* (batadv/net) 690bb6fb64f5 ("batman-adv: Request iflink once in batadv-on-batadv check")
* (batadv/net-next) 6ee3c393eeb7 ("batman-adv: Demote batadv-on-batadv skip error message")
They should be resolved like this:
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -167,13 +167,7 @@
return false;
/* recurse over the parent device */
-<<<<<<<
- parent_dev = __dev_get_by_index((struct net *)parent_net,
- dev_get_iflink(net_dev));
-=======
parent_dev = __dev_get_by_index((struct net *)parent_net, iflink);
- /* if we got a NULL parent_dev there is something broken.. */
->>>>>>>
if (!parent_dev) {
pr_warn("Cannot find parent device. Skipping batadv-on-batadv check for %s\n",
net_dev->name);
Thank you,
Simon
The following changes since commit e783362eb54cd99b2cac8b3a9aeac942e6f6ac07:
Linux 5.17-rc1 (2022-01-23 10:12:53 +0200)
are available in the Git repository at:
git://git.open-mesh.org/linux-merge.git tags/batadv-next-pullrequest-20220302
for you to fetch changes up to 6ee3c393eeb7d16a3c228c4fa23913b76c7e7df3:
batman-adv: Demote batadv-on-batadv skip error message (2022-03-02 09:00:17 +0100)
----------------------------------------------------------------
This cleanup patchset includes the following patches:
- bump version strings, by Simon Wunderlich
- Remove redundant 'flush_workqueue()' calls, by Christophe JAILLET
- Migrate to linux/container_of.h, by Sven Eckelmann
- Demote batadv-on-batadv skip error message, by Sven Eckelmann
----------------------------------------------------------------
Christophe JAILLET (1):
batman-adv: Remove redundant 'flush_workqueue()' calls
Simon Wunderlich (1):
batman-adv: Start new development cycle
Sven Eckelmann (2):
batman-adv: Migrate to linux/container_of.h
batman-adv: Demote batadv-on-batadv skip error message
net/batman-adv/bat_iv_ogm.c | 2 +-
net/batman-adv/bat_v_elp.c | 2 +-
net/batman-adv/bat_v_ogm.c | 2 +-
net/batman-adv/bridge_loop_avoidance.c | 1 +
net/batman-adv/distributed-arp-table.c | 2 +-
net/batman-adv/gateway_client.c | 1 +
net/batman-adv/hard-interface.c | 6 +++---
net/batman-adv/main.c | 2 +-
net/batman-adv/main.h | 2 +-
net/batman-adv/multicast.c | 1 +
net/batman-adv/network-coding.c | 2 +-
net/batman-adv/originator.c | 2 +-
net/batman-adv/send.c | 2 +-
net/batman-adv/soft-interface.c | 2 +-
net/batman-adv/tp_meter.c | 2 +-
net/batman-adv/translation-table.c | 2 +-
net/batman-adv/tvlv.c | 2 +-
17 files changed, 19 insertions(+), 16 deletions(-)
11 months
[PATCH 0/3] pull request for net: batman-adv 2022-03-02
by Simon Wunderlich
Hi David, hi Jakub,
here are some bugfixes for batman-adv which we would like to have integrated into net.
Please pull or let me know of any problem!
There might be a small merge conflict between the net and net-next pull
requests which I both send today, specifically those two commits:
* (batadv/net) 690bb6fb64f5 ("batman-adv: Request iflink once in batadv-on-batadv check")
* (batadv/net-next) 6ee3c393eeb7 ("batman-adv: Demote batadv-on-batadv skip error message")
They should be resolved like this:
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -167,13 +167,7 @@
return false;
/* recurse over the parent device */
-<<<<<<<
- parent_dev = __dev_get_by_index((struct net *)parent_net,
- dev_get_iflink(net_dev));
-=======
parent_dev = __dev_get_by_index((struct net *)parent_net, iflink);
- /* if we got a NULL parent_dev there is something broken.. */
->>>>>>>
if (!parent_dev) {
pr_warn("Cannot find parent device. Skipping batadv-on-batadv check for %s\n",
net_dev->name);
Thank you,
Simon
The following changes since commit e783362eb54cd99b2cac8b3a9aeac942e6f6ac07:
Linux 5.17-rc1 (2022-01-23 10:12:53 +0200)
are available in the Git repository at:
git://git.open-mesh.org/linux-merge.git tags/batadv-net-pullrequest-20220302
for you to fetch changes up to 6c1f41afc1dbe59d9d3c8bb0d80b749c119aa334:
batman-adv: Don't expect inter-netns unique iflink indices (2022-03-02 09:24:55 +0100)
----------------------------------------------------------------
Here are some batman-adv bugfixes:
- Remove redundant iflink requests, by Sven Eckelmann (2 patches)
- Don't expect inter-netns unique iflink indices, by Sven Eckelmann
----------------------------------------------------------------
Sven Eckelmann (3):
batman-adv: Request iflink once in batadv-on-batadv check
batman-adv: Request iflink once in batadv_get_real_netdevice
batman-adv: Don't expect inter-netns unique iflink indices
net/batman-adv/hard-interface.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
11 months
[PATCH] batman-adv: make mc_forwarding atomic
by Sven Eckelmann
From: Eric Dumazet <edumazet(a)google.com>
This fixes minor data-races in ip6_mc_input() and
batadv_mcast_mla_rtr_flags_softif_get_ipv6()
Signed-off-by: Eric Dumazet <edumazet(a)google.com>
Signed-off-by: David S. Miller <davem(a)davemloft.net>
[sven(a)narfation.org: Add ugly hack to get it building with old kernels]
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
net-next commit 145c7a793838 ("ipv6: make mc_forwarding atomic")
I didn't find a good way to handle this. So either we introduce the
auto-patch-before build stuff again or we allow minimal changes like this
which are not in sync with upstream.
I will try to have a look at ways how we can (with our build_tests):
* filter out everything with UGLY_HACK + everything between
UGLY_HACK_OLD + UGLY_HACK_STOP before comparing it with upstream
* have some automatic warning in case someone adds code to linux-merge.git
with UGLY_HACK in it
net/batman-adv/multicast.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index 1860de73..720c12c0 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -135,7 +135,11 @@ static u8 batadv_mcast_mla_rtr_flags_softif_get_ipv6(struct net_device *dev)
{
struct inet6_dev *in6_dev = __in6_dev_get(dev);
+#if LINUX_VERSION_IS_GEQ(5, 18, 0) // UGLY_HACK_NEW
+ if (in6_dev && atomic_read(&in6_dev->cnf.mc_forwarding))
+#else // UGLY_HACK_OLD
if (in6_dev && in6_dev->cnf.mc_forwarding)
+#endif // UGLY_HACK_STOP
return BATADV_NO_FLAGS;
else
return BATADV_MCAST_WANT_NO_RTR6;
--
2.30.2
11 months
[PATCH] batman-adv: Demote batadv-on-batadv skip error message
by Sven Eckelmann
The error message "Cannot find parent device" was shown for users of
macvtap (on batadv devices) whenever the macvtap was moved to a different
netns. This happens because macvtap doesn't provide an implementation for
rtnl_link_ops->get_link_net.
The situation for which this message is printed is actually not an error
but just a warning that the optional sanity check was skipped. So demote
the message from error to warning and adjust the text to better explain
what happened.
Reported-by: Leonardo Mörlein <freifunk(a)irrelefant.net>
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
net/batman-adv/hard-interface.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 59d19097..b25afc7f 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -165,9 +165,9 @@ static bool batadv_is_on_batman_iface(const struct net_device *net_dev)
/* recurse over the parent device */
parent_dev = __dev_get_by_index((struct net *)parent_net,
dev_get_iflink(net_dev));
- /* if we got a NULL parent_dev there is something broken.. */
if (!parent_dev) {
- pr_err("Cannot find parent device\n");
+ pr_warn("Cannot find parent device. Skipping batadv-on-batadv check for %s\n",
+ net_dev->name);
return false;
}
--
2.30.2
11 months
[PATCH maint 1/3] batman-adv: Request iflink once in batadv-on-batadv check
by Sven Eckelmann
There is no need to call dev_get_iflink multiple times for the same
net_device in batadv_is_on_batman_iface. And since some of the
.ndo_get_iflink callbacks are dynamic (for example via RCUs like in
vxcan_get_iflink), it could easily happen that the returned values are not
stable. The pre-checks before __dev_get_by_index are then of course bogus.
Fixes: 3d48811b27f5 ("batman-adv: prevent using any virtual device created on batman-adv as hard-interface")
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
net/batman-adv/hard-interface.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 59d19097..774a26c5 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -149,22 +149,23 @@ static bool batadv_is_on_batman_iface(const struct net_device *net_dev)
struct net *net = dev_net(net_dev);
struct net_device *parent_dev;
struct net *parent_net;
+ int iflink;
bool ret;
/* check if this is a batman-adv mesh interface */
if (batadv_softif_is_valid(net_dev))
return true;
+ iflink = dev_get_iflink(net_dev);
+
/* no more parents..stop recursion */
- if (dev_get_iflink(net_dev) == 0 ||
- dev_get_iflink(net_dev) == net_dev->ifindex)
+ if (iflink == 0 || iflink == net_dev->ifindex)
return false;
parent_net = batadv_getlink_net(net_dev, net);
/* recurse over the parent device */
- parent_dev = __dev_get_by_index((struct net *)parent_net,
- dev_get_iflink(net_dev));
+ parent_dev = __dev_get_by_index((struct net *)parent_net, iflink);
/* if we got a NULL parent_dev there is something broken.. */
if (!parent_dev) {
pr_err("Cannot find parent device\n");
--
2.30.2
11 months