Skip to content

Commit

Permalink
northd: Prevent assert with wrong LSP configuration.
Browse files Browse the repository at this point in the history
We would crash northd with assert when LSP was configured to use
LRP that already had a peer defined. Prevent the crash and add
warning that the configuration is not valid.

Reported-by: Enrique Llorente <ellorent@redhat.com>
Acked-by: Felix Huettner <felix.huettner@stackit.cloud>
Signed-off-by: Ales Musil <amusil@redhat.com>
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
(cherry picked from commit 83b4802)
  • Loading branch information
almusil authored and dceara committed Feb 26, 2025
1 parent 386c830 commit 5d64ee9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions northd/northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2452,6 +2452,15 @@ join_logical_ports(const struct sbrec_port_binding_table *sbrec_pb_table,
continue;
}

if (peer->nbrp->peer) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
VLOG_WARN_RL(&rl, "Bad configuration: The peer of the switch "
"port '%s' (LRP peer: '%s') has its own peer "
"configuration: '%s'", op->key, peer->key,
peer->nbrp->peer);
continue;
}

ovn_datapath_add_router_port(op->od, op);
ovn_datapath_add_ls_peer(peer->od, op->od);
peer->peer = op;
Expand Down
19 changes: 19 additions & 0 deletions tests/ovn-northd.at
Original file line number Diff line number Diff line change
Expand Up @@ -16710,3 +16710,22 @@ check_row_count Port_Binding 1 logical_port=lrp2 options:peer{not-in}lrp0

AT_CLEANUP
])

OVN_FOR_EACH_NORTHD_NO_HV([
AT_SETUP([LSP using LRP with peer])
ovn_start

check ovn-nbctl --wait=sb sync \
-- lr-add lr \
-- ls-add ls \
-- lrp-add lr lrp0 00:00:00:01:ff:01 192.168.1.1/24 peer=lrp1 \
-- lrp-add lr lrp1 00:00:00:01:ff:01 192.168.1.1/24 peer=lrp0 \
-- lsp-add ls ls-lrp1 \
-- lsp-set-type ls-lrp1 router \
-- lsp-set-options ls-lrp1 router-port=lrp1 \
-- lsp-set-addresses ls-lrp1 router

check grep -q "Bad configuration: The peer of the switch port 'ls-lrp1' (LRP peer: 'lrp1') has its own peer configuration: 'lrp0'" northd/ovn-northd.log

AT_CLEANUP
])

0 comments on commit 5d64ee9

Please # to comment.