Fix build issues with recent SNAT changes on older kernels.
authorJustin Pettit <jpettit@nicira.com>
Mon, 26 Jan 2009 21:42:16 +0000 (13:42 -0800)
committerJustin Pettit <jpettit@nicira.com>
Mon, 26 Jan 2009 21:42:16 +0000 (13:42 -0800)
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.

datapath/linux-2.6/compat-2.6/include/linux/netfilter_bridge.h [new file with mode: 0644]
datapath/linux-2.6/compat-2.6/include/linux/skbuff.h
datapath/nx_act_snat.c

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 (file)
index 0000000..1c8183c
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef __LINUX_NETFILTER_BRIDGE_WRAPPER_H
+#define __LINUX_NETFILTER_BRIDGE_WRAPPER_H
+
+#include_next <linux/netfilter_bridge.h>
+
+#include <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+
+#include <linux/if_vlan.h>
+#include <linux/if_pppox.h>
+
+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 
index 1464e728c23164f17742554673bc150be908cd3f..9d38c46d859b2d7db7540a8e94a633f964a919c0 100644 (file)
@@ -5,6 +5,49 @@
 
 #include <linux/version.h>
 
+#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. */
index ae56e931a695b87faaa50cd5369657be2dd72e39..c7705d4902068c9284661371071b417eebebdabf 100644 (file)
@@ -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);