From patchwork Mon Oct 12 09:15:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1380759 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C8tMH3sJ2z9sSs for ; Mon, 12 Oct 2020 20:15:55 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 2E9B1873AC; Mon, 12 Oct 2020 09:15:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6ndkuxGfKZpo; Mon, 12 Oct 2020 09:15:52 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 72AAA87237; Mon, 12 Oct 2020 09:15:52 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 48ECFC07FF; Mon, 12 Oct 2020 09:15:52 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0D617C0051 for ; Mon, 12 Oct 2020 09:15:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id E8B708723C for ; Mon, 12 Oct 2020 09:15:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QuC1FpzHSOhn for ; Mon, 12 Oct 2020 09:15:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by hemlock.osuosl.org (Postfix) with ESMTPS id 71D9B87237 for ; Mon, 12 Oct 2020 09:15:48 +0000 (UTC) X-Originating-IP: 27.7.91.162 Received: from nusiddiq.home.org.com (unknown [27.7.91.162]) (Authenticated sender: numans@ovn.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id ACACF20010; Mon, 12 Oct 2020 09:15:44 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Mon, 12 Oct 2020 14:45:35 +0530 Message-Id: <20201012091535.1412723-1-numans@ovn.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Cc: Vladislav Odintsov Subject: [ovs-dev] [PATCH ovn] vtep-controller: extract mac address in building umr X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Vladislav Odintsov port_binding_rec->mac array contains items with addresses (MAC, IP, ...) delimited by whitespace. In Unicast_Macs_Remote record should be only one mac address. Now mac address extracts from port_binding_rec->mac[i]. Submitted-at: https://github.com/ovn-org/ovn/pull/48 Signed-off-by: Vladislav Odintsov Signed-off-by: Numan Siddique --- controller-vtep/vtep.c | 12 ++++++++++-- tests/ovn-controller-vtep.at | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/controller-vtep/vtep.c b/controller-vtep/vtep.c index e2baca5a7..5538c7d6a 100644 --- a/controller-vtep/vtep.c +++ b/controller-vtep/vtep.c @@ -20,6 +20,7 @@ #include "lib/hash.h" #include "openvswitch/hmap.h" #include "openvswitch/shash.h" +#include "lib/ovn-util.h" #include "lib/smap.h" #include "lib/sset.h" #include "lib/util.h" @@ -366,7 +367,13 @@ vtep_macs_run(struct ovsdb_idl_txn *vtep_idl_txn, struct shash *ucast_macs_rmts, for (i = 0; i < port_binding_rec->n_mac; i++) { const struct vteprec_ucast_macs_remote *umr; const struct sbrec_port_binding *conflict; - char *mac = port_binding_rec->mac[i]; + struct lport_addresses laddrs; + + if (!extract_lsp_addresses(port_binding_rec->mac[i], &laddrs)) { + continue; + }; + + char *mac = laddrs.ea_s; /* Checks for duplicate MAC in the same vtep logical switch. */ conflict = shash_find_data(&ls_node->added_macs, mac); @@ -384,7 +391,7 @@ vtep_macs_run(struct ovsdb_idl_txn *vtep_idl_txn, struct shash *ucast_macs_rmts, tnl_key); umr = shash_find_data(ucast_macs_rmts, mac_ip_tnlkey); /* If finds the 'umr' entry for the mac, ip, and tnl_key, deletes - * the entry from shash so that it is not gargage collected. + * the entry from shash so that it is not garbage collected. * * If not found, creates a new 'umr' entry. */ if (umr && umr->logical_switch == ls_node->vtep_ls) { @@ -395,6 +402,7 @@ vtep_macs_run(struct ovsdb_idl_txn *vtep_idl_txn, struct shash *ucast_macs_rmts, vteprec_ucast_macs_remote_set_locator(new_umr, pl); } free(mac_ip_tnlkey); + destroy_lport_addresses(&laddrs); } } diff --git a/tests/ovn-controller-vtep.at b/tests/ovn-controller-vtep.at index 3092dd5ca..f0598fa4d 100644 --- a/tests/ovn-controller-vtep.at +++ b/tests/ovn-controller-vtep.at @@ -383,6 +383,22 @@ AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr - "f0:ab:cd:ef:01:03" ]) +# adds MAC-IP pair to logical switch port. +AT_CHECK([ovn-nbctl lsp-set-addresses vif0 "f0:ab:cd:ef:01:04 192.168.0.1"]) +OVS_WAIT_UNTIL([test -n "`vtep-ctl list Ucast_Macs_Remote | grep 'f0:ab:cd:ef:01:04'`"]) +AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' ' | sort], [0], [dnl +"f0:ab:cd:ef:01:04" +]) + +# adds another MAC-IP pair to logical switch port. +AT_CHECK([ovn-nbctl lsp-set-addresses vif0 "f0:ab:cd:ef:01:04 192.168.0.1" "f0:ab:cd:ef:01:05 192.168.0.2"]) +OVS_WAIT_UNTIL([test -n "`vtep-ctl list Ucast_Macs_Remote | grep 'f0:ab:cd:ef:01:05'`"]) +AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' ' | sort], [0], [dnl + +"f0:ab:cd:ef:01:04" +"f0:ab:cd:ef:01:05" +]) + # removes one mac to logical switch port. AT_CHECK([ovn-nbctl lsp-set-addresses vif0 f0:ab:cd:ef:01:03]) OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=MAC list Ucast_Macs_Remote | grep 02`"])