bgpd: Fix crash for show bgp attribute-info

attr->srv6_vpn might be NULL as well. Let's check both.

Happened after 073801481b.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
This commit is contained in:
Donatas Abraitis 2022-12-09 22:46:54 +02:00
parent 58552d28fa
commit 42d1ca394f

View File

@ -904,6 +904,12 @@ static void attrhash_finish(void)
static void attr_show_all_iterator(struct hash_bucket *bucket, struct vty *vty) static void attr_show_all_iterator(struct hash_bucket *bucket, struct vty *vty)
{ {
struct attr *attr = bucket->data; struct attr *attr = bucket->data;
struct in6_addr *sid = NULL;
if (attr->srv6_l3vpn)
sid = &attr->srv6_l3vpn->sid;
else if (attr->srv6_vpn)
sid = &attr->srv6_vpn->sid;
vty_out(vty, "attr[%ld] nexthop %pI4\n", attr->refcnt, &attr->nexthop); vty_out(vty, "attr[%ld] nexthop %pI4\n", attr->refcnt, &attr->nexthop);
@ -911,9 +917,7 @@ static void attr_show_all_iterator(struct hash_bucket *bucket, struct vty *vty)
"\tflags: %" PRIu64 "\tflags: %" PRIu64
" distance: %u med: %u local_pref: %u origin: %u weight: %u label: %u sid: %pI6\n", " distance: %u med: %u local_pref: %u origin: %u weight: %u label: %u sid: %pI6\n",
attr->flag, attr->distance, attr->med, attr->local_pref, attr->flag, attr->distance, attr->med, attr->local_pref,
attr->origin, attr->weight, attr->label, attr->origin, attr->weight, attr->label, sid);
attr->srv6_l3vpn ? &attr->srv6_l3vpn->sid
: &attr->srv6_vpn->sid);
} }
void attr_show_all(struct vty *vty) void attr_show_all(struct vty *vty)