diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2007-02-12 03:53:28 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-12 12:48:35 -0500 |
commit | 6b174337e5126de834a971d3edc3681bbfa45e2c (patch) | |
tree | b1dc3e0ecd82353896b07c433f98f547abc5adc2 /net/sunrpc | |
parent | f85aaeba458fda1de199a73566c641516e9a935d (diff) |
[PATCH] knfsd: SUNRPC: update internal API: separate pmap register and temp sockets
Currently in the RPC server, registering with the local portmapper and
creating "permanent" sockets are tied together. Expand the internal APIs to
allow these two socket characteristics to be separately specified.
This will be externalized in the next patch.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Cc: Aurelien Charbon <aurelien.charbon@ext.bull.net>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'net/sunrpc')
-rw-r--r-- | net/sunrpc/svcsock.c | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 2fd0ba2b20df..27ba34a152ec 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c | |||
@@ -75,7 +75,7 @@ | |||
75 | 75 | ||
76 | 76 | ||
77 | static struct svc_sock *svc_setup_socket(struct svc_serv *, struct socket *, | 77 | static struct svc_sock *svc_setup_socket(struct svc_serv *, struct socket *, |
78 | int *errp, int pmap_reg); | 78 | int *errp, int flags); |
79 | static void svc_delete_socket(struct svc_sock *svsk); | 79 | static void svc_delete_socket(struct svc_sock *svsk); |
80 | static void svc_udp_data_ready(struct sock *, int); | 80 | static void svc_udp_data_ready(struct sock *, int); |
81 | static int svc_udp_recvfrom(struct svc_rqst *); | 81 | static int svc_udp_recvfrom(struct svc_rqst *); |
@@ -935,7 +935,8 @@ svc_tcp_accept(struct svc_sock *svsk) | |||
935 | */ | 935 | */ |
936 | newsock->sk->sk_sndtimeo = HZ*30; | 936 | newsock->sk->sk_sndtimeo = HZ*30; |
937 | 937 | ||
938 | if (!(newsvsk = svc_setup_socket(serv, newsock, &err, 0))) | 938 | if (!(newsvsk = svc_setup_socket(serv, newsock, &err, |
939 | (SVC_SOCK_ANONYMOUS | SVC_SOCK_TEMPORARY)))) | ||
939 | goto failed; | 940 | goto failed; |
940 | 941 | ||
941 | 942 | ||
@@ -1476,12 +1477,14 @@ svc_age_temp_sockets(unsigned long closure) | |||
1476 | * Initialize socket for RPC use and create svc_sock struct | 1477 | * Initialize socket for RPC use and create svc_sock struct |
1477 | * XXX: May want to setsockopt SO_SNDBUF and SO_RCVBUF. | 1478 | * XXX: May want to setsockopt SO_SNDBUF and SO_RCVBUF. |
1478 | */ | 1479 | */ |
1479 | static struct svc_sock * | 1480 | static struct svc_sock *svc_setup_socket(struct svc_serv *serv, |
1480 | svc_setup_socket(struct svc_serv *serv, struct socket *sock, | 1481 | struct socket *sock, |
1481 | int *errp, int pmap_register) | 1482 | int *errp, int flags) |
1482 | { | 1483 | { |
1483 | struct svc_sock *svsk; | 1484 | struct svc_sock *svsk; |
1484 | struct sock *inet; | 1485 | struct sock *inet; |
1486 | int pmap_register = !(flags & SVC_SOCK_ANONYMOUS); | ||
1487 | int is_temporary = flags & SVC_SOCK_TEMPORARY; | ||
1485 | 1488 | ||
1486 | dprintk("svc: svc_setup_socket %p\n", sock); | 1489 | dprintk("svc: svc_setup_socket %p\n", sock); |
1487 | if (!(svsk = kzalloc(sizeof(*svsk), GFP_KERNEL))) { | 1490 | if (!(svsk = kzalloc(sizeof(*svsk), GFP_KERNEL))) { |
@@ -1523,7 +1526,7 @@ svc_setup_socket(struct svc_serv *serv, struct socket *sock, | |||
1523 | svc_tcp_init(svsk); | 1526 | svc_tcp_init(svsk); |
1524 | 1527 | ||
1525 | spin_lock_bh(&serv->sv_lock); | 1528 | spin_lock_bh(&serv->sv_lock); |
1526 | if (!pmap_register) { | 1529 | if (is_temporary) { |
1527 | set_bit(SK_TEMP, &svsk->sk_flags); | 1530 | set_bit(SK_TEMP, &svsk->sk_flags); |
1528 | list_add(&svsk->sk_list, &serv->sv_tempsocks); | 1531 | list_add(&svsk->sk_list, &serv->sv_tempsocks); |
1529 | serv->sv_tmpcnt++; | 1532 | serv->sv_tmpcnt++; |
@@ -1567,7 +1570,7 @@ int svc_addsock(struct svc_serv *serv, | |||
1567 | else if (so->state > SS_UNCONNECTED) | 1570 | else if (so->state > SS_UNCONNECTED) |
1568 | err = -EISCONN; | 1571 | err = -EISCONN; |
1569 | else { | 1572 | else { |
1570 | svsk = svc_setup_socket(serv, so, &err, 1); | 1573 | svsk = svc_setup_socket(serv, so, &err, SVC_SOCK_DEFAULTS); |
1571 | if (svsk) | 1574 | if (svsk) |
1572 | err = 0; | 1575 | err = 0; |
1573 | } | 1576 | } |
@@ -1583,8 +1586,8 @@ EXPORT_SYMBOL_GPL(svc_addsock); | |||
1583 | /* | 1586 | /* |
1584 | * Create socket for RPC service. | 1587 | * Create socket for RPC service. |
1585 | */ | 1588 | */ |
1586 | static int | 1589 | static int svc_create_socket(struct svc_serv *serv, int protocol, |
1587 | svc_create_socket(struct svc_serv *serv, int protocol, struct sockaddr_in *sin) | 1590 | struct sockaddr_in *sin, int flags) |
1588 | { | 1591 | { |
1589 | struct svc_sock *svsk; | 1592 | struct svc_sock *svsk; |
1590 | struct socket *sock; | 1593 | struct socket *sock; |
@@ -1620,8 +1623,8 @@ svc_create_socket(struct svc_serv *serv, int protocol, struct sockaddr_in *sin) | |||
1620 | goto bummer; | 1623 | goto bummer; |
1621 | } | 1624 | } |
1622 | 1625 | ||
1623 | if ((svsk = svc_setup_socket(serv, sock, &error, 1)) != NULL) | 1626 | if ((svsk = svc_setup_socket(serv, sock, &error, flags)) != NULL) |
1624 | return 0; | 1627 | return ntohs(inet_sk(svsk->sk_sk)->sport); |
1625 | 1628 | ||
1626 | bummer: | 1629 | bummer: |
1627 | dprintk("svc: svc_create_socket error = %d\n", -error); | 1630 | dprintk("svc: svc_create_socket error = %d\n", -error); |
@@ -1681,19 +1684,23 @@ void svc_close_socket(struct svc_sock *svsk) | |||
1681 | svc_sock_put(svsk); | 1684 | svc_sock_put(svsk); |
1682 | } | 1685 | } |
1683 | 1686 | ||
1684 | /* | 1687 | /** |
1685 | * Make a socket for nfsd and lockd | 1688 | * svc_makesock - Make a socket for nfsd and lockd |
1689 | * @serv: RPC server structure | ||
1690 | * @protocol: transport protocol to use | ||
1691 | * @port: port to use | ||
1692 | * | ||
1686 | */ | 1693 | */ |
1687 | int | 1694 | int svc_makesock(struct svc_serv *serv, int protocol, unsigned short port) |
1688 | svc_makesock(struct svc_serv *serv, int protocol, unsigned short port) | ||
1689 | { | 1695 | { |
1690 | struct sockaddr_in sin; | 1696 | struct sockaddr_in sin = { |
1697 | .sin_family = AF_INET, | ||
1698 | .sin_addr.s_addr = INADDR_ANY, | ||
1699 | .sin_port = htons(port), | ||
1700 | }; | ||
1691 | 1701 | ||
1692 | dprintk("svc: creating socket proto = %d\n", protocol); | 1702 | dprintk("svc: creating socket proto = %d\n", protocol); |
1693 | sin.sin_family = AF_INET; | 1703 | return svc_create_socket(serv, protocol, &sin, SVC_SOCK_DEFAULTS); |
1694 | sin.sin_addr.s_addr = INADDR_ANY; | ||
1695 | sin.sin_port = htons(port); | ||
1696 | return svc_create_socket(serv, protocol, &sin); | ||
1697 | } | 1704 | } |
1698 | 1705 | ||
1699 | /* | 1706 | /* |