From patchwork Wed Apr 20 07:39:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Johnson.Li" X-Patchwork-Id: 612521 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 3qqYgv3DxPz9sdQ for ; Wed, 20 Apr 2016 17:40:11 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 946B410603; Wed, 20 Apr 2016 00:40:09 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e3.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 411DA105F1 for ; Wed, 20 Apr 2016 00:40:08 -0700 (PDT) Received: from bar5.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id 8A4AA420127 for ; Wed, 20 Apr 2016 01:40:07 -0600 (MDT) X-ASG-Debug-ID: 1461138006-09eadd0e4100ce0001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar5.cudamail.com with ESMTP id 5GSTDABjlXjTm0Zk (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 20 Apr 2016 01:40:06 -0600 (MDT) X-Barracuda-Envelope-From: lijohnso@shecgisg004.sh.intel.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO mga03.intel.com) (134.134.136.65) by mx3-pf3.cudamail.com with SMTP; 20 Apr 2016 07:40:05 -0000 Received-SPF: none (mx3-pf3.cudamail.com: domain at shecgisg004.sh.intel.com does not designate permitted sender hosts) X-Barracuda-Apparent-Source-IP: 134.134.136.65 X-Barracuda-RBL-IP: 134.134.136.65 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 20 Apr 2016 00:40:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,508,1455004800"; d="scan'208";a="689167422" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 20 Apr 2016 00:40:03 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id u3K7e1KT032650; Wed, 20 Apr 2016 15:40:01 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id u3K7dw3X007557; Wed, 20 Apr 2016 15:40:00 +0800 Received: (from lijohnso@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id u3K7dw8Y007553; Wed, 20 Apr 2016 15:39:58 +0800 X-CudaMail-Envelope-Sender: lijohnso@shecgisg004.sh.intel.com From: "Johnson.Li" To: dev@openvswitch.org X-CudaMail-MID: CM-V3-419001404 X-CudaMail-DTE: 042016 X-CudaMail-Originating-IP: 134.134.136.65 Date: Wed, 20 Apr 2016 15:39:53 +0800 X-ASG-Orig-Subj: [##CM-V3-419001404##][PATCH v2] Add VxLAN-GBP support for user space data path Message-Id: <1461137993-7521-1-git-send-email-johnson.li@intel.com> X-Mailer: git-send-email 1.7.4.1 X-GBUdb-Analysis: 0, 134.134.136.65, Ugly c=0 p=0 Source New X-MessageSniffer-Rules: 0-0-0-10905-c X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1461138006 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using per-user scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC5_MJ1963, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.28894 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Subject: [ovs-dev] [PATCH v2] Add VxLAN-GBP support for user space data path 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" From: Johnson Li In user space, only standard VxLAN was support. This patch will add the VxLAN-GBP support for the user space data path. How to use: 1> Create VxLAN port with GBP extension $ovs-vsctl add-port br-int vxlan0 -- set interface vxlan0 \ type=vxlan options:dst_port=4789 \ options:remote_ip=192.168.60.22 \ options:key=1000 options:exts=gbp 2> Add flow for transmitting $ovs-ofctl add-flow br-int "table=0, priority=260, \ in_port=LOCAL actions=load:0x100->NXM_NX_TUN_GBP_ID[], \ output:1" 3> Add flow for receiving $ovs-ofctl add-flow br-int "table=0, priority=260, \ in_port=1,tun_gbp_id=0x100 actions=output:LOCAL" Check data path flow rules: $ovs-appctl dpif/dump-flows br-int recirc_id(0),in_port(1),eth_type(0x0800),ipv4(tos=0/0x3,frag=no), packets:0, bytes:0, used:never, actions:tnl_push(tnl_port(2), header(size=50,type=4,eth(dst=90:e2:ba:48:7f:a4,src=90:e2:ba:48:7e:1c, dl_type=0x0800),ipv4(src=192.168.60.21,dst=192.168.60.22,proto=17, tos=0,ttl=64,frag=0x4000),udp(src=0,dst=4789,csum=0x0), vxlan(flags=0x88000100,vni=0x3e8)),out_port(3)) tunnel(tun_id=0x3e8,src=192.168.60.22,dst=192.168.60.21, vxlan(gbp(id=256)),flags(-df-csum+key)),skb_mark(0),recirc_id(0), in_port(2),eth(dst=ae:1b:ed:1e:e3:4e),eth_type(0x0800), ipv4(dst=172.168.60.21,proto=1/0x10,frag=no), packets:0, bytes:0, used:never, actions:1 Change Log: v2: Set Each enabled bit for the VxLAN-GBP. Signed-off-by: Johnson Li diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c index e398562..0ac449e 100644 --- a/lib/netdev-vport.c +++ b/lib/netdev-vport.c @@ -1286,6 +1286,7 @@ netdev_vxlan_pop_header(struct dp_packet *packet) struct flow_tnl *tnl = &md->tunnel; struct vxlanhdr *vxh; unsigned int hlen; + uint32_t vxh_flags; pkt_metadata_init_tnl(md); if (VXLAN_HLEN > dp_packet_l4_size(packet)) { @@ -1297,10 +1298,18 @@ netdev_vxlan_pop_header(struct dp_packet *packet) return EINVAL; } - if (get_16aligned_be32(&vxh->vx_flags) != htonl(VXLAN_FLAGS) || - (get_16aligned_be32(&vxh->vx_vni) & htonl(0xff))) { - VLOG_WARN_RL(&err_rl, "invalid vxlan flags=%#x vni=%#x\n", - ntohl(get_16aligned_be32(&vxh->vx_flags)), + vxh_flags = get_16aligned_be32(&vxh->vx_flags); + if (vxh_flags & htonl(VXLAN_HF_GBP)) { + tnl->gbp_id = htons(ntohl(vxh_flags) & VXLAN_GBP_ID_MASK); + vxh_flags &= (VXLAN_GBP_DONT_LEARN | VXLAN_GBP_POLICY_APPLIED); + tnl->gbp_flags = vxh_flags >> 16; + } else if (vxh_flags != htonl(VXLAN_FLAGS)) { + VLOG_WARN_RL(&err_rl, "invalid vxlan flags=%#x\n", + ntohl(get_16aligned_be32(&vxh->vx_flags))); + return EINVAL; + } + if (get_16aligned_be32(&vxh->vx_vni) & htonl(0xff)) { + VLOG_WARN_RL(&err_rl, "invalid vxlan vni=%#x\n", ntohl(get_16aligned_be32(&vxh->vx_vni))); return EINVAL; } @@ -1312,6 +1321,26 @@ netdev_vxlan_pop_header(struct dp_packet *packet) return 0; } +static void +netdev_vxlan_build_gbp_header(struct vxlanhdr *vxh, + const struct flow *tnl_flow) +{ + uint32_t vxh_flags = VXLAN_FLAGS; + + /* G bit to indicates that the source TSI Group membership is being + * carried within the Group Policy ID field. */ + vxh_flags |= VXLAN_HF_GBP; + + /* Only D bit and A bit is valid in gbp_flags. Other bit which is + * set will be ignored. */ + vxh_flags |= (tnl_flow->tunnel.gbp_flags << 16) + & (VXLAN_GBP_DONT_LEARN | VXLAN_GBP_POLICY_APPLIED); + + vxh_flags |= ntohs(tnl_flow->tunnel.gbp_id); + + put_16aligned_be32(&vxh->vx_flags, htonl(vxh_flags)); +} + static int netdev_vxlan_build_header(const struct netdev *netdev, struct ovs_action_push_tnl *data, @@ -1328,7 +1357,11 @@ netdev_vxlan_build_header(const struct netdev *netdev, vxh = udp_build_header(tnl_cfg, tnl_flow, data, &hlen); - put_16aligned_be32(&vxh->vx_flags, htonl(VXLAN_FLAGS)); + if (tnl_cfg->exts & (1 << OVS_VXLAN_EXT_GBP)) { + netdev_vxlan_build_gbp_header(vxh, tnl_flow); + } else { + put_16aligned_be32(&vxh->vx_flags, htonl(VXLAN_FLAGS)); + } put_16aligned_be32(&vxh->vx_vni, htonl(ntohll(tnl_flow->tunnel.tun_id) << 8)); ovs_mutex_unlock(&dev->mutex); diff --git a/lib/packets.h b/lib/packets.h index 8139a6b..c78b053 100644 --- a/lib/packets.h +++ b/lib/packets.h @@ -1003,6 +1003,11 @@ struct vxlanhdr { #define VXLAN_FLAGS 0x08000000 /* struct vxlanhdr.vx_flags required value. */ +#define VXLAN_HF_GBP 0x80000000 /* Group Based Policy, BIT(31) */ +#define VXLAN_GBP_DONT_LEARN 0x400000 /* Don't Learn, (BIT(6) << 16) */ +#define VXLAN_GBP_POLICY_APPLIED 0x80000 /* Policy Applied, (BIT(3) << 16) */ +#define VXLAN_GBP_ID_MASK 0xFFFF /* GBP ID */ + void ipv6_format_addr(const struct in6_addr *addr, struct ds *); void ipv6_format_addr_bracket(const struct in6_addr *addr, struct ds *, bool bracket);