From 660f4b3c4ebfb5ad23635ac212012bb9d9260b3e Mon Sep 17 00:00:00 2001 From: claudio Date: Tue, 13 Feb 2024 16:35:43 +0000 Subject: [PATCH] Use an C99 anonymous union inside struct bgpd_addr This kills the two far to generic v4 and v6 macros which is a big win. OK tb@ --- usr.sbin/bgpd/bgpd.h | 6 ++---- usr.sbin/bgpd/pftable.c | 9 +++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index fc31312d899..36a888f988c 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.484 2024/01/30 13:50:08 claudio Exp $ */ +/* $OpenBSD: bgpd.h,v 1.485 2024/02/13 16:35:43 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -197,14 +197,12 @@ struct bgpd_addr { struct in_addr v4; struct in6_addr v6; /* maximum size for a prefix is 256 bits */ - } ba; /* 128-bit address */ + }; /* 128-bit address */ uint64_t rd; /* route distinguisher for VPN addrs */ uint32_t scope_id; /* iface scope id for v6 */ uint8_t aid; uint8_t labellen; /* size of the labelstack */ uint8_t labelstack[18]; /* max that makes sense */ -#define v4 ba.v4 -#define v6 ba.v6 }; #define DEFAULT_LISTENER 0x01 diff --git a/usr.sbin/bgpd/pftable.c b/usr.sbin/bgpd/pftable.c index bb60269c3b8..f1fe6006701 100644 --- a/usr.sbin/bgpd/pftable.c +++ b/usr.sbin/bgpd/pftable.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pftable.c,v 1.17 2022/08/17 15:15:26 claudio Exp $ */ +/* $OpenBSD: pftable.c,v 1.18 2024/02/13 16:35:43 claudio Exp $ */ /* * Copyright (c) 2004 Damien Miller @@ -31,12 +31,9 @@ #include "log.h" -/* Namespace collision: these are defined in both bgpd.h and pfvar.h */ +/* Namespace collision: these are defined in pfvar.h and bgpd.h */ #undef v4 #undef v6 -#undef addr8 -#undef addr16 -#undef addr32 #include "bgpd.h" @@ -216,7 +213,7 @@ pftable_add_work(const char *table, struct bgpd_addr *addr, pfa = &pft->worklist[pft->naddrs]; memset(pfa, 0, sizeof(*pfa)); - memcpy(&pfa->pfra_u, &addr->ba, (len + 7U) / 8); + memcpy(&pfa->pfra_u, &addr->v6, (len + 7U) / 8); pfa->pfra_af = aid2af(addr->aid); pfa->pfra_net = len; -- 2.20.1