]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: protocol: remove the redundant ->sock_domain field
authorWilly Tarreau <w@1wt.eu>
Tue, 8 Dec 2020 11:13:54 +0000 (12:13 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 8 Dec 2020 11:13:54 +0000 (12:13 +0100)
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.

include/haproxy/protocol-t.h
src/proto_sockpair.c
src/proto_tcp.c
src/proto_udp.c
src/proto_uxst.c
src/protocol.c

index 494f95d03ce8b1a895c58535e3ead373f1d36e2e..0119cf2fb826db1f21cdea24c4a8a40d6f416520 100644 (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() */
 
index fe74ff469d9517009cc76f4c2ff3481c93c2e46c..2f691f7ecd10cc2aff23f3b938efd9e5807033d2 100644 (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,
index 30a0045be10a71f3e95789d5afef728dfd581ec7..eecb299e6cfc9c555ca6d9e2ca354d850be30434 100644 (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,
index 5ac7b15880cb20ff319c895cd2e997c14ac37d4c..12e25afdf17773a8b8251d0bd0b5068bc098e0ca 100644 (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,
index 9c19374f787bb00b5e090da57268a7a109ba961a..52e90ae4a25f42603b9c1a405dc2b195be756db0 100644 (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,
index 8ea36cb8190389017ba8cfbcc16c00c7b1b216ef..cb9f6e7c1d94bdbb200402d625a803b3eaddf658 100644 (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);