squash into "pnfsd: Correctly set netid to tcp or tcp6 for non-local exports"
Currently, the code looks for ':' using strcspn that requires a null terminated string
while the address buffer isn't null terminated.
Instead, just use strnchr to look for a ':' and if not found assume
it's an IPv4 address, otherwise it's IPv6
Signed-off-by: Benny Halevy <[email protected]>
---
fs/nfsd/nfs4pnfsdlm.c | 9 ++-------
1 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/fs/nfsd/nfs4pnfsdlm.c b/fs/nfsd/nfs4pnfsdlm.c
index abc4d83..d07a6037 100644
--- a/fs/nfsd/nfs4pnfsdlm.c
+++ b/fs/nfsd/nfs4pnfsdlm.c
@@ -328,13 +328,8 @@ static int nfsd4_pnfs_dlm_getdevinfo(struct super_block *sb,
memcpy(daddr->r_addr.data + len, ".8.1", 4);
daddr->r_addr.len = len + 4;
- if (strcspn(daddr->r_addr.data, ":") - 1 == daddr->r_addr.len) {
- daddr->r_netid.data = "tcp";
- daddr->r_netid.len = 3;
- } else {
- daddr->r_netid.data = "tcp6";
- daddr->r_netid.len = 4;
- }
+ daddr->r_netid.data = "tcp6";
+ daddr->r_netid.len = strnchr(daddr->r_addr.data, len, ':') ? 4 : 3;
fdev.fl_device_list[i].fl_multipath_length = 1;
fdev.fl_device_list[i].fl_multipath_list = daddr;
--
1.7.6
Benny, this patch does not fix the issue. Except that now all the
entries list "tcp6". Previously if you recall first data server entry
was correct but others listed tcp6 type with it was suppose to be tcp.
On Tue, Oct 18, 2011 at 8:52 PM, Benny Halevy <[email protected]> wrote:
> squash into "pnfsd: Correctly set netid to tcp or tcp6 for non-local exports"
>
> Currently, the code looks for ':' using strcspn that requires a null terminated string
> while the address buffer isn't null terminated.
>
> Instead, just use strnchr to look for a ':' and if not found assume
> it's an IPv4 address, otherwise it's IPv6
>
> Signed-off-by: Benny Halevy <[email protected]>
> ---
> ?fs/nfsd/nfs4pnfsdlm.c | ? ?9 ++-------
> ?1 files changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/fs/nfsd/nfs4pnfsdlm.c b/fs/nfsd/nfs4pnfsdlm.c
> index abc4d83..d07a6037 100644
> --- a/fs/nfsd/nfs4pnfsdlm.c
> +++ b/fs/nfsd/nfs4pnfsdlm.c
> @@ -328,13 +328,8 @@ static int nfsd4_pnfs_dlm_getdevinfo(struct super_block *sb,
> ? ? ? ? ? ? ? ?memcpy(daddr->r_addr.data + len, ".8.1", 4);
> ? ? ? ? ? ? ? ?daddr->r_addr.len = len + 4;
>
> - ? ? ? ? ? ? ? if (strcspn(daddr->r_addr.data, ":") - 1 == daddr->r_addr.len) {
> - ? ? ? ? ? ? ? ? ? ? ? daddr->r_netid.data = "tcp";
> - ? ? ? ? ? ? ? ? ? ? ? daddr->r_netid.len = 3;
> - ? ? ? ? ? ? ? } else {
> - ? ? ? ? ? ? ? ? ? ? ? daddr->r_netid.data = "tcp6";
> - ? ? ? ? ? ? ? ? ? ? ? daddr->r_netid.len = 4;
> - ? ? ? ? ? ? ? }
> + ? ? ? ? ? ? ? daddr->r_netid.data = "tcp6";
> + ? ? ? ? ? ? ? daddr->r_netid.len = strnchr(daddr->r_addr.data, len, ':') ? 4 : 3;
>
> ? ? ? ? ? ? ? ?fdev.fl_device_list[i].fl_multipath_length = 1;
> ? ? ? ? ? ? ? ?fdev.fl_device_list[i].fl_multipath_list = daddr;
> --
> 1.7.6
>
>
Looks good to me.
-dros
On Oct 18, 2011, at 8:52 PM, Benny Halevy wrote:
> squash into "pnfsd: Correctly set netid to tcp or tcp6 for non-local exports"
>
> Currently, the code looks for ':' using strcspn that requires a null terminated string
> while the address buffer isn't null terminated.
>
> Instead, just use strnchr to look for a ':' and if not found assume
> it's an IPv4 address, otherwise it's IPv6
>
> Signed-off-by: Benny Halevy <[email protected]>
> ---
> fs/nfsd/nfs4pnfsdlm.c | 9 ++-------
> 1 files changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/fs/nfsd/nfs4pnfsdlm.c b/fs/nfsd/nfs4pnfsdlm.c
> index abc4d83..d07a6037 100644
> --- a/fs/nfsd/nfs4pnfsdlm.c
> +++ b/fs/nfsd/nfs4pnfsdlm.c
> @@ -328,13 +328,8 @@ static int nfsd4_pnfs_dlm_getdevinfo(struct super_block *sb,
> memcpy(daddr->r_addr.data + len, ".8.1", 4);
> daddr->r_addr.len = len + 4;
>
> - if (strcspn(daddr->r_addr.data, ":") - 1 == daddr->r_addr.len) {
> - daddr->r_netid.data = "tcp";
> - daddr->r_netid.len = 3;
> - } else {
> - daddr->r_netid.data = "tcp6";
> - daddr->r_netid.len = 4;
> - }
> + daddr->r_netid.data = "tcp6";
> + daddr->r_netid.len = strnchr(daddr->r_addr.data, len, ':') ? 4 : 3;
>
> fdev.fl_device_list[i].fl_multipath_length = 1;
> fdev.fl_device_list[i].fl_multipath_list = daddr;
> --
> 1.7.6
>
> --
> 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
SGksIHRoYW5rcyBmb3IgdGVzdGluZyB0aGUgcGF0Y2ghDQpEbyBhbGwgZW50cmllcyBoYXZlIHJf
bmV0aWQubGVuPT00Pw0KQ2FuIHlvdSBwbGVhc2UgcHJpbnQgcl9hZGRyLmRhdGEgYW5kIHJfYWRk
ci5sZW4/DQoNCkJlbm55DQoNCi0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQpGcm9tOiBPbGdh
IEtvcm5pZXZza2FpYSA8YWdsb0BjaXRpLnVtaWNoLmVkdT4NClNlbmRlcjogb2xnYS5rb3JuaWV2
c2thaWFAZ21haWwuY29tDQpEYXRlOiBNb24sIDMxIE9jdCAyMDExIDE3OjE2OjQxIA0KVG86IEJl
bm55IEhhbGV2eTxiaGFsZXZ5QHRvbmlhbi5jb20+DQpDYzogTWljaGFlbCBHcm9zaGFuczxncm9z
aGFuc0B1bWljaC5lZHU+OyBORlMgbGlzdDxsaW51eC1uZnNAdmdlci5rZXJuZWwub3JnPg0KU3Vi
amVjdDogUmU6IFtQQVRDSF0gcG5mc2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