Skip to contentSkip to conversation

neighbour: always have struct net pointer in struct neigh_parms

PATCH In review Jiri Pirko 2 participants 3 messages Dec 10, 2013

Subsystems (2)
lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

PATCH 1/1 neighbour: always have struct net pointer in struct neigh_parms

This fixes compile error when CONFIG_NET_NS is not set.

Introduced by:
commit 1d4c8c29841b9991cdf3c7cc4ba7f96a94f104ca
"neigh: restore old behaviour of default parms values"

---
 include/net/neighbour.h | 2 --
 1 file changed, 2 deletions(-)
include/net/neighbour.h +0 -2
index 41b1ce6..157c038 100644
@@ -65,9 +65,7 @@ enum {
 };
 
 struct neigh_parms {
-#ifdef CONFIG_NET_NS
 	struct net *net;
-#endif
 	struct net_device *dev;
 	struct neigh_parms *next;
 	int	(*neigh_setup)(struct neighbour *);
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw

From: Jiri Pirko <[email protected]>
Date: Tue, 10 Dec 2013 08:44:57 +0100

Quoted 7 lines

This fixes compile error when CONFIG_NET_NS is not set.

Introduced by:
commit 1d4c8c29841b9991cdf3c7cc4ba7f96a94f104ca
"neigh: restore old behaviour of default parms values"

Jiri please don't fix things this way.

When network name spaces are disabled, you're supposed to abstract all of this stuff away behind accessor macros so that it is truly zero cost.

For example, look at how "dev_net()" and related helpers works.

This means you need to do something like:

/*
* Net namespace inlines
*/
static inline
struct net *neigh_parms_net(const struct neigh_parms *np)

{
	return read_pnet(&np->net);
}

static inline
void neigh_parms_net_set(struct neigh_parms *np, struct net *net) {

#ifdef CONFIG_NET_NS
	release_net(np->net);
	np->net = hold_net(net);

#endif
}

And then use these helpers consistently in your new code.

Thanks.

author
#2 lore raw
Quoted 33 lines · Tue, Dec 10, 2013 at 08:45:38PM CET, [email protected] wrote:

From: Jiri Pirko <[email protected]>
Date: Tue, 10 Dec 2013 08:44:57 +0100

Quoted 7 lines

This fixes compile error when CONFIG_NET_NS is not set.

Introduced by:
commit 1d4c8c29841b9991cdf3c7cc4ba7f96a94f104ca
"neigh: restore old behaviour of default parms values"

Jiri please don't fix things this way.

When network name spaces are disabled, you're supposed to abstract all of this stuff away behind accessor macros so that it is truly zero cost.

For example, look at how "dev_net()" and related helpers works.

This means you need to do something like:

/*
* Net namespace inlines
*/
static inline
struct net *neigh_parms_net(const struct neigh_parms *np)

{
	return read_pnet(&np->net);
}

static inline
void neigh_parms_net_set(struct neigh_parms *np, struct net *net) {

Quoted 7 lines
#ifdef CONFIG_NET_NS
	release_net(np->net);
	np->net = hold_net(net);

#endif
}

And then use these helpers consistently in your new code.

Will do. Thanks.

Quoted 2 lines

Thanks.