Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: mptcp: sockopt: use IPPROTO_MPTCP for getaddrinfo

getaddrinfo MPTCP is recently supported in glibc and IPPROTO_MPTCP for
getaddrinfo is used in mptcp_connect.c. But in mptcp_sockopt.c and
mptcp_inq.c, IPPROTO_TCP are still used for getaddrinfo, So this patch
updates them.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20250502-net-next-mptcp-sft-inc-cover-v1-2-68eec95898fb@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Geliang Tang and committed by
Jakub Kicinski
dd367e81 6d0eb15c

+24 -8
+12 -4
tools/testing/selftests/net/mptcp/mptcp_inq.c
··· 72 72 } 73 73 74 74 static void xgetaddrinfo(const char *node, const char *service, 75 - const struct addrinfo *hints, 75 + struct addrinfo *hints, 76 76 struct addrinfo **res) 77 77 { 78 + again: 78 79 int err = getaddrinfo(node, service, hints, res); 79 80 80 81 if (err) { 81 - const char *errstr = getxinfo_strerr(err); 82 + const char *errstr; 83 + 84 + if (err == EAI_SOCKTYPE) { 85 + hints->ai_protocol = IPPROTO_TCP; 86 + goto again; 87 + } 88 + 89 + errstr = getxinfo_strerr(err); 82 90 83 91 fprintf(stderr, "Fatal: getaddrinfo(%s:%s): %s\n", 84 92 node ? node : "", service ? service : "", errstr); ··· 99 91 { 100 92 int sock = -1; 101 93 struct addrinfo hints = { 102 - .ai_protocol = IPPROTO_TCP, 94 + .ai_protocol = IPPROTO_MPTCP, 103 95 .ai_socktype = SOCK_STREAM, 104 96 .ai_flags = AI_PASSIVE | AI_NUMERICHOST 105 97 }; ··· 144 136 const char * const port, int proto) 145 137 { 146 138 struct addrinfo hints = { 147 - .ai_protocol = IPPROTO_TCP, 139 + .ai_protocol = IPPROTO_MPTCP, 148 140 .ai_socktype = SOCK_STREAM, 149 141 }; 150 142 struct addrinfo *a, *addr;
+12 -4
tools/testing/selftests/net/mptcp/mptcp_sockopt.c
··· 159 159 } 160 160 161 161 static void xgetaddrinfo(const char *node, const char *service, 162 - const struct addrinfo *hints, 162 + struct addrinfo *hints, 163 163 struct addrinfo **res) 164 164 { 165 + again: 165 166 int err = getaddrinfo(node, service, hints, res); 166 167 167 168 if (err) { 168 - const char *errstr = getxinfo_strerr(err); 169 + const char *errstr; 170 + 171 + if (err == EAI_SOCKTYPE) { 172 + hints->ai_protocol = IPPROTO_TCP; 173 + goto again; 174 + } 175 + 176 + errstr = getxinfo_strerr(err); 169 177 170 178 fprintf(stderr, "Fatal: getaddrinfo(%s:%s): %s\n", 171 179 node ? node : "", service ? service : "", errstr); ··· 186 178 { 187 179 int sock = -1; 188 180 struct addrinfo hints = { 189 - .ai_protocol = IPPROTO_TCP, 181 + .ai_protocol = IPPROTO_MPTCP, 190 182 .ai_socktype = SOCK_STREAM, 191 183 .ai_flags = AI_PASSIVE | AI_NUMERICHOST 192 184 }; ··· 231 223 const char * const port, int proto) 232 224 { 233 225 struct addrinfo hints = { 234 - .ai_protocol = IPPROTO_TCP, 226 + .ai_protocol = IPPROTO_MPTCP, 235 227 .ai_socktype = SOCK_STREAM, 236 228 }; 237 229 struct addrinfo *a, *addr;