Thread (29 messages) 29 messages, 3 authors, 2019-03-27

Re: [PATCH net-next 02/13] ipv4: Move IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN to helper

From: Ido Schimmel <hidden>
Date: 2019-03-27 07:44:48

On Tue, Mar 26, 2019 at 08:29:31PM -0700, David Ahern wrote:
From: David Ahern <redacted>

in_dev lookup followed by IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN check
is called in several places, some with the rcu lock and others with the
rtnl held.

Move the check to a helper similar to what IPv6 has. Since the helper
can be invoked from either context use rcu_dereference_rtnl to
dereference ip_ptr.

Signed-off-by: David Ahern <redacted>
Reviewed-by: Ido Schimmel <redacted>

See one nit below.
quoted hunk ↗ jump to hunk
---
 include/linux/inetdevice.h | 14 ++++++++++++++
 net/ipv4/fib_semantics.c   | 31 +++++++------------------------
 net/ipv4/fib_trie.c        |  4 +---
 3 files changed, 22 insertions(+), 27 deletions(-)
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
index a64f21a97369..35e0390fd7b8 100644
--- a/include/linux/inetdevice.h
+++ b/include/linux/inetdevice.h
@@ -237,6 +237,20 @@ static inline struct in_device *__in_dev_get_rtnl(const struct net_device *dev)
 	return rtnl_dereference(dev->ip_ptr);
 }
 
+/* called with rc_read_lock or rtnl held */
s/rc_read_lock/rcu_read_lock/
+static inline bool ip_ignore_linkdown(const struct net_device *dev)
+{
+	struct in_device *in_dev;
+	bool rc = false;
+
+	in_dev = rcu_dereference_rtnl(dev->ip_ptr);
+	if (in_dev &&
+	    IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN(in_dev))
+		rc = true;
+
+	return rc;
+}
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help