From 448d73c9c40dacec6140b683399f24a03966ddc1 Mon Sep 17 00:00:00 2001 From: claudio Date: Tue, 28 Mar 2023 13:30:31 +0000 Subject: [PATCH] More pt_entry cleanup, move structure definitions to rde_prefix.c and by that make them private. Remove no longer used AID_PTSIZE define. OK tb@ --- usr.sbin/bgpd/bgpd.h | 11 +------- usr.sbin/bgpd/rde.h | 45 ++------------------------------- usr.sbin/bgpd/rde_prefix.c | 52 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 53 insertions(+), 55 deletions(-) diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index ecee4ef776a..21b239148bc 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.467 2023/03/28 12:15:23 claudio Exp $ */ +/* $OpenBSD: bgpd.h,v 1.468 2023/03/28 13:30:31 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -184,15 +184,6 @@ extern const struct aid aid_vals[]; { AFI_IPv6, AF_INET6, SAFI_MPLSVPN, "IPv6 vpn" } \ } -#define AID_PTSIZE { \ - 0, \ - sizeof(struct pt_entry4), \ - sizeof(struct pt_entry6), \ - sizeof(struct pt_entry_vpn4), \ - sizeof(struct pt_entry_vpn6) \ -} - - #define BGP_MPLS_BOS 0x01 struct bgpd_addr { diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h index f6c315404b6..b128b841922 100644 --- a/usr.sbin/bgpd/rde.h +++ b/usr.sbin/bgpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.286 2023/03/13 16:52:42 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.287 2023/03/28 13:30:31 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker and @@ -266,48 +266,7 @@ struct pt_entry { uint8_t aid; uint8_t prefixlen; uint16_t refcnt; -}; - -struct pt_entry4 { - RB_ENTRY(pt_entry) pt_e; - uint8_t aid; - uint8_t prefixlen; - uint16_t refcnt; - struct in_addr prefix4; -}; - -struct pt_entry6 { - RB_ENTRY(pt_entry) pt_e; - uint8_t aid; - uint8_t prefixlen; - uint16_t refcnt; - struct in6_addr prefix6; -}; - -struct pt_entry_vpn4 { - RB_ENTRY(pt_entry) pt_e; - uint8_t aid; - uint8_t prefixlen; - uint16_t refcnt; - struct in_addr prefix4; - uint64_t rd; - uint8_t labelstack[21]; - uint8_t labellen; - uint8_t pad1; - uint8_t pad2; -}; - -struct pt_entry_vpn6 { - RB_ENTRY(pt_entry) pt_e; - uint8_t aid; - uint8_t prefixlen; - uint16_t refcnt; - struct in6_addr prefix6; - uint64_t rd; - uint8_t labelstack[21]; - uint8_t labellen; - uint8_t pad1; - uint8_t pad2; + uint8_t data[4]; /* data depending on aid */ }; struct prefix { diff --git a/usr.sbin/bgpd/rde_prefix.c b/usr.sbin/bgpd/rde_prefix.c index e7223320240..ab86250ee26 100644 --- a/usr.sbin/bgpd/rde_prefix.c +++ b/usr.sbin/bgpd/rde_prefix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_prefix.c,v 1.43 2023/03/28 12:06:15 claudio Exp $ */ +/* $OpenBSD: rde_prefix.c,v 1.44 2023/03/28 13:30:31 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker @@ -48,7 +48,55 @@ static struct pt_entry *pt_alloc(struct pt_entry *); static void pt_free(struct pt_entry *); -size_t pt_sizes[AID_MAX] = AID_PTSIZE; +struct pt_entry4 { + RB_ENTRY(pt_entry) pt_e; + uint8_t aid; + uint8_t prefixlen; + uint16_t refcnt; + struct in_addr prefix4; +}; + +struct pt_entry6 { + RB_ENTRY(pt_entry) pt_e; + uint8_t aid; + uint8_t prefixlen; + uint16_t refcnt; + struct in6_addr prefix6; +}; + +struct pt_entry_vpn4 { + RB_ENTRY(pt_entry) pt_e; + uint8_t aid; + uint8_t prefixlen; + uint16_t refcnt; + struct in_addr prefix4; + uint64_t rd; + uint8_t labelstack[21]; + uint8_t labellen; + uint8_t pad1; + uint8_t pad2; +}; + +struct pt_entry_vpn6 { + RB_ENTRY(pt_entry) pt_e; + uint8_t aid; + uint8_t prefixlen; + uint16_t refcnt; + struct in6_addr prefix6; + uint64_t rd; + uint8_t labelstack[21]; + uint8_t labellen; + uint8_t pad1; + uint8_t pad2; +}; + +size_t pt_sizes[AID_MAX] = { + 0, + sizeof(struct pt_entry4), + sizeof(struct pt_entry6), + sizeof(struct pt_entry_vpn4), + sizeof(struct pt_entry_vpn6) +}; RB_HEAD(pt_tree, pt_entry); RB_PROTOTYPE(pt_tree, pt_entry, pt_e, pt_prefix_cmp); -- 2.20.1