messenger.c (cdd38c5f1ce4398ec58fec95904b75824daab7b5) | messenger.c (2d7c86a8f9cdce1408c4f3c69d94d007eff2f179) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2#include <linux/ceph/ceph_debug.h> 3 4#include <linux/crc32c.h> 5#include <linux/ctype.h> 6#include <linux/highmem.h> 7#include <linux/inet.h> 8#include <linux/kthread.h> --- 1253 unchanged lines hidden (view full) --- 1262} 1263 1264/* 1265 * Parse an ip[:port] list into an addr array. Use the default 1266 * monitor port if a port isn't specified. 1267 */ 1268int ceph_parse_ips(const char *c, const char *end, 1269 struct ceph_entity_addr *addr, | 1// SPDX-License-Identifier: GPL-2.0 2#include <linux/ceph/ceph_debug.h> 3 4#include <linux/crc32c.h> 5#include <linux/ctype.h> 6#include <linux/highmem.h> 7#include <linux/inet.h> 8#include <linux/kthread.h> --- 1253 unchanged lines hidden (view full) --- 1262} 1263 1264/* 1265 * Parse an ip[:port] list into an addr array. Use the default 1266 * monitor port if a port isn't specified. 1267 */ 1268int ceph_parse_ips(const char *c, const char *end, 1269 struct ceph_entity_addr *addr, |
1270 int max_count, int *count) | 1270 int max_count, int *count, char delim) |
1271{ 1272 int i, ret = -EINVAL; 1273 const char *p = c; 1274 1275 dout("parse_ips on '%.*s'\n", (int)(end-c), c); 1276 for (i = 0; i < max_count; i++) { | 1271{ 1272 int i, ret = -EINVAL; 1273 const char *p = c; 1274 1275 dout("parse_ips on '%.*s'\n", (int)(end-c), c); 1276 for (i = 0; i < max_count; i++) { |
1277 char cur_delim = delim; |
|
1277 const char *ipend; 1278 int port; | 1278 const char *ipend; 1279 int port; |
1279 char delim = ','; | |
1280 1281 if (*p == '[') { | 1280 1281 if (*p == '[') { |
1282 delim = ']'; | 1282 cur_delim = ']'; |
1283 p++; 1284 } 1285 | 1283 p++; 1284 } 1285 |
1286 ret = ceph_parse_server_name(p, end - p, &addr[i], delim, &ipend); | 1286 ret = ceph_parse_server_name(p, end - p, &addr[i], cur_delim, 1287 &ipend); |
1287 if (ret) 1288 goto bad; 1289 ret = -EINVAL; 1290 1291 p = ipend; 1292 | 1288 if (ret) 1289 goto bad; 1290 ret = -EINVAL; 1291 1292 p = ipend; 1293 |
1293 if (delim == ']') { | 1294 if (cur_delim == ']') { |
1294 if (*p != ']') { 1295 dout("missing matching ']'\n"); 1296 goto bad; 1297 } 1298 p++; 1299 } 1300 1301 /* port? */ --- 19 unchanged lines hidden (view full) --- 1321 * addresses. Rather than complicating parsing, set 1322 * to LEGACY and override in build_initial_monmap() 1323 * for mon addresses and ceph_messenger_init() for 1324 * ip option. 1325 */ 1326 addr[i].type = CEPH_ENTITY_ADDR_TYPE_LEGACY; 1327 addr[i].nonce = 0; 1328 | 1295 if (*p != ']') { 1296 dout("missing matching ']'\n"); 1297 goto bad; 1298 } 1299 p++; 1300 } 1301 1302 /* port? */ --- 19 unchanged lines hidden (view full) --- 1322 * addresses. Rather than complicating parsing, set 1323 * to LEGACY and override in build_initial_monmap() 1324 * for mon addresses and ceph_messenger_init() for 1325 * ip option. 1326 */ 1327 addr[i].type = CEPH_ENTITY_ADDR_TYPE_LEGACY; 1328 addr[i].nonce = 0; 1329 |
1329 dout("parse_ips got %s\n", ceph_pr_addr(&addr[i])); | 1330 dout("%s got %s\n", __func__, ceph_pr_addr(&addr[i])); |
1330 1331 if (p == end) 1332 break; | 1331 1332 if (p == end) 1333 break; |
1333 if (*p != ',') | 1334 if (*p != delim) |
1334 goto bad; 1335 p++; 1336 } 1337 1338 if (p != end) 1339 goto bad; 1340 1341 if (count) --- 818 unchanged lines hidden --- | 1335 goto bad; 1336 p++; 1337 } 1338 1339 if (p != end) 1340 goto bad; 1341 1342 if (count) --- 818 unchanged lines hidden --- |