aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2010-07-08 12:54:52 -0400
committerSage Weil <sage@newdream.net>2010-07-09 18:00:18 -0400
commit39139f64e14684cf2370770deb79d929d27cfd9b (patch)
tree7ea80cd49b3afd0816eacf7fbf191647c44d5661 /fs
parentd06dbaf6c2c7187938f3f6745d9e4938a2d0ec47 (diff)
ceph: fix parsing of ipv6 addresses
Check for brackets around the ipv6 address to avoid ambiguity with the port number. Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs')
-rw-r--r--fs/ceph/messenger.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/fs/ceph/messenger.c b/fs/ceph/messenger.c
index e8c5a2d0e88f..3ddef1556457 100644
--- a/fs/ceph/messenger.c
+++ b/fs/ceph/messenger.c
@@ -997,19 +997,32 @@ int ceph_parse_ips(const char *c, const char *end,
997 struct sockaddr_in *in4 = (void *)ss; 997 struct sockaddr_in *in4 = (void *)ss;
998 struct sockaddr_in6 *in6 = (void *)ss; 998 struct sockaddr_in6 *in6 = (void *)ss;
999 int port; 999 int port;
1000 char delim = ',';
1001
1002 if (*p == '[') {
1003 delim = ']';
1004 p++;
1005 }
1000 1006
1001 memset(ss, 0, sizeof(*ss)); 1007 memset(ss, 0, sizeof(*ss));
1002 if (in4_pton(p, end - p, (u8 *)&in4->sin_addr.s_addr, 1008 if (in4_pton(p, end - p, (u8 *)&in4->sin_addr.s_addr,
1003 ',', &ipend)) { 1009 delim, &ipend))
1004 ss->ss_family = AF_INET; 1010 ss->ss_family = AF_INET;
1005 } else if (in6_pton(p, end - p, (u8 *)&in6->sin6_addr.s6_addr, 1011 else if (in6_pton(p, end - p, (u8 *)&in6->sin6_addr.s6_addr,
1006 ',', &ipend)) { 1012 delim, &ipend))
1007 ss->ss_family = AF_INET6; 1013 ss->ss_family = AF_INET6;
1008 } else { 1014 else
1009 goto bad; 1015 goto bad;
1010 }
1011 p = ipend; 1016 p = ipend;
1012 1017
1018 if (delim == ']') {
1019 if (*p != ']') {
1020 dout("missing matching ']'\n");
1021 goto bad;
1022 }
1023 p++;
1024 }
1025
1013 /* port? */ 1026 /* port? */
1014 if (p < end && *p == ':') { 1027 if (p < end && *p == ':') {
1015 port = 0; 1028 port = 0;
@@ -1043,7 +1056,7 @@ int ceph_parse_ips(const char *c, const char *end,
1043 return 0; 1056 return 0;
1044 1057
1045bad: 1058bad:
1046 pr_err("parse_ips bad ip '%s'\n", c); 1059 pr_err("parse_ips bad ip '%.*s'\n", (int)(end - c), c);
1047 return -EINVAL; 1060 return -EINVAL;
1048} 1061}
1049 1062