Commit dd1b082f authored by Paolo Abeni's avatar Paolo Abeni
Browse files

Merge branch 'ipv4-convert-rtm_-new-del-addr-and-more-to-per-netns-rtnl'

Kuniyuki Iwashima says:

====================
ipv4: Convert RTM_{NEW,DEL}ADDR and more to per-netns RTNL.

The IPv4 address hash table and GC are already namespacified.

This series converts RTM_NEWADDR/RTM_DELADDR and some more
RTNL users to per-netns RTNL.

Changes:
  v2:
    * Add patch 1 to address sparse warning for CONFIG_DEBUG_NET_SMALL_RTNL=n
    * Add Eric's tags to patch 2-12

  v1: https://lore.kernel.org/netdev/20241018012225.90409-1-kuniyu@amazon.com/
====================

Link: https://patch.msgid.link/20241021183239.79741-1-kuniyu@amazon.com


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents ab101c55 7ed8da17
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -226,6 +226,10 @@ static __inline__ bool bad_mask(__be32 mask, __be32 addr)
	for (ifa = rtnl_dereference((in_dev)->ifa_list); ifa;	\
	     ifa = rtnl_dereference(ifa->ifa_next))

#define in_dev_for_each_ifa_rtnl_net(net, ifa, in_dev)			\
	for (ifa = rtnl_net_dereference(net, (in_dev)->ifa_list); ifa;	\
	     ifa = rtnl_net_dereference(net, ifa->ifa_next))

#define in_dev_for_each_ifa_rcu(ifa, in_dev)			\
	for (ifa = rcu_dereference((in_dev)->ifa_list); ifa;	\
	     ifa = rcu_dereference(ifa->ifa_next))
@@ -252,6 +256,11 @@ static inline struct in_device *__in_dev_get_rtnl(const struct net_device *dev)
	return rtnl_dereference(dev->ip_ptr);
}

static inline struct in_device *__in_dev_get_rtnl_net(const struct net_device *dev)
{
	return rtnl_net_dereference(dev_net(dev), dev->ip_ptr);
}

/* called with rcu_read_lock or rtnl held */
static inline bool ip_ignore_linkdown(const struct net_device *dev)
{
+11 −14
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ void __rtnl_net_lock(struct net *net);
void __rtnl_net_unlock(struct net *net);
void rtnl_net_lock(struct net *net);
void rtnl_net_unlock(struct net *net);
int rtnl_net_trylock(struct net *net);
int rtnl_net_lock_cmp_fn(const struct lockdep_map *a, const struct lockdep_map *b);

bool rtnl_net_is_locked(struct net *net);
@@ -132,26 +133,22 @@ static inline void rtnl_net_unlock(struct net *net)
	rtnl_unlock();
}

static inline void ASSERT_RTNL_NET(struct net *net)
{
	ASSERT_RTNL();
}

static inline void *rcu_dereference_rtnl_net(struct net *net, void *p)
static inline int rtnl_net_trylock(struct net *net)
{
	return rcu_dereference_rtnl(p);
	return rtnl_trylock();
}

static inline void *rtnl_net_dereference(struct net *net, void *p)
static inline void ASSERT_RTNL_NET(struct net *net)
{
	return rtnl_dereference(p);
	ASSERT_RTNL();
}

static inline void *rcu_replace_pointer_rtnl_net(struct net *net,
						 void *rp, void *p)
{
	return rcu_replace_pointer_rtnl(rp, p);
}
#define rcu_dereference_rtnl_net(net, p)		\
	rcu_dereference_rtnl(p)
#define rtnl_net_dereference(net, p)			\
	rtnl_dereference(p)
#define rcu_replace_pointer_rtnl_net(net, rp, p)	\
	rcu_replace_pointer_rtnl(rp, p)
#endif

static inline struct netdev_queue *dev_ingress_queue(struct net_device *dev)
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ typedef int (*rtnl_dumpit_func)(struct sk_buff *, struct netlink_callback *);

enum rtnl_link_flags {
	RTNL_FLAG_DOIT_UNLOCKED		= BIT(0),
#define RTNL_FLAG_DOIT_PERNET		RTNL_FLAG_DOIT_UNLOCKED
	RTNL_FLAG_BULK_DEL_SUPPORTED	= BIT(1),
	RTNL_FLAG_DUMP_UNLOCKED		= BIT(2),
	RTNL_FLAG_DUMP_SPLIT_NLM_DONE	= BIT(3),	/* legacy behavior */
+3 −3
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ int dev_ifconf(struct net *net, struct ifconf __user *uifc)
	}

	/* Loop over the interfaces, and write an info block for each. */
	rtnl_lock();
	rtnl_net_lock(net);
	for_each_netdev(net, dev) {
		if (!pos)
			done = inet_gifconf(dev, NULL, 0, size);
@@ -72,12 +72,12 @@ int dev_ifconf(struct net *net, struct ifconf __user *uifc)
			done = inet_gifconf(dev, pos + total,
					    len - total, size);
		if (done < 0) {
			rtnl_unlock();
			rtnl_net_unlock(net);
			return -EFAULT;
		}
		total += done;
	}
	rtnl_unlock();
	rtnl_net_unlock(net);

	return put_user(total, &uifc->ifc_len);
}
+11 −0
Original line number Diff line number Diff line
@@ -210,6 +210,17 @@ void rtnl_net_unlock(struct net *net)
}
EXPORT_SYMBOL(rtnl_net_unlock);

int rtnl_net_trylock(struct net *net)
{
	int ret = rtnl_trylock();

	if (ret)
		__rtnl_net_lock(net);

	return ret;
}
EXPORT_SYMBOL(rtnl_net_trylock);

static int rtnl_net_cmp_locks(const struct net *net_a, const struct net *net_b)
{
	if (net_eq(net_a, net_b))
Loading