From patchwork Sun Jul 19 14:15:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1331813 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 4B8n2K2wScz9sRR for ; Mon, 20 Jul 2020 00:15:35 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 9523487B08; Sun, 19 Jul 2020 14:15:33 +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 g1eOWPnRUWP6; Sun, 19 Jul 2020 14:15:32 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 6D01B87AE7; Sun, 19 Jul 2020 14:15:32 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5063BC089F; Sun, 19 Jul 2020 14:15:32 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0B073C016F for ; Sun, 19 Jul 2020 14:15:30 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id BE59A2038B for ; Sun, 19 Jul 2020 14:15:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Okhk23V6yx79 for ; Sun, 19 Jul 2020 14:15:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by silver.osuosl.org (Postfix) with ESMTPS id C4B1F20010 for ; Sun, 19 Jul 2020 14:15:27 +0000 (UTC) X-Originating-IP: 90.177.210.238 Received: from im-t490s.redhat.com (238.210.broadband10.iol.cz [90.177.210.238]) (Authenticated sender: i.maximets@ovn.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id C2B781BF206; Sun, 19 Jul 2020 14:15:22 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org, Ben Pfaff Date: Sun, 19 Jul 2020 16:15:09 +0200 Message-Id: <20200719141509.3129129-1-i.maximets@ovn.org> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Cc: wenxu , Mike , frank.zeng@ucloud.cn, Ilya Maximets Subject: [ovs-dev] [PATCH] ovs-router: Fix flushing local routes. 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" Since commit 8e4e45887ec3, priority of 'local' route entries no longer matches with 'plen'. This should be taken into account while flushing cached routes, otherwise they will remain in OVS even after removing them from the system: # ifconfig eth0 11.1 # ovs-appctl ovs/route/show --- A new route synchronized from kernel route table --- Cached: 11.0.0.1/32 dev eth0 SRC 11.0.0.1 local # ifconfig eth0 0 # ovs-appctl ovs/route/show -- the new route entry is still in ovs route table --- Cached: 11.0.0.1/32 dev eth0 SRC 11.0.0.1 local CC: wenxu Fixes: 8e4e45887ec3 ("ofproto-dpif-xlate: makes OVS native tunneling honor tunnel-specified source addresses") Reported-by: Mike Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2020-July/373093.html Signed-off-by: Ilya Maximets --- lib/ovs-router.c | 2 +- tests/automake.mk | 3 ++- tests/system-kmod-testsuite.at | 1 + tests/system-route.at | 28 ++++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 tests/system-route.at diff --git a/lib/ovs-router.c b/lib/ovs-router.c index bfb2b7071..09b81c6e5 100644 --- a/lib/ovs-router.c +++ b/lib/ovs-router.c @@ -505,7 +505,7 @@ ovs_router_flush(void) ovs_mutex_lock(&mutex); classifier_defer(&cls); CLS_FOR_EACH(rt, cr, &cls) { - if (rt->priority == rt->plen) { + if (rt->priority == rt->plen || rt->local) { rt_entry_delete__(&rt->cr); } } diff --git a/tests/automake.mk b/tests/automake.mk index cbba5b170..0f0562b19 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -149,7 +149,8 @@ OVSDB_CLUSTER_TESTSUITE_AT = \ SYSTEM_KMOD_TESTSUITE_AT = \ tests/system-common-macros.at \ tests/system-kmod-testsuite.at \ - tests/system-kmod-macros.at + tests/system-kmod-macros.at \ + tests/system-route.at SYSTEM_USERSPACE_TESTSUITE_AT = \ tests/system-userspace-testsuite.at \ diff --git a/tests/system-kmod-testsuite.at b/tests/system-kmod-testsuite.at index 3de0290c0..ff2ecd0ba 100644 --- a/tests/system-kmod-testsuite.at +++ b/tests/system-kmod-testsuite.at @@ -25,3 +25,4 @@ m4_include([tests/system-kmod-macros.at]) m4_include([tests/system-traffic.at]) m4_include([tests/system-layer3-tunnels.at]) m4_include([tests/system-interface.at]) +m4_include([tests/system-route.at]) diff --git a/tests/system-route.at b/tests/system-route.at new file mode 100644 index 000000000..1714273e3 --- /dev/null +++ b/tests/system-route.at @@ -0,0 +1,28 @@ +AT_BANNER([system-route]) + +dnl Add an interface, add/del ip address, check that OVS catches route updates. +AT_SETUP([ovs-route - add/remove system route]) +AT_KEYWORDS([route]) +OVS_TRAFFIC_VSWITCHD_START() + +dnl Create tap port. +AT_CHECK([ip tuntap add name p1-route mode tap]) +AT_CHECK([ip link set p1-route up]) +on_exit 'ip link del p1-route' + +dnl Add ip address. +AT_CHECK([ip addr add 10.0.0.17/24 dev p1-route], [0], [stdout]) + +dnl Check that OVS catches route updates. +OVS_WAIT_UNTIL([ovs-appctl ovs/route/show | grep 'p1-route' | sort], [0], [dnl +Cached: 10.0.0.17/24 dev p1-route SRC 10.0.0.17 +Cached: 10.0.0.17/32 dev p1-route SRC 10.0.0.17 local +]) + +dnl Delete ip address. +AT_CHECK([ip addr del 10.0.0.17/24 dev p1-route], [0], [stdout]) +dnl Check that routes was removed from OVS. +OVS_WAIT_UNTIL([test `ovs-appctl ovs/route/show | grep -c 'p1-route'` -eq 0 ]) + +OVS_TRAFFIC_VSWITCHD_STOP +AT_CLEANUP