netgraph: prevent panic during attach to-non ethernet devices

This code will be purged with 16.7, but for now we tighten the
it to prevent panics that surfaced after cleaning up defunct
code paths in the legacy VPN area of the GUI.  Userland must
not be able to produce panics...

PR: https://forum.opnsense.org/index.php?topic=2385
This commit is contained in:
Franco Fichtner 2016-03-22 07:05:19 +01:00
parent 4206b8b851
commit 56b3d8393e

View file

@ -2923,10 +2923,15 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook)
case NGM_ETHER_ATTACH:
{
struct ifnet *ifp;
ifp = ifunit((char *)msg->data);
if (ifp && ng_ether_attach_p != NULL) {
ng_ether_attach_p(ifp);
struct ifnet *ifp = ifunit((char *)msg->data);
if (ng_ether_attach_p) {
if (ifp && (ifp->if_type == IFT_ETHER ||
&& ifp->if_type == IFT_L2VLAN)) {
ng_ether_attach_p(ifp);
} else {
error = ENOENT;
}
}
break;