From: Justin Pettit Date: Mon, 26 Jan 2009 21:42:16 +0000 (-0800) Subject: Fix build issues with recent SNAT changes on older kernels. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a06668332987db3837a8d1a1579adb27d93345e5;p=openvswitch Fix build issues with recent SNAT changes on older kernels. Recent changes that fixed fragmented packets for SNAT-enabled builds used calls not implemented in older kernels. These changes add those calls to the compatibility layer and clean up a few warnings in those older kernel builds. --- diff --git a/datapath/linux-2.6/compat-2.6/include/linux/netfilter_bridge.h b/datapath/linux-2.6/compat-2.6/include/linux/netfilter_bridge.h new file mode 100644 index 00000000..1c8183c8 --- /dev/null +++ b/datapath/linux-2.6/compat-2.6/include/linux/netfilter_bridge.h @@ -0,0 +1,24 @@ +#ifndef __LINUX_NETFILTER_BRIDGE_WRAPPER_H +#define __LINUX_NETFILTER_BRIDGE_WRAPPER_H + +#include_next + +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) + +#include +#include + +static inline unsigned int nf_bridge_encap_header_len(const struct sk_buff *skb) +{ + switch (skb->protocol) { + case __constant_htons(ETH_P_8021Q): + return VLAN_HLEN; + default: + return 0; + } +} + +#endif /* linux version < 2.6.22 */ + +#endif diff --git a/datapath/linux-2.6/compat-2.6/include/linux/skbuff.h b/datapath/linux-2.6/compat-2.6/include/linux/skbuff.h index 1464e728..9d38c46d 100644 --- a/datapath/linux-2.6/compat-2.6/include/linux/skbuff.h +++ b/datapath/linux-2.6/compat-2.6/include/linux/skbuff.h @@ -5,6 +5,49 @@ #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) +static inline void skb_copy_from_linear_data_offset(const struct sk_buff *skb, + const int offset, void *to, + const unsigned int len) +{ + memcpy(to, skb->data + offset, len); +} + +static inline void skb_copy_to_linear_data_offset(struct sk_buff *skb, + const int offset, + const void *from, + const unsigned int len) +{ + memcpy(skb->data + offset, from, len); +} + +#endif /* linux < 2.6.22 */ + + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23) +static inline int __skb_cow(struct sk_buff *skb, unsigned int headroom, + int cloned) +{ + int delta = 0; + + if (headroom < NET_SKB_PAD) + headroom = NET_SKB_PAD; + if (headroom > skb_headroom(skb)) + delta = headroom - skb_headroom(skb); + + if (delta || cloned) + return pskb_expand_head(skb, ALIGN(delta, NET_SKB_PAD), 0, + GFP_ATOMIC); + return 0; +} + +static inline int skb_cow_head(struct sk_buff *skb, unsigned int headroom) +{ + return __skb_cow(skb, headroom, skb_header_cloned(skb)); +} +#endif /* linux < 2.6.23 */ + + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17) /* Emulate Linux 2.6.17 and later behavior, in which kfree_skb silently ignores * null pointer arguments. */ diff --git a/datapath/nx_act_snat.c b/datapath/nx_act_snat.c index ae56e931..c7705d49 100644 --- a/datapath/nx_act_snat.c +++ b/datapath/nx_act_snat.c @@ -351,14 +351,14 @@ handle_icmp_snat(struct sk_buff *skb) tmp_ip = iph->daddr; iph->daddr = iph->saddr; iph->saddr = tmp_ip; - iph->check = ip_fast_csum(iph, iph->ihl); + iph->check = ip_fast_csum((void *)iph, iph->ihl); /* Update ICMP header. */ icmph = icmp_hdr(nskb); icmph->type = ICMP_ECHOREPLY; icmph->checksum = 0; - icmph->checksum = ip_compute_csum(icmph, - nskb->tail - nskb->transport_header); + icmph->checksum = ip_compute_csum((void *)icmph, + nskb->tail - skb_transport_header(nskb)); dp_xmit_skb_push(nskb); @@ -405,7 +405,7 @@ snat_pre_route(struct sk_buff *skb) goto consume; iph = ip_hdr(skb); - if (unlikely(ip_fast_csum(iph, iph->ihl))) + if (unlikely(ip_fast_csum((void *)iph, iph->ihl))) goto consume; len = ntohs(iph->tot_len);