mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 01:51:26 +00:00
When adding a route with ovs/route/add command, the source address in "ovs_router_entry" structure is always the FIRST address that the interface has. See "ovs_router_get_netdev_source_address" function for more information. If an interface has multiple ipv4 and/or ipv6 addresses, there are use cases where the user wants to control the source address. This patch therefore addresses this issue by adding a src parameter. Note that same constraints also exist when caching routes from Kernel FIB with Netlink, but are not dealt with in this patch. Acked-by: Eelco Chaudron <echaudro@redhat.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Signed-off-by: Nobuhiro MIKI <nmiki@yahoo-corp.jp> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
181 lines
7.1 KiB
Plaintext
181 lines
7.1 KiB
Plaintext
AT_BANNER([ovs-router])
|
|
|
|
AT_SETUP([appctl - route/add with gateway and pkt_mark])
|
|
AT_KEYWORDS([ovs_router])
|
|
OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=dummy])
|
|
AT_CHECK([ovs-appctl netdev-dummy/ip4addr br0 2.2.2.2/24], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 2.2.2.3/32 br0 pkt_mark=1], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 1.1.1.0/24 br0 2.2.2.10], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 1.1.2.0/24 br0 2.2.2.10 pkt_mark=2], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 1.1.3.0/24 br0 pkt_mark=3], [2], [], [dnl
|
|
Error while inserting route.
|
|
ovs-appctl: ovs-vswitchd: server returned an error
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 1.1.foo.bar/24 br0 2.2.2.10], [2], [], [dnl
|
|
Invalid 'ip/plen' parameter
|
|
ovs-appctl: ovs-vswitchd: server returned an error
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 2.2.2.4/24 br0 pkt_mark=baz], [2], [], [dnl
|
|
Invalid pkt_mark, IP gateway or src_ip
|
|
ovs-appctl: ovs-vswitchd: server returned an error
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/show | grep User | sort], [0], [dnl
|
|
User: 1.1.1.0/24 dev br0 GW 2.2.2.10 SRC 2.2.2.2
|
|
User: 1.1.2.0/24 MARK 2 dev br0 GW 2.2.2.10 SRC 2.2.2.2
|
|
User: 2.2.2.3/32 MARK 1 dev br0 SRC 2.2.2.2
|
|
])
|
|
OVS_VSWITCHD_STOP
|
|
AT_CLEANUP
|
|
|
|
AT_SETUP([appctl - route/add with src - ipv4])
|
|
AT_KEYWORDS([ovs_router])
|
|
OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=dummy])
|
|
AT_CHECK([ovs-appctl netdev-dummy/ip4addr br0 192.168.9.2/24], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl netdev-dummy/ip4addr br0 192.168.9.3/24], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 192.168.9.11/32 br0 src=192.168.9.3], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 192.168.10.12/32 br0 192.168.9.1 src=192.168.9.3], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 192.168.10.13/32 br0 192.168.9.1 pkt_mark=13 src=192.168.9.3], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 192.168.10.14/32 br0 192.168.9.1 pkt_mark=14 src=192.168.9.2], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 192.168.10.15/32 br0 192.168.9.1 src=foo.bar.9.200], [2], [], [dnl
|
|
Invalid pkt_mark, IP gateway or src_ip
|
|
ovs-appctl: ovs-vswitchd: server returned an error
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 192.168.10.16/32 br0 192.168.9.1 src=192.168.9.200], [2], [], [dnl
|
|
Error while inserting route.
|
|
ovs-appctl: ovs-vswitchd: server returned an error
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 192.168.10.17/32 br0 192.168.11.1 src=192.168.9.3], [2], [], [dnl
|
|
Error while inserting route.
|
|
ovs-appctl: ovs-vswitchd: server returned an error
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 192.168.10.18/32 br0 src=192.168.9.3], [2], [], [dnl
|
|
Error while inserting route.
|
|
ovs-appctl: ovs-vswitchd: server returned an error
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/show | grep User | grep 192.168.10 | sort], [0], [dnl
|
|
User: 192.168.10.12/32 dev br0 GW 192.168.9.1 SRC 192.168.9.3
|
|
User: 192.168.10.13/32 MARK 13 dev br0 GW 192.168.9.1 SRC 192.168.9.3
|
|
User: 192.168.10.14/32 MARK 14 dev br0 GW 192.168.9.1 SRC 192.168.9.2
|
|
])
|
|
OVS_VSWITCHD_STOP
|
|
AT_CLEANUP
|
|
|
|
AT_SETUP([appctl - route/add with src - ipv6])
|
|
AT_KEYWORDS([ovs_router])
|
|
OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=dummy])
|
|
AT_CHECK([ovs-appctl netdev-dummy/ip6addr br0 2001:db8:cafe::2/64], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl netdev-dummy/ip6addr br0 2001:db8:cafe::3/64], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 2001:db8:cafe::11/128 br0 src=2001:db8:cafe::3], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 2001:db8:beef::12/128 br0 2001:db8:cafe::1 src=2001:db8:cafe::3], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 2001:db8:beef::13/128 br0 2001:db8:cafe::1 pkt_mark=13 src=2001:db8:cafe::3], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 2001:db8:beef::14/128 br0 2001:db8:cafe::1 pkt_mark=14 src=2001:db8:cafe::2], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 2001:db8:beef::15/128 br0 2001:db8:cafe::1 src=foo:bar:2001:db8:cafe], [2], [], [dnl
|
|
Invalid pkt_mark, IP gateway or src_ip
|
|
ovs-appctl: ovs-vswitchd: server returned an error
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 2001:db8:beef::16/128 br0 2001:db8:cafe::1 src=2001:db8:cafe::200], [2], [], [dnl
|
|
Error while inserting route.
|
|
ovs-appctl: ovs-vswitchd: server returned an error
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 2001:db8:beef::17/128 br0 2001:db8:face::1 src=2001:db8:cafe::3], [2], [], [dnl
|
|
Error while inserting route.
|
|
ovs-appctl: ovs-vswitchd: server returned an error
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 2001:db8:beef::18/128 br0 src=2001:db8:cafe::3], [2], [], [dnl
|
|
Error while inserting route.
|
|
ovs-appctl: ovs-vswitchd: server returned an error
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/show | grep User | grep 2001:db8:beef | sort], [0], [dnl
|
|
User: 2001:db8:beef::12/128 dev br0 GW 2001:db8:cafe::1 SRC 2001:db8:cafe::3
|
|
User: 2001:db8:beef::13/128 MARK 13 dev br0 GW 2001:db8:cafe::1 SRC 2001:db8:cafe::3
|
|
User: 2001:db8:beef::14/128 MARK 14 dev br0 GW 2001:db8:cafe::1 SRC 2001:db8:cafe::2
|
|
])
|
|
OVS_VSWITCHD_STOP
|
|
AT_CLEANUP
|
|
|
|
AT_SETUP([appctl - route/lookup])
|
|
AT_KEYWORDS([ovs_router])
|
|
OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=dummy])
|
|
AT_CHECK([ovs-appctl netdev-dummy/ip4addr br0 192.0.2.1/24], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 198.51.100.0/24 br0 192.0.2.254], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 192.0.2.1/24 br0 pkt_mark=123], [0], [OK
|
|
])
|
|
|
|
AT_CHECK([ovs-appctl ovs/route/add 198.51.100.200/24 br0 192.0.2.250 pkt_mark=1234], [0], [OK
|
|
])
|
|
|
|
AT_CHECK([ovs-appctl ovs/route/show | grep User | sort], [0], [User: 192.0.2.0/24 MARK 123 dev br0 SRC 192.0.2.1
|
|
User: 198.51.100.0/24 MARK 1234 dev br0 GW 192.0.2.250 SRC 192.0.2.1
|
|
User: 198.51.100.0/24 dev br0 GW 192.0.2.254 SRC 192.0.2.1
|
|
])
|
|
|
|
AT_CHECK([ovs-appctl ovs/route/lookup 198.51.100.1], [0], [src 192.0.2.1
|
|
gateway 192.0.2.254
|
|
dev br0
|
|
])
|
|
|
|
AT_CHECK([ovs-appctl ovs/route/lookup 198.51.100.1 pkt_mark=1234], [0], [src 192.0.2.1
|
|
gateway 192.0.2.250
|
|
dev br0
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/del 198.51.100.0/24 pkt_mark=1234], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/show | grep User | sort], [0], [User: 192.0.2.0/24 MARK 123 dev br0 SRC 192.0.2.1
|
|
User: 198.51.100.0/24 dev br0 GW 192.0.2.254 SRC 192.0.2.1
|
|
])
|
|
|
|
OVS_VSWITCHD_STOP
|
|
AT_CLEANUP
|
|
|
|
AT_SETUP([appctl - route/lookup6])
|
|
AT_KEYWORDS([ovs_router])
|
|
OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=dummy])
|
|
AT_CHECK([ovs-appctl netdev-dummy/ip6addr br0 2001:db8:cafe::1/64], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 2001:db8:babe::/64 br0 2001:db8:cafe::2], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/add 2001:db8:babe::/64 br0 2001:db8:cafe::3 pkt_mark=321], [0], [OK
|
|
])
|
|
|
|
AT_CHECK([ovs-appctl ovs/route/show | grep User | sort], [0], [dnl
|
|
User: 2001:db8:babe::/64 MARK 321 dev br0 GW 2001:db8:cafe::3 SRC 2001:db8:cafe::1
|
|
User: 2001:db8:babe::/64 dev br0 GW 2001:db8:cafe::2 SRC 2001:db8:cafe::1
|
|
])
|
|
|
|
AT_CHECK([ovs-appctl ovs/route/lookup 2001:db8:babe::1eaf], [0], [src 2001:db8:cafe::1
|
|
gateway 2001:db8:cafe::2
|
|
dev br0
|
|
])
|
|
|
|
AT_CHECK([ovs-appctl ovs/route/lookup 2001:db8:babe::1eaf pkt_mark=321], [0], [src 2001:db8:cafe::1
|
|
gateway 2001:db8:cafe::3
|
|
dev br0
|
|
])
|
|
|
|
AT_CHECK([ovs-appctl ovs/route/del 2001:db8:babe::/64 pkt_mark=321], [0], [OK
|
|
])
|
|
AT_CHECK([ovs-appctl ovs/route/show | grep User | sort], [0], [dnl
|
|
User: 2001:db8:babe::/64 dev br0 GW 2001:db8:cafe::2 SRC 2001:db8:cafe::1
|
|
])
|
|
|
|
OVS_VSWITCHD_STOP
|
|
AT_CLEANUP
|