On 1/23/25 11:06 PM, [email protected] wrote:
> From: Numan Siddique <[email protected]>
>
> 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 b52ba504ed6f 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: b52ba504ed6f ("northd: Fix relying on naming coincidences.")
> Signed-off-by: Numan Siddique <[email protected]>
> ---
Sorry for the regression, Numan! Applied to main.
> northd/northd.c | 8 ++++++--
> tests/ovn.at | 30 ++++++++++++++++++++++++++++++
> 2 files changed, 36 insertions(+), 2 deletions(-)
>
> diff --git a/northd/northd.c b/northd/northd.c
> index cff0b21f49..3ff4326e6b 100644
> --- a/northd/northd.c
> +++ b/northd/northd.c
> @@ -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);
> }
> }
> diff --git a/tests/ovn.at b/tests/ovn.at
> index e9144b0cdd..4f6b96aabe 100644
> --- a/tests/ovn.at
> +++ b/tests/ovn.at
> @@ -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
> +ovs-vsctl add-br br-phys
Nit: I added a check here.
> +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])
Regards,
Dumitru
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev