From patchwork Sat Aug 17 00:36:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankur Sharma X-Patchwork-Id: 1148559 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nutanix.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nutanix.com header.i=@nutanix.com header.b="Xp6ufa83"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 469MB16RQVz9sDQ for ; Sat, 17 Aug 2019 10:53:13 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A6D8CCF6; Sat, 17 Aug 2019 00:52:49 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 8D343CD4 for ; Sat, 17 Aug 2019 00:52:48 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx0b-002c1b01.pphosted.com (mx0b-002c1b01.pphosted.com [148.163.155.12]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 40E818AC for ; Sat, 17 Aug 2019 00:52:44 +0000 (UTC) Received: from pps.filterd (m0127842.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7H0nspk005691 for ; Fri, 16 Aug 2019 17:52:43 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=proofpoint20171006; bh=veKlQPR4WDp14/qqB6k8ODj9I0GXoJyIuOYk+LJgZc4=; b=Xp6ufa83znIeYO6Pq3fc++RQ8e/r49EqdQ+uuZsVqee5DcIjVkEM7q48TukWxbDNXnzr x+4iSYHJxRU/sRvXNkfiTNxNp7pZSjqqHVwiN+8FpmTb9uZ5J4SBFTSCkWRhZypPwFz1 zcxUcLZc0G41iz9OjUGxZ4WJ8QlgLlq4jXatmfodxChBIUMMX9O3oOwzRUe2o3z6z8s+ buVmN7Fu0myIbgAdxlFQd30RVEaC9XXqn1wtay80rVmlYLbnKGrbv55ykEyGY8a4tW+c n5FWjNRnl2ZDwTbxjiiyueauB22tZBJDyEbvPJeTHCPtlYNXKql+wy4zzKFjY3skGObE cQ== Received: from nam03-by2-obe.outbound.protection.outlook.com (mail-by2nam03lp2051.outbound.protection.outlook.com [104.47.42.51]) by mx0b-002c1b01.pphosted.com with ESMTP id 2ubf9x8f4x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 16 Aug 2019 17:52:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XIVC01X0KmpL+QoGiVqr8V9BMMbnEbg57umgb0/jZZKJuIHzJuZ4daAf8c06MANU+J7ZCbSPwVoymHbBfNqpw6+dPMCueh4rLIQ8nGaYH5UcsBcjZUo6h9Njgbf+ip0knOK5b3AkODYxYpy7vF4+YbDiTiQUvpswBXe4WErFVqSQwHodTKNadIYpdCdeI7+mnVRKpfNyapCaFssPfyAb3NoTDjdNPkaM+SG5Iyw7mwzup9aEc8SBw4FiNynEiumoZW8FNf4arYpUNlR2g+0VuAcvtOS5VpnbUo0SaEM1oBgbOB0jN6VJ4S2FWrhoZK4aJkQTF63SnjNPP1PXvASaKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=veKlQPR4WDp14/qqB6k8ODj9I0GXoJyIuOYk+LJgZc4=; b=Ip8PUzmb31eVVUJAu3k0oU2pCo9PPW376znhUS75MNQ2+Bh3Qr5TrV8+XtU4YFLSPIZH/+6tTxt8vP+HazH23OU+WlWGS/Ky9gsoJKd7DyggJUghtWaY55NiSjVs8MpNkSUJXsFfSH0Lb14n6jf0HmG5GuaXR6j3HhYfEqxn42Qs+hw8wJm15OGEnQMyvbaEXx54RNK8NIlWi6IK9lKSXgucN/nwdH3vioHgXxl039iES6UluJwRL6ncj8P5eZ07hyAlGUNb6Mpsx2GEwfH1dUuDy5sqynZ1FFQZVRltf8A3sYlBC9c5cznA4XJj9nSbz9G6muqKtQQJ6ZUrmtDafg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from MW2PR02MB3899.namprd02.prod.outlook.com (52.132.178.28) by MW2PR02MB3755.namprd02.prod.outlook.com (52.132.177.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Sat, 17 Aug 2019 00:36:43 +0000 Received: from MW2PR02MB3899.namprd02.prod.outlook.com ([fe80::a4e3:ca62:dfc6:1149]) by MW2PR02MB3899.namprd02.prod.outlook.com ([fe80::a4e3:ca62:dfc6:1149%3]) with mapi id 15.20.2157.022; Sat, 17 Aug 2019 00:36:43 +0000 From: Ankur Sharma To: "ovs-dev@openvswitch.org" Thread-Topic: [PATCH v6 1/4 ovn] OVN: Do not replace router port mac on gateway chassis. Thread-Index: AQHVVJPX/wiQE5kzwUiQ0VW8+5mY9Q== Date: Sat, 17 Aug 2019 00:36:43 +0000 Message-ID: <1566002197-29398-2-git-send-email-ankur.sharma@nutanix.com> References: <1566002197-29398-1-git-send-email-ankur.sharma@nutanix.com> In-Reply-To: <1566002197-29398-1-git-send-email-ankur.sharma@nutanix.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BY5PR03CA0017.namprd03.prod.outlook.com (2603:10b6:a03:1e0::27) To MW2PR02MB3899.namprd02.prod.outlook.com (2603:10b6:907:4::28) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 1.8.3.1 x-originating-ip: [192.146.154.98] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e53f6ea3-2a9a-4f66-398c-08d722aaf9fc x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600148)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MW2PR02MB3755; x-ms-traffictypediagnostic: MW2PR02MB3755: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-proofpoint-crosstenant: true x-ms-oob-tlc-oobclassifiers: OLM:530; x-forefront-prvs: 0132C558ED x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(376002)(396003)(39860400002)(366004)(346002)(199004)(189003)(256004)(6916009)(66476007)(66556008)(102836004)(2906002)(14444005)(71200400001)(5024004)(66574012)(64756008)(26005)(478600001)(53936002)(66446008)(99286004)(30864003)(66946007)(5640700003)(53946003)(81166006)(107886003)(81156014)(8676002)(386003)(6486002)(305945005)(71190400001)(76176011)(5660300002)(7736002)(4326008)(6512007)(25786009)(6506007)(2351001)(50226002)(44832011)(52116002)(316002)(8936002)(6436002)(3846002)(446003)(4720700003)(14454004)(86362001)(186003)(476003)(486006)(66066001)(2616005)(2501003)(11346002)(6116002)(36756003)(64030200001); DIR:OUT; SFP:1102; SCL:1; SRVR:MW2PR02MB3755; H:MW2PR02MB3899.namprd02.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nutanix.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Vu7hOClrdz5MA9eev78psRLsQsotvauk5j6XW7CybhAFBZxERpGh1RC2UAZmnCAidvrGPwnGIQ77bJ8n0jl/rTdYQhaaMLHB8y+LKP1RXVqAScCR7dG/lxVvey3cSFI9HKl+jbTVhJM0e83o3TFI57GA5yRQyVl6hbDyXZBFA4lC6Rjc0H6LjrdFy8+kOva26Oc7VQszR9mJhUESbHmmIrfP51C3RbYfH6HzjJYYjdWQRiouLVgxaqPWcuELNtcc1hhC8Olnh/7KQK5wItk9Z3SGqwA6rEVWOxRmlKpZecGhn7RilO4aWgFzJ7me9EGxMz/Nd9Cv3CCU8jXfuypPLNpPHfN9SlC3Mn5wdNbYK+vWYcEgQDobX+aMRtBkIbgRuUI6fRzr6q0eP544lN4cF8vLkUYmDvBKbzDP9iB3T9k= MIME-Version: 1.0 X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: e53f6ea3-2a9a-4f66-398c-08d722aaf9fc X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Aug 2019 00:36:43.1674 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: dzfbBYxM9f8E6FSWrYQ/fLABpxrnuy9dYCHts4O695UxDJxJ2XDxuaqFe7l7RM3NdPMTsMiuGkjiC3HoBoh8CZIRZu+L+gGEIsN/3qts4gk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR02MB3755 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:5.22.84,1.0.8 definitions=2019-08-16_10:2019-08-16,2019-08-16 signatures=0 X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v6 1/4 ovn] OVN: Do not replace router port mac on gateway chassis. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org With 795d7f24ce0e2ed5454e193a059451d237289542 we have added support for E-W routing on vlan backed networks by replacing router port macs with chassis macs. This replacement of router port mac need NOT be done on gateway chassis for following reasons: a. For N-S traffic, gateway chassis will respond to ARP for the router port (to which it is attached) and traffic will be using router port mac as destination mac. b. Chassis redirect port is a centralized version of distributed router port, hence we need not replace its mac with chassis mac on the resident chassis. This patch addresses the same. Signed-off-by: Ankur Sharma --- controller/lport.c | 20 ++++ controller/lport.h | 6 + controller/physical.c | 18 ++- controller/pinctrl.c | 20 +--- tests/ovn.at | 321 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 364 insertions(+), 21 deletions(-) diff --git a/controller/lport.c b/controller/lport.c index 792c825..478fcfd 100644 --- a/controller/lport.c +++ b/controller/lport.c @@ -17,6 +17,7 @@ #include "lib/sset.h" #include "lport.h" +#include "ha-chassis.h" #include "hash.h" #include "openvswitch/vlog.h" #include "lib/ovn-sb-idl.h" @@ -64,6 +65,25 @@ lport_lookup_by_key(struct ovsdb_idl_index *sbrec_datapath_binding_by_key, return retval; } +bool +lport_is_chassis_resident(struct ovsdb_idl_index *sbrec_port_binding_by_name, + const struct sbrec_chassis *chassis, + const struct sset *active_tunnels, + const char *port_name) +{ + const struct sbrec_port_binding *pb + = lport_lookup_by_name(sbrec_port_binding_by_name, port_name); + if (!pb || !pb->chassis) { + return false; + } + if (strcmp(pb->type, "chassisredirect")) { + return pb->chassis == chassis; + } else { + return ha_chassis_group_is_active(pb->ha_chassis_group, + active_tunnels, chassis); + } +} + const struct sbrec_datapath_binding * datapath_lookup_by_key(struct ovsdb_idl_index *sbrec_datapath_binding_by_key, uint64_t dp_key) diff --git a/controller/lport.h b/controller/lport.h index 2d4bb71..345efc1 100644 --- a/controller/lport.h +++ b/controller/lport.h @@ -23,6 +23,7 @@ struct sbrec_chassis; struct sbrec_datapath_binding; struct sbrec_multicast_group; struct sbrec_port_binding; +struct sset; /* Database indexes. @@ -48,5 +49,10 @@ const struct sbrec_datapath_binding *datapath_lookup_by_key( const struct sbrec_multicast_group *mcgroup_lookup_by_dp_name( struct ovsdb_idl_index *sbrec_multicast_group_by_name_datapath, const struct sbrec_datapath_binding *, const char *name); +bool +lport_is_chassis_resident(struct ovsdb_idl_index *sbrec_port_binding_by_name, + const struct sbrec_chassis *chassis, + const struct sset *active_tunnels, + const char *port_name); #endif /* controller/lport.h */ diff --git a/controller/physical.c b/controller/physical.c index a05962b..5068785 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -228,9 +228,12 @@ get_zone_ids(const struct sbrec_port_binding *binding, } static void -put_replace_router_port_mac_flows(const struct +put_replace_router_port_mac_flows(struct ovsdb_idl_index + *sbrec_port_binding_by_name, + const struct sbrec_port_binding *localnet_port, const struct sbrec_chassis *chassis, + const struct sset *active_tunnels, const struct hmap *local_datapaths, struct ofpbuf *ofpacts_p, ofp_port_t ofport, @@ -270,6 +273,16 @@ put_replace_router_port_mac_flows(const struct struct eth_addr router_port_mac; struct match match; struct ofpact_mac *replace_mac; + char *cr_peer_name = xasprintf("cr-%s", rport_binding->logical_port); + if (lport_is_chassis_resident(sbrec_port_binding_by_name, + chassis, active_tunnels, + cr_peer_name)) { + /* If a router port's chassisredirect port is + * resident on this chassis, then we need not do mac replace. */ + free(cr_peer_name); + continue; + } + free(cr_peer_name); /* Table 65, priority 150. * ======================= @@ -787,7 +800,8 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, &match, ofpacts_p, &binding->header_.uuid); if (!strcmp(binding->type, "localnet")) { - put_replace_router_port_mac_flows(binding, chassis, + put_replace_router_port_mac_flows(sbrec_port_binding_by_name, + binding, chassis, active_tunnels, local_datapaths, ofpacts_p, ofport, flow_table); } diff --git a/controller/pinctrl.c b/controller/pinctrl.c index f27718f..e8abe0b 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -3755,24 +3755,6 @@ get_localnet_vifs_l3gwports( sbrec_port_binding_index_destroy_row(target); } -static bool -pinctrl_is_chassis_resident(struct ovsdb_idl_index *sbrec_port_binding_by_name, - const struct sbrec_chassis *chassis, - const struct sset *active_tunnels, - const char *port_name) -{ - const struct sbrec_port_binding *pb - = lport_lookup_by_name(sbrec_port_binding_by_name, port_name); - if (!pb || !pb->chassis) { - return false; - } - if (strcmp(pb->type, "chassisredirect")) { - return pb->chassis == chassis; - } else { - return ha_chassis_group_is_active(pb->ha_chassis_group, - active_tunnels, chassis); - } -} /* Extracts the mac, IPv4 and IPv6 addresses, and logical port from * 'addresses' which should be of the format 'MAC [IP1 IP2 ..] @@ -3853,7 +3835,7 @@ consider_nat_address(struct ovsdb_idl_index *sbrec_port_binding_by_name, char *lport = NULL; if (!extract_addresses_with_port(nat_address, laddrs, &lport) || (!lport && !strcmp(pb->type, "patch")) - || (lport && !pinctrl_is_chassis_resident( + || (lport && !lport_is_chassis_resident( sbrec_port_binding_by_name, chassis, active_tunnels, lport))) { destroy_lport_addresses(laddrs); diff --git a/tests/ovn.at b/tests/ovn.at index 71eb390..045cec3 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -29,6 +29,23 @@ m4_define([OVN_CHECK_PACKETS], [ovn_check_packets__ "$1" "$2" AT_CHECK([sort $rcv_text], [0], [expout])]) +m4_define([OVN_CHECK_PACKETS_REMOVE_BROADCAST], + [ovn_check_packets__ () { + echo + echo "checking packets in $1 against $2:" + rcv_pcap=$1 + exp_text=$2 + exp_n=`wc -l < "$exp_text"` + OVS_WAIT_UNTIL( + [$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" $rcv_pcap > $rcv_text + sed -i '/ffffffffffff/d' $rcv_text + rcv_n=`wc -l < "$rcv_text"` + echo "rcv_n=$rcv_n exp_n=$exp_n" + test $rcv_n -ge $exp_n]) + sort $exp_text > expout + } +]) + AT_BANNER([OVN components]) AT_SETUP([ovn -- lexer]) @@ -15009,3 +15026,307 @@ on_exit 'kill $(cat ovn-nbctl.pid)' AT_CHECK([ovn-nbctl -u $sockfile show]) AT_CLEANUP + + +AT_SETUP([ovn -- 2 HVs, 2 lports/HV, localnet ports, DVR N-S ARP handling]) +ovn_start + +# In this test cases we create 3 switches, all connected to same +# physical network (through br-phys on each HV). LS1 and LS2 have +# 1 VIF each. Each HV has 1 VIF port. The first digit +# of VIF port name indicates the hypervisor it is bound to, e.g. +# lp23 means VIF 3 on hv2. +# +# All the switches are connected to a logical router "router". +# +# Each switch's VLAN tag and their logical switch ports are: +# - ls1: +# - tagged with VLAN 101 +# - ports: lp11 +# - ls2: +# - tagged with VLAN 201 +# - ports: lp22 +# - ls-underlay: +# - tagged with VLAN 1000 +# Note: a localnet port is created for each switch to connect to +# physical network. + +for i in 1 2; do + ls_name=ls$i + ovn-nbctl ls-add $ls_name + ln_port_name=ln$i + if test $i -eq 1; then + ovn-nbctl lsp-add $ls_name $ln_port_name "" 101 + elif test $i -eq 2; then + ovn-nbctl lsp-add $ls_name $ln_port_name "" 201 + fi + ovn-nbctl lsp-set-addresses $ln_port_name unknown + ovn-nbctl lsp-set-type $ln_port_name localnet + ovn-nbctl lsp-set-options $ln_port_name network_name=phys +done + +# lsp_to_ls LSP +# +# Prints the name of the logical switch that contains LSP. +lsp_to_ls () { + case $1 in dnl ( + lp?[[11]]) echo ls1 ;; dnl ( + lp?[[12]]) echo ls2 ;; dnl ( + *) AT_FAIL_IF([:]) ;; + esac +} + +vif_to_hv () { + case $1 in dnl ( + vif[[1]]?) echo hv1 ;; dnl ( + vif[[2]]?) echo hv2 ;; dnl ( + vif?[[north]]?) echo hv4 ;; dnl ( + *) AT_FAIL_IF([:]) ;; + esac +} + +ip_to_hex() { + printf "%02x%02x%02x%02x" "$@" +} + +net_add n1 +for i in 1 2; do + sim_add hv$i + as hv$i + ovs-vsctl add-br br-phys + ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys + ovs-vsctl set open . external-ids:ovn-chassis-mac-mappings="phys:aa:bb:cc:dd:ee:$i$i" + ovn_attach n1 br-phys 192.168.0.$i + + ovs-vsctl add-port br-int vif$i$i -- \ + set Interface vif$i$i external-ids:iface-id=lp$i$i \ + options:tx_pcap=hv$i/vif$i$i-tx.pcap \ + options:rxq_pcap=hv$i/vif$i$i-rx.pcap \ + ofport-request=$i$i + + lsp_name=lp$i$i + ls_name=$(lsp_to_ls $lsp_name) + + ovn-nbctl lsp-add $ls_name $lsp_name + ovn-nbctl lsp-set-addresses $lsp_name "f0:00:00:00:00:$i$i 192.168.$i.$i" + ovn-nbctl lsp-set-port-security $lsp_name f0:00:00:00:00:$i$i + + OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up $lsp_name` = xup]) + +done + +ovn-nbctl ls-add ls-underlay +ovn-nbctl lsp-add ls-underlay ln3 "" 1000 +ovn-nbctl lsp-set-addresses ln3 unknown +ovn-nbctl lsp-set-type ln3 localnet +ovn-nbctl lsp-set-options ln3 network_name=phys + +ovn-nbctl ls-add ls-north +ovn-nbctl lsp-add ls-north ln4 "" 1000 +ovn-nbctl lsp-set-addresses ln4 unknown +ovn-nbctl lsp-set-type ln4 localnet +ovn-nbctl lsp-set-options ln4 network_name=phys + +# Add a VM on ls-north +ovn-nbctl lsp-add ls-north lp-north +ovn-nbctl lsp-set-addresses lp-north "f0:f0:00:00:00:11 172.31.0.10" +ovn-nbctl lsp-set-port-security lp-north f0:f0:00:00:00:11 + +# Add 3rd hypervisor +sim_add hv3 +as hv3 ovs-vsctl add-br br-phys +as hv3 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys +as hv3 ovs-vsctl set open . external-ids:ovn-chassis-mac-mappings="phys:aa:bb:cc:dd:ee:33" +as hv3 ovn_attach n1 br-phys 192.168.0.3 + +# Add 4th hypervisor +sim_add hv4 +as hv4 ovs-vsctl add-br br-phys +as hv4 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys +as hv4 ovs-vsctl set open . external-ids:ovn-chassis-mac-mappings="phys:aa:bb:cc:dd:ee:44" +as hv4 ovn_attach n1 br-phys 192.168.0.4 + +as hv4 ovs-vsctl add-port br-int vif-north -- \ + set Interface vif-north external-ids:iface-id=lp-north \ + options:tx_pcap=hv4/vif-north-tx.pcap \ + options:rxq_pcap=hv4/vif-north-rx.pcap \ + ofport-request=44 + +ovn-nbctl lr-add router +ovn-nbctl lrp-add router router-to-ls1 00:00:01:01:02:03 192.168.1.3/24 +ovn-nbctl lrp-add router router-to-ls2 00:00:01:01:02:05 192.168.2.3/24 +ovn-nbctl lrp-add router router-to-underlay 00:00:01:01:02:07 172.31.0.1/24 + +ovn-nbctl lsp-add ls1 ls1-to-router -- set Logical_Switch_Port ls1-to-router type=router \ + options:router-port=router-to-ls1 -- lsp-set-addresses ls1-to-router router +ovn-nbctl lsp-add ls2 ls2-to-router -- set Logical_Switch_Port ls2-to-router type=router \ + options:router-port=router-to-ls2 -- lsp-set-addresses ls2-to-router router +ovn-nbctl lsp-add ls-underlay underlay-to-router -- set Logical_Switch_Port \ + underlay-to-router type=router \ + options:router-port=router-to-underlay \ + -- lsp-set-addresses underlay-to-router router + + +OVN_POPULATE_ARP + +# lsp_to_ls LSP +# +# Prints the name of the logical switch that contains LSP. +lsp_to_ls () { + case $1 in dnl ( + lp?[[11]]) echo ls1 ;; dnl ( + lp?[[12]]) echo ls2 ;; dnl ( + *) AT_FAIL_IF([:]) ;; + esac +} + +vif_to_ls () { + case $1 in dnl ( + vif?[[11]]) echo ls1 ;; dnl ( + vif?[[12]]) echo ls2 ;; dnl ( + vif-north) echo ls-north ;; dnl ( + *) AT_FAIL_IF([:]) ;; + esac +} + +hv_to_num () { + case $1 in dnl ( + hv1) echo 1 ;; dnl ( + hv2) echo 2 ;; dnl ( + hv3) echo 3 ;; dnl ( + hv4) echo 4 ;; dnl ( + *) AT_FAIL_IF([:]) ;; + esac +} + +vif_to_num () { + case $1 in dnl ( + vif22) echo 22 ;; dnl ( + vif21) echo 21 ;; dnl ( + vif11) echo 11 ;; dnl ( + *) AT_FAIL_IF([:]) ;; + esac +} + +vif_to_hv () { + case $1 in dnl ( + vif[[1]]?) echo hv1 ;; dnl ( + vif[[2]]?) echo hv2 ;; dnl ( + vif-north) echo hv4 ;; dnl ( + *) AT_FAIL_IF([:]) ;; + esac +} + +vif_to_lrp () { + echo router-to-`vif_to_ls $1` +} + +ip_to_hex() { + printf "%02x%02x%02x%02x" "$@" +} + +# test_arp INPORT SHA SPA TPA [REPLY_HA] +# +# Causes a packet to be received on INPORT. The packet is an ARP +# request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then +# it should be the hardware address of the target to expect to receive in an +# ARP reply; otherwise no reply is expected. +# +# INPORT is an logical switch port number, e.g. 11 for vif11. +# SHA and REPLY_HA are each 12 hex digits. +# SPA and TPA are each 8 hex digits. +test_arp() { + local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5 + local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa} + hv=`vif_to_hv $inport` + as $hv ovs-appctl netdev-dummy/receive $inport $request + + if test X$reply_ha = X; then + # Expect to receive the broadcast ARP on the other logical switch ports + # if no reply is expected. + local i j + for i in 1 2 3; do + for j in 1 2 3; do + if test $i$j != $inport; then + echo $request >> $i$j.expected + fi + done + done + else + # Expect to receive the reply, if any. + local reply=${sha}${reply_ha}08060001080006040002${reply_ha}${tpa}${sha}${spa} + local reply_vid=${sha}${reply_ha}810003e808060001080006040002${reply_ha}${tpa}${sha}${spa} + echo $reply_vid >> ${inport}_vid.expected + echo $reply >> $inport.expected + fi +} + +sip=`ip_to_hex 172 31 0 10` +tip=`ip_to_hex 172 31 0 1` + +# Set a hypervisor as gateway chassis, for router port 172.31.0.1 +ovn-nbctl lrp-set-gateway-chassis router-to-underlay hv3 +ovn-nbctl --wait=sb sync + +# Dump a bunch of info helpful for debugging if there's a failure. + +echo "------ OVN dump ------" +ovn-nbctl show +ovn-sbctl show +ovn-sbctl list port_binding +ovn-sbctl list mac_binding + +echo "------ hv1 dump ------" +as hv1 ovs-vsctl show +as hv1 ovs-vsctl list Open_Vswitch + +echo "------ hv2 dump ------" +as hv2 ovs-vsctl show +as hv2 ovs-vsctl list Open_Vswitch + +echo "------ hv3 dump ------" +as hv3 ovs-vsctl show +as hv3 ovs-vsctl list Open_Vswitch + +echo "------ hv4 dump ------" +as hv4 ovs-vsctl show +as hv4 ovs-vsctl list Open_Vswitch + +OVS_WAIT_UNTIL([test x`ovn-sbctl --bare --columns chassis find port_binding logical_port=cr-router-to-underlay | wc -l` = x1]) + +test_arp vif-north f0f000000011 $sip $tip 000001010207 + +# Confirm that vif-north gets a single ARP reply +OVN_CHECK_PACKETS_REMOVE_BROADCAST([hv4/vif-north-tx.pcap], [vif-north.expected]) + +# Confirm that only redirect chassis allowed arp resolution. +OVN_CHECK_PACKETS_REMOVE_BROADCAST([hv3/br-phys_n1-tx.pcap], [vif-north_vid.expected]) + +# Confirm that other OVN chassis did not generate ARP reply. +$PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/br-phys_n1-tx.pcap > hv1/br-phys_n1-tx.packets +$PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap > hv2/br-phys_n1-tx.packets + +AT_CHECK([grep 000001010207 hv1/br-phys_n1-tx.packets | wc -l], [0], [[0 +]]) +AT_CHECK([grep 000001010207 hv2/br-phys_n1-tx.packets | wc -l], [0], [[0 +]]) + +echo "----------- Post Traffic hv1 dump -----------" +as hv1 ovs-ofctl -O OpenFlow13 dump-flows br-int +as hv1 ovs-appctl fdb/show br-phys + +echo "----------- Post Traffic hv2 dump -----------" +as hv2 ovs-ofctl -O OpenFlow13 dump-flows br-int +as hv2 ovs-appctl fdb/show br-phys + +echo "----------- Post Traffic hv3 dump -----------" +as hv3 ovs-ofctl -O OpenFlow13 dump-flows br-int +as hv3 ovs-appctl fdb/show br-phys + +echo "----------- Post Traffic hv4 dump -----------" +as hv4 ovs-ofctl -O OpenFlow13 dump-flows br-int +as hv4 ovs-appctl fdb/show br-phys + +OVN_CLEANUP([hv1],[hv2],[hv3],[hv4]) + +AT_CLEANUP From patchwork Sat Aug 17 00:36:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankur Sharma X-Patchwork-Id: 1148548 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nutanix.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nutanix.com header.i=@nutanix.com header.b="fSj6GEmE"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 469Lqj61crz9sDQ for ; Sat, 17 Aug 2019 10:37:21 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 58345C91; Sat, 17 Aug 2019 00:36:48 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 011DDC5C for ; Sat, 17 Aug 2019 00:36:47 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx0a-002c1b01.pphosted.com (mx0a-002c1b01.pphosted.com [148.163.151.68]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 1F90463D for ; Sat, 17 Aug 2019 00:36:46 +0000 (UTC) Received: from pps.filterd (m0127839.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7H0Ycg7015184 for ; Fri, 16 Aug 2019 17:36:45 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=proofpoint20171006; bh=D3bSdSOmr41STS0Xo69XKNKtPkxxjJRjkPU22SaV9gY=; b=fSj6GEmEE0uN/zNm5uP5MFPG2QWSWUWVlyFRNmlDyfasMEm8exwlLDIHsaYpNi4CJLRz nxACgRHDUXchwSIUwFSUShiumIyjX/tohjR+iTc8tUmhuKFhbunGrAPs1kL7nhVH7sJm kybGuWVu+5p6SjL5CA7/6qjcKdlw6iZ5mCFYPWfCGeSqNlXLasG0y1EDojxjZftHMl+4 HP1b/YSWygNti2t5LxMMdh8wP/Dq11YuJa5qXwvwf0qBcntzNw9qllgnauxEsJLMqi5F y/fotPGq6uc12yczKLfQ0irqMGN+hfNXlqAK7DWVokKqJi/rrsKckaGXiservSS6SFbP MQ== Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2055.outbound.protection.outlook.com [104.47.45.55]) by mx0a-002c1b01.pphosted.com with ESMTP id 2ubf9wrq6p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 16 Aug 2019 17:36:45 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c97HRphvbuYUUs/AXNNgH6nVrJ8HtOf2W629EacWGOC5SV3eWnu04tooBmpWZEEEiO+ECkCAHo3T+lPDTISeg7Pnr2c0+8EmqFISfzC9fbIu/3kglCrFIFbEu9E0uXixSX1acIgkZ2RakztiU3ipiBS6EWhotFL2Wz5KtQBAMml2z1wZjwUrE/32Obclw9FwloaSjGNAMi6F1i61qXyyxwEk2dXYXqRlvrRpNGpgP8n+x1b7yz5J6n3RZD8wQr3EmltAcJ9YshWxU5WhCiB4mncNUutfJNRoo4oZksBV3+m+mqeiogpxoXFwkfiA0RK0U7UcOfY4X8JHDc/pJUH/cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D3bSdSOmr41STS0Xo69XKNKtPkxxjJRjkPU22SaV9gY=; b=Y7I3yEhQfLH/LB0/nHMNF/+NWURfevcyBf8uHtKkgR0fSUVc5YLfqVvVGLlXO+SSOgJA4YL/cX60fwtDLHI6ZqHY2tX7e7s6o83mrN01vAE4qNoz/xRfYWpT9DWZjxO75oHgj35c9xyVTg3MLPWSjZAKKwrt7o4pLtmyo4661oVj8oUKUo2P117Q8vKZkYgye+hLOZ6wNsODZbfqMufzn0V2A0UUYAX5eY0aVZTFoJJNryuWapagU9NN+mdoaCLJbdg6zpRWMcDj0RE3cH+Nwvwr1UgeRBUsj7Lzaa8YL2lfrGeCjO7+npn9Jn4x+lv6BvB9Jrg85rEk58Hfk6FLGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from MW2PR02MB3899.namprd02.prod.outlook.com (52.132.178.28) by MW2PR02MB3755.namprd02.prod.outlook.com (52.132.177.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Sat, 17 Aug 2019 00:36:44 +0000 Received: from MW2PR02MB3899.namprd02.prod.outlook.com ([fe80::a4e3:ca62:dfc6:1149]) by MW2PR02MB3899.namprd02.prod.outlook.com ([fe80::a4e3:ca62:dfc6:1149%3]) with mapi id 15.20.2157.022; Sat, 17 Aug 2019 00:36:44 +0000 From: Ankur Sharma To: "ovs-dev@openvswitch.org" Thread-Topic: [PATCH v6 2/4 ovn] OVN: Vlan backed DVR N-S, redirect-type option Thread-Index: AQHVVJPY5gEozI1PxEKXLH6e4be4HA== Date: Sat, 17 Aug 2019 00:36:44 +0000 Message-ID: <1566002197-29398-3-git-send-email-ankur.sharma@nutanix.com> References: <1566002197-29398-1-git-send-email-ankur.sharma@nutanix.com> In-Reply-To: <1566002197-29398-1-git-send-email-ankur.sharma@nutanix.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BY5PR03CA0017.namprd03.prod.outlook.com (2603:10b6:a03:1e0::27) To MW2PR02MB3899.namprd02.prod.outlook.com (2603:10b6:907:4::28) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 1.8.3.1 x-originating-ip: [192.146.154.98] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: eaa591e3-6577-4936-57f7-08d722aafab7 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600148)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MW2PR02MB3755; x-ms-traffictypediagnostic: MW2PR02MB3755: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-proofpoint-crosstenant: true x-ms-oob-tlc-oobclassifiers: OLM:843; x-forefront-prvs: 0132C558ED x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(376002)(396003)(39860400002)(366004)(346002)(199004)(189003)(256004)(6916009)(66476007)(66556008)(102836004)(2906002)(14444005)(71200400001)(5024004)(66574012)(64756008)(26005)(478600001)(53936002)(66446008)(99286004)(66946007)(5640700003)(81166006)(107886003)(81156014)(8676002)(386003)(6486002)(305945005)(71190400001)(76176011)(5660300002)(7736002)(4326008)(6512007)(25786009)(6506007)(2351001)(50226002)(44832011)(52116002)(316002)(8936002)(6436002)(3846002)(446003)(4720700003)(14454004)(86362001)(186003)(476003)(486006)(66066001)(2616005)(2501003)(11346002)(6116002)(36756003)(64030200001); DIR:OUT; SFP:1102; SCL:1; SRVR:MW2PR02MB3755; H:MW2PR02MB3899.namprd02.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nutanix.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 1g+IBpGQdtlBBbOtL8K0SNKnjgzrU3c4nmfZvkTgfVniI0YMymxW942F/sB5gg0ckDIKv3b7akJB4YNk7emNadPWY66jGBihYFQkqp4gso6nQgXJSXbczbqxiP7URF+KmciGx3UMvyvjnMHiwQ8RcjZ8tMstuEf0wEP5o95VXkZYEh4rgPO89Dxpa2q+8Yt8Jvdyl+Pp0INDTJ/kxv9x0/pY8iYexjoSJ+EUWVUWBeqJv48lkD9gDXUQ8JBmicXUtDHfOmvdwQIdQRWVI/mhe1oD/klsEm1RqqlEhFTomOjj9PPOrglTTzd9Vl+Xyz75ap22EFcQuARyVWq9lrUQIYa9L6a0lNgaCgFeeUl+7YMgtlf+hLkOje5Iz2ioRP0HZgBga7G/VNxiPNH3vZ34Ku4+1kVav6SK+bpZQjIDSUg= MIME-Version: 1.0 X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: eaa591e3-6577-4936-57f7-08d722aafab7 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Aug 2019 00:36:44.3937 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: d0DlyzxvU6bx2qwKwLcR36SZ7K+l87ytr1iId5QtG5FplEpnLxYieME+4FTH7lWRxCK4Ch6HmtQ3v8lEQSZrIAW03kpsCOQUpV178RYagXQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR02MB3755 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:5.22.84,1.0.8 definitions=2019-08-16_10:2019-08-16,2019-08-16 signatures=0 X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v6 2/4 ovn] OVN: Vlan backed DVR N-S, redirect-type option X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Background: With c0974331b7a19a87ab8f1f2cec8fbe366af92fa2, we have added support for E-W workflow for vlan backed DVRs. This series enables N-S workflow for vlan backed DVRs. Key difference between E-W and N-S traffic flow is that N-S flow requires a gateway chassis. A gateway chassis will be respondible for following: a. Doing Network Address Translation (NAT). b. Becoming entry and exit point for North->South and South->North traffic respectively. OVN by default always uses overlay encapsulation to redirect the packet to gateway chassis. This series will enable the redirection to gateway chassis in the absence of encapsulation. This patch: a. Add a new key-value in options of a router port. b. This new config key will be used by ovn-controller to determine if a redirected packet will go out of tunnel port or localnet port. c. key is "redirect-type" and it takes "overlay" and "vlan" as values. d. Added ovn-nbctl command to set and get redirect-type option on a router port. e. This new configuration is added because vlan or overlay based forwarding is considered to be a logical switch property, hence for a router configuration has to be done at the router port level. f. Restored the function ovsdb_datum_to_smap, which helps in ensuring that we do not overwrite existing options, while adding a new key-value pair to it. This function exists in 2.8.5, i am not able to figure out so far, which release/why it was removed. I do not see a harm in adding it back. Signed-off-by: Ankur Sharma Signed-off-by: Ankur Sharma Signed-off-by: Ankur Sharma > --- northd/ovn-northd.c | 6 +++++ ovn-nb.xml | 43 ++++++++++++++++++++++++++++++++ ovs/lib/ovsdb-data.c | 11 +++++++++ ovs/lib/ovsdb-data.h | 2 ++ tests/ovn-nbctl.at | 25 +++++++++++++++++++ tests/ovn-northd.at | 31 +++++++++++++++++++++++ utilities/ovn-nbctl.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 186 insertions(+) diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index e861344..89ca8df 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -2445,6 +2445,9 @@ ovn_port_update_sbrec(struct northd_context *ctx, if (op->derived) { const char *redirect_chassis = smap_get(&op->nbrp->options, "redirect-chassis"); + const char *redirect_type = smap_get(&op->nbrp->options, + "redirect-type"); + int n_gw_options_set = 0; if (op->nbrp->ha_chassis_group) { n_gw_options_set++; @@ -2536,6 +2539,9 @@ ovn_port_update_sbrec(struct northd_context *ctx, sbrec_port_binding_set_gateway_chassis(op->sb, NULL, 0); } smap_add(&new, "distributed-port", op->nbrp->name); + if (redirect_type) { + smap_add(&new, "redirect-type", redirect_type); + } } else { if (op->peer) { smap_add(&new, "peer", op->peer->key); diff --git a/ovn-nb.xml b/ovn-nb.xml index e166190..8bb6221 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -1948,6 +1948,49 @@ issues.

+ + +

+ This options dictates if a packet redirected to + gateway chassis will be overlay encapsulated + or go as a regular vlan packet. +

+ +

+ Option takes following values +

+ +
    +
  • + OVERLAY +
  • + +
  • + VLAN +
  • +
+ +

+ OVERLAY option will ensure that redirected packet goes out as + encapsulation via the tunnel port. +

+ +

+ VLAN option will ensure that redirected packet goes out as vlan + tagged via the localnet port. +

+ +

+ OVERLAY is the default redirection type. +

+ +

+ Option is applicable only to gateway chassis attached logical + router ports. +

+ +
+ diff --git a/ovs/lib/ovsdb-data.c b/ovs/lib/ovsdb-data.c index b0fb20d..c7fcb8a 100644 --- a/ovs/lib/ovsdb-data.c +++ b/ovs/lib/ovsdb-data.c @@ -1691,6 +1691,17 @@ ovsdb_datum_from_smap(struct ovsdb_datum *datum, const struct smap *smap) ovsdb_datum_sort_unique(datum, OVSDB_TYPE_STRING, OVSDB_TYPE_STRING); } +/* Initializes smap from a string-to-string datum map. */ +void +ovsdb_datum_to_smap(struct smap *smap, const struct ovsdb_datum *datum) +{ + size_t i = 0; + for (; i < datum->n; i++) { + smap_add(smap, datum->keys[i].string, datum->values[i].string); + } + ovs_assert(i == smap_count(smap)); +} + struct ovsdb_error * OVS_WARN_UNUSED_RESULT ovsdb_datum_convert(struct ovsdb_datum *dst, const struct ovsdb_type *dst_type, diff --git a/ovs/lib/ovsdb-data.h b/ovs/lib/ovsdb-data.h index c5a80ee..bf2cd8a 100644 --- a/ovs/lib/ovsdb-data.h +++ b/ovs/lib/ovsdb-data.h @@ -191,6 +191,8 @@ void ovsdb_datum_to_bare(const struct ovsdb_datum *, const struct ovsdb_type *, struct ds *); void ovsdb_datum_from_smap(struct ovsdb_datum *, const struct smap *); +void ovsdb_datum_to_smap(struct smap *smap, const struct ovsdb_datum *datum); + struct ovsdb_error *ovsdb_datum_convert(struct ovsdb_datum *dst, const struct ovsdb_type *dst_type, diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at index cf06966..39b0bff 100644 --- a/tests/ovn-nbctl.at +++ b/tests/ovn-nbctl.at @@ -1220,6 +1220,31 @@ lrp0-chassis1 1 dnl --------------------------------------------------------------------- +OVN_NBCTL_TEST([ovn_nbctl_redirect_type], [logical router port redirect type], [ +AT_CHECK([ovn-nbctl lr-add lr0]) +AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24]) +AT_CHECK([ovn-nbctl lrp-get-redirect-type lrp0], [0], [dnl +overlay +]) +AT_CHECK([ovn-nbctl lrp-set-redirect-type lp0 vlan], [1], [], +[ovn-nbctl: lp0: port name not found +]) +AT_CHECK([ovn-nbctl lrp-set-redirect-type lrp0 vlan], [0], []) +AT_CHECK([ovn-nbctl lrp-get-redirect-type lrp0], [0], [dnl +vlan +]) +AT_CHECK([ovn-nbctl lrp-set-redirect-type lrp0 overlay], [0], []) +AT_CHECK([ovn-nbctl lrp-get-redirect-type lrp0], [0], [dnl +overlay +]) +AT_CHECK([ovn-nbctl lrp-set-redirect-type lrp0 abcd], [1], [], +[ovn-nbctl: Invalid redirect type: abcd +]) + +]) + +dnl --------------------------------------------------------------------- + OVN_NBCTL_TEST([ovn_nbctl_lrp_enable], [logical router port enable and disable], [ AT_CHECK([ovn-nbctl lr-add lr0]) AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24]) diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index 0dea04e..8718130 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -936,3 +936,34 @@ OVS_WAIT_UNTIL([ test 0 = $?]) AT_CLEANUP + +AT_SETUP([ovn -- check Redirect Chassis propagation from NB to SB]) +AT_SKIP_IF([test $HAVE_PYTHON = no]) +ovn_start + +ovn-sbctl chassis-add gw1 geneve 127.0.0.1 + +ovn-nbctl lr-add R1 +ovn-nbctl lrp-add R1 R1-S1 02:ac:10:01:00:01 172.16.1.1/24 + +ovn-nbctl ls-add S1 +ovn-nbctl lsp-add S1 S1-R1 +ovn-nbctl lsp-set-type S1-R1 router +ovn-nbctl lsp-set-addresses S1-R1 router +ovn-nbctl --wait=sb lsp-set-options S1-R1 router-port=R1-S1 + +ovn-nbctl lrp-set-gateway-chassis R1-S1 gw1 + +uuid=`ovn-sbctl --columns=_uuid --bare find Port_Binding logical_port=cr-R1-S1` +echo "CR-LRP UUID is: " $uuid + +ovn-nbctl lrp-set-redirect-type R1-S1 vlan +AT_CHECK([ovn-sbctl get Port_Binding ${uuid} options:redirect-type], [0], [vlan +]) + +ovn-nbctl lrp-set-redirect-type R1-S1 overlay +AT_CHECK([ovn-sbctl get Port_Binding ${uuid} options:redirect-type], [0], [overlay +]) + + +AT_CLEANUP diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c index b8b440e..5444fc7 100644 --- a/utilities/ovn-nbctl.c +++ b/utilities/ovn-nbctl.c @@ -667,6 +667,14 @@ Logical router port commands:\n\ ('enabled' or 'disabled')\n\ lrp-get-enabled PORT get administrative state PORT\n\ ('enabled' or 'disabled')\n\ + lrp-set-redirect-type PORT TYPE\n\ + set whether redirected packet to gateway chassis\n\ + of PORT will be encapsulated or not\n\ + ('overlay' or 'vlan')\n\ + lrp-get-redirect-type PORT\n\ + get whether redirected packet to gateway chassis\n\ + of PORT will be encapsulated or not\n\ + ('overlay' or 'vlan')\n\ \n\ Route commands:\n\ [--policy=POLICY] lr-route-add ROUTER PREFIX NEXTHOP [PORT]\n\ @@ -4597,6 +4605,62 @@ nbctl_lrp_get_enabled(struct ctl_context *ctx) !lrp->enabled || *lrp->enabled ? "enabled" : "disabled"); } + +/* Set the logical router port redirect type. */ +static void +nbctl_lrp_set_redirect_type(struct ctl_context *ctx) +{ + const char *id = ctx->argv[1]; + const char *type = ctx->argv[2]; + const struct nbrec_logical_router_port *lrp = NULL; + struct smap lrp_options; + + char *error = lrp_by_name_or_uuid(ctx, id, true, &lrp); + if (error) { + ctx->error = error; + return; + } + + if (strcasecmp(type, "vlan") && strcasecmp(type, "overlay")) { + error = xasprintf("Invalid redirect type: %s", type); + ctx->error = error; + return; + } + + smap_init(&lrp_options); + + ovsdb_datum_to_smap(&lrp_options, + nbrec_logical_router_port_get_options + (lrp, OVSDB_TYPE_STRING, OVSDB_TYPE_STRING)); + + if (smap_get(&lrp_options, "redirect-type")) { + smap_replace(&lrp_options, "redirect-type", type); + } else { + smap_add(&lrp_options, "redirect-type", type); + } + + nbrec_logical_router_port_set_options(lrp, &lrp_options); + + smap_destroy(&lrp_options); +} + +static void +nbctl_lrp_get_redirect_type(struct ctl_context *ctx) +{ + const char *id = ctx->argv[1]; + const struct nbrec_logical_router_port *lrp = NULL; + + char *error = lrp_by_name_or_uuid(ctx, id, true, &lrp); + if (error) { + ctx->error = error; + return; + } + + const char *redirect_type = smap_get(&lrp->options, "redirect-type"); + ds_put_format(&ctx->output, "%s\n", + !redirect_type ? "overlay": redirect_type); +} + struct ipv4_route { int priority; @@ -5604,6 +5668,10 @@ static const struct ctl_command_syntax nbctl_commands[] = { NULL, "", RW }, { "lrp-get-enabled", 1, 1, "PORT", NULL, nbctl_lrp_get_enabled, NULL, "", RO }, + { "lrp-set-redirect-type", 2, 2, "PORT TYPE", NULL, + nbctl_lrp_set_redirect_type, NULL, "", RW }, + { "lrp-get-redirect-type", 1, 1, "PORT", NULL, nbctl_lrp_get_redirect_type, + NULL, "", RO }, /* logical router route commands. */ { "lr-route-add", 3, 4, "ROUTER PREFIX NEXTHOP [PORT]", NULL, From patchwork Sat Aug 17 00:36:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankur Sharma X-Patchwork-Id: 1148549 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nutanix.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nutanix.com header.i=@nutanix.com header.b="M1YQB0i0"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 469Lrd4Qw8z9sDQ for ; Sat, 17 Aug 2019 10:38:08 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 3E72BC87; Sat, 17 Aug 2019 00:36:51 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id B97FFC7D for ; Sat, 17 Aug 2019 00:36:47 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx0a-002c1b01.pphosted.com (mx0a-002c1b01.pphosted.com [148.163.151.68]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3D82063D for ; Sat, 17 Aug 2019 00:36:47 +0000 (UTC) Received: from pps.filterd (m0127840.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7H0YLO5015982 for ; Fri, 16 Aug 2019 17:36:46 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=proofpoint20171006; bh=kN7GIcvHJ4hjBMfb8F3n904XYjiI8tUJdmANSBU7sEY=; b=M1YQB0i096Fxlr9eLr62kFNeZQ8qCzykSQ/JV0aEGF0W6Lh6CcxB1OTSgV7cxGvr130k kqyHZ7P3tItBI41zkGguC2gWYbC2WQQfJfiupLw1DAZGVMN/+IlhZOj4KHWhvTdKkM6p xy+XLYjClnIfSvr4BLEEMp/yk0WCmAvQeGa14YBLeycICg2a3yWN10OwSc6SDhe/44zy v4czojSMzmZdBieG9uw9tLESIbK7m1r5ZXOtlb9VvdT8/om7dLCSvAoZ740UOfVBkN7L +E6sW1sNoUvVOE96FDW8C+z2rSRNvuTa+acXq+Ycqn94e4b0XyOzKuQ19CeIZ4OXNjcU qg== Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2059.outbound.protection.outlook.com [104.47.45.59]) by mx0a-002c1b01.pphosted.com with ESMTP id 2ubf9ugpwk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 16 Aug 2019 17:36:46 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gjv66J0Tmh5/ndDTpFd9oLGKA3FwL+7ar8AqC+UdTPeJ2+rovYs+l3JftpPpPA426lJa5aA5yLKPctJBuoCftvjJ08vn3MewNWIU0lxaY4xzhEQzIlDckR0KC7hLi73NrUYXqEHsRDaWcWiuxVZ/z7qSaSG2GiA4M0p8JbpPcqfZ1ZYngi9z+96FiFPTH55+tiOJlw+BQqmy7i0olYne6XyPWXJ12uaCv0ZKsCYKHTJSlVrFn2EkIy81zPlCpg+Tc/ybDy6trcmXwUaqynERTRj6+HJRjiWVi7YMxtn5u+EYl7bMYtcQdEHc/UiLcWYmGmgJ+9aCJJZ6Q6GGwOHMdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kN7GIcvHJ4hjBMfb8F3n904XYjiI8tUJdmANSBU7sEY=; b=WuTq3tNWJKFxasP6CGhWgsfQu0etGpRfm/46unpJLmVHKUmY/s3u8CvoVHvkwunUTmtQgIzRD6sSk3gFBuGUtzOvOUPoGw7uGWUYutqykdsT+vQwR+w+Y2moTvDjbRtQTRaztwdwQmhOsU4bmFX2uNiCLxbiUEweCS5zoj11sm4WHZSE2kx2+tq605c+PT33I4f+A7UHj06gPoGBVOemf8xjfFxCTM2Qfif1etAw19700qYxzwz0IF4aUeL6ZMqGutuPteClopuAI4oLl+RVYYnLAt7q6WZyRaYO9iLsUxQb845nbR0ZJJ9bTkc0kCbHvDcrmKm3vuVMMll9VeYYPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from MW2PR02MB3899.namprd02.prod.outlook.com (52.132.178.28) by MW2PR02MB3755.namprd02.prod.outlook.com (52.132.177.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Sat, 17 Aug 2019 00:36:45 +0000 Received: from MW2PR02MB3899.namprd02.prod.outlook.com ([fe80::a4e3:ca62:dfc6:1149]) by MW2PR02MB3899.namprd02.prod.outlook.com ([fe80::a4e3:ca62:dfc6:1149%3]) with mapi id 15.20.2157.022; Sat, 17 Aug 2019 00:36:45 +0000 From: Ankur Sharma To: "ovs-dev@openvswitch.org" Thread-Topic: [PATCH v6 3/4 ovn] OVN: Vlan backed DVR N-S, avoid get_arp on non redirect chassis. Thread-Index: AQHVVJPZ5iho/jfJ+E6ckF10rQlezg== Date: Sat, 17 Aug 2019 00:36:45 +0000 Message-ID: <1566002197-29398-4-git-send-email-ankur.sharma@nutanix.com> References: <1566002197-29398-1-git-send-email-ankur.sharma@nutanix.com> In-Reply-To: <1566002197-29398-1-git-send-email-ankur.sharma@nutanix.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BY5PR03CA0017.namprd03.prod.outlook.com (2603:10b6:a03:1e0::27) To MW2PR02MB3899.namprd02.prod.outlook.com (2603:10b6:907:4::28) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 1.8.3.1 x-originating-ip: [192.146.154.98] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: aaaa8241-740b-454e-f50f-08d722aafb65 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600148)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MW2PR02MB3755; x-ms-traffictypediagnostic: MW2PR02MB3755: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-proofpoint-crosstenant: true x-ms-oob-tlc-oobclassifiers: OLM:3044; x-forefront-prvs: 0132C558ED x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(376002)(396003)(39860400002)(366004)(346002)(199004)(189003)(256004)(6916009)(66476007)(66556008)(102836004)(2906002)(14444005)(71200400001)(5024004)(66574012)(64756008)(26005)(478600001)(53936002)(66446008)(99286004)(66946007)(5640700003)(81166006)(107886003)(81156014)(8676002)(386003)(6486002)(305945005)(71190400001)(76176011)(5660300002)(7736002)(4326008)(6512007)(25786009)(6506007)(2351001)(50226002)(44832011)(52116002)(316002)(8936002)(6436002)(3846002)(446003)(4720700003)(14454004)(86362001)(186003)(476003)(486006)(66066001)(2616005)(2501003)(11346002)(6116002)(36756003)(64030200001); DIR:OUT; SFP:1102; SCL:1; SRVR:MW2PR02MB3755; H:MW2PR02MB3899.namprd02.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nutanix.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: VVBvnm6lBDwGe/9fO4VY7lD+00FmhI//P9cXxF81r/DA+4lltT9khtW0s/e3IjY3oL8TSG/ItagXy0eOnb/DSwaYvADFjkVOeGR3coBYVAqx+p3V7ftGwrCcjHbLfefiTzzCMiURcol5eGnVZtIafYC65jfPF+I5ct3D/h07lZR6EhvrISeloSx9qws0mtnoLUn2uMJoSTf/zXRxSEaXiVksuW9vYeMTojkGSF9pOKlndx0Jhd/V/34oxObEjpRjhl3XW6vK2mwfZl6M7dYXuLmIHbUh0JteHT1a+Lvd5sK4R1ibZSGzL8CdHZUMGxD/pYn9TirSD2i2a2zAYJfKcm1bD5Eudf7Wcp0OzOslM/0SNO8Ra7eOFTQNegyJx3Zkhhv1zVknHlMwsUp3H9XAFlZMiGemBKFWyZ0SLT/auMU= MIME-Version: 1.0 X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: aaaa8241-740b-454e-f50f-08d722aafb65 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Aug 2019 00:36:45.5241 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 1Q1HohDE/zW0ijGIKB4wB7NuS4GGdf4JwKzOjzLDMApMOHu4E7aRTNtl3Si4ePrQWntyECJ8n39d//xrg0QXJGKk4XgJX7/BXcG6rJ+4WXw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR02MB3755 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:5.22.84,1.0.8 definitions=2019-08-16_10:2019-08-16,2019-08-16 signatures=0 X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v6 3/4 ovn] OVN: Vlan backed DVR N-S, avoid get_arp on non redirect chassis. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Background: With c0974331b7a19a87ab8f1f2cec8fbe366af92fa2, we have added support for E-W workflow for vlan backed DVRs. This series enables N-S workflow for vlan backed DVRs. Key difference between E-W and N-S traffic flow is that N-S flow requires a gateway chassis. A gateway chassis will be respondible for following: a. Doing Network Address Translation (NAT). b. Becoming entry and exit point for North->South and South->North traffic respectively. OVN by default always uses overlay encapsulation to redirect the packet to gateway chassis. This series will enable the redirection to gateway chassis in the absence of encapsulation. This patch: a. Make sure that ARP request for endpoint behind the gateway router port is sent from gateway chassis only and not from host(compute) chassis. b. This is achieved by adding a new logical flow in lr_in_arp_resolve at priority=50. c. This flow run on non gateway chassis and sets the destination mac to router port mac, if outport is a gateway chassis attached router port and redirect-type is set as "vlan". Example logical flow: table=9 (lr_in_arp_resolve ), priority=50 , match=(outport == "router-to-underlay" && !is_chassis_resident("cr-router-to-underlay")), action=(eth.dst = 00:00:01:01:02:04; next;) d. This change is needed because other wise for non resolved ARPs, we will end up doing get_arp in host chassis. Doing so will have following issues: i. We want all the interation with North bound endpoints via gateway chassis only, doing so on host chassis will violate that. ii. With get_arp, ovn-controller will generate the ARP using router port's mac as source mac, which will lead us to the same issue, where router port mac will be going through continous mac moves in physical network. Worst, it would affect the redirection, since it uses router port mac as destination mac. Signed-off-by: Ankur Sharma Signed-off-by: Ankur Sharma > --- northd/ovn-northd.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 89ca8df..e13a5af 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -3516,6 +3516,16 @@ lsp_is_external(const struct nbrec_logical_switch_port *nbsp) return !strcmp(nbsp->type, "external"); } +/* Returns true if lrp has either gateway chassis or ha chassis group + * attached to it. */ +static bool +lrp_has_gateway(const struct nbrec_logical_router_port *nbrp) +{ + return (nbrp->n_gateway_chassis || + (nbrp->ha_chassis_group && nbrp->ha_chassis_group->n_ha_chassis)) + ? true : false; +} + static bool build_dhcpv4_action(struct ovn_port *op, ovs_be32 offer_ip, struct ds *options_action, struct ds *response_action, @@ -7568,6 +7578,28 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, 100, ds_cstr(&match), ds_cstr(&actions)); } } + + if (!op->derived && lrp_has_gateway(op->nbrp)) { + const char *redirect_type = smap_get(&op->nbrp->options, + "redirect-type"); + if (redirect_type && !strcasecmp(redirect_type, "vlan")) { + /* Packet is on a non gateway chassis and + * has an unresolved ARP on a network behind gateway + * chassis attached router port. Since, redirect type + * is set to vlan, hence instead of calling "get_arp" + * on this node, we will redirect the packet to gateway + * chassis, by setting destination mac router port mac.*/ + ds_clear(&match); + ds_put_format(&match, "outport == %s && " + "!is_chassis_resident(%s)", op->json_key, + op->od->l3redirect_port->json_key); + ds_clear(&actions); + ds_put_format(&actions, "eth.dst = %s; next;", + op->lrp_networks.ea_s); + ovn_lflow_add(lflows, op->od, S_ROUTER_IN_ARP_RESOLVE, + 50, ds_cstr(&match), ds_cstr(&actions)); + } + } } else if (op->od->n_router_ports && strcmp(op->nbsp->type, "router") && strcmp(op->nbsp->type, "virtual")) { /* This is a logical switch port that backs a VM or a container. From patchwork Sat Aug 17 00:36:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankur Sharma X-Patchwork-Id: 1148556 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nutanix.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nutanix.com header.i=@nutanix.com header.b="pXSiwHSF"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 469M9C3hgYz9sDQ for ; Sat, 17 Aug 2019 10:52:30 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id AE770CC8; Sat, 17 Aug 2019 00:52:27 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 9796DCC1 for ; Sat, 17 Aug 2019 00:52:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx0b-002c1b01.pphosted.com (mx0b-002c1b01.pphosted.com [148.163.155.12]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 9889063D for ; Sat, 17 Aug 2019 00:52:24 +0000 (UTC) Received: from pps.filterd (m0127842.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7H0ouSS007032 for ; Fri, 16 Aug 2019 17:52:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=proofpoint20171006; bh=eKrhNjR0cXn1SCF4mxfFj8rtU7X2pWQ3wfinOR6MZI0=; b=pXSiwHSFdbhfxTE8wGN+9mvwgCC5fSE6lePt/gFZzqIUOmqifgEVvPpo1LGCrA9in0eo onnuKyvEKRq7QpFWCdp6yG5R/jMEVa8G9e8N5z/hAgnIjWfKht5B8k0IWhur5tK+ppi5 fwjpDMbuMLIh90B4A2c9zRGBqv1NYujRSUMpcdEp+k/70RF7cxyuDDdsXmgnjwRaoqnA 391gqo4FfIzZ594OlZuH1eCUWFD686kJgZ4Jo6DYuQMARBXt5REpcppjqghi7G+VDfZy Riajs8R9+7riMCd7n3G78ffU/59MaLkAyfJDAiM6dyCr/Z1nVth6WvtD1XklW5/dmFwL uA== Received: from nam03-by2-obe.outbound.protection.outlook.com (mail-by2nam03lp2052.outbound.protection.outlook.com [104.47.42.52]) by mx0b-002c1b01.pphosted.com with ESMTP id 2ubf9x8f4q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 16 Aug 2019 17:52:23 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sz6xi2Wznyn4BwtmR8CVasM9IcbpFKz8sS0fuUZnehF5oXmeNMeuFHjoYzQfx8vCdCrQrnT0uPvGk2Itkzp0QQMdkU5UQ57NZCbgyd923beJzGfBszLui0oTOVIrRtIo9emHkp+PD00fgm2tq0qSUMdFS4nzE3bw283NpTEKOimPiFiJ6Eea6W6yoCOUsDj0glek0CsoSw+aay4V1KMwFZc7h4Cg8dmmQTovdMc6gMLP+py+lCWzhzFeZ7cHnGgMhF0ue6KmjytlpolH7ds+iWWjp8Cb2WmA2+ebxuMeKINRbJ7SMJ7S5Sxsh/nN1252iF/wxXvt2iaYa2MigvLc0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eKrhNjR0cXn1SCF4mxfFj8rtU7X2pWQ3wfinOR6MZI0=; b=ZNdvXSDywMQEj/dvtIjFnQwZMOaMPhCEQDFv4Mbazo2Wu9O3zURRUiOUIcOV8Cc9cscIN8eg1JFzG1/rv9KB2DhpkvFpet+/G/iApe/X7lTz+Z+M2LKu9zNqKHn8qYO45ssby4qfmBxJnE1Mc4WH4ZgEhlf+2qyewVdBykYG3UhIomF8cz4SDnRQZVNJmZf/pOsFHfW2RADrqfQRXFDnKEpn+FamXlIjWMIk0ehfe31FO2jsrEFOwpGrxdFLaJfHBMJi9TxyG7tq14o+8ZIAfhIn0iXbRFgSKv0JlWyhysssSrIPvIMw5Hl8vhZXi9lbXrtP0IfITcc8RFI8oGm2Xg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from MW2PR02MB3899.namprd02.prod.outlook.com (52.132.178.28) by MW2PR02MB3755.namprd02.prod.outlook.com (52.132.177.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Sat, 17 Aug 2019 00:36:46 +0000 Received: from MW2PR02MB3899.namprd02.prod.outlook.com ([fe80::a4e3:ca62:dfc6:1149]) by MW2PR02MB3899.namprd02.prod.outlook.com ([fe80::a4e3:ca62:dfc6:1149%3]) with mapi id 15.20.2157.022; Sat, 17 Aug 2019 00:36:46 +0000 From: Ankur Sharma To: "ovs-dev@openvswitch.org" Thread-Topic: [PATCH v6 4/4 ovn] OVN: Vlan backed DVR N-S, redirect packet via localnet port Thread-Index: AQHVVJPZzl09Ef3LI0yaVbuvphpp3w== Date: Sat, 17 Aug 2019 00:36:46 +0000 Message-ID: <1566002197-29398-5-git-send-email-ankur.sharma@nutanix.com> References: <1566002197-29398-1-git-send-email-ankur.sharma@nutanix.com> In-Reply-To: <1566002197-29398-1-git-send-email-ankur.sharma@nutanix.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BY5PR03CA0017.namprd03.prod.outlook.com (2603:10b6:a03:1e0::27) To MW2PR02MB3899.namprd02.prod.outlook.com (2603:10b6:907:4::28) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 1.8.3.1 x-originating-ip: [192.146.154.98] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4facb699-78a0-4932-df9a-08d722aafc1d x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600148)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MW2PR02MB3755; x-ms-traffictypediagnostic: MW2PR02MB3755: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-proofpoint-crosstenant: true x-ms-oob-tlc-oobclassifiers: OLM:400; x-forefront-prvs: 0132C558ED x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(376002)(396003)(39860400002)(366004)(346002)(199004)(189003)(256004)(6916009)(66476007)(66556008)(102836004)(2906002)(14444005)(71200400001)(5024004)(66574012)(64756008)(26005)(478600001)(53936002)(66446008)(99286004)(30864003)(66946007)(5640700003)(53946003)(81166006)(107886003)(81156014)(8676002)(386003)(6486002)(305945005)(71190400001)(76176011)(5660300002)(7736002)(4326008)(6512007)(25786009)(6506007)(2351001)(50226002)(44832011)(52116002)(316002)(8936002)(6436002)(3846002)(446003)(4720700003)(14454004)(86362001)(186003)(476003)(486006)(66066001)(2616005)(2501003)(11346002)(6116002)(36756003)(64030200001)(569006); DIR:OUT; SFP:1102; SCL:1; SRVR:MW2PR02MB3755; H:MW2PR02MB3899.namprd02.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nutanix.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: +i8CoU9+CIui4En8C0k4zf0XhCROA/56LVhQ5N4evQFqHAe4jo2kLb8+F0ARwJ5+xV6qLkY2NMHNA5XAH4sZc98VnSw1JQCwznh4gfQTZ8cztiVZk/WanSjH2Nt70IBDUdBzocHPSZgpc8dk/8evu7EzUETG9hEIvuI4ID7WqQkxmHNJkPRE6WAtymg7ln3/wrc+i1jPaffAcnh86RBFbeJWs41ZsxRkly/mH9PHfA2TQXa8ngX1uMprMECuAqmZLt7sn0TRewfee1x3MVYeANauJdnAOP0IzjMTMTk1oN2Ic9Ywft1f0QjArTVhwBg3HPh6M98JCPiB0MCRBu6BWAWXybBD9mt6DNT6URq6NTFfnx7Bzql++NfzysHGKuO6OSlNQBZFWlO25PJOYD0q1arLe49/rI+SueP5ZgDOA0g= MIME-Version: 1.0 X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4facb699-78a0-4932-df9a-08d722aafc1d X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Aug 2019 00:36:46.7634 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: R3bzVxFXLTpu4ymj5rdsd4YiEADmTASjzs3VBi722qgMw8bNqgYLNKK08xaquY0XNjur5eT91D36EmHXkejjkQlD9P2z1yCkUUt09ie40T8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR02MB3755 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:5.22.84,1.0.8 definitions=2019-08-16_10:2019-08-16,2019-08-16 signatures=0 X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v6 4/4 ovn] OVN: Vlan backed DVR N-S, redirect packet via localnet port X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Background: With c0974331b7a19a87ab8f1f2cec8fbe366af92fa2, we have added support for E-W workflow for vlan backed DVRs. This series enables N-S workflow for vlan backed DVRs. Key difference between E-W and N-S traffic flow is that N-S flow requires a gateway chassis. A gateway chassis will be respondible for following: a. Doing Network Address Translation (NAT). b. Becoming entry and exit point for North->South and South->North traffic respectively. OVN by default always uses overlay encapsulation to redirect the packet to gateway chassis. This series will enable the redirection to gateway chassis in the absence of encapsulation. This patch: Achieves the vlan backed redirection by doing following: Sender Side: ------------ a. For a remote port of type "chassisredirect" and if it has redirect type as "vlan", then do not add tunnel based redirection flow in table=32. b. In table=33, add a flow with priority=100, that would do following: i. Change the metadata to that of gateway logical switch (i.e logical switch attached to gateway logical router port). ii. Change REG15 to point to localnet port of gateway logical switch. iii. send to packet to table=15. c. In Table=65, packet will hit the existing priority=150 flow to send the packet to physical bridge, while attaching vlan header and changing source mac to chassis mac. Receiver Side: -------------- a. No changes needed OVERALL PACKET FLOW: Sender Side: ----------- a. logical flow in lr_in_gw_redirect stage will ensure that outport of the packet is chassisredirect port. For example: table=12(lr_in_gw_redirect ), priority=50 , match=(outport == "router-to-underlay"), action=(outport = "cr-router-to-underlay"; next;) b. After ingress pipeline, packet will enter the table=32, followed by table=33 c. Table=33, will send the packet to table=65. d. Table=65, will send the packet to uplink bridge with destination mac of chassisredirect port and vlan id of peer logical switch. Receiver Side: ------------- a. Packet is received by the pipeline of peer logical switch. b. Since destination mac is that of router port, hence packet will enter the logical router pipeline. c. Now, packet will go through regular logical router pipeline (both ingress and egress). One caveat with the approach is that ttl will be decremented twice, since the packets are going through logical router ingress pipeline twice (once on sender chassis and again on gateway chassis). No changes needed for the reverse path. Signed-off-by: Ankur Sharma --- controller/physical.c | 255 +++++++++++++++++++++++++++-------------- lib/ovn-util.c | 33 ++++++ lib/ovn-util.h | 5 + ovn-architecture.7.xml | 64 +++++++++++ tests/ovn.at | 304 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 578 insertions(+), 83 deletions(-) diff --git a/controller/physical.c b/controller/physical.c index 5068785..9e56149 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -228,6 +228,165 @@ get_zone_ids(const struct sbrec_port_binding *binding, } static void +put_remote_port_redirect_vlan(const struct + sbrec_port_binding *binding, + const struct hmap *local_datapaths, + struct local_datapath *ld, + struct match *match, + struct ofpbuf *ofpacts_p, + struct ovn_desired_flow_table *flow_table) +{ + struct eth_addr binding_mac; + uint32_t ls_dp_key = 0; + + if (strcmp(binding->type, "chassisredirect")) { + /* VLAN based redirect is only supported for chassisredirect + * type remote ports. */ + return; + } + + bool is_valid_mac = extract_sbrec_binding_first_mac(binding, + &binding_mac); + if (!is_valid_mac) { + return; + } + + for (int i = 0; i < ld->n_peer_ports; i++) { + const struct sbrec_port_binding *sport_binding = ld->peer_ports[i]; + const char *sport_peer_name = smap_get(&sport_binding->options, + "peer"); + const char *distributed_port = smap_get(&binding->options, + "distributed-port"); + + if (!strcmp(sport_peer_name, distributed_port)) { + ls_dp_key = sport_binding->datapath->tunnel_key; + break; + } + } + + if (!ls_dp_key) { + return; + } + + union mf_value value; + struct ofpact_mac *src_mac; + const struct sbrec_port_binding *ls_localnet_port; + + ls_localnet_port = get_localnet_port(local_datapaths, ls_dp_key); + + src_mac = ofpact_put_SET_ETH_SRC(ofpacts_p); + src_mac->mac = binding_mac; + + value.be64 = htonll(ls_dp_key); + + ofpact_put_set_field(ofpacts_p, mf_from_id(MFF_METADATA), + &value, NULL); + + value.be32 = htonl(ls_localnet_port->tunnel_key); + ofpact_put_set_field(ofpacts_p, mf_from_id(MFF_REG15), + &value, NULL); + + put_resubmit(OFTABLE_LOG_TO_PHY, ofpacts_p); + ofctrl_add_flow(flow_table, OFTABLE_LOCAL_OUTPUT, 100, 0, + match, ofpacts_p, &binding->header_.uuid); + +} + +static void +put_remote_port_redirect_overlay(const struct + sbrec_port_binding *binding, + bool is_ha_remote, + struct ha_chassis_ordered *ha_ch_ordered, + enum mf_field_id mff_ovn_geneve, + const struct chassis_tunnel *tun, + uint32_t port_key, + struct match *match, + struct ofpbuf *ofpacts_p, + struct ovn_desired_flow_table *flow_table) +{ + if (!is_ha_remote) { + /* Setup encapsulation */ + const struct chassis_tunnel *rem_tun = + get_port_binding_tun(binding); + if (!rem_tun) { + return; + } + put_encapsulation(mff_ovn_geneve, tun, binding->datapath, + port_key, ofpacts_p); + /* Output to tunnel. */ + ofpact_put_OUTPUT(ofpacts_p)->port = rem_tun->ofport; + } else { + /* Make sure all tunnel endpoints use the same encapsulation, + * and set it up */ + for (size_t i = 0; i < ha_ch_ordered->n_ha_ch; i++) { + const struct sbrec_chassis *ch = ha_ch_ordered->ha_ch[i].chassis; + if (!ch) { + continue; + } + if (!tun) { + tun = chassis_tunnel_find(ch->name, NULL); + } else { + struct chassis_tunnel *chassis_tunnel = + chassis_tunnel_find(ch->name, NULL); + if (chassis_tunnel && + tun->type != chassis_tunnel->type) { + static struct vlog_rate_limit rl = + VLOG_RATE_LIMIT_INIT(1, 1); + VLOG_ERR_RL(&rl, "Port %s has Gateway_Chassis " + "with mixed encapsulations, only " + "uniform encapsulations are " + "supported.", binding->logical_port); + return; + } + } + } + if (!tun) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); + VLOG_ERR_RL(&rl, "No tunnel endpoint found for HA chassis in " + "HA chassis group of port %s", + binding->logical_port); + return; + } + + put_encapsulation(mff_ovn_geneve, tun, binding->datapath, + port_key, ofpacts_p); + + /* Output to tunnels with active/backup */ + struct ofpact_bundle *bundle = ofpact_put_BUNDLE(ofpacts_p); + + for (size_t i = 0; i < ha_ch_ordered->n_ha_ch; i++) { + const struct sbrec_chassis *ch = + ha_ch_ordered->ha_ch[i].chassis; + if (!ch) { + continue; + } + tun = chassis_tunnel_find(ch->name, NULL); + if (!tun) { + continue; + } + if (bundle->n_slaves >= BUNDLE_MAX_SLAVES) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); + VLOG_WARN_RL(&rl, "Remote endpoints for port beyond " + "BUNDLE_MAX_SLAVES"); + break; + } + ofpbuf_put(ofpacts_p, &tun->ofport, sizeof tun->ofport); + bundle = ofpacts_p->header; + bundle->n_slaves++; + } + + bundle->algorithm = NX_BD_ALG_ACTIVE_BACKUP; + /* Although ACTIVE_BACKUP bundle algorithm seems to ignore + * the next two fields, those are always set */ + bundle->basis = 0; + bundle->fields = NX_HASH_FIELDS_ETH_SRC; + ofpact_finish_BUNDLE(ofpacts_p, &bundle); + } + ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 100, 0, + match, ofpacts_p, &binding->header_.uuid); +} + +static void put_replace_router_port_mac_flows(struct ovsdb_idl_index *sbrec_port_binding_by_name, const struct @@ -484,7 +643,8 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, { uint32_t dp_key = binding->datapath->tunnel_key; uint32_t port_key = binding->tunnel_key; - if (!get_local_datapath(local_datapaths, dp_key)) { + struct local_datapath *ld; + if (!(ld = get_local_datapath(local_datapaths, dp_key))) { return; } @@ -830,6 +990,10 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, ofctrl_add_flow(flow_table, OFTABLE_LOCAL_OUTPUT, 100, 0, &match, ofpacts_p, &binding->header_.uuid); } else { + + const char *redirect_type = smap_get(&binding->options, + "redirect-type"); + /* Remote port connected by tunnel */ /* Table 32, priority 100. @@ -846,90 +1010,15 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, match_set_metadata(&match, htonll(dp_key)); match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); - if (!is_ha_remote) { - /* Setup encapsulation */ - const struct chassis_tunnel *rem_tun = - get_port_binding_tun(binding); - if (!rem_tun) { - goto out; - } - put_encapsulation(mff_ovn_geneve, tun, binding->datapath, - port_key, ofpacts_p); - /* Output to tunnel. */ - ofpact_put_OUTPUT(ofpacts_p)->port = rem_tun->ofport; + if (redirect_type && !strcasecmp(redirect_type, "vlan")) { + put_remote_port_redirect_vlan(binding, local_datapaths, + ld, &match, ofpacts_p, flow_table); } else { - /* Make sure all tunnel endpoints use the same encapsulation, - * and set it up */ - for (size_t i = 0; i < ha_ch_ordered->n_ha_ch; i++) { - const struct sbrec_chassis *ch = - ha_ch_ordered->ha_ch[i].chassis; - if (!ch) { - continue; - } - if (!tun) { - tun = chassis_tunnel_find(ch->name, NULL); - } else { - struct chassis_tunnel *chassis_tunnel = - chassis_tunnel_find(ch->name, NULL); - if (chassis_tunnel && - tun->type != chassis_tunnel->type) { - static struct vlog_rate_limit rl = - VLOG_RATE_LIMIT_INIT(1, 1); - VLOG_ERR_RL(&rl, "Port %s has Gateway_Chassis " - "with mixed encapsulations, only " - "uniform encapsulations are " - "supported.", - binding->logical_port); - goto out; - } - } - } - if (!tun) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); - VLOG_ERR_RL(&rl, "No tunnel endpoint found for HA chassis in " - "HA chassis group of port %s", - binding->logical_port); - goto out; - } - - put_encapsulation(mff_ovn_geneve, tun, binding->datapath, - port_key, ofpacts_p); - - /* Output to tunnels with active/backup */ - struct ofpact_bundle *bundle = ofpact_put_BUNDLE(ofpacts_p); - - for (size_t i = 0; i < ha_ch_ordered->n_ha_ch; i++) { - const struct sbrec_chassis *ch = - ha_ch_ordered->ha_ch[i].chassis; - if (!ch) { - continue; - } - tun = chassis_tunnel_find(ch->name, NULL); - if (!tun) { - continue; - } - if (bundle->n_slaves >= BUNDLE_MAX_SLAVES) { - static struct vlog_rate_limit rl = - VLOG_RATE_LIMIT_INIT(1, 1); - VLOG_WARN_RL(&rl, "Remote endpoints for port beyond " - "BUNDLE_MAX_SLAVES"); - break; - } - ofpbuf_put(ofpacts_p, &tun->ofport, - sizeof tun->ofport); - bundle = ofpacts_p->header; - bundle->n_slaves++; - } - - bundle->algorithm = NX_BD_ALG_ACTIVE_BACKUP; - /* Although ACTIVE_BACKUP bundle algorithm seems to ignore - * the next two fields, those are always set */ - bundle->basis = 0; - bundle->fields = NX_HASH_FIELDS_ETH_SRC; - ofpact_finish_BUNDLE(ofpacts_p, &bundle); + put_remote_port_redirect_overlay(binding, is_ha_remote, + ha_ch_ordered, mff_ovn_geneve, + tun, port_key, &match, ofpacts_p, + flow_table); } - ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 100, 0, - &match, ofpacts_p, &binding->header_.uuid); } out: if (ha_ch_ordered) { diff --git a/lib/ovn-util.c b/lib/ovn-util.c index 085498f..ebba7ad 100644 --- a/lib/ovn-util.c +++ b/lib/ovn-util.c @@ -16,6 +16,7 @@ #include "ovn-util.h" #include "dirs.h" #include "openvswitch/vlog.h" +#include "openvswitch/ofp-parse.h" #include "ovn-nb-idl.h" #include "ovn-sb-idl.h" @@ -272,6 +273,38 @@ extract_lrp_networks(const struct nbrec_logical_router_port *lrp, return true; } +bool +extract_sbrec_binding_first_mac(const struct sbrec_port_binding *binding, + struct eth_addr *ea) +{ + char *save_ptr = NULL; + bool ret = false; + + if (!binding->n_mac) { + return ret; + } + + char *tokstr = xstrdup(binding->mac[0]); + + for (char *token = strtok_r(tokstr, " ", &save_ptr); + token != NULL; + token = strtok_r(NULL, " ", &save_ptr)) { + + /* Return the first chassis mac. */ + char *err_str = str_to_mac(token, ea); + if (err_str) { + free(err_str); + continue; + } + + ret = true; + break; + } + + free(tokstr); + return ret; +} + void destroy_lport_addresses(struct lport_addresses *laddrs) { diff --git a/lib/ovn-util.h b/lib/ovn-util.h index 6d5e1df..8461db5 100644 --- a/lib/ovn-util.h +++ b/lib/ovn-util.h @@ -21,6 +21,8 @@ struct nbrec_logical_router_port; struct sbrec_logical_flow; struct uuid; +struct eth_addr; +struct sbrec_port_binding; struct ipv4_netaddr { ovs_be32 addr; /* 192.168.10.123 */ @@ -61,6 +63,9 @@ bool extract_lsp_addresses(const char *address, struct lport_addresses *); bool extract_ip_addresses(const char *address, struct lport_addresses *); bool extract_lrp_networks(const struct nbrec_logical_router_port *, struct lport_addresses *); +bool extract_sbrec_binding_first_mac(const struct sbrec_port_binding *binding, + struct eth_addr *ea); + void destroy_lport_addresses(struct lport_addresses *); char *alloc_nat_zone_key(const struct uuid *key, const char *type); diff --git a/ovn-architecture.7.xml b/ovn-architecture.7.xml index c4099f2..366c201 100644 --- a/ovn-architecture.7.xml +++ b/ovn-architecture.7.xml @@ -1614,6 +1614,70 @@ + VLAN based redirection + + As an enhancement to reside-on-redirect-chassis we support + VLAN based redirection as well. By setting options:redirect-type + to vlan to a gateway chassis attached router port, user can + enforce that redirected packet should not use tunnel port but rather use + localnet port of peer logical switch to go out as vlan packet. + + Following happens for a VLAN based redirection: +
    +
  1. + On compute chassis, packet passes though logical router's + ingress pipeline. +
  2. + +
  3. + If logical outport is gateway chassis attached router port + then packet is "redirected" to gateway chassis using peer logical + switch's localnet port. +
  4. + +
  5. + This VLAN backed redirected packet has destination mac + as router port mac (the one to which gateway chassis is attached) and + vlan id is that of localnet port (peer logical switch of + the logical router port). +
  6. + +
  7. + On the gateway chassis packet will enter the logical router pipeline + again and this time it will passthrough egress pipeline as well. +
  8. + +
  9. + Reverse traffic packet flows stays the same. +
  10. +
+ + Some guidelines and expections with VLAN based redirection: +
    +
  1. + Since router port mac is destination mac, hence it has to be ensured + that physical network learns it on ONLY from the gateway chassis. + Which means that ovn-chassis-mac-mappings should be + configure on all the compute nodes, so that physical network + never learn router port mac from compute nodes. +
  2. + +
  3. + Since packet enters logical router ingress pipeline twice + (once on compute chassis and again on gateway chassis), + hence ttl will be decremented twice. +
  4. + +
  5. + Default redirection type continues to be overlay. + User can switch the redirect-type between vlan + and overlay by changing the value of + options:redirect-type +
  6. + +
+ +

Life Cycle of a VTEP gateway

diff --git a/tests/ovn.at b/tests/ovn.at index 045cec3..c4d5fee 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -15330,3 +15330,307 @@ as hv4 ovs-appctl fdb/show br-phys OVN_CLEANUP([hv1],[hv2],[hv3],[hv4]) AT_CLEANUP + +AT_SETUP([ovn -- 2 HVs, 2 lports/HV, localnet ports, DVR N-S Ping]) +ovn_start + +# In this test cases we create 3 switches, all connected to same +# physical network (through br-phys on each HV). LS1 and LS2 have +# 1 VIF each. Each HV has 1 VIF port. The first digit +# of VIF port name indicates the hypervisor it is bound to, e.g. +# lp23 means VIF 3 on hv2. +# +# All the switches are connected to a logical router "router". +# +# Each switch's VLAN tag and their logical switch ports are: +# - ls1: +# - tagged with VLAN 101 +# - ports: lp11 +# - ls2: +# - tagged with VLAN 201 +# - ports: lp22 +# - ls-underlay: +# - tagged with VLAN 1000 +# Note: a localnet port is created for each switch to connect to +# physical network. + +for i in 1 2; do + ls_name=ls$i + ovn-nbctl ls-add $ls_name + ln_port_name=ln$i + if test $i -eq 1; then + ovn-nbctl lsp-add $ls_name $ln_port_name "" 101 + elif test $i -eq 2; then + ovn-nbctl lsp-add $ls_name $ln_port_name "" 201 + fi + ovn-nbctl lsp-set-addresses $ln_port_name unknown + ovn-nbctl lsp-set-type $ln_port_name localnet + ovn-nbctl lsp-set-options $ln_port_name network_name=phys +done + +# lsp_to_ls LSP +# +# Prints the name of the logical switch that contains LSP. +lsp_to_ls () { + case $1 in dnl ( + lp?[[11]]) echo ls1 ;; dnl ( + lp?[[12]]) echo ls2 ;; dnl ( + *) AT_FAIL_IF([:]) ;; + esac +} + +vif_to_hv () { + case $1 in dnl ( + vif[[1]]?) echo hv1 ;; dnl ( + vif[[2]]?) echo hv2 ;; dnl ( + vif?[[north]]?) echo hv4 ;; dnl ( + *) AT_FAIL_IF([:]) ;; + esac +} + +ip_to_hex() { + printf "%02x%02x%02x%02x" "$@" +} + +net_add n1 +for i in 1 2; do + sim_add hv$i + as hv$i + ovs-vsctl add-br br-phys + ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys + ovs-vsctl set open . external-ids:ovn-chassis-mac-mappings="phys:aa:bb:cc:dd:ee:$i$i" + ovn_attach n1 br-phys 192.168.0.$i + + ovs-vsctl add-port br-int vif$i$i -- \ + set Interface vif$i$i external-ids:iface-id=lp$i$i \ + options:tx_pcap=hv$i/vif$i$i-tx.pcap \ + options:rxq_pcap=hv$i/vif$i$i-rx.pcap \ + ofport-request=$i$i + + lsp_name=lp$i$i + ls_name=$(lsp_to_ls $lsp_name) + + ovn-nbctl lsp-add $ls_name $lsp_name + ovn-nbctl lsp-set-addresses $lsp_name "f0:00:00:00:00:$i$i 192.168.$i.$i" + ovn-nbctl lsp-set-port-security $lsp_name f0:00:00:00:00:$i$i + + OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up $lsp_name` = xup]) + +done + +ovn-nbctl ls-add ls-underlay +ovn-nbctl lsp-add ls-underlay ln3 "" 1000 +ovn-nbctl lsp-set-addresses ln3 unknown +ovn-nbctl lsp-set-type ln3 localnet +ovn-nbctl lsp-set-options ln3 network_name=phys + +ovn-nbctl ls-add ls-north +ovn-nbctl lsp-add ls-north ln4 "" 1000 +ovn-nbctl lsp-set-addresses ln4 unknown +ovn-nbctl lsp-set-type ln4 localnet +ovn-nbctl lsp-set-options ln4 network_name=phys + +# Add a VM on ls-north +ovn-nbctl lsp-add ls-north lp-north +ovn-nbctl lsp-set-addresses lp-north "f0:f0:00:00:00:11 172.31.0.10" +ovn-nbctl lsp-set-port-security lp-north f0:f0:00:00:00:11 + +# Add 3rd hypervisor +sim_add hv3 +as hv3 ovs-vsctl add-br br-phys +as hv3 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys +as hv3 ovs-vsctl set open . external-ids:ovn-chassis-mac-mappings="phys:aa:bb:cc:dd:ee:33" +as hv3 ovn_attach n1 br-phys 192.168.0.3 + +# Add 4th hypervisor +sim_add hv4 +as hv4 ovs-vsctl add-br br-phys +as hv4 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys +as hv4 ovs-vsctl set open . external-ids:ovn-chassis-mac-mappings="phys:aa:bb:cc:dd:ee:44" +as hv4 ovn_attach n1 br-phys 192.168.0.4 + +as hv4 ovs-vsctl add-port br-int vif-north -- \ + set Interface vif-north external-ids:iface-id=lp-north \ + options:tx_pcap=hv4/vif-north-tx.pcap \ + options:rxq_pcap=hv4/vif-north-rx.pcap \ + ofport-request=44 + +ovn-nbctl lr-add router +ovn-nbctl lrp-add router router-to-ls1 00:00:01:01:02:03 192.168.1.3/24 +ovn-nbctl lrp-add router router-to-ls2 00:00:01:01:02:05 192.168.2.3/24 +ovn-nbctl lrp-add router router-to-underlay 00:00:01:01:02:07 172.31.0.1/24 + +ovn-nbctl lsp-add ls1 ls1-to-router -- set Logical_Switch_Port ls1-to-router type=router \ + options:router-port=router-to-ls1 -- lsp-set-addresses ls1-to-router router +ovn-nbctl lsp-add ls2 ls2-to-router -- set Logical_Switch_Port ls2-to-router type=router \ + options:router-port=router-to-ls2 -- lsp-set-addresses ls2-to-router router +ovn-nbctl lsp-add ls-underlay underlay-to-router -- set Logical_Switch_Port \ + underlay-to-router type=router \ + options:router-port=router-to-underlay \ + -- lsp-set-addresses underlay-to-router router + +ovn-nbctl lrp-set-gateway-chassis router-to-underlay hv3 +ovn-nbctl lrp-set-redirect-type router-to-underlay vlan + +ovn-nbctl --wait=sb sync + + +OVN_POPULATE_ARP + +# lsp_to_ls LSP +# +# Prints the name of the logical switch that contains LSP. +lsp_to_ls () { + case $1 in dnl ( + lp?[[11]]) echo ls1 ;; dnl ( + lp?[[12]]) echo ls2 ;; dnl ( + *) AT_FAIL_IF([:]) ;; + esac +} + +vif_to_ls () { + case $1 in dnl ( + vif?[[11]]) echo ls1 ;; dnl ( + vif?[[12]]) echo ls2 ;; dnl ( + vif-north) echo ls-north ;; dnl ( + *) AT_FAIL_IF([:]) ;; + esac +} + +hv_to_num () { + case $1 in dnl ( + hv1) echo 1 ;; dnl ( + hv2) echo 2 ;; dnl ( + hv3) echo 3 ;; dnl ( + hv4) echo 4 ;; dnl ( + *) AT_FAIL_IF([:]) ;; + esac +} + +vif_to_num () { + case $1 in dnl ( + vif22) echo 22 ;; dnl ( + vif21) echo 21 ;; dnl ( + vif11) echo 11 ;; dnl ( + *) AT_FAIL_IF([:]) ;; + esac +} + +vif_to_hv () { + case $1 in dnl ( + vif[[1]]?) echo hv1 ;; dnl ( + vif[[2]]?) echo hv2 ;; dnl ( + vif-north) echo hv4 ;; dnl ( + *) AT_FAIL_IF([:]) ;; + esac +} + +vif_to_lrp () { + echo router-to-`vif_to_ls $1` +} + +ip_to_hex() { + printf "%02x%02x%02x%02x" "$@" +} + + +test_ip() { + # This packet has bad checksums but logical L3 routing doesn't check. + local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 outport=$6 + local packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 + shift; shift; shift; shift; shift + hv=`vif_to_hv $inport` + as $hv ovs-appctl netdev-dummy/receive $inport $packet + in_ls=`vif_to_ls $inport` + for outport; do + out_ls=`vif_to_ls $outport` + if test $in_ls = $out_ls; then + # Ports on the same logical switch receive exactly the same packet. + echo $packet + else + # Routing decrements TTL and updates source and dest MAC + # (and checksum). + out_lrp=`vif_to_lrp $outport` + # For North-South, packet will come via gateway chassis, i.e hv3 + if test $inport = vif-north; then + echo f00000000011aabbccddee3308004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 >> $outport.expected + fi + if test $outport = vif-north; then + echo f0f00000001100000101020708004500001c000000003e110200${src_ip}${dst_ip}0035111100080000 >> $outport.expected + fi + fi >> $outport.expected + done +} + +# Dump a bunch of info helpful for debugging if there's a failure. + +echo "------ OVN dump ------" +ovn-nbctl show +ovn-sbctl show +ovn-sbctl list port_binding +ovn-sbctl list mac_binding + +echo "------ hv1 dump ------" +as hv1 ovs-vsctl show +as hv1 ovs-vsctl list Open_Vswitch + +echo "------ hv2 dump ------" +as hv2 ovs-vsctl show +as hv2 ovs-vsctl list Open_Vswitch + +echo "------ hv3 dump ------" +as hv3 ovs-vsctl show +as hv3 ovs-vsctl list Open_Vswitch + +echo "------ hv4 dump ------" +as hv4 ovs-vsctl show +as hv4 ovs-vsctl list Open_Vswitch + +echo "Send traffic North to South" + +sip=`ip_to_hex 172 31 0 10` +dip=`ip_to_hex 192 168 1 1` +test_ip vif-north f0f000000011 000001010207 $sip $dip vif11 + +# Confirm that North to south traffic works fine. +OVN_CHECK_PACKETS([hv1/vif11-tx.pcap], [vif11.expected]) + +echo "Send traffic South to Nouth" +sip=`ip_to_hex 192 168 1 1` +dip=`ip_to_hex 172 31 0 10` +test_ip vif11 f00000000011 000001010203 $sip $dip vif-north + +# Confirm that South to North traffic works fine. +OVN_CHECK_PACKETS_REMOVE_BROADCAST([hv4/vif-north-tx.pcap], [vif-north.expected]) + +# Confirm that packets did not go out via tunnel port. +AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep table=32 | grep NXM_NX_TUN_METADATA0 | grep n_packets=0 | wc -l], [0], [[0 +]]) + +# Confirm that packet went out via localnet port +AT_CHECK([as hv1 ovs-ofctl dump-flows br-int | grep table=65 | grep priority=150 | grep src=00:00:01:01:02:07 | grep n_packets=1 | wc -l], [0], [[1 +]]) + +echo "----------- Post Traffic hv1 dump -----------" +as hv1 ovs-ofctl dump-flows br-int +as hv1 ovs-ofctl show br-phys +as hv1 ovs-appctl fdb/show br-phys + +echo "----------- Post Traffic hv2 dump -----------" +as hv2 ovs-ofctl dump-flows br-int +as hv2 ovs-ofctl show br-phys +as hv2 ovs-appctl fdb/show br-phys + +echo "----------- Post Traffic hv3 dump -----------" +as hv3 ovs-ofctl dump-flows br-int +as hv3 ovs-ofctl show br-phys +as hv3 ovs-appctl fdb/show br-phys + +echo "----------- Post Traffic hv4 dump -----------" +as hv4 ovs-ofctl dump-flows br-int +as hv4 ovs-ofctl show br-phys +as hv4 ovs-appctl fdb/show br-phys + +OVN_CLEANUP([hv1],[hv2],[hv3],[hv4]) + +AT_CLEANUP