Date: Mon, 27 Jul 2026 19:28:22 +0000 From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 698402f4f97c - main - inpcb: declare struct in_conninfo as a single declaration Message-ID: <6a67b156.383fa.5ed6e1b4@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=698402f4f97ce3bbe8130382c0bb16d48a87ff63 commit 698402f4f97ce3bbe8130382c0bb16d48a87ff63 Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2026-07-27 19:28:08 +0000 Commit: Gleb Smirnoff <glebius@FreeBSD.org> CommitDate: 2026-07-27 19:28:08 +0000 inpcb: declare struct in_conninfo as a single declaration This removes just one level of #define mess that is needed to reach into an inpcbs IPv4 address. And makes the declaration easier to read. No functional change. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D58273 --- sys/netinet/in_pcb.h | 62 ++++++++++++++++++------------------------------ sys/netinet/in_pcb_var.h | 2 +- 2 files changed, 24 insertions(+), 40 deletions(-) diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 933a4c42808e..34762b58d86b 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -38,50 +38,34 @@ #define _NETINET_IN_PCB_H_ /* - * PCB with AF_INET6 null bind'ed laddr can receive AF_INET input packet. - * So, AF_INET6 null laddr is also used as AF_INET null laddr, by utilizing - * the following structure. This requires padding always be zeroed out, - * which is done right after inpcb allocation and stays through its lifetime. - */ -struct in_addr_4in6 { - uint32_t ia46_pad32[3]; - struct in_addr ia46_addr4; -}; - -union in_dependaddr { - struct in_addr_4in6 id46_addr; - struct in6_addr id6_addr; -}; - -/* - * NOTE: ipv6 addrs should be 64-bit aligned, per RFC 2553. in_conninfo has - * some extra padding to accomplish this. + * NOTE: IPv6 inpcb bound to unspecified local address shall also receive IPv4 + * traffic. Thus, IPv6 local address that is IN6_IS_ADDR_UNSPECIFIED() should + * also be usable as IPv4 INADDR_ANY. This requires padding in in_dependaddr + * to always be zeroed out, which is done right after inpcb allocation and + * stays through its lifetime. * NOTE 2: tcp_syncache.c uses first 5 32-bit words, which identify fport, * lport, faddr to generate hash, so these fields shouldn't be moved. */ -struct in_endpoints { - uint16_t ie_fport; /* foreign port */ - uint16_t ie_lport; /* local port */ - /* protocol dependent part, local and foreign addr */ - union in_dependaddr ie_dependfaddr; /* foreign host table entry */ - union in_dependaddr ie_dependladdr; /* local host table entry */ -#define ie_faddr ie_dependfaddr.id46_addr.ia46_addr4 -#define ie_laddr ie_dependladdr.id46_addr.ia46_addr4 -#define ie6_faddr ie_dependfaddr.id6_addr -#define ie6_laddr ie_dependladdr.id6_addr - uint32_t ie6_zoneid; /* scope zone id */ -}; - -/* - * XXX The defines for inc_* are hacks and should be changed to direct - * references. - */ struct in_conninfo { uint8_t inc_flags; uint8_t inc_len; - uint16_t inc_fibnum; /* XXX was pad, 16 bits is plenty */ - /* protocol dependent part */ - struct in_endpoints inc_ie; + uint16_t inc_fibnum; + struct in_endpoints { + uint16_t ie_fport; /* foreign port */ + uint16_t ie_lport; /* local port */ + union in_dependaddr { + struct { + uint32_t __pad[3]; + struct in_addr id4_addr; + }; + struct in6_addr id6_addr; + } ie_dependfaddr, ie_dependladdr; +#define ie_faddr ie_dependfaddr.id4_addr +#define ie_laddr ie_dependladdr.id4_addr +#define ie6_faddr ie_dependfaddr.id6_addr +#define ie6_laddr ie_dependladdr.id6_addr + uint32_t ie6_zoneid; /* scope zone id */ + } inc_ie; }; /* @@ -566,7 +550,7 @@ VNET_DECLARE(uint32_t, in_pcbhashseed); * wildcard IPv4 and wildcard IPv6 must be the same, otherwise AF_INET6 * wildcard bound pcb won't be able to receive AF_INET connections, while: * jenkins_hash(&zeroes, 1, s) != jenkins_hash(&zeroes, 4, s) - * See also comment above struct in_addr_4in6. + * See also comment above struct in_conninfo. */ #define IN_ADDR_JHASH32(addr) \ ((addr)->s_addr == INADDR_ANY ? V_in_pcbhashseed : \ diff --git a/sys/netinet/in_pcb_var.h b/sys/netinet/in_pcb_var.h index 8b005712de27..f70d5cb3e8b5 100644 --- a/sys/netinet/in_pcb_var.h +++ b/sys/netinet/in_pcb_var.h @@ -74,7 +74,7 @@ struct inpcblbgroup { uint8_t il_numa_domain; int il_fibnum; union in_dependaddr il_dependladdr; /* (c) */ -#define il_laddr il_dependladdr.id46_addr.ia46_addr4 +#define il_laddr il_dependladdr.id4_addr #define il6_laddr il_dependladdr.id6_addr uint32_t il_inpsiz; /* max count in il_inp[] (h) */ uint32_t il_inpcnt; /* cur count in il_inp[] (h) */home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a67b156.383fa.5ed6e1b4>
