Next series of IPv6 patches for lockd
Subsystems (2)
cover Next series of IPv6 patches for lockd
Hi Bruce-
Here are ten more IPv6 patches for lockd, as requested. There are just a handful of remaining minor IPv6 patches to finish enabling IPv6 in lockd. These can likely wait until we have a complete IPv6 user space implementation.
Please consider these for 2.6.28.
---
Chuck Lever (10):
lockd: Use "unsigned short" for lockd_up() "proto" argument
lockd: IPv6 support for SM_MON / SM_UNMON
lockd: struct nlm_reboot should contain a full socket address
lockd: Remove unused fields in the nlm_reboot structure
lockd: Add helper to sanity check incoming NOTIFY requests
lockd: Adjust signature of nlm_host_rebooted to handle non-AF_INET
lockd: change nlmclnt_grant() to take a "struct sockaddr *"
lockd: Adjust nlmsvc_lookup_host() to accomodate AF_INET6 addresses
lockd: Adjust nlmclnt_lookup_host() signature to accomodate non-AF_INET
lockd: Support non-AF_INET addresses in nlm_lookup_host()
fs/lockd/clntlock.c | 10 +- fs/lockd/host.c | 189 ++++++++++++++++++++++++++++------------ fs/lockd/mon.c | 76 ++++++++++++---- fs/lockd/svc.c | 5 - fs/lockd/svc4proc.c | 18 +--- fs/lockd/svcproc.c | 18 +--- fs/lockd/xdr.c | 30 ++++++ fs/lockd/xdr4.c | 29 +++++- include/linux/lockd/bind.h | 2 include/linux/lockd/lockd.h | 63 ++++++++++++- include/linux/lockd/sm_inter.h | 2 include/linux/lockd/xdr.h | 5 - 12 files changed, 315 insertions(+), 132 deletions(-)
Signature · 1 line
Chuck Lever
A message that is not in the archive (sent off-list or not yet received): 20080917161337.4963.74674.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org
PATCH 1/10 lockd: Support non-AF_INET addresses in nlm_lookup_host()
Make nlm_lookup_host() agnostic to address families. As a clean up, convert nlm_lookup_host() to use a single structure instead of nearly a dozen separate arguments.
---
fs/lockd/host.c | 88 +++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 56 insertions(+), 32 deletions(-)
fs/lockd/host.c +56 -32
@@ -38,6 +38,21 @@ static struct nsm_handle *nsm_find(const struct sockaddr *sap,const size_t hostname_len, const int create); +#define NLM_SERVER (0) +#define NLM_CLIENT (1) + +struct nlm_lookup_host_info { +const int peer;/* search for server|client */ +const struct sockaddr *sap;/* address to search for */ +const size_t salen;/* it's length */ +const unsigned short protocol;/* transport to search for*/ +const u32 version;/* NLM version to search for */ +const char *hostname;/* remote's hostname */ +const size_t hostname_len;/* it's length */ +const struct sockaddr *src_sap;/* our address (optional) */ +const size_t src_len;/* it's length */ +}; +/* * Hash function must work well on big- and little-endian platforms */
@@ -121,23 +136,13 @@ static void nlm_display_address(const struct sockaddr *sap,/* * Common host lookup routine for server & client */ -static struct nlm_host *nlm_lookup_host (int server, -const struct sockaddr_in *sin, -int proto,u32 version, -const char *hostname, -unsigned int hostname_len, -const struct sockaddr_in *ssin) +static struct nlm_host *nlm_lookup_host (struct nlm_lookup_host_info *ni) {struct hlist_head *chain;struct hlist_node *pos;struct nlm_host *host;struct nsm_handle *nsm =NULL ; -dprintk ("lockd: nlm_lookup_host(proto=%d, vers=%u," -" my role is %s, hostname=%.*s)\n" , - proto, version, server ?"server" :"client" , - hostname_len, hostname ? hostname :"<none>" ); -mutex_lock (&nlm_host_mutex);if (time_after_eq (jiffies, next_gc))
@@ -150,22 +155,22 @@ static struct nlm_host *nlm_lookup_host(int server,* different NLM rpc_clients into one single nlm_host object. * This would allow us to have one nlm_host per address. */ - chain = &nlm_hosts[nlm_hash_address ((struct sockaddr *)sin)]; + chain = &nlm_hosts[nlm_hash_address (ni->sap)];hlist_for_each_entry (host, pos, chain, h_hash) { -if (!nlm_cmp_addr (nlm_addr (host), (struct sockaddr *)sin)) +if (!nlm_cmp_addr (nlm_addr (host), ni->sap))continue ;/* See if we have an NSM handle for this client */ if (!nsm) nsm = host->h_nsmhandle; -if (host->h_proto != proto) +if (host->h_proto != ni->protocol)continue ; -if (host->h_version != version) +if (host->h_version != ni->version)continue ; -if (host->h_server != server) +if (host->h_server != ni->peer)continue ; -if (!nlm_cmp_addr (nlm_srcaddr (host), (struct sockaddr *)ssin)) +if (!nlm_cmp_addr (nlm_srcaddr (host), ni->src_sap))continue ;/* Move to head of hash chain. */
@@ -186,8 +191,8 @@ static struct nlm_host *nlm_lookup_host(int server,atomic_inc (&nsm->sm_count); else { host =NULL ; - nsm =nsm_find ((struct sockaddr *)sin,sizeof (*sin), - hostname, hostname_len,1 ); + nsm =nsm_find (ni->sap, ni->salen, + ni->hostname, ni->hostname_len,1 );if (!nsm) {dprintk ("lockd: nlm_lookup_host failed; " "no nsm handle\n" );
@@ -202,12 +207,12 @@ static struct nlm_host *nlm_lookup_host(int server, goto out; } host->h_name = nsm->sm_name; -memcpy (nlm_addr (host), sin,sizeof (*sin)); - host->h_addrlen =sizeof (*sin); +memcpy (nlm_addr (host), ni->sap, ni->salen); + host->h_addrlen = ni->salen;nlm_clear_port (nlm_addr (host)); -memcpy (nlm_srcaddr (host), ssin,sizeof (*ssin)); - host->h_version = version; - host->h_proto = proto; +memcpy (nlm_srcaddr (host), ni->src_sap, ni->src_len); + host->h_version = ni->version; + host->h_proto = ni->protocol; host->h_rpcclnt =NULL ;mutex_init (&host->h_mutex); host->h_nextrebind = jiffies +NLM_HOST_REBIND ;
@@ -218,7 +223,7 @@ static struct nlm_host *nlm_lookup_host(int server, host->h_state =0 ;/* pseudo NSM state */ host->h_nsmstate =0 ;/* real NSM state */ host->h_nsmhandle = nsm; - host->h_server = server; + host->h_server = ni->peer;hlist_add_head (&host->h_hash, chain);INIT_LIST_HEAD (&host->h_lockowners);spin_lock_init (&host->h_lock);
@@ -270,12 +275,22 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr_in *sin,const char *hostname, unsigned int hostname_len) { - const struct sockaddr_in source = { - .sin_family =AF_UNSPEC , + const struct sockaddr source = { + .sa_family =AF_UNSPEC , + }; +struct nlm_lookup_host_info ni = { + .peer =NLM_SERVER , + .sap = (struct sockaddr *)sin, + .salen =sizeof (*sin), + .protocol = proto, + .version = version, + .hostname = hostname, + .hostname_len = hostname_len, + .src_sap = &source, + .src_len =sizeof (source), }; -return nlm_lookup_host (0 , sin, proto, version, - hostname, hostname_len, &source); +return nlm_lookup_host (&ni); }/*
@@ -289,10 +304,19 @@ nlmsvc_lookup_host(struct svc_rqst *rqstp, .sin_family = AF_INET, .sin_addr = rqstp->rq_daddr.addr, }; +struct nlm_lookup_host_info ni = { + .peer =NLM_CLIENT , + .sap =svc_addr (rqstp), + .salen = rqstp->rq_addrlen, + .protocol = rqstp->rq_prot, + .version = rqstp->rq_vers, + .hostname = hostname, + .hostname_len = hostname_len, + .src_sap = (struct sockaddr *)&source, + .src_len =sizeof (source), + }; -return nlm_lookup_host (1 ,svc_addr_in (rqstp), - rqstp->rq_prot, rqstp->rq_vers, - hostname, hostname_len, &source); +return nlm_lookup_host (&ni); }/*
A message that is not in the archive (sent off-list or not yet received): 20080917161720.4963.42788.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org
Re: [PATCH 01/10] lockd: Support non-AF_INET addresses in nlm_lookup_host()
Quoted 3 lines · Chuck Lever
Make
nlm_lookup_host()agnostic to address families. As a clean up, convertnlm_lookup_host()to use a single structure instead of nearly a dozen separate arguments.
Could you do those two steps as two separate patches, and resend?
--b.
Quoted 176 lines
Signed-off-by Chuck Lever <[email protected]>---
fs/lockd/host.c | 88 +++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 56 insertions(+), 32 deletions(-)fs/lockd/host.c +56
-32@@ -38,6 +38,21 @@ static struct nsm_handle *nsm_find(const struct sockaddr *sap,const size_t hostname_len, const int create); +#define NLM_SERVER (0) +#define NLM_CLIENT (1) + +struct nlm_lookup_host_info { +const int peer;/* search for server|client */ +const struct sockaddr *sap;/* address to search for */ +const size_t salen;/* it's length */ +const unsigned short protocol;/* transport to search for*/ +const u32 version;/* NLM version to search for */ +const char *hostname;/* remote's hostname */ +const size_t hostname_len;/* it's length */ +const struct sockaddr *src_sap;/* our address (optional) */ +const size_t src_len;/* it's length */ +}; +/* * Hash function must work well on big- and little-endian platforms */ @@ -121,23 +136,13 @@ static void nlm_display_address(const struct sockaddr *sap,/* * Common host lookup routine for server & client */ -static struct nlm_host *nlm_lookup_host (int server, -const struct sockaddr_in *sin, -int proto,u32 version, -const char *hostname, -unsigned int hostname_len, -const struct sockaddr_in *ssin) +static struct nlm_host *nlm_lookup_host (struct nlm_lookup_host_info *ni) {struct hlist_head *chain;struct hlist_node *pos;struct nlm_host *host;struct nsm_handle *nsm =NULL ; -dprintk ("lockd: nlm_lookup_host(proto=%d, vers=%u," -" my role is %s, hostname=%.*s)\n" , - proto, version, server ?"server" :"client" , - hostname_len, hostname ? hostname :"<none>" ); -mutex_lock (&nlm_host_mutex);if (time_after_eq (jiffies, next_gc))@@ -150,22 +155,22 @@ static struct nlm_host *nlm_lookup_host(int server,* different NLM rpc_clients into one single nlm_host object. * This would allow us to have one nlm_host per address. */ - chain = &nlm_hosts[nlm_hash_address ((struct sockaddr *)sin)]; + chain = &nlm_hosts[nlm_hash_address (ni->sap)];hlist_for_each_entry (host, pos, chain, h_hash) { -if (!nlm_cmp_addr (nlm_addr (host), (struct sockaddr *)sin)) +if (!nlm_cmp_addr (nlm_addr (host), ni->sap))continue ;/* See if we have an NSM handle for this client */ if (!nsm) nsm = host->h_nsmhandle; -if (host->h_proto != proto) +if (host->h_proto != ni->protocol)continue ; -if (host->h_version != version) +if (host->h_version != ni->version)continue ; -if (host->h_server != server) +if (host->h_server != ni->peer)continue ; -if (!nlm_cmp_addr (nlm_srcaddr (host), (struct sockaddr *)ssin)) +if (!nlm_cmp_addr (nlm_srcaddr (host), ni->src_sap))continue ;/* Move to head of hash chain. */ @@ -186,8 +191,8 @@ static struct nlm_host *nlm_lookup_host(int server,atomic_inc (&nsm->sm_count); else { host =NULL ; - nsm =nsm_find ((struct sockaddr *)sin,sizeof (*sin), - hostname, hostname_len,1 ); + nsm =nsm_find (ni->sap, ni->salen, + ni->hostname, ni->hostname_len,1 );if (!nsm) {dprintk ("lockd: nlm_lookup_host failed; " "no nsm handle\n" );@@ -202,12 +207,12 @@ static struct nlm_host *nlm_lookup_host(int server, goto out; } host->h_name = nsm->sm_name; -memcpy (nlm_addr (host), sin,sizeof (*sin)); - host->h_addrlen =sizeof (*sin); +memcpy (nlm_addr (host), ni->sap, ni->salen); + host->h_addrlen = ni->salen;nlm_clear_port (nlm_addr (host)); -memcpy (nlm_srcaddr (host), ssin,sizeof (*ssin)); - host->h_version = version; - host->h_proto = proto; +memcpy (nlm_srcaddr (host), ni->src_sap, ni->src_len); + host->h_version = ni->version; + host->h_proto = ni->protocol; host->h_rpcclnt =NULL ;mutex_init (&host->h_mutex); host->h_nextrebind = jiffies +NLM_HOST_REBIND ;@@ -218,7 +223,7 @@ static struct nlm_host *nlm_lookup_host(int server, host->h_state =0 ;/* pseudo NSM state */ host->h_nsmstate =0 ;/* real NSM state */ host->h_nsmhandle = nsm; - host->h_server = server; + host->h_server = ni->peer;hlist_add_head (&host->h_hash, chain);INIT_LIST_HEAD (&host->h_lockowners);spin_lock_init (&host->h_lock);@@ -270,12 +275,22 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr_in *sin,const char *hostname, unsigned int hostname_len) { - const struct sockaddr_in source = { - .sin_family =AF_UNSPEC , + const struct sockaddr source = { + .sa_family =AF_UNSPEC , + }; +struct nlm_lookup_host_info ni = { + .peer =NLM_SERVER , + .sap = (struct sockaddr *)sin, + .salen =sizeof (*sin), + .protocol = proto, + .version = version, + .hostname = hostname, + .hostname_len = hostname_len, + .src_sap = &source, + .src_len =sizeof (source), }; -return nlm_lookup_host (0 , sin, proto, version, - hostname, hostname_len, &source); +return nlm_lookup_host (&ni); }/* @@ -289,10 +304,19 @@ nlmsvc_lookup_host(struct svc_rqst *rqstp, .sin_family = AF_INET, .sin_addr = rqstp->rq_daddr.addr, }; +struct nlm_lookup_host_info ni = { + .peer =NLM_CLIENT , + .sap =svc_addr (rqstp), + .salen = rqstp->rq_addrlen, + .protocol = rqstp->rq_prot, + .version = rqstp->rq_vers, + .hostname = hostname, + .hostname_len = hostname_len, + .src_sap = (struct sockaddr *)&source, + .src_len =sizeof (source), + }; -return nlm_lookup_host (1 ,svc_addr_in (rqstp), - rqstp->rq_prot, rqstp->rq_vers, - hostname, hostname_len, &source); +return nlm_lookup_host (&ni); }/*
Re: [PATCH 01/10] lockd: Support non-AF_INET addresses in nlm_lookup_host()
Quoted 6 lines · J. Bruce Fields
Quoted 3 lines · Chuck Lever
Make
nlm_lookup_host()agnostic to address families. As a clean up, convertnlm_lookup_host()to use a single structure instead of nearly a dozen separate arguments.Could you do those two steps as two separate patches, and resend?
I tried that before, but it didn't make sense as two patches.
I can try it again.
Quoted 189 lines
--b.
Quoted 185 lines
Signed-off-by Chuck Lever <[email protected]>---
fs/lockd/host.c| 88 ++++++++++++++++++++++++++++++++++
+--------------------1 files changed, 56 insertions(+), 32 deletions(-)fs/lockd/host.c +15
-0@@ -38,6 +38,21 @@ static struct nsm_handle *nsm_find(const structsockaddr *sap, const size_t hostname_len, const int create); +#define NLM_SERVER (0) +#define NLM_CLIENT (1) + +struct nlm_lookup_host_info { +const int peer;/* search for server|client */ +const struct sockaddr *sap;/* address to search for */ +const size_t salen;/* it's length */ +const unsigned short protocol;/* transport to search for*/ +const u32 version;/* NLM version to search for */ +const char *hostname;/* remote's hostname */ +const size_t hostname_len;/* it's length */ +const struct sockaddr *src_sap;/* our address (optional) */ +const size_t src_len;/* it's length */ +}; +/* * Hash function must work well on big- and little-endian platforms */
fs/lockd/host.c +1
-11@@ -121,23 +136,13 @@ static void nlm_display_address(const structsockaddr *sap,/* * Common host lookup routine for server & client */ -static struct nlm_host *nlm_lookup_host(int server, - const struct sockaddr_in *sin, - int proto, u32 version, - const char *hostname, - unsigned int hostname_len, - const struct sockaddr_in *ssin) +static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni) { struct hlist_head *chain;struct hlist_node *pos;struct nlm_host *host;struct nsm_handle *nsm =NULL ; -dprintk ("lockd: nlm_lookup_host(proto=%d, vers=%u," -" my role is %s, hostname=%.*s)\n" , - proto, version, server ?"server" :"client" , - hostname_len, hostname ? hostname :"<none>" ); -mutex_lock (&nlm_host_mutex);if (
time_after_eq(jiffies, next_gc))fs/lockd/host.c +6
-6@@ -150,22 +155,22 @@ static struct nlm_host *nlm_lookup_host(intserver, * different NLM rpc_clients into one single nlm_host object. * This would allow us to have one nlm_host per address. */ - chain = &nlm_hosts[nlm_hash_address ((struct sockaddr *)sin)]; + chain = &nlm_hosts[nlm_hash_address (ni->sap)];hlist_for_each_entry (host, pos, chain, h_hash) { -if (!nlm_cmp_addr (nlm_addr (host), (struct sockaddr *)sin)) +if (!nlm_cmp_addr (nlm_addr (host), ni->sap))continue ;/* See if we have an NSM handle for this client */ if (!nsm) nsm = host->h_nsmhandle; -if (host->h_proto != proto) +if (host->h_proto != ni->protocol)continue ; -if (host->h_version != version) +if (host->h_version != ni->version)continue ; -if (host->h_server != server) +if (host->h_server != ni->peer)continue ; -if (!nlm_cmp_addr (nlm_srcaddr (host), (struct sockaddr *)ssin)) +if (!nlm_cmp_addr (nlm_srcaddr (host), ni->src_sap))continue ;/* Move to head of hash chain. */fs/lockd/host.c +2
-2@@ -186,8 +191,8 @@ static struct nlm_host *nlm_lookup_host(int server,atomic_inc (&nsm->sm_count); else { host =NULL ; - nsm =nsm_find ((struct sockaddr *)sin,sizeof (*sin), - hostname, hostname_len,1 ); + nsm =nsm_find (ni->sap, ni->salen, + ni->hostname, ni->hostname_len,1 );if (!nsm) { dprintk("lockd: nlm_lookup_host failed; ""no nsm handle\n");fs/lockd/host.c +5
-5@@ -202,12 +207,12 @@ static struct nlm_host *nlm_lookup_host(int server, goto out; } host->h_name = nsm->sm_name; -memcpy (nlm_addr (host), sin,sizeof (*sin)); - host->h_addrlen =sizeof (*sin); +memcpy (nlm_addr (host), ni->sap, ni->salen); + host->h_addrlen = ni->salen;nlm_clear_port (nlm_addr (host)); -memcpy (nlm_srcaddr (host), ssin,sizeof (*ssin)); - host->h_version = version; - host->h_proto = proto; +memcpy (nlm_srcaddr (host), ni->src_sap, ni->src_len); + host->h_version = ni->version; + host->h_proto = ni->protocol; host->h_rpcclnt =NULL ;mutex_init (&host->h_mutex);host->h_nextrebind = jiffies + NLM_HOST_REBIND;fs/lockd/host.c +1
-1@@ -218,7 +223,7 @@ static struct nlm_host *nlm_lookup_host(int server, host->h_state =0 ;/* pseudo NSM state */ host->h_nsmstate =0 ;/* real NSM state */ host->h_nsmhandle = nsm; - host->h_server = server; + host->h_server = ni->peer;hlist_add_head (&host->h_hash, chain);INIT_LIST_HEAD (&host->h_lockowners);spin_lock_init(&host->h_lock);fs/lockd/host.c +14
-4@@ -270,12 +275,22 @@ struct nlm_host *nlmclnt_lookup_host(conststruct sockaddr_in *sin, const char *hostname, unsigned int hostname_len) { - const struct sockaddr_in source = { - .sin_family =AF_UNSPEC , + const struct sockaddr source = { + .sa_family =AF_UNSPEC , + }; +struct nlm_lookup_host_info ni = { + .peer =NLM_SERVER , + .sap = (struct sockaddr *)sin, + .salen =sizeof (*sin), + .protocol = proto, + .version = version, + .hostname = hostname, + .hostname_len = hostname_len, + .src_sap = &source, + .src_len =sizeof (source), }; -return nlm_lookup_host (0 , sin, proto, version, - hostname, hostname_len, &source); +return nlm_lookup_host (&ni); }/*
fs/lockd/host.c +12
-3@@ -289,10 +304,19 @@ nlmsvc_lookup_host(struct svc_rqst *rqstp, .sin_family = AF_INET, .sin_addr = rqstp->rq_daddr.addr, }; +struct nlm_lookup_host_info ni = { + .peer =NLM_CLIENT , + .sap =svc_addr (rqstp), + .salen = rqstp->rq_addrlen, + .protocol = rqstp->rq_prot, + .version = rqstp->rq_vers, + .hostname = hostname, + .hostname_len = hostname_len, + .src_sap = (struct sockaddr *)&source, + .src_len =sizeof (source), + }; -return nlm_lookup_host (1 ,svc_addr_in (rqstp), - rqstp->rq_prot, rqstp->rq_vers, - hostname, hostname_len, &source); +return nlm_lookup_host (&ni); }/*
Signature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 01/10] lockd: Support non-AF_INET addresses in nlm_lookup_host()
Quoted 8 lines · Chuck Lever
Quoted 7 lines · J. Bruce Fields
Quoted 5 lines · Chuck Lever
Make
nlm_lookup_host()agnostic to address families. As a clean up, convertnlm_lookup_host()to use a single structure instead of nearly a dozen separate
arguments.
Quoted 5 lines
Quoted 1 line
Could you do those two steps as two separate patches, and resend?
I tried that before, but it didn't make sense as two patches.
I can try it again.
It should be very straightforward; I'd do the cleanup first, so:
1. Bundle up nlm_lookup_host arguments into a single structure.
2. Fix the address fields in that structure.
And it'd make change #2 trivial to verify.
--b.
Quoted 198 lines
Quoted 190 lines
--b.
Quoted 185 lines
Signed-off-by Chuck Lever <[email protected]>---
fs/lockd/host.c| 88 ++++++++++++++++++++++++++++++++++
+--------------------1 files changed, 56 insertions(+), 32 deletions(-)fs/lockd/host.c +15
-0@@ -38,6 +38,21 @@ static struct nsm_handle *nsm_find(const structsockaddr *sap, const size_t hostname_len, const int create); +#define NLM_SERVER (0) +#define NLM_CLIENT (1) + +struct nlm_lookup_host_info { +const int peer;/* search for server|client */ +const struct sockaddr *sap;/* address to search for */ +const size_t salen;/* it's length */ +const unsigned short protocol;/* transport to search for*/ +const u32 version;/* NLM version to search for */ +const char *hostname;/* remote's hostname */ +const size_t hostname_len;/* it's length */ +const struct sockaddr *src_sap;/* our address (optional) */ +const size_t src_len;/* it's length */ +}; +/* * Hash function must work well on big- and little-endian platforms */
fs/lockd/host.c +1
-11@@ -121,23 +136,13 @@ static void nlm_display_address(const structsockaddr *sap,/* * Common host lookup routine for server & client */ -static struct nlm_host *nlm_lookup_host(int server, - const struct sockaddr_in *sin, - int proto, u32 version, - const char *hostname, - unsigned int hostname_len, - const struct sockaddr_in *ssin) +static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni) { struct hlist_head *chain;struct hlist_node *pos;struct nlm_host *host;struct nsm_handle *nsm =NULL ; -dprintk ("lockd: nlm_lookup_host(proto=%d, vers=%u," -" my role is %s, hostname=%.*s)\n" , - proto, version, server ?"server" :"client" , - hostname_len, hostname ? hostname :"<none>" ); -mutex_lock (&nlm_host_mutex);if (
time_after_eq(jiffies, next_gc))fs/lockd/host.c +6
-6@@ -150,22 +155,22 @@ static struct nlm_host *nlm_lookup_host(intserver, * different NLM rpc_clients into one single nlm_host object. * This would allow us to have one nlm_host per address. */ - chain = &nlm_hosts[nlm_hash_address ((struct sockaddr *)sin)]; + chain = &nlm_hosts[nlm_hash_address (ni->sap)];hlist_for_each_entry (host, pos, chain, h_hash) { -if (!nlm_cmp_addr (nlm_addr (host), (struct sockaddr *)sin)) +if (!nlm_cmp_addr (nlm_addr (host), ni->sap))continue ;/* See if we have an NSM handle for this client */ if (!nsm) nsm = host->h_nsmhandle; -if (host->h_proto != proto) +if (host->h_proto != ni->protocol)continue ; -if (host->h_version != version) +if (host->h_version != ni->version)continue ; -if (host->h_server != server) +if (host->h_server != ni->peer)continue ; -if (!nlm_cmp_addr (nlm_srcaddr (host), (struct sockaddr *)ssin)) +if (!nlm_cmp_addr (nlm_srcaddr (host), ni->src_sap))continue ;/* Move to head of hash chain. */fs/lockd/host.c +2
-2@@ -186,8 +191,8 @@ static struct nlm_host *nlm_lookup_host(int server,atomic_inc (&nsm->sm_count); else { host =NULL ; - nsm =nsm_find ((struct sockaddr *)sin,sizeof (*sin), - hostname, hostname_len,1 ); + nsm =nsm_find (ni->sap, ni->salen, + ni->hostname, ni->hostname_len,1 );if (!nsm) { dprintk("lockd: nlm_lookup_host failed; ""no nsm handle\n");fs/lockd/host.c +5
-5@@ -202,12 +207,12 @@ static struct nlm_host *nlm_lookup_host(int server, goto out; } host->h_name = nsm->sm_name; -memcpy (nlm_addr (host), sin,sizeof (*sin)); - host->h_addrlen =sizeof (*sin); +memcpy (nlm_addr (host), ni->sap, ni->salen); + host->h_addrlen = ni->salen;nlm_clear_port (nlm_addr (host)); -memcpy (nlm_srcaddr (host), ssin,sizeof (*ssin)); - host->h_version = version; - host->h_proto = proto; +memcpy (nlm_srcaddr (host), ni->src_sap, ni->src_len); + host->h_version = ni->version; + host->h_proto = ni->protocol; host->h_rpcclnt =NULL ;mutex_init (&host->h_mutex);host->h_nextrebind = jiffies + NLM_HOST_REBIND;fs/lockd/host.c +1
-1@@ -218,7 +223,7 @@ static struct nlm_host *nlm_lookup_host(int server, host->h_state =0 ;/* pseudo NSM state */ host->h_nsmstate =0 ;/* real NSM state */ host->h_nsmhandle = nsm; - host->h_server = server; + host->h_server = ni->peer;hlist_add_head (&host->h_hash, chain);INIT_LIST_HEAD (&host->h_lockowners);spin_lock_init(&host->h_lock);fs/lockd/host.c +14
-4@@ -270,12 +275,22 @@ struct nlm_host *nlmclnt_lookup_host(conststruct sockaddr_in *sin, const char *hostname, unsigned int hostname_len) { - const struct sockaddr_in source = { - .sin_family =AF_UNSPEC , + const struct sockaddr source = { + .sa_family =AF_UNSPEC , + }; +struct nlm_lookup_host_info ni = { + .peer =NLM_SERVER , + .sap = (struct sockaddr *)sin, + .salen =sizeof (*sin), + .protocol = proto, + .version = version, + .hostname = hostname, + .hostname_len = hostname_len, + .src_sap = &source, + .src_len =sizeof (source), }; -return nlm_lookup_host (0 , sin, proto, version, - hostname, hostname_len, &source); +return nlm_lookup_host (&ni); }/*
fs/lockd/host.c +12
-3@@ -289,10 +304,19 @@ nlmsvc_lookup_host(struct svc_rqst *rqstp, .sin_family = AF_INET, .sin_addr = rqstp->rq_daddr.addr, }; +struct nlm_lookup_host_info ni = { + .peer =NLM_CLIENT , + .sap =svc_addr (rqstp), + .salen = rqstp->rq_addrlen, + .protocol = rqstp->rq_prot, + .version = rqstp->rq_vers, + .hostname = hostname, + .hostname_len = hostname_len, + .src_sap = (struct sockaddr *)&source, + .src_len =sizeof (source), + }; -return nlm_lookup_host (1 ,svc_addr_in (rqstp), - rqstp->rq_prot, rqstp->rq_vers, - hostname, hostname_len, &source); +return nlm_lookup_host (&ni); }/* Signature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
PATCH 2/10 lockd: Adjust nlmclnt_lookup_host() signature to accomodate non-AF_INET
In reply to a message not in the archivePass a struct sockaddr * and a length to nlmclnt_lookup_host() to accomodate non-AF_INET family addresses.
---
fs/lockd/clntlock.c | 5 ++--- fs/lockd/host.c | 34 ++++++++++++++++++++++++---------- include/linux/lockd/lockd.h | 9 +++++---- 3 files changed, 31 insertions(+), 17 deletions(-)
fs/lockd/clntlock.c +2 -3
@@ -58,10 +58,9 @@ struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init)if (status <0 )return ERR_PTR (status); - host =nlmclnt_lookup_host ((struct sockaddr_in *)nlm_init->address, + host =nlmclnt_lookup_host (nlm_init->address, nlm_init->addrlen, nlm_init->protocol, nlm_version, - nlm_init->hostname, -strlen (nlm_init->hostname)); + nlm_init->hostname);if (host ==NULL ) {lockd_down ();return ERR_PTR (-ENOLCK );
fs/lockd/host.c +24 -10
@@ -267,29 +267,43 @@ nlm_destroy_host(struct nlm_host *host)kfree (host); } -/* -* Find an NLM server handle in the cache. If there is none, create it. +/** +* nlmclnt_lookup_host - Find an NLM host handle matching a remote server +* @sap: network address of server +* @salen: length of server address +* @protocol: transport protocol to use +* @version: NLM protocol version +* @hostname: '\0'-terminated hostname of server +* +* Returns an nlm_host structure that matches the passed-in +* [server address, transport protocol, NLM version, server hostname]. +* If one doesn't already exist in the host cache, a new handle is +* created and returned. */ -struct nlm_host *nlmclnt_lookup_host (const struct sockaddr_in *sin, -int proto,u32 version, -const char *hostname, -unsigned int hostname_len) +struct nlm_host *nlmclnt_lookup_host (const struct sockaddr *sap, +const size_t salen, +const unsigned short protocol, +const u32 version,const char *hostname) {const struct sockaddr source = { .sa_family =AF_UNSPEC , };struct nlm_lookup_host_info ni = { .peer =NLM_SERVER , - .sap = (struct sockaddr *)sin, - .salen =sizeof (*sin), - .protocol = proto, + .sap = sap, + .salen = salen, + .protocol = protocol, .version = version, .hostname = hostname, - .hostname_len = hostname_len, + .hostname_len =strlen (hostname), .src_sap = &source, .src_len =sizeof (source), }; +dprintk ("lockd: nlmclnt_lookup_host(host='%s', vers=%u, proto=%s)\n" , + (hostname ? hostname :"<none>" ), version, + (protocol ==IPPROTO_UDP ?"udp" :"tcp" )); +return nlm_lookup_host (&ni); }
include/linux/lockd/lockd.h +5 -4
@@ -215,10 +215,11 @@ void nlmclnt_next_cookie(struct nlm_cookie *);/* * Host cache */ -struct nlm_host *nlmclnt_lookup_host (const struct sockaddr_in *sin, -int proto,u32 version, -const char *hostname, -unsigned int hostname_len); +struct nlm_host *nlmclnt_lookup_host (const struct sockaddr *sap, +const size_t salen, +const unsigned short protocol, +const u32 version, +const char *hostname);struct nlm_host *nlmsvc_lookup_host (struct svc_rqst *,const char *,unsigned int );struct rpc_clnt *nlm_bind_host (struct nlm_host *);
A message that is not in the archive (sent off-list or not yet received): 20080917161728.4963.48337.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org
Re: [PATCH 02/10] lockd: Adjust nlmclnt_lookup_host() signature to accomodate non-AF_INET
Quoted 2 lines · Chuck Lever
Pass a struct sockaddr * and a length to
nlmclnt_lookup_host()to accomodate non-AF_INET family addresses.
I'd prefer separate patches here too, though since the two changes (null-terminated hostname and sockaddr) are a bit easier to separate visually, it doesn't bother me as much here....
--b.
Quoted 105 lines
Signed-off-by Chuck Lever <[email protected]>---
fs/lockd/clntlock.c | 5 ++--- fs/lockd/host.c | 34 ++++++++++++++++++++++++---------- include/linux/lockd/lockd.h | 9 +++++---- 3 files changed, 31 insertions(+), 17 deletions(-)fs/lockd/clntlock.c +2
-3@@ -58,10 +58,9 @@ struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init)if (status <0 )return ERR_PTR (status); - host =nlmclnt_lookup_host ((struct sockaddr_in *)nlm_init->address, + host =nlmclnt_lookup_host (nlm_init->address, nlm_init->addrlen, nlm_init->protocol, nlm_version, - nlm_init->hostname, -strlen (nlm_init->hostname)); + nlm_init->hostname);if (host ==NULL ) {lockd_down ();return ERR_PTR (-ENOLCK );fs/lockd/host.c +24
-10@@ -267,29 +267,43 @@ nlm_destroy_host(struct nlm_host *host)kfree (host); } -/* -* Find an NLM server handle in the cache. If there is none, create it. +/** +* nlmclnt_lookup_host - Find an NLM host handle matching a remote server +* @sap: network address of server +* @salen: length of server address +* @protocol: transport protocol to use +* @version: NLM protocol version +* @hostname: '\0'-terminated hostname of server +* +* Returns an nlm_host structure that matches the passed-in +* [server address, transport protocol, NLM version, server hostname]. +* If one doesn't already exist in the host cache, a new handle is +* created and returned. */ -struct nlm_host *nlmclnt_lookup_host (const struct sockaddr_in *sin, -int proto,u32 version, -const char *hostname, -unsigned int hostname_len) +struct nlm_host *nlmclnt_lookup_host (const struct sockaddr *sap, +const size_t salen, +const unsigned short protocol, +const u32 version,const char *hostname) {const struct sockaddr source = { .sa_family =AF_UNSPEC , };struct nlm_lookup_host_info ni = { .peer =NLM_SERVER , - .sap = (struct sockaddr *)sin, - .salen =sizeof (*sin), - .protocol = proto, + .sap = sap, + .salen = salen, + .protocol = protocol, .version = version, .hostname = hostname, - .hostname_len = hostname_len, + .hostname_len =strlen (hostname), .src_sap = &source, .src_len =sizeof (source), }; +dprintk ("lockd: nlmclnt_lookup_host(host='%s', vers=%u, proto=%s)\n" , + (hostname ? hostname :"<none>" ), version, + (protocol ==IPPROTO_UDP ?"udp" :"tcp" )); +return nlm_lookup_host (&ni); }include/linux/lockd/lockd.h +5
-4@@ -215,10 +215,11 @@ void nlmclnt_next_cookie(struct nlm_cookie *);/* * Host cache */ -struct nlm_host *nlmclnt_lookup_host (const struct sockaddr_in *sin, -int proto,u32 version, -const char *hostname, -unsigned int hostname_len); +struct nlm_host *nlmclnt_lookup_host (const struct sockaddr *sap, +const size_t salen, +const unsigned short protocol, +const u32 version, +const char *hostname);struct nlm_host *nlmsvc_lookup_host (struct svc_rqst *,const char *,unsigned int );struct rpc_clnt *nlm_bind_host (struct nlm_host *);
Re: [PATCH 02/10] lockd: Adjust nlmclnt_lookup_host() signature to accomodate non-AF_INET
Quoted 7 lines · J. Bruce Fields
Quoted 2 lines · Chuck Lever
Pass a struct sockaddr * and a length to
nlmclnt_lookup_host()to accomodate non-AF_INET family addresses.I'd prefer separate patches here too, though since the two changes (null-terminated hostname and sockaddr) are a bit easier to separate visually, it doesn't bother me as much here....
I'm not sure I understand what you want here. The "NUL-terminated" stuff is merely documenting what is already the case, and eliminating an unneeded argument. Maybe I should just add a note about it to the patch description?
Quoted 119 lines
--b.
Quoted 109 lines
Signed-off-by Chuck Lever <[email protected]>---
fs/lockd/clntlock.c | 5 ++--- fs/lockd/host.c | 34 ++++++++++++++++++++++++---------- include/linux/lockd/lockd.h | 9 +++++---- 3 files changed, 31 insertions(+), 17 deletions(-)fs/lockd/clntlock.c +2
-3@@ -58,10 +58,9 @@ struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init)if (status <0 )return ERR_PTR (status); - host =nlmclnt_lookup_host ((struct sockaddr_in *)nlm_init->address, + host =nlmclnt_lookup_host (nlm_init->address, nlm_init->addrlen, nlm_init->protocol, nlm_version, - nlm_init->hostname, -strlen (nlm_init->hostname)); + nlm_init->hostname);if (host ==NULL ) {lockd_down ();return ERR_PTR(-ENOLCK);fs/lockd/host.c +0
-2@@ -267,29 +267,43 @@ nlm_destroy_host(struct nlm_host *host)kfree (host); } -/* -* Find an NLM server handle in the cache. If there is none, create it.
+/**
+ *nlmclnt_lookup_host- Find an NLM host handle matching a remote server
+ * @sap: network address of server
+ * @salen: length of server address
+ * @protocol: transport protocol to use
+ * @version: NLM protocol version
+ * @hostname: '\0'-terminated hostname of server
+ *
+ * Returns annlm_hoststructure that matches the passed-in
+ * [server address, transport protocol, NLM version, server hostname].
+ * If one doesn't already exist in the host cache, a new handle is
+ * created and returned.
*/fs/lockd/host.c +4
-4-struct nlm_host *nlmclnt_lookup_host (const struct sockaddr_in *sin, -int proto,u32 version, -const char *hostname, -unsigned int hostname_len) +struct nlm_host *nlmclnt_lookup_host (const struct sockaddr *sap, +const size_t salen, +const unsigned short protocol, +const u32 version,const char *hostname){ const struct sockaddr source = { .sa_family = AF_UNSPEC, }; struct nlm_lookup_host_info ni = { .peer = NLM_SERVER,fs/lockd/host.c +3
-3- .sap = (struct sockaddr *)sin, - .salen = sizeof(*sin), - .protocol = proto, + .sap = sap, + .salen = salen, + .protocol = protocol,.version = version,
.hostname = hostname,fs/lockd/host.c +1
-1- .hostname_len = hostname_len, + .hostname_len = strlen(hostname),.src_sap = &source, .src_len = sizeof(source), };fs/lockd/host.c +1
-0+ dprintk("lockd: nlmclnt_lookup_host(host='%s', vers=%u, proto=%s)\n",
fs/lockd/host.c +3
-0+ (hostname ? hostname :"<none>" ), version, + (protocol == IPPROTO_UDP ? "udp" : "tcp")); +return nlm_lookup_host(&ni); }include/linux/lockd/lockd.h +5
-4@@ -215,10 +215,11 @@ void nlmclnt_next_cookie(struct nlm_cookie *);/* * Host cache */ -struct nlm_host *nlmclnt_lookup_host (const struct sockaddr_in *sin, -int proto,u32 version, -const char *hostname, -unsigned int hostname_len); +struct nlm_host *nlmclnt_lookup_host (const struct sockaddr *sap, +const size_t salen, +const unsigned short protocol, +const u32 version, +const char *hostname);struct nlm_host *nlmsvc_lookup_host (struct svc_rqst *,const char *,unsigned int );Quoted 2 lines
struct
rpc_clnt*nlm_bind_host(struct nlm_host *);--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 02/10] lockd: Adjust nlmclnt_lookup_host() signature to accomodate non-AF_INET
Quoted 5 lines · Chuck Lever
Quoted 4 lines · J. Bruce Fields
Quoted 2 lines · Chuck Lever
Pass a struct sockaddr * and a length to
nlmclnt_lookup_host()to accomodate non-AF_INET family addresses.
Quoted 7 lines
Quoted 3 lines
I'd prefer separate patches here too, though since the two changes (null-terminated hostname and sockaddr) are a bit easier to separate visually, it doesn't bother me as much here....
I'm not sure I understand what you want here. The "NUL-terminated" stuff is merely documenting what is already the case, and eliminating an unneeded argument.
Yes, I understand, and I'm fine with that--it's just that I'd personally normally stick those two in a separate patch.
It's not a big deal.
--b.
Quoted 133 lines
Maybe I should just add a note about it to the patch description?
Quoted 121 lines
--b.
Quoted 110 lines
Signed-off-by Chuck Lever <[email protected]>---
fs/lockd/clntlock.c | 5 ++--- fs/lockd/host.c | 34 ++++++++++++++++++++++++---------- include/linux/lockd/lockd.h | 9 +++++---- 3 files changed, 31 insertions(+), 17 deletions(-)fs/lockd/clntlock.c +2
-3@@ -58,10 +58,9 @@ struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init)if (status <0 )return ERR_PTR (status); - host =nlmclnt_lookup_host ((struct sockaddr_in *)nlm_init->address, + host =nlmclnt_lookup_host (nlm_init->address, nlm_init->addrlen, nlm_init->protocol, nlm_version, - nlm_init->hostname, -strlen (nlm_init->hostname)); + nlm_init->hostname);if (host ==NULL ) {lockd_down ();return ERR_PTR(-ENOLCK);fs/lockd/host.c +0
-2@@ -267,29 +267,43 @@ nlm_destroy_host(struct nlm_host *host)kfree (host); } -/* -* Find an NLM server handle in the cache. If there is none, create it.
+/**
+ *nlmclnt_lookup_host- Find an NLM host handle matching a remote server
+ * @sap: network address of server
+ * @salen: length of server address
+ * @protocol: transport protocol to use
+ * @version: NLM protocol version
+ * @hostname: '\0'-terminated hostname of server
+ *
+ * Returns annlm_hoststructure that matches the passed-in
+ * [server address, transport protocol, NLM version, server hostname].
+ * If one doesn't already exist in the host cache, a new handle is
+ * created and returned.
*/fs/lockd/host.c +4
-4-struct nlm_host *nlmclnt_lookup_host (const struct sockaddr_in *sin, -int proto,u32 version, -const char *hostname, -unsigned int hostname_len) +struct nlm_host *nlmclnt_lookup_host (const struct sockaddr *sap, +const size_t salen, +const unsigned short protocol, +const u32 version,const char *hostname){ const struct sockaddr source = { .sa_family = AF_UNSPEC, }; struct nlm_lookup_host_info ni = { .peer = NLM_SERVER,fs/lockd/host.c +3
-3- .sap = (struct sockaddr *)sin, - .salen = sizeof(*sin), - .protocol = proto, + .sap = sap, + .salen = salen, + .protocol = protocol,.version = version,
.hostname = hostname,fs/lockd/host.c +1
-1- .hostname_len = hostname_len, + .hostname_len = strlen(hostname),.src_sap = &source, .src_len = sizeof(source), };fs/lockd/host.c +1
-0+ dprintk("lockd: nlmclnt_lookup_host(host='%s', vers=%u, proto=%s)\n",
fs/lockd/host.c +3
-0+ (hostname ? hostname :"<none>" ), version, + (protocol == IPPROTO_UDP ? "udp" : "tcp")); +return nlm_lookup_host(&ni); }include/linux/lockd/ renamed from include/linux/lockd/lockd.h +0
-0
lockd.h
index ec8af11..693d57b 100644include/linux/lockd/lockd.h +5
-4@@ -215,10 +215,11 @@ void nlmclnt_next_cookie(struct nlm_cookie *);/* * Host cache */ -struct nlm_host *nlmclnt_lookup_host (const struct sockaddr_in *sin, -int proto,u32 version, -const char *hostname, -unsigned int hostname_len); +struct nlm_host *nlmclnt_lookup_host (const struct sockaddr *sap, +const size_t salen, +const unsigned short protocol, +const u32 version, +const char *hostname);struct nlm_host *nlmsvc_lookup_host (struct svc_rqst *,const char *,unsigned int );Quoted 2 lines
struct
rpc_clnt*nlm_bind_host(struct nlm_host *);--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlSignature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
PATCH 3/10 lockd: Adjust nlmsvc_lookup_host() to accomodate AF_INET6 addresses
In reply to a message not in the archiveFix up nlmsvc_lookup_host() to pass AF_INET6 source addresses to nlm_lookup_host().
To keep stack usage down, we use address-family-specific sockaddr_in and sockaddr_in6 structures instead of sockaddr_storage where appropriate. The server-side supports only AF_INET and AF_INET6.
---
fs/lockd/host.c | 51 +++++++++++++++++++++++++++++++++++-------- include/linux/lockd/lockd.h | 5 +++- 2 files changed, 44 insertions(+), 12 deletions(-)
fs/lockd/host.c +41 -10
@@ -307,29 +307,60 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,return nlm_lookup_host (&ni); } -/* -* Find an NLM client handle in the cache. If there is none, create it. +/** +* nlmsvc_lookup_host - Find an NLM host handle matching a remote client +* @rqstp: incoming NLM request +* @hostname: name of client host +* @hostname_len: length of client hostname +* +* Returns an nlm_host structure that matches the [client address, +* transport protocol, NLM version, client hostname] of the passed-in +* NLM request. If one doesn't already exist in the host cache, a +* new handle is created and returned. +* +* Manufacture a specific source address in case the local system +* services clients from multiple IP addresses. The family of the +* address in rq_daddr is guaranteed to be the same as the family of +* the address in rq_addr, so it's safe to use the same family and +* length for our manufactured source address. */ -struct nlm_host * -nlmsvc_lookup_host (struct svc_rqst *rqstp, -const char *hostname,unsigned int hostname_len) +struct nlm_host *nlmsvc_lookup_host (const struct svc_rqst *rqstp, +const char *hostname, +const size_t hostname_len) { -const struct sockaddr_in source = { - .sin_family =AF_INET , - .sin_addr = rqstp->rq_daddr.addr, +const struct sockaddr *sap =svc_addr (rqstp); +struct sockaddr_storage source = { + .ss_family = sap->sa_family, }; +struct sockaddr_in *sin = (struct sockaddr_in *)&source; +struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&source;struct nlm_lookup_host_info ni = { .peer =NLM_CLIENT , - .sap =svc_addr (rqstp), + .sap = sap, .salen = rqstp->rq_addrlen, .protocol = rqstp->rq_prot, .version = rqstp->rq_vers, .hostname = hostname, .hostname_len = hostname_len, .src_sap = (struct sockaddr *)&source, - .src_len =sizeof (source), + .src_len = rqstp->rq_addrlen, }; +dprintk ("lockd: %s(host='%.*s', vers=%u, proto=%s)\n" , __func__, + (int )hostname_len, hostname, rqstp->rq_vers, + (rqstp->rq_prot ==IPPROTO_UDP ?"udp" :"tcp" )); + +switch (sap->sa_family) { +case AF_INET : + sin->sin_addr.s_addr = rqstp->rq_daddr.addr.s_addr; +break ; +case AF_INET6 : +ipv6_addr_copy (&sin6->sin6_addr, &rqstp->rq_daddr.addr6); +break ; +default : +return NULL ; + } +return nlm_lookup_host (&ni); }
include/linux/lockd/lockd.h +3 -2
@@ -220,8 +220,9 @@ struct nlm_host *nlmclnt_lookup_host(const struct sockaddr *sap,const unsigned short protocol, const u32 version, const char *hostname); -struct nlm_host *nlmsvc_lookup_host (struct svc_rqst *,const char *, -unsigned int ); +struct nlm_host *nlmsvc_lookup_host (const struct svc_rqst *rqstp, +const char *hostname, +const size_t hostname_len);struct rpc_clnt *nlm_bind_host (struct nlm_host *);void nlm_rebind_host (struct nlm_host *);struct nlm_host *nlm_get_host (struct nlm_host *);
A message that is not in the archive (sent off-list or not yet received): 20080917161735.4963.86248.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org
Re: [PATCH 03/10] lockd: Adjust nlmsvc_lookup_host() to accomodate AF_INET6 addresses
Quoted 6 lines · Chuck Lever
Fix up
nlmsvc_lookup_host()to passAF_INET6source addresses tonlm_lookup_host().To keep stack usage down, we use address-family-specific
sockaddr_inandsockaddr_in6structures instead ofsockaddr_storagewhere appropriate. The server-side supports onlyAF_INETandAF_INET6.
Looks like there still is one sockaddr_storage on the stack. That's 128 bytes. Sounds doable, OK.
Quoted 5 lines
+/**
+ *nlmsvc_lookup_host- Find an NLM host handle matching a remote client
+ * @rqstp: incoming NLM request
+ * @hostname: name of client host
+ * @hostname_len: length of client hostname
Quoted 8 lines
+ *
+ * Returns annlm_hoststructure that matches the [client address,
+ * transport protocol, NLM version, client hostname] of the passed-in
+ * NLM request. If one doesn't already exist in the host cache, a
+ * new handle is created and returned.
+ *
+ * Manufacture a specific source address in case the local system
+ * services clients from multiple IP addresses.
"Manufacture" makes it sound like we're faking one up somehow, but we're actually just copying it from the svc_rqst, right? Maybe make that "store the specific source address..." instead?
--b.
Re: [PATCH 03/10] lockd: Adjust nlmsvc_lookup_host() to accomodate AF_INET6 addresses
Quoted 27 lines · J. Bruce Fields
Quoted 6 lines · Chuck Lever
Fix up
nlmsvc_lookup_host()to passAF_INET6source addresses tonlm_lookup_host().To keep stack usage down, we use address-family-specific
sockaddr_inandsockaddr_in6structures instead ofsockaddr_storagewhere appropriate. The server-side supports onlyAF_INETandAF_INET6.Looks like there still is one
sockaddr_storageon the stack. That's 128 bytes. Sounds doable, OK.Quoted 7 lines
+/**
+ *nlmsvc_lookup_host- Find an NLM host handle matching a remote client
+ * @rqstp: incoming NLM request
+ * @hostname: name of client host
+ * @hostname_len: length of client hostname
+ *Quoted 8 lines
+ * Returns an
nlm_hoststructure that matches the [client address,
+ * transport protocol, NLM version, client hostname] of the passed- in
+ * NLM request. If one doesn't already exist in the host cache, a
+ * new handle is created and returned.
+ *
+ * Manufacture a specific source address in case the local system
+ * services clients from multiple IP addresses.
Quoted 3 lines
"Manufacture" makes it sound like we're faking one up somehow, but we're actually just copying it from the
svc_rqst, right? Maybe make that "store the specific source address..." instead?
We really are faking it up, in a sense. The svc_rqst does not store an address family for our source address, so we use an assumption (that our source address will always have the same family as the sender's address) to construct a full sockaddr.
How about "Construct a sockaddr for a specific source address, in case the local system has multiple network addresses."
Signature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 03/10] lockd: Adjust nlmsvc_lookup_host() to accomodate AF_INET6 addresses
Quoted 34 lines · Chuck Lever
Quoted 28 lines · J. Bruce Fields
Quoted 6 lines · Chuck Lever
Fix up
nlmsvc_lookup_host()to passAF_INET6source addresses tonlm_lookup_host().To keep stack usage down, we use address-family-specific
sockaddr_inandsockaddr_in6structures instead ofsockaddr_storagewhere appropriate. The server-side supports onlyAF_INETandAF_INET6.Looks like there still is one
sockaddr_storageon the stack. That's 128
bytes. Sounds doable, OK.Quoted 7 lines
+/**
+ *nlmsvc_lookup_host- Find an NLM host handle matching a remote client
+ * @rqstp: incoming NLM request
+ * @hostname: name of client host
+ * @hostname_len: length of client hostname
+ *Quoted 8 lines
+ * Returns an
nlm_hoststructure that matches the [client address,
+ * transport protocol, NLM version, client hostname] of the passed- in
+ * NLM request. If one doesn't already exist in the host cache, a
+ * new handle is created and returned.
+ *
+ * Manufacture a specific source address in case the local system
+ * services clients from multiple IP addresses.Quoted 4 lines
"Manufacture" makes it sound like we're faking one up somehow, but we're
actually just copying it from thesvc_rqst, right? Maybe make that "store the specific source address..." instead?
Quoted 4 lines
We really are faking it up, in a sense. The
svc_rqstdoes not store an address family for our source address, so we use an assumption (that our source address will always have the same family as the sender's address) to construct a full sockaddr.
OK, got it.
Quoted 3 lines
How about "Construct a sockaddr for a specific source address, in case the
local system has multiple network addresses."
The existing comment's fine.
--b.
PATCH 4/10 lockd: change nlmclnt_grant() to take a "struct sockaddr *"
In reply to a message not in the archiveAdjust the signature and callers of nlmclnt_grant() to pass a "struct sockaddr *" instead of a "struct sockaddr_in *" in order to support IPv6 addresses.
---
fs/lockd/clntlock.c | 5 ++--- fs/lockd/svc4proc.c | 2 +- fs/lockd/svcproc.c | 2 +- include/linux/lockd/lockd.h | 3 ++- 4 files changed, 6 insertions(+), 6 deletions(-)
fs/lockd/clntlock.c +2 -3
@@ -141,7 +141,7 @@ int nlmclnt_block(struct nlm_wait *block, struct nlm_rqst *req, long timeout)/* * The server lockd has called us back to tell us the lock was granted */ -__be32 nlmclnt_grant (const struct sockaddr_in *addr,const struct nlm_lock *lock) +__be32 nlmclnt_grant (const struct sockaddr *addr,const struct nlm_lock *lock) {const struct file_lock *fl = &lock->fl;const struct nfs_fh *fh = &lock->fh;
@@ -165,8 +165,7 @@ __be32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *lock*/ if (fl_blocked->fl_u.nfs_fl.owner->pid != lock->svid)continue ; -if (!nlm_cmp_addr (nlm_addr (block->b_host), - (struct sockaddr *)addr)) +if (!nlm_cmp_addr (nlm_addr (block->b_host), addr))continue ;if (nfs_compare_fh (NFS_FH (fl_blocked->fl_file->f_path.dentry->d_inode) ,fh) !=0 )continue ;
fs/lockd/svc4proc.c +1 -1
@@ -231,7 +231,7 @@ nlm4svc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp, resp->cookie = argp->cookie;dprintk ("lockd: GRANTED called\n" ); - resp->status =nlmclnt_grant (svc_addr_in (rqstp), &argp->lock); + resp->status =nlmclnt_grant (svc_addr (rqstp), &argp->lock);dprintk ("lockd: GRANTED status %d\n" ,ntohl (resp->status));return rpc_success; }
fs/lockd/svcproc.c +1 -1
@@ -261,7 +261,7 @@ nlmsvc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp, resp->cookie = argp->cookie;dprintk ("lockd: GRANTED called\n" ); - resp->status =nlmclnt_grant (svc_addr_in (rqstp), &argp->lock); + resp->status =nlmclnt_grant (svc_addr (rqstp), &argp->lock);dprintk ("lockd: GRANTED status %d\n" ,ntohl (resp->status));return rpc_success; }
include/linux/lockd/lockd.h +2 -1
@@ -207,7 +207,8 @@ int nlm_async_reply(struct nlm_rqst *, u32, const struct rpc_call_ops *);struct nlm_wait *nlmclnt_prepare_block (struct nlm_host *host,struct file_lock *fl);void nlmclnt_finish_block (struct nlm_wait *block);int nlmclnt_block (struct nlm_wait *block,struct nlm_rqst *req,long timeout); -__be32 nlmclnt_grant (const struct sockaddr_in *addr,const struct nlm_lock *); +__be32 nlmclnt_grant (const struct sockaddr *addr, +const struct nlm_lock *lock);void nlmclnt_recovery (struct nlm_host *);int nlmclnt_reclaim (struct nlm_host *,struct file_lock *);void nlmclnt_next_cookie (struct nlm_cookie *);
A message that is not in the archive (sent off-list or not yet received): 20080917161742.4963.24984.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org
Re: [PATCH 04/10] lockd: change nlmclnt_grant() to take a "struct sockaddr *"
Quoted 3 lines · Chuck Lever
Adjust the signature and callers of
nlmclnt_grant()to pass a "struct sockaddr *" instead of a "structsockaddr_in*" in order to support IPv6 addresses.
OK!--b.
Quoted 74 lines
Signed-off-by Chuck Lever <[email protected]>---
fs/lockd/clntlock.c | 5 ++--- fs/lockd/svc4proc.c | 2 +- fs/lockd/svcproc.c | 2 +- include/linux/lockd/lockd.h | 3 ++- 4 files changed, 6 insertions(+), 6 deletions(-)fs/lockd/clntlock.c +2
-3@@ -141,7 +141,7 @@ int nlmclnt_block(struct nlm_wait *block, struct nlm_rqst *req, long timeout)/* * The server lockd has called us back to tell us the lock was granted */ -__be32 nlmclnt_grant (const struct sockaddr_in *addr,const struct nlm_lock *lock) +__be32 nlmclnt_grant (const struct sockaddr *addr,const struct nlm_lock *lock) {const struct file_lock *fl = &lock->fl;const struct nfs_fh *fh = &lock->fh;@@ -165,8 +165,7 @@ __be32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *lock*/ if (fl_blocked->fl_u.nfs_fl.owner->pid != lock->svid)continue ; -if (!nlm_cmp_addr (nlm_addr (block->b_host), - (struct sockaddr *)addr)) +if (!nlm_cmp_addr (nlm_addr (block->b_host), addr))continue ;if (nfs_compare_fh (NFS_FH (fl_blocked->fl_file->f_path.dentry->d_inode) ,fh) !=0 )continue ;fs/lockd/svc4proc.c +1
-1@@ -231,7 +231,7 @@ nlm4svc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp, resp->cookie = argp->cookie;dprintk ("lockd: GRANTED called\n" ); - resp->status =nlmclnt_grant (svc_addr_in (rqstp), &argp->lock); + resp->status =nlmclnt_grant (svc_addr (rqstp), &argp->lock);dprintk ("lockd: GRANTED status %d\n" ,ntohl (resp->status));return rpc_success; }fs/lockd/svcproc.c +1
-1@@ -261,7 +261,7 @@ nlmsvc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp, resp->cookie = argp->cookie;dprintk ("lockd: GRANTED called\n" ); - resp->status =nlmclnt_grant (svc_addr_in (rqstp), &argp->lock); + resp->status =nlmclnt_grant (svc_addr (rqstp), &argp->lock);dprintk ("lockd: GRANTED status %d\n" ,ntohl (resp->status));return rpc_success; }include/linux/lockd/lockd.h +2
-1@@ -207,7 +207,8 @@ int nlm_async_reply(struct nlm_rqst *, u32, const struct rpc_call_ops *);struct nlm_wait *nlmclnt_prepare_block (struct nlm_host *host,struct file_lock *fl);void nlmclnt_finish_block (struct nlm_wait *block);int nlmclnt_block (struct nlm_wait *block,struct nlm_rqst *req,long timeout); -__be32 nlmclnt_grant (const struct sockaddr_in *addr,const struct nlm_lock *); +__be32 nlmclnt_grant (const struct sockaddr *addr, +const struct nlm_lock *lock);void nlmclnt_recovery (struct nlm_host *);int nlmclnt_reclaim (struct nlm_host *,struct file_lock *);void nlmclnt_next_cookie (struct nlm_cookie *);
PATCH 5/10 lockd: Adjust signature of nlm_host_rebooted to handle non-AF_INET
In reply to a message not in the archivePass a struct sockaddr * and length to nlm_host_rebooted() to accomodate non-AF_INET addresses.
---
fs/lockd/host.c | 28 ++++++++++++++++------------ fs/lockd/svc4proc.c | 4 +++- fs/lockd/svcproc.c | 4 +++- include/linux/lockd/lockd.h | 7 +++++-- 4 files changed, 27 insertions(+), 16 deletions(-)
fs/lockd/host.c +16 -12
@@ -473,31 +473,35 @@ void nlm_release_host(struct nlm_host *host) } } -/* -* We were notified that the host indicated by address &sin -* has rebooted. -* Release all resources held by that peer. +/** +* nlm_host_rebooted - Release all resources held by rebooted host +* @sap: network address of peer that just rebooted +* @salen: length of peer's network address +* @hostname: hostname of peer that just rebooted +* @hostname_len: length of peer's hostname +* @new_state: peer's new nsmstate +* +* We were notified that the host indicated by address "sap" +* has rebooted. Release all resources held by that peer. */ -void nlm_host_rebooted (const struct sockaddr_in *sin, -const char *hostname, -unsigned int hostname_len, -u32 new_state) +void nlm_host_rebooted (const struct sockaddr *sap,const size_t salen, +const char *hostname,const size_t hostname_len, +const u32 new_state) {struct hlist_head *chain;struct hlist_node *pos;struct nsm_handle *nsm;struct nlm_host *host; - nsm =nsm_find ((struct sockaddr *)sin,sizeof (*sin), - hostname, hostname_len,0 ); + nsm =nsm_find (sap, salen, hostname, hostname_len,0 );if (nsm ==NULL ) {dprintk ("lockd: never saw rebooted peer '%.*s' before\n" , - hostname_len, hostname); + (int )hostname_len, hostname);return ; }dprintk ("lockd: nlm_host_rebooted(%.*s, %s)\n" , - hostname_len, hostname, nsm->sm_addrbuf); + (int )hostname_len, hostname, nsm->sm_addrbuf);/* When reclaiming locks on this peer, make sure that * we set up a new notification */
fs/lockd/svc4proc.c +3 -1
@@ -447,8 +447,10 @@ nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,* reclaim all locks we hold on this server. */ memset (&saddr,0 ,sizeof (saddr)); + saddr.sin_family =AF_INET ; saddr.sin_addr.s_addr = argp->addr; -nlm_host_rebooted (&saddr, argp->mon, argp->len, argp->state); +nlm_host_rebooted ((struct sockaddr *)&saddr,sizeof (saddr), + argp->mon, argp->len, argp->state);return rpc_success; }
fs/lockd/svcproc.c +3 -1
@@ -479,8 +479,10 @@ nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,* reclaim all locks we hold on this server. */ memset (&saddr,0 ,sizeof (saddr)); + saddr.sin_family =AF_INET ; saddr.sin_addr.s_addr = argp->addr; -nlm_host_rebooted (&saddr, argp->mon, argp->len, argp->state); +nlm_host_rebooted ((struct sockaddr *)&saddr,sizeof (saddr), + argp->mon, argp->len, argp->state);return rpc_success; }
include/linux/lockd/lockd.h +5 -2
@@ -229,8 +229,11 @@ void nlm_rebind_host(struct nlm_host *);struct nlm_host *nlm_get_host (struct nlm_host *);void nlm_release_host (struct nlm_host *);void nlm_shutdown_hosts (void ); -extern void nlm_host_rebooted (const struct sockaddr_in *,const char *, -unsigned int ,u32 ); +extern void nlm_host_rebooted (const struct sockaddr *sap, +const size_t salen, +const char *hostname, +const size_t hostname_len, +const u32 new_state);void nsm_release (struct nsm_handle *);
A message that is not in the archive (sent off-list or not yet received): 20080917161749.4963.84067.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org
Re: [PATCH 05/10] lockd: Adjust signature of nlm_host_rebooted to handle non-AF_INET
Quoted 2 lines · Chuck Lever
Pass a struct sockaddr * and length to
nlm_host_rebooted()to accomodate non-AF_INET addresses.
OK, thanks.
Quoted 21 lines
fs/lockd/host.c +13
-4+/** +* nlm_host_rebooted - Release all resources held by rebooted host +* @sap: network address of peer that just rebooted +* @salen: length of peer's network address +* @hostname: hostname of peer that just rebooted +* @hostname_len: length of peer's hostname +* @new_state: peer's new nsmstate +* +* We were notified that the host indicated by address "sap" +* has rebooted. Release all resources held by that peer. */ -void nlm_host_rebooted (const struct sockaddr_in *sin, -const char *hostname, -unsigned int hostname_len, -u32 new_state) +void nlm_host_rebooted (const struct sockaddr *sap,const size_t salen, +const char *hostname,const size_t hostname_len, +const u32 new_state) {struct hlist_head *chain;struct hlist_node *pos;
fs/lockd/host.c void nlm_release_host(struct nlm_host *host) · line 499
Quoted 10 lines
fs/lockd/host.c +2
-3struct nsm_handle *nsm;struct nlm_host *host; - nsm =nsm_find ((struct sockaddr *)sin,sizeof (*sin), - hostname, hostname_len,0 ); + nsm =nsm_find (sap, salen, hostname, hostname_len,0 );if (nsm ==NULL ) {dprintk ("lockd: never saw rebooted peer '%.*s' before\n" , - hostname_len, hostname); + (int )hostname_len, hostname);
This seems unrelated to the current patch. And there's been no change to the signedness of hostname_len. Do we care?
--b.
Quoted 60 lines
fs/lockd/host.c +1
-1return ; }dprintk ("lockd: nlm_host_rebooted(%.*s, %s)\n" , - hostname_len, hostname, nsm->sm_addrbuf); + (int )hostname_len, hostname, nsm->sm_addrbuf);/* When reclaiming locks on this peer, make sure that * we set up a new notification */ fs/lockd/svc4proc.c +3
-1@@ -447,8 +447,10 @@ nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,* reclaim all locks we hold on this server. */ memset (&saddr,0 ,sizeof (saddr)); + saddr.sin_family =AF_INET ; saddr.sin_addr.s_addr = argp->addr; -nlm_host_rebooted (&saddr, argp->mon, argp->len, argp->state); +nlm_host_rebooted ((struct sockaddr *)&saddr,sizeof (saddr), + argp->mon, argp->len, argp->state);return rpc_success; }fs/lockd/svcproc.c +3
-1@@ -479,8 +479,10 @@ nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,* reclaim all locks we hold on this server. */ memset (&saddr,0 ,sizeof (saddr)); + saddr.sin_family =AF_INET ; saddr.sin_addr.s_addr = argp->addr; -nlm_host_rebooted (&saddr, argp->mon, argp->len, argp->state); +nlm_host_rebooted ((struct sockaddr *)&saddr,sizeof (saddr), + argp->mon, argp->len, argp->state);return rpc_success; }include/linux/lockd/lockd.h +5
-2@@ -229,8 +229,11 @@ void nlm_rebind_host(struct nlm_host *);struct nlm_host *nlm_get_host (struct nlm_host *);void nlm_release_host (struct nlm_host *);void nlm_shutdown_hosts (void ); -extern void nlm_host_rebooted (const struct sockaddr_in *,const char *, -unsigned int ,u32 ); +extern void nlm_host_rebooted (const struct sockaddr *sap, +const size_t salen, +const char *hostname, +const size_t hostname_len, +const u32 new_state);void nsm_release (struct nsm_handle *);
PATCH 6/10 lockd: Add helper to sanity check incoming NOTIFY requests
In reply to a message not in the archiveThe NLM performs a silly test to see that incoming NOTIFY requests are relatively secure. Make sure the test works for both AF_INET and AF_INET6 addresses.
---
fs/lockd/svc4proc.c | 6 ++---- fs/lockd/svcproc.c | 6 ++---- include/linux/lockd/lockd.h | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 8 deletions(-)
fs/lockd/svc4proc.c +2 -4
@@ -432,11 +432,9 @@ nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, {struct sockaddr_in saddr; -memcpy (&saddr,svc_addr_in (rqstp),sizeof (saddr)); -dprintk ("lockd: SM_NOTIFY called\n" ); -if (saddr.sin_addr.s_addr !=htonl (INADDR_LOOPBACK ) - ||ntohs (saddr.sin_port) >=1024 ) { + +if (!nlm_privileged_requester (rqstp)) {char buf[RPC_MAX_ADDRBUFLEN ];printk (KERN_WARNING "lockd: rejected NSM callback from %s\n" ,svc_print_addr (rqstp, buf,sizeof (buf)));
fs/lockd/svcproc.c +2 -4
@@ -464,11 +464,9 @@ nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, {struct sockaddr_in saddr; -memcpy (&saddr,svc_addr_in (rqstp),sizeof (saddr)); -dprintk ("lockd: SM_NOTIFY called\n" ); -if (saddr.sin_addr.s_addr !=htonl (INADDR_LOOPBACK ) - ||ntohs (saddr.sin_port) >=1024 ) { + +if (!nlm_privileged_requester (rqstp)) {char buf[RPC_MAX_ADDRBUFLEN ];printk (KERN_WARNING "lockd: rejected NSM callback from %s\n" ,svc_print_addr (rqstp, buf,sizeof (buf)));
include/linux/lockd/lockd.h +41 -0
47 lines not on this page · raw message
A message that is not in the archive (sent off-list or not yet received): 20080917161757.4963.82230.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org
Re: [PATCH 06/10] lockd: Add helper to sanity check incoming NOTIFY requests
Quoted 3 lines · Chuck Lever
The NLM performs a silly test to see that incoming NOTIFY requests are relatively secure. Make sure the test works for both
AF_INETandAF_INET6addresses.
Makes sense. (Why's the test silly? If it prevents local users from telling lockd to drop a client's locks, that seems good.)
--b.
Quoted 98 lines
Signed-off-by Chuck Lever <[email protected]>---
fs/lockd/svc4proc.c | 6 ++---- fs/lockd/svcproc.c | 6 ++---- include/linux/lockd/lockd.h | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 8 deletions(-)fs/lockd/svc4proc.c +2
-4@@ -432,11 +432,9 @@ nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, {struct sockaddr_in saddr; -memcpy (&saddr,svc_addr_in (rqstp),sizeof (saddr)); -dprintk ("lockd: SM_NOTIFY called\n" ); -if (saddr.sin_addr.s_addr !=htonl (INADDR_LOOPBACK ) - ||ntohs (saddr.sin_port) >=1024 ) { + +if (!nlm_privileged_requester (rqstp)) {char buf[RPC_MAX_ADDRBUFLEN ];printk (KERN_WARNING "lockd: rejected NSM callback from %s\n" ,svc_print_addr (rqstp, buf,sizeof (buf)));fs/lockd/svcproc.c +2
-4@@ -464,11 +464,9 @@ nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, {struct sockaddr_in saddr; -memcpy (&saddr,svc_addr_in (rqstp),sizeof (saddr)); -dprintk ("lockd: SM_NOTIFY called\n" ); -if (saddr.sin_addr.s_addr !=htonl (INADDR_LOOPBACK ) - ||ntohs (saddr.sin_port) >=1024 ) { + +if (!nlm_privileged_requester (rqstp)) {char buf[RPC_MAX_ADDRBUFLEN ];printk (KERN_WARNING "lockd: rejected NSM callback from %s\n" ,svc_print_addr (rqstp, buf,sizeof (buf)));include/linux/lockd/lockd.h +41
-0@@ -280,6 +280,47 @@ static inline struct inode *nlmsvc_file_inode(struct nlm_file *file)return file->f_file->f_path.dentry->d_inode; } +static inline int __nlm_privileged_request4 (const struct sockaddr *sap) +{ +const struct sockaddr_in *sin = (struct sockaddr_in *)sap; +return (sin->sin_addr.s_addr ==htonl (INADDR_LOOPBACK )) && + (ntohs (sin->sin_port) <1024 ); +} + +#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +static inline int __nlm_privileged_request6 (const struct sockaddr *sap) +{ +const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; +return (ipv6_addr_type (&sin6->sin6_addr) &IPV6_ADDR_LOOPBACK ) && + (ntohs (sin6->sin6_port) <1024 ); +} +#else /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ +static inline int __nlm_privileged_request6 (const struct sockaddr *sap) +{ +return 0 ; +} +#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ + +/* +* Ensure incoming requests are suitably "secure" +* +* Return TRUE if sender is local and is connecting via a privileged port; +* otherwise return FALSE. +*/ +static inline int nlm_privileged_requester (const struct svc_rqst *rqstp) +{ +const struct sockaddr *sap =svc_addr (rqstp); + +switch (sap->sa_family) { +case AF_INET : +return __nlm_privileged_request4 (sap); +case AF_INET6 : +return __nlm_privileged_request6 (sap); +default : +return 0 ; + } +} +static inline int __nlm_cmp_addr4 (const struct sockaddr *sap1,const struct sockaddr *sap2) {
Re: [PATCH 06/10] lockd: Add helper to sanity check incoming NOTIFY requests
Quoted 7 lines · J. Bruce Fields
Quoted 3 lines · Chuck Lever
The NLM performs a silly test to see that incoming NOTIFY requests are relatively secure. Make sure the test works for both
AF_INETandAF_INET6addresses.Makes sense. (Why's the test silly? If it prevents local users from telling lockd to drop a client's locks, that seems good.)
I was referring to the port range part of the test. Anyone who wants real security will not rely on the port value, but will use SSL or third-party authentication like Kerberos.
Quoted 115 lines
--b.
Quoted 103 lines
Signed-off-by Chuck Lever <[email protected]>---
fs/lockd/svc4proc.c | 6 ++---- fs/lockd/svcproc.c | 6 ++---- include/linux/lockd/lockd.h | 41 +++++++++++++++++++++++++++++++++ ++++++++ 3 files changed, 45 insertions(+), 8 deletions(-)fs/lockd/svc4proc.c +2
-4@@ -432,11 +432,9 @@ nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, {struct sockaddr_in saddr; -memcpy (&saddr,svc_addr_in (rqstp),sizeof (saddr)); -dprintk ("lockd: SM_NOTIFY called\n" ); -if (saddr.sin_addr.s_addr !=htonl (INADDR_LOOPBACK ) - ||ntohs (saddr.sin_port) >=1024 ) { + +if (!nlm_privileged_requester (rqstp)) {char buf[RPC_MAX_ADDRBUFLEN ]; printk(KERN_WARNING "lockd: rejected NSM callback from %s\n",svc_print_addr(rqstp, buf, sizeof(buf)));fs/lockd/svcproc.c +2
-4@@ -464,11 +464,9 @@ nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, {struct sockaddr_in saddr; -memcpy (&saddr,svc_addr_in (rqstp),sizeof (saddr)); -dprintk ("lockd: SM_NOTIFY called\n" ); -if (saddr.sin_addr.s_addr !=htonl (INADDR_LOOPBACK ) - ||ntohs (saddr.sin_port) >=1024 ) { + +if (!nlm_privileged_requester (rqstp)) {char buf[RPC_MAX_ADDRBUFLEN ]; printk(KERN_WARNING "lockd: rejected NSM callback from %s\n",svc_print_addr(rqstp, buf, sizeof(buf)));include/linux/lockd/lockd.h +16
-0@@ -280,6 +280,47 @@ static inline struct inode *nlmsvc_file_inode(struct nlm_file *file)return file->f_file->f_path.dentry->d_inode; } +static inline int __nlm_privileged_request4 (const struct sockaddr *sap) +{ +const struct sockaddr_in *sin = (struct sockaddr_in *)sap; +return (sin->sin_addr.s_addr ==htonl (INADDR_LOOPBACK )) && + (ntohs (sin->sin_port) <1024 ); +} + +#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +static inline int __nlm_privileged_request6 (const struct sockaddr *sap) +{ +const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; +return (ipv6_addr_type (&sin6->sin6_addr) &IPV6_ADDR_LOOPBACK ) && + (ntohs (sin6->sin6_port) <1024 ); +} +#else /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ +static inline int __nlm_privileged_request6(const struct sockaddr*sap)
include/linux/lockd/lockd.h +9
-0+{ +return 0 ; +} +#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ + +/* +* Ensure incoming requests are suitably "secure" +* +* Return TRUE if sender is local and is connecting via a privileged port;
+ * otherwise return FALSE.
+ */
+static inline intnlm_privileged_requester(const struct svc_rqst *rqstp)include/linux/lockd/lockd.h +13
-0+{ +const struct sockaddr *sap =svc_addr (rqstp); + +switch (sap->sa_family) { +case AF_INET : +return __nlm_privileged_request4 (sap); +case AF_INET6 : +return __nlm_privileged_request6 (sap); +default : +return 0 ; + } +} +Quoted 4 lines
static inline int __nlm_cmp_addr4(const struct sockaddr *sap1,
const struct sockaddr *sap2)
{--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 06/10] lockd: Add helper to sanity check incoming NOTIFY requests
Quoted 8 lines · Chuck Lever
Quoted 7 lines · J. Bruce Fields
Quoted 5 lines · Chuck Lever
The NLM performs a silly test to see that incoming NOTIFY requests are
relatively secure. Make sure the test works for bothAF_INETandAF_INET6
addresses.
Quoted 6 lines
Quoted 2 lines
Makes sense. (Why's the test silly? If it prevents local users from telling lockd to drop a client's locks, that seems good.)
I was referring to the port range part of the test. Anyone who wants real security will not rely on the port value, but will use SSL or third-party authentication like Kerberos.
Over the loopback interface?
This is a local call--if the kernel needs kerberos to decide whether a local process is privileged, something's wrong.
--b.
Quoted 126 lines
Quoted 118 lines
--b.
Quoted 104 lines
Signed-off-by Chuck Lever <[email protected]>---
fs/lockd/svc4proc.c | 6 ++---- fs/lockd/svcproc.c | 6 ++---- include/linux/lockd/lockd.h | 41 +++++++++++++++++++++++++++++++++ ++++++++ 3 files changed, 45 insertions(+), 8 deletions(-)fs/lockd/svc4proc.c +2
-4@@ -432,11 +432,9 @@ nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, {struct sockaddr_in saddr; -memcpy (&saddr,svc_addr_in (rqstp),sizeof (saddr)); -dprintk ("lockd: SM_NOTIFY called\n" ); -if (saddr.sin_addr.s_addr !=htonl (INADDR_LOOPBACK ) - ||ntohs (saddr.sin_port) >=1024 ) { + +if (!nlm_privileged_requester (rqstp)) {char buf[RPC_MAX_ADDRBUFLEN ]; printk(KERN_WARNING "lockd: rejected NSM callback from %s\n",svc_print_addr(rqstp, buf, sizeof(buf)));fs/lockd/svcproc.c +2
-4@@ -464,11 +464,9 @@ nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, {struct sockaddr_in saddr; -memcpy (&saddr,svc_addr_in (rqstp),sizeof (saddr)); -dprintk ("lockd: SM_NOTIFY called\n" ); -if (saddr.sin_addr.s_addr !=htonl (INADDR_LOOPBACK ) - ||ntohs (saddr.sin_port) >=1024 ) { + +if (!nlm_privileged_requester (rqstp)) {char buf[RPC_MAX_ADDRBUFLEN ]; printk(KERN_WARNING "lockd: rejected NSM callback from %s\n",svc_print_addr(rqstp, buf, sizeof(buf)));include/linux/lockd/ renamed from include/linux/lockd/lockd.h +0
-0
lockd.h
index 075095f..409eab4 100644include/linux/lockd/lockd.h +16
-0@@ -280,6 +280,47 @@ static inline struct inode *nlmsvc_file_inode(struct nlm_file *file)return file->f_file->f_path.dentry->d_inode; } +static inline int __nlm_privileged_request4 (const struct sockaddr *sap) +{ +const struct sockaddr_in *sin = (struct sockaddr_in *)sap; +return (sin->sin_addr.s_addr ==htonl (INADDR_LOOPBACK )) && + (ntohs (sin->sin_port) <1024 ); +} + +#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +static inline int __nlm_privileged_request6 (const struct sockaddr *sap) +{ +const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; +return (ipv6_addr_type (&sin6->sin6_addr) &IPV6_ADDR_LOOPBACK ) && + (ntohs (sin6->sin6_port) <1024 ); +} +#else /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ +static inline int __nlm_privileged_request6(const struct sockaddr*sap)
include/linux/lockd/lockd.h +9
-0+{ +return 0 ; +} +#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ + +/* +* Ensure incoming requests are suitably "secure" +* +* Return TRUE if sender is local and is connecting via a privileged port;
+ * otherwise return FALSE.
+ */
+static inline intnlm_privileged_requester(const struct svc_rqst *rqstp)include/linux/lockd/lockd.h +13
-0+{ +const struct sockaddr *sap =svc_addr (rqstp); + +switch (sap->sa_family) { +case AF_INET : +return __nlm_privileged_request4 (sap); +case AF_INET6 : +return __nlm_privileged_request6 (sap); +default : +return 0 ; + } +} +Quoted 4 lines
static inline int __nlm_cmp_addr4(const struct sockaddr *sap1,
const struct sockaddr *sap2)
{--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlSignature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
PATCH 7/10 lockd: Remove unused fields in the nlm_reboot structure
In reply to a message not in the archiveThe nlm_reboot structure is used to store information provided by the NSM_NOTIFY procedure. This procedure is not specified by the NLM or NSM protocols, other than to say that the procedure can be used to transmit information private to a particular NLM/NSM implementation.
For Linux, the callback arguments include the name of the monitored host, the new NSM state of the host, and a 16-byte private opaque.
Linux encodes the monitored host's IP address into the opaque field. Formerly, this field contained a 4-byte in_addr IPv4 address and the NSM version and transport protocol used to contact the monitored host. Recently this was changed so that the private field now contains the 4-byte IPv4 address and 12 bytes of zero.
As a clean up, remove the unused fields and the server-side XDR logic that decodes them.
---
fs/lockd/xdr.c | 2 -- fs/lockd/xdr4.c | 2 -- include/linux/lockd/xdr.h | 2 -- 3 files changed, 0 insertions(+), 6 deletions(-)
fs/lockd/xdr.c +0 -2
@@ -351,8 +351,6 @@ nlmsvc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp) argp->state =ntohl (*p++);/* Preserve the address in network byte order */ argp->addr = *p++; - argp->vers = *p++; - argp->proto = *p++;return xdr_argsize_check (rqstp, p); }
fs/lockd/xdr4.c +0 -2
@@ -358,8 +358,6 @@ nlm4svc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp argp->state =ntohl (*p++);/* Preserve the address in network byte order */ argp->addr = *p++; - argp->vers = *p++; - argp->proto = *p++;return xdr_argsize_check (rqstp, p); }
include/linux/lockd/xdr.h +0 -2
@@ -81,8 +81,6 @@ struct nlm_reboot {unsigned int len;u32 state;__be32 addr; -__be32 vers; -__be32 proto; };/*
A message that is not in the archive (sent off-list or not yet received): 20080917161804.4963.71981.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org
Re: [PATCH 07/10] lockd: Remove unused fields in the nlm_reboot structure
Quoted 8 lines · Chuck Lever
The
nlm_rebootstructure is used to store information provided by theNSM_NOTIFYprocedure. This procedure is not specified by the NLM or NSM protocols, other than to say that the procedure can be used to transmit information private to a particular NLM/NSM implementation.For Linux, the callback arguments include the name of the monitored host, the new NSM state of the host, and a 16-byte private opaque.
Quoted 8 lines
Linux encodes the monitored host's IP address into the opaque field. Formerly, this field contained a 4-byte
in_addrIPv4 address and the NSM version and transport protocol used to contact the monitored host. Recently this was changed so that the private field now contains the 4-byte IPv4 address and 12 bytes of zero.As a clean up, remove the unused fields and the server-side XDR logic that decodes them.
My one concern here:
include/linux/lockd/xdr.h struct nlm_reboot { · line 84
Quoted 11 lines
include/linux/lockd/xdr.h +0
-2@@ -81,8 +81,6 @@ struct nlm_reboot {unsigned int len;u32 state;__be32 addr; -__be32 vers; -__be32 proto; };
is that sizeof(nlm_reboot) is used to set pc_argsize in the PROC() macro's at the end of svcproc.c and svc4proc.c. On a quick glance I can see any problem that that would cause. Have you checked this?
--b.
Re: [PATCH 07/10] lockd: Remove unused fields in the nlm_reboot structure
Quoted 20 lines · bfields
Quoted 8 lines · Chuck Lever
The
nlm_rebootstructure is used to store information provided by theNSM_NOTIFYprocedure. This procedure is not specified by the NLM or NSM protocols, other than to say that the procedure can be used to transmit information private to a particular NLM/NSM implementation.For Linux, the callback arguments include the name of the monitored host, the new NSM state of the host, and a 16-byte private opaque.
Quoted 8 lines
Linux encodes the monitored host's IP address into the opaque field. Formerly, this field contained a 4-byte
in_addrIPv4 address and the NSM version and transport protocol used to contact the monitored host. Recently this was changed so that the private field now contains the 4-byte IPv4 address and 12 bytes of zero.As a clean up, remove the unused fields and the server-side XDR logic that decodes them.
My one concern here:
Quoted 15 lines
include/linux/lockd/xdr.h struct nlm_reboot { · line 84
Quoted 11 lines
include/linux/lockd/xdr.h +0
-2@@ -81,8 +81,6 @@ struct nlm_reboot {unsigned int len;u32 state;__be32 addr; -__be32 vers; -__be32 proto; };is that
sizeof(nlm_reboot)is used to setpc_argsizein thePROC()macro's at the end ofsvcproc.candsvc4proc.c. On a quick glance I can see any problem that that would cause. Have you checked this?
Never mind, I think I was assuming there was some connection between the size of this struct and the on-the-wire xdr size, which isn't the case. OK, this shouldn't matter at all.
--b.
PATCH 8/10 lockd: struct nlm_reboot should contain a full socket address
In reply to a message not in the archiveThe XDR decoders for the NSM NOTIFY procedure should construct a full socket address and store it in the nlm_reboot structure. In addition to being able to store larger addresses, this means upper layer routines get an address family tag so they can distinguish between AF_INET and AF_INET6 addresses.
This also keeps potentially large socket addresses off the stack and instead in dynamically allocated storage.
---
fs/lockd/svc4proc.c | 10 +--------- fs/lockd/svcproc.c | 10 +--------- fs/lockd/xdr.c | 28 ++++++++++++++++++++++++++-- fs/lockd/xdr4.c | 27 +++++++++++++++++++++++++-- include/linux/lockd/xdr.h | 3 ++- 5 files changed, 55 insertions(+), 23 deletions(-)
fs/lockd/svc4proc.c +1 -9
@@ -430,8 +430,6 @@ static __be32 nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, void *resp) { - struct sockaddr_in saddr; - dprintk("lockd: SM_NOTIFY called\n");if (!nlm_privileged_requester (rqstp)) {
@@ -441,13 +439,7 @@ nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,return rpc_system_err; } -/* Obtain the host pointer for this NFS server and try to -* reclaim all locks we hold on this server. -*/ -memset (&saddr,0 ,sizeof (saddr)); - saddr.sin_family =AF_INET ; - saddr.sin_addr.s_addr = argp->addr; -nlm_host_rebooted ((struct sockaddr *)&saddr,sizeof (saddr), +nlm_host_rebooted ((struct sockaddr *)&argp->addr, argp->addrlen, argp->mon, argp->len, argp->state);return rpc_success;
fs/lockd/svcproc.c +1 -9
@@ -462,8 +462,6 @@ static __be32 nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, void *resp) { - struct sockaddr_in saddr; - dprintk("lockd: SM_NOTIFY called\n");if (!nlm_privileged_requester (rqstp)) {
@@ -473,13 +471,7 @@ nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,return rpc_system_err; } -/* Obtain the host pointer for this NFS server and try to -* reclaim all locks we hold on this server. -*/ -memset (&saddr,0 ,sizeof (saddr)); - saddr.sin_family =AF_INET ; - saddr.sin_addr.s_addr = argp->addr; -nlm_host_rebooted ((struct sockaddr *)&saddr,sizeof (saddr), +nlm_host_rebooted ((struct sockaddr *)&argp->addr, argp->addrlen, argp->mon, argp->len, argp->state);return rpc_success;
fs/lockd/xdr.c +26 -2
@@ -9,6 +9,7 @@#include <linux/types.h> #include <linux/sched.h> #include <linux/utsname.h> +#include <linux/in.h> #include <linux/nfs.h> #include <linux/sunrpc/xdr.h>
@@ -346,11 +347,34 @@ nlmsvc_decode_notify(struct svc_rqst *rqstp, __be32 *p, struct nlm_args *argp)int nlmsvc_decode_reboot (struct svc_rqst *rqstp,__be32 *p,struct nlm_reboot *argp) { +struct sockaddr_in *sin = (struct sockaddr_in *)&argp->addr; +struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&argp->addr; +if (!(p =xdr_decode_string_inplace (p, &argp->mon, &argp->len,SM_MAXSTRLEN )))return 0 ; argp->state =ntohl (*p++); -/* Preserve the address in network byte order */ - argp->addr = *p++; + +/* Decode the 16-byte private field */ +memset (&argp->addr,0 ,sizeof (argp->addr)); +switch (svc_addr (rqstp)->sa_family) { +case AF_INET : +/* data in recv buffer is already in network byte order */ + sin->sin_family =AF_INET ; + sin->sin_addr.s_addr = *p++; + argp->addrlen =sizeof (*sin); +break ; +case AF_INET6 : + sin6->sin6_family =AF_INET6 ; + sin6->sin6_addr.s6_addr32[0 ] = *p++; + sin6->sin6_addr.s6_addr32[1 ] = *p++; + sin6->sin6_addr.s6_addr32[2 ] = *p++; + sin6->sin6_addr.s6_addr32[3 ] = *p++; + argp->addrlen =sizeof (*sin6); +break ; +default : +return -EIO ; + } +return xdr_argsize_check (rqstp, p); }
fs/lockd/xdr4.c +25 -2
@@ -353,11 +353,34 @@ nlm4svc_decode_notify(struct svc_rqst *rqstp, __be32 *p, struct nlm_args *argp)int nlm4svc_decode_reboot (struct svc_rqst *rqstp,__be32 *p,struct nlm_reboot *argp) { +struct sockaddr_in *sin = (struct sockaddr_in *)&argp->addr; +struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&argp->addr; +if (!(p =xdr_decode_string_inplace (p, &argp->mon, &argp->len,SM_MAXSTRLEN )))return 0 ; argp->state =ntohl (*p++); -/* Preserve the address in network byte order */ - argp->addr = *p++; + +/* Decode the 16-byte private field */ +memset (&argp->addr,0 ,sizeof (argp->addr)); +switch (svc_addr (rqstp)->sa_family) { +case AF_INET : +/* address in recv buffer is already in network byte order */ + sin->sin_family =AF_INET ; + sin->sin_addr.s_addr = *p++; + argp->addrlen =sizeof (*sin); +break ; +case AF_INET6 : + sin6->sin6_family =AF_INET6 ; + sin6->sin6_addr.s6_addr32[0 ] = *p++; + sin6->sin6_addr.s6_addr32[1 ] = *p++; + sin6->sin6_addr.s6_addr32[2 ] = *p++; + sin6->sin6_addr.s6_addr32[3 ] = *p++; + argp->addrlen =sizeof (*sin6); +break ; +default : +return -EIO ; + } +return xdr_argsize_check (rqstp, p); }
include/linux/lockd/xdr.h +2 -1
@@ -80,7 +80,8 @@ struct nlm_reboot {char * mon;unsigned int len;u32 state; -__be32 addr; +struct sockaddr_storage addr; +size_t addrlen; };/*
A message that is not in the archive (sent off-list or not yet received): 20080917161811.4963.60224.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org
Re: [PATCH 08/10] lockd: struct nlm_reboot should contain a full socket address
Quoted 8 lines · Chuck Lever
The XDR decoders for the NSM NOTIFY procedure should construct a full socket address and store it in the
nlm_rebootstructure. In addition to being able to store larger addresses, this means upper layer routines get an address family tag so they can distinguish betweenAF_INETandAF_INET6addresses.This also keeps potentially large socket addresses off the stack and instead in dynamically allocated storage.
So one way to think of this would be that you're extending the kernel<->statd interface by using the address family of statd's notify call to communicate the address family of the host that rebooted.
Do I have that right?
--b.
Quoted 172 lines
Signed-off-by Chuck Lever <[email protected]>---
fs/lockd/svc4proc.c | 10 +--------- fs/lockd/svcproc.c | 10 +--------- fs/lockd/xdr.c | 28 ++++++++++++++++++++++++++-- fs/lockd/xdr4.c | 27 +++++++++++++++++++++++++-- include/linux/lockd/xdr.h | 3 ++- 5 files changed, 55 insertions(+), 23 deletions(-)fs/lockd/svc4proc.c +1
-9@@ -430,8 +430,6 @@ static __be32 nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, void *resp) { - struct sockaddr_in saddr; - dprintk("lockd: SM_NOTIFY called\n");if (!nlm_privileged_requester (rqstp)) {@@ -441,13 +439,7 @@ nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,return rpc_system_err; } -/* Obtain the host pointer for this NFS server and try to -* reclaim all locks we hold on this server. -*/ -memset (&saddr,0 ,sizeof (saddr)); - saddr.sin_family =AF_INET ; - saddr.sin_addr.s_addr = argp->addr; -nlm_host_rebooted ((struct sockaddr *)&saddr,sizeof (saddr), +nlm_host_rebooted ((struct sockaddr *)&argp->addr, argp->addrlen, argp->mon, argp->len, argp->state);return rpc_success;fs/lockd/svcproc.c +1
-9@@ -462,8 +462,6 @@ static __be32 nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, void *resp) { - struct sockaddr_in saddr; - dprintk("lockd: SM_NOTIFY called\n");if (!nlm_privileged_requester (rqstp)) {@@ -473,13 +471,7 @@ nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp,return rpc_system_err; } -/* Obtain the host pointer for this NFS server and try to -* reclaim all locks we hold on this server. -*/ -memset (&saddr,0 ,sizeof (saddr)); - saddr.sin_family =AF_INET ; - saddr.sin_addr.s_addr = argp->addr; -nlm_host_rebooted ((struct sockaddr *)&saddr,sizeof (saddr), +nlm_host_rebooted ((struct sockaddr *)&argp->addr, argp->addrlen, argp->mon, argp->len, argp->state);return rpc_success;fs/lockd/xdr.c +26
-2@@ -9,6 +9,7 @@#include <linux/types.h> #include <linux/sched.h> #include <linux/utsname.h> +#include <linux/in.h> #include <linux/nfs.h> #include <linux/sunrpc/xdr.h> @@ -346,11 +347,34 @@ nlmsvc_decode_notify(struct svc_rqst *rqstp, __be32 *p, struct nlm_args *argp)int nlmsvc_decode_reboot (struct svc_rqst *rqstp,__be32 *p,struct nlm_reboot *argp) { +struct sockaddr_in *sin = (struct sockaddr_in *)&argp->addr; +struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&argp->addr; +if (!(p =xdr_decode_string_inplace (p, &argp->mon, &argp->len,SM_MAXSTRLEN )))return 0 ; argp->state =ntohl (*p++); -/* Preserve the address in network byte order */ - argp->addr = *p++; + +/* Decode the 16-byte private field */ +memset (&argp->addr,0 ,sizeof (argp->addr)); +switch (svc_addr (rqstp)->sa_family) { +case AF_INET : +/* data in recv buffer is already in network byte order */ + sin->sin_family =AF_INET ; + sin->sin_addr.s_addr = *p++; + argp->addrlen =sizeof (*sin); +break ; +case AF_INET6 : + sin6->sin6_family =AF_INET6 ; + sin6->sin6_addr.s6_addr32[0 ] = *p++; + sin6->sin6_addr.s6_addr32[1 ] = *p++; + sin6->sin6_addr.s6_addr32[2 ] = *p++; + sin6->sin6_addr.s6_addr32[3 ] = *p++; + argp->addrlen =sizeof (*sin6); +break ; +default : +return -EIO ; + } +return xdr_argsize_check (rqstp, p); }fs/lockd/xdr4.c +25
-2@@ -353,11 +353,34 @@ nlm4svc_decode_notify(struct svc_rqst *rqstp, __be32 *p, struct nlm_args *argp)int nlm4svc_decode_reboot (struct svc_rqst *rqstp,__be32 *p,struct nlm_reboot *argp) { +struct sockaddr_in *sin = (struct sockaddr_in *)&argp->addr; +struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&argp->addr; +if (!(p =xdr_decode_string_inplace (p, &argp->mon, &argp->len,SM_MAXSTRLEN )))return 0 ; argp->state =ntohl (*p++); -/* Preserve the address in network byte order */ - argp->addr = *p++; + +/* Decode the 16-byte private field */ +memset (&argp->addr,0 ,sizeof (argp->addr)); +switch (svc_addr (rqstp)->sa_family) { +case AF_INET : +/* address in recv buffer is already in network byte order */ + sin->sin_family =AF_INET ; + sin->sin_addr.s_addr = *p++; + argp->addrlen =sizeof (*sin); +break ; +case AF_INET6 : + sin6->sin6_family =AF_INET6 ; + sin6->sin6_addr.s6_addr32[0 ] = *p++; + sin6->sin6_addr.s6_addr32[1 ] = *p++; + sin6->sin6_addr.s6_addr32[2 ] = *p++; + sin6->sin6_addr.s6_addr32[3 ] = *p++; + argp->addrlen =sizeof (*sin6); +break ; +default : +return -EIO ; + } +return xdr_argsize_check (rqstp, p); }include/linux/lockd/xdr.h +2
-1@@ -80,7 +80,8 @@ struct nlm_reboot {char * mon;unsigned int len;u32 state; -__be32 addr; +struct sockaddr_storage addr; +size_t addrlen; };/*
Re: [PATCH 08/10] lockd: struct nlm_reboot should contain a full socket address
Quoted 7 lines · J. Bruce Fields
Quoted 6 lines · Chuck Lever
The XDR decoders for the NSM NOTIFY procedure should construct a full socket address and store it in the
nlm_rebootstructure. In addition to being able to store larger addresses, this means upper layer routines get an address family tag so they can distinguish betweenAF_INETandAF_INET6addresses.
Quoted 8 lines
Quoted 2 lines
This also keeps potentially large socket addresses off the stack and instead in dynamically allocated storage.
So one way to think of this would be that you're extending the kernel<->statd interface by using the address family of statd's notify call to communicate the address family of the host that rebooted.
Do I have that right?
For statd, we're using the same technique that we used when constructing the source address in nlmsvc_lookup_host(). There's no family tag associated with the address because the 16-byte opaque in the on-the-wire format has room only for the sin6_addr part of the address. The notification downcall for IPv6 peers has to come via IPv6 loopback for this to work.
Quoted 186 lines
--b.
Quoted 169 lines
Signed-off-by Chuck Lever <[email protected]>---
fs/lockd/svc4proc.c | 10 +--------- fs/lockd/svcproc.c | 10 +--------- fs/lockd/xdr.c | 28 ++++++++++++++++++++++++++-- fs/lockd/xdr4.c | 27 +++++++++++++++++++++++++-- include/linux/lockd/xdr.h | 3 ++- 5 files changed, 55 insertions(+), 23 deletions(-)fs/lockd/svc4proc.c +1
-9@@ -430,8 +430,6 @@ static __be32 nlm4svc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, void *resp) { - struct sockaddr_in saddr; - dprintk("lockd: SM_NOTIFY called\n");if (!nlm_privileged_requester (rqstp)) {@@ -441,13 +439,7 @@ nlm4svc_proc_sm_notify(struct svc_rqst *rqstp,struct nlm_reboot *argp, return rpc_system_err; } -/* Obtain the host pointer for this NFS server and try to -* reclaim all locks we hold on this server. -*/ -memset (&saddr,0 ,sizeof (saddr)); - saddr.sin_family =AF_INET ; - saddr.sin_addr.s_addr = argp->addr; -nlm_host_rebooted ((struct sockaddr *)&saddr,sizeof (saddr), +nlm_host_rebooted ((struct sockaddr *)&argp->addr, argp->addrlen, argp->mon, argp->len, argp->state);return rpc_success;fs/lockd/svcproc.c +1
-9@@ -462,8 +462,6 @@ static __be32 nlmsvc_proc_sm_notify(struct svc_rqst *rqstp, struct nlm_reboot *argp, void *resp) { - struct sockaddr_in saddr; - dprintk("lockd: SM_NOTIFY called\n");if (!nlm_privileged_requester (rqstp)) {@@ -473,13 +471,7 @@ nlmsvc_proc_sm_notify(struct svc_rqst *rqstp,struct nlm_reboot *argp, return rpc_system_err; } -/* Obtain the host pointer for this NFS server and try to -* reclaim all locks we hold on this server. -*/ -memset (&saddr,0 ,sizeof (saddr)); - saddr.sin_family =AF_INET ; - saddr.sin_addr.s_addr = argp->addr; -nlm_host_rebooted ((struct sockaddr *)&saddr,sizeof (saddr), +nlm_host_rebooted ((struct sockaddr *)&argp->addr, argp->addrlen, argp->mon, argp->len, argp->state);return rpc_success;fs/lockd/xdr.c +1
-0@@ -9,6 +9,7 @@#include <linux/types.h> #include <linux/sched.h> #include <linux/utsname.h> +#include <linux/in.h> #include <linux/nfs.h> #include <linux/sunrpc/xdr.h> @@ -346,11 +347,34 @@ nlmsvc_decode_notify(struct svc_rqst *rqstp, __be32 *p, struct nlm_args *argp)int
nlmsvc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp){fs/lockd/xdr.c +3
-0+struct sockaddr_in *sin = (struct sockaddr_in *)&argp->addr; +struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&argp->addr; +if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN))) return 0; argp->state = ntohl(*p++);fs/lockd/xdr.c +22
-2-/* Preserve the address in network byte order */ - argp->addr = *p++; + +/* Decode the 16-byte private field */ +memset (&argp->addr,0 ,sizeof (argp->addr)); +switch (svc_addr (rqstp)->sa_family) { +case AF_INET : +/* data in recv buffer is already in network byte order */ + sin->sin_family =AF_INET ; + sin->sin_addr.s_addr = *p++; + argp->addrlen =sizeof (*sin); +break ; +case AF_INET6 : + sin6->sin6_family =AF_INET6 ; + sin6->sin6_addr.s6_addr32[0 ] = *p++; + sin6->sin6_addr.s6_addr32[1 ] = *p++; + sin6->sin6_addr.s6_addr32[2 ] = *p++; + sin6->sin6_addr.s6_addr32[3 ] = *p++; + argp->addrlen =sizeof (*sin6); +break ; +default : +return -EIO ; + } +return xdr_argsize_check(rqstp, p); }fs/lockd/xdr4.c +0
-0@@ -353,11 +353,34 @@ nlm4svc_decode_notify(struct svc_rqst *rqstp, __be32 *p, struct nlm_args *argp)int
nlm4svc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp){fs/lockd/xdr4.c +3
-0+struct sockaddr_in *sin = (struct sockaddr_in *)&argp->addr; +struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&argp->addr; +if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN))) return 0; argp->state = ntohl(*p++);fs/lockd/xdr4.c +22
-2-/* Preserve the address in network byte order */ - argp->addr = *p++; + +/* Decode the 16-byte private field */ +memset (&argp->addr,0 ,sizeof (argp->addr)); +switch (svc_addr (rqstp)->sa_family) { +case AF_INET : +/* address in recv buffer is already in network byte order */ + sin->sin_family =AF_INET ; + sin->sin_addr.s_addr = *p++; + argp->addrlen =sizeof (*sin); +break ; +case AF_INET6 : + sin6->sin6_family =AF_INET6 ; + sin6->sin6_addr.s6_addr32[0 ] = *p++; + sin6->sin6_addr.s6_addr32[1 ] = *p++; + sin6->sin6_addr.s6_addr32[2 ] = *p++; + sin6->sin6_addr.s6_addr32[3 ] = *p++; + argp->addrlen =sizeof (*sin6); +break ; +default : +return -EIO ; + } +return xdr_argsize_check(rqstp, p); }include/linux/lockd/xdr.h +0
-0include/linux/lockd/xdr.h struct nlm_reboot { · line 87
Quoted 9 lines
include/linux/lockd/xdr.h +2
-1@@ -80,7 +80,8 @@ struct nlm_reboot {char * mon;unsigned int len;u32 state; -__be32 addr; +struct sockaddr_storage addr; +size_t addrlen; };/* --
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 08/10] lockd: struct nlm_reboot should contain a full socket address
Quoted 15 lines · Chuck Lever
Quoted 14 lines · J. Bruce Fields
Quoted 8 lines · Chuck Lever
The XDR decoders for the NSM NOTIFY procedure should construct a full socket address and store it in the
nlm_rebootstructure. In addition to being able to store larger addresses, this means upper layer routines get an address family tag so they can distinguish betweenAF_INETandAF_INET6addresses.This also keeps potentially large socket addresses off the stack and instead in dynamically allocated storage.
So one way to think of this would be that you're extending the kernel<->statd interface by using the address family of statd's notify call to communicate the address family of the host that rebooted.
Quoted 6 lines
Quoted 1 line
Do I have that right?
For statd, we're using the same technique that we used when constructing the source address in
nlmsvc_lookup_host(). There's no family tag associated with the address because the 16-byte opaque in the on-the-wire format has room only for thesin6_addrpart of the address.
OK. It seems a bit tricky, but I can't see why it doesn't work.
--b.
Quoted 202 lines
The notification downcall for IPv6 peers has to come via IPv6 loopback for this to work.
Quoted 191 lines
--b.
Quoted 173 lines
Signed-off-by Chuck Lever <[email protected]>---
fs/lockd/svc4proc.c | 10 +--------- fs/lockd/svcproc.c | 10 +--------- fs/lockd/xdr.c | 28 ++++++++++++++++++++++++++-- fs/lockd/xdr4.c | 27 +++++++++++++++++++++++++-- include/linux/lockd/xdr.h | 3 ++- 5 files changed, 55 insertions(+), 23 deletions(-)fs/lockd/svc4proc.c +0
-0@@ -430,8 +430,6 @@ static __be32nlm4svc_proc_sm_notify(struct
svc_rqst*rqstp, structnlm_reboot*argp,
void *resp)
{fs/lockd/svc4proc.c +0
-2-struct sockaddr_in saddr; -dprintk("lockd: SM_NOTIFY called\n"); if (!nlm_privileged_requester(rqstp)) {fs/lockd/svc4proc.c +1
-7@@ -441,13 +439,7 @@ nlm4svc_proc_sm_notify(struct svc_rqst *rqstp,struct nlm_reboot *argp, return rpc_system_err; } -/* Obtain the host pointer for this NFS server and try to -* reclaim all locks we hold on this server. -*/ -memset (&saddr,0 ,sizeof (saddr)); - saddr.sin_family =AF_INET ; - saddr.sin_addr.s_addr = argp->addr; -nlm_host_rebooted ((struct sockaddr *)&saddr,sizeof (saddr), +nlm_host_rebooted ((struct sockaddr *)&argp->addr, argp->addrlen, argp->mon, argp->len, argp->state);return rpc_success;fs/lockd/svcproc.c +0
-0@@ -462,8 +462,6 @@ static __be32nlmsvc_proc_sm_notify(struct
svc_rqst*rqstp, structnlm_reboot*argp,
void *resp)
{fs/lockd/svcproc.c +0
-2-struct sockaddr_in saddr; -dprintk("lockd: SM_NOTIFY called\n"); if (!nlm_privileged_requester(rqstp)) {fs/lockd/svcproc.c +1
-7@@ -473,13 +471,7 @@ nlmsvc_proc_sm_notify(struct svc_rqst *rqstp,struct nlm_reboot *argp, return rpc_system_err; } -/* Obtain the host pointer for this NFS server and try to -* reclaim all locks we hold on this server. -*/ -memset (&saddr,0 ,sizeof (saddr)); - saddr.sin_family =AF_INET ; - saddr.sin_addr.s_addr = argp->addr; -nlm_host_rebooted ((struct sockaddr *)&saddr,sizeof (saddr), +nlm_host_rebooted ((struct sockaddr *)&argp->addr, argp->addrlen, argp->mon, argp->len, argp->state);return rpc_success;fs/lockd/xdr.c +1
-0@@ -9,6 +9,7 @@#include <linux/types.h> #include <linux/sched.h> #include <linux/utsname.h> +#include <linux/in.h> #include <linux/nfs.h> #include <linux/sunrpc/xdr.h> @@ -346,11 +347,34 @@ nlmsvc_decode_notify(struct svc_rqst *rqstp, __be32 *p, struct nlm_args *argp)int
nlmsvc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp)
{fs/lockd/xdr.c +3
-0+struct sockaddr_in *sin = (struct sockaddr_in *)&argp->addr; +struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&argp->addr; +if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN))) return 0; argp->state = ntohl(*p++);fs/lockd/xdr.c +22
-2-/* Preserve the address in network byte order */ - argp->addr = *p++; + +/* Decode the 16-byte private field */ +memset (&argp->addr,0 ,sizeof (argp->addr)); +switch (svc_addr (rqstp)->sa_family) { +case AF_INET : +/* data in recv buffer is already in network byte order */ + sin->sin_family =AF_INET ; + sin->sin_addr.s_addr = *p++; + argp->addrlen =sizeof (*sin); +break ; +case AF_INET6 : + sin6->sin6_family =AF_INET6 ; + sin6->sin6_addr.s6_addr32[0 ] = *p++; + sin6->sin6_addr.s6_addr32[1 ] = *p++; + sin6->sin6_addr.s6_addr32[2 ] = *p++; + sin6->sin6_addr.s6_addr32[3 ] = *p++; + argp->addrlen =sizeof (*sin6); +break ; +default : +return -EIO ; + } +return xdr_argsize_check(rqstp, p); }fs/lockd/xdr4.c +0
-0@@ -353,11 +353,34 @@ nlm4svc_decode_notify(struct svc_rqst *rqstp, __be32 *p, struct nlm_args *argp)int
nlm4svc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp)
{fs/lockd/xdr4.c +3
-0+struct sockaddr_in *sin = (struct sockaddr_in *)&argp->addr; +struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&argp->addr; +if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN))) return 0; argp->state = ntohl(*p++);fs/lockd/xdr4.c +22
-2-/* Preserve the address in network byte order */ - argp->addr = *p++; + +/* Decode the 16-byte private field */ +memset (&argp->addr,0 ,sizeof (argp->addr)); +switch (svc_addr (rqstp)->sa_family) { +case AF_INET : +/* address in recv buffer is already in network byte order */ + sin->sin_family =AF_INET ; + sin->sin_addr.s_addr = *p++; + argp->addrlen =sizeof (*sin); +break ; +case AF_INET6 : + sin6->sin6_family =AF_INET6 ; + sin6->sin6_addr.s6_addr32[0 ] = *p++; + sin6->sin6_addr.s6_addr32[1 ] = *p++; + sin6->sin6_addr.s6_addr32[2 ] = *p++; + sin6->sin6_addr.s6_addr32[3 ] = *p++; + argp->addrlen =sizeof (*sin6); +break ; +default : +return -EIO ; + } +return xdr_argsize_check(rqstp, p); }include/linux/lockd/xdr.h +0
-0include/linux/lockd/xdr.h struct nlm_reboot { · line 87
Quoted 9 lines
include/linux/lockd/xdr.h +2
-1@@ -80,7 +80,8 @@ struct nlm_reboot {char * mon;unsigned int len;u32 state; -__be32 addr; +struct sockaddr_storage addr; +size_t addrlen; };/* --
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlSignature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 08/10] lockd: struct nlm_reboot should contain a full socket address
Quoted 16 lines · J. Bruce Fields
Quoted 15 lines · Chuck Lever
Quoted 14 lines · J. Bruce Fields
Quoted 8 lines · Chuck Lever
The XDR decoders for the NSM NOTIFY procedure should construct a full socket address and store it in the
nlm_rebootstructure. In addition to being able to store larger addresses, this means upper layer routines get an address family tag so they can distinguish betweenAF_INETandAF_INET6addresses.This also keeps potentially large socket addresses off the stack and instead in dynamically allocated storage.
So one way to think of this would be that you're extending the kernel<->statd interface by using the address family of statd's notify call to communicate the address family of the host that rebooted.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Do I have that right?
For statd, we're using the same technique that we used when constructing the source address in
nlmsvc_lookup_host(). There's no family tag associated with the address because the 16-byte opaque in the on-the-wire format has room only for thesin6_addrpart of the address.OK. It seems a bit tricky, but I can't see why it doesn't work.
Right. I couldn't think of something simpler.
rpc.statd has to continue to work with legacy kernels where the first 4 bytes of the opaque are a 32-bit sin_addr field and the following 12 bytes are zero. Apparently you can have a valid IPv6 address that looks like that, but I can't find anything that states this conclusively.
The kernel needs to know the address family in order to interpret the contents of the opaque and turn them back into a sockaddr so it can be matched against an nlm_host.
Quoted 202 lines
Quoted 202 lines
The notification downcall for IPv6 peers has to come via IPv6 loopback for this to work.
Quoted 191 lines
--b.
Quoted 173 lines
Signed-off-by Chuck Lever <[email protected]>---
fs/lockd/svc4proc.c | 10 +--------- fs/lockd/svcproc.c | 10 +--------- fs/lockd/xdr.c | 28 ++++++++++++++++++++++++++-- fs/lockd/xdr4.c | 27 +++++++++++++++++++++++++-- include/linux/lockd/xdr.h | 3 ++- 5 files changed, 55 insertions(+), 23 deletions(-)fs/lockd/svc4proc.c +0
-0@@ -430,8 +430,6 @@ static __be32nlm4svc_proc_sm_notify(struct
svc_rqst*rqstp, structnlm_reboot*argp,
void *resp)
{fs/lockd/svc4proc.c +0
-2-struct sockaddr_in saddr; -dprintk("lockd: SM_NOTIFY called\n"); if (!nlm_privileged_requester(rqstp)) {fs/lockd/svc4proc.c +1
-7@@ -441,13 +439,7 @@ nlm4svc_proc_sm_notify(struct svc_rqst *rqstp,struct nlm_reboot *argp, return rpc_system_err; } -/* Obtain the host pointer for this NFS server and try to -* reclaim all locks we hold on this server. -*/ -memset (&saddr,0 ,sizeof (saddr)); - saddr.sin_family =AF_INET ; - saddr.sin_addr.s_addr = argp->addr; -nlm_host_rebooted ((struct sockaddr *)&saddr,sizeof (saddr), +nlm_host_rebooted ((struct sockaddr *)&argp->addr, argp->addrlen, argp->mon, argp->len, argp->state);return rpc_success;fs/lockd/svcproc.c +0
-0@@ -462,8 +462,6 @@ static __be32nlmsvc_proc_sm_notify(struct
svc_rqst*rqstp, structnlm_reboot*argp,
void *resp)
{fs/lockd/svcproc.c +0
-2-struct sockaddr_in saddr; -dprintk("lockd: SM_NOTIFY called\n"); if (!nlm_privileged_requester(rqstp)) {fs/lockd/svcproc.c +1
-7@@ -473,13 +471,7 @@ nlmsvc_proc_sm_notify(struct svc_rqst *rqstp,struct nlm_reboot *argp, return rpc_system_err; } -/* Obtain the host pointer for this NFS server and try to -* reclaim all locks we hold on this server. -*/ -memset (&saddr,0 ,sizeof (saddr)); - saddr.sin_family =AF_INET ; - saddr.sin_addr.s_addr = argp->addr; -nlm_host_rebooted ((struct sockaddr *)&saddr,sizeof (saddr), +nlm_host_rebooted ((struct sockaddr *)&argp->addr, argp->addrlen, argp->mon, argp->len, argp->state);return rpc_success;fs/lockd/xdr.c +1
-0@@ -9,6 +9,7 @@#include <linux/types.h> #include <linux/sched.h> #include <linux/utsname.h> +#include <linux/in.h> #include <linux/nfs.h> #include <linux/sunrpc/xdr.h> @@ -346,11 +347,34 @@ nlmsvc_decode_notify(struct svc_rqst *rqstp, __be32 *p, struct nlm_args *argp)int
nlmsvc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp)
{fs/lockd/xdr.c +3
-0+struct sockaddr_in *sin = (struct sockaddr_in *)&argp->addr; +struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&argp->addr; +if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN))) return 0; argp->state = ntohl(*p++);fs/lockd/xdr.c +22
-2-/* Preserve the address in network byte order */ - argp->addr = *p++; + +/* Decode the 16-byte private field */ +memset (&argp->addr,0 ,sizeof (argp->addr)); +switch (svc_addr (rqstp)->sa_family) { +case AF_INET : +/* data in recv buffer is already in network byte order */ + sin->sin_family =AF_INET ; + sin->sin_addr.s_addr = *p++; + argp->addrlen =sizeof (*sin); +break ; +case AF_INET6 : + sin6->sin6_family =AF_INET6 ; + sin6->sin6_addr.s6_addr32[0 ] = *p++; + sin6->sin6_addr.s6_addr32[1 ] = *p++; + sin6->sin6_addr.s6_addr32[2 ] = *p++; + sin6->sin6_addr.s6_addr32[3 ] = *p++; + argp->addrlen =sizeof (*sin6); +break ; +default : +return -EIO ; + } +return xdr_argsize_check(rqstp, p); }fs/lockd/xdr4.c +0
-0@@ -353,11 +353,34 @@ nlm4svc_decode_notify(struct svc_rqst *rqstp, __be32 *p, struct nlm_args *argp)int
nlm4svc_decode_reboot(struct svc_rqst *rqstp, __be32 *p, struct nlm_reboot *argp)
{fs/lockd/xdr4.c +3
-0+struct sockaddr_in *sin = (struct sockaddr_in *)&argp->addr; +struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&argp->addr; +if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN))) return 0; argp->state = ntohl(*p++);fs/lockd/xdr4.c +22
-2-/* Preserve the address in network byte order */ - argp->addr = *p++; + +/* Decode the 16-byte private field */ +memset (&argp->addr,0 ,sizeof (argp->addr)); +switch (svc_addr (rqstp)->sa_family) { +case AF_INET : +/* address in recv buffer is already in network byte order */ + sin->sin_family =AF_INET ; + sin->sin_addr.s_addr = *p++; + argp->addrlen =sizeof (*sin); +break ; +case AF_INET6 : + sin6->sin6_family =AF_INET6 ; + sin6->sin6_addr.s6_addr32[0 ] = *p++; + sin6->sin6_addr.s6_addr32[1 ] = *p++; + sin6->sin6_addr.s6_addr32[2 ] = *p++; + sin6->sin6_addr.s6_addr32[3 ] = *p++; + argp->addrlen =sizeof (*sin6); +break ; +default : +return -EIO ; + } +return xdr_argsize_check(rqstp, p); }include/linux/lockd/xdr.h +0
-0include/linux/lockd/xdr.h struct nlm_reboot { · line 87
Quoted 9 lines
include/linux/lockd/xdr.h +2
-1@@ -80,7 +80,8 @@ struct nlm_reboot {char * mon;unsigned int len;u32 state; -__be32 addr; +struct sockaddr_storage addr; +size_t addrlen; };/* --
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlSignature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
Signature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 08/10] lockd: struct nlm_reboot should contain a full socket address
Quoted 30 lines · Chuck Lever
Quoted 29 lines · J. Bruce Fields
Quoted 27 lines · Chuck Lever
Quoted 13 lines · J. Bruce Fields
Quoted 11 lines · Chuck Lever
The XDR decoders for the NSM NOTIFY procedure should construct a full
socket address and store it in thenlm_rebootstructure. In addition
to being able to store larger addresses, this means upper layer routines get an address family tag so they can distinguish betweenAF_INETandAF_INET6addresses.This also keeps potentially large socket addresses off the stack and
instead in dynamically allocated storage.Quoted 6 lines
So one way to think of this would be that you're extending the kernel<->statd interface by using the address family of statd's notify
call to communicate the address family of the host that rebooted.Do I have that right?
For statd, we're using the same technique that we used when constructing
the source address innlmsvc_lookup_host(). There's no family tag associated with the address because the 16-byte opaque in the on- the-wire
format has room only for thesin6_addrpart of the address.
Quoted 7 lines
Quoted 1 line
OK. It seems a bit tricky, but I can't see why it doesn't work.
Right. I couldn't think of something simpler.
rpc.statd has to continue to work with legacy kernels where the first 4 bytes of the opaque are a 32-bit
sin_addrfield and the following 12 bytes are zero.
Wait a minute, there's something not right there: rpc.statd shouldn't interpret the contents of the opaque field at all, should it?
--b.
Quoted 7 lines
Apparently you can have a valid IPv6 address that looks like that, but I can't find anything that states this conclusively.
The kernel needs to know the address family in order to interpret the contents of the opaque and turn them back into a sockaddr so it can be matched against an
nlm_host.
Re: [PATCH 08/10] lockd: struct nlm_reboot should contain a full socket address
Quoted 33 lines · bfields
Quoted 32 lines · Chuck Lever
Quoted 30 lines · J. Bruce Fields
Quoted 19 lines · Chuck Lever
Quoted 18 lines · J. Bruce Fields
Quoted 11 lines · Chuck Lever
The XDR decoders for the NSM NOTIFY procedure should construct a full
socket address and store it in thenlm_rebootstructure. In addition
to being able to store larger addresses, this means upper layer routines get an address family tag so they can distinguish betweenAF_INETandAF_INET6addresses.This also keeps potentially large socket addresses off the stack and
instead in dynamically allocated storage.So one way to think of this would be that you're extending the kernel<->statd interface by using the address family of statd's notify
call to communicate the address family of the host that rebooted.Quoted 8 lines
Quoted 1 line
Do I have that right?
For statd, we're using the same technique that we used when constructing
the source address innlmsvc_lookup_host(). There's no family tag associated with the address because the 16-byte opaque in the on- the-wire
format has room only for thesin6_addrpart of the address.OK. It seems a bit tricky, but I can't see why it doesn't work.
Quoted 8 lines
Quoted 5 lines
Right. I couldn't think of something simpler.
rpc.statd has to continue to work with legacy kernels where the first 4 bytes of the opaque are a 32-bit
sin_addrfield and the following 12 bytes are zero.Wait a minute, there's something not right there: rpc.statd shouldn't interpret the contents of the opaque field at all, should it?
And from a quick look at nfs-utils/statd/ it certainly looks to me like it's correctly treating the contents as a totally opaque object.
So I think we can put whatever we want in the priv field--an ipv6 address, an index into some kernel table, whatever. (The priv field shouldn't even have to make sense to a future boot instance--we don't need to be notified of previously monitored hosts' reboots any more once we've rebooted ourselves.)
--b.
Re: [PATCH 08/10] lockd: struct nlm_reboot should contain a full socket address
Quoted 40 lines · J. Bruce Fields
Quoted 39 lines · bfields
Quoted 37 lines · Chuck Lever
Quoted 22 lines · J. Bruce Fields
Quoted 21 lines · Chuck Lever
Quoted 19 lines · J. Bruce Fields
Quoted 11 lines · Chuck Lever
The XDR decoders for the NSM NOTIFY procedure should construct a full
socket address and store it in thenlm_rebootstructure. In addition
to being able to store larger addresses, this means upper layer routines get an address family tag so they can distinguish betweenAF_INETandAF_INET6addresses.This also keeps potentially large socket addresses off the stack and
instead in dynamically allocated storage.So one way to think of this would be that you're extending the kernel<->statd interface by using the address family of statd's notify
call to communicate the address family of the host that rebooted.Do I have that right?
Quoted 8 lines
Quoted 6 lines
For statd, we're using the same technique that we used when constructing
the source address innlmsvc_lookup_host(). There's no family tag associated with the address because the 16-byte opaque in the on- the-wire
format has room only for thesin6_addrpart of the address.OK. It seems a bit tricky, but I can't see why it doesn't work.
Right. I couldn't think of something simpler.
rpc.statd has to continue to work with legacy kernels where the first 4 bytes of the opaque are a 32-bit
sin_addrfield and the following 12 bytes are zero.
Quoted 5 lines
Quoted 2 lines
Wait a minute, there's something not right there: rpc.statd shouldn't interpret the contents of the opaque field at all, should it?
And from a quick look at nfs-utils/statd/ it certainly looks to me like it's correctly treating the contents as a totally opaque object.
That's exactly what happens. The cookie field is generated by the SM_MON upcall, and passed back by the SM_NOTIFY downcall.
Quoted 5 lines
So I think we can put whatever we want in the priv field--an ipv6 address, an index into some kernel table, whatever. (The priv field shouldn't even have to make sense to a future boot instance--we don't need to be notified of previously monitored hosts' reboots any more once we've rebooted ourselves.)
Apparently, then, rpc.statd doesn't have enough knowledge to make the downcall via IPv6 when needed. Everything we need to look up the host must be encoded into the 16-byte opaque field.
I'll look into it.
Signature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 08/10] lockd: struct nlm_reboot should contain a full socket address
Quoted 7 lines · Chuck Lever
Quoted 3 lines · J. Bruce Fields
And from a quick look at nfs-utils/statd/ it certainly looks to me like
it's correctly treating the contents as a totally opaque object.That's exactly what happens. The cookie field is generated by the
SM_MONupcall, and passed back by theSM_NOTIFYdowncall.
OK, that's great. So we can just
- Choose whatever contents for the "priv"/cookie field we want to keep the lookup on receipt of SM_NOTIFY easy, and
- remove the support for ipv6 on the loopback communication with statd; we don't need it.
Quoted 7 lines
Quoted 6 lines
So I think we can put whatever we want in the priv field--an ipv6 address, an index into some kernel table, whatever. (The priv field shouldn't even have to make sense to a future boot instance--we don't need to be notified of previously monitored hosts' reboots any more once
we've rebooted ourselves.)
Quoted 5 lines
Apparently, then, rpc.statd doesn't have enough knowledge to make the downcall via IPv6 when needed. Everything we need to look up the host must be encoded into the 16-byte opaque field.
I'll look into it.
Thanks!
--b.
Re: [PATCH 08/10] lockd: struct nlm_reboot should contain a full socket address
Quoted 9 lines · J. Bruce Fields
Quoted 7 lines · Chuck Lever
Quoted 3 lines · J. Bruce Fields
And from a quick look at nfs-utils/statd/ it certainly looks to me like
it's correctly treating the contents as a totally opaque object.That's exactly what happens. The cookie field is generated by the
SM_MONupcall, and passed back by theSM_NOTIFYdowncall.
Quoted 6 lines
OK, that's great. So we can just
- Choose whatever contents for the "priv"/cookie field we want to keep the lookup on receipt of
SM_NOTIFYeasy, and
- remove the support for ipv6 on the loopback communication with statd; we don't need it.
I agree that since lockd generates the cookies, we can be smarter about how lockd deals with cookies coming back from statd, and I strongly prefer an approach that treats the opaques as arbitrary rather than interpreted values.
I think we may need to keep some IPv6 support in lockd for loopback down calls. On an AF_INET6 listener socket, loopback calls will come from the IPv6 loopback address, AFAICT, even if they are sent from user space via the IPv4 loopback address. The kernel's network layer will map the IPv4 loopback address to the IPv6 loopback address automatically.
I am working on revising last week's patch set based on your comments. I plan to repost an updated version of these soon, but I can leave out the last two or three patches that deal solely with the mechanics of these NSM-related cookies.
Quoted 16 lines
Quoted 7 lines
Quoted 6 lines
So I think we can put whatever we want in the priv field--an ipv6 address, an index into some kernel table, whatever. (The priv field shouldn't even have to make sense to a future boot instance--we don't need to be notified of previously monitored hosts' reboots any more once
we've rebooted ourselves.)Quoted 5 lines
Apparently, then, rpc.statd doesn't have enough knowledge to make the downcall via IPv6 when needed. Everything we need to look up the host must be encoded into the 16-byte opaque field.
I'll look into it.
Thanks!
--b.
Signature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 08/10] lockd: struct nlm_reboot should contain a full socket address
Quoted 24 lines · Chuck Lever
Quoted 9 lines · J. Bruce Fields
Quoted 7 lines · Chuck Lever
Quoted 3 lines · J. Bruce Fields
And from a quick look at nfs-utils/statd/ it certainly looks to me like
it's correctly treating the contents as a totally opaque object.That's exactly what happens. The cookie field is generated by the
SM_MONupcall, and passed back by theSM_NOTIFYdowncall.Quoted 6 lines
OK, that's great. So we can just
- Choose whatever contents for the "priv"/cookie field we want to keep the lookup on receipt of
SM_NOTIFYeasy, and
- remove the support for ipv6 on the loopback communication with statd; we don't need it.I agree that since lockd generates the cookies, we can be smarter about how lockd deals with cookies coming back from statd, and I strongly prefer an approach that treats the opaques as arbitrary rather than interpreted values.
Quoted 5 lines
I think we may need to keep some IPv6 support in lockd for loopback down calls. On an
AF_INET6listener socket, loopback calls will come from the IPv6 loopback address, AFAICT, even if they are sent from user space via the IPv4 loopback address. The kernel's network layer will map the IPv4 loopback address to the IPv6 loopback address automatically.
OK. (Well, I guess we could do whatever we'd like here, including using a separate socket and even program for the notification downcall, but doing what you propose is probably simplest.)
Quoted 4 lines
I am working on revising last week's patch set based on your comments. I plan to repost an updated version of these soon, but I can leave out the last two or three patches that deal solely with the mechanics of these NSM-related cookies.
Sounds fine, thanks!
--b.
Re: [PATCH 08/10] lockd: struct nlm_reboot should contain a full socket address
In reply to J. Bruce FieldsQuoted 33 lines · J. Bruce Fields
Quoted 32 lines · Chuck Lever
Quoted 30 lines · J. Bruce Fields
Quoted 19 lines · Chuck Lever
Quoted 18 lines · J. Bruce Fields
Quoted 11 lines · Chuck Lever
The XDR decoders for the NSM NOTIFY procedure should construct a full
socket address and store it in thenlm_rebootstructure. In addition
to being able to store larger addresses, this means upper layer routines get an address family tag so they can distinguish betweenAF_INETandAF_INET6addresses.This also keeps potentially large socket addresses off the stack and
instead in dynamically allocated storage.So one way to think of this would be that you're extending the kernel<->statd interface by using the address family of statd's notify
call to communicate the address family of the host that rebooted.Quoted 8 lines
Quoted 1 line
Do I have that right?
For statd, we're using the same technique that we used when constructing
the source address innlmsvc_lookup_host(). There's no family tag associated with the address because the 16-byte opaque in the on- the-wire
format has room only for thesin6_addrpart of the address.OK. It seems a bit tricky, but I can't see why it doesn't work.
Quoted 8 lines
Quoted 5 lines
Right. I couldn't think of something simpler.
rpc.statd has to continue to work with legacy kernels where the first 4 bytes of the opaque are a 32-bit
sin_addrfield and the following 12 bytes are zero.Wait a minute, there's something not right there: rpc.statd shouldn't interpret the contents of the opaque field at all, should it?
Yes, our rpc.statd and lockd should agree on the contents and interpretation of the opaque field. The field is opaque because it's internal content is not defined by a standard. It's a cookie, just like a file handle.
I would certainly *prefer* the use of an entirely arbitrary cookie, but that's not the way Linux happens to work today.
Quoted 6 lines
Quoted 6 lines
Apparently you can have a valid IPv6 address that looks like that, but I can't find anything that states this conclusively.
The kernel needs to know the address family in order to interpret the contents of the opaque and turn them back into a sockaddr so it can be matched against an
nlm_host.
Signature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 08/10] lockd: struct nlm_reboot should contain a full socket address
Quoted 12 lines · Chuck Lever
Quoted 10 lines · J. Bruce Fields
Quoted 6 lines · Chuck Lever
Right. I couldn't think of something simpler.
rpc.statd has to continue to work with legacy kernels where the first 4
bytes of the opaque are a 32-bitsin_addrfield and the following 12 bytes are zero.Wait a minute, there's something not right there: rpc.statd shouldn't interpret the contents of the opaque field at all, should it?
Quoted 7 lines
Yes, our rpc.statd and lockd should agree on the contents and interpretation of the opaque field. The field is opaque because it's internal content is not defined by a standard. It's a cookie, just like a file handle.
I would certainly *prefer* the use of an entirely arbitrary cookie, but that's not the way Linux happens to work today.
I'm pretty certain it does--at least on the rpc.statd size. (Any evidence to the contrary.) Sure, it means something to the kernel, but that's just for the kernel's convenience. We can do whatever we want in the kernel.
--b.
Re: [PATCH 08/10] lockd: struct nlm_reboot should contain a full socket address
Quoted 18 lines · bfields
Quoted 17 lines · Chuck Lever
Quoted 10 lines · J. Bruce Fields
Quoted 6 lines · Chuck Lever
Right. I couldn't think of something simpler.
rpc.statd has to continue to work with legacy kernels where the first 4
bytes of the opaque are a 32-bitsin_addrfield and the following 12 bytes are zero.Wait a minute, there's something not right there: rpc.statd shouldn't interpret the contents of the opaque field at all, should it?
Yes, our rpc.statd and lockd should agree on the contents and interpretation of the opaque field. The field is opaque because it's internal content is not defined by a standard. It's a cookie, just like a file handle.
Quoted 5 lines
Quoted 2 lines
I would certainly *prefer* the use of an entirely arbitrary cookie, but that's not the way Linux happens to work today.
I'm pretty certain it does--at least on the rpc.statd size. (Any evidence to the contrary.) Sure, it means something to the kernel, but
(Err, I think that parenthetical remark was meant to be a question. Apologies.)
Quoted 4 lines
that's just for the kernel's convenience. We can do whatever we want in the kernel.
--b.
PATCH 9/10 lockd: IPv6 support for SM_MON / SM_UNMON
In reply to a message not in the archiveWiden the field that stores addresses in the nsm_args structure to handle non-AF_INET addresses, and adjust NSM XDR routines to handle AF_INET6 family addresses.
---
fs/lockd/mon.c | 76 +++++++++++++++++++++++++++++++--------- include/linux/lockd/sm_inter.h | 2 + 2 files changed, 59 insertions(+), 19 deletions(-)
fs/lockd/mon.c +58 -18
@@ -18,7 +18,7 @@#define NLMDBG_FACILITY NLMDBG_MONITOR -#define XDR_ADDRBUF_LEN (20) +#define XDR_ADDRBUF_LEN (48)static struct rpc_clnt *nsm_create (void );
@@ -37,7 +37,12 @@ nsm_mon_unmon(struct nsm_handle *nsm, u32 proc, struct nsm_res *res) {struct rpc_clnt *clnt;int status; -struct nsm_args args; +struct nsm_args args = { + .prog =NLM_PROGRAM , + .vers =3 , + .proc =NLMPROC_NSM_NOTIFY , + .mon_name = nsm->sm_name, + };struct rpc_message msg = { .rpc_argp = &args, .rpc_resp = res,
@@ -46,21 +51,18 @@ nsm_mon_unmon(struct nsm_handle *nsm, u32 proc, struct nsm_res *res) clnt =nsm_create ();if (IS_ERR (clnt)) { status =PTR_ERR (clnt); +printk (KERN_NOTICE "nsm_mon_unmon: failed to create transport, " +"status=%d\n" , status); goto out; } -memset (&args,0 ,sizeof (args)); - args.mon_name = nsm->sm_name; - args.addr =nsm_addr_in (nsm)->sin_addr.s_addr; - args.prog =NLM_PROGRAM ; - args.vers =3 ; - args.proc =NLMPROC_NSM_NOTIFY ; +memcpy (&args.addr,nsm_addr (nsm), nsm->sm_addrlen);memset (res,0 ,sizeof (*res)); msg.rpc_proc = &clnt->cl_procinfo[proc]; status =rpc_call_sync (clnt, &msg,0 );if (status <0 ) -printk (KERN_DEBUG "nsm_mon_unmon: rpc failed, status=%d\n" , +printk (KERN_NOTICE "nsm_mon_unmon: rpc failed, status=%d\n" , status);else status =0 ;
@@ -174,14 +176,30 @@ static __be32 *xdr_encode_nsm_string(__be32 *p, char *string)*/ static __be32 *xdr_encode_mon_name (__be32 *p,struct nsm_args *argp) { -char buffer[XDR_ADDRBUF_LEN +1 ]; -char *name = argp->mon_name; +char *name, buffer[XDR_ADDRBUF_LEN +1 ];if (!nsm_use_hostnames) { -snprintf (buffer,XDR_ADDRBUF_LEN , -NIPQUAD_FMT ,NIPQUAD (argp->addr)); +const struct sockaddr_storage *ssp = &argp->addr; +const struct sockaddr_in *sin = (struct sockaddr_in *)ssp; +const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)ssp; + +switch (ssp->ss_family) { +case AF_INET : +snprintf (buffer,XDR_ADDRBUF_LEN ,NIPQUAD_FMT , +NIPQUAD (sin->sin_addr.s_addr)); +break ; +case AF_INET6 : +snprintf (buffer,XDR_ADDRBUF_LEN ,NIP6_FMT , +NIP6 (sin6->sin6_addr)); +break ; +default : +printk (KERN_NOTICE "%s: unsupported address family " +"(%u)\n" , __func__, ssp->ss_family); +return ERR_PTR (-EIO ); + } name = buffer; - } + }else + name = argp->mon_name;return xdr_encode_nsm_string (p, name); }
@@ -225,13 +243,35 @@ static __be32 *xdr_encode_mon_id(__be32 *p, struct nsm_args *argp)* * Linux provides the raw IP address of the monitored host, * left in network byte order. +* +* We should send only AF_INET6 addresses in this field if the +* underlying transport is IPv6, and only AF_INET addresses if +* the underlying transport is IPv4. */ static __be32 *xdr_encode_priv (__be32 *p,struct nsm_args *argp) { - *p++ = argp->addr; - *p++ =0 ; - *p++ =0 ; - *p++ =0 ; +const struct sockaddr_storage *ssp = &argp->addr; +const struct sockaddr_in *sin = (struct sockaddr_in *)ssp; +const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)ssp; + +switch (ssp->ss_family) { +case AF_INET : + *p++ = sin->sin_addr.s_addr; + *p++ =0 ; + *p++ =0 ; + *p++ =0 ; +break ; +case AF_INET6 : + *p++ = sin6->sin6_addr.s6_addr32[0 ]; + *p++ = sin6->sin6_addr.s6_addr32[1 ]; + *p++ = sin6->sin6_addr.s6_addr32[2 ]; + *p++ = sin6->sin6_addr.s6_addr32[3 ]; +break ; +default : +printk (KERN_NOTICE "%s: unsupported address family (%u)\n" , + __func__, ssp->ss_family); +return ERR_PTR (-EIO ); + }return p; }
include/linux/lockd/sm_inter.h +1 -1
@@ -25,7 +25,7 @@* Arguments for all calls to statd */ struct nsm_args { -__be32 addr;/* remote address */ +struct sockaddr_storage addr;/* remote address */ u32 prog;/* RPC callback info */ u32 vers;u32 proc;
PATCH 10/10 lockd: Use "unsigned short" for lockd_up() "proto" argument
In reply to a message not in the archiveClean up. Use conventional data type for transport argument to the lockd_up() function.
---
fs/lockd/svc.c | 5 ++--- include/linux/lockd/bind.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-)
fs/lockd/svc.c +2 -3
@@ -207,7 +207,7 @@ lockd(void *vrqstp)* If nlm_udpport or nlm_tcpport were set as module * options, make those sockets unconditionally */ -static int make_socks (struct svc_serv *serv,int proto) +static int make_socks (struct svc_serv *serv,const unsigned short proto) {static int warned;struct svc_xprt *xprt;
@@ -241,8 +241,7 @@ static int make_socks(struct svc_serv *serv, int proto)/* * Bring up the lockd process if it's not already up. */ -int -lockd_up (int proto)/* Maybe add a 'family' option when IPv6 is supported ?? */ +int lockd_up (const unsigned short proto) {struct svc_serv *serv;int error =0 ;
include/linux/lockd/bind.h +1 -1
@@ -53,7 +53,7 @@ extern void nlmclnt_done(struct nlm_host *host);extern int nlmclnt_proc (struct nlm_host *host,int cmd,struct file_lock *fl); -extern int lockd_up (int proto); +extern int lockd_up (const unsigned short proto);extern void lockd_down (void );unsigned long get_nfs_grace_period (void );
Quoted 6 lines · Chuck Lever
Hi Bruce-
Here are ten more IPv6 patches for lockd, as requested. There are just a handful of remaining minor IPv6 patches to finish enabling IPv6 in lockd. These can likely wait until we have a complete IPv6 user space implementation.
Thanks, I've read through them all.
Could you just split up those one or two initial patches?
My remaining point of confusion is over just exactly how the interface to statd is going to work. I don't think about statd enough and may just be terribly confused....
--b.
Quoted 34 lines
Please consider these for 2.6.28.
---
Chuck Lever (10):
lockd: Use "unsigned short" forlockd_up()"proto" argument
lockd: IPv6 support forSM_MON/SM_UNMON
lockd: structnlm_rebootshould contain a full socket address
lockd: Remove unused fields in thenlm_rebootstructure
lockd: Add helper to sanity check incoming NOTIFY requests
lockd: Adjust signature ofnlm_host_rebootedto handle non-AF_INET
lockd: changenlmclnt_grant()to take a "struct sockaddr *"
lockd: Adjustnlmsvc_lookup_host()to accomodateAF_INET6addresses
lockd: Adjustnlmclnt_lookup_host()signature to accomodate non-AF_INET
lockd: Support non-AF_INET addresses innlm_lookup_host()fs/lockd/clntlock.c | 10 +- fs/lockd/host.c | 189 ++++++++++++++++++++++++++++------------ fs/lockd/mon.c | 76 ++++++++++++---- fs/lockd/svc.c | 5 - fs/lockd/svc4proc.c | 18 +--- fs/lockd/svcproc.c | 18 +--- fs/lockd/xdr.c | 30 ++++++ fs/lockd/xdr4.c | 29 +++++- include/linux/lockd/bind.h | 2 include/linux/lockd/lockd.h | 63 ++++++++++++- include/linux/lockd/sm_inter.h | 2 include/linux/lockd/xdr.h | 5 - 12 files changed, 315 insertions(+), 132 deletions(-)Signature · 1 line
Chuck Lever