#include <linux/init.h>
 #include <linux/skbuff.h>
 #include <linux/net.h>
-#include <linux/netdevice.h>
 #include <linux/if.h>
 #include <linux/in.h>
 #include <linux/in6.h>
 #include <linux/wait.h>
 #include <linux/list.h>
-#include <net/net_namespace.h>
 #endif
 #include <linux/types.h>
 #include <linux/compiler.h>
 static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {}
 #endif
 
-static inline struct net *nf_pre_routing_net(const struct net_device *in,
-                                            const struct net_device *out)
-{
-#ifdef CONFIG_NET_NS
-       return in->nd_net;
-#else
-       return &init_net;
-#endif
-}
-
-static inline struct net *nf_local_in_net(const struct net_device *in,
-                                         const struct net_device *out)
-{
-#ifdef CONFIG_NET_NS
-       return in->nd_net;
-#else
-       return &init_net;
-#endif
-}
-
-static inline struct net *nf_forward_net(const struct net_device *in,
-                                        const struct net_device *out)
-{
-#ifdef CONFIG_NET_NS
-       BUG_ON(in->nd_net != out->nd_net);
-       return in->nd_net;
-#else
-       return &init_net;
-#endif
-}
-
-static inline struct net *nf_local_out_net(const struct net_device *in,
-                                          const struct net_device *out)
-{
-#ifdef CONFIG_NET_NS
-       return out->nd_net;
-#else
-       return &init_net;
-#endif
-}
-
-static inline struct net *nf_post_routing_net(const struct net_device *in,
-                                             const struct net_device *out)
-{
-#ifdef CONFIG_NET_NS
-       return out->nd_net;
-#else
-       return &init_net;
-#endif
-}
-
 #endif /*__KERNEL__*/
 #endif /*__LINUX_NETFILTER_H*/
 
                  int (*okfn)(struct sk_buff *))
 {
        return ipt_do_table(skb, hook, in, out,
-                           nf_local_in_net(in, out)->ipv4.iptable_filter);
+                           dev_net(in)->ipv4.iptable_filter);
 }
 
 static unsigned int
         int (*okfn)(struct sk_buff *))
 {
        return ipt_do_table(skb, hook, in, out,
-                           nf_forward_net(in, out)->ipv4.iptable_filter);
+                           dev_net(in)->ipv4.iptable_filter);
 }
 
 static unsigned int
        }
 
        return ipt_do_table(skb, hook, in, out,
-                           nf_local_out_net(in, out)->ipv4.iptable_filter);
+                           dev_net(out)->ipv4.iptable_filter);
 }
 
 static struct nf_hook_ops ipt_ops[] __read_mostly = {
 
                     int (*okfn)(struct sk_buff *))
 {
        return ipt_do_table(skb, hook, in, out,
-                           nf_pre_routing_net(in, out)->ipv4.iptable_mangle);
+                           dev_net(in)->ipv4.iptable_mangle);
 }
 
 static unsigned int
                      int (*okfn)(struct sk_buff *))
 {
        return ipt_do_table(skb, hook, in, out,
-                           nf_post_routing_net(in, out)->ipv4.iptable_mangle);
+                           dev_net(out)->ipv4.iptable_mangle);
 }
 
 static unsigned int
                  int (*okfn)(struct sk_buff *))
 {
        return ipt_do_table(skb, hook, in, out,
-                           nf_local_in_net(in, out)->ipv4.iptable_mangle);
+                           dev_net(in)->ipv4.iptable_mangle);
 }
 
 static unsigned int
         int (*okfn)(struct sk_buff *))
 {
        return ipt_do_table(skb, hook, in, out,
-                           nf_forward_net(in, out)->ipv4.iptable_mangle);
+                           dev_net(in)->ipv4.iptable_mangle);
 }
 
 static unsigned int
        tos = iph->tos;
 
        ret = ipt_do_table(skb, hook, in, out,
-                          nf_local_out_net(in, out)->ipv4.iptable_mangle);
+                          dev_net(out)->ipv4.iptable_mangle);
        /* Reroute for ANY change. */
        if (ret != NF_DROP && ret != NF_STOLEN && ret != NF_QUEUE) {
                iph = ip_hdr(skb);
 
         int (*okfn)(struct sk_buff *))
 {
        return ipt_do_table(skb, hook, in, out,
-                           nf_pre_routing_net(in, out)->ipv4.iptable_raw);
+                           dev_net(in)->ipv4.iptable_raw);
 }
 
 static unsigned int
                return NF_ACCEPT;
        }
        return ipt_do_table(skb, hook, in, out,
-                           nf_local_out_net(in, out)->ipv4.iptable_raw);
+                           dev_net(out)->ipv4.iptable_raw);
 }
 
 /* 'raw' is the very first table. */
 
                  int (*okfn)(struct sk_buff *))
 {
        return ipt_do_table(skb, hook, in, out,
-                           nf_local_in_net(in, out)->ipv4.iptable_security);
+                           dev_net(in)->ipv4.iptable_security);
 }
 
 static unsigned int
                 int (*okfn)(struct sk_buff *))
 {
        return ipt_do_table(skb, hook, in, out,
-                           nf_forward_net(in, out)->ipv4.iptable_security);
+                           dev_net(in)->ipv4.iptable_security);
 }
 
 static unsigned int
                return NF_ACCEPT;
        }
        return ipt_do_table(skb, hook, in, out,
-                           nf_local_out_net(in, out)->ipv4.iptable_security);
+                           dev_net(out)->ipv4.iptable_security);
 }
 
 static struct nf_hook_ops ipt_ops[] __read_mostly = {
 
                   int (*okfn)(struct sk_buff *))
 {
        return ip6t_do_table(skb, hook, in, out,
-                            nf_local_in_net(in, out)->ipv6.ip6table_filter);
+                            dev_net(in)->ipv6.ip6table_filter);
 }
 
 static unsigned int
                  int (*okfn)(struct sk_buff *))
 {
        return ip6t_do_table(skb, hook, in, out,
-                            nf_forward_net(in, out)->ipv6.ip6table_filter);
+                            dev_net(in)->ipv6.ip6table_filter);
 }
 
 static unsigned int
 #endif
 
        return ip6t_do_table(skb, hook, in, out,
-                            nf_local_out_net(in, out)->ipv6.ip6table_filter);
+                            dev_net(out)->ipv6.ip6table_filter);
 }
 
 static struct nf_hook_ops ip6t_ops[] __read_mostly = {
 
                   int (*okfn)(struct sk_buff *))
 {
        return ip6t_do_table(skb, hook, in, out,
-                            nf_local_in_net(in, out)->ipv6.ip6table_security);
+                            dev_net(in)->ipv6.ip6table_security);
 }
 
 static unsigned int
                  int (*okfn)(struct sk_buff *))
 {
        return ip6t_do_table(skb, hook, in, out,
-                            nf_forward_net(in, out)->ipv6.ip6table_security);
+                            dev_net(in)->ipv6.ip6table_security);
 }
 
 static unsigned int
 {
        /* TBD: handle short packets via raw socket */
        return ip6t_do_table(skb, hook, in, out,
-                            nf_local_out_net(in, out)->ipv6.ip6table_security);
+                            dev_net(out)->ipv6.ip6table_security);
 }
 
 static struct nf_hook_ops ip6t_ops[] __read_mostly = {