From patchwork Thu Jun 20 03:02:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasu Dasari X-Patchwork-Id: 1119104 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=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cut5P93x"; 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 45TmpK61Xfz9s5c for ; Thu, 20 Jun 2019 13:02:49 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 54F85A7F; Thu, 20 Jun 2019 03:02:46 +0000 (UTC) X-Original-To: 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 93B829D for ; Thu, 20 Jun 2019 03:02:45 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id E77F0E6 for ; Thu, 20 Jun 2019 03:02:44 +0000 (UTC) Received: by mail-qt1-f195.google.com with SMTP id x2so1703133qtr.0 for ; Wed, 19 Jun 2019 20:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=LGpousrBCzFcKKww8HkQ31gVSCAKED9eFrS4srl49tg=; b=cut5P93xZuvEjrRtZQFnXb+wHO4MSdjZVGe2WyQnpu2lXB+uLldcAgizauJBZg+BuM F2ZdAsNtIAAi4Q922paJ08+p4YfMrdpiGg1cMuV0hNJEAiAhI5gEszto42dCDXo5zMo0 +WM9hk8v/F90tcb+HsbA7D7doWbm7W2hlMhQ6bFUer89KmOFzFIDlqDHE3nt1+o442FI p3k4ahHVln74jjpARcJj9boEz8thaop0OAqpvJWzEg9JubNctcaJIWeok0g/KjliXFib 84v09FeVJJBKfIficQ8vKwyG0hrZIVLE3uyrKLxkiqKr4kI4t3DJWqtm33p+TkdwZzXz +Q9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LGpousrBCzFcKKww8HkQ31gVSCAKED9eFrS4srl49tg=; b=BgZrcMOBWMc8vyx1Z/Pg5XD9w4PYXyKRO0mXJtt3I/0IvE1BCPZFsChPb3f8q+Jvf1 aj4MWT7j6azo2S/KgycG4XAvk31UOhaeZbgNSVpK/BNVhQLc1ryha0HCLXsazpE0fHjy PV3jbZ2MCWc9rrv/fLT/R8ZvvyzMueavsHS0XV2y91m9Pq8hH4NR0diLP73FYlKqjiMX tRXxuviyx93Ucow8viI5Vu537CgHQhUghsfaTm1GQzNOENqXmvChnNW3p8Trc69G4KFW qSw3UB7Vpgn5+MOY+rHFRrCtn/dhTb8dTFA0/pdcijnR2JcykrGAzLORlXsmZIx64PCC 3Wwg== X-Gm-Message-State: APjAAAUE83R6RGuqrYDi/MgQOWSnNg8xKyHBL3Ym6J9/MWgpyJOhJSmL 6/TZyNR9DSf1ZwT6FtAGK8lhGEz2xnY= X-Google-Smtp-Source: APXvYqxTRit8nDNeRFxzeXT0TNsLcEbniJWtFR2Vg3ICWx4CYdYzxlYVhoxE0nfsr3/N6JtJozgbCg== X-Received: by 2002:a0c:c94d:: with SMTP id v13mr37250049qvj.211.1560999763623; Wed, 19 Jun 2019 20:02:43 -0700 (PDT) Received: from localhost.localdomain (c-98-216-4-188.hsd1.nh.comcast.net. [98.216.4.188]) by smtp.gmail.com with ESMTPSA id o66sm11748431qkb.90.2019.06.19.20.02.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Jun 2019 20:02:42 -0700 (PDT) From: Vasu Dasari To: dev@openvswitch.org Date: Wed, 19 Jun 2019 23:02:07 -0400 Message-Id: <20190620030207.17383-1-vdasari@gmail.com> X-Mailer: git-send-email 2.17.2 (Apple Git-113) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: fbl@sysclose.org Subject: [ovs-dev] [PATCH] tnl-neigh-cache: Purge learnt neighbors when port/bridge is deleted 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 Say an ARP entry is learnt on a OVS port and when such a port is deleted, learnt entry should be removed from the port. It would have be aged out after ARP ageout time. This code will clean up immediately. Added test case(tunnel - neighbor entry add and deletion) in tunnel.at, to verify neighbors are added and removed on deletion of a ports and bridges. Discussion for this addition is at: https://mail.openvswitch.org/pipermail/ovs-discuss/2019-June/048754.html Signed-off-by: Vasu Dasari --- lib/tnl-neigh-cache.c | 20 +++++++++++++++++ lib/tnl-neigh-cache.h | 1 + ofproto/ofproto-dpif-xlate.c | 3 +++ tests/tunnel.at | 43 ++++++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+) diff --git a/lib/tnl-neigh-cache.c b/lib/tnl-neigh-cache.c index b28f9f1bb..8718405db 100644 --- a/lib/tnl-neigh-cache.c +++ b/lib/tnl-neigh-cache.c @@ -220,6 +220,26 @@ tnl_neigh_cache_run(void) } } +void +tnl_neigh_flush(const char br_name[]) +{ + struct tnl_neigh_entry *neigh; + bool changed = false; + + ovs_mutex_lock(&mutex); + CMAP_FOR_EACH(neigh, cmap_node, &table) { + if (nullable_string_is_equal(neigh->br_name, br_name)) { + tnl_neigh_delete(neigh); + changed = true; + } + } + ovs_mutex_unlock(&mutex); + + if (changed) { + seq_change(tnl_conf_seq); + } +} + static void tnl_neigh_cache_flush(struct unixctl_conn *conn, int argc OVS_UNUSED, const char *argv[] OVS_UNUSED, void *aux OVS_UNUSED) diff --git a/lib/tnl-neigh-cache.h b/lib/tnl-neigh-cache.h index fee8e6a6f..ded9c2f86 100644 --- a/lib/tnl-neigh-cache.h +++ b/lib/tnl-neigh-cache.h @@ -37,5 +37,6 @@ int tnl_neigh_lookup(const char dev_name[], const struct in6_addr *dst, struct eth_addr *mac); void tnl_neigh_cache_init(void); void tnl_neigh_cache_run(void); +void tnl_neigh_flush(const char dev_name[]); #endif diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 73966a4e8..e0cd8edab 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -1481,6 +1481,9 @@ xlate_ofport_remove(struct ofport_dpif *ofport) ovs_assert(new_xcfg); xport = xport_lookup(new_xcfg, ofport); + if(xport) { + tnl_neigh_flush(netdev_get_name(xport->netdev)); + } xlate_xport_remove(new_xcfg, xport); } diff --git a/tests/tunnel.at b/tests/tunnel.at index 035c54f67..6d7550724 100644 --- a/tests/tunnel.at +++ b/tests/tunnel.at @@ -920,3 +920,46 @@ dnl which is not correct OVS_VSWITCHD_STOP AT_CLEANUP + +AT_SETUP([tunnel - neighbor entry add and deletion]) +OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \ + options:remote_ip=1.1.1.1 options:local_ip=2.2.2.2 \ + options:key=5 ofport_request=1 \ + -- add-port br0 p2 -- set Interface p2 type=gre \ + options:local_ip=3.3.3.3 options:remote_ip=4.4.4.4 \ + ofport_request=2]) +AT_CHECK([ovs-vsctl add-br br1 -- set bridge br1 datapath_type=dummy], [0]) + +dnl Populate tunnel neighbor cache table +AT_CHECK([ + ovs-appctl tnl/arp/set p1 10.0.0.1 00:00:10:00:00:01 + ovs-appctl tnl/arp/set p2 10.0.1.1 00:00:10:00:01:01 + ovs-appctl tnl/arp/set br0 10.0.2.1 00:00:10:00:02:01 + ovs-appctl tnl/arp/set br1 20.0.0.1 00:00:20:00:00:01 +], [0], [stdout]) + +AT_CHECK([ovs-appctl tnl/neigh/show | tail -n+3 | sort], [0], [dnl +10.0.0.1 00:00:10:00:00:01 p1 +10.0.1.1 00:00:10:00:01:01 p2 +10.0.2.1 00:00:10:00:02:01 br0 +20.0.0.1 00:00:20:00:00:01 br1 +]) + +dnl neighbor table after deleting port p1 +AT_CHECK([ovs-vsctl del-port br0 p1],[0], [stdout]) +AT_CHECK([ovs-appctl tnl/neigh/show | tail -n+3 | grep -w p1 | sort], [0], [dnl +]) + +dnl neighbor table after deleting bridge br0 +AT_CHECK([ovs-vsctl del-br br0],[0], [stdout]) +AT_CHECK([ovs-appctl tnl/neigh/show | tail -n+3 | sort], [0], [dnl +20.0.0.1 00:00:20:00:00:01 br1 +]) + +dnl neighbor table after deleting bridge br1 +AT_CHECK([ovs-vsctl del-br br1],[0], [stdout]) +AT_CHECK([ovs-appctl tnl/neigh/show | tail -n+3 | sort], [0], [dnl +]) + +OVS_VSWITCHD_STOP +AT_CLEANUP