From: claudio Date: Wed, 22 Jun 2022 14:48:51 +0000 (+0000) Subject: Use struct kroute_full instead of a union of struct kroute & kroute6. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0dee3f9de5f26c6023a87e5a0e6c7fced6da64c8;p=openbsd Use struct kroute_full instead of a union of struct kroute & kroute6. struct kroute_full is address family independent and so more portable. Also struct kroute and struct kroute6 will be kroute.c internal soon. OK tb@ --- diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index cc190a33496..ac1545b844d 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.432 2022/06/19 10:30:09 claudio Exp $ */ +/* $OpenBSD: bgpd.h,v 1.433 2022/06/22 14:48:51 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -769,10 +769,7 @@ struct ctl_show_interface { struct ctl_show_nexthop { struct bgpd_addr addr; struct ctl_show_interface iface; - union { - struct kroute kr4; - struct kroute6 kr6; - } kr; + struct kroute_full kr; uint8_t valid; uint8_t krvalid; }; diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c index 25476db58d0..70534b417eb 100644 --- a/usr.sbin/bgpd/kroute.c +++ b/usr.sbin/bgpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.261 2022/06/22 12:28:33 claudio Exp $ */ +/* $OpenBSD: kroute.c,v 1.262 2022/06/22 14:48:51 claudio Exp $ */ /* * Copyright (c) 2022 Claudio Jeker @@ -1149,16 +1149,14 @@ kr_show_route(struct imsg *imsg) kr = h->kroute; snh.valid = kroute_validate(&kr->r); snh.krvalid = 1; - memcpy(&snh.kr.kr4, &kr->r, - sizeof(snh.kr.kr4)); + snh.kr = *kr_tofull(&kr->r); ifindex = kr->r.ifindex; break; case AID_INET6: kr6 = h->kroute; snh.valid = kroute6_validate(&kr6->r); snh.krvalid = 1; - memcpy(&snh.kr.kr6, &kr6->r, - sizeof(snh.kr.kr6)); + snh.kr = *kr6_tofull(&kr6->r); ifindex = kr6->r.ifindex; break; }