]> git.openfabrics.org - ~shefty/ibacm.git/commitdiff
Add support for preloading IPv4 and IPv6 ACM caches
authorHal Rosenstock <hal@mellanox.com>
Thu, 27 Jun 2013 18:48:11 +0000 (21:48 +0300)
committerSean Hefty <sean.hefty@intel.com>
Thu, 27 Jun 2013 20:08:04 +0000 (13:08 -0700)
A hosts file (ibacm_hosts.cfg) is configured with tuples of
IP addresses (either IPv4 or IPv6) and IB GID. This information
in conjunction with the path record preloading allows
for the IPv4 and IPv6 ACM caches to be preloaded.

IPv4 was tested with both rping and ucmatose as well as
acme. IPv6 was tested with ucmatose and acme.

The remaining ACM cache to be preloaded is the name cache.
This will be added in subsequent patch.

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Makefile.am
acm_notes.txt
ibacm_hosts.cfg [new file with mode: 0644]
ibacm_opts.cfg
man/ibacm.1
src/acm.c
src/acme.c

index de035bcda8ccd7a2b4c1ec1903acebe43305530c..c97326a1e6a1c1f9229fd4b8d9295bf3c9764ded 100644 (file)
@@ -20,7 +20,7 @@ man_MANS = \
 
 EXTRA_DIST = src/acm_mad.h src/libacm.h ibacm.init.in \
             linux/osd.h linux/dlist.h ibacm.spec.in $(man_MANS) ibacm_opts.cfg \
-            ibacm_addr.cfg
+            ibacm_addr.cfg ibacm_hosts.cfg
 
 install-exec-hook:
        install -D -m 755 ibacm.init $(DESTDIR)$(sysconfdir)/init.d/ibacm;
index a8b03d8442fb468fc71dfde40193b6f8dbb060f3..fd8a3f4ddcc342f1cef232303a48cb62c1c1ff06 100644 (file)
@@ -137,3 +137,7 @@ be set to full_opensm_v1 for  this file format.  Default format is
 none which does not preload these caches.  See dump_pr.notes.txt in dump_pr
 for more information on the full_opensm_v1 file format and how to configure
 OpenSM to generate this file.
+
+Additional IPv4 and IPv6 caches can be be preloaded by using the
+hosts_file option.  The default is "none" which does not preload these
+caches.
diff --git a/ibacm_hosts.cfg b/ibacm_hosts.cfg
new file mode 100644 (file)
index 0000000..9011691
--- /dev/null
@@ -0,0 +1,12 @@
+# InfiniBand Communication Management Assistant for clusters hosts file
+#
+# Entry format is:
+# address IB GID
+#
+# address - IPv4 or IPv6 formatted address
+#
+# There can be multiple entries for a single IB GID
+#
+# Samples:
+# 192.168.1.3 fe80::8:f104:39a:169
+# fe80::208:f104:39a:169 fe80::8:f104:39a:169
index fc4bd088c21499db2265d4b523a5f2c1fdd7781a..e2b3dcec858501f09ef68480731a994b718e4150 100644 (file)
@@ -154,3 +154,9 @@ path_rec_fmt none
 # path_rec_file:
 # If path_rec_fmt is other than "none", full pathname of path records file
 # to use for preloading the ACM cache.  Default is ACM_CONF_DIR/ibacm_path_records.dump
+
+# hosts_file:
+# none - No hosts file
+# If hosts_file is other than "none", full pathname of hosts file
+
+hosts_file none
index ec97b35c1e45471cba0c99fd49759e846ee4921a..2ca7eec24bd6b7ba58e2eb36c07b2941654bc30e 100644 (file)
@@ -156,5 +156,9 @@ format.  Default format is none which does not preload these caches.
 See dump_pr.notes.txt in dump_pr for more information on the
 full_opensm_v1 file format and how to configure OpenSM to
 generate this file.
+.P
+Additional IPv4 and IPv6 caches can be be preloaded by using the
+hosts_file option.  The default is "none" which does not preload these
+caches.
 .SH "SEE ALSO"
 ibacm(7), ib_acme(1), rdma_cm(7)
index 726acb805841b283f6e28b46cd87673f54ea91bb..fc0d920449b5f40272a98dcb82a2ddeb689b5ffe 100644 (file)
--- a/src/acm.c
+++ b/src/acm.c
@@ -219,6 +219,7 @@ static char *acme = BINDIR "/ib_acme -A";
 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";
@@ -234,6 +235,7 @@ static int resolve_depth = 1;
 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;
@@ -2790,6 +2792,73 @@ err:
        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;
@@ -3046,6 +3115,12 @@ static void acm_ep_up(struct acm_port *port, uint16_t pkey_index)
                        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:
@@ -3362,6 +3437,13 @@ static void acm_set_options(void)
                        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);
@@ -3387,6 +3469,7 @@ static void acm_log_options(void)
        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)
index 5ba5c0ac4077a6c2146cede0c6b965ad76636731..648e97f79d24df32e6b4dffe4fcbf105fe94e5b9 100644 (file)
@@ -256,6 +256,12 @@ static void gen_opts_temp(FILE *f)
        fprintf(f, "# If path_rec_fmt is other than \"none\", full pathname of path records file\n");
        fprintf(f, "# to use for preloading the ACM cache.  Default is ACM_CONF_DIR/ibacm_path_records.dump\n");
        fprintf(f, "\n");
+       fprintf(f, "# hosts_file:\n");
+       fprintf(f, "# none - No hosts file\n");
+       fprintf(f, "# If hosts_file is other than \"none\", full pathname of hosts file\n");
+       fprintf(f, "\n");
+       fprintf(f, "hosts_file none\n");
+       fprintf(f, "\n");
 }
 
 static int open_dir(void)