From: claudio Date: Wed, 10 Aug 2022 14:17:01 +0000 (+0000) Subject: More kroute_nexthop cleanup. Mainly use direct assignment instead of X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=47bbf013c3a023c5a325ae968ca3b57a1e852f28;p=openbsd More kroute_nexthop cleanup. Mainly use direct assignment instead of memcpy(). Additionally replace a bzero() with memset() and remove to superfluous bzero calls. OK tb@ --- diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index 981a4424f57..6c256da17f0 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.448 2022/07/28 13:11:48 deraadt Exp $ */ +/* $OpenBSD: bgpd.h,v 1.449 2022/08/10 14:17:01 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -717,9 +717,9 @@ struct kroute_nexthop { struct bgpd_addr nexthop; struct bgpd_addr gateway; struct bgpd_addr net; + uint8_t netlen; uint8_t valid; uint8_t connected; - uint8_t netlen; }; struct session_dependon { diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index ecf201bdafb..b23295553bf 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.561 2022/08/10 11:11:02 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.562 2022/08/10 14:17:01 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -2474,7 +2474,7 @@ rde_dump_rib_as(struct prefix *p, struct rde_aspath *asp, pid_t pid, int flags, nexthop = prefix_nexthop(p); peer = prefix_peer(p); - bzero(&rib, sizeof(rib)); + memset(&rib, 0, sizeof(rib)); rib.age = getmonotime() - p->lastchange; rib.local_pref = asp->lpref; rib.med = asp->med; @@ -2484,16 +2484,12 @@ rde_dump_rib_as(struct prefix *p, struct rde_aspath *asp, pid_t pid, int flags, sizeof(rib.remote_addr)); rib.remote_id = peer->remote_bgpid; if (nexthop != NULL) { - memcpy(&rib.true_nexthop, &nexthop->true_nexthop, - sizeof(rib.true_nexthop)); - memcpy(&rib.exit_nexthop, &nexthop->exit_nexthop, - sizeof(rib.exit_nexthop)); + rib.exit_nexthop = nexthop->exit_nexthop; + rib.true_nexthop = nexthop->true_nexthop; } else { - /* announced network may have a NULL nexthop */ - bzero(&rib.true_nexthop, sizeof(rib.true_nexthop)); - bzero(&rib.exit_nexthop, sizeof(rib.exit_nexthop)); - rib.true_nexthop.aid = p->pt->aid; + /* announced network can have a NULL nexthop */ rib.exit_nexthop.aid = p->pt->aid; + rib.true_nexthop.aid = p->pt->aid; } pt_getaddr(p->pt, &rib.prefix); rib.prefixlen = p->pt->prefixlen; diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c index 578d3aca700..151944456a8 100644 --- a/usr.sbin/bgpd/rde_rib.c +++ b/usr.sbin/bgpd/rde_rib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_rib.c,v 1.242 2022/07/28 13:11:51 deraadt Exp $ */ +/* $OpenBSD: rde_rib.c,v 1.243 2022/08/10 14:17:01 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker @@ -1741,14 +1741,11 @@ nexthop_update(struct kroute_nexthop *msg) if (msg->connected) { nh->flags |= NEXTHOP_CONNECTED; - memcpy(&nh->true_nexthop, &nh->exit_nexthop, - sizeof(nh->true_nexthop)); + nh->true_nexthop = nh->exit_nexthop; } else - memcpy(&nh->true_nexthop, &msg->gateway, - sizeof(nh->true_nexthop)); + nh->true_nexthop = msg->gateway; - memcpy(&nh->nexthop_net, &msg->net, - sizeof(nh->nexthop_net)); + nh->nexthop_net = msg->net; nh->nexthop_netlen = msg->netlen; nh->next_prefix = LIST_FIRST(&nh->prefix_h);