NFS/SUNRPC: support transport protocol naming

To prepare for including non-sockets-based RPC transports, select
RPC transports by an identifier (to be used in following patches).

Signed-off-by: Tom Talpey <tmt@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
\"Talpey, Thomas\ 2007-09-10 13:47:57 -04:00 committed by Trond Myklebust
parent 49c36fcc44
commit 4fa016eb24
5 changed files with 19 additions and 13 deletions

View file

@ -187,7 +187,7 @@ struct rpc_xprt {
}; };
struct xprt_create { struct xprt_create {
int proto; /* IPPROTO_UDP or IPPROTO_TCP */ int ident; /* XPRT_TRANSPORT identifier */
struct sockaddr * srcaddr; /* optional local address */ struct sockaddr * srcaddr; /* optional local address */
struct sockaddr * dstaddr; /* remote peer address */ struct sockaddr * dstaddr; /* remote peer address */
size_t addrlen; size_t addrlen;
@ -196,8 +196,7 @@ struct xprt_create {
struct xprt_class { struct xprt_class {
struct list_head list; struct list_head list;
unsigned short family; int ident; /* XPRT_TRANSPORT identifier */
int protocol;
struct rpc_xprt * (*setup)(struct xprt_create *); struct rpc_xprt * (*setup)(struct xprt_create *);
struct module *owner; struct module *owner;
char name[32]; char name[32];

View file

@ -18,6 +18,17 @@ struct rpc_xprt *xs_setup_tcp(struct xprt_create *args);
int init_socket_xprt(void); int init_socket_xprt(void);
void cleanup_socket_xprt(void); void cleanup_socket_xprt(void);
/*
* RPC transport identifiers for UDP, TCP
*
* To preserve compatibility with the historical use of raw IP protocol
* id's for transport selection, these are specified with the previous
* values. No such restriction exists for new transports, except that
* they may not collide with these values (17 and 6, respectively).
*/
#define XPRT_TRANSPORT_UDP IPPROTO_UDP
#define XPRT_TRANSPORT_TCP IPPROTO_TCP
/* /*
* RPC slot table sizes for UDP, TCP transports * RPC slot table sizes for UDP, TCP transports
*/ */

View file

@ -241,7 +241,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
struct rpc_xprt *xprt; struct rpc_xprt *xprt;
struct rpc_clnt *clnt; struct rpc_clnt *clnt;
struct xprt_create xprtargs = { struct xprt_create xprtargs = {
.proto = args->protocol, .ident = args->protocol,
.srcaddr = args->saddress, .srcaddr = args->saddress,
.dstaddr = args->address, .dstaddr = args->address,
.addrlen = args->addrsize, .addrlen = args->addrsize,

View file

@ -104,7 +104,7 @@ int xprt_register_transport(struct xprt_class *transport)
spin_lock(&xprt_list_lock); spin_lock(&xprt_list_lock);
list_for_each_entry(t, &xprt_list, list) { list_for_each_entry(t, &xprt_list, list) {
/* don't register the same transport class twice */ /* don't register the same transport class twice */
if (t == transport) if (t->ident == transport->ident)
goto out; goto out;
} }
@ -987,15 +987,13 @@ struct rpc_xprt *xprt_create_transport(struct xprt_create *args)
spin_lock(&xprt_list_lock); spin_lock(&xprt_list_lock);
list_for_each_entry(t, &xprt_list, list) { list_for_each_entry(t, &xprt_list, list) {
if ((t->family == args->dstaddr->sa_family) && if (t->ident == args->ident) {
(t->protocol == args->proto)) {
spin_unlock(&xprt_list_lock); spin_unlock(&xprt_list_lock);
goto found; goto found;
} }
} }
spin_unlock(&xprt_list_lock); spin_unlock(&xprt_list_lock);
printk(KERN_ERR "RPC: transport (%u/%d) not supported\n", printk(KERN_ERR "RPC: transport (%d) not supported\n", args->ident);
args->dstaddr->sa_family, args->proto);
return ERR_PTR(-EIO); return ERR_PTR(-EIO);
found: found:

View file

@ -1955,8 +1955,7 @@ static struct xprt_class xs_udp_transport = {
.list = LIST_HEAD_INIT(xs_udp_transport.list), .list = LIST_HEAD_INIT(xs_udp_transport.list),
.name = "udp", .name = "udp",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.family = AF_INET, .ident = IPPROTO_UDP,
.protocol = IPPROTO_UDP,
.setup = xs_setup_udp, .setup = xs_setup_udp,
}; };
@ -1964,8 +1963,7 @@ static struct xprt_class xs_tcp_transport = {
.list = LIST_HEAD_INIT(xs_tcp_transport.list), .list = LIST_HEAD_INIT(xs_tcp_transport.list),
.name = "tcp", .name = "tcp",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.family = AF_INET, .ident = IPPROTO_TCP,
.protocol = IPPROTO_TCP,
.setup = xs_setup_tcp, .setup = xs_setup_tcp,
}; };