Skip to content

Commit

Permalink
northd: Fix segfault when changing the router to a gateway router.
Browse files Browse the repository at this point in the history
When a distributed router with a gateway router port is changed
to a gateway router (options:chassis=<ch>), during the recompute
run, op->cr_port is not created and instead a warning is logged
because of bad configuration.

The commit b52ba50 is accessing op->cr_port even though cr_port
is not created for the 'op' and this results in a segfault.

This patch fixes it.

Fixes: b52ba50 ("northd: Fix relying on naming coincidences.")
Signed-off-by: Numan Siddique <[email protected]>
Signed-off-by: Dumitru Ceara <[email protected]>
  • Loading branch information
numansiddique authored and dceara committed Jan 24, 2025
1 parent 9198808 commit 8e138ec
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
8 changes: 6 additions & 2 deletions northd/northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4086,8 +4086,12 @@ sync_pb_for_lrp(struct ovn_port *op,
} else {
if (op->peer) {
smap_add(&new, "peer", op->peer->key);
if (op->nbrp->ha_chassis_group ||
op->nbrp->n_gateway_chassis) {
/* Even if the router port has ha_chassis_group or
* gateway_chassis configured, don't assume that its
* chassis-redirect port is created.
* Check op->cr_port for NULL before accessing. */
if (op->cr_port && (op->nbrp->ha_chassis_group ||
op->nbrp->n_gateway_chassis)) {
smap_add(&new, "chassis-redirect-port", op->cr_port->key);
}
}
Expand Down
30 changes: 30 additions & 0 deletions tests/ovn.at
Original file line number Diff line number Diff line change
Expand Up @@ -40852,6 +40852,36 @@ OVN_CLEANUP([hv1],[hv2])
AT_CLEANUP
])

OVN_FOR_EACH_NORTHD_NO_HV([
AT_SETUP([Switch from Distributed Router to Gateway Router])

ovn_start
net_add n1
sim_add hv1
as hv1
check ovs-vsctl add-br br-phys
ovn_attach n1 br-phys 192.168.0.11

check ovn-nbctl ls-add public
check ovn-nbctl lsp-add public public-lr0
check ovn-nbctl lsp-set-type public-lr0 router
check ovn-nbctl lsp-set-addresses public-lr0 router
check ovn-nbctl lsp-set-options public-lr0 router-port=lr0-public

check ovn-nbctl lr-add lr0
check ovn-nbctl lrp-add lr0 lr0-public 00:00:20:20:12:13 172.168.0.100/24
check ovn-nbctl --wait=hv lrp-set-gateway-chassis lr0-public hv1
wait_column "chassisredirect" sb:Port_Binding type logical_port=cr-lr0-public

check ovn-nbctl --wait=hv set logical_router lr0 options:chassis=hv1
wait_row_count sb:Port_Binding 0 logical_port=cr-lr0-public
check ovn-nbctl --wait=hv clear logical_router_port lr0-public gateway_chassis
wait_column "l3gateway" sb:Port_Binding type logical_port=lr0-public

OVN_CLEANUP([hv1])
AT_CLEANUP
])

OVN_FOR_EACH_NORTHD([
AT_SETUP([requested-tnl-key-recompute])
AT_KEYWORDS([requested-tnl-key-recompute])
Expand Down

0 comments on commit 8e138ec

Please sign in to comment.