/*
- * Copyright (c) 2009-2010 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009-2012 Intel Corporation. All rights reserved.
*
* This software is available to you under the OpenIB.org BSD license
* below:
lock_t lock;
enum acm_state state;
atomic_t refcnt;
+ uint64_t addr_timeout;
+ uint64_t route_timeout;
uint8_t addr_type;
};
static int log_level = 0;
static char lock_file[128] = "/var/run/ibacm.pid";
static enum acm_addr_prot addr_prot = ACM_ADDR_PROT_ACM;
+static int addr_timeout = 1440;
static enum acm_route_prot route_prot = ACM_ROUTE_PROT_SA;
+static int route_timeout = -1;
static enum acm_loopback_prot loopback_prot = ACM_LOOPBACK_PROT_LOCAL;
static short server_port = 6125;
static int timeout = 2000;
dest->path = ep->mc_dest[i].path;
dest->path.dgid = dest->av.grh.dgid;
dest->path.dlid = htons(dest->av.dlid);
+ dest->addr_timeout = time_stamp_min() + (uint64_t) addr_timeout;
+ dest->route_timeout = time_stamp_min() + (uint64_t) route_timeout;
dest->state = ACM_READY;
return ACM_STATUS_SUCCESS;
}
if (!status) {
memcpy(&dest->path, sa_mad->data, sizeof(dest->path));
acm_init_path_av(msg->ep->port, dest);
+ dest->addr_timeout = time_stamp_min() + (uint64_t) addr_timeout;
+ dest->route_timeout = time_stamp_min() + (uint64_t) route_timeout;
+ acm_log(2, "timeout addr %llu route %llu\n", dest->addr_timeout, dest->route_timeout);
dest->state = ACM_READY;
} else {
dest->state = ACM_INIT;
return ACM_STATUS_SUCCESS;
}
+static int acm_dest_timeout(struct acm_dest *dest)
+{
+ uint64_t timestamp = time_stamp_min();
+
+ if (timestamp > dest->addr_timeout) {
+ acm_log(2, "%s address timed out\n", dest->name);
+ dest->state = ACM_INIT;
+ return 1;
+ } else if (timestamp > dest->route_timeout) {
+ acm_log(2, "%s route timed out\n", dest->name);
+ dest->state = ACM_ADDR_RESOLVED;
+ return 1;
+ }
+ return 0;
+}
+
static int
acm_svr_resolve_dest(struct acm_client *client, struct acm_msg *msg)
{
}
lock_acquire(&dest->lock);
+test:
switch (dest->state) {
case ACM_READY:
+ if (acm_dest_timeout(dest))
+ goto test;
acm_log(2, "request satisfied from local cache\n");
atomic_inc(&counter[ACM_CNTR_ROUTE_CACHE]);
status = ACM_STATUS_SUCCESS;
}
lock_acquire(&dest->lock);
+test:
switch (dest->state) {
case ACM_READY:
+ if (acm_dest_timeout(dest))
+ goto test;
acm_log(2, "request satisfied from local cache\n");
atomic_inc(&counter[ACM_CNTR_ROUTE_CACHE]);
status = ACM_STATUS_SUCCESS;
dest->path.rate = (uint8_t) ep->port->rate;
dest->remote_qpn = ep->qp->qp_num;
+ dest->addr_timeout = (uint64_t) -1;
+ dest->route_timeout = (uint64_t) -1;
dest->state = ACM_READY;
acm_put_dest(dest);
acm_log(1, "added loopback dest %s\n", dest->name);
strcpy(lock_file, value);
else if (!stricmp("addr_prot", opt))
addr_prot = acm_convert_addr_prot(value);
+ else if (!stricmp("addr_timeout", opt))
+ addr_timeout = atoi(value);
else if (!stricmp("route_prot", opt))
route_prot = acm_convert_route_prot(value);
+ else if (!strcmp("route_timeout", opt))
+ route_timeout = atoi(value);
else if (!stricmp("loopback_prot", opt))
loopback_prot = acm_convert_loopback_prot(value);
else if (!stricmp("server_port", opt))
fprintf(f, "\n");
fprintf(f, "addr_prot acm\n");
fprintf(f, "\n");
+ fprintf(f, "# addr_timeout:\n");
+ fprintf(f, "# Number of minutes to maintain IP address to GID mapping before\n");
+ fprintf(f, "# repeating address resolution. A value of -1 indicates that the\n");
+ fprintf(f, "# mapping will not time out.\n");
+ fprintf(f, "# 1 hour = 60, 1 day = 1440, 1 week = 10080, 1 month ~ 43200");
+ fprintf(f, "\n");
+ fprintf(f, "addr_timeout 1440\n");
+ fprintf(f, "\n");
fprintf(f, "# route_prot:\n");
fprintf(f, "# Default resolution protocol to resolve IB routing information.\n");
fprintf(f, "# Supported protocols are:\n");
fprintf(f, "\n");
fprintf(f, "route_prot sa\n");
fprintf(f, "\n");
+ fprintf(f, "# route_timeout:\n");
+ fprintf(f, "# Number of minutes to maintain IB routing information before\n");
+ fprintf(f, "# repeating route resolution. A value of -1 indicates that the\n");
+ fprintf(f, "# mapping will not time out. However, the route will\n");
+ fprintf(f, "# automatically time out when the address times out.\n");
+ fprintf(f, "# 1 hour = 60, 1 day = 1440, 1 week = 10080, 1 month ~ 43200");
+ fprintf(f, "\n");
+ fprintf(f, "route_timeout -1\n");
+ fprintf(f, "\n");
fprintf(f, "# loopback_prot:\n");
fprintf(f, "# Address and route resolution protocol to resolve local addresses\n");
fprintf(f, "# Supported protocols are:\n");
}
printf("%s,", svc);
- for (i = 0; i < cnt; i++)
+ for (i = 0; i < cnt - 1; i++)
printf("%llu,", (unsigned long long) counters[i]);
- printf("\n");
+ printf("%llu\n", (unsigned long long) counters[i]);
ib_acm_free_perf(counters);
}