]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - net/ipv4/netfilter/nf_tables_ipv4.c
netfilter: nf_tables: add compatibility layer for x_tables
[karo-tx-linux.git] / net / ipv4 / netfilter / nf_tables_ipv4.c
index 23525c4c01928cd20ecc48b87c70d14732c42e6a..c61cffb9b76020091dfecd6236f835df56cffb5e 100644 (file)
@@ -15,6 +15,8 @@
 #include <linux/netfilter_ipv4.h>
 #include <net/netfilter/nf_tables.h>
 #include <net/ip.h>
+#include <net/net_namespace.h>
+#include <net/netfilter/nf_tables_ipv4.h>
 
 static unsigned int nft_ipv4_output(const struct nf_hook_ops *ops,
                                    struct sk_buff *skb,
@@ -22,6 +24,8 @@ static unsigned int nft_ipv4_output(const struct nf_hook_ops *ops,
                                    const struct net_device *out,
                                    int (*okfn)(struct sk_buff *))
 {
+       struct nft_pktinfo pkt;
+
        if (unlikely(skb->len < sizeof(struct iphdr) ||
                     ip_hdr(skb)->ihl < sizeof(struct iphdr) / 4)) {
                if (net_ratelimit())
@@ -29,8 +33,9 @@ static unsigned int nft_ipv4_output(const struct nf_hook_ops *ops,
                                "packet\n");
                return NF_ACCEPT;
        }
+       nft_set_pktinfo_ipv4(&pkt, ops, skb, in, out);
 
-       return nft_do_chain(ops, skb, in, out, okfn);
+       return nft_do_chain_pktinfo(&pkt, ops);
 }
 
 static struct nft_af_info nft_af_ipv4 __read_mostly = {
@@ -42,6 +47,21 @@ static struct nft_af_info nft_af_ipv4 __read_mostly = {
        },
 };
 
+
+static unsigned int
+nft_do_chain_ipv4(const struct nf_hook_ops *ops,
+                 struct sk_buff *skb,
+                 const struct net_device *in,
+                 const struct net_device *out,
+                 int (*okfn)(struct sk_buff *))
+{
+       struct nft_pktinfo pkt;
+
+       nft_set_pktinfo_ipv4(&pkt, ops, skb, in, out);
+
+       return nft_do_chain_pktinfo(&pkt, ops);
+}
+
 static struct nf_chain_type filter_ipv4 = {
        .family         = NFPROTO_IPV4,
        .name           = "filter",
@@ -52,11 +72,11 @@ static struct nf_chain_type filter_ipv4 = {
                          (1 << NF_INET_PRE_ROUTING) |
                          (1 << NF_INET_POST_ROUTING),
        .fn             = {
-               [NF_INET_LOCAL_IN]      = nft_do_chain,
-               [NF_INET_LOCAL_OUT]     = nft_do_chain,
-               [NF_INET_FORWARD]       = nft_do_chain,
-               [NF_INET_PRE_ROUTING]   = nft_do_chain,
-               [NF_INET_POST_ROUTING]  = nft_do_chain,
+               [NF_INET_LOCAL_IN]      = nft_do_chain_ipv4,
+               [NF_INET_LOCAL_OUT]     = nft_ipv4_output,
+               [NF_INET_FORWARD]       = nft_do_chain_ipv4,
+               [NF_INET_PRE_ROUTING]   = nft_do_chain_ipv4,
+               [NF_INET_POST_ROUTING]  = nft_do_chain_ipv4,
        },
 };