From patchwork Fri Oct 26 01:39:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankur Sharma X-Patchwork-Id: 989412 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" (1024-bit key; unprotected) header.d=nutanix.com header.i=@nutanix.com header.b="YoojDH+l"; 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 42h6BL0SrJz9s8F for ; Fri, 26 Oct 2018 12:40:10 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 157DC2400; Fri, 26 Oct 2018 01:39:48 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 67F0323FA for ; Fri, 26 Oct 2018 01:39:46 +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 ADB987E8 for ; Fri, 26 Oct 2018 01:39:45 +0000 (UTC) Received: from pps.filterd (m0127838.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.16.0.23/8.16.0.23) with SMTP id w9Q1ZCkC021094 for ; Thu, 25 Oct 2018 18:39:45 -0700 Received: from nam03-by2-obe.outbound.protection.outlook.com (mail-by2nam03lp0052.outbound.protection.outlook.com [216.32.180.52]) by mx0a-002c1b01.pphosted.com with ESMTP id 2nbmetrdb1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 25 Oct 2018 18:39:44 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sdYeLgb4vrsYCnzxZEM3/C2yoDDqazYDlhiAg9X10T8=; b=YoojDH+lDdj+3AX3TDMD71J2B1OVySRGyWyNW5JHPPhkc5Zd2fPf2WsnbY95KGQP97UdJdI8oZ9UBA58B1rKkn95zbpXLV1q27Qy/D2d3umnU3PK5NXTrioHdG4L+s29cJFRp7eWfIfDagbSsXieGsndeCkyMZtGoxlTh253UfQ= 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.1228.24; Fri, 26 Oct 2018 01:39:43 +0000 Received: from MW2PR02MB3899.namprd02.prod.outlook.com ([fe80::658c:be4a:179:1576]) by MW2PR02MB3899.namprd02.prod.outlook.com ([fe80::658c:be4a:179:1576%2]) with mapi id 15.20.1250.028; Fri, 26 Oct 2018 01:39:43 +0000 From: Ankur Sharma To: "ovs-dev@openvswitch.org" Thread-Topic: [PATCH v1 2/3] Vlan Support in ovn, add nbctl commands to set network type Thread-Index: AQHUbMzEBeOgcfH4p0qhV+ejm4EATA== Date: Fri, 26 Oct 2018 01:39:43 +0000 Message-ID: <1540517969-4872-2-git-send-email-ankur.sharma@nutanix.com> References: <1540517969-4872-1-git-send-email-ankur.sharma@nutanix.com> In-Reply-To: <1540517969-4872-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: BYAPR01CA0018.prod.exchangelabs.com (2603:10b6:a02:80::31) To MW2PR02MB3899.namprd02.prod.outlook.com (2603:10b6:907:4::28) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [50.200.179.74] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MW2PR02MB3803; 6:ROqJg3u7n4ep1DlrKjLNVmM/olP/2CJV+aHEMtgTqcbOQe1jYgARsYBjrLyJxk7dkLxKvaRkBtEJfGwgPm09RMCYBF4ZVfw81nIWa+qFM112MinRuRDqygre6YReMvjO/N473WEpENssO6srFkOthFtpBzH5iyzNdjWU0LwSTxOBgslXbjiV1oUXgSt6fZagOStUuc8MqpubEHKRH9pToyfWKxLTlRJg8j3lcq2KqRiNNG1Xzo+acwOFKFLAmGjArlKTmoZAKRXPMG3PUOuzUaSueUhpo5iY1xWBXke/pArSvpzcyr+fuayNOd1kXqBbNDcn0i7+jIR9dBPTiaPmO7wf8uK77f3Ku4gHfhQKKmjmE7qZ0xDxX1c+YUoo7sgL5mv2BCup0srLCUnPoSAjeeTXlwd23bRij4iDQzcXQ7exdZJz+mgVRz0itSDAkVuoubuWVhoK9vHbdzXG+oNv2w==; 5:MsAhTXkuH/jYhYf3M6MMJ1zbOqj52EtGPQu2mcrv6ZnePO+NJkUFkovfNenMva0T8qxqJfP5b1IoMSj6aGbFF6Q72AMqLTIGnmkx3F142Dy7DPHT7rYJFeV3cdK3cSRxGylw12KtxyATRBM2NIQqu3EPxQXygXOmKjymsF1VXjQ=; 7:vPRV9hX/wldTpPeht+ddxwLeAaad9ZpmRy4s4uxZGeHO6V+FNKnrII6oEQ5hBkqqEZ0q4So1Rkp2IfgtDG94IqcEDOCMkIU+a5Toa4CO0O0D4Eif1w80UyMEIPBHBewUDKZaGvkg0etFrQImko4Ta0RgjzK7fT8NHdPRetHyUrqsAMwLB0rlABCUwcpgpRkTmv4qaDROA6VVEXbwEMeaPpAMfe7hrNZPHQ7QP77tVEQtHK5yHDb/ajPxhi0VfhUJ x-ms-office365-filtering-correlation-id: 8680fd52-5748-4e5f-8888-08d63ae3e73a x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:MW2PR02MB3803; x-ms-traffictypediagnostic: MW2PR02MB3803: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(216315784871565)(119230021023882)(211936372134217)(228109839391802)(52384705835673); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231355)(944501410)(52105095)(3002001)(148016)(149066)(150057)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:MW2PR02MB3803; BCL:0; PCL:0; RULEID:; SRVR:MW2PR02MB3803; x-forefront-prvs: 083751FCA6 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(346002)(376002)(136003)(396003)(39860400002)(199004)(189003)(2616005)(561944003)(99286004)(11346002)(81166006)(4326008)(81156014)(8936002)(14454004)(478600001)(446003)(6116002)(3846002)(68736007)(6436002)(486006)(5250100002)(2501003)(44832011)(316002)(2906002)(6486002)(5640700003)(6306002)(106356001)(71200400001)(966005)(53936002)(8676002)(2900100001)(26005)(410100003)(97736004)(7736002)(14444005)(386003)(52116002)(476003)(6506007)(6512007)(86362001)(36756003)(76176011)(66066001)(71190400001)(186003)(102836004)(107886003)(105586002)(25786009)(256004)(5660300001)(6916009)(2351001)(305945005)(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-microsoft-antispam-message-info: 7vtLwhLAl05BlMW5/6dq7otmpCUNBZLU87BP9ZQED2IDpyHwSNewMBR8CA77VcZm9H/GXKGjzEBfq66ITN7GUrUUYiST+bpBWuFoOlo5gBPwdSZ/B+OP14MtSnYpHSDQ2JUMxUa642as2R/+ilNG8w86QTTwsabfR5tYBM+4byc3BCKte9iJmeQBQm7wScmB++XmF0uyYpRqUzFOOrnYHSfJE/6uMuOe4y3ZhBWI2yyNDqgxCbfLiRhDS964t6CTksPdrr/iC5+OxZowesa53448gp8lHSzfWi6gJEnRQwEBbNvAoZz+mYBdSmgkQ+zdqSTmOWakuog8/bCCYzSUfluczqarUV+e3hwvW/BbtdU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8680fd52-5748-4e5f-8888-08d63ae3e73a X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Oct 2018 01:39:43.4614 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR02MB3803 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-10-25_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810260012 X-Spam-Status: No, score=-0.7 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] [PATCH v1 2/3] Vlan Support in ovn, add nbctl commands to set network type 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 As a part of proposal for distributed virtual routing for VLAN networks through OVN, this series has code changes for Layer 2. [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: a. Changes in OVN NB Schema to introduce a logical switch type. b. Changes in ovn-nbctl to configure a logical switch type. c. Changes in ovn-northd to process and save a logical switch type. Adding a logical switch type would be helpful in following: a. Debugging, since VLAN backed logical switch is dependent on localnet ports, hence basic validations like localnet port configured or not etc., can be done with ease. b. Helps with Layer 3 implementation (https://mail.openvswitch.org/pipermail/ovs-dev/2018-October/353179.html). This Patch: a. By default set network_type as overlay during ls_add handling. b. Add a new ovn-nbctl command to set network type of a logical switch. ovn-nbctl ls-set-network-type LS_NAME vlan|overlay c. Display network type along with logical switch, for example: # ovn-nbctl ls-list d94d7531-128b-43a2-bff0-56f2aa2ea878 (bar) (type: overlay) 531e6f24-f6ae-4ea3-856d-ac986f900770 (foo) (type: vlan) d. Unit tests to validate this command Signed-off-by: Ankur Sharma --- ovn/utilities/ovn-nbctl.c | 38 ++++++++++++++++++++++++++++++++++---- tests/ovn-nbctl.at | 40 ++++++++++++++++++++++++++++------------ 2 files changed, 62 insertions(+), 16 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 75dcb07..68afb5a 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -971,8 +971,9 @@ print_lr(const struct nbrec_logical_router *lr, struct ds *s) static void print_ls(const struct nbrec_logical_switch *ls, struct ds *s) { - ds_put_format(s, "switch "UUID_FMT" (%s)", - UUID_ARGS(&ls->header_.uuid), ls->name); + ds_put_format(s, "switch "UUID_FMT" (%s) (type: %s)", + UUID_ARGS(&ls->header_.uuid), ls->name, + strlen(ls->network_type) ? ls->network_type : "overlay"); print_alias(&ls->external_ids, "neutron:network_name", s); ds_put_char(s, '\n'); @@ -1111,6 +1112,31 @@ nbctl_ls_add(struct ctl_context *ctx) if (ls_name) { nbrec_logical_switch_set_name(ls, ls_name); } + + nbrec_logical_switch_set_network_type(ls, "overlay"); +} + +static void +nbctl_ls_set_network_type(struct ctl_context *ctx) +{ + const char *ls_name = ctx->argv[1]; + const char *ls_type = ctx->argv[2]; + const struct nbrec_logical_switch *ls = NULL; + + char *error = ls_by_name_or_uuid(ctx, ls_name, true, &ls); + + if (!ls || error) { + ctx->error = error; + return; + } + + if (strcmp(ls_type, "vlan") && strcmp(ls_type, "overlay")) { + ctl_error(ctx, "Invalid type: \"%s\", supported types are \"vlan\" " + "and \"overlay\"", ls_type); + return; + } + + nbrec_logical_switch_set_network_type(ls, ls_type); } static void @@ -1140,8 +1166,10 @@ nbctl_ls_list(struct ctl_context *ctx) smap_init(&switches); NBREC_LOGICAL_SWITCH_FOR_EACH(ls, ctx->idl) { - smap_add_format(&switches, ls->name, UUID_FMT " (%s)", - UUID_ARGS(&ls->header_.uuid), ls->name); + smap_add_format(&switches, ls->name, UUID_FMT " (%s) (type: %s)", + UUID_ARGS(&ls->header_.uuid), ls->name, + strlen(ls->network_type) ? ls->network_type : + "overlay"); } const struct smap_node **nodes = smap_sort(&switches); for (size_t i = 0; i < smap_count(&switches); i++) { @@ -5048,6 +5076,8 @@ static const struct ctl_command_syntax nbctl_commands[] = { "--may-exist,--add-duplicate", RW }, { "ls-del", 1, 1, "SWITCH", NULL, nbctl_ls_del, NULL, "--if-exists", RW }, { "ls-list", 0, 0, "", NULL, nbctl_ls_list, NULL, "", RO }, + { "ls-set-network-type", 2, 2, "SWITCH TYPE", NULL, + nbctl_ls_set_network_type, NULL, "", RW }, /* acl commands. */ { "acl-add", 5, 6, "{SWITCH | PORTGROUP} DIRECTION PRIORITY MATCH ACTION", diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at index 25414b8..7d07811 100644 --- a/tests/ovn-nbctl.at +++ b/tests/ovn-nbctl.at @@ -56,31 +56,31 @@ m4_define([OVN_NBCTL_TEST], OVN_NBCTL_TEST([ovn_nbctl_basic_switch], [basic switch commands], [ AT_CHECK([ovn-nbctl ls-add ls0]) AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl -<0> (ls0) +<0> (ls0) (type: overlay) ]) AT_CHECK([ovn-nbctl ls-add ls1]) AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl -<0> (ls0) -<1> (ls1) +<0> (ls0) (type: overlay) +<1> (ls1) (type: overlay) ]) AT_CHECK([ovn-nbctl ls-del ls0]) AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl -<0> (ls1) +<0> (ls1) (type: overlay) ]) AT_CHECK([ovn-nbctl show ls0]) AT_CHECK([ovn-nbctl ls-add ls0]) AT_CHECK([ovn-nbctl show ls0 | uuidfilt], [0], - [switch <0> (ls0) + [switch <0> (ls0) (type: overlay) ]) AT_CHECK([ovn-nbctl ls-add ls0], [1], [], [ovn-nbctl: ls0: a switch with this name already exists ]) AT_CHECK([ovn-nbctl --may-exist ls-add ls0]) AT_CHECK([ovn-nbctl show ls0 | uuidfilt], [0], - [switch <0> (ls0) + [switch <0> (ls0) (type: overlay) ]) AT_CHECK([ovn-nbctl --add-duplicate ls-add ls0]) AT_CHECK([ovn-nbctl --may-exist --add-duplicate ls-add ls0], [1], [], @@ -102,7 +102,23 @@ AT_CHECK([ovn-nbctl --add-duplicate ls-add], [1], [], ]) AT_CHECK([ovn-nbctl --may-exist ls-add], [1], [], [ovn-nbctl: --may-exist requires specifying a name -])]) +]) + +AT_CHECK([ovn-nbctl ls-set-network-type ls1 vlan]) +AT_CHECK([ovn-nbctl show ls1 | uuidfilt], [0], + [switch <0> (ls1) (type: vlan) +]) + +AT_CHECK([ovn-nbctl ls-set-network-type ls1 overlay]) +AT_CHECK([ovn-nbctl show ls1 | uuidfilt], [0], + [switch <0> (ls1) (type: overlay) +]) + +AT_CHECK([ovn-nbctl ls-set-network-type ls1 temp], [1], [], + [ovn-nbctl: Invalid type: "temp", supported types are "vlan" and "overlay" +]) + +]) dnl --------------------------------------------------------------------- @@ -1411,7 +1427,7 @@ dnl --------------------------------------------------------------------- OVN_NBCTL_TEST([ovn_nbctl_dry_run_mode], [dry run mode], [ dnl Check that dry run has no permanent effect. AT_CHECK([ovn-nbctl --dry-run ls-add ls0 -- ls-list | uuidfilt], [0], [dnl -<0> (ls0) +<0> (ls0) (type: overlay) ]) AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl ]) @@ -1419,7 +1435,7 @@ AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl dnl Check that dry-run mode is not sticky. AT_CHECK([ovn-nbctl ls-add ls0]) AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl -<0> (ls0) +<0> (ls0) (type: overlay) ])]) dnl --------------------------------------------------------------------- @@ -1429,13 +1445,13 @@ AT_CHECK([ovn-nbctl ls-add ls0 -- ls-add ls1]) dnl Expect one line for one command. AT_CHECK([ovn-nbctl --oneline ls-list | uuidfilt], [0], [dnl -<0> (ls0)\n<1> (ls1) +<0> (ls0) (type: overlay)\n<1> (ls1) (type: overlay) ]) dnl Expect lines for two commands. AT_CHECK([ovn-nbctl --oneline ls-list -- ls-list | uuidfilt], [0], [dnl -<0> (ls0)\n<1> (ls1) -<0> (ls0)\n<1> (ls1) +<0> (ls0) (type: overlay)\n<1> (ls1) (type: overlay) +<0> (ls0) (type: overlay)\n<1> (ls1) (type: overlay) ])]) dnl ---------------------------------------------------------------------