diff options
author | Dominik Sliwa <dominik.sliwa@toradex.com> | 2017-07-02 16:41:37 +0200 |
---|---|---|
committer | Dominik Sliwa <dominik.sliwa@toradex.com> | 2017-07-02 16:41:37 +0200 |
commit | 52409fae3e4b8d16b68b61902fc09075cd97b75d (patch) | |
tree | e67110145c5843b3f199d872ae285e2546c9ebe2 /backport-include/net/net_namespace.h |
Backports generated from 4.11 kernel
Initial commit.
Signed-off-by: Dominik Sliwa <dominik.sliwa@toradex.com>
Diffstat (limited to 'backport-include/net/net_namespace.h')
-rw-r--r-- | backport-include/net/net_namespace.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/backport-include/net/net_namespace.h b/backport-include/net/net_namespace.h new file mode 100644 index 0000000..1e84297 --- /dev/null +++ b/backport-include/net/net_namespace.h @@ -0,0 +1,44 @@ +#ifndef _COMPAT_NET_NET_NAMESPACE_H +#define _COMPAT_NET_NET_NAMESPACE_H 1 + +#include_next <net/net_namespace.h> + +#if LINUX_VERSION_IS_LESS(3,20,0) +/* + * In older kernels we simply fail this function. + */ +#define get_net_ns_by_fd LINUX_BACKPORT(get_net_ns_by_fd) +static inline struct net *get_net_ns_by_fd(int fd) +{ + return ERR_PTR(-EINVAL); +} +#endif + +#if LINUX_VERSION_IS_LESS(4,1,0) +typedef struct { +#ifdef CONFIG_NET_NS + struct net *net; +#endif +} possible_net_t; + +static inline void possible_write_pnet(possible_net_t *pnet, struct net *net) +{ +#ifdef CONFIG_NET_NS + pnet->net = net; +#endif +} + +static inline struct net *possible_read_pnet(const possible_net_t *pnet) +{ +#ifdef CONFIG_NET_NS + return pnet->net; +#else + return &init_net; +#endif +} +#else +#define possible_write_pnet(pnet, net) write_pnet(pnet, net) +#define possible_read_pnet(pnet) read_pnet(pnet) +#endif /* LINUX_VERSION_IS_LESS(4,1,0) */ + +#endif /* _COMPAT_NET_NET_NAMESPACE_H */ |