From: Justin Pettit Date: Mon, 13 Oct 2008 22:45:07 +0000 (-0700) Subject: Allow SNAT to build on older (2.6.15) and new (2.6.26) kernels. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96c809cc519201e40c5e0dbe8a73d4de806666a1;p=openvswitch Allow SNAT to build on older (2.6.15) and new (2.6.26) kernels. --- 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 index 00000000..b21c98d5 --- /dev/null +++ b/datapath/linux-2.6/compat-2.6/include/linux/if_arp.h @@ -0,0 +1,20 @@ +#ifndef __LINUX_IF_ARP_WRAPPER_H +#define __LINUX_IF_ARP_WRAPPER_H 1 + +#include_next + +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) + +#ifdef __KERNEL__ +#include + +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 index 00000000..ed8a5d94 --- /dev/null +++ b/datapath/linux-2.6/compat-2.6/include/linux/netfilter_ipv4.h @@ -0,0 +1,19 @@ +#ifndef __LINUX_NETFILTER_IPV4_WRAPPER_H +#define __LINUX_NETFILTER_IPV4_WRAPPER_H 1 + +#include_next + +#include +#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 diff --git a/datapath/nx_act_snat.c b/datapath/nx_act_snat.c index 0bb98e02..83d505fb 100644 --- a/datapath/nx_act_snat.c +++ b/datapath/nx_act_snat.c @@ -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); }