Message ID | 1423100070-31848-3-git-send-email-dsahern@gmail.com |
---|---|
State | RFC, archived |
Delegated to: | David Miller |
Headers | show |
Le 05/02/2015 02:34, David Ahern a écrit : > +static inline > +int dev_net_ctx_eq(const struct net_device *dev, struct net_ctx *ctx) > +{ > + if (net_eq(dev_net(dev), ctx->net)) > + return 1; Why not using net_ctx_eq()? -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 2/5/15 6:47 AM, Nicolas Dichtel wrote: > Le 05/02/2015 02:34, David Ahern a écrit : >> +static inline >> +int dev_net_ctx_eq(const struct net_device *dev, struct net_ctx *ctx) >> +{ >> + if (net_eq(dev_net(dev), ctx->net)) >> + return 1; > Why not using net_ctx_eq()? right, will change it. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 16251e96e6aa..55a221fec12b 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1697,9 +1697,8 @@ struct net_device { struct netpoll_info __rcu *npinfo; #endif -#ifdef CONFIG_NET_NS - struct net *nd_net; -#endif + struct net_ctx net_ctx; +#define nd_net net_ctx.net /* mid-layer private */ union { @@ -1845,6 +1844,18 @@ void dev_net_set(struct net_device *dev, struct net *net) #endif } +/* get net_ctx from device */ +#define DEV_NET_CTX(dev) { .net = dev_net((dev)) } + +static inline +int dev_net_ctx_eq(const struct net_device *dev, struct net_ctx *ctx) +{ + if (net_eq(dev_net(dev), ctx->net)) + return 1; + + return 0; +} + static inline bool netdev_uses_dsa(struct net_device *dev) { #if IS_ENABLED(CONFIG_NET_DSA)
Enhances a net_device from the current namespace only assignment to a network context. Define nd_net macro to handle existing code references. Add macros for generating net_ctx struct given a net_device (needed because of the way net references are done) and for comparing a given net_ctx struct to the context of a net_device. Signed-off-by: David Ahern <dsahern@gmail.com> --- include/linux/netdevice.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)