aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2019-05-10 13:18:22 +0000
committerKyle Evans <kevans@FreeBSD.org>2019-05-10 13:18:22 +0000
commit6a68e95de80965974b76892e5c753c3db781f91c (patch)
tree33b4466d17632bb85072b829bc4093832f41e9b6
parentef68f03ec2bb74993d888995c336fece24f362de (diff)
downloadsrc-6a68e95de80965974b76892e5c753c3db781f91c.tar.gz
src-6a68e95de80965974b76892e5c753c3db781f91c.zip
ifconfig(8): Add kld mappings for ipsec/enc
Additionally, providing mappings makes the comparison for already loaded modules a little more strict. This should have been done at initial introduction, but there was no real reason- however, it proves necessary for enc which has a standard enc -> if_enc mapping but there also exists an 'enc' module that's actually CAM. The mapping lets us unambiguously determine the correct module. Discussed with: ae MFC after: 4 days
Notes
Notes: svn path=/head/; revision=347429
-rw-r--r--sbin/ifconfig/ifconfig.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 6a42e3a6bb77..c324050aad82 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -71,6 +71,7 @@ static const char rcsid[] =
#ifdef JAIL
#include <jail.h>
#endif
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -146,6 +147,20 @@ static struct module_map_entry {
.ifname = "vmnet",
.kldname = "if_tuntap",
},
+ {
+ .ifname = "ipsec",
+ .kldname = "ipsec",
+ },
+ {
+ /*
+ * This mapping exists because there is a conflicting enc module
+ * in CAM. ifconfig's guessing behavior will attempt to match
+ * the ifname to a module as well as if_${ifname} and clash with
+ * CAM enc. This is an assertion of the correct module to load.
+ */
+ .ifname = "enc",
+ .kldname = "if_enc",
+ },
};
@@ -1436,6 +1451,7 @@ ifmaybeload(const char *name)
char ifkind[IFNAMSIZ + MOD_PREFIX_LEN], ifname[IFNAMSIZ], *dp;
const char *cp;
struct module_map_entry *mme;
+ bool found;
/* loading suppressed by the user */
if (noload)
@@ -1451,16 +1467,18 @@ ifmaybeload(const char *name)
/* Either derive it from the map or guess otherwise */
*ifkind = '\0';
+ found = false;
for (i = 0; i < nitems(module_map); ++i) {
mme = &module_map[i];
if (strcmp(mme->ifname, ifname) == 0) {
strlcpy(ifkind, mme->kldname, sizeof(ifkind));
+ found = true;
break;
}
}
/* We didn't have an alias for it... we'll guess. */
- if (*ifkind == '\0') {
+ if (!found) {
/* turn interface and unit into module name */
strlcpy(ifkind, "if_", sizeof(ifkind));
strlcat(ifkind, ifname, sizeof(ifkind));
@@ -1480,8 +1498,12 @@ ifmaybeload(const char *name)
} else {
cp = mstat.name;
}
- /* already loaded? */
- if (strcmp(ifname, cp) == 0 ||
+ /*
+ * Is it already loaded? Don't compare with ifname if
+ * we were specifically told which kld to use. Doing
+ * so could lead to conflicts not trivially solved.
+ */
+ if ((!found && strcmp(ifname, cp) == 0) ||
strcmp(ifkind, cp) == 0)
return;
}