lockd: Teach nlm_cmp_addr() to support AF_INET6 addresses
[safe/jmp/linux-2.6] / fs / lockd / host.c
index 008e402..dbf3fe6 100644 (file)
@@ -116,7 +116,7 @@ static struct nlm_host *nlm_lookup_host(int server,
         */
        chain = &nlm_hosts[hash];
        hlist_for_each_entry(host, pos, chain, h_hash) {
-               if (!nlm_cmp_addr(&host->h_addr, sin))
+               if (!nlm_cmp_addr(nlm_addr(host), (struct sockaddr *)sin))
                        continue;
 
                /* See if we have an NSM handle for this client */
@@ -129,7 +129,7 @@ static struct nlm_host *nlm_lookup_host(int server,
                        continue;
                if (host->h_server != server)
                        continue;
-               if (!nlm_cmp_addr(&host->h_saddr, ssin))
+               if (!nlm_cmp_addr(nlm_srcaddr(host), (struct sockaddr *)ssin))
                        continue;
 
                /* Move to head of hash chain. */
@@ -165,9 +165,10 @@ static struct nlm_host *nlm_lookup_host(int server,
                goto out;
        }
        host->h_name       = nsm->sm_name;
-       host->h_addr       = *sin;
-       nlm_clear_port((struct sockaddr *)&host->h_addr);
-       host->h_saddr      = *ssin;
+       memcpy(nlm_addr(host), sin, sizeof(*sin));
+       host->h_addrlen = sizeof(*sin);
+       nlm_clear_port(nlm_addr(host));
+       memcpy(nlm_srcaddr(host), ssin, sizeof(*ssin));
        host->h_version    = version;
        host->h_proto      = proto;
        host->h_rpcclnt    = NULL;
@@ -191,8 +192,8 @@ static struct nlm_host *nlm_lookup_host(int server,
 
        nlm_display_address((struct sockaddr *)&host->h_addr,
                                host->h_addrbuf, sizeof(host->h_addrbuf));
-       nlm_display_address((struct sockaddr *)&host->h_saddr,
-                               host->h_saddrbuf, sizeof(host->h_saddrbuf));
+       nlm_display_address((struct sockaddr *)&host->h_srcaddr,
+                               host->h_srcaddrbuf, sizeof(host->h_srcaddrbuf));
 
        dprintk("lockd: nlm_lookup_host created host %s\n",
                        host->h_name);
@@ -266,7 +267,7 @@ nlm_bind_host(struct nlm_host *host)
        struct rpc_clnt *clnt;
 
        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 */
        mutex_lock(&host->h_mutex);
@@ -291,9 +292,9 @@ nlm_bind_host(struct nlm_host *host)
                };
                struct rpc_create_args args = {
                        .protocol       = host->h_proto,
-                       .address        = (struct sockaddr *)&host->h_addr,
-                       .addrsize       = sizeof(host->h_addr),
-                       .saddress       = (struct sockaddr *)&host->h_saddr,
+                       .address        = nlm_addr(host),
+                       .addrsize       = host->h_addrlen,
+                       .saddress       = nlm_srcaddr(host),
                        .timeout        = &timeparms,
                        .servername     = host->h_name,
                        .program        = &nlm_program,
@@ -550,7 +551,7 @@ retry:
                        if (strlen(pos->sm_name) != hostname_len
                         || memcmp(pos->sm_name, hostname, hostname_len))
                                continue;
-               } else if (!nlm_cmp_addr(&pos->sm_addr, sin))
+               } else if (!nlm_cmp_addr(nsm_addr(pos), (struct sockaddr *)sin))
                        continue;
                atomic_inc(&pos->sm_count);
                kfree(nsm);
@@ -570,7 +571,8 @@ retry:
        if (nsm == NULL)
                return NULL;
 
-       nsm->sm_addr = *sin;
+       memcpy(nsm_addr(nsm), sin, sizeof(*sin));
+       nsm->sm_addrlen = sizeof(*sin);
        nsm->sm_name = (char *) (nsm + 1);
        memcpy(nsm->sm_name, hostname, hostname_len);
        nsm->sm_name[hostname_len] = '\0';