The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=3182dc411788ea690d557f9e16083dcaf38ddab0
commit 3182dc411788ea690d557f9e16083dcaf38ddab0 Author: Gleb Smirnoff <[email protected]> AuthorDate: 2026-01-23 22:17:10 +0000 Commit: Gleb Smirnoff <[email protected]> CommitDate: 2026-01-23 22:17:10 +0000 netinet6: embed the counter(9) arrays in struct in6_ifextra Reviewed by: tuexen Differential Revision: https://reviews.freebsd.org/D54723 --- sys/netinet/icmp6.h | 3 +-- sys/netinet6/in6.c | 6 ------ sys/netinet6/in6_ifattach.c | 2 -- sys/netinet6/in6_var.h | 36 +++++++++++++++++------------------- 4 files changed, 18 insertions(+), 29 deletions(-) diff --git a/sys/netinet/icmp6.h b/sys/netinet/icmp6.h index 082ef5d29ce9..9ed39d118c16 100644 --- a/sys/netinet/icmp6.h +++ b/sys/netinet/icmp6.h @@ -717,8 +717,7 @@ int icmp6_ratelimit(const struct in6_addr *, const int, const int); #define icmp6_ifstat_inc(ifp, tag) \ do { \ if (ifp) \ - counter_u64_add(((struct in6_ifextra *) \ - ((ifp)->if_inet6))->icmp6_ifstat[ \ + counter_u64_add((ifp)->if_inet6->icmp6_ifstat[ \ offsetof(struct icmp6_ifstat, tag) / sizeof(uint64_t)], 1);\ } while (/*CONSTCOND*/ 0) diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 43452525e992..40bc286f3ab2 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -2610,14 +2610,8 @@ in6_ifarrival(void *arg __unused, struct ifnet *ifp) ext = (struct in6_ifextra *)malloc(sizeof(*ext), M_IFADDR, M_WAITOK); bzero(ext, sizeof(*ext)); - ext->in6_ifstat = malloc(sizeof(counter_u64_t) * - sizeof(struct in6_ifstat) / sizeof(uint64_t), M_IFADDR, M_WAITOK); COUNTER_ARRAY_ALLOC(ext->in6_ifstat, sizeof(struct in6_ifstat) / sizeof(uint64_t), M_WAITOK); - - ext->icmp6_ifstat = malloc(sizeof(counter_u64_t) * - sizeof(struct icmp6_ifstat) / sizeof(uint64_t), M_IFADDR, - M_WAITOK); COUNTER_ARRAY_ALLOC(ext->icmp6_ifstat, sizeof(struct icmp6_ifstat) / sizeof(uint64_t), M_WAITOK); diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c index c3d256a8d51f..194033ee7808 100644 --- a/sys/netinet6/in6_ifattach.c +++ b/sys/netinet6/in6_ifattach.c @@ -922,10 +922,8 @@ in6_ifdeparture(void *arg __unused, struct ifnet *ifp) lltable_free(ext->lltable); COUNTER_ARRAY_FREE(ext->in6_ifstat, sizeof(struct in6_ifstat) / sizeof(uint64_t)); - free(ext->in6_ifstat, M_IFADDR); COUNTER_ARRAY_FREE(ext->icmp6_ifstat, sizeof(struct icmp6_ifstat) / sizeof(uint64_t)); - free(ext->icmp6_ifstat, M_IFADDR); free(ext, M_IFADDR); } EVENTHANDLER_DEFINE(ifnet_departure_event, in6_ifdeparture, NULL, diff --git a/sys/netinet6/in6_var.h b/sys/netinet6/in6_var.h index 8881885ecf86..1e0b6c0ed29e 100644 --- a/sys/netinet6/in6_var.h +++ b/sys/netinet6/in6_var.h @@ -93,25 +93,6 @@ struct in6_addrlifetime { u_int32_t ia6t_pltime; /* prefix lifetime */ }; -struct nd_ifinfo; -struct scope6_id; -struct lltable; -struct mld_ifsoftc; -struct in6_multi; - -struct in6_ifextra { - counter_u64_t *in6_ifstat; - counter_u64_t *icmp6_ifstat; - struct nd_ifinfo *nd_ifinfo; - struct scope6_id *scope6_id; - struct lltable *lltable; - struct mld_ifsoftc *mld_ifinfo; - u_int dad_failures; /* DAD failures when using RFC 7217 stable addresses */ -}; - -#define LLTABLE6(ifp) ((ifp)->if_inet6->lltable) -#define DAD_FAILURES(ifp) ((ifp)->if_inet6->dad_failures) - #ifdef _KERNEL SLIST_HEAD(in6_multi_head, in6_multi); @@ -507,6 +488,23 @@ struct in6_rrenumreq { #endif #ifdef _KERNEL +/* + * Structure pointed at by ifp->if_inet6. + */ +struct in6_ifextra { + counter_u64_t in6_ifstat[sizeof(struct in6_ifstat) / sizeof(uint64_t)]; + counter_u64_t icmp6_ifstat[sizeof(struct icmp6_ifstat) / + sizeof(uint64_t)]; + struct nd_ifinfo *nd_ifinfo; + struct scope6_id *scope6_id; + struct lltable *lltable; + struct mld_ifsoftc *mld_ifinfo; + u_int dad_failures; /* DAD failures when using RFC 7217 stable addresses */ +}; + +#define LLTABLE6(ifp) ((ifp)->if_inet6->lltable) +#define DAD_FAILURES(ifp) ((ifp)->if_inet6->dad_failures) + VNET_DECLARE(struct in6_ifaddrhead, in6_ifaddrhead); VNET_DECLARE(struct in6_ifaddrlisthead *, in6_ifaddrhashtbl); VNET_DECLARE(u_long, in6_ifaddrhmask);
