From patchwork Mon Apr 1 12:37:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1072719 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=mellanox.com 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 44XsLX1KWvz9sPp for ; Mon, 1 Apr 2019 23:37:39 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id C6F3070D1; Mon, 1 Apr 2019 12:37: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 6554670C5 for ; Mon, 1 Apr 2019 12:37:35 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 5D0037ED for ; Mon, 1 Apr 2019 12:37:34 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from chrism@mellanox.com) with ESMTPS (AES256-SHA encrypted); 1 Apr 2019 15:37:30 +0300 Received: from dev-r630-04.mtbc.labs.mlnx (dev-r630-04.mtbc.labs.mlnx [10.12.205.14]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x31CbRuP022021; Mon, 1 Apr 2019 15:37:28 +0300 From: Chris Mi To: blp@ovn.org, ovs-dev@openvswitch.org, fbl@sysclose.org Date: Mon, 1 Apr 2019 08:37:23 -0400 Message-Id: <1554122243-125096-1-git-send-email-chrism@mellanox.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: simon.horman@netronome.com Subject: [ovs-dev] [PATCH v3] netdev-vport: Use the dst_port in tunnel netdev name 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: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org If tunnel device dst_port is not the default one, "ovs-dpctl dump-flows" will fail. The error message for vxlan is: netdev_linux|INFO|ioctl(SIOCGIFINDEX) on vxlan_sys_4789 device failed: No such device That's because when calling netdev_vport_construct() for netdev vxlan_sys_xxxx, the default dst_port is used. Actually, the dst_port value is in the netdev name. Use it to avoid the error. Signed-off-by: Chris Mi Reviewed-by: Roi Dayan --- v1 == Any comment about this patch? We are not sure if it is correct to verify the port from the name. If it is correct, is it applicable for other tunnels? Thanks! v2 == Apply the same fix to other tunnel types according to Flavio Leitner's comment. v3 == Addressed Ben Pfaff's comment to deal with the string correctly. lib/netdev-vport.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c index 808a43f..7906980 100644 --- a/lib/netdev-vport.c +++ b/lib/netdev-vport.c @@ -189,22 +189,34 @@ netdev_vport_alloc(void) int netdev_vport_construct(struct netdev *netdev_) { + const struct netdev_class *class = netdev_get_class(netdev_); + const char *dpif_port = netdev_vport_class_get_dpif_port(class); struct netdev_vport *dev = netdev_vport_cast(netdev_); + const char *p, *name = netdev_get_name(netdev_); const char *type = netdev_get_type(netdev_); + uint16_t port = 0; ovs_mutex_init(&dev->mutex); eth_addr_random(&dev->etheraddr); - /* Add a default destination port for tunnel ports if none specified. */ + if ((strlen(name) > strlen(dpif_port) + 1) && + (!strncmp(name, dpif_port, strlen(dpif_port)))) { + p = name + strlen(dpif_port) + 1; + port = atoi(p); + } + + /* If a destination port for tunnel ports is specified in the netdev + * name, use it instead of the default one. Otherwise, use the default + * destination port */ if (!strcmp(type, "geneve")) { - dev->tnl_cfg.dst_port = htons(GENEVE_DST_PORT); + dev->tnl_cfg.dst_port = port ? htons(port) : htons(GENEVE_DST_PORT); } else if (!strcmp(type, "vxlan")) { - dev->tnl_cfg.dst_port = htons(VXLAN_DST_PORT); + dev->tnl_cfg.dst_port = port ? htons(port) : htons(VXLAN_DST_PORT); update_vxlan_global_cfg(netdev_, NULL, &dev->tnl_cfg); } else if (!strcmp(type, "lisp")) { - dev->tnl_cfg.dst_port = htons(LISP_DST_PORT); + dev->tnl_cfg.dst_port = port ? htons(port) : htons(LISP_DST_PORT); } else if (!strcmp(type, "stt")) { - dev->tnl_cfg.dst_port = htons(STT_DST_PORT); + dev->tnl_cfg.dst_port = port ? htons(port) : htons(STT_DST_PORT); } dev->tnl_cfg.dont_fragment = true;