From d0a781434cf6421c444d25ddf99f0b404e3a92a5 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Thu, 21 Jul 2016 11:14:13 -0700 Subject: [PATCH] datapath: remove flow_dissector flow_dissector was only built for Linux 3.8 and older. There is no need for this anymore, as anything older than 3.10 is no longer supported. Signed-off-by: Thadeu Lima de Souza Cascardo Acked-by: Pravin B Shelar --- datapath/linux/Modules.mk | 2 - datapath/linux/compat/flow_dissector.c | 236 ------------------ datapath/linux/compat/include/linux/skbuff.h | 20 -- datapath/linux/compat/include/net/flow_keys.h | 22 -- 4 files changed, 280 deletions(-) delete mode 100644 datapath/linux/compat/flow_dissector.c delete mode 100644 datapath/linux/compat/include/net/flow_keys.h diff --git a/datapath/linux/Modules.mk b/datapath/linux/Modules.mk index 7e114f008..8f30fe19e 100644 --- a/datapath/linux/Modules.mk +++ b/datapath/linux/Modules.mk @@ -2,7 +2,6 @@ openvswitch_sources += \ linux/compat/dev-openvswitch.c \ linux/compat/dst_cache.c \ linux/compat/exthdrs_core.c \ - linux/compat/flow_dissector.c \ linux/compat/geneve.c \ linux/compat/gre.c \ linux/compat/gso.c \ @@ -71,7 +70,6 @@ openvswitch_headers += \ linux/compat/include/net/dst.h \ linux/compat/include/net/dst_cache.h \ linux/compat/include/net/dst_metadata.h \ - linux/compat/include/net/flow_keys.h \ linux/compat/include/net/genetlink.h \ linux/compat/include/net/geneve.h \ linux/compat/include/net/gre.h \ diff --git a/datapath/linux/compat/flow_dissector.c b/datapath/linux/compat/flow_dissector.c deleted file mode 100644 index 3f42dba6c..000000000 --- a/datapath/linux/compat/flow_dissector.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (c) 2007-2013 Nicira, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA - * - * This code is derived from kernel flow_dissector.c - */ - -#include -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -/* copy saddr & daddr, possibly using 64bit load/store - * Equivalent to : flow->src = iph->saddr; - * flow->dst = iph->daddr; - */ -static void iph_to_flow_copy_addrs(struct flow_keys *flow, const struct iphdr *iph) -{ - BUILD_BUG_ON(offsetof(typeof(*flow), dst) != - offsetof(typeof(*flow), src) + sizeof(flow->src)); - memcpy(&flow->src, &iph->saddr, sizeof(flow->src) + sizeof(flow->dst)); -} - -static __be32 skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto) -{ - int poff = proto_ports_offset(ip_proto); - - if (poff >= 0) { - __be32 *ports, _ports; - - ports = skb_header_pointer(skb, thoff + poff, - sizeof(_ports), &_ports); - if (ports) - return *ports; - } - - return 0; -} - -static bool skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow) -{ - int nhoff = skb_network_offset(skb); - u8 ip_proto; - __be16 proto = skb->protocol; - - memset(flow, 0, sizeof(*flow)); - -again: - switch (proto) { - case __constant_htons(ETH_P_IP): { - const struct iphdr *iph; - struct iphdr _iph; -ip: - iph = skb_header_pointer(skb, nhoff, sizeof(_iph), &_iph); - if (!iph) - return false; - - if (ip_is_fragment(iph)) - ip_proto = 0; - else - ip_proto = iph->protocol; - iph_to_flow_copy_addrs(flow, iph); - nhoff += iph->ihl * 4; - break; - } - case __constant_htons(ETH_P_IPV6): { - const struct ipv6hdr *iph; - struct ipv6hdr _iph; -ipv6: - iph = skb_header_pointer(skb, nhoff, sizeof(_iph), &_iph); - if (!iph) - return false; - - ip_proto = iph->nexthdr; - flow->src = (__force __be32)ipv6_addr_hash(&iph->saddr); - flow->dst = (__force __be32)ipv6_addr_hash(&iph->daddr); - nhoff += sizeof(struct ipv6hdr); - break; - } - case __constant_htons(ETH_P_8021AD): - case __constant_htons(ETH_P_8021Q): { - const struct vlan_hdr *vlan; - struct vlan_hdr _vlan; - - vlan = skb_header_pointer(skb, nhoff, sizeof(_vlan), &_vlan); - if (!vlan) - return false; - - proto = vlan->h_vlan_encapsulated_proto; - nhoff += sizeof(*vlan); - goto again; - } - case __constant_htons(ETH_P_PPP_SES): { - struct { - struct pppoe_hdr hdr; - __be16 proto; - } *hdr, _hdr; - hdr = skb_header_pointer(skb, nhoff, sizeof(_hdr), &_hdr); - if (!hdr) - return false; - proto = hdr->proto; - nhoff += PPPOE_SES_HLEN; - switch (proto) { - case __constant_htons(PPP_IP): - goto ip; - case __constant_htons(PPP_IPV6): - goto ipv6; - default: - return false; - } - } - default: - return false; - } - - switch (ip_proto) { - case IPPROTO_GRE: { - struct gre_hdr { - __be16 flags; - __be16 proto; - } *hdr, _hdr; - - hdr = skb_header_pointer(skb, nhoff, sizeof(_hdr), &_hdr); - if (!hdr) - return false; - /* - * Only look inside GRE if version zero and no - * routing - */ - if (!(hdr->flags & (GRE_VERSION|GRE_ROUTING))) { - proto = hdr->proto; - nhoff += 4; - if (hdr->flags & GRE_CSUM) - nhoff += 4; - if (hdr->flags & GRE_KEY) - nhoff += 4; - if (hdr->flags & GRE_SEQ) - nhoff += 4; - if (proto == htons(ETH_P_TEB)) { - const struct ethhdr *eth; - struct ethhdr _eth; - - eth = skb_header_pointer(skb, nhoff, - sizeof(_eth), &_eth); - if (!eth) - return false; - proto = eth->h_proto; - nhoff += sizeof(*eth); - } - goto again; - } - break; - } - case IPPROTO_IPIP: - goto again; - case IPPROTO_IPV6: - proto = htons(ETH_P_IPV6); - goto ipv6; - default: - break; - } - - flow->ip_proto = ip_proto; - flow->ports = skb_flow_get_ports(skb, nhoff, ip_proto); - flow->thoff = (u16) nhoff; - - return true; -} - -static u32 hashrnd __read_mostly; -static __always_inline void __flow_hash_secret_init(void) -{ - net_get_random_once(&hashrnd, sizeof(hashrnd)); -} - -static __always_inline u32 __flow_hash_3words(u32 a, u32 b, u32 c) -{ - __flow_hash_secret_init(); - return jhash_3words(a, b, c, hashrnd); -} - -u32 rpl__skb_get_rxhash(struct sk_buff *skb) -{ - struct flow_keys keys; - u32 hash; - - if (!skb_flow_dissect(skb, &keys)) - return 0; - - /* get a consistent hash (same value on both flow directions) */ - if (((__force u32)keys.dst < (__force u32)keys.src) || - (((__force u32)keys.dst == (__force u32)keys.src) && - ((__force u16)keys.port16[1] < (__force u16)keys.port16[0]))) { - swap(keys.dst, keys.src); - swap(keys.port16[0], keys.port16[1]); - } - - hash = __flow_hash_3words((__force u32)keys.dst, - (__force u32)keys.src, - (__force u32)keys.ports); - if (!hash) - hash = 1; - -#ifdef HAVE_RXHASH - skb->rxhash = hash; -#endif - return hash; -} -EXPORT_SYMBOL_GPL(rpl__skb_get_rxhash); - -#endif diff --git a/datapath/linux/compat/include/linux/skbuff.h b/datapath/linux/compat/include/linux/skbuff.h index 4511ac002..ad5a5583a 100644 --- a/datapath/linux/compat/include/linux/skbuff.h +++ b/datapath/linux/compat/include/linux/skbuff.h @@ -209,27 +209,7 @@ static inline int skb_orphan_frags(struct sk_buff *skb, gfp_t gfp_mask) #endif #ifndef HAVE_SKB_GET_HASH -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) -#define __skb_get_hash rpl__skb_get_rxhash -#define skb_get_hash rpl_skb_get_rxhash - -extern u32 __skb_get_hash(struct sk_buff *skb); -static inline __u32 skb_get_hash(struct sk_buff *skb) -{ -#ifdef HAVE_RXHASH - if (skb->rxhash) -#ifndef HAVE_U16_RXHASH - return skb->rxhash; -#else - return jhash_1word(skb->rxhash, 0); -#endif -#endif - return __skb_get_hash(skb); -} - -#else #define skb_get_hash skb_get_rxhash -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) */ #endif /* HAVE_SKB_GET_HASH */ #if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) diff --git a/datapath/linux/compat/include/net/flow_keys.h b/datapath/linux/compat/include/net/flow_keys.h deleted file mode 100644 index 766b4b376..000000000 --- a/datapath/linux/compat/include/net/flow_keys.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _NET_FLOW_KEYS_WRAPPER_H -#define _NET_FLOW_KEYS_WRAPPER_H - -#include - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0) -#include_next -#else -struct flow_keys { - /* (src,dst) must be grouped, in the same way than in IP header */ - __be32 src; - __be32 dst; - union { - __be32 ports; - __be16 port16[2]; - }; - u16 thoff; - u8 ip_proto; -}; -#endif - -#endif -- 2.20.1