From 22893351e5bb57c3fcccd119cd1db11e60b71e63 Mon Sep 17 00:00:00 2001 From: Jack F Vogel Date: Thu, 28 Aug 2008 22:05:19 +0000 Subject: Fix to bug kern/126850. Only dispatch event hander if the interface had a parent (was attached). Reviewed by: EvilSam MFC after: 1 week --- sys/net/if_vlan.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'sys/net/if_vlan.c') diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 439d14a06633..3f9388334a96 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1094,13 +1094,13 @@ vlan_unconfig_locked(struct ifnet *ifp) ifv = ifp->if_softc; trunk = ifv->ifv_trunk; - parent = PARENT(ifv); + parent = NULL; - if (trunk) { + if (trunk != NULL) { struct sockaddr_dl sdl; - struct ifnet *p = trunk->parent; TRUNK_LOCK(trunk); + parent = trunk->parent; /* * Since the interface is being unconfigured, we need to @@ -1110,14 +1110,14 @@ vlan_unconfig_locked(struct ifnet *ifp) bzero((char *)&sdl, sizeof(sdl)); sdl.sdl_len = sizeof(sdl); sdl.sdl_family = AF_LINK; - sdl.sdl_index = p->if_index; + sdl.sdl_index = parent->if_index; sdl.sdl_type = IFT_ETHER; sdl.sdl_alen = ETHER_ADDR_LEN; while ((mc = SLIST_FIRST(&ifv->vlan_mc_listhead)) != NULL) { bcopy((char *)&mc->mc_addr, LLADDR(&sdl), ETHER_ADDR_LEN); - error = if_delmulti(p, (struct sockaddr *)&sdl); + error = if_delmulti(parent, (struct sockaddr *)&sdl); if (error) return (error); SLIST_REMOVE_HEAD(&ifv->vlan_mc_listhead, mc_entries); @@ -1158,7 +1158,13 @@ vlan_unconfig_locked(struct ifnet *ifp) ifp->if_link_state = LINK_STATE_UNKNOWN; ifp->if_drv_flags &= ~IFF_DRV_RUNNING; - EVENTHANDLER_INVOKE(vlan_unconfig, parent, ifv->ifv_tag); + /* + * Only dispatch an event if vlan was + * attached, otherwise there is nothing + * to cleanup anyway. + */ + if (parent != NULL) + EVENTHANDLER_INVOKE(vlan_unconfig, parent, ifv->ifv_tag); return (0); } -- cgit v1.2.3