Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 20453d88 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'possible_net_t'



Eric W. Biederman says:

====================
Introduce possible_net_t

The current usage of write_pnet and read_pnet is a little laborious and
error prone as you only notice if you failed to include them if are
compiling with network namespaces enabled.

possible_net_t remedies that by using a type that is 0 bytes when
network namespaces are disabled and can only be read and written to with
read_pnet and write_pnet.

Aka less work and safer for the same effect.

I kill hold_net and release_net first as are they are haven't been used
since 2008 and are noise at the points where write_pnet and read_pnet
are used.

I have folded in Eric Dumazets suggestions to improve the killing of
hold_net and release net.  And respon.  I had to respin anyway as
there was enough changes elsewhere in the tree the previous version
of these patches did not quite apply cleanly.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 6c7005f6 0c5c9fb5
Loading
Loading
Loading
Loading
+2 −7
Original line number Original line Diff line number Diff line
@@ -1721,9 +1721,7 @@ struct net_device {
	struct netpoll_info __rcu	*npinfo;
	struct netpoll_info __rcu	*npinfo;
#endif
#endif


#ifdef CONFIG_NET_NS
	possible_net_t			nd_net;
	struct net		*nd_net;
#endif


	/* mid-layer private */
	/* mid-layer private */
	union {
	union {
@@ -1863,10 +1861,7 @@ struct net *dev_net(const struct net_device *dev)
static inline
static inline
void dev_net_set(struct net_device *dev, struct net *net)
void dev_net_set(struct net_device *dev, struct net *net)
{
{
#ifdef CONFIG_NET_NS
	write_pnet(&dev->nd_net, net);
	release_net(dev->nd_net);
	dev->nd_net = hold_net(net);
#endif
}
}


static inline bool netdev_uses_dsa(struct net_device *dev)
static inline bool netdev_uses_dsa(struct net_device *dev)
+1 −3
Original line number Original line Diff line number Diff line
@@ -3183,10 +3183,8 @@ struct wiphy {
	const struct ieee80211_ht_cap *ht_capa_mod_mask;
	const struct ieee80211_ht_cap *ht_capa_mod_mask;
	const struct ieee80211_vht_cap *vht_capa_mod_mask;
	const struct ieee80211_vht_cap *vht_capa_mod_mask;


#ifdef CONFIG_NET_NS
	/* the network namespace this phy lives in currently */
	/* the network namespace this phy lives in currently */
	struct net *_net;
	possible_net_t _net;
#endif


#ifdef CONFIG_CFG80211_WEXT
#ifdef CONFIG_CFG80211_WEXT
	const struct iw_handler_def *wext;
	const struct iw_handler_def *wext;
+1 −8
Original line number Original line Diff line number Diff line
@@ -95,17 +95,10 @@ static inline void fib_rule_get(struct fib_rule *rule)
	atomic_inc(&rule->refcnt);
	atomic_inc(&rule->refcnt);
}
}


static inline void fib_rule_put_rcu(struct rcu_head *head)
{
	struct fib_rule *rule = container_of(head, struct fib_rule, rcu);
	release_net(rule->fr_net);
	kfree(rule);
}

static inline void fib_rule_put(struct fib_rule *rule)
static inline void fib_rule_put(struct fib_rule *rule)
{
{
	if (atomic_dec_and_test(&rule->refcnt))
	if (atomic_dec_and_test(&rule->refcnt))
		call_rcu(&rule->rcu, fib_rule_put_rcu);
		kfree_rcu(rule, rcu);
}
}


static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla)
static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla)
+1 −3
Original line number Original line Diff line number Diff line
@@ -92,9 +92,7 @@ struct genl_info {
	struct genlmsghdr *	genlhdr;
	struct genlmsghdr *	genlhdr;
	void *			userhdr;
	void *			userhdr;
	struct nlattr **	attrs;
	struct nlattr **	attrs;
#ifdef CONFIG_NET_NS
	possible_net_t		_net;
	struct net *		_net;
#endif
	void *			user_ptr[2];
	void *			user_ptr[2];
	struct sock *		dst_sk;
	struct sock *		dst_sk;
};
};
+1 −3
Original line number Original line Diff line number Diff line
@@ -76,9 +76,7 @@ struct inet_ehash_bucket {
 * ports are created in O(1) time?  I thought so. ;-)	-DaveM
 * ports are created in O(1) time?  I thought so. ;-)	-DaveM
 */
 */
struct inet_bind_bucket {
struct inet_bind_bucket {
#ifdef CONFIG_NET_NS
	possible_net_t		ib_net;
	struct net		*ib_net;
#endif
	unsigned short		port;
	unsigned short		port;
	signed char		fastreuse;
	signed char		fastreuse;
	signed char		fastreuseport;
	signed char		fastreuseport;
Loading