Allow SNAT to build on older (2.6.15) and new (2.6.26) kernels.
authorJustin Pettit <jpettit@nicira.com>
Mon, 13 Oct 2008 22:45:07 +0000 (15:45 -0700)
committerJustin Pettit <jpettit@nicira.com>
Mon, 13 Oct 2008 22:45:07 +0000 (15:45 -0700)
datapath/linux-2.6/compat-2.6/include/linux/if_arp.h [new file with mode: 0644]
datapath/linux-2.6/compat-2.6/include/linux/netfilter_ipv4.h [new file with mode: 0644]
datapath/nx_act_snat.c

diff --git a/datapath/linux-2.6/compat-2.6/include/linux/if_arp.h b/datapath/linux-2.6/compat-2.6/include/linux/if_arp.h
new file mode 100644 (file)
index 0000000..b21c98d
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef __LINUX_IF_ARP_WRAPPER_H
+#define __LINUX_IF_ARP_WRAPPER_H 1
+
+#include_next <linux/if_arp.h>
+
+#include <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+
+#ifdef __KERNEL__
+#include <linux/skbuff.h>
+
+static inline struct arphdr *arp_hdr(const struct sk_buff *skb)
+{
+       return (struct arphdr *)skb_network_header(skb);
+}
+#endif /* __KERNEL__ */
+
+#endif /* linux kernel < 2.6.22 */
+
+#endif
diff --git a/datapath/linux-2.6/compat-2.6/include/linux/netfilter_ipv4.h b/datapath/linux-2.6/compat-2.6/include/linux/netfilter_ipv4.h
new file mode 100644 (file)
index 0000000..ed8a5d9
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef __LINUX_NETFILTER_IPV4_WRAPPER_H
+#define __LINUX_NETFILTER_IPV4_WRAPPER_H 1
+
+#include_next <linux/netfilter_ipv4.h>
+
+#include <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
+
+#ifdef __KERNEL__
+
+#define NF_INET_PRE_ROUTING NF_IP_PRE_ROUTING
+#define NF_INET_POST_ROUTING NF_IP_POST_ROUTING
+#define NF_INET_FORWARD NF_IP_FORWARD
+
+#endif /* __KERNEL__ */
+
+#endif /* linux kernel < 2.6.25 */
+
+#endif
index 0bb98e02a80dab9b8750d6f3926ae59bf6cdd498..83d505fbde0c59893df1df38ef564f1332dc023f 100644 (file)
@@ -311,7 +311,7 @@ snat_pre_route(struct sk_buff *skb)
        skb->dst = (struct dst_entry *)&__fake_rtable;
        dst_hold(skb->dst);
 
-       return NF_HOOK(PF_INET, NF_IP_PRE_ROUTING, skb, skb->dev, NULL,
+       return NF_HOOK(PF_INET, NF_INET_PRE_ROUTING, skb, skb->dev, NULL,
                        snat_pre_route_finish);
 
 ipv4_error:
@@ -322,7 +322,7 @@ ipv4_error:
 static int 
 snat_skb_finish(struct sk_buff *skb)
 {
-       NF_HOOK(PF_INET, NF_IP_POST_ROUTING, skb, NULL, skb->dev, 
+       NF_HOOK(PF_INET, NF_INET_POST_ROUTING, skb, NULL, skb->dev, 
                        dp_xmit_skb_push);
 
        return 0;
@@ -398,7 +398,7 @@ snat_skb(struct datapath *dp, struct sk_buff *skb, int out_port)
        /* Take the Ethernet header back off for netfilter hooks. */
        skb_pull(nskb, ETH_HLEN);
 
-       NF_HOOK(PF_INET, NF_IP_FORWARD, nskb, skb->dev, nskb->dev, 
+       NF_HOOK(PF_INET, NF_INET_FORWARD, nskb, skb->dev, nskb->dev, 
                        snat_skb_finish);
 }