Author: vanhu
Date: Sun Dec 21 19:13:30 2008
New Revision: 186375
URL: http://svn.freebsd.org/changeset/base/186375

Log:
  Fix to bug kern/126850. Only dispatch event hander if the interface had a 
parent...
  
  PR:           kern/126850
  Reviewed by:  EvilSam
  Approved by:  re

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/net/if.h
  stable/7/sys/net/if_vlan.c

Modified: stable/7/sys/net/if.h
==============================================================================
--- stable/7/sys/net/if.h       Sun Dec 21 16:56:13 2008        (r186374)
+++ stable/7/sys/net/if.h       Sun Dec 21 19:13:30 2008        (r186375)
@@ -199,22 +199,23 @@ struct if_data {
  *   more detailed or differenciated than IFCAP_*.
  *   Hwassist features are defined CSUM_* in sys/mbuf.h
  */
-#define IFCAP_RXCSUM           0x0001  /* can offload checksum on RX */
-#define IFCAP_TXCSUM           0x0002  /* can offload checksum on TX */
-#define IFCAP_NETCONS          0x0004  /* can be a network console */
-#define        IFCAP_VLAN_MTU          0x0008  /* VLAN-compatible MTU */
-#define        IFCAP_VLAN_HWTAGGING    0x0010  /* hardware VLAN tag support */
-#define        IFCAP_JUMBO_MTU         0x0020  /* 9000 byte MTU supported */
-#define        IFCAP_POLLING           0x0040  /* driver supports polling */
-#define        IFCAP_VLAN_HWCSUM       0x0080  /* can do IFCAP_HWCSUM on VLANs 
*/
-#define        IFCAP_TSO4              0x0100  /* can do TCP Segmentation 
Offload */
-#define        IFCAP_TSO6              0x0200  /* can do TCP6 Segmentation 
Offload */
-#define        IFCAP_LRO               0x0400  /* can do Large Receive Offload 
*/
-#define        IFCAP_WOL_UCAST         0x0800  /* wake on any unicast frame */
-#define        IFCAP_WOL_MCAST         0x1000  /* wake on any multicast frame 
*/
-#define        IFCAP_WOL_MAGIC         0x2000  /* wake on any Magic Packet */
-#define        IFCAP_TOE4              0x4000  /* interface can offload TCP */
-#define        IFCAP_TOE6              0x8000  /* interface can offload TCP6 */
+#define        IFCAP_RXCSUM            0x00001  /* can offload checksum on RX 
*/
+#define        IFCAP_TXCSUM            0x00002  /* can offload checksum on TX 
*/
+#define        IFCAP_NETCONS           0x00004  /* can be a network console */
+#define        IFCAP_VLAN_MTU          0x00008 /* VLAN-compatible MTU */
+#define        IFCAP_VLAN_HWTAGGING    0x00010 /* hardware VLAN tag support */
+#define        IFCAP_JUMBO_MTU         0x00020 /* 9000 byte MTU supported */
+#define        IFCAP_POLLING           0x00040 /* driver supports polling */
+#define        IFCAP_VLAN_HWCSUM       0x00080 /* can do IFCAP_HWCSUM on VLANs 
*/
+#define        IFCAP_TSO4              0x00100 /* can do TCP Segmentation 
Offload */
+#define        IFCAP_TSO6              0x00200 /* can do TCP6 Segmentation 
Offload */
+#define        IFCAP_LRO               0x00400 /* can do Large Receive Offload 
*/
+#define        IFCAP_WOL_UCAST         0x00800 /* wake on any unicast frame */
+#define        IFCAP_WOL_MCAST         0x01000 /* wake on any multicast frame 
*/
+#define        IFCAP_WOL_MAGIC         0x02000 /* wake on any Magic Packet */
+#define        IFCAP_TOE4              0x04000 /* interface can offload TCP */
+#define        IFCAP_TOE6              0x08000 /* interface can offload TCP6 */
+#define        IFCAP_VLAN_HWFILTER     0x10000 /* interface hw can filter vlan 
tag */
 
 #define IFCAP_HWCSUM   (IFCAP_RXCSUM | IFCAP_TXCSUM)
 #define        IFCAP_TSO       (IFCAP_TSO4 | IFCAP_TSO6)

Modified: stable/7/sys/net/if_vlan.c
==============================================================================
--- stable/7/sys/net/if_vlan.c  Sun Dec 21 16:56:13 2008        (r186374)
+++ stable/7/sys/net/if_vlan.c  Sun Dec 21 19:13:30 2008        (r186375)
@@ -1093,13 +1093,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
@@ -1109,14 +1109,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);
@@ -1157,7 +1157,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);
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to