]> git.proxmox.com Git - ovs.git/commitdiff
ovs-router: Fix flushing of local routes.
authorIlya Maximets <i.maximets@ovn.org>
Tue, 21 Jul 2020 12:47:32 +0000 (14:47 +0200)
committerWilliam Tu <u9012063@gmail.com>
Tue, 21 Jul 2020 13:23:49 +0000 (06:23 -0700)
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.0.0.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 <wenxu@ucloud.cn>
Fixes: 8e4e45887ec3 ("ofproto-dpif-xlate: makes OVS native tunneling honor tunnel-specified source addresses")
Reported-by: Zheng Jingzhou <glovejmm@163.com>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2020-July/373093.html
Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: William Tu <u9012063@gmail.com>
AUTHORS.rst
lib/ovs-router.c
tests/automake.mk
tests/system-route.at [new file with mode: 0644]
tests/system-userspace-testsuite.at

index 763f199ec7931fdf2f93e031199ab2527f6bfb66..10ce012ba45cb86f303e57c4bb04547e80e72f9c 100644 (file)
@@ -666,6 +666,7 @@ Ying Chen                       yingchen@vmware.com
 Yongqiang Liu                   liuyq7809@gmail.com
 ZHANG Zhiming                   zhangzhiming@yunshan.net.cn
 Zhangguanghui                   zhang.guanghui@h3c.com
+Zheng Jingzhou                  glovejmm@163.com
 Ziyou Wang                      ziyouw@vmware.com
 ankur dwivedi                   ankurengg2003@gmail.com
 chen zhang                      3zhangchen9211@gmail.com
index bfb2b7071bc08c582a4f42685dfcadaa269dc914..09b81c6e5a786bca57cb87747c042e23d59e5058 100644 (file)
@@ -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);
         }
     }
index cbba5b1704276934a38cf36d9b0839bbf8c74fda..677b99a6b487147e5eab34ed80c9c9e89fb63501 100644 (file)
@@ -154,7 +154,8 @@ SYSTEM_KMOD_TESTSUITE_AT = \
 SYSTEM_USERSPACE_TESTSUITE_AT = \
        tests/system-userspace-testsuite.at \
        tests/system-userspace-macros.at \
-       tests/system-userspace-packet-type-aware.at
+       tests/system-userspace-packet-type-aware.at \
+       tests/system-route.at
 
 SYSTEM_TSO_TESTSUITE_AT = \
        tests/system-tso-testsuite.at \
diff --git a/tests/system-route.at b/tests/system-route.at
new file mode 100644 (file)
index 0000000..1714273
--- /dev/null
@@ -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
index b40da9579e7068a414cf4af9f73bec46c8cbcbce..2e9659a6758569590ed44eee5c93d7bb6d05fc45 100644 (file)
@@ -26,3 +26,4 @@ m4_include([tests/system-traffic.at])
 m4_include([tests/system-layer3-tunnels.at])
 m4_include([tests/system-interface.at])
 m4_include([tests/system-userspace-packet-type-aware.at])
+m4_include([tests/system-route.at])