diff options
Diffstat (limited to 'net/sunrpc/addr.c')
-rw-r--r-- | net/sunrpc/addr.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c index ee77742e0ed6..d11418f97f1f 100644 --- a/net/sunrpc/addr.c +++ b/net/sunrpc/addr.c | |||
@@ -156,8 +156,9 @@ static size_t rpc_pton4(const char *buf, const size_t buflen, | |||
156 | } | 156 | } |
157 | 157 | ||
158 | #if IS_ENABLED(CONFIG_IPV6) | 158 | #if IS_ENABLED(CONFIG_IPV6) |
159 | static int rpc_parse_scope_id(const char *buf, const size_t buflen, | 159 | static int rpc_parse_scope_id(struct net *net, const char *buf, |
160 | const char *delim, struct sockaddr_in6 *sin6) | 160 | const size_t buflen, const char *delim, |
161 | struct sockaddr_in6 *sin6) | ||
161 | { | 162 | { |
162 | char *p; | 163 | char *p; |
163 | size_t len; | 164 | size_t len; |
@@ -177,7 +178,7 @@ static int rpc_parse_scope_id(const char *buf, const size_t buflen, | |||
177 | unsigned long scope_id = 0; | 178 | unsigned long scope_id = 0; |
178 | struct net_device *dev; | 179 | struct net_device *dev; |
179 | 180 | ||
180 | dev = dev_get_by_name(&init_net, p); | 181 | dev = dev_get_by_name(net, p); |
181 | if (dev != NULL) { | 182 | if (dev != NULL) { |
182 | scope_id = dev->ifindex; | 183 | scope_id = dev->ifindex; |
183 | dev_put(dev); | 184 | dev_put(dev); |
@@ -197,7 +198,7 @@ static int rpc_parse_scope_id(const char *buf, const size_t buflen, | |||
197 | return 0; | 198 | return 0; |
198 | } | 199 | } |
199 | 200 | ||
200 | static size_t rpc_pton6(const char *buf, const size_t buflen, | 201 | static size_t rpc_pton6(struct net *net, const char *buf, const size_t buflen, |
201 | struct sockaddr *sap, const size_t salen) | 202 | struct sockaddr *sap, const size_t salen) |
202 | { | 203 | { |
203 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; | 204 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; |
@@ -213,14 +214,14 @@ static size_t rpc_pton6(const char *buf, const size_t buflen, | |||
213 | if (in6_pton(buf, buflen, addr, IPV6_SCOPE_DELIMITER, &delim) == 0) | 214 | if (in6_pton(buf, buflen, addr, IPV6_SCOPE_DELIMITER, &delim) == 0) |
214 | return 0; | 215 | return 0; |
215 | 216 | ||
216 | if (!rpc_parse_scope_id(buf, buflen, delim, sin6)) | 217 | if (!rpc_parse_scope_id(net, buf, buflen, delim, sin6)) |
217 | return 0; | 218 | return 0; |
218 | 219 | ||
219 | sin6->sin6_family = AF_INET6; | 220 | sin6->sin6_family = AF_INET6; |
220 | return sizeof(struct sockaddr_in6); | 221 | return sizeof(struct sockaddr_in6); |
221 | } | 222 | } |
222 | #else | 223 | #else |
223 | static size_t rpc_pton6(const char *buf, const size_t buflen, | 224 | static size_t rpc_pton6(struct net *net, const char *buf, const size_t buflen, |
224 | struct sockaddr *sap, const size_t salen) | 225 | struct sockaddr *sap, const size_t salen) |
225 | { | 226 | { |
226 | return 0; | 227 | return 0; |
@@ -229,6 +230,7 @@ static size_t rpc_pton6(const char *buf, const size_t buflen, | |||
229 | 230 | ||
230 | /** | 231 | /** |
231 | * rpc_pton - Construct a sockaddr in @sap | 232 | * rpc_pton - Construct a sockaddr in @sap |
233 | * @net: applicable network namespace | ||
232 | * @buf: C string containing presentation format IP address | 234 | * @buf: C string containing presentation format IP address |
233 | * @buflen: length of presentation address in bytes | 235 | * @buflen: length of presentation address in bytes |
234 | * @sap: buffer into which to plant socket address | 236 | * @sap: buffer into which to plant socket address |
@@ -241,14 +243,14 @@ static size_t rpc_pton6(const char *buf, const size_t buflen, | |||
241 | * socket address, if successful. Returns zero if an error | 243 | * socket address, if successful. Returns zero if an error |
242 | * occurred. | 244 | * occurred. |
243 | */ | 245 | */ |
244 | size_t rpc_pton(const char *buf, const size_t buflen, | 246 | size_t rpc_pton(struct net *net, const char *buf, const size_t buflen, |
245 | struct sockaddr *sap, const size_t salen) | 247 | struct sockaddr *sap, const size_t salen) |
246 | { | 248 | { |
247 | unsigned int i; | 249 | unsigned int i; |
248 | 250 | ||
249 | for (i = 0; i < buflen; i++) | 251 | for (i = 0; i < buflen; i++) |
250 | if (buf[i] == ':') | 252 | if (buf[i] == ':') |
251 | return rpc_pton6(buf, buflen, sap, salen); | 253 | return rpc_pton6(net, buf, buflen, sap, salen); |
252 | return rpc_pton4(buf, buflen, sap, salen); | 254 | return rpc_pton4(buf, buflen, sap, salen); |
253 | } | 255 | } |
254 | EXPORT_SYMBOL_GPL(rpc_pton); | 256 | EXPORT_SYMBOL_GPL(rpc_pton); |
@@ -295,6 +297,7 @@ char *rpc_sockaddr2uaddr(const struct sockaddr *sap, gfp_t gfp_flags) | |||
295 | 297 | ||
296 | /** | 298 | /** |
297 | * rpc_uaddr2sockaddr - convert a universal address to a socket address. | 299 | * rpc_uaddr2sockaddr - convert a universal address to a socket address. |
300 | * @net: applicable network namespace | ||
298 | * @uaddr: C string containing universal address to convert | 301 | * @uaddr: C string containing universal address to convert |
299 | * @uaddr_len: length of universal address string | 302 | * @uaddr_len: length of universal address string |
300 | * @sap: buffer into which to plant socket address | 303 | * @sap: buffer into which to plant socket address |
@@ -306,8 +309,9 @@ char *rpc_sockaddr2uaddr(const struct sockaddr *sap, gfp_t gfp_flags) | |||
306 | * Returns the size of the socket address if successful; otherwise | 309 | * Returns the size of the socket address if successful; otherwise |
307 | * zero is returned. | 310 | * zero is returned. |
308 | */ | 311 | */ |
309 | size_t rpc_uaddr2sockaddr(const char *uaddr, const size_t uaddr_len, | 312 | size_t rpc_uaddr2sockaddr(struct net *net, const char *uaddr, |
310 | struct sockaddr *sap, const size_t salen) | 313 | const size_t uaddr_len, struct sockaddr *sap, |
314 | const size_t salen) | ||
311 | { | 315 | { |
312 | char *c, buf[RPCBIND_MAXUADDRLEN + sizeof('\0')]; | 316 | char *c, buf[RPCBIND_MAXUADDRLEN + sizeof('\0')]; |
313 | unsigned long portlo, porthi; | 317 | unsigned long portlo, porthi; |
@@ -339,7 +343,7 @@ size_t rpc_uaddr2sockaddr(const char *uaddr, const size_t uaddr_len, | |||
339 | port = (unsigned short)((porthi << 8) | portlo); | 343 | port = (unsigned short)((porthi << 8) | portlo); |
340 | 344 | ||
341 | *c = '\0'; | 345 | *c = '\0'; |
342 | if (rpc_pton(buf, strlen(buf), sap, salen) == 0) | 346 | if (rpc_pton(net, buf, strlen(buf), sap, salen) == 0) |
343 | return 0; | 347 | return 0; |
344 | 348 | ||
345 | switch (sap->sa_family) { | 349 | switch (sap->sa_family) { |