From: Sean Hefty Date: Wed, 10 Oct 2012 15:52:21 +0000 (-0700) Subject: uncommit X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=93d9fc6147e690da0c6a8df5695ff075494e5daf;p=~shefty%2Fibacm.git uncommit --- diff --git a/meta b/meta index 4f41078..3b41bb1 100644 --- a/meta +++ b/meta @@ -1,7 +1,10 @@ Version: 1 -Previous: c109bf24da7456883d74dae19c179c60a854543b +Previous: 048496d160e06f78b9a0edb610be34aff39aecc4 Head: 7a3adb7d1415698bc219649ff077523499549821 Applied: + ibacm-timeout-address-and-rout: 2168f8cc0fe1a67b2565715ef0655866ce904a24 + ibacm-remove-umask-0: d204fca2b6298d7799e918141ea8e11e7ad43cec + ib_acme-add-option-to-display-: 7a3adb7d1415698bc219649ff077523499549821 Unapplied: dev-name2ip: 8e00708e882239292492e13aa51c82042255933c dev-addrsize: 8de02c47fbf595132105a7050ad6f755f49f9a7a diff --git a/patches/ib_acme-add-option-to-display- b/patches/ib_acme-add-option-to-display- new file mode 100644 index 0000000..c60cd8e --- /dev/null +++ b/patches/ib_acme-add-option-to-display- @@ -0,0 +1,138 @@ +Bottom: 755378776a1eabd34e5c6e5a8ac9d7b31d4f94ce +Top: 9cb1d5b0b8438be2b4dec2a27ca479aa2151d622 +Author: Sean Hefty +Date: 2012-10-09 11:39:15 -0700 + +ib_acme: Add option to display output in more readable format + +Signed-off-by: Sean Hefty + + +--- + +diff --git a/src/acme.c b/src/acme.c +index 4cd1a97..81d9e3a 100644 +--- a/src/acme.c ++++ b/src/acme.c +@@ -55,7 +55,13 @@ static char *src_arg; + static char addr_type = 'u'; + static int verify; + static int nodelay; +-static int perf_query; ++ ++enum perf_query_output { ++ PERF_QUERY_NONE, ++ PERF_QUERY_ROW, ++ PERF_QUERY_COL ++}; ++static enum perf_query_output perf_query; + int verbose; + + struct ibv_context **verbs; +@@ -667,6 +673,7 @@ static void resolve(char *svc) + + static void query_perf(char *svc) + { ++ static int lables; + int ret, cnt, i; + uint64_t *counters; + +@@ -676,10 +683,24 @@ static void query_perf(char *svc) + return; + } + +- printf("%s,", svc); +- for (i = 0; i < cnt - 1; i++) +- printf("%llu,", (unsigned long long) counters[i]); +- printf("%llu\n", (unsigned long long) counters[i]); ++ if (perf_query == PERF_QUERY_ROW) { ++ if (!lables) { ++ for (i = 0; i < cnt - 1; i++) ++ printf("%s,", ib_acm_cntr_name(i)); ++ printf("%s\n", ib_acm_cntr_name(i)); ++ lables = 1; ++ } ++ printf("%s,", svc); ++ for (i = 0; i < cnt - 1; i++) ++ printf("%llu,", (unsigned long long) counters[i]); ++ printf("%llu\n", (unsigned long long) counters[i]); ++ } else { ++ printf("%s\n", svc); ++ for (i = 0; i < cnt; i++) { ++ printf("%s : ", ib_acm_cntr_name(i)); ++ printf("%llu\n", (unsigned long long) counters[i]); ++ } ++ } + ib_acm_free_perf(counters); + } + +@@ -694,11 +715,6 @@ static int query_svcs(void) + return -1; + } + +- if (perf_query) { +- printf("Destination,Error Count,Resolve Count,No Data,Addr Query Count," +- "Addr Cache Count,Route Query Count,Route Cache Count\n"); +- } +- + for (i = 0; svc_list[i]; i++) { + ret = ib_acm_connect(svc_list[i]); + if (ret) { +@@ -741,7 +757,7 @@ int CDECL_FUNC main(int argc, char **argv) + if (ret) + goto out; + +- while ((op = getopt(argc, argv, "f:s:d:vcA::O::D:PS:V")) != -1) { ++ while ((op = getopt(argc, argv, "f:s:d:vcA::O::D:P::S:V")) != -1) { + switch (op) { + case 'f': + addr_type = optarg[0]; +@@ -775,7 +791,10 @@ int CDECL_FUNC main(int argc, char **argv) + dest_dir = optarg; + break; + case 'P': +- perf_query = 1; ++ if (opt_arg(argc, argv) && !strnicmp("col", opt_arg(argc, argv), 3)) ++ perf_query = PERF_QUERY_COL; ++ else ++ perf_query = PERF_QUERY_ROW; + break; + case 'S': + svc_arg = optarg; +diff --git a/src/libacm.c b/src/libacm.c +index 5ca1abc..274eb2d 100644 +--- a/src/libacm.c ++++ b/src/libacm.c +@@ -357,3 +357,21 @@ out: + lock_release(&lock); + return ret; + } ++ ++const char *ib_acm_cntr_name(int index) ++{ ++ static const char *const cntr_name[] = { ++ [ACM_CNTR_ERROR] = "Error Count", ++ [ACM_CNTR_RESOLVE] = "Resolve Count", ++ [ACM_CNTR_NODATA] = "No Data", ++ [ACM_CNTR_ADDR_QUERY] = "Addr Query Count", ++ [ACM_CNTR_ADDR_CACHE] = "Addr Cache Count", ++ [ACM_CNTR_ROUTE_QUERY] = "Route Query Count", ++ [ACM_CNTR_ROUTE_CACHE] = "Route Cache Count", ++ }; ++ ++ if (index < ACM_CNTR_ERROR || index > ACM_MAX_COUNTER) ++ return "Unknown"; ++ ++ return cntr_name[index]; ++} +diff --git a/src/libacm.h b/src/libacm.h +index 049b7a9..61220d5 100644 +--- a/src/libacm.h ++++ b/src/libacm.h +@@ -45,4 +45,6 @@ int ib_acm_resolve_path(struct ibv_path_record *path, uint32_t flags); + int ib_acm_query_perf(uint64_t **counters, int *count); + #define ib_acm_free_perf(counters) free(counters) + ++const char *ib_acm_cntr_name(int index); ++ + #endif /* LIBACM_H */ diff --git a/patches/ibacm-remove-umask-0 b/patches/ibacm-remove-umask-0 new file mode 100644 index 0000000..edcbe99 --- /dev/null +++ b/patches/ibacm-remove-umask-0 @@ -0,0 +1,29 @@ +Bottom: ff1e80680dcbd7bb8358925088eab6c8b16694a8 +Top: 755378776a1eabd34e5c6e5a8ac9d7b31d4f94ce +Author: Sean Hefty +Date: 2012-10-09 11:33:27 -0700 + +ibacm: Remove umask(0) + +This causes ibacm files to be created as world writable. + +Problem reported by Florian Weimer + +Signed-off-by: Sean Hefty + + +--- + +diff --git a/src/acm.c b/src/acm.c +index 00fc35d..725cde2 100644 +--- a/src/acm.c ++++ b/src/acm.c +@@ -3182,8 +3182,6 @@ static void daemonize(void) + if (pid) + exit(pid < 0); + +- umask(0); +- + sid = setsid(); + if (sid < 0) + exit(1); diff --git a/patches/ibacm-timeout-address-and-rout b/patches/ibacm-timeout-address-and-rout new file mode 100644 index 0000000..2e17cd6 --- /dev/null +++ b/patches/ibacm-timeout-address-and-rout @@ -0,0 +1,206 @@ +Bottom: 422919c089c623304ae1940eb6bdae4237feb5ab +Top: ff1e80680dcbd7bb8358925088eab6c8b16694a8 +Author: Sean Hefty +Date: 2012-10-08 17:00:14 -0700 + +ibacm: Timeout address and route data + +Add an option that allows address and route data to +time out. Once data has timed out, it needs to be +resolved again. This helps handle cases where the +remote data has changed. + +Signed-off-by: Sean Hefty + + +--- + +diff --git a/linux/osd.h b/linux/osd.h +index e2424b4..c8278aa 100644 +--- a/linux/osd.h ++++ b/linux/osd.h +@@ -155,7 +155,9 @@ static inline uint64_t time_stamp_us(void) + return (uint64_t) curtime.tv_sec * 1000000 + (uint64_t) curtime.tv_usec; + } + +-#define time_stamp_ms() (time_stamp_us() / 1000) ++#define time_stamp_ms() (time_stamp_us() / (uint64_t) 1000) ++#define time_stamp_sec() (time_stamp_ms() / (uint64_t) 1000) ++#define time_stamp_min() (time_stamp_sec() / (uint64_t) 60) + + #define PER_THREAD __thread + static inline int beginthread(void (*func)(void *), void *arg) +diff --git a/src/acm.c b/src/acm.c +index b6fa32f..00fc35d 100644 +--- a/src/acm.c ++++ b/src/acm.c +@@ -1,5 +1,5 @@ + /* +- * 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: +@@ -90,6 +90,8 @@ struct acm_dest { + lock_t lock; + enum acm_state state; + atomic_t refcnt; ++ uint64_t addr_timeout; ++ uint64_t route_timeout; + uint8_t addr_type; + }; + +@@ -212,7 +214,9 @@ static char log_file[128] = "/var/log/ibacm.log"; + 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; +@@ -805,6 +809,8 @@ acm_record_acm_route(struct acm_ep *ep, struct acm_dest *dest) + 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() + (unsigned) addr_timeout; ++ dest->route_timeout = time_stamp_min() + (unsigned) route_timeout; + dest->state = ACM_READY; + return ACM_STATUS_SUCCESS; + } +@@ -1111,6 +1117,9 @@ acm_dest_sa_resp(struct acm_send_msg *msg, struct ibv_wc *wc, struct acm_mad *ma + 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() + (unsigned) addr_timeout; ++ dest->route_timeout = time_stamp_min() + (unsigned) 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; +@@ -2085,6 +2094,22 @@ acm_svr_queue_req(struct acm_dest *dest, struct acm_client *client, + 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) + { +@@ -2127,8 +2152,11 @@ 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; +@@ -2222,8 +2250,11 @@ acm_svr_resolve_path(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; +@@ -2620,6 +2651,8 @@ static int acm_init_ep_loopback(struct acm_ep *ep) + dest->path.rate = (uint8_t) ep->port->rate; + + dest->remote_qpn = ep->qp->qp_num; ++ dest->addr_timeout = (uint64_t) ~0ULL; ++ dest->route_timeout = (uint64_t) ~0ULL; + dest->state = ACM_READY; + acm_put_dest(dest); + acm_log(1, "added loopback dest %s\n", dest->name); +@@ -3055,8 +3088,12 @@ static void acm_set_options(void) + 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)) +@@ -3087,7 +3124,9 @@ static void acm_log_options(void) + acm_log(0, "log level %d\n", log_level); + acm_log(0, "lock file %s\n", lock_file); + acm_log(0, "address resolution %d\n", addr_prot); ++ acm_log(0, "address timeout %d\n", addr_timeout); + acm_log(0, "route resolution %d\n", route_prot); ++ acm_log(0, "route timeout %d\n", route_timeout); + acm_log(0, "loopback resolution %d\n", loopback_prot); + acm_log(0, "server_port %d\n", server_port); + acm_log(0, "timeout %d ms\n", timeout); +diff --git a/src/acme.c b/src/acme.c +index 0e1d4ed..4cd1a97 100644 +--- a/src/acme.c ++++ b/src/acme.c +@@ -132,6 +132,14 @@ static void gen_opts_temp(FILE *f) + 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"); +@@ -140,6 +148,15 @@ static void gen_opts_temp(FILE *f) + 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"); +@@ -660,9 +677,9 @@ static void query_perf(char *svc) + } + + 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); + }