From 742ef16208676db210a2cbcfee2105adaf8be167 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Fri, 28 Jun 2013 10:55:36 -0700 Subject: [PATCH] Allow user to preload address data without route data ACM must load routing data (path records) before it can preload address information. Remove this order requirement. Signed-off-by: Sean Hefty --- src/acm.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/acm.c b/src/acm.c index a57ab17..97e6351 100644 --- a/src/acm.c +++ b/src/acm.c @@ -2812,7 +2812,7 @@ static void acm_parse_hosts_file(struct acm_ep *ep) char addr[INET6_ADDRSTRLEN], gid[INET6_ADDRSTRLEN]; uint8_t name[ACM_MAX_ADDRESS]; struct in6_addr ip_addr, ib_addr; - struct acm_dest *dest, *new_dest; + struct acm_dest *dest, *gid_dest; uint8_t addr_type; if (!(f = fopen(addr_data_file, "r"))) { @@ -2841,30 +2841,31 @@ static void acm_parse_hosts_file(struct acm_ep *ep) continue; } - memset(name, 0, ACM_MAX_ADDRESS); - memcpy(name, &ib_addr, sizeof(ib_addr)); - dest = acm_get_dest(ep, ACM_ADDRESS_GID, name); - if (!dest) { - acm_log(0, "ERROR - IB GID %s not found in cache\n", gid); - continue; - } - memset(name, 0, ACM_MAX_ADDRESS); if (addr_type == ACM_ADDRESS_IP) memcpy(name, &ip_addr, 4); else memcpy(name, &ip_addr, sizeof(ip_addr)); - new_dest = acm_acquire_dest(ep, addr_type, name); - if (!new_dest) { + dest = acm_acquire_dest(ep, addr_type, name); + if (!dest) { acm_log(0, "ERROR - unable to create dest %s\n", addr); continue; } - new_dest->path = dest->path; - new_dest->remote_qpn = dest->remote_qpn; - new_dest->addr_timeout = dest->addr_timeout; - new_dest->route_timeout = dest->route_timeout; - new_dest->state = dest->state; - acm_put_dest(new_dest); + + memset(name, 0, ACM_MAX_ADDRESS); + memcpy(name, &ib_addr, sizeof(ib_addr)); + gid_dest = acm_get_dest(ep, ACM_ADDRESS_GID, name); + if (gid_dest) { + dest->path = gid_dest->path; + dest->state = ACM_READY; + acm_put_dest(gid_dest); + } else { + dest->state = ACM_ADDR_RESOLVED; + } + + dest->remote_qpn = 1; + dest->addr_timeout = time_stamp_min() + (unsigned) addr_timeout; + dest->route_timeout = time_stamp_min() + (unsigned) route_timeout; acm_put_dest(dest); acm_log(1, "added host %s address type %d IB GID %s\n", addr, addr_type, gid); -- 2.46.0