On Fri, 2024-06-07 at 10:26 -0400, Mike Snitzer wrote: > From: Peng Tao <tao.peng@xxxxxxxxxxxxxxx> > Still looking over the set, but this could use some justification. > Signed-off-by: Peng Tao <tao.peng@xxxxxxxxxxxxxxx> > Signed-off-by: Lance Shelton <lance.shelton@xxxxxxxxxxxxxxx> > Signed-off-by: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx> > Signed-off-by: Mike Snitzer <snitzer@xxxxxxxxxx> > --- > include/linux/sunrpc/addr.h | 9 +++++++++ > net/sunrpc/addr.c | 19 +++++++++++++------ > 2 files changed, 22 insertions(+), 6 deletions(-) > > diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h > index 07d454873b6d..e1007bddc3c4 100644 > --- a/include/linux/sunrpc/addr.h > +++ b/include/linux/sunrpc/addr.h > @@ -68,6 +68,9 @@ static inline bool __rpc_copy_addr4(struct sockaddr *dst, > } > > #if IS_ENABLED(CONFIG_IPV6) > +extern size_t rpc_ntop6_addr_noscopeid(const struct in6_addr *addr, > + char *buf, const int buflen); > + > static inline bool rpc_cmp_addr6(const struct sockaddr *sap1, > const struct sockaddr *sap2) > { > @@ -94,6 +97,12 @@ static inline bool __rpc_copy_addr6(struct sockaddr *dst, > return true; > } > #else /* !(IS_ENABLED(CONFIG_IPV6) */ > +static size_t rpc_ntop6_addr_noscopeid(const struct in6_addr *addr, > + char *buf, const int buflen) > +{ > + return 0; > +} > + > static inline bool rpc_cmp_addr6(const struct sockaddr *sap1, > const struct sockaddr *sap2) > { > diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c > index 97ff11973c49..78a123a7c39b 100644 > --- a/net/sunrpc/addr.c > +++ b/net/sunrpc/addr.c > @@ -25,12 +25,9 @@ > > #if IS_ENABLED(CONFIG_IPV6) > > -static size_t rpc_ntop6_noscopeid(const struct sockaddr *sap, > - char *buf, const int buflen) > +size_t rpc_ntop6_addr_noscopeid(const struct in6_addr *addr, > + char *buf, const int buflen) > { > - const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; > - const struct in6_addr *addr = &sin6->sin6_addr; > - > /* > * RFC 4291, Section 2.2.2 > * > @@ -55,13 +52,23 @@ static size_t rpc_ntop6_noscopeid(const struct sockaddr *sap, > */ > if (ipv6_addr_v4mapped(addr)) > return snprintf(buf, buflen, "::ffff:%pI4", > - &addr->s6_addr32[3]); > + &addr->s6_addr32[3]); > > /* > * RFC 4291, Section 2.2.1 > */ > return snprintf(buf, buflen, "%pI6c", addr); > } > +EXPORT_SYMBOL_GPL(rpc_ntop6_addr_noscopeid); > + > +static size_t rpc_ntop6_noscopeid(const struct sockaddr *sap, > + char *buf, const int buflen) > +{ > + const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; > + const struct in6_addr *addr = &sin6->sin6_addr; > + > + return rpc_ntop6_addr_noscopeid(addr, buf, buflen); > +} > > static size_t rpc_ntop6(const struct sockaddr *sap, > char *buf, const size_t buflen) -- Jeff Layton <jlayton@xxxxxxxxxx>