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
This commit is contained in:
parent
ef68f03ec2
commit
6a68e95de8
@ -71,6 +71,7 @@ static const char rcsid[] =
|
|||||||
#ifdef JAIL
|
#ifdef JAIL
|
||||||
#include <jail.h>
|
#include <jail.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -146,6 +147,20 @@ static struct module_map_entry {
|
|||||||
.ifname = "vmnet",
|
.ifname = "vmnet",
|
||||||
.kldname = "if_tuntap",
|
.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;
|
char ifkind[IFNAMSIZ + MOD_PREFIX_LEN], ifname[IFNAMSIZ], *dp;
|
||||||
const char *cp;
|
const char *cp;
|
||||||
struct module_map_entry *mme;
|
struct module_map_entry *mme;
|
||||||
|
bool found;
|
||||||
|
|
||||||
/* loading suppressed by the user */
|
/* loading suppressed by the user */
|
||||||
if (noload)
|
if (noload)
|
||||||
@ -1451,16 +1467,18 @@ ifmaybeload(const char *name)
|
|||||||
|
|
||||||
/* Either derive it from the map or guess otherwise */
|
/* Either derive it from the map or guess otherwise */
|
||||||
*ifkind = '\0';
|
*ifkind = '\0';
|
||||||
|
found = false;
|
||||||
for (i = 0; i < nitems(module_map); ++i) {
|
for (i = 0; i < nitems(module_map); ++i) {
|
||||||
mme = &module_map[i];
|
mme = &module_map[i];
|
||||||
if (strcmp(mme->ifname, ifname) == 0) {
|
if (strcmp(mme->ifname, ifname) == 0) {
|
||||||
strlcpy(ifkind, mme->kldname, sizeof(ifkind));
|
strlcpy(ifkind, mme->kldname, sizeof(ifkind));
|
||||||
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We didn't have an alias for it... we'll guess. */
|
/* We didn't have an alias for it... we'll guess. */
|
||||||
if (*ifkind == '\0') {
|
if (!found) {
|
||||||
/* turn interface and unit into module name */
|
/* turn interface and unit into module name */
|
||||||
strlcpy(ifkind, "if_", sizeof(ifkind));
|
strlcpy(ifkind, "if_", sizeof(ifkind));
|
||||||
strlcat(ifkind, ifname, sizeof(ifkind));
|
strlcat(ifkind, ifname, sizeof(ifkind));
|
||||||
@ -1480,8 +1498,12 @@ ifmaybeload(const char *name)
|
|||||||
} else {
|
} else {
|
||||||
cp = mstat.name;
|
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)
|
strcmp(ifkind, cp) == 0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user