diff options
Diffstat (limited to 'net/sunrpc/xprtsock.c')
-rw-r--r-- | net/sunrpc/xprtsock.c | 287 |
1 files changed, 149 insertions, 138 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 83c73c4d017a..62438f3a914d 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c | |||
@@ -248,8 +248,8 @@ struct sock_xprt { | |||
248 | * Connection of transports | 248 | * Connection of transports |
249 | */ | 249 | */ |
250 | struct delayed_work connect_worker; | 250 | struct delayed_work connect_worker; |
251 | struct sockaddr_storage addr; | 251 | struct sockaddr_storage srcaddr; |
252 | unsigned short port; | 252 | unsigned short srcport; |
253 | 253 | ||
254 | /* | 254 | /* |
255 | * UDP socket buffer size parameters | 255 | * UDP socket buffer size parameters |
@@ -296,117 +296,60 @@ static inline struct sockaddr_in6 *xs_addr_in6(struct rpc_xprt *xprt) | |||
296 | return (struct sockaddr_in6 *) &xprt->addr; | 296 | return (struct sockaddr_in6 *) &xprt->addr; |
297 | } | 297 | } |
298 | 298 | ||
299 | static void xs_format_ipv4_peer_addresses(struct rpc_xprt *xprt, | 299 | static void xs_format_common_peer_addresses(struct rpc_xprt *xprt) |
300 | const char *protocol, | ||
301 | const char *netid) | ||
302 | { | 300 | { |
303 | struct sockaddr_in *addr = xs_addr_in(xprt); | 301 | struct sockaddr *sap = xs_addr(xprt); |
304 | char *buf; | 302 | struct sockaddr_in6 *sin6; |
303 | struct sockaddr_in *sin; | ||
304 | char buf[128]; | ||
305 | 305 | ||
306 | buf = kzalloc(20, GFP_KERNEL); | 306 | (void)rpc_ntop(sap, buf, sizeof(buf)); |
307 | if (buf) { | 307 | xprt->address_strings[RPC_DISPLAY_ADDR] = kstrdup(buf, GFP_KERNEL); |
308 | snprintf(buf, 20, "%pI4", &addr->sin_addr.s_addr); | ||
309 | } | ||
310 | xprt->address_strings[RPC_DISPLAY_ADDR] = buf; | ||
311 | |||
312 | buf = kzalloc(8, GFP_KERNEL); | ||
313 | if (buf) { | ||
314 | snprintf(buf, 8, "%u", | ||
315 | ntohs(addr->sin_port)); | ||
316 | } | ||
317 | xprt->address_strings[RPC_DISPLAY_PORT] = buf; | ||
318 | |||
319 | xprt->address_strings[RPC_DISPLAY_PROTO] = protocol; | ||
320 | |||
321 | buf = kzalloc(48, GFP_KERNEL); | ||
322 | if (buf) { | ||
323 | snprintf(buf, 48, "addr=%pI4 port=%u proto=%s", | ||
324 | &addr->sin_addr.s_addr, | ||
325 | ntohs(addr->sin_port), | ||
326 | protocol); | ||
327 | } | ||
328 | xprt->address_strings[RPC_DISPLAY_ALL] = buf; | ||
329 | |||
330 | buf = kzalloc(10, GFP_KERNEL); | ||
331 | if (buf) { | ||
332 | snprintf(buf, 10, "%02x%02x%02x%02x", | ||
333 | NIPQUAD(addr->sin_addr.s_addr)); | ||
334 | } | ||
335 | xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = buf; | ||
336 | 308 | ||
337 | buf = kzalloc(8, GFP_KERNEL); | 309 | switch (sap->sa_family) { |
338 | if (buf) { | 310 | case AF_INET: |
339 | snprintf(buf, 8, "%4hx", | 311 | sin = xs_addr_in(xprt); |
340 | ntohs(addr->sin_port)); | 312 | (void)snprintf(buf, sizeof(buf), "%02x%02x%02x%02x", |
341 | } | 313 | NIPQUAD(sin->sin_addr.s_addr)); |
342 | xprt->address_strings[RPC_DISPLAY_HEX_PORT] = buf; | 314 | break; |
343 | 315 | case AF_INET6: | |
344 | buf = kzalloc(30, GFP_KERNEL); | 316 | sin6 = xs_addr_in6(xprt); |
345 | if (buf) { | 317 | (void)snprintf(buf, sizeof(buf), "%pi6", &sin6->sin6_addr); |
346 | snprintf(buf, 30, "%pI4.%u.%u", | 318 | break; |
347 | &addr->sin_addr.s_addr, | 319 | default: |
348 | ntohs(addr->sin_port) >> 8, | 320 | BUG(); |
349 | ntohs(addr->sin_port) & 0xff); | ||
350 | } | 321 | } |
351 | xprt->address_strings[RPC_DISPLAY_UNIVERSAL_ADDR] = buf; | 322 | xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = kstrdup(buf, GFP_KERNEL); |
352 | |||
353 | xprt->address_strings[RPC_DISPLAY_NETID] = netid; | ||
354 | } | 323 | } |
355 | 324 | ||
356 | static void xs_format_ipv6_peer_addresses(struct rpc_xprt *xprt, | 325 | static void xs_format_common_peer_ports(struct rpc_xprt *xprt) |
357 | const char *protocol, | ||
358 | const char *netid) | ||
359 | { | 326 | { |
360 | struct sockaddr_in6 *addr = xs_addr_in6(xprt); | 327 | struct sockaddr *sap = xs_addr(xprt); |
361 | char *buf; | 328 | char buf[128]; |
362 | 329 | ||
363 | buf = kzalloc(40, GFP_KERNEL); | 330 | (void)snprintf(buf, sizeof(buf), "%u", rpc_get_port(sap)); |
364 | if (buf) { | 331 | xprt->address_strings[RPC_DISPLAY_PORT] = kstrdup(buf, GFP_KERNEL); |
365 | snprintf(buf, 40, "%pI6",&addr->sin6_addr); | ||
366 | } | ||
367 | xprt->address_strings[RPC_DISPLAY_ADDR] = buf; | ||
368 | 332 | ||
369 | buf = kzalloc(8, GFP_KERNEL); | 333 | (void)snprintf(buf, sizeof(buf), "%4hx", rpc_get_port(sap)); |
370 | if (buf) { | 334 | xprt->address_strings[RPC_DISPLAY_HEX_PORT] = kstrdup(buf, GFP_KERNEL); |
371 | snprintf(buf, 8, "%u", | 335 | } |
372 | ntohs(addr->sin6_port)); | ||
373 | } | ||
374 | xprt->address_strings[RPC_DISPLAY_PORT] = buf; | ||
375 | 336 | ||
337 | static void xs_format_peer_addresses(struct rpc_xprt *xprt, | ||
338 | const char *protocol, | ||
339 | const char *netid) | ||
340 | { | ||
376 | xprt->address_strings[RPC_DISPLAY_PROTO] = protocol; | 341 | xprt->address_strings[RPC_DISPLAY_PROTO] = protocol; |
342 | xprt->address_strings[RPC_DISPLAY_NETID] = netid; | ||
343 | xs_format_common_peer_addresses(xprt); | ||
344 | xs_format_common_peer_ports(xprt); | ||
345 | } | ||
377 | 346 | ||
378 | buf = kzalloc(64, GFP_KERNEL); | 347 | static void xs_update_peer_port(struct rpc_xprt *xprt) |
379 | if (buf) { | 348 | { |
380 | snprintf(buf, 64, "addr=%pI6 port=%u proto=%s", | 349 | kfree(xprt->address_strings[RPC_DISPLAY_HEX_PORT]); |
381 | &addr->sin6_addr, | 350 | kfree(xprt->address_strings[RPC_DISPLAY_PORT]); |
382 | ntohs(addr->sin6_port), | ||
383 | protocol); | ||
384 | } | ||
385 | xprt->address_strings[RPC_DISPLAY_ALL] = buf; | ||
386 | |||
387 | buf = kzalloc(36, GFP_KERNEL); | ||
388 | if (buf) | ||
389 | snprintf(buf, 36, "%pi6", &addr->sin6_addr); | ||
390 | |||
391 | xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = buf; | ||
392 | |||
393 | buf = kzalloc(8, GFP_KERNEL); | ||
394 | if (buf) { | ||
395 | snprintf(buf, 8, "%4hx", | ||
396 | ntohs(addr->sin6_port)); | ||
397 | } | ||
398 | xprt->address_strings[RPC_DISPLAY_HEX_PORT] = buf; | ||
399 | |||
400 | buf = kzalloc(50, GFP_KERNEL); | ||
401 | if (buf) { | ||
402 | snprintf(buf, 50, "%pI6.%u.%u", | ||
403 | &addr->sin6_addr, | ||
404 | ntohs(addr->sin6_port) >> 8, | ||
405 | ntohs(addr->sin6_port) & 0xff); | ||
406 | } | ||
407 | xprt->address_strings[RPC_DISPLAY_UNIVERSAL_ADDR] = buf; | ||
408 | 351 | ||
409 | xprt->address_strings[RPC_DISPLAY_NETID] = netid; | 352 | xs_format_common_peer_ports(xprt); |
410 | } | 353 | } |
411 | 354 | ||
412 | static void xs_free_peer_addresses(struct rpc_xprt *xprt) | 355 | static void xs_free_peer_addresses(struct rpc_xprt *xprt) |
@@ -1587,25 +1530,15 @@ static unsigned short xs_get_random_port(void) | |||
1587 | */ | 1530 | */ |
1588 | static void xs_set_port(struct rpc_xprt *xprt, unsigned short port) | 1531 | static void xs_set_port(struct rpc_xprt *xprt, unsigned short port) |
1589 | { | 1532 | { |
1590 | struct sockaddr *addr = xs_addr(xprt); | ||
1591 | |||
1592 | dprintk("RPC: setting port for xprt %p to %u\n", xprt, port); | 1533 | dprintk("RPC: setting port for xprt %p to %u\n", xprt, port); |
1593 | 1534 | ||
1594 | switch (addr->sa_family) { | 1535 | rpc_set_port(xs_addr(xprt), port); |
1595 | case AF_INET: | 1536 | xs_update_peer_port(xprt); |
1596 | ((struct sockaddr_in *)addr)->sin_port = htons(port); | ||
1597 | break; | ||
1598 | case AF_INET6: | ||
1599 | ((struct sockaddr_in6 *)addr)->sin6_port = htons(port); | ||
1600 | break; | ||
1601 | default: | ||
1602 | BUG(); | ||
1603 | } | ||
1604 | } | 1537 | } |
1605 | 1538 | ||
1606 | static unsigned short xs_get_srcport(struct sock_xprt *transport, struct socket *sock) | 1539 | static unsigned short xs_get_srcport(struct sock_xprt *transport, struct socket *sock) |
1607 | { | 1540 | { |
1608 | unsigned short port = transport->port; | 1541 | unsigned short port = transport->srcport; |
1609 | 1542 | ||
1610 | if (port == 0 && transport->xprt.resvport) | 1543 | if (port == 0 && transport->xprt.resvport) |
1611 | port = xs_get_random_port(); | 1544 | port = xs_get_random_port(); |
@@ -1614,8 +1547,8 @@ static unsigned short xs_get_srcport(struct sock_xprt *transport, struct socket | |||
1614 | 1547 | ||
1615 | static unsigned short xs_next_srcport(struct sock_xprt *transport, struct socket *sock, unsigned short port) | 1548 | static unsigned short xs_next_srcport(struct sock_xprt *transport, struct socket *sock, unsigned short port) |
1616 | { | 1549 | { |
1617 | if (transport->port != 0) | 1550 | if (transport->srcport != 0) |
1618 | transport->port = 0; | 1551 | transport->srcport = 0; |
1619 | if (!transport->xprt.resvport) | 1552 | if (!transport->xprt.resvport) |
1620 | return 0; | 1553 | return 0; |
1621 | if (port <= xprt_min_resvport || port > xprt_max_resvport) | 1554 | if (port <= xprt_min_resvport || port > xprt_max_resvport) |
@@ -1633,7 +1566,7 @@ static int xs_bind4(struct sock_xprt *transport, struct socket *sock) | |||
1633 | unsigned short port = xs_get_srcport(transport, sock); | 1566 | unsigned short port = xs_get_srcport(transport, sock); |
1634 | unsigned short last; | 1567 | unsigned short last; |
1635 | 1568 | ||
1636 | sa = (struct sockaddr_in *)&transport->addr; | 1569 | sa = (struct sockaddr_in *)&transport->srcaddr; |
1637 | myaddr.sin_addr = sa->sin_addr; | 1570 | myaddr.sin_addr = sa->sin_addr; |
1638 | do { | 1571 | do { |
1639 | myaddr.sin_port = htons(port); | 1572 | myaddr.sin_port = htons(port); |
@@ -1642,7 +1575,7 @@ static int xs_bind4(struct sock_xprt *transport, struct socket *sock) | |||
1642 | if (port == 0) | 1575 | if (port == 0) |
1643 | break; | 1576 | break; |
1644 | if (err == 0) { | 1577 | if (err == 0) { |
1645 | transport->port = port; | 1578 | transport->srcport = port; |
1646 | break; | 1579 | break; |
1647 | } | 1580 | } |
1648 | last = port; | 1581 | last = port; |
@@ -1666,7 +1599,7 @@ static int xs_bind6(struct sock_xprt *transport, struct socket *sock) | |||
1666 | unsigned short port = xs_get_srcport(transport, sock); | 1599 | unsigned short port = xs_get_srcport(transport, sock); |
1667 | unsigned short last; | 1600 | unsigned short last; |
1668 | 1601 | ||
1669 | sa = (struct sockaddr_in6 *)&transport->addr; | 1602 | sa = (struct sockaddr_in6 *)&transport->srcaddr; |
1670 | myaddr.sin6_addr = sa->sin6_addr; | 1603 | myaddr.sin6_addr = sa->sin6_addr; |
1671 | do { | 1604 | do { |
1672 | myaddr.sin6_port = htons(port); | 1605 | myaddr.sin6_port = htons(port); |
@@ -1675,7 +1608,7 @@ static int xs_bind6(struct sock_xprt *transport, struct socket *sock) | |||
1675 | if (port == 0) | 1608 | if (port == 0) |
1676 | break; | 1609 | break; |
1677 | if (err == 0) { | 1610 | if (err == 0) { |
1678 | transport->port = port; | 1611 | transport->srcport = port; |
1679 | break; | 1612 | break; |
1680 | } | 1613 | } |
1681 | last = port; | 1614 | last = port; |
@@ -1780,8 +1713,11 @@ static void xs_udp_connect_worker4(struct work_struct *work) | |||
1780 | goto out; | 1713 | goto out; |
1781 | } | 1714 | } |
1782 | 1715 | ||
1783 | dprintk("RPC: worker connecting xprt %p to address: %s\n", | 1716 | dprintk("RPC: worker connecting xprt %p via %s to " |
1784 | xprt, xprt->address_strings[RPC_DISPLAY_ALL]); | 1717 | "%s (port %s)\n", xprt, |
1718 | xprt->address_strings[RPC_DISPLAY_PROTO], | ||
1719 | xprt->address_strings[RPC_DISPLAY_ADDR], | ||
1720 | xprt->address_strings[RPC_DISPLAY_PORT]); | ||
1785 | 1721 | ||
1786 | xs_udp_finish_connecting(xprt, sock); | 1722 | xs_udp_finish_connecting(xprt, sock); |
1787 | status = 0; | 1723 | status = 0; |
@@ -1822,8 +1758,11 @@ static void xs_udp_connect_worker6(struct work_struct *work) | |||
1822 | goto out; | 1758 | goto out; |
1823 | } | 1759 | } |
1824 | 1760 | ||
1825 | dprintk("RPC: worker connecting xprt %p to address: %s\n", | 1761 | dprintk("RPC: worker connecting xprt %p via %s to " |
1826 | xprt, xprt->address_strings[RPC_DISPLAY_ALL]); | 1762 | "%s (port %s)\n", xprt, |
1763 | xprt->address_strings[RPC_DISPLAY_PROTO], | ||
1764 | xprt->address_strings[RPC_DISPLAY_ADDR], | ||
1765 | xprt->address_strings[RPC_DISPLAY_PORT]); | ||
1827 | 1766 | ||
1828 | xs_udp_finish_connecting(xprt, sock); | 1767 | xs_udp_finish_connecting(xprt, sock); |
1829 | status = 0; | 1768 | status = 0; |
@@ -1948,8 +1887,11 @@ static void xs_tcp_setup_socket(struct rpc_xprt *xprt, | |||
1948 | goto out_eagain; | 1887 | goto out_eagain; |
1949 | } | 1888 | } |
1950 | 1889 | ||
1951 | dprintk("RPC: worker connecting xprt %p to address: %s\n", | 1890 | dprintk("RPC: worker connecting xprt %p via %s to " |
1952 | xprt, xprt->address_strings[RPC_DISPLAY_ALL]); | 1891 | "%s (port %s)\n", xprt, |
1892 | xprt->address_strings[RPC_DISPLAY_PROTO], | ||
1893 | xprt->address_strings[RPC_DISPLAY_ADDR], | ||
1894 | xprt->address_strings[RPC_DISPLAY_PORT]); | ||
1953 | 1895 | ||
1954 | status = xs_tcp_finish_connecting(xprt, sock); | 1896 | status = xs_tcp_finish_connecting(xprt, sock); |
1955 | dprintk("RPC: %p connect status %d connected %d sock state %d\n", | 1897 | dprintk("RPC: %p connect status %d connected %d sock state %d\n", |
@@ -2120,7 +2062,7 @@ static void xs_udp_print_stats(struct rpc_xprt *xprt, struct seq_file *seq) | |||
2120 | struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); | 2062 | struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); |
2121 | 2063 | ||
2122 | seq_printf(seq, "\txprt:\tudp %u %lu %lu %lu %lu %Lu %Lu\n", | 2064 | seq_printf(seq, "\txprt:\tudp %u %lu %lu %lu %lu %Lu %Lu\n", |
2123 | transport->port, | 2065 | transport->srcport, |
2124 | xprt->stat.bind_count, | 2066 | xprt->stat.bind_count, |
2125 | xprt->stat.sends, | 2067 | xprt->stat.sends, |
2126 | xprt->stat.recvs, | 2068 | xprt->stat.recvs, |
@@ -2144,7 +2086,7 @@ static void xs_tcp_print_stats(struct rpc_xprt *xprt, struct seq_file *seq) | |||
2144 | idle_time = (long)(jiffies - xprt->last_used) / HZ; | 2086 | idle_time = (long)(jiffies - xprt->last_used) / HZ; |
2145 | 2087 | ||
2146 | seq_printf(seq, "\txprt:\ttcp %u %lu %lu %lu %ld %lu %lu %lu %Lu %Lu\n", | 2088 | seq_printf(seq, "\txprt:\ttcp %u %lu %lu %lu %ld %lu %lu %lu %Lu %Lu\n", |
2147 | transport->port, | 2089 | transport->srcport, |
2148 | xprt->stat.bind_count, | 2090 | xprt->stat.bind_count, |
2149 | xprt->stat.connect_count, | 2091 | xprt->stat.connect_count, |
2150 | xprt->stat.connect_time, | 2092 | xprt->stat.connect_time, |
@@ -2223,7 +2165,7 @@ static struct rpc_xprt *xs_setup_xprt(struct xprt_create *args, | |||
2223 | memcpy(&xprt->addr, args->dstaddr, args->addrlen); | 2165 | memcpy(&xprt->addr, args->dstaddr, args->addrlen); |
2224 | xprt->addrlen = args->addrlen; | 2166 | xprt->addrlen = args->addrlen; |
2225 | if (args->srcaddr) | 2167 | if (args->srcaddr) |
2226 | memcpy(&new->addr, args->srcaddr, args->addrlen); | 2168 | memcpy(&new->srcaddr, args->srcaddr, args->addrlen); |
2227 | 2169 | ||
2228 | return xprt; | 2170 | return xprt; |
2229 | } | 2171 | } |
@@ -2272,7 +2214,7 @@ static struct rpc_xprt *xs_setup_udp(struct xprt_create *args) | |||
2272 | 2214 | ||
2273 | INIT_DELAYED_WORK(&transport->connect_worker, | 2215 | INIT_DELAYED_WORK(&transport->connect_worker, |
2274 | xs_udp_connect_worker4); | 2216 | xs_udp_connect_worker4); |
2275 | xs_format_ipv4_peer_addresses(xprt, "udp", RPCBIND_NETID_UDP); | 2217 | xs_format_peer_addresses(xprt, "udp", RPCBIND_NETID_UDP); |
2276 | break; | 2218 | break; |
2277 | case AF_INET6: | 2219 | case AF_INET6: |
2278 | if (((struct sockaddr_in6 *)addr)->sin6_port != htons(0)) | 2220 | if (((struct sockaddr_in6 *)addr)->sin6_port != htons(0)) |
@@ -2280,15 +2222,22 @@ static struct rpc_xprt *xs_setup_udp(struct xprt_create *args) | |||
2280 | 2222 | ||
2281 | INIT_DELAYED_WORK(&transport->connect_worker, | 2223 | INIT_DELAYED_WORK(&transport->connect_worker, |
2282 | xs_udp_connect_worker6); | 2224 | xs_udp_connect_worker6); |
2283 | xs_format_ipv6_peer_addresses(xprt, "udp", RPCBIND_NETID_UDP6); | 2225 | xs_format_peer_addresses(xprt, "udp", RPCBIND_NETID_UDP6); |
2284 | break; | 2226 | break; |
2285 | default: | 2227 | default: |
2286 | kfree(xprt); | 2228 | kfree(xprt); |
2287 | return ERR_PTR(-EAFNOSUPPORT); | 2229 | return ERR_PTR(-EAFNOSUPPORT); |
2288 | } | 2230 | } |
2289 | 2231 | ||
2290 | dprintk("RPC: set up transport to address %s\n", | 2232 | if (xprt_bound(xprt)) |
2291 | xprt->address_strings[RPC_DISPLAY_ALL]); | 2233 | dprintk("RPC: set up xprt to %s (port %s) via %s\n", |
2234 | xprt->address_strings[RPC_DISPLAY_ADDR], | ||
2235 | xprt->address_strings[RPC_DISPLAY_PORT], | ||
2236 | xprt->address_strings[RPC_DISPLAY_PROTO]); | ||
2237 | else | ||
2238 | dprintk("RPC: set up xprt to %s (autobind) via %s\n", | ||
2239 | xprt->address_strings[RPC_DISPLAY_ADDR], | ||
2240 | xprt->address_strings[RPC_DISPLAY_PROTO]); | ||
2292 | 2241 | ||
2293 | if (try_module_get(THIS_MODULE)) | 2242 | if (try_module_get(THIS_MODULE)) |
2294 | return xprt; | 2243 | return xprt; |
@@ -2337,23 +2286,33 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args) | |||
2337 | if (((struct sockaddr_in *)addr)->sin_port != htons(0)) | 2286 | if (((struct sockaddr_in *)addr)->sin_port != htons(0)) |
2338 | xprt_set_bound(xprt); | 2287 | xprt_set_bound(xprt); |
2339 | 2288 | ||
2340 | INIT_DELAYED_WORK(&transport->connect_worker, xs_tcp_connect_worker4); | 2289 | INIT_DELAYED_WORK(&transport->connect_worker, |
2341 | xs_format_ipv4_peer_addresses(xprt, "tcp", RPCBIND_NETID_TCP); | 2290 | xs_tcp_connect_worker4); |
2291 | xs_format_peer_addresses(xprt, "tcp", RPCBIND_NETID_TCP); | ||
2342 | break; | 2292 | break; |
2343 | case AF_INET6: | 2293 | case AF_INET6: |
2344 | if (((struct sockaddr_in6 *)addr)->sin6_port != htons(0)) | 2294 | if (((struct sockaddr_in6 *)addr)->sin6_port != htons(0)) |
2345 | xprt_set_bound(xprt); | 2295 | xprt_set_bound(xprt); |
2346 | 2296 | ||
2347 | INIT_DELAYED_WORK(&transport->connect_worker, xs_tcp_connect_worker6); | 2297 | INIT_DELAYED_WORK(&transport->connect_worker, |
2348 | xs_format_ipv6_peer_addresses(xprt, "tcp", RPCBIND_NETID_TCP6); | 2298 | xs_tcp_connect_worker6); |
2299 | xs_format_peer_addresses(xprt, "tcp", RPCBIND_NETID_TCP6); | ||
2349 | break; | 2300 | break; |
2350 | default: | 2301 | default: |
2351 | kfree(xprt); | 2302 | kfree(xprt); |
2352 | return ERR_PTR(-EAFNOSUPPORT); | 2303 | return ERR_PTR(-EAFNOSUPPORT); |
2353 | } | 2304 | } |
2354 | 2305 | ||
2355 | dprintk("RPC: set up transport to address %s\n", | 2306 | if (xprt_bound(xprt)) |
2356 | xprt->address_strings[RPC_DISPLAY_ALL]); | 2307 | dprintk("RPC: set up xprt to %s (port %s) via %s\n", |
2308 | xprt->address_strings[RPC_DISPLAY_ADDR], | ||
2309 | xprt->address_strings[RPC_DISPLAY_PORT], | ||
2310 | xprt->address_strings[RPC_DISPLAY_PROTO]); | ||
2311 | else | ||
2312 | dprintk("RPC: set up xprt to %s (autobind) via %s\n", | ||
2313 | xprt->address_strings[RPC_DISPLAY_ADDR], | ||
2314 | xprt->address_strings[RPC_DISPLAY_PROTO]); | ||
2315 | |||
2357 | 2316 | ||
2358 | if (try_module_get(THIS_MODULE)) | 2317 | if (try_module_get(THIS_MODULE)) |
2359 | return xprt; | 2318 | return xprt; |
@@ -2412,3 +2371,55 @@ void cleanup_socket_xprt(void) | |||
2412 | xprt_unregister_transport(&xs_udp_transport); | 2371 | xprt_unregister_transport(&xs_udp_transport); |
2413 | xprt_unregister_transport(&xs_tcp_transport); | 2372 | xprt_unregister_transport(&xs_tcp_transport); |
2414 | } | 2373 | } |
2374 | |||
2375 | static int param_set_uint_minmax(const char *val, struct kernel_param *kp, | ||
2376 | unsigned int min, unsigned int max) | ||
2377 | { | ||
2378 | unsigned long num; | ||
2379 | int ret; | ||
2380 | |||
2381 | if (!val) | ||
2382 | return -EINVAL; | ||
2383 | ret = strict_strtoul(val, 0, &num); | ||
2384 | if (ret == -EINVAL || num < min || num > max) | ||
2385 | return -EINVAL; | ||
2386 | *((unsigned int *)kp->arg) = num; | ||
2387 | return 0; | ||
2388 | } | ||
2389 | |||
2390 | static int param_set_portnr(const char *val, struct kernel_param *kp) | ||
2391 | { | ||
2392 | return param_set_uint_minmax(val, kp, | ||
2393 | RPC_MIN_RESVPORT, | ||
2394 | RPC_MAX_RESVPORT); | ||
2395 | } | ||
2396 | |||
2397 | static int param_get_portnr(char *buffer, struct kernel_param *kp) | ||
2398 | { | ||
2399 | return param_get_uint(buffer, kp); | ||
2400 | } | ||
2401 | #define param_check_portnr(name, p) \ | ||
2402 | __param_check(name, p, unsigned int); | ||
2403 | |||
2404 | module_param_named(min_resvport, xprt_min_resvport, portnr, 0644); | ||
2405 | module_param_named(max_resvport, xprt_max_resvport, portnr, 0644); | ||
2406 | |||
2407 | static int param_set_slot_table_size(const char *val, struct kernel_param *kp) | ||
2408 | { | ||
2409 | return param_set_uint_minmax(val, kp, | ||
2410 | RPC_MIN_SLOT_TABLE, | ||
2411 | RPC_MAX_SLOT_TABLE); | ||
2412 | } | ||
2413 | |||
2414 | static int param_get_slot_table_size(char *buffer, struct kernel_param *kp) | ||
2415 | { | ||
2416 | return param_get_uint(buffer, kp); | ||
2417 | } | ||
2418 | #define param_check_slot_table_size(name, p) \ | ||
2419 | __param_check(name, p, unsigned int); | ||
2420 | |||
2421 | module_param_named(tcp_slot_table_entries, xprt_tcp_slot_table_entries, | ||
2422 | slot_table_size, 0644); | ||
2423 | module_param_named(udp_slot_table_entries, xprt_udp_slot_table_entries, | ||
2424 | slot_table_size, 0644); | ||
2425 | |||