Skip to content

Commit

Permalink
Merge pull request ofiwg#12 from hppritcha/topic/mac_addr_fix
Browse files Browse the repository at this point in the history
prov/gni: fix problem with finding mac addr
  • Loading branch information
hppritcha committed Feb 16, 2015
2 parents 1585b5d + 8ece1bf commit 7c1f3a3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
36 changes: 22 additions & 14 deletions prov/gni/src/gnix_nameserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static int gnixu_get_pe_from_ip(const char *ip_addr, uint32_t *gni_nic_addr)
int ret = -FI_ENODATA; /* return this if no ipgogif for this ip-addr found */
FILE *fd=NULL;
char line[BUF_SIZE], *tmp;
char dummy[64],iface[64];
char dummy[64],iface[64],fnd_ip_addr[64];
char mac_str[64];
int w,x,y;

Expand All @@ -95,23 +95,30 @@ static int gnixu_get_pe_from_ip(const char *ip_addr, uint32_t *gni_nic_addr)
if ((strstr(line,ip_addr) != NULL) && (strstr(line,"ipogif") != NULL)) {

ret = 0;
scount = sscanf(line,"%s%s%s%s%s%s",dummy,dummy,dummy,mac_str,dummy,iface);
scount = sscanf(line,"%s%s%s%s%s%s",fnd_ip_addr,dummy,
dummy,mac_str,dummy,iface);
if (scount != 6) {
ret = -EIO;
goto err;
}

scount = sscanf(mac_str, "00:01:01:%02x:%02x:%02x", &w, &x, &y);
if (scount != 3) {
ret = -EIO;
goto err;
}

/*
* mysteries of XE/XC mac to nid mapping, see nid2mac in xt sysutils
*/

*gni_nic_addr = (w << 16) | (x << 8) | y;
/*
* check exact match of ip addr
*/
if(!strcmp(fnd_ip_addr,ip_addr)) {

scount = sscanf(mac_str, "00:01:01:%02x:%02x:%02x", &w, &x, &y);
if (scount != 3) {
ret = -EIO;
goto err;
}
/*
* mysteries of XE/XC mac to nid mapping, see nid2mac in xt sysutils
*/
*gni_nic_addr = (w << 16) | (x << 8) | y;
ret = FI_SUCCESS;
break;
}
}
}

Expand All @@ -124,7 +131,8 @@ static int gnixu_get_pe_from_ip(const char *ip_addr, uint32_t *gni_nic_addr)
* gnixu name resolution function,
*/

int gnix_resolve_name(const char *node, const char *service, struct gnix_ep_name *resolved_addr)
int gnix_resolve_name(const char *node, const char *service,
struct gnix_ep_name *resolved_addr)
{
int s, rc = 0;
struct addrinfo *result, *rp;
Expand Down
3 changes: 3 additions & 0 deletions src/fi_tostr.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ static void fi_tostr_addr(char *buf, uint32_t addr_format,
inet_ntop(AF_INET6, &((struct sockaddr_in6 *)addr)->sin6_addr,
p, 64);
break;
case FI_ADDR_GNI: /*TODO: eventually something better */
sprintf(p, "0x%lx",*(uint64_t *)addr);
break;
default:
sprintf(p, "%p", addr);
break;
Expand Down

0 comments on commit 7c1f3a3

Please sign in to comment.