MINOR: protocol: remove the redundant ->sock_domain field

This field used to be needed before commit 2b5e0d8b6 ("MEDIUM: proto_udp:
replace last AF_CUST_UDP* with AF_INET*") as it was used as a protocol
entry selector. Since this commit it's always equal to the socket family's
value so it's entirely redundant. Let's remove it now to simplify the
protocol definition a little bit.
This commit is contained in:
Willy Tarreau 2020-12-08 12:13:54 +01:00
parent c43fca0139
commit f9ad06cb26
6 changed files with 2 additions and 9 deletions

View File

@ -83,7 +83,6 @@ struct protocol {
char name[PROTO_NAME_LEN]; /* protocol name, zero-terminated */
struct proto_fam *fam; /* protocol family */
int ctrl_type; /* control layer type (SOCK_STREAM/SOCK_DGRAM) */
int sock_domain; /* socket domain, as passed to socket() */
int sock_type; /* socket type, as passed to socket() */
int sock_prot; /* socket protocol, as passed to socket() */

View File

@ -67,7 +67,6 @@ static struct protocol proto_sockpair = {
.name = "sockpair",
.fam = &proto_fam_sockpair,
.ctrl_type = SOCK_STREAM,
.sock_domain = AF_CUST_SOCKPAIR,
.sock_type = SOCK_STREAM,
.sock_prot = 0,
.add = default_add_listener,

View File

@ -55,7 +55,6 @@ static struct protocol proto_tcpv4 = {
.name = "tcpv4",
.fam = &proto_fam_inet4,
.ctrl_type = SOCK_STREAM,
.sock_domain = AF_INET,
.sock_type = SOCK_STREAM,
.sock_prot = IPPROTO_TCP,
.add = default_add_listener,
@ -85,7 +84,6 @@ static struct protocol proto_tcpv6 = {
.name = "tcpv6",
.fam = &proto_fam_inet6,
.ctrl_type = SOCK_STREAM,
.sock_domain = AF_INET6,
.sock_type = SOCK_STREAM,
.sock_prot = IPPROTO_TCP,
.add = default_add_listener,

View File

@ -51,7 +51,6 @@ static struct protocol proto_udp4 = {
.name = "udp4",
.fam = &proto_fam_inet4,
.ctrl_type = SOCK_DGRAM,
.sock_domain = AF_INET,
.sock_type = SOCK_DGRAM,
.sock_prot = IPPROTO_UDP,
.add = default_add_listener,
@ -77,7 +76,6 @@ static struct protocol proto_udp6 = {
.name = "udp6",
.fam = &proto_fam_inet6,
.ctrl_type = SOCK_DGRAM,
.sock_domain = AF_INET6,
.sock_type = SOCK_DGRAM,
.sock_prot = IPPROTO_UDP,
.add = default_add_listener,

View File

@ -51,7 +51,6 @@ static struct protocol proto_unix = {
.name = "unix_stream",
.fam = &proto_fam_unix,
.ctrl_type = SOCK_STREAM,
.sock_domain = PF_UNIX,
.sock_type = SOCK_STREAM,
.sock_prot = 0,
.add = default_add_listener,

View File

@ -37,8 +37,8 @@ void protocol_register(struct protocol *proto)
{
HA_SPIN_LOCK(PROTO_LOCK, &proto_lock);
LIST_ADDQ(&protocols, &proto->list);
if (proto->sock_domain >= 0 && proto->sock_domain < AF_CUST_MAX)
__protocol_by_family[proto->sock_domain]
if (proto->fam->sock_domain >= 0 && proto->fam->sock_domain < AF_CUST_MAX)
__protocol_by_family[proto->fam->sock_domain]
[proto->sock_type == SOCK_DGRAM]
[proto->ctrl_type == SOCK_DGRAM] = proto;
HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock);