From patchwork Wed Aug 28 01:55:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankur Sharma X-Patchwork-Id: 1154134 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="j7jP9SUP"; 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 46J83Q6g13z9sDB for ; Wed, 28 Aug 2019 11:56:02 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id AE131220F; Wed, 28 Aug 2019 01:55:33 +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 9D449220F for ; Wed, 28 Aug 2019 01:55:32 +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 6A1DA1FB for ; Wed, 28 Aug 2019 01:55:31 +0000 (UTC) Received: from pps.filterd (m0127841.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7S1tRxr010980 for ; Tue, 27 Aug 2019 18:55:30 -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=uJ8BjUy7vdrcBkkEFTGcr2ZKlboWa5uHKGOZ5r3UUmY=; b=j7jP9SUPeb8HtvLaeKnS/wLEY9AI4e96FyZehT8jkm/g8hrnAILHBcNbBLtQjjnRsBp8 IlLEe2sOzyS4XdNafFghbIERjhoTHqhJ+Dx0i5pNh98Zri0+SyXyavUQyQtEf36i1WFB 80msRzIEdacJ0qo78HQfe9BpFaIw4DKyngTapJ7IFo53PVoSsF/ysl8d5QnmMfbQRPai igZ0t1zXJSuDy8svM7g45qhI+pzTJFigc03HXyDCvhhUtWnPvivnI8YBhdNXzoXsnhr/ 9+dHsR/63IYx1h/G11Broqtjga7ecnJMr9GuUIPY6rtCtGp19vxi1czW8AT5Y4PP644e Ww== Received: from nam01-sn1-obe.outbound.protection.outlook.com (mail-sn1nam01lp2052.outbound.protection.outlook.com [104.47.32.52]) by mx0b-002c1b01.pphosted.com with ESMTP id 2uk2s8xmrd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 27 Aug 2019 18:55:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Swb3blu/mCGpurxURJyBUp/i9yliXH7/VjvFl+rjiWS/vtcWcMbTOa4ptaLhaLbCCk009oWJx1buspPvKZpBswqeihywQJFh43VVrNFt8K0mEixcSQ7UebN5FdpEgYM1eGQg4OQVn/BITTCH6CReLwg9sGFX2BW+xQRgsQs4Wu3XOBuyQJUPdiCV1Q/0GaJ1ipY1kctUJZ/V3wQSFqye5IOgyCWDsw6YvXDnX1Ggft8Gs8jdk5SqbzHWaWLFwRyNXOYA/axov5s2QWzspXNC/fFkdhVVyvdqe3I/vDXbM7dgNHLAMIVHxABFUuNDe6UP3+8J2/qX5KfhekLO4k+uMg== 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=uJ8BjUy7vdrcBkkEFTGcr2ZKlboWa5uHKGOZ5r3UUmY=; b=oGvC+Hp/ftdN4RaOcbqrbbORy6ecPPZYzQWq+LXJJLZrrVyvsOVV0qMbSuv3HD1a8EoXwSGlQDO4TGFkPvSCG3/jftE75KLih/S12usl0wHcUWPd4ipDOajmh5TLZtZ3NXJtaAeRisXATIkh9epVWzjBROV6b37g5PHn7QApctNF6Dy2zFA7BrMr2dOH2b7sfbAzjLMkdoX2SQWs2AiLbWQZWhqIgA+85ZR83pHcQN1B9rtnQ4F7NAMcY+Qd7ezDkqadjd/3BLVk1IfJg5nkNnWMyhW7kzjLgvn0yLpORNd6VSDUe51+BalCjCJ13uqEZ+Fu+0wZkuof/GdyPBomNA== 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 MW2PR02MB3865.namprd02.prod.outlook.com (52.132.178.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2199.21; Wed, 28 Aug 2019 01:55:28 +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.2199.021; Wed, 28 Aug 2019 01:55:28 +0000 From: Ankur Sharma To: "ovs-dev@openvswitch.org" Thread-Topic: [PATCH v8 1/3 ovn] OVN: Vlan backed DVR N-S, redirect-type option Thread-Index: AQHVXUOqxECIKrh0wkWccG82IYGCTQ== Date: Wed, 28 Aug 2019 01:55:28 +0000 Message-ID: <1566957337-56025-2-git-send-email-ankur.sharma@nutanix.com> References: <1566957337-56025-1-git-send-email-ankur.sharma@nutanix.com> In-Reply-To: <1566957337-56025-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: BYAPR06CA0036.namprd06.prod.outlook.com (2603:10b6:a03:d4::49) 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: d1cfcbdf-1c37-491d-c1e8-08d72b5acccf x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MW2PR02MB3865; x-ms-traffictypediagnostic: MW2PR02MB3865: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-proofpoint-crosstenant: true x-ms-oob-tlc-oobclassifiers: OLM:843; x-forefront-prvs: 014304E855 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(396003)(136003)(346002)(366004)(376002)(189003)(199004)(14444005)(5024004)(4720700003)(4326008)(386003)(256004)(86362001)(6512007)(99286004)(2616005)(26005)(53936002)(71200400001)(71190400001)(81166006)(52116002)(25786009)(6506007)(6436002)(5660300002)(476003)(76176011)(6916009)(66476007)(486006)(66446008)(316002)(6486002)(44832011)(11346002)(66946007)(2351001)(64756008)(66556008)(102836004)(446003)(50226002)(186003)(5640700003)(2501003)(3846002)(6116002)(66574012)(14454004)(8936002)(305945005)(7736002)(66066001)(478600001)(8676002)(81156014)(36756003)(2906002)(107886003)(64030200001); DIR:OUT; SFP:1102; SCL:1; SRVR:MW2PR02MB3865; H:MW2PR02MB3899.namprd02.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: xp0SK5d0eBOemSNEynRT087O5mAQVzClXtbBeuJ06nogRCjiRVR0FYYNmhEstkRC0gHQUjqq0z8x8NehWgp+0bNeu6U84T4JLC2Wv9FvNWnqOlHT+IH+kKsYwVy2IMjUmby+gpFl6hJUiVRED5Ln9k+2CmGYNKMy4bFXgFVJe+smaseTAFhgs+AsWwQRHxAaeYK9SJGSa20B/GgB8Z8sZTtcILqDsv5/CFa2uBxHA1Kn96/KhxVPYJ98GVXfIRTdZ9/P2UbcQYphGzwMIF0XN2kHE3jxAdnNlbwmiG0QYkpsx5sHKEjddotWnnErHaIJK4lzZrI8SP9hS4cTo2OLQkzMYCiDCfV+wJ0hPSlNVzuAe5sc11MA6//DDPeTxuBAJcXytRFWg8pLQL0r7G9yoHOYKp+lyeyC+GM5QbAi3gw= MIME-Version: 1.0 X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1cfcbdf-1c37-491d-c1e8-08d72b5acccf X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Aug 2019 01:55:28.0572 (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: mioHkB5ZOIW7PpOSW0FupTysJGz8aE5EzFI+6/fPiXuwgsolFZYa9y5a4a+qGjmdQsmhfsgcgZGeM8O9FEmeV4Vx1S8K8r28QVtoyYOQuu0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR02MB3865 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:5.22.84,1.0.8 definitions=2019-08-27_05:2019-08-27,2019-08-27 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 v8 1/3 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 "bridged" 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 bridged 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 --- northd/ovn-northd.c | 6 +++++ ovn-nb.xml | 43 ++++++++++++++++++++++++++++++++++ tests/ovn-nbctl.at | 25 ++++++++++++++++++++ tests/ovn-northd.at | 31 ++++++++++++++++++++++++ utilities/ovn-nbctl.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 170 insertions(+) diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index ca128c9..0a7f181 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -2514,6 +2514,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++; @@ -2605,6 +2608,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 1f8d751..aab369a 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -1954,6 +1954,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 +
  • + +
  • + BRIDGED +
  • +
+ +

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

+ +

+ BRIDGED 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/tests/ovn-nbctl.at b/tests/ovn-nbctl.at index cf06966..197e5b0 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 bridged], [1], [], +[ovn-nbctl: lp0: port name not found +]) +AT_CHECK([ovn-nbctl lrp-set-redirect-type lrp0 bridged], [0], []) +AT_CHECK([ovn-nbctl lrp-get-redirect-type lrp0], [0], [dnl +bridged +]) +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..eebd369 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 bridged +AT_CHECK([ovn-sbctl get Port_Binding ${uuid} options:redirect-type], [0], [bridged +]) + +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..a89a9cb 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,59 @@ 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, "bridged") && strcasecmp(type, "overlay")) { + error = xasprintf("Invalid redirect type: %s", type); + ctx->error = error; + return; + } + + smap_init(&lrp_options); + smap_clone(&lrp_options, &lrp->options); + + 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 +5665,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 Wed Aug 28 01:55:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankur Sharma X-Patchwork-Id: 1154135 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="pRgClZDA"; 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 46J8422Sj6z9sDB for ; Wed, 28 Aug 2019 11:56:34 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 820272223; Wed, 28 Aug 2019 01:55:36 +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 32C54221B for ; Wed, 28 Aug 2019 01:55:34 +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 821C38A8 for ; Wed, 28 Aug 2019 01:55:33 +0000 (UTC) Received: from pps.filterd (m0127841.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7S1tRxt010980 for ; Tue, 27 Aug 2019 18:55:32 -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=hW010GE1lX2SdA+U2HaZHGz/4Gagz+v0cGli6qReYJk=; b=pRgClZDA67ezVUu62QpLKMxyKsWcRSqSY1O3n9ju5gPiWbNTuh7pRGJo7xXVQF0+Csnu ZpzCBuwiDux2e2hM07QmhLw4wkUxo8ijI05GV8jD9Spy/YNzhYqHnD7HAaEGSiHHc3Wx a0lSFl4pbzHERb5uZlTqGRp7vK+SjpX4FHOGfftP1o4l6HDzDngg1fMIvtW4t5wUZedq pHd42SWzcYNPS14BrmyJii9neaIN+5O2Hl4uv2TjjrIqlFv0zhOC5Smwq3cvV9O3juqt HIbRLtoG5gnIyhQSoU3+A5a0acYZ646Ek3uvMs3ELcOpsQzmK60riK+IZbPGuavmm/I7 Og== Received: from nam01-sn1-obe.outbound.protection.outlook.com (mail-sn1nam01lp2052.outbound.protection.outlook.com [104.47.32.52]) by mx0b-002c1b01.pphosted.com with ESMTP id 2uk2s8xmrd-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 27 Aug 2019 18:55:32 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SRxhNLa2BK/v47qlKBHEvCQAu1YJwUrtEqrHL5E9SktOI5Rc/BcxQlI2eO+G31rrGbveA3Z9TzyrHnDrYqf7um0MOazLhDGBi0aIIVjDTjh+JR9HzrH2AB0bMI/kDLAXG5hSu88aT7U9iFSIutAlNyOuaUYV9F1Tlp5gkjvJ26/yC/lOSTT9lTWd92lXXGzUyRlM1ZN+oi9OhpTtxe4fnEHL/77LQ1d44yQ/cIFkvKepxk6IoJ738bB5u3C5QyHhN32K+h6LP4BYe/mjPRjfHgBTr2nJQYXXMAbNIVRekhqW6o5BeKtLnY90D/pliZE6mOD7S8L8qOlay3vtyZLQkw== 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=hW010GE1lX2SdA+U2HaZHGz/4Gagz+v0cGli6qReYJk=; b=jCFETgMzA3VeQRYReBETjE0zwc+2he5bzpfCnoSRy+O4NYpHanFWIgisDW80xV4IwXYipTSGssqkNpvss68e/R6xt3FUQmtp8agXRw3UO1t4P+CseMEcp8RXm/tn2y0WD4dSrOyDOJ+bZzujXsWOOyDJU7a6Lfzz2lc2TS8uaBInsNXH4JDmiENFdMBe+ub2oF1wjI6QGWbvZVGgswZvTdCCMd5DijTeJkUu9avfzfGiuduJ8jJK7SkF/zRLOI42SU+gxnGBk0optzuiTn7TwO9OfmXIr1yl2Pi8CbhXg0Vv5fGx0jHhGmFZmKzZsxHIEv4Z150sYFZLp/TrMObYDg== 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 MW2PR02MB3865.namprd02.prod.outlook.com (52.132.178.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2199.21; Wed, 28 Aug 2019 01:55:29 +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.2199.021; Wed, 28 Aug 2019 01:55:29 +0000 From: Ankur Sharma To: "ovs-dev@openvswitch.org" Thread-Topic: [PATCH v8 2/3 ovn] OVN: Vlan backed DVR N-S, avoid get_arp on non redirect chassis. Thread-Index: AQHVXUOrDb7kE4TrLU+1v3qHxZZl1g== Date: Wed, 28 Aug 2019 01:55:29 +0000 Message-ID: <1566957337-56025-3-git-send-email-ankur.sharma@nutanix.com> References: <1566957337-56025-1-git-send-email-ankur.sharma@nutanix.com> In-Reply-To: <1566957337-56025-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: BYAPR06CA0036.namprd06.prod.outlook.com (2603:10b6:a03:d4::49) 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: 72bc0bba-52c2-4ea8-c838-08d72b5acdaf x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MW2PR02MB3865; x-ms-traffictypediagnostic: MW2PR02MB3865: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-proofpoint-crosstenant: true x-ms-oob-tlc-oobclassifiers: OLM:3044; x-forefront-prvs: 014304E855 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(396003)(136003)(346002)(366004)(376002)(189003)(199004)(14444005)(5024004)(4720700003)(4326008)(386003)(256004)(86362001)(6512007)(99286004)(2616005)(26005)(53936002)(71200400001)(71190400001)(81166006)(52116002)(25786009)(6506007)(6436002)(5660300002)(476003)(76176011)(6916009)(66476007)(486006)(66446008)(316002)(6486002)(44832011)(11346002)(66946007)(2351001)(64756008)(66556008)(102836004)(446003)(50226002)(186003)(5640700003)(2501003)(3846002)(6116002)(66574012)(14454004)(8936002)(305945005)(7736002)(66066001)(478600001)(8676002)(81156014)(36756003)(2906002)(107886003)(64030200001); DIR:OUT; SFP:1102; SCL:1; SRVR:MW2PR02MB3865; H:MW2PR02MB3899.namprd02.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: y2KFhd7t2G4egbS/AacdKAv3B+klnMZ5/NtMmY5RQP682BPe122I06rxrZiT1ZtffPA83ToPJFSy9g/lo4dAyPW6gPjqbinHoEM1h4s4DzG3pieNib6TwQMeK9MNCfSXXXMNU8rKMECQbknK5DwgPMC+A7nGbrgMlmQxFht17uE0+VZIqn+DfyIwGOxg1GdzzkUSR9g/dMXbyGA0GMiLi3V5D5F7XarONCZaweOP+jTCP5LsV+BoyMmoIPhNopUilezOuKFjVAx5CdaHou/rpcl0ClUoUEXsLncAAalfqBZlJMCgrjaWreZ/XqbGWiYbwm9XL+3TFkwlqFVxMhvAFoOTIEnmCTBYUqrdvq6UWhH9acFF98FcCJD8erQ6FGjhoc08cj9lfp9q2J9kjEaF+EEb6SJSpQegsxuAKZY90ec= MIME-Version: 1.0 X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72bc0bba-52c2-4ea8-c838-08d72b5acdaf X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Aug 2019 01:55:29.5274 (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: vwSXryaI3k93KArmrYElacG4Cy+dO8e4WhvrAmOxyvfAJbuIzh9BI4VNiR3YrJELlF2vd3h2+298tikwA9focgpsWqMUBLEbUBEJEtyvs4I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR02MB3865 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:5.22.84,1.0.8 definitions=2019-08-27_05:2019-08-27,2019-08-27 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 v8 2/3 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 --- northd/ovn-northd.8.xml | 12 ++++++++++++ northd/ovn-northd.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/northd/ovn-northd.8.xml b/northd/ovn-northd.8.xml index d45bb15..442e899 100644 --- a/northd/ovn-northd.8.xml +++ b/northd/ovn-northd.8.xml @@ -2239,6 +2239,18 @@ next; get_nd(outport, xxreg0); next;.

+ +
  • +

    + For logical router port with redirect-chassis and redirect-type + being set as bridged, a priority-50 flow will match + outport == "ROUTER_PORT" and !is_chassis_resident + ("cr-ROUTER_PORT") has actions eth.dst = E; + next;, where E is the ethernet address of the + logical router port. +

    +
  • +

    Ingress Table 9: Check packet length

    diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 0a7f181..0daf327 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -3636,6 +3636,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, @@ -7743,6 +7753,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, "bridged")) { + /* 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 Wed Aug 28 01:55:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankur Sharma X-Patchwork-Id: 1154136 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="fzcMTjse"; 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 46J84Z6d4Fz9sDB for ; Wed, 28 Aug 2019 11:57:02 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 55E8C2225; Wed, 28 Aug 2019 01:55:38 +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 02E4A221F for ; Wed, 28 Aug 2019 01:55:36 +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 0CA701FB for ; Wed, 28 Aug 2019 01:55:33 +0000 (UTC) Received: from pps.filterd (m0127841.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x7S1tRxu010980 for ; Tue, 27 Aug 2019 18:55:33 -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=P42x3hLkuuKw2v103NmN3vWVOk58+vHZBeceG+EMsdk=; b=fzcMTjsevzNIuHkvnswvgFZP52yU2qcRPIU4vY4DKn8VtV25vx7tRsmfER9UZBai6UAu wCf7QL/eCP/TJpYqDOYo3hzZjei2+x0BLaylyAw1rOy1NKbUdaKTf2VsJeOO/nzz80nF WW/kVU26knQufhBI7ysW5xRfuviv9cM85GKzVKVkeizK7HoxAkHbRiHjWBB4Rx35kQ2B 1DBmFJuguTw56jQ0J3N7MMjie0EV0wxEzrDyk/6YrMmPUQ3SfYP6ftwZs4tttfEg5uS3 eAW9V6oNhiyqyYInBiSl16yQ+yjZroab30VAlHuOMYyTw7Rub6E+KwdGce116+ugn6AJ 8w== Received: from nam01-sn1-obe.outbound.protection.outlook.com (mail-sn1nam01lp2052.outbound.protection.outlook.com [104.47.32.52]) by mx0b-002c1b01.pphosted.com with ESMTP id 2uk2s8xmrd-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 27 Aug 2019 18:55:33 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fCcOetSwTCr7zX6n5dvjMRYCjuqseIMarJnwUFXDhyF+1nNYvgFHLFIxLIjRbH1KRa6BUb9wkveCTzFEXovYJO1p5D2d0qNPcwU+uDVWSPceinovpbLRw57FcKNnbe2fR/x/lMnMebG/paJB2KUyRz8Hce+idJUx7wtbuAAEIqYsOxktPrGxFLQD8dXfXt3hgkNQ8BSiTvGONxUWKSum2oCgbVlFsHPIQk2qmdCxHQ7sui/hMynByy5DpDaGKpGQWVySaaoYq/Q0AEhP/eCg9OORAqobHgBOoQIEvD+pip4ZaGjkZ90QjKyOKBmkMAq385j+BEYMX9InuBQpIa/lhA== 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=P42x3hLkuuKw2v103NmN3vWVOk58+vHZBeceG+EMsdk=; b=gvhS9exTrlQ4am+tguM9yoERSEr/mA5uRgtaF/6SKfmbTyayi/Wo1uOXh2GGM2X9VuTcMDP93bPO1mUkG2MzILvfDD/oWjmth8Q0IeahyVYNSkKY/RW7TdQCg08c/3Oqf1m85CI9jIk5qPL17yTV+bfEEoigxAlv2x2I1wjZdSbKNH7B++hJlOGnwPkCLLaZ6ee1yk9VuuJG+eceo2BYmKUKTqMhgiMkdx3Q+40SHW4PFegvdAOfOSf2UYqqXc+0vIsC+FwQy/0JTaye90uQhhCNCx7VT93zav1drlF5iiFWzh/Zv7GfpNDzEFx42XsR6+e7S0Gqja8s7W4OdYL7zA== 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 MW2PR02MB3865.namprd02.prod.outlook.com (52.132.178.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2199.21; Wed, 28 Aug 2019 01:55:30 +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.2199.021; Wed, 28 Aug 2019 01:55:30 +0000 From: Ankur Sharma To: "ovs-dev@openvswitch.org" Thread-Topic: [PATCH v8 3/3 ovn] OVN: Vlan backed DVR N-S, redirect packet via localnet port Thread-Index: AQHVXUOr3hgwcBtvAUqY7a56OLFlpg== Date: Wed, 28 Aug 2019 01:55:30 +0000 Message-ID: <1566957337-56025-4-git-send-email-ankur.sharma@nutanix.com> References: <1566957337-56025-1-git-send-email-ankur.sharma@nutanix.com> In-Reply-To: <1566957337-56025-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: BYAPR06CA0036.namprd06.prod.outlook.com (2603:10b6:a03:d4::49) 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: e970fb61-235c-4756-1b40-08d72b5ace65 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MW2PR02MB3865; x-ms-traffictypediagnostic: MW2PR02MB3865: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-proofpoint-crosstenant: true x-ms-oob-tlc-oobclassifiers: OLM:400; x-forefront-prvs: 014304E855 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(396003)(136003)(346002)(366004)(376002)(189003)(199004)(14444005)(5024004)(4720700003)(4326008)(386003)(256004)(86362001)(6512007)(99286004)(2616005)(26005)(53936002)(71200400001)(71190400001)(81166006)(52116002)(25786009)(6506007)(6436002)(5660300002)(53946003)(476003)(76176011)(6916009)(66476007)(486006)(66446008)(316002)(6486002)(44832011)(11346002)(66946007)(2351001)(64756008)(66556008)(102836004)(446003)(30864003)(50226002)(186003)(5640700003)(2501003)(3846002)(6116002)(66574012)(14454004)(8936002)(305945005)(7736002)(66066001)(478600001)(8676002)(81156014)(36756003)(2906002)(107886003)(64030200001)(579004)(559001)(569006); DIR:OUT; SFP:1102; SCL:1; SRVR:MW2PR02MB3865; H:MW2PR02MB3899.namprd02.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: QnmHnVpfNY4IRgXO4DGlQdRnesxoSbLcJZ9MyvXKyXP62Wm+STtTV0NQOx/P3YIaWmbTaCIj13jxIBv/DLvCe5Ti5VHM+q1iMsbv+HT/MNgEMCZzXgxHYfk50nLZn4wGDojy4VxJoSKM/361T2jwYMdnhLN60S+rRAOpFplBq/l4lzbPjZFYtKf9GaAuw/VLNqRIetHOg14c6ufDareKCGOcG2P6hYSUgYPAYU5K2lLqlCHmgPYwj/fIIV8DTzRBaDihHqHHICNRpzMWNjrx0s0NUH4oMwx0B1Kw0flMwSYZZyjLa2DlaYMe0VTcHLLwfYCMpIpXTkQIDG98PxoDe8ZbGCRtDb/BFfgLreea/IC5EuhM/bvqqiJ92Egkx96B+i9sQyJfRgBx9V9bXe/noUzLlEeOeh4GApf3WrvxXwU= MIME-Version: 1.0 X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: e970fb61-235c-4756-1b40-08d72b5ace65 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Aug 2019 01:55:30.7037 (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: yHv1Lrtio9C/wxZ6bpF+2Sc9j6Y9EhTW5eshNFgWCTAfpPTpBny+mViOGRV9vFMAB/tjzz0rOD1bz003BNMWOkRrRmrMo7c9Gq27wMV4j7c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR02MB3865 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:5.22.84,1.0.8 definitions=2019-08-27_05:2019-08-27,2019-08-27 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 v8 3/3 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..427be18 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, "bridged")) { + 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 c5281a0..7bc25b1 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -15492,3 +15492,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 bridged + +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