netinet6: embed struct scope6_id into struct in6_ifextra

Reviewed by:		tuexen
Differential Revision:	https://reviews.freebsd.org/D54726
This commit is contained in:
Gleb Smirnoff
2026-01-23 14:18:07 -08:00
parent 576ee62dd2
commit aa3bbc06e5
5 changed files with 17 additions and 28 deletions
+1 -1
View File
@@ -2613,8 +2613,8 @@ in6_ifarrival(void *arg __unused, struct ifnet *ifp)
COUNTER_ARRAY_ALLOC(ext->icmp6_ifstat,
sizeof(struct icmp6_ifstat) / sizeof(uint64_t), M_WAITOK);
nd6_ifattach(ifp);
scope6_ifattach(ifp);
ext->scope6_id = scope6_ifattach(ifp);
ext->lltable = in6_lltattach(ifp);
ext->mld_ifinfo = mld_domifattach(ifp);
-1
View File
@@ -917,7 +917,6 @@ in6_ifdeparture(void *arg __unused, struct ifnet *ifp)
#endif
_in6_ifdetach(ifp, 1);
mld_domifdetach(ifp);
scope6_ifdetach(ext->scope6_id);
nd6_ifdetach(ifp);
lltable_free(ext->lltable);
COUNTER_ARRAY_FREE(ext->in6_ifstat,
+9 -1
View File
@@ -506,7 +506,15 @@ struct in6_ifextra {
u_int nd_dad_failures;
uint8_t nd_curhoplimit;
struct scope6_id *scope6_id;
struct scope6_id {
/*
* 16 is correspondent to 4bit multicast scope field. i.e. from
* node-local to global with some reserved/unassigned types.
*/
#define IPV6_ADDR_SCOPES_COUNT 16
uint32_t s6id_list[IPV6_ADDR_SCOPES_COUNT];
} scope6_id;
struct lltable *lltable;
struct mld_ifsoftc *mld_ifinfo;
};
+6 -13
View File
@@ -73,10 +73,11 @@ static struct mtx scope6_lock;
VNET_DEFINE_STATIC(struct scope6_id, sid_default);
#define V_sid_default VNET(sid_default)
#define SID(ifp) ((ifp)->if_inet6->scope6_id)
#define SID(ifp) (&(ifp)->if_inet6->scope6_id)
static int scope6_get(struct ifnet *, struct scope6_id *);
static int scope6_set(struct ifnet *, struct scope6_id *);
static int scope6_get_default(struct scope6_id *);
void
scope6_init(void)
@@ -90,26 +91,18 @@ scope6_init(void)
SCOPE6_LOCK_INIT();
}
struct scope6_id *
void
scope6_ifattach(struct ifnet *ifp)
{
struct scope6_id *sid;
struct scope6_id *sid = &ifp->if_inet6->scope6_id;
sid = malloc(sizeof(*sid), M_IFADDR, M_WAITOK | M_ZERO);
/*
* XXX: IPV6_ADDR_SCOPE_xxx macros are not standard.
* Should we rather hardcode here?
*/
bzero(sid, sizeof(*sid));
sid->s6id_list[IPV6_ADDR_SCOPE_INTFACELOCAL] = ifp->if_index;
sid->s6id_list[IPV6_ADDR_SCOPE_LINKLOCAL] = ifp->if_index;
return (sid);
}
void
scope6_ifdetach(struct scope6_id *sid)
{
free(sid, M_IFADDR);
}
int
@@ -280,7 +273,7 @@ scope6_setdefault(struct ifnet *ifp)
SCOPE6_UNLOCK();
}
int
static int
scope6_get_default(struct scope6_id *idlist)
{
+1 -12
View File
@@ -37,21 +37,10 @@
#ifdef _KERNEL
#include <net/vnet.h>
#define IPV6_ADDR_SCOPES_COUNT 16
struct scope6_id {
/*
* 16 is correspondent to 4bit multicast scope field.
* i.e. from node-local to global with some reserved/unassigned types.
*/
uint32_t s6id_list[IPV6_ADDR_SCOPES_COUNT];
};
void scope6_init(void);
struct scope6_id *scope6_ifattach(struct ifnet *);
void scope6_ifdetach(struct scope6_id *);
void scope6_ifattach(struct ifnet *);
int scope6_ioctl(u_long cmd, caddr_t data, struct ifnet *);
void scope6_setdefault(struct ifnet *);
int scope6_get_default(struct scope6_id *);
u_int32_t scope6_addr2default(struct in6_addr *);
int sa6_embedscope(struct sockaddr_in6 *, int);
int sa6_recoverscope(struct sockaddr_in6 *);