From patchwork Wed Nov 25 13:31:16 2015 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: 548565 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (unknown [IPv6:2600:3c00::f03c:91ff:fe6e:bdf7]) by ozlabs.org (Postfix) with ESMTP id BF35A1402E2 for ; Thu, 26 Nov 2015 00:33:15 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id BCD5210B93; Wed, 25 Nov 2015 05:32:04 -0800 (PST) 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 E589610B7C for ; Wed, 25 Nov 2015 05:32:02 -0800 (PST) Received: from bar4.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 7C3C7161517 for ; Wed, 25 Nov 2015 06:32:02 -0700 (MST) X-ASG-Debug-ID: 1448458321-03dc216040110500001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar4.cudamail.com with ESMTP id oXnGUj3223q7Rveq (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 25 Nov 2015 06:32:01 -0700 (MST) X-Barracuda-Envelope-From: cascardo@redhat.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO mx1.redhat.com) (209.132.183.28) by mx3-pf3.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 25 Nov 2015 13:35:00 -0000 Received-SPF: pass (mx3-pf3.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-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 1AE0FC0D2249 for ; Wed, 25 Nov 2015 13:31:50 +0000 (UTC) Received: from indiana.gru.redhat.com (ovpn-113-86.phx2.redhat.com [10.3.113.86]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAPDVREE029492 for ; Wed, 25 Nov 2015 08:31:49 -0500 X-CudaMail-Envelope-Sender: cascardo@redhat.com From: Thadeu Lima de Souza Cascardo To: dev@openvswitch.org X-CudaMail-MID: CM-V3-1124010298 X-CudaMail-DTE: 112515 X-CudaMail-Originating-IP: 209.132.183.28 Date: Wed, 25 Nov 2015 11:31:16 -0200 X-ASG-Orig-Subj: [##CM-V3-1124010298##][PATCH v2 13/14] Allow flow-based IPv6 tunnels to be configured with OpenFlow Message-Id: <1448458277-28154-14-git-send-email-cascardo@redhat.com> In-Reply-To: <1448458277-28154-1-git-send-email-cascardo@redhat.com> References: <1448458277-28154-1-git-send-email-cascardo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-GBUdb-Analysis: 0, 209.132.183.28, Ugly c=0.285716 p=-0.25 Source Normal X-MessageSniffer-Rules: 0-0-0-17745-c X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1448458321 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: 1.10 X-Barracuda-Spam-Status: No, SCORE=1.10 using per-user scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_RULE7568M, BSF_SC5_MJ1963, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.24709 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE7568M Custom Rule 7568M 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 13/14] Allow flow-based IPv6 tunnels to be configured with OpenFlow 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" With this patch, it is possible to set the IPv6 source and destination address in flow-based tunnels. $ ovs-ofctl add-flow br0 "in_port=LOCAL actions=set_field:2001:cafe::92->tun_ipv6_dst" Signed-off-by: Thadeu Lima de Souza Cascardo Signed-off-by: Jiri Benc Co-authored-by: Jiri Benc --- lib/meta-flow.c | 42 ++++++++++++++++++++++++++++++++++++++++++ lib/meta-flow.h | 35 +++++++++++++++++++++++++++++++++++ lib/nx-match.c | 4 ++++ tests/ofproto.at | 4 +++- 4 files changed, 84 insertions(+), 1 deletion(-) diff --git a/lib/meta-flow.c b/lib/meta-flow.c index b3397cf..6bd0b99 100644 --- a/lib/meta-flow.c +++ b/lib/meta-flow.c @@ -190,6 +190,10 @@ mf_is_all_wild(const struct mf_field *mf, const struct flow_wildcards *wc) return !wc->masks.tunnel.ip_src; case MFF_TUN_DST: return !wc->masks.tunnel.ip_dst; + case MFF_TUN_IPV6_SRC: + return ipv6_mask_is_any(&wc->masks.tunnel.ipv6_src); + case MFF_TUN_IPV6_DST: + return ipv6_mask_is_any(&wc->masks.tunnel.ipv6_dst); case MFF_TUN_ID: return !wc->masks.tunnel.tun_id; case MFF_TUN_TOS: @@ -496,6 +500,8 @@ mf_is_value_valid(const struct mf_field *mf, const union mf_value *value) case MFF_TUN_ID: case MFF_TUN_SRC: case MFF_TUN_DST: + case MFF_TUN_IPV6_SRC: + case MFF_TUN_IPV6_DST: case MFF_TUN_TOS: case MFF_TUN_TTL: case MFF_TUN_GBP_ID: @@ -617,6 +623,12 @@ mf_get_value(const struct mf_field *mf, const struct flow *flow, case MFF_TUN_DST: value->be32 = flow->tunnel.ip_dst; break; + case MFF_TUN_IPV6_SRC: + value->ipv6 = flow->tunnel.ipv6_src; + break; + case MFF_TUN_IPV6_DST: + value->ipv6 = flow->tunnel.ipv6_dst; + break; case MFF_TUN_FLAGS: value->be16 = htons(flow->tunnel.flags & FLOW_TNL_PUB_F_MASK); break; @@ -858,6 +870,12 @@ mf_set_value(const struct mf_field *mf, case MFF_TUN_DST: match_set_tun_dst(match, value->be32); break; + case MFF_TUN_IPV6_SRC: + match_set_tun_ipv6_src(match, &value->ipv6); + break; + case MFF_TUN_IPV6_DST: + match_set_tun_ipv6_dst(match, &value->ipv6); + break; case MFF_TUN_FLAGS: match_set_tun_flags(match, ntohs(value->be16)); break; @@ -1164,6 +1182,12 @@ mf_set_flow_value(const struct mf_field *mf, case MFF_TUN_DST: flow->tunnel.ip_dst = value->be32; break; + case MFF_TUN_IPV6_SRC: + flow->tunnel.ipv6_src = value->ipv6; + break; + case MFF_TUN_IPV6_DST: + flow->tunnel.ipv6_dst = value->ipv6; + break; case MFF_TUN_FLAGS: flow->tunnel.flags = (flow->tunnel.flags & ~FLOW_TNL_PUB_F_MASK) | ntohs(value->be16); @@ -1468,6 +1492,18 @@ mf_set_wild(const struct mf_field *mf, struct match *match, char **err_str) case MFF_TUN_DST: match_set_tun_dst_masked(match, htonl(0), htonl(0)); break; + case MFF_TUN_IPV6_SRC: + memset(&match->wc.masks.tunnel.ipv6_src, 0, + sizeof match->wc.masks.tunnel.ipv6_src); + memset(&match->flow.tunnel.ipv6_src, 0, + sizeof match->flow.tunnel.ipv6_src); + break; + case MFF_TUN_IPV6_DST: + memset(&match->wc.masks.tunnel.ipv6_dst, 0, + sizeof match->wc.masks.tunnel.ipv6_dst); + memset(&match->flow.tunnel.ipv6_dst, 0, + sizeof match->flow.tunnel.ipv6_dst); + break; case MFF_TUN_FLAGS: match_set_tun_flags_masked(match, 0, 0); break; @@ -1760,6 +1796,12 @@ mf_set(const struct mf_field *mf, case MFF_TUN_DST: match_set_tun_dst_masked(match, value->be32, mask->be32); break; + case MFF_TUN_IPV6_SRC: + match_set_tun_ipv6_src_masked(match, &value->ipv6, &mask->ipv6); + break; + case MFF_TUN_IPV6_DST: + match_set_tun_ipv6_dst_masked(match, &value->ipv6, &mask->ipv6); + break; case MFF_TUN_FLAGS: match_set_tun_flags_masked(match, ntohs(value->be16), ntohs(mask->be16)); break; diff --git a/lib/meta-flow.h b/lib/meta-flow.h index 736abc4..71c238d 100644 --- a/lib/meta-flow.h +++ b/lib/meta-flow.h @@ -368,6 +368,41 @@ enum OVS_PACKED_ENUM mf_field_id { */ MFF_TUN_DST, + /* "tun_ipv6_src". + * + * The IPv6 source address in the outer IP header of a tunneled packet. + * + * For non-tunneled packets, the value is 0. + * + * Type: be128. + * Maskable: bitwise. + * Formatting: IPv6. + * Prerequisites: none. + * Access: read/write. + * NXM: NXM_NX_TUN_IPV6_SRC(109) since v2.5. + * OXM: none. + * Prefix lookup member: tunnel.ipv6_src. + */ + MFF_TUN_IPV6_SRC, + + /* "tun_ipv6_dst". + * + * The IPv6 destination address in the outer IP header of a tunneled + * packet. + * + * For non-tunneled packets, the value is 0. + * + * Type: be128. + * Maskable: bitwise. + * Formatting: IPv6. + * Prerequisites: none. + * Access: read/write. + * NXM: NXM_NX_TUN_IPV6_DST(110) since v2.5. + * OXM: none. + * Prefix lookup member: tunnel.ipv6_dst. + */ + MFF_TUN_IPV6_DST, + /* "tun_flags". * * Flags representing aspects of tunnel behavior. diff --git a/lib/nx-match.c b/lib/nx-match.c index 2a0159f..11bcd95 100644 --- a/lib/nx-match.c +++ b/lib/nx-match.c @@ -1020,6 +1020,10 @@ nx_put_raw(struct ofpbuf *b, enum ofp_version oxm, const struct match *match, flow->tunnel.ip_src, match->wc.masks.tunnel.ip_src); nxm_put_32m(b, MFF_TUN_DST, oxm, flow->tunnel.ip_dst, match->wc.masks.tunnel.ip_dst); + nxm_put_ipv6(b, MFF_TUN_IPV6_SRC, oxm, + &flow->tunnel.ipv6_src, &match->wc.masks.tunnel.ipv6_src); + nxm_put_ipv6(b, MFF_TUN_IPV6_DST, oxm, + &flow->tunnel.ipv6_dst, &match->wc.masks.tunnel.ipv6_dst); nxm_put_16m(b, MFF_TUN_GBP_ID, oxm, flow->tunnel.gbp_id, match->wc.masks.tunnel.gbp_id); nxm_put_8m(b, MFF_TUN_GBP_FLAGS, oxm, diff --git a/tests/ofproto.at b/tests/ofproto.at index 5c40c7d..15c2f9e 100644 --- a/tests/ofproto.at +++ b/tests/ofproto.at @@ -1532,7 +1532,7 @@ head_table () { instructions: meter,apply_actions,clear_actions,write_actions,write_metadata,goto_table Write-Actions and Apply-Actions features: actions: output group set_field strip_vlan push_vlan mod_nw_ttl dec_ttl set_mpls_ttl dec_mpls_ttl push_mpls pop_mpls set_queue - supported on Set-Field: tun_id tun_src tun_dst tun_flags tun_gbp_id tun_gbp_flags tun_metadata0 dnl + supported on Set-Field: tun_id tun_src tun_dst tun_ipv6_src tun_ipv6_dst tun_flags tun_gbp_id tun_gbp_flags tun_metadata0 dnl tun_metadata1 tun_metadata2 tun_metadata3 tun_metadata4 tun_metadata5 tun_metadata6 tun_metadata7 tun_metadata8 tun_metadata9 tun_metadata10 tun_metadata11 tun_metadata12 tun_metadata13 tun_metadata14 tun_metadata15 tun_metadata16 tun_metadata17 tun_metadata18 tun_metadata19 tun_metadata20 tun_metadata21 tun_metadata22 tun_metadata23 tun_metadata24 tun_metadata25 tun_metadata26 tun_metadata27 tun_metadata28 tun_metadata29 tun_metadata30 tun_metadata31 tun_metadata32 tun_metadata33 tun_metadata34 tun_metadata35 tun_metadata36 tun_metadata37 tun_metadata38 tun_metadata39 tun_metadata40 tun_metadata41 tun_metadata42 tun_metadata43 tun_metadata44 tun_metadata45 tun_metadata46 tun_metadata47 tun_metadata48 tun_metadata49 tun_metadata50 tun_metadata51 tun_metadata52 tun_metadata53 tun_metadata54 tun_metadata55 tun_metadata56 tun_metadata57 tun_metadata58 tun_metadata59 tun_metadata60 tun_metadata61 tun_metadata62 tun_metadata63 dnl metadata in_port in_port_oxm pkt_mark ct_mark ct_label reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 xreg0 xreg1 xreg2 xreg3 eth_src eth_dst vlan_tci vlan_vid vlan_pcp mpls_label mpls_tc ip_src ip_dst ipv6_src ipv6_dst ipv6_label nw_tos ip_dscp nw_ecn nw_ttl arp_op arp_spa arp_tpa arp_sha arp_tha tcp_src tcp_dst udp_src udp_dst sctp_src sctp_dst icmp_type icmp_code icmpv6_type icmpv6_code nd_target nd_sll nd_tll matching: @@ -1542,6 +1542,8 @@ metadata in_port in_port_oxm pkt_mark ct_mark ct_label reg0 reg1 reg2 reg3 reg4 tun_id: arbitrary mask tun_src: arbitrary mask tun_dst: arbitrary mask + tun_ipv6_src: arbitrary mask + tun_ipv6_dst: arbitrary mask tun_flags: arbitrary mask tun_gbp_id: arbitrary mask tun_gbp_flags: arbitrary mask