Cleanup the IPv4 address parsing, and correct the error message.
This commit was SVN r24750.
Этот коммит содержится в:
родитель
6b52d8f519
Коммит
7ebd094ecf
@ -24,7 +24,7 @@ install its own signal handler for this signal by setting the
|
||||
Signal: %d
|
||||
Current opal_signal value: %s
|
||||
*
|
||||
[malformed IP address or netmask]
|
||||
[malformed net_private_ipv4]
|
||||
Open MPI has detected at least one malformed IP address or netmask in
|
||||
the value of the opal_net_private_ipv4 MCA parameter. The
|
||||
opal_net_private_ipv4 MCA parameter accepts a semicolon-delimited list
|
||||
@ -37,16 +37,11 @@ All malformed entries will be ignored; Open MPI will attempt to continue
|
||||
your job. The first detected malformed entry was %s.
|
||||
#
|
||||
[invalid-net-mask]
|
||||
We were unable to parse the provided network interface:
|
||||
Open MPI has detected an malformed IPv4 address or netmask
|
||||
in %s. Accepted values follows the Classless Inter-Domain
|
||||
Routing (CIDR) notation specifications. For example:
|
||||
|
||||
Interface: %s
|
||||
10.0.0.0/8;172.16/12;192.168;169.254.0.0/16
|
||||
|
||||
The interface must be one of the following forms:
|
||||
|
||||
123.456.789.123
|
||||
123.456/16
|
||||
123.456.789
|
||||
|
||||
The system can parse any one of these, and will find an interface
|
||||
that matches within the provided scope. Please revise your input
|
||||
and try again.
|
||||
All malformed entries will be ignored; Open MPI will attempt to continue
|
||||
your job.
|
||||
|
@ -490,29 +490,37 @@ opal_ifislocal(const char *hostname)
|
||||
return false;
|
||||
}
|
||||
|
||||
static uint32_t parse_dots(const char *addr)
|
||||
static uint32_t parse_ipv4_dots(const char *addr, uint32_t* net, int* dots)
|
||||
{
|
||||
char **tuple;
|
||||
const char *start = addr, *end;
|
||||
uint32_t n[]={0,0,0,0};
|
||||
uint32_t net;
|
||||
int i;
|
||||
int i, rc = OPAL_SUCCESS;
|
||||
|
||||
tuple = opal_argv_split(addr, '.');
|
||||
/* now assemble the address */
|
||||
for (i=0; NULL != tuple[i]; i++) {
|
||||
n[i] = strtoul(tuple[i], NULL, 10);
|
||||
for( i = 0; i < 4; i++ ) {
|
||||
n[i] = strtoul(start, (char**)&end, 10);
|
||||
if( end == start ) { /* error case: use what we have so far */
|
||||
rc = OPAL_ERROR;
|
||||
break;
|
||||
}
|
||||
net = OPAL_IF_ASSEMBLE_NETWORK(n[0], n[1], n[2], n[3]);
|
||||
opal_argv_free(tuple);
|
||||
return net;
|
||||
/* skip all the . */
|
||||
for( start = end; '\0' != *start; start++ )
|
||||
if( '.' != *start ) break;
|
||||
/* did we read something sensible? */
|
||||
if( n[i] > 255 ) {
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
}
|
||||
*dots = i;
|
||||
*net = OPAL_IF_ASSEMBLE_NETWORK(n[0], n[1], n[2], n[3]);
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
opal_iftupletoaddr(const char *inaddr, uint32_t *net, uint32_t *mask)
|
||||
{
|
||||
char **tuple;
|
||||
int pval;
|
||||
char *msk, *ptr;
|
||||
int pval, dots, rc = OPAL_SUCCESS;
|
||||
const char *ptr;
|
||||
|
||||
/* if a mask was desired... */
|
||||
if (NULL != mask) {
|
||||
@ -520,19 +528,17 @@ opal_iftupletoaddr(const char *inaddr, uint32_t *net, uint32_t *mask)
|
||||
*mask = 0xFFFFFFFF;
|
||||
|
||||
/* if entry includes mask, split that off */
|
||||
msk = NULL;
|
||||
if (NULL != (ptr = strchr(inaddr, '/'))) {
|
||||
*ptr = '\0';
|
||||
msk = ptr + 1;
|
||||
ptr = ptr + 1; /* skip the / */
|
||||
/* is the mask a tuple? */
|
||||
if (NULL != strchr(msk, '.')) {
|
||||
if (NULL != strchr(ptr, '.')) {
|
||||
/* yes - extract mask from it */
|
||||
*mask = parse_dots(msk);
|
||||
rc = parse_ipv4_dots(ptr, mask, &dots);
|
||||
} else {
|
||||
/* no - must be an int telling us how much of the addr to use: e.g., /16
|
||||
* For more information please read http://en.wikipedia.org/wiki/Subnetwork.
|
||||
*/
|
||||
pval = strtol(msk, NULL, 10);
|
||||
pval = strtol(ptr, NULL, 10);
|
||||
if ((pval > 31) || (pval < 1)) {
|
||||
opal_output(0, "opal_iftupletoaddr: unknown mask");
|
||||
return OPAL_ERROR;
|
||||
@ -541,8 +547,8 @@ opal_iftupletoaddr(const char *inaddr, uint32_t *net, uint32_t *mask)
|
||||
}
|
||||
} else {
|
||||
/* use the number of dots to determine it */
|
||||
tuple = opal_argv_split(inaddr, '.');
|
||||
pval = opal_argv_count(tuple);
|
||||
for( ptr = inaddr, pval = 0; '\0'!= *ptr; ptr++ )
|
||||
if( '.' == *ptr ) pval++;
|
||||
/* if we have three dots, then we have four
|
||||
* fields since it is a full address, so the
|
||||
* default netmask is fine
|
||||
@ -559,24 +565,16 @@ opal_iftupletoaddr(const char *inaddr, uint32_t *net, uint32_t *mask)
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
}
|
||||
opal_argv_free(tuple);
|
||||
}
|
||||
}
|
||||
|
||||
/* if network addr is desired... */
|
||||
if (NULL != net) {
|
||||
/* set default */
|
||||
*net = 0;
|
||||
|
||||
/* if entry includes mask, split that off */
|
||||
if (NULL != (ptr = strchr(inaddr, '/'))) {
|
||||
*ptr = '\0';
|
||||
}
|
||||
/* now assemble the address */
|
||||
*net = parse_dots(inaddr);
|
||||
rc = parse_ipv4_dots(inaddr, net, &dots);
|
||||
}
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -155,9 +155,8 @@ opal_net_init()
|
||||
* get added to the trunk.
|
||||
*/
|
||||
if (0 == found_bad) {
|
||||
opal_output(0, "FOUND BAD!\n");
|
||||
opal_show_help("help-opal-util.txt",
|
||||
"malformed IP address or netmask",
|
||||
"malformed net_private_ipv4",
|
||||
true, args[i]);
|
||||
found_bad = 1;
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user