mirror of https://gitee.com/openkylin/linux.git
lockd: Use sockaddr_storage for h_saddr field
To store larger addresses in the nlm_host structure, make h_saddr a sockaddr_storage. And let's call it something more self-explanatory: "saddr" could easily be mistaken for "server address". Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
This commit is contained in:
parent
b4ed58fd34
commit
90151e6e4d
|
@ -129,7 +129,7 @@ static struct nlm_host *nlm_lookup_host(int server,
|
||||||
continue;
|
continue;
|
||||||
if (host->h_server != server)
|
if (host->h_server != server)
|
||||||
continue;
|
continue;
|
||||||
if (!nlm_cmp_addr(&host->h_saddr, ssin))
|
if (!nlm_cmp_addr(nlm_srcaddr_in(host), ssin))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Move to head of hash chain. */
|
/* Move to head of hash chain. */
|
||||||
|
@ -168,7 +168,7 @@ static struct nlm_host *nlm_lookup_host(int server,
|
||||||
memcpy(nlm_addr(host), sin, sizeof(*sin));
|
memcpy(nlm_addr(host), sin, sizeof(*sin));
|
||||||
host->h_addrlen = sizeof(*sin);
|
host->h_addrlen = sizeof(*sin);
|
||||||
nlm_clear_port(nlm_addr(host));
|
nlm_clear_port(nlm_addr(host));
|
||||||
host->h_saddr = *ssin;
|
memcpy(nlm_srcaddr(host), ssin, sizeof(*ssin));
|
||||||
host->h_version = version;
|
host->h_version = version;
|
||||||
host->h_proto = proto;
|
host->h_proto = proto;
|
||||||
host->h_rpcclnt = NULL;
|
host->h_rpcclnt = NULL;
|
||||||
|
@ -192,8 +192,8 @@ static struct nlm_host *nlm_lookup_host(int server,
|
||||||
|
|
||||||
nlm_display_address((struct sockaddr *)&host->h_addr,
|
nlm_display_address((struct sockaddr *)&host->h_addr,
|
||||||
host->h_addrbuf, sizeof(host->h_addrbuf));
|
host->h_addrbuf, sizeof(host->h_addrbuf));
|
||||||
nlm_display_address((struct sockaddr *)&host->h_saddr,
|
nlm_display_address((struct sockaddr *)&host->h_srcaddr,
|
||||||
host->h_saddrbuf, sizeof(host->h_saddrbuf));
|
host->h_srcaddrbuf, sizeof(host->h_srcaddrbuf));
|
||||||
|
|
||||||
dprintk("lockd: nlm_lookup_host created host %s\n",
|
dprintk("lockd: nlm_lookup_host created host %s\n",
|
||||||
host->h_name);
|
host->h_name);
|
||||||
|
@ -267,7 +267,7 @@ nlm_bind_host(struct nlm_host *host)
|
||||||
struct rpc_clnt *clnt;
|
struct rpc_clnt *clnt;
|
||||||
|
|
||||||
dprintk("lockd: nlm_bind_host %s (%s), my addr=%s\n",
|
dprintk("lockd: nlm_bind_host %s (%s), my addr=%s\n",
|
||||||
host->h_name, host->h_addrbuf, host->h_saddrbuf);
|
host->h_name, host->h_addrbuf, host->h_srcaddrbuf);
|
||||||
|
|
||||||
/* Lock host handle */
|
/* Lock host handle */
|
||||||
mutex_lock(&host->h_mutex);
|
mutex_lock(&host->h_mutex);
|
||||||
|
@ -294,7 +294,7 @@ nlm_bind_host(struct nlm_host *host)
|
||||||
.protocol = host->h_proto,
|
.protocol = host->h_proto,
|
||||||
.address = nlm_addr(host),
|
.address = nlm_addr(host),
|
||||||
.addrsize = host->h_addrlen,
|
.addrsize = host->h_addrlen,
|
||||||
.saddress = (struct sockaddr *)&host->h_saddr,
|
.saddress = nlm_srcaddr(host),
|
||||||
.timeout = &timeparms,
|
.timeout = &timeparms,
|
||||||
.servername = host->h_name,
|
.servername = host->h_name,
|
||||||
.program = &nlm_program,
|
.program = &nlm_program,
|
||||||
|
|
|
@ -418,7 +418,7 @@ EXPORT_SYMBOL_GPL(nlmsvc_unlock_all_by_sb);
|
||||||
static int
|
static int
|
||||||
nlmsvc_match_ip(void *datap, struct nlm_host *host)
|
nlmsvc_match_ip(void *datap, struct nlm_host *host)
|
||||||
{
|
{
|
||||||
return nlm_cmp_addr(&host->h_saddr, datap);
|
return nlm_cmp_addr(nlm_srcaddr_in(host), datap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -40,7 +40,7 @@ struct nlm_host {
|
||||||
struct hlist_node h_hash; /* doubly linked list */
|
struct hlist_node h_hash; /* doubly linked list */
|
||||||
struct sockaddr_storage h_addr; /* peer address */
|
struct sockaddr_storage h_addr; /* peer address */
|
||||||
size_t h_addrlen;
|
size_t h_addrlen;
|
||||||
struct sockaddr_in h_saddr; /* our address (optional) */
|
struct sockaddr_storage h_srcaddr; /* our address (optional) */
|
||||||
struct rpc_clnt * h_rpcclnt; /* RPC client to talk to peer */
|
struct rpc_clnt * h_rpcclnt; /* RPC client to talk to peer */
|
||||||
char * h_name; /* remote hostname */
|
char * h_name; /* remote hostname */
|
||||||
u32 h_version; /* interface version */
|
u32 h_version; /* interface version */
|
||||||
|
@ -64,7 +64,7 @@ struct nlm_host {
|
||||||
struct nsm_handle * h_nsmhandle; /* NSM status handle */
|
struct nsm_handle * h_nsmhandle; /* NSM status handle */
|
||||||
|
|
||||||
char h_addrbuf[48], /* address eyecatchers */
|
char h_addrbuf[48], /* address eyecatchers */
|
||||||
h_saddrbuf[48];
|
h_srcaddrbuf[48];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nsm_handle {
|
struct nsm_handle {
|
||||||
|
@ -90,6 +90,16 @@ static inline struct sockaddr *nlm_addr(const struct nlm_host *host)
|
||||||
return (struct sockaddr *)&host->h_addr;
|
return (struct sockaddr *)&host->h_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct sockaddr_in *nlm_srcaddr_in(const struct nlm_host *host)
|
||||||
|
{
|
||||||
|
return (struct sockaddr_in *)&host->h_srcaddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline struct sockaddr *nlm_srcaddr(const struct nlm_host *host)
|
||||||
|
{
|
||||||
|
return (struct sockaddr *)&host->h_srcaddr;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Map an fl_owner_t into a unique 32-bit "pid"
|
* Map an fl_owner_t into a unique 32-bit "pid"
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue