bgpd: do not crash when labels are empty

bgp_evpn_path_info_get_l3vni() tries to find out l3vni associated with
the path. However, under some circumstances, function
bgp_evpn_path_info_labels_get_l3vni() may return NULL, and if it is
passed to label2vni(), it causes abort(). bgpd crashes and is then
restarted, which may lead to several seconds of lost connectivity to the
host, until the daemon gets restarted and BGP sessions are
reestablished.

This behaviour was observed in real life.  Here is a partial stack trace:

/usr/lib/x86_64-linux-gnu/frr/libfrr.so.0(_zlog_assert_failed+0xe9) [0x7f60dbff5299]
/usr/lib/frr/bgpd(bgp_evpn_mpath_has_dvni+0x90) [0x5649d89a9140]
/usr/lib/frr/bgpd(bgp_evpn_path_es_use_nhg+0x10b) [0x5649d89b12fb]
/usr/lib/frr/bgpd(bgp_zebra_announce+0x234) [0x5649d8a68214]

Signed-off-by: Eugene Crosser <crosser@average.org>
This commit is contained in:
Eugene Crosser 2025-04-17 15:01:19 +02:00
parent 38968cc8df
commit f97bbb8a25

View file

@ -8102,10 +8102,12 @@ vni_t bgp_evpn_path_info_get_l3vni(const struct bgp_path_info *pi)
if (!pi->extra)
return 0;
return label2vni(
bgp_evpn_path_info_labels_get_l3vni(pi->extra->labels->label,
pi->extra->labels
->num_labels));
mpls_label_t *label = bgp_evpn_path_info_labels_get_l3vni(pi->extra->labels->label,
pi->extra->labels->num_labels);
if (!label)
return 0;
return label2vni(label);
}
/*