From patchwork Sat Mar 16 01:58:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankur Sharma X-Patchwork-Id: 1057302 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="joIHT7Kr"; 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 44LlyY3YLCz9s47 for ; Sat, 16 Mar 2019 13:00:21 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 1E755165F; Sat, 16 Mar 2019 01:58:52 +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 B94281655 for ; Sat, 16 Mar 2019 01:58:50 +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 DDAC712E for ; Sat, 16 Mar 2019 01:58:49 +0000 (UTC) Received: from pps.filterd (m0127842.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2G1tJ7l031541 for ; Fri, 15 Mar 2019 18:58:49 -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=zn1TK3zqwOYvG67/vF3/Tt5hjlPKmwf2qejKFYBAtNk=; b=joIHT7KrwaPJvHfIoIoZEWdbbyKnbDwNRf1YmnNRTfBvMZhMh1/XYQK9WHxjXUixP9E+ fLxRF8Zdb7NcJ03Mmn8UpEDtTgWS1w36AdfCQ7l1dhDXqu8igqmia6K8k2czFfhuekBR /I/wGhg28cnbQu72RiHMpHRkQqHKc11c6d8jtoARVAUwkz1agkQS4HBQGCanPqEV5zZG nHqSnzo//iw5U8VYAA4Bcz1x75PnZiv2vwhIZFCm4FFQSF/q4xFAAL30OhIQAWtCEAAT iaQOfLm5PI1kHRXebQ8xouMhO1lttGmC9zvuNfRUp9B8exfSp3+tSbNvcC1x0BJdSkxO fw== Received: from nam05-by2-obe.outbound.protection.outlook.com (mail-by2nam05lp2057.outbound.protection.outlook.com [104.47.50.57]) by mx0b-002c1b01.pphosted.com with ESMTP id 2r81gksxct-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 15 Mar 2019 18:58:49 -0700 Received: from MW2PR02MB3899.namprd02.prod.outlook.com (52.132.178.28) by MW2PR02MB3803.namprd02.prod.outlook.com (52.132.177.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1709.14; Sat, 16 Mar 2019 01:58:47 +0000 Received: from MW2PR02MB3899.namprd02.prod.outlook.com ([fe80::e06f:12fc:62b0:3c30]) by MW2PR02MB3899.namprd02.prod.outlook.com ([fe80::e06f:12fc:62b0:3c30%3]) with mapi id 15.20.1709.011; Sat, 16 Mar 2019 01:58:47 +0000 From: Ankur Sharma To: "ovs-dev@openvswitch.org" Thread-Topic: [RFC PATCH v2 3/4] L3 N-S support in ovn, do not replace router port mac on gateway chassis Thread-Index: AQHU25vKSFcfxpmKOUKvpXAjA/gYWw== Date: Sat, 16 Mar 2019 01:58:47 +0000 Message-ID: <1552701563-91687-4-git-send-email-ankur.sharma@nutanix.com> References: <1552701563-91687-1-git-send-email-ankur.sharma@nutanix.com> In-Reply-To: <1552701563-91687-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: BYAPR03CA0004.namprd03.prod.outlook.com (2603:10b6:a02:a8::17) 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.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 07ae0a96-0923-4df7-ad13-08d6a9b2ed15 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020); SRVR:MW2PR02MB3803; x-ms-traffictypediagnostic: MW2PR02MB3803: x-ms-exchange-purlcount: 2 x-proofpoint-crosstenant: true x-microsoft-antispam-prvs: x-forefront-prvs: 09781D4C35 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(366004)(39860400002)(396003)(346002)(376002)(199004)(189003)(5660300002)(6116002)(3846002)(97736004)(305945005)(2906002)(2351001)(68736007)(106356001)(86362001)(105586002)(50226002)(71190400001)(71200400001)(5024004)(14444005)(256004)(410100003)(316002)(44832011)(8936002)(2501003)(6916009)(99286004)(14454004)(26005)(107886003)(476003)(2616005)(186003)(11346002)(66066001)(6512007)(8676002)(6306002)(446003)(36756003)(7736002)(966005)(81166006)(81156014)(478600001)(5640700003)(6486002)(4326008)(52116002)(25786009)(102836004)(66574012)(6506007)(386003)(6436002)(76176011)(4720700003)(53936002)(486006)(64030200001); DIR:OUT; SFP:1102; SCL:1; SRVR:MW2PR02MB3803; 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: TvkUtt9WANW5dv4iQ2PP1lvn7AwGtE+hoRbpSpuEn8er4clbnKM7+0OmGQYoGV6cdhDUiX92Dy0n0wqiJ/Sa8qEZVDi6r6XbQGeo5PBRLhDX2H05254sUgeJYWraR/npQxPY/SoeXl6r+7HCLSprU7MLoENbsmptYX1bzgJmPDLlxlaMTqKxcbvGLZFHKf7bJhSIuQBWnke3xXaNP+uuddmH6xQIUV608Sxl65mx34StskGze/6ldf9mak2KrIlPxSmpNJQmnvRmCGK6Ahi5NCFwMRWkPT1gHN8GxuJ7sicK98pt7A7wjKqnQZVNF6JiFEFvwLOcnIysgMpGt7vgsd+/9fD4b/iandQL1TWJzMl44wD4E+jnfWF03hXdKw5kx2WnQzUdgQjGSgK5NPFYbPRrWwvYRivML7uOqMaPQAg= MIME-Version: 1.0 X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 07ae0a96-0923-4df7-ad13-08d6a9b2ed15 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Mar 2019 01:58:47.3392 (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-Transport-CrossTenantHeadersStamped: MW2PR02MB3803 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-16_02:, , signatures=0 X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_DYNAMIC, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [RFC PATCH v2 3/4] L3 N-S support in 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 Background: [1] https://mail.openvswitch.org/pipermail/ovs-dev/2018-October/353066.html [2] https://docs.google.com/document/d/1uoQH478wM1OZ16HrxzbOUvk5LvFnfNEWbkPT6Zmm9OU/edit?usp=sharing This Series: Layer 2, Layer 3 E-W and Layer 3 N-S (NO NAT) changes for vlan backed distributed logical router. This Patch: a. Do not replace router port mac, if the corrsponding cr- port is resident on current chassis. b. We do not need this, as gateway chassis is where we will advertise the router port mac. Signed-off-by: Ankur Sharma --- ovn/controller/physical.c | 30 ++++++++++++-- ovn/controller/pinctrl.c | 57 +++++++++++-------------- ovn/controller/pinctrl.h | 6 +++ tests/ovn.at | 103 +++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 160 insertions(+), 36 deletions(-) diff --git a/ovn/controller/physical.c b/ovn/controller/physical.c index 0fd83ae..71d80e0 100644 --- a/ovn/controller/physical.c +++ b/ovn/controller/physical.c @@ -21,6 +21,7 @@ #include "lflow.h" #include "lport.h" #include "chassis.h" +#include "pinctrl.h" #include "lib/bundle.h" #include "openvswitch/poll-loop.h" #include "lib/uuid.h" @@ -235,8 +236,14 @@ get_zone_ids(const struct sbrec_port_binding *binding, } static void -put_replace_router_port_mac_flows(const struct sbrec_port_binding *localnet_port, +put_replace_router_port_mac_flows(struct ovsdb_idl_index + *sbrec_chassis_by_name, + 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, @@ -277,8 +284,22 @@ put_replace_router_port_mac_flows(const struct sbrec_port_binding *localnet_port char *err_str = NULL; struct match match; struct ofpact_mac *replace_mac; + char *cr_peer_name = xasprintf("cr-%s", rport_binding->logical_port); - /* Table 65, priority 150. + + if (pinctrl_is_chassis_resident(sbrec_chassis_by_name, + 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. * ======================= * * Implements output to localnet port. @@ -793,7 +814,10 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_chassis_by_name, &match, ofpacts_p); if (!strcmp(binding->type, "localnet")) { - put_replace_router_port_mac_flows(binding, chassis, local_datapaths, + put_replace_router_port_mac_flows(sbrec_chassis_by_name, + sbrec_port_binding_by_name, + binding, chassis, + active_tunnels, local_datapaths, ofpacts_p, ofport, flow_table); } diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c index 2a10d1a..72a3d96 100644 --- a/ovn/controller/pinctrl.c +++ b/ovn/controller/pinctrl.c @@ -67,13 +67,6 @@ static void destroy_buffered_packets_map(void); static void pinctrl_handle_put_mac_binding(const struct flow *md, const struct flow *headers, bool is_arp); -static bool -pinctrl_is_chassis_resident(struct ovsdb_idl_index *sbrec_chassis_by_name, - struct ovsdb_idl_index *sbrec_port_binding_by_name, - const struct sbrec_chassis *chassis, - const struct sset *active_tunnels, - const char *port_name); - static void init_put_mac_bindings(void); static void destroy_put_mac_bindings(void); static void run_put_mac_bindings( @@ -134,6 +127,31 @@ pinctrl_init(void) init_buffered_packets_map(); } +bool +pinctrl_is_chassis_resident(struct ovsdb_idl_index *sbrec_chassis_by_name, + 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 { + struct ovs_list *gateway_chassis = + gateway_chassis_get_ordered(sbrec_chassis_by_name, pb); + bool active = gateway_chassis_is_active(gateway_chassis, + chassis, + active_tunnels); + gateway_chassis_destroy(gateway_chassis); + return active; + } +} + static ovs_be32 queue_msg(struct ofpbuf *msg) { @@ -2405,31 +2423,6 @@ get_localnet_vifs_l3gwports( sbrec_port_binding_index_destroy_row(target); } -static bool -pinctrl_is_chassis_resident(struct ovsdb_idl_index *sbrec_chassis_by_name, - 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 { - struct ovs_list *gateway_chassis = - gateway_chassis_get_ordered(sbrec_chassis_by_name, pb); - bool active = gateway_chassis_is_active(gateway_chassis, - chassis, - active_tunnels); - gateway_chassis_destroy(gateway_chassis); - return active; - } -} - /* Extracts the mac, IPv4 and IPv6 addresses, and logical port from * 'addresses' which should be of the format 'MAC [IP1 IP2 ..] * [is_chassis_resident("LPORT_NAME")]', where IPn should be a valid IPv4 diff --git a/ovn/controller/pinctrl.h b/ovn/controller/pinctrl.h index 697d024..7d0b726 100644 --- a/ovn/controller/pinctrl.h +++ b/ovn/controller/pinctrl.h @@ -45,4 +45,10 @@ void pinctrl_run(struct ovsdb_idl_txn *ovnsb_idl_txn, void pinctrl_wait(struct ovsdb_idl_txn *ovnsb_idl_txn); void pinctrl_destroy(void); +bool +pinctrl_is_chassis_resident(struct ovsdb_idl_index *sbrec_chassis_by_name, + struct ovsdb_idl_index *sbrec_port_binding_by_name, + const struct sbrec_chassis *chassis, + const struct sset *active_tunnels, + const char *port_name); #endif /* ovn/pinctrl.h */ diff --git a/tests/ovn.at b/tests/ovn.at index 6af746e..6fce847 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -12282,7 +12282,7 @@ ovn-nbctl list logical_router_port AT_CLEANUP -AT_SETUP([ovn -- 2 HVs, 2 lports/HV, localnet ports, DVR chassis mac]) +AT_SETUP([ovn -- 2 HVs, 2 lports/HV, localnet ports, DVR E-W chassis mac]) ovn_start @@ -12292,6 +12292,8 @@ ovn_start # of VIF port name indicates the hypervisor it is bound to, e.g. # lp23 means VIF 3 on hv2. # +# Both 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 @@ -12475,6 +12477,105 @@ as hv2 ovs-appctl fdb/show br-phys OVN_CHECK_PACKETS([hv2/vif22-tx.pcap], [vif22.expected]) + +# Associate a chassis as gateway chassis and validate garp. + +OVN_CLEANUP([hv1],[hv2]) + +AT_CLEANUP + + +AT_SETUP([ovn -- 2 HVs, 2 lports/HV, localnet ports, DVR N-S GARP]) +ovn_start + + +# In this test cases we create 2 switches, all connected to same +# physical network (through br-phys on each HV). Each switch has +# 1 VIF. 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. +# +# Both the switches are connected to a logical router "router". +# +# Additionally, we create a logical switch (ls-underlay) for N-S traffic. +# +# 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. +# lsp_to_ls LSP +# +# Prints the name of the logical switch that contains LSP. + +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" + ovs-vsctl set open . external-ids:system-id="HV$i" + ovn_attach n1 br-phys 192.168.0.$i + ovs-vsctl set-controller br-int ptcp: +done + +ovn-nbctl ls-add ls-underlay vlan +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 lr-add router +ovn-nbctl lrp-add router router-to-underlay 00:00:01:01:02:07 172.31.0.1/24 + +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 --wait=sb sync + +# Associate hv2 as gateway chassis +ovn-nbctl lrp-set-gateway-chassis router-to-underlay hv2 + +ovn-nbctl show +ovn-sbctl show + +# Dump a bunch of info helpful for debugging if there's a failure. + +echo "------ OVN dump ------" +ovn-nbctl show +ovn-sbctl show + +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 + +sleep 1 + +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 + +AT_CHECK([as hv2 ovs-appctl fdb/show br-phys | grep 00:00:01:01:02:07 | grep 1000 | wc -l], [0], [[1 +]]) + OVN_CLEANUP([hv1],[hv2]) AT_CLEANUP