From 775d0779cfa0caae069e65e5b449f64f6162e3df Mon Sep 17 00:00:00 2001 From: claudio Date: Wed, 10 Aug 2022 11:11:02 +0000 Subject: [PATCH] Fix logic in network_dump_upcall() The nexthop can be valid but still a NULL pointer. In that case just set the aid like it is done for invalid nexthops. If the nexthop is set by explicitly specifying one then include the exit_nexthop, that is the nexthop that is relevant for BGP. Further cleanup the function as usual. OK tb@ --- usr.sbin/bgpd/rde.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index f08b23ac62b..ecf201bdafb 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.560 2022/07/28 13:11:50 deraadt Exp $ */ +/* $OpenBSD: rde.c,v 1.561 2022/08/10 11:11:02 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -4247,14 +4247,13 @@ network_dump_upcall(struct rib_entry *re, void *ptr) continue; pt_getaddr(p->pt, &addr); - bzero(&kf, sizeof(kf)); - memcpy(&kf.prefix, &addr, sizeof(kf.prefix)); - if (prefix_nhvalid(p)) - kf.nexthop.aid = kf.prefix.aid; - else - memcpy(&kf.nexthop, &prefix_nexthop(p)->true_nexthop, - sizeof(kf.nexthop)); + memset(&kf, 0, sizeof(kf)); + kf.prefix = addr; kf.prefixlen = p->pt->prefixlen; + if (prefix_nhvalid(p) && prefix_nexthop(p) != NULL) + kf.nexthop = prefix_nexthop(p)->true_nexthop; + else + kf.nexthop.aid = kf.prefix.aid; if ((asp->flags & F_ANN_DYNAMIC) == 0) kf.flags = F_STATIC; if (imsg_compose(ibuf_se_ctl, IMSG_CTL_SHOW_NETWORK, 0, -- 2.20.1