From fc47e028bb31ecd84ced50a31b6f0981bfd7c45d Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Fri, 20 Dec 2013 00:17:26 +0000 Subject: Use more fine-grained kvm(3) symbol lookup: routing code retrieves only necessary symbols needed per subsystem. Main kvm(3) init is now delayed as much as possbile. This finally fixes performance issues reported in kern/167204. Some non-working code (ng_socket.ko symbol addresses calculation) removed. Some global variables eliminated. PR: kern/167204 MFC after: 4 weeks --- usr.bin/netstat/netgraph.c | 51 ++++------------------------------------------ 1 file changed, 4 insertions(+), 47 deletions(-) (limited to 'usr.bin/netstat/netgraph.c') diff --git a/usr.bin/netstat/netgraph.c b/usr.bin/netstat/netgraph.c index 3427dd36c5f4..95578af739fa 100644 --- a/usr.bin/netstat/netgraph.c +++ b/usr.bin/netstat/netgraph.c @@ -72,53 +72,10 @@ netgraphprotopr(u_long off, const char *name, int af1 __unused, /* If symbol not found, try looking in the KLD module */ if (off == 0) { - const char *const modname = "ng_socket.ko"; -/* XXX We should get "mpath" from "sysctl kern.module_path" */ - const char *mpath[] = { "/", "/boot/", "/modules/", NULL }; - struct nlist sym[] = { { .n_name = "_ngsocklist" }, - { .n_name = NULL } }; - const char **pre; - struct kld_file_stat ks; - int fileid; - - /* Can't do this for core dumps. */ - if (!live) - return; - - /* See if module is loaded */ - if ((fileid = kldfind(modname)) < 0) { - if (debug) - warn("kldfind(%s)", modname); - return; - } - - /* Get module info */ - memset(&ks, 0, sizeof(ks)); - ks.version = sizeof(struct kld_file_stat); - if (kldstat(fileid, &ks) < 0) { - if (debug) - warn("kldstat(%d)", fileid); - return; - } - - /* Get symbol table from module file */ - for (pre = mpath; *pre; pre++) { - char path[MAXPATHLEN]; - - snprintf(path, sizeof(path), "%s%s", *pre, modname); - if (nlist(path, sym) == 0) - break; - } - - /* Did we find it? */ - if (sym[0].n_value == 0) { - if (debug) - warnx("%s not found", modname); - return; - } - - /* Symbol found at load address plus symbol offset */ - off = (u_long) ks.address + sym[0].n_value; + if (debug) + fprintf(stderr, + "Error reading symbols from ng_socket.ko"); + return; } /* Get pointer to first socket */ -- cgit v1.3