static char *opts_file = ACM_CONF_DIR "/" ACM_OPTS_FILE;
static char *addr_file = ACM_CONF_DIR "/" ACM_ADDR_FILE;
static char path_rec_file[128] = ACM_CONF_DIR "/" ACM_PATH_REC_FILE;
+static char hosts_file[128] = "none";
static char log_file[128] = "/var/log/ibacm.log";
static int log_level = 0;
static char lock_file[128] = "/var/run/ibacm.pid";
static int sa_depth = 1;
static int send_depth = 1;
static int recv_depth = 1024;
+static int hosts_opt = 0;
static uint8_t min_mtu = IBV_MTU_2048;
static uint8_t min_rate = IBV_RATE_10_GBPS;
static enum acm_path_rec_fmt path_rec_fmt = ACM_PATH_REV_FMT_NONE;
return ret;
}
+static void acm_parse_hosts_file(struct acm_ep *ep)
+{
+ FILE *f;
+ char s[120];
+ 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;
+ uint8_t addr_type;
+
+ if (!(f = fopen(hosts_file, "r"))) {
+ acm_log(0, "ERROR - couldn't open %s\n", hosts_file);
+ return;
+ }
+
+ while (fgets(s, sizeof s, f)) {
+ if (s[0] == '#')
+ continue;
+
+ if (sscanf(s, "%46s%46s", addr, gid) != 2)
+ continue;
+
+ acm_log(2, "%s", s);
+ if (inet_pton(AF_INET6, gid, &ib_addr) <= 0) {
+ acm_log(0, "ERROR - %s is not IB GID\n", gid);
+ continue;
+ }
+ if (inet_pton(AF_INET, addr, &ip_addr) > 0)
+ addr_type = ACM_ADDRESS_IP;
+ else if (inet_pton(AF_INET6, addr, &ip_addr) > 0)
+ addr_type = ACM_ADDRESS_IP6;
+ else {
+ acm_log(0, "ERROR - %s is not IP address\n", addr);
+ 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) {
+ 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);
+ acm_log(1, "added host %s address type %d IB GID %s\n",
+ addr, addr_type, gid);
+ }
+
+ fclose(f);
+}
+
static int acm_assign_ep_names(struct acm_ep *ep)
{
FILE *faddr;
acm_log(1, "unable to find ep in path records\n");
}
+ if (hosts_opt) {
+ if (path_rec_fmt == ACM_PATH_REV_FMT_NONE)
+ acm_log(0, "when using hosts file option should also use path records option\n");
+ acm_parse_hosts_file(ep);
+ }
+
return;
err2:
path_rec_fmt = acm_convert_path_rec_fmt(value);
else if (!stricmp("path_rec_file", opt))
strcpy(path_rec_file, value);
+ else if (!stricmp("hosts_file", opt)) {
+ strcpy(hosts_file, value);
+ if (!stricmp(hosts_file, "none"))
+ hosts_opt = 0;
+ else
+ hosts_opt = 1;
+ }
}
fclose(f);
acm_log(0, "minimum rate %d\n", min_rate);
acm_log(0, "path record format %d\n", path_rec_fmt);
acm_log(0, "path record file %s\n", path_rec_file);
+ acm_log(0, "hosts file %s\n", hosts_file);
}
static FILE *acm_open_log(void)