The nexthop of Logical Router Policy can be NULL or empty, make sure
the northd doesn't crash when that happens:
northd/northd.c:14771:39: runtime error: null pointer passed as argument 1,
which is declared to never be null
string.h:247:33: note: nonnull attribute specified here
build_route_policies northd/northd.c:14771:32
en_route_policies_run northd/en-northd.c:324:9
engine_recompute lib/inc-proc-eng.c:448:33
engine_compute lib/inc-proc-eng.c:491:17
engine_run_node lib/inc-proc-eng.c:550:14
engine_run ovn/lib/inc-proc-eng.c:579:9
inc_proc_northd_run northd/inc-proc-northd.c:608:5
main northd/ovn-northd.c:1134:36
Reported-at: https://issues.redhat.com/browse/FDP-2919
Signed-off-by: Ales Musil <[email protected]>
---
northd/northd.c | 5 +++++
tests/ovn-northd.at | 28 ++++++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/northd/northd.c b/northd/northd.c
index c3c0780a3..2faf5d09a 100644
--- a/northd/northd.c
+++ b/northd/northd.c
@@ -14762,6 +14762,11 @@ build_route_policies(struct ovn_datapath *od, const
struct hmap *lr_ports,
for (size_t j = 0; j < n_nexthops; j++) {
char *nexthop = rule->n_nexthops
? rule->nexthops[j] : rule->nexthop;
+
+ if (!nexthop || !nexthop[0]) {
+ continue;
+ }
+
struct ovn_port *out_port = NULL;
bool is_ipv4 = strchr(nexthop, '.') ? true : false;
diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
index 5b1a8b6f8..79075465b 100644
--- a/tests/ovn-northd.at
+++ b/tests/ovn-northd.at
@@ -19030,3 +19030,31 @@ check ovn-nbctl --wait=sb sync
OVN_CLEANUP_NORTHD
AT_CLEANUP
])
+
+OVN_FOR_EACH_NORTHD_NO_HV([
+AT_SETUP([Router policies - crash])
+ovn_start
+
+dnl Test with a simple reroute policy with an explicit output-port set.
+check ovn-nbctl \
+ -- lr-add lr0 \
+ -- lrp-add lr0 lrp1 00:00:00:00:00:01 1.1.1.1/24 \
+ -- lrp-add lr0 lrp2 00:00:00:00:00:02 2.2.2.1/24 \
+ -- --output-port=lrp2 lr-policy-add lr0 100 "ip4.src == 42.42.42.42" \
+ reroute 3.3.3.3
+
+dnl Clear the nexthops. This shouldn't crash and not produce any lflows.
+uuid=$(fetch_column nb:logical_router_policy _uuid priority=100)
+check ovn-nbctl clear logical_router_policy $uuid nexthops
+check ovn-nbctl --wait=sb sync
+
+ovn-sbctl dump-flows lr0 > lr0flows
+AT_CAPTURE_FILE([lr0flows])
+
+AT_CHECK([grep "lr_in_policy[[^_]]" lr0flows | ovn_strip_lflows | sort], [0],
[dnl
+ table=??(lr_in_policy ), priority=0 , match=(1),
action=(reg8[[0..15]] = 0; next;)
+])
+
+OVN_CLEANUP_NORTHD
+AT_CLEANUP
+])
--
2.52.0
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev