inpcb: allow to provide protocol specific pcb size

The protocol specific structure shall start with inpcb.

Differential revision:	https://reviews.freebsd.org/D37126
This commit is contained in:
Gleb Smirnoff 2022-12-02 14:10:55 -08:00
parent cc2be31177
commit 0aa120d52f
5 changed files with 9 additions and 7 deletions

View File

@ -551,7 +551,7 @@ in_pcbstorage_init(void *arg)
struct inpcbstorage *pcbstor = arg;
pcbstor->ips_zone = uma_zcreate(pcbstor->ips_zone_name,
sizeof(struct inpcb), NULL, inpcb_dtor, pcbstor->ips_pcbinit,
pcbstor->ips_size, NULL, inpcb_dtor, pcbstor->ips_pcbinit,
inpcb_fini, UMA_ALIGN_PTR, UMA_ZONE_SMR);
pcbstor->ips_portzone = uma_zcreate(pcbstor->ips_portzone_name,
sizeof(struct inpcbport), NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);

View File

@ -464,13 +464,14 @@ struct inpcbstorage {
uma_zone_t ips_zone;
uma_zone_t ips_portzone;
uma_init ips_pcbinit;
size_t ips_size;
const char * ips_zone_name;
const char * ips_portzone_name;
const char * ips_infolock_name;
const char * ips_hashlock_name;
};
#define INPCBSTORAGE_DEFINE(prot, lname, zname, iname, hname) \
#define INPCBSTORAGE_DEFINE(prot, ppcb, lname, zname, iname, hname) \
static int \
prot##_inpcb_init(void *mem, int size __unused, int flags __unused) \
{ \
@ -480,6 +481,7 @@ prot##_inpcb_init(void *mem, int size __unused, int flags __unused) \
return (0); \
} \
static struct inpcbstorage prot = { \
.ips_size = sizeof(struct ppcb), \
.ips_pcbinit = prot##_inpcb_init, \
.ips_zone_name = zname, \
.ips_portzone_name = zname " ports", \

View File

@ -182,7 +182,7 @@ rip_delhash(struct inpcb *inp)
}
#endif /* INET */
INPCBSTORAGE_DEFINE(ripcbstor, "rawinp", "ripcb", "rip", "riphash");
INPCBSTORAGE_DEFINE(ripcbstor, inpcb, "rawinp", "ripcb", "rip", "riphash");
static void
rip_init(void *arg __unused)

View File

@ -1148,7 +1148,7 @@ static struct mtx isn_mtx;
#define ISN_LOCK() mtx_lock(&isn_mtx)
#define ISN_UNLOCK() mtx_unlock(&isn_mtx)
INPCBSTORAGE_DEFINE(tcpcbstor, "tcpinp", "tcp_inpcb", "tcp", "tcphash");
INPCBSTORAGE_DEFINE(tcpcbstor, inpcb, "tcpinp", "tcp_inpcb", "tcp", "tcphash");
/*
* Take a value and get the next power of 2 that doesn't overflow.

View File

@ -170,9 +170,9 @@ static int udp_output(struct inpcb *, struct mbuf *, struct sockaddr *,
struct mbuf *, struct thread *, int);
#endif
INPCBSTORAGE_DEFINE(udpcbstor, "udpinp", "udp_inpcb", "udp", "udphash");
INPCBSTORAGE_DEFINE(udplitecbstor, "udpliteinp", "udplite_inpcb", "udplite",
"udplitehash");
INPCBSTORAGE_DEFINE(udpcbstor, inpcb, "udpinp", "udp_inpcb", "udp", "udphash");
INPCBSTORAGE_DEFINE(udplitecbstor, inpcb, "udpliteinp", "udplite_inpcb",
"udplite", "udplitehash");
static void
udp_vnet_init(void *arg __unused)