Skip to content

Commit

Permalink
controller: Fix first ping from lsp to external through snat failing
Browse files Browse the repository at this point in the history
Fixes: b89b96e ("controller: fix potential segmentation violation when removing ports")
Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=2130046

Signed-off-by: Xavier Simonart <xsimonar@redhat.com>
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
(cherry picked from commit f12ae16)
  • Loading branch information
simonartxavier authored and dceara committed Sep 28, 2022
1 parent bc8691d commit 8706146
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 2 deletions.
2 changes: 1 addition & 1 deletion controller/pinctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4311,7 +4311,7 @@ run_buffered_binding(struct ovsdb_idl_index *sbrec_mac_binding_by_lport_ip,
const struct sbrec_port_binding *pb;
SBREC_PORT_BINDING_FOR_EACH_EQUAL (pb, target,
sbrec_port_binding_by_datapath) {
if (strcmp(pb->type, "patch")) {
if (strcmp(pb->type, "patch") && strcmp(pb->type, "l3gateway")) {
continue;
}
struct buffered_packets *cur_qp, *next_qp;
Expand Down
25 changes: 24 additions & 1 deletion tests/system-common-macros.at
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,38 @@ m4_define([NS_CHECK_EXEC],
# appropriate type, and allows additional arguments to be passed.
m4_define([ADD_BR], [ovs-vsctl _ADD_BR([$1]) -- $2])

# ADD_INT([port], [namespace], [ovs-br], [ip_addr])
# ADD_INT([port], [namespace], [ovs-br], [ip_addr] [ip6_addr])
#
# Add an internal port to 'ovs-br', then shift it into 'namespace' and
# configure it with 'ip_addr' (specified in CIDR notation).
# Optionally add an ipv6 address
m4_define([ADD_INT],
[ AT_CHECK([ovs-vsctl add-port $3 $1 -- set int $1 type=internal])
AT_CHECK([ip link set $1 netns $2])
NS_CHECK_EXEC([$2], [ip addr add $4 dev $1])
NS_CHECK_EXEC([$2], [ip link set dev $1 up])
if test -n "$5"; then
NS_CHECK_EXEC([$2], [ip -6 addr add $5 dev $1])
fi
]
)

# NS_ADD_INT([port], [namespace], [ovs-br], [ip_addr] [mac_addr] [ip6_addr] [default_gw] [default_ipv6_gw])
# Create a namespace
# Add an internal port to 'ovs-br', then shift it into 'namespace'.
# Configure it with 'ip_addr' (specified in CIDR notation) and ip6_addr.
# Set mac_addr
# Add default gw for ipv4 and ipv6
m4_define([NS_ADD_INT],
[ AT_CHECK([ovs-vsctl add-port $3 $1 -- set int $1 type=internal external_ids:iface-id=$1])
ADD_NAMESPACES($2)
AT_CHECK([ip link set $1 netns $2])
NS_CHECK_EXEC([$2], [ip link set $1 address $5])
NS_CHECK_EXEC([$2], [ip link set dev $1 up])
NS_CHECK_EXEC([$2], [ip addr add $4 dev $1])
NS_CHECK_EXEC([$2], [ip addr add $6 dev $1])
NS_CHECK_EXEC([$2], [ip route add default via $7 dev $1])
NS_CHECK_EXEC([$2], [ip -6 route add default via $8 dev $1])
]
)

Expand Down
82 changes: 82 additions & 0 deletions tests/system-ovn.at
Original file line number Diff line number Diff line change
Expand Up @@ -8221,3 +8221,85 @@ OVS_TRAFFIC_VSWITCHD_STOP(["/failed to query port patch-.*/d

AT_CLEANUP
])

OVN_FOR_EACH_NORTHD([
AT_SETUP([SNAT in gateway router mode])
AT_KEYWORDS([ovnnat])

CHECK_CONNTRACK()
CHECK_CONNTRACK_NAT()
ovn_start
OVS_TRAFFIC_VSWITCHD_START()

ADD_BR([br-int])
check ovs-ofctl add-flow br0 action=normal
# Set external-ids in br-int needed for ovn-controller
ovs-vsctl \
-- set Open_vSwitch . external-ids:system-id=hv1 \
-- set Open_vSwitch . external-ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb.sock \
-- set Open_vSwitch . external-ids:ovn-encap-type=geneve \
-- set Open_vSwitch . external-ids:ovn-encap-ip=169.0.0.1 \
-- set bridge br-int fail-mode=secure other-config:disable-in-band=true

# Start ovn-controller
start_daemon ovn-controller

check ip link set br0 up
check ovs-vsctl set open . external-ids:ovn-bridge-mappings=provider:br0

check ovn-nbctl ls-add ls1
check ovn-nbctl lsp-add ls1 ls1p1
check ovn-nbctl lsp-set-addresses ls1p1 "00:00:00:01:01:01 192.168.1.1 2001::1"
check ovn-nbctl lsp-add ls1 ls1p2
check ovn-nbctl lsp-set-addresses ls1p2 "00:00:00:01:01:02 192.168.1.2 2001::2"

check ovn-nbctl lr-add lr1
check ovn-nbctl lrp-add lr1 lr1-ls1 00:00:00:00:00:01 192.168.1.254/24 2001::a/64
check ovn-nbctl lsp-add ls1 ls1-lr1
check ovn-nbctl lsp-set-addresses ls1-lr1 "00:00:00:00:00:01 192.168.1.254 2001::a"
check ovn-nbctl lsp-set-type ls1-lr1 router
check ovn-nbctl lsp-set-options ls1-lr1 router-port=lr1-ls1

check ovn-nbctl set logical_router lr1 options:chassis=hv1

check ovn-nbctl lrp-add lr1 lr1-pub 00:00:00:00:0f:01 172.16.1.254/24 1711::a/64
check ovn-nbctl ls-add pub
check ovn-nbctl lsp-add pub pub-lr1
check ovn-nbctl lsp-set-type pub-lr1 router
check ovn-nbctl lsp-set-options pub-lr1 router-port=lr1-pub
check ovn-nbctl lsp-set-addresses pub-lr1 router

check ovn-nbctl lsp-add pub ln -- lsp-set-options ln network_name=provider
check ovn-nbctl lsp-set-type ln localnet
check ovn-nbctl lsp-set-addresses ln unknown

check ovn-nbctl lr-nat-add lr1 snat 172.16.1.10 192.168.1.0/24
check ovn-nbctl lr-nat-add lr1 snat 1711::10 2001::/64

NS_ADD_INT(ls1p1, ls1p1, br-int, "192.168.1.1/24", "00:00:00:01:01:01", "2001::1/64", "192.168.1.254", "2001::a" )
NS_ADD_INT(ls1p2, ls1p2, br-int, "192.168.1.2/24", "00:00:00:01:01:02", "2001::2/64", "192.168.1.254", "2001::a" )

ADD_NAMESPACES(ext1)
ADD_INT(ext1, ext1, br0, 172.16.1.1/24, 1711::1/64)
check ovn-nbctl --wait=hv sync
wait_for_ports_up
OVS_WAIT_UNTIL([test "$(ip netns exec ls1p1 ip a | grep 2001::1 | grep tentative)" = ""])
OVS_WAIT_UNTIL([test "$(ip netns exec ls1p2 ip a | grep 2002::1 | grep tentative)" = ""])

NS_CHECK_EXEC([ls1p1], [ping -q -c 3 -i 0.3 -w 2 172.16.1.1 | FORMAT_PING], \
[0], [dnl
3 packets transmitted, 3 received, 0% packet loss, time 0ms
])

NS_CHECK_EXEC([ls1p1], [ping6 -v -q -c 3 -i 0.3 -w 2 1711::1 | FORMAT_PING], \
[0], [dnl
3 packets transmitted, 3 received, 0% packet loss, time 0ms
])

OVS_APP_EXIT_AND_WAIT([ovn-controller])
as
OVS_TRAFFIC_VSWITCHD_STOP(["/failed to query port patch-.*/d
/connection dropped.*/d
/removing policing failed: No such device/d"])
AT_CLEANUP
])

0 comments on commit 8706146

Please sign in to comment.