Message ID | 20250311075239.2018087-2-pizhenwei@bytedance.com |
---|---|
State | New |
Headers | show |
Series | getaddrinfo.c: support MPTCP | expand |
On 11/03/25 04:52, zhenwei pi wrote: > There is a lack of MPTCP support from gaih_inet_typeproto array, add > MPTCP entry. > > Signed-off-by: zhenwei pi <zhenwei.pi@linux.dev> > Signed-off-by: zhenwei pi <pizhenwei@bytedance.com> LGTM, thanks. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> > --- > nss/getaddrinfo.c | 3 +++ > nss/tst-getaddrinfo3.c | 26 ++++++++++++++++++++++++++ > 2 files changed, 29 insertions(+) > > diff --git a/nss/getaddrinfo.c b/nss/getaddrinfo.c > index 21e899ff1d..efe6ad30d5 100644 > --- a/nss/getaddrinfo.c > +++ b/nss/getaddrinfo.c > @@ -143,6 +143,9 @@ static const struct gaih_typeproto gaih_inet_typeproto[] = > #ifdef IPPROTO_SCTP > { SOCK_STREAM, IPPROTO_SCTP, 0, false, "sctp" }, > { SOCK_SEQPACKET, IPPROTO_SCTP, 0, false, "sctp" }, > +#endif > +#ifdef IPPROTO_MPTCP > + { SOCK_STREAM, IPPROTO_MPTCP, 0, false, "mptcp" }, > #endif > { SOCK_RAW, 0, GAI_PROTO_PROTOANY|GAI_PROTO_NOSERVICE, true, "raw" }, > { 0, 0, 0, false, "" } > diff --git a/nss/tst-getaddrinfo3.c b/nss/tst-getaddrinfo3.c > index 5077f311fc..caea19b27f 100644 > --- a/nss/tst-getaddrinfo3.c > +++ b/nss/tst-getaddrinfo3.c > @@ -144,6 +144,32 @@ getaddrinfo test %d return address of family %d, expected %d\n", \ > hints.ai_socktype = SOCK_STREAM; > T (10, 0, "::ffff:127.0.0.1", AF_INET6, "::ffff:127.0.0.1"); > > +#ifdef IPPROTO_MPTCP > + memset (&hints, '\0', sizeof (hints)); > + hints.ai_family = AF_UNSPEC; > + hints.ai_socktype = SOCK_STREAM; > + hints.ai_protocol = IPPROTO_MPTCP; > + T (11, 0, "127.0.0.1", AF_INET, "127.0.0.1"); > + > + memset (&hints, '\0', sizeof (hints)); > + hints.ai_family = AF_INET; > + hints.ai_socktype = SOCK_STREAM; > + hints.ai_protocol = IPPROTO_MPTCP; > + T (12, 0, "127.0.0.1", AF_INET, "127.0.0.1"); > + > + memset (&hints, '\0', sizeof (hints)); > + hints.ai_family = AF_INET6; > + hints.ai_socktype = SOCK_STREAM; > + hints.ai_protocol = IPPROTO_MPTCP; > + T (13, 0, "::ffff:127.0.0.1", AF_INET6, "::ffff:127.0.0.1"); > + > + memset (&hints, '\0', sizeof (hints)); > + hints.ai_family = AF_INET6; > + hints.ai_socktype = SOCK_STREAM; > + hints.ai_protocol = IPPROTO_MPTCP; > + T (14, 0, "::ffff:127.0.0.1", AF_INET6, "::ffff:127.0.0.1"); > +#endif > + > return result; > } >
diff --git a/nss/getaddrinfo.c b/nss/getaddrinfo.c index 21e899ff1d..efe6ad30d5 100644 --- a/nss/getaddrinfo.c +++ b/nss/getaddrinfo.c @@ -143,6 +143,9 @@ static const struct gaih_typeproto gaih_inet_typeproto[] = #ifdef IPPROTO_SCTP { SOCK_STREAM, IPPROTO_SCTP, 0, false, "sctp" }, { SOCK_SEQPACKET, IPPROTO_SCTP, 0, false, "sctp" }, +#endif +#ifdef IPPROTO_MPTCP + { SOCK_STREAM, IPPROTO_MPTCP, 0, false, "mptcp" }, #endif { SOCK_RAW, 0, GAI_PROTO_PROTOANY|GAI_PROTO_NOSERVICE, true, "raw" }, { 0, 0, 0, false, "" } diff --git a/nss/tst-getaddrinfo3.c b/nss/tst-getaddrinfo3.c index 5077f311fc..caea19b27f 100644 --- a/nss/tst-getaddrinfo3.c +++ b/nss/tst-getaddrinfo3.c @@ -144,6 +144,32 @@ getaddrinfo test %d return address of family %d, expected %d\n", \ hints.ai_socktype = SOCK_STREAM; T (10, 0, "::ffff:127.0.0.1", AF_INET6, "::ffff:127.0.0.1"); +#ifdef IPPROTO_MPTCP + memset (&hints, '\0', sizeof (hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_MPTCP; + T (11, 0, "127.0.0.1", AF_INET, "127.0.0.1"); + + memset (&hints, '\0', sizeof (hints)); + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_MPTCP; + T (12, 0, "127.0.0.1", AF_INET, "127.0.0.1"); + + memset (&hints, '\0', sizeof (hints)); + hints.ai_family = AF_INET6; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_MPTCP; + T (13, 0, "::ffff:127.0.0.1", AF_INET6, "::ffff:127.0.0.1"); + + memset (&hints, '\0', sizeof (hints)); + hints.ai_family = AF_INET6; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_MPTCP; + T (14, 0, "::ffff:127.0.0.1", AF_INET6, "::ffff:127.0.0.1"); +#endif + return result; }