From patchwork Thu Jul 21 18:14:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thadeu Lima de Souza Cascardo X-Patchwork-Id: 651357 X-Patchwork-Delegate: pshelar@ovn.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3rwMPk3MpLz9sxS for ; Fri, 22 Jul 2016 04:14:50 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 870B210C52; Thu, 21 Jul 2016 11:14:37 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 26E1610C47 for ; Thu, 21 Jul 2016 11:14:35 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id B2C7F1611FA for ; Thu, 21 Jul 2016 12:14:34 -0600 (MDT) X-ASG-Debug-ID: 1469124873-0b323745292173a0001-byXFYA Received: from mx3-pf2.cudamail.com ([192.168.14.1]) by bar6.cudamail.com with ESMTP id Kq1FlPSGsLk2Gjwu (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 21 Jul 2016 12:14:33 -0600 (MDT) X-Barracuda-Envelope-From: cascardo@redhat.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.1 Received: from unknown (HELO mx1.redhat.com) (209.132.183.28) by mx3-pf2.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 21 Jul 2016 18:14:33 -0000 Received-SPF: pass (mx3-pf2.cudamail.com: SPF record at _spf1.redhat.com designates 209.132.183.28 as permitted sender) X-Barracuda-Apparent-Source-IP: 209.132.183.28 X-Barracuda-RBL-IP: 209.132.183.28 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D5D6BDEF for ; Thu, 21 Jul 2016 18:14:32 +0000 (UTC) Received: from indiana.gru.redhat.com (ovpn-116-65.phx2.redhat.com [10.3.116.65]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6LIEQif019357 for ; Thu, 21 Jul 2016 14:14:31 -0400 X-CudaMail-Envelope-Sender: cascardo@redhat.com From: Thadeu Lima de Souza Cascardo To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V2-720035112 X-CudaMail-DTE: 072116 X-CudaMail-Originating-IP: 209.132.183.28 Date: Thu, 21 Jul 2016 15:14:13 -0300 X-ASG-Orig-Subj: [##CM-V2-720035112##][PATCH 2/6] datapath: remove flow_dissector Message-Id: <1469124857-30036-3-git-send-email-cascardo@redhat.com> In-Reply-To: <1469124857-30036-1-git-send-email-cascardo@redhat.com> References: <1469124857-30036-1-git-send-email-cascardo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 21 Jul 2016 18:14:32 +0000 (UTC) X-Barracuda-Connect: UNKNOWN[192.168.14.1] X-Barracuda-Start-Time: 1469124873 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Subject: [ovs-dev] [PATCH 2/6] datapath: remove flow_dissector X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" 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 --- 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 7e114f0..8f30fe1 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 3f42dba..0000000 --- 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 4511ac0..ad5a558 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 766b4b3..0000000 --- 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