diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2022-08-10 11:11:03 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2022-08-10 11:11:03 +0000 |
commit | 08e825d78a3a8ec61eb0590c8a43dd4dfed4d8e2 (patch) | |
tree | ff4ae86ddc5f76413455003b5af080b94a19f8da /usr.sbin/bgpd/rde.c | |
parent | d2b7c77c317452550907809803170565ed8dfa76 (diff) |
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@
Diffstat (limited to 'usr.sbin/bgpd/rde.c')
-rw-r--r-- | usr.sbin/bgpd/rde.c | 15 |
1 files 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 <henning@openbsd.org> @@ -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, |