From patchwork Wed Aug 28 01:03:22 2019
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Ankur Sharma
X-Patchwork-Id: 1154124
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="FVZfHDS/"; 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 46J6vP6Gx2z9sBF
for ;
Wed, 28 Aug 2019 11:04:01 +1000 (AEST)
Received: from mail.linux-foundation.org (localhost [127.0.0.1])
by mail.linuxfoundation.org (Postfix) with ESMTP id 86E681EDB;
Wed, 28 Aug 2019 01:03: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 0DCFD1AB1
for ; Wed, 28 Aug 2019 01:03:25 +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 2F2E513A
for ; Wed, 28 Aug 2019 01:03:24 +0000 (UTC)
Received: from pps.filterd (m0127837.ppops.net [127.0.0.1])
by mx0a-002c1b01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id
x7S0xiQK012889
for ; Tue, 27 Aug 2019 18:03: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=DPT/8erHQgVykKLVXf7M/eqjZT3ElTTgSGIQ+/yZgMc=;
b=FVZfHDS/0u/lMXw3LrmCUZ0Iz7Lo09s2Ul9o8SqlG797vD4LAUFFwj8yNwMVlHqlB11k
zKDDwoWl23zm8rSwFCjIyR6tFp0Te91tBd1pyerRAfr6dk/1R1Hhladp8tPbfJ4cyMwv
9SZeY52UMrcpPbfPBHDiOHqFXcLEOVGhITBZDWoI7oaBGUY9y4wK6ObP2Y4AquIsCZwr
cU8ii9sySlEL3dLy/EYHPYZzfFPOKK+nl5z8Uh8mS9LD0MNiZ9BEsBj/ntBkgtOYwu01
gCvzuL2ZohzUmi2FHtHUcGui6VL7EL1wXL0VRiLptQlRpiO2YgHUpcgK7+A4cChfgH4Q
nQ==
Received: from nam05-co1-obe.outbound.protection.outlook.com
(mail-co1nam05lp2056.outbound.protection.outlook.com [104.47.48.56])
by mx0a-002c1b01.pphosted.com with ESMTP id 2uk155ptxk-2
(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256
verify=NOT)
for ; Tue, 27 Aug 2019 18:03:23 -0700
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=BliYcSR/bckXwKFcoL5zsryffoQlrDXnSccKtZ+4u//lE+/vS/5mltUZLaqcV+jeDKx65rt7SLNCTFt6b48DZwfu6SdOhg0UmZt8QYCbl11q1tel3JNTBpsXxSaMzD900KJzVoh2psmHrEQjQ2AGPJEQE5lB59/XU9tFQ9N1hWHMhjIGA1O/VC1sra49JJ47LlVW4bUGQYLH7WO3IwD6KSDzREspPvjA9LdZKoCpce/sIRb3HT4UVl5BDz01J595Ch24NeuE5Q4EuYzF+xwQPGVbkHWNBBWkTDtVQ9uQRHGRkNQJqd+RL5YDYOw9nzysi0XSOQPmJNfJAUJuaU38jQ==
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=DPT/8erHQgVykKLVXf7M/eqjZT3ElTTgSGIQ+/yZgMc=;
b=mRRaGcE0u3umxrThvspT4TOfEKMx2xTVI52vM29kyXkcrpPOFWiI0uojA8xuDjACDSsE4EDCKXWyAspc4M1we2tFoB9TMHTWq8pb/8vC0X5b5Az04RDceNTTF1nqX4dvdeqKsPrvEUFfJEaz8GGxUXEGX8elzROcPDKdJrTPu51qGWDFxZHQk6z3bg4eX/+XHlw0ovT1xnH+WJ5okYH7NEh356CkEXcNUOlAEGQu243HSK9y3FBBAdaS4UNuw1WLQZrS9yXo4awHCTH4IybR+rOOMsy0978OoOafCAlza4Lr5eZaor0cly2ob34dYbQHqQwNuQqvh+XKB564twZHpw==
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
MW2PR02MB3673.namprd02.prod.outlook.com (52.132.177.18) with
Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
15.20.2199.19; Wed, 28 Aug 2019 01:03:22 +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:03:22 +0000
From: Ankur Sharma
To: "ovs-dev@openvswitch.org"
Thread-Topic: [PATCH v7 1/3 ovn] OVN: Vlan backed DVR N-S,
redirect-type option
Thread-Index: AQHVXTxjv0kTVSWylEWezuZy5OaW8Q==
Date: Wed, 28 Aug 2019 01:03:22 +0000
Message-ID: <1566954211-55973-2-git-send-email-ankur.sharma@nutanix.com>
References: <1566954211-55973-1-git-send-email-ankur.sharma@nutanix.com>
In-Reply-To: <1566954211-55973-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: BY5PR04CA0023.namprd04.prod.outlook.com
(2603:10b6:a03:1d0::33) 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: ac2b4bba-df34-4105-57b7-08d72b53858c
x-microsoft-antispam: BCL:0; PCL:0;
RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600166)(711020)(4605104)(1401327)(2017052603328)(7193020);
SRVR:MW2PR02MB3673;
x-ms-traffictypediagnostic: MW2PR02MB3673:
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)(366004)(136003)(39860400002)(396003)(376002)(346002)(199004)(189003)(25786009)(107886003)(186003)(26005)(6506007)(386003)(102836004)(53936002)(86362001)(4326008)(50226002)(8936002)(6116002)(3846002)(486006)(11346002)(446003)(316002)(66946007)(36756003)(8676002)(66476007)(64756008)(66556008)(66446008)(66066001)(305945005)(44832011)(4720700003)(2501003)(6916009)(2906002)(14454004)(478600001)(5660300002)(2616005)(6486002)(99286004)(476003)(76176011)(6436002)(5640700003)(81166006)(81156014)(6512007)(52116002)(7736002)(66574012)(71200400001)(71190400001)(2351001)(5024004)(256004)(14444005)(64030200001);
DIR:OUT; SFP:1102; SCL:1; SRVR:MW2PR02MB3673;
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:
kqo+IO20W1enRln7r/FNJDRldh4u6yCUKqJipeQ1sVabz6ocuUBNGnjSw9HXOMu4gC/XG/KnCrmPWSa8tnpC4GQIIUcNfnbeI8gqiVSzmwca+uefusH0D3QuVUYR6fThGtW/hAZIZIadNQ9T9KoTfKLO0q63vwQhb+GSzF/VDCf6naGFiBkw0ciX0lQ0bQmZ2qDI7e0/J1cTv/31eq89jkrdaYS+OZJ81EWGEv5Tmn2ILnOVv3mVLX6OjyZwfTPvhPDh6TRBzuCFJdVtQA0hl/Sky8+mPpLMs9J+AZf7z2ZlPlYc/hUPTYVbzNPfLqDJdsDosAtHPphhUCSyH0Oy1I3rQHNFEuhmYhGmo2wQcsO2pb9VRS/c5PhyogRlxPzkETF7c+HOb0VIucen+jZe/k2NdxP40GKYtS2xgGAdLLQ=
MIME-Version: 1.0
X-OriginatorOrg: nutanix.com
X-MS-Exchange-CrossTenant-Network-Message-Id:
ac2b4bba-df34-4105-57b7-08d72b53858c
X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Aug 2019 01:03:22.3049
(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:
DpZAFfaBl+GbfvE9O/+n2dR33Q6y6XS7jrllKLAWIXqVYSTD67zrupaK9L19HH8vqyQvrrFWTz9Aq2iQhP+DZ/2rQEEqIkqYIGPth/wy7zg=
X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR02MB3673
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 v7 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
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 | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 183 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/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..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,