From: Jesse Gross Date: Tue, 2 Feb 2010 21:44:44 +0000 (-0500) Subject: gre: Unify IPTUNNEL_XMIT across kernel versions. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02059c09d4d7bc4860db9aee7f4daae43b6eab68;p=openvswitch gre: Unify IPTUNNEL_XMIT across kernel versions. The IPTUNNEL_XMIT macro was split into different versions based on the kernel. This adds the compatibility code to allow a single copy to work on all kernel versions, making it easier to maintain. --- diff --git a/datapath/linux-2.6/Modules.mk b/datapath/linux-2.6/Modules.mk index 8d2f9696..dafbcad7 100644 --- a/datapath/linux-2.6/Modules.mk +++ b/datapath/linux-2.6/Modules.mk @@ -52,6 +52,7 @@ dist_modules += ip_gre build_modules += $(if $(BUILD_GRE),ip_gre) ip_gre_sources = \ linux-2.6/compat-2.6/ip_gre.c \ + linux-2.6/compat-2.6/ip_output-ip_gre.c \ linux-2.6/compat-2.6/net_namespace-ip_gre.c ip_gre_headers = \ linux-2.6/compat-2.6/compat26.h \ @@ -66,6 +67,7 @@ ip_gre_headers = \ linux-2.6/compat-2.6/include/linux/tcp.h \ linux-2.6/compat-2.6/include/linux/types.h \ linux-2.6/compat-2.6/include/net/dst.h \ + linux-2.6/compat-2.6/include/net/ip.h \ linux-2.6/compat-2.6/include/net/ipip.h \ linux-2.6/compat-2.6/include/net/netns/generic.h \ linux-2.6/compat-2.6/include/net/net_namespace.h \ diff --git a/datapath/linux-2.6/compat-2.6/include/linux/netdevice.h b/datapath/linux-2.6/compat-2.6/include/linux/netdevice.h index c25f2bd0..0a0e47ab 100644 --- a/datapath/linux-2.6/compat-2.6/include/linux/netdevice.h +++ b/datapath/linux-2.6/compat-2.6/include/linux/netdevice.h @@ -63,6 +63,8 @@ typedef int netdev_tx_t; #define for_each_netdev(net,d) list_for_each_entry(d, &dev_base_head, dev_list) #endif - +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) +#define net_xmit_eval(e) ((e) == NET_XMIT_CN? 0 : (e)) +#endif #endif diff --git a/datapath/linux-2.6/compat-2.6/include/net/ip.h b/datapath/linux-2.6/compat-2.6/include/net/ip.h new file mode 100644 index 00000000..b18b968b --- /dev/null +++ b/datapath/linux-2.6/compat-2.6/include/net/ip.h @@ -0,0 +1,14 @@ +#ifndef __NET_IP_WRAPPER_H +#define __NET_IP_WRAPPER_H 1 + +#include_next + +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) + +extern int __ip_local_out(struct sk_buff *skb); +extern int ip_local_out(struct sk_buff *skb); + +#endif /* linux kernel < 2.6.25 */ + +#endif diff --git a/datapath/linux-2.6/compat-2.6/include/net/ipip.h b/datapath/linux-2.6/compat-2.6/include/net/ipip.h index 2eca5f8b..604ece2d 100644 --- a/datapath/linux-2.6/compat-2.6/include/net/ipip.h +++ b/datapath/linux-2.6/compat-2.6/include/net/ipip.h @@ -48,31 +48,11 @@ struct ip_tunnel_prl_entry spinlock_t lock; }; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) #define IPTUNNEL_XMIT() do { \ int err; \ int pkt_len = skb->len - skb_transport_offset(skb); \ \ skb->ip_summed = CHECKSUM_NONE; \ - iph->tot_len = htons(skb->len); \ - ip_select_ident(iph, &rt->u.dst, NULL); \ - ip_send_check(iph); \ - \ - err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev, dst_output);\ - if (err == NET_XMIT_SUCCESS || err == NET_XMIT_CN) { \ - stats->tx_bytes += pkt_len; \ - stats->tx_packets++; \ - } else { \ - stats->tx_errors++; \ - stats->tx_aborted_errors++; \ - } \ -} while (0) -#else -#define IPTUNNEL_XMIT() do { \ - int err; \ - int pkt_len = skb->len; \ - \ - skb->ip_summed = CHECKSUM_NONE; \ ip_select_ident(iph, &rt->u.dst, NULL); \ \ err = ip_local_out(skb); \ @@ -84,7 +64,6 @@ struct ip_tunnel_prl_entry stats->tx_aborted_errors++; \ } \ } while (0) -#endif #else #include_next diff --git a/datapath/linux-2.6/compat-2.6/ip_output-ip_gre.c b/datapath/linux-2.6/compat-2.6/ip_output-ip_gre.c new file mode 100644 index 00000000..a09fcbce --- /dev/null +++ b/datapath/linux-2.6/compat-2.6/ip_output-ip_gre.c @@ -0,0 +1,33 @@ +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) + +#include +#include + +int __ip_local_out(struct sk_buff *skb) +{ + struct iphdr *iph = ip_hdr(skb); + + iph->tot_len = htons(skb->len); + ip_send_check(iph); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) + return nf_hook(PF_INET, NF_IP_LOCAL_OUT, &skb, NULL, skb->dst->dev, + dst_output); +#else + return nf_hook(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, skb->dst->dev, + dst_output); +#endif /* kernel < 2.6.24 */ +} + +int ip_local_out(struct sk_buff *skb) +{ + int err; + + err = __ip_local_out(skb); + if (likely(err == 1)) + err = dst_output(skb); + + return err; +} + +#endif /* kernel < 2.6.25 */