diff options
Diffstat (limited to 'net/sunrpc/addr.c')
-rw-r--r-- | net/sunrpc/addr.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c index c7450c8f0a7c..1419d0cdbbac 100644 --- a/net/sunrpc/addr.c +++ b/net/sunrpc/addr.c | |||
@@ -18,6 +18,7 @@ | |||
18 | 18 | ||
19 | #include <net/ipv6.h> | 19 | #include <net/ipv6.h> |
20 | #include <linux/sunrpc/clnt.h> | 20 | #include <linux/sunrpc/clnt.h> |
21 | #include <linux/slab.h> | ||
21 | 22 | ||
22 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 23 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
23 | 24 | ||
@@ -55,16 +56,8 @@ static size_t rpc_ntop6_noscopeid(const struct sockaddr *sap, | |||
55 | 56 | ||
56 | /* | 57 | /* |
57 | * RFC 4291, Section 2.2.1 | 58 | * RFC 4291, Section 2.2.1 |
58 | * | ||
59 | * To keep the result as short as possible, especially | ||
60 | * since we don't shorthand, we don't want leading zeros | ||
61 | * in each halfword, so avoid %pI6. | ||
62 | */ | 59 | */ |
63 | return snprintf(buf, buflen, "%x:%x:%x:%x:%x:%x:%x:%x", | 60 | return snprintf(buf, buflen, "%pI6c", addr); |
64 | ntohs(addr->s6_addr16[0]), ntohs(addr->s6_addr16[1]), | ||
65 | ntohs(addr->s6_addr16[2]), ntohs(addr->s6_addr16[3]), | ||
66 | ntohs(addr->s6_addr16[4]), ntohs(addr->s6_addr16[5]), | ||
67 | ntohs(addr->s6_addr16[6]), ntohs(addr->s6_addr16[7])); | ||
68 | } | 61 | } |
69 | 62 | ||
70 | static size_t rpc_ntop6(const struct sockaddr *sap, | 63 | static size_t rpc_ntop6(const struct sockaddr *sap, |
@@ -79,8 +72,9 @@ static size_t rpc_ntop6(const struct sockaddr *sap, | |||
79 | if (unlikely(len == 0)) | 72 | if (unlikely(len == 0)) |
80 | return len; | 73 | return len; |
81 | 74 | ||
82 | if (!(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) && | 75 | if (!(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL)) |
83 | !(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_SITELOCAL)) | 76 | return len; |
77 | if (sin6->sin6_scope_id == 0) | ||
84 | return len; | 78 | return len; |
85 | 79 | ||
86 | rc = snprintf(scopebuf, sizeof(scopebuf), "%c%u", | 80 | rc = snprintf(scopebuf, sizeof(scopebuf), "%c%u", |
@@ -173,8 +167,7 @@ static int rpc_parse_scope_id(const char *buf, const size_t buflen, | |||
173 | if (*delim != IPV6_SCOPE_DELIMITER) | 167 | if (*delim != IPV6_SCOPE_DELIMITER) |
174 | return 0; | 168 | return 0; |
175 | 169 | ||
176 | if (!(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) && | 170 | if (!(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL)) |
177 | !(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_SITELOCAL)) | ||
178 | return 0; | 171 | return 0; |
179 | 172 | ||
180 | len = (buf + buflen) - delim - 1; | 173 | len = (buf + buflen) - delim - 1; |