More pt_entry cleanup, move structure definitions to rde_prefix.c and
authorclaudio <claudio@openbsd.org>
Tue, 28 Mar 2023 13:30:31 +0000 (13:30 +0000)
committerclaudio <claudio@openbsd.org>
Tue, 28 Mar 2023 13:30:31 +0000 (13:30 +0000)
by that make them private. Remove no longer used AID_PTSIZE define.
OK tb@

usr.sbin/bgpd/bgpd.h
usr.sbin/bgpd/rde.h
usr.sbin/bgpd/rde_prefix.c

index ecee4ef..21b2391 100644 (file)
@@ -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 <henning@openbsd.org>
@@ -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 {
index f6c3154..b128b84 100644 (file)
@@ -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 <claudio@openbsd.org> 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 {
index e722332..ab86250 100644 (file)
@@ -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 <claudio@openbsd.org>
 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);