Skip to content

Commit dd367e8

Browse files
Geliang Tangkuba-moo
authored andcommitted
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>
1 parent 6d0eb15 commit dd367e8

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

tools/testing/selftests/net/mptcp/mptcp_inq.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,21 @@ static const char *getxinfo_strerr(int err)
7272
}
7373

7474
static void xgetaddrinfo(const char *node, const char *service,
75-
const struct addrinfo *hints,
75+
struct addrinfo *hints,
7676
struct addrinfo **res)
7777
{
78+
again:
7879
int err = getaddrinfo(node, service, hints, res);
7980

8081
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);
8290

8391
fprintf(stderr, "Fatal: getaddrinfo(%s:%s): %s\n",
8492
node ? node : "", service ? service : "", errstr);
@@ -91,7 +99,7 @@ static int sock_listen_mptcp(const char * const listenaddr,
9199
{
92100
int sock = -1;
93101
struct addrinfo hints = {
94-
.ai_protocol = IPPROTO_TCP,
102+
.ai_protocol = IPPROTO_MPTCP,
95103
.ai_socktype = SOCK_STREAM,
96104
.ai_flags = AI_PASSIVE | AI_NUMERICHOST
97105
};
@@ -136,7 +144,7 @@ static int sock_connect_mptcp(const char * const remoteaddr,
136144
const char * const port, int proto)
137145
{
138146
struct addrinfo hints = {
139-
.ai_protocol = IPPROTO_TCP,
147+
.ai_protocol = IPPROTO_MPTCP,
140148
.ai_socktype = SOCK_STREAM,
141149
};
142150
struct addrinfo *a, *addr;

tools/testing/selftests/net/mptcp/mptcp_sockopt.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,21 @@ static const char *getxinfo_strerr(int err)
159159
}
160160

161161
static void xgetaddrinfo(const char *node, const char *service,
162-
const struct addrinfo *hints,
162+
struct addrinfo *hints,
163163
struct addrinfo **res)
164164
{
165+
again:
165166
int err = getaddrinfo(node, service, hints, res);
166167

167168
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);
169177

170178
fprintf(stderr, "Fatal: getaddrinfo(%s:%s): %s\n",
171179
node ? node : "", service ? service : "", errstr);
@@ -178,7 +186,7 @@ static int sock_listen_mptcp(const char * const listenaddr,
178186
{
179187
int sock = -1;
180188
struct addrinfo hints = {
181-
.ai_protocol = IPPROTO_TCP,
189+
.ai_protocol = IPPROTO_MPTCP,
182190
.ai_socktype = SOCK_STREAM,
183191
.ai_flags = AI_PASSIVE | AI_NUMERICHOST
184192
};
@@ -223,7 +231,7 @@ static int sock_connect_mptcp(const char * const remoteaddr,
223231
const char * const port, int proto)
224232
{
225233
struct addrinfo hints = {
226-
.ai_protocol = IPPROTO_TCP,
234+
.ai_protocol = IPPROTO_MPTCP,
227235
.ai_socktype = SOCK_STREAM,
228236
};
229237
struct addrinfo *a, *addr;

0 commit comments

Comments
 (0)