From owner-p4-projects@FreeBSD.ORG Thu Aug 4 13:01:58 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 838C416A421; Thu, 4 Aug 2005 13:01:57 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4022816A41F for ; Thu, 4 Aug 2005 13:01:57 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id BFFAA43D46 for ; Thu, 4 Aug 2005 13:01:56 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j74D1uK6085070 for ; Thu, 4 Aug 2005 13:01:56 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j74D1uON085067 for perforce@freebsd.org; Thu, 4 Aug 2005 13:01:56 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Thu, 4 Aug 2005 13:01:56 GMT Message-Id: <200508041301.j74D1uON085067@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 81444 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Aug 2005 13:01:58 -0000 http://perforce.freebsd.org/chv.cgi?CH=81444 Change 81444 by rwatson@rwatson_zoo on 2005/08/04 13:01:38 Supporting paperwork for _DRV_ changes on flags: inspect, annotate, assert in various if.c flag-related activities, especially for functions that simply expect a variable flag argument. Annotate that currently all _DRV_ flags are not changeable from user space, so don't require special handling. However, for monitoring purposes, mix them into the flags returned to user space. Affected files ... .. //depot/projects/netsmp/src/sys/net/if.c#8 edit .. //depot/projects/netsmp/src/sys/net/if.h#3 edit Differences ... ==== //depot/projects/netsmp/src/sys/net/if.c#8 (text+ko) ==== @@ -1030,6 +1030,8 @@ { struct ifaddr *ifa; + KASSERT(flag == IFF_UP, ("if_unroute: flag != IFF_UP")); + ifp->if_flags &= ~flag; getmicrotime(&ifp->if_lastchange); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) @@ -1053,6 +1055,8 @@ { struct ifaddr *ifa; + KASSERT(flag == IFF_UP, ("if_route: flag != IFF_UP")); + ifp->if_flags |= flag; getmicrotime(&ifp->if_lastchange); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) @@ -1230,7 +1234,7 @@ struct ifreq *ifr; struct ifstat *ifs; int error = 0; - int new_flags; + int new_flags, temp_flags; size_t namelen, onamelen; char new_name[IFNAMSIZ]; struct ifaddr *ifa; @@ -1243,8 +1247,9 @@ break; case SIOCGIFFLAGS: - ifr->ifr_flags = ifp->if_flags & 0xffff; - ifr->ifr_flagshigh = ifp->if_flags >> 16; + temp_flags = ifp->if_flags | ifp->if_drv_flags; + ifr->ifr_flags = temp_flags & 0xffff; + ifr->ifr_flagshigh = temp_flags >> 16; break; case SIOCGIFCAP: @@ -1274,6 +1279,11 @@ error = suser(td); if (error) return (error); + /* + * XXXRW: Currently, no driver owned flags pass the + * IFF_CANTCHANGE check, so we don't need special handling + * here yet. + */ new_flags = (ifr->ifr_flags & 0xffff) | (ifr->ifr_flagshigh << 16); if (ifp->if_flags & IFF_SMART) { @@ -1611,10 +1621,12 @@ } /* - * The code common to hadling reference counted flags, + * The code common to handling reference counted flags, * e.g., in ifpromisc() and if_allmulti(). * The "pflag" argument can specify a permanent mode flag, * such as IFF_PPROMISC for promiscuous mode; should be 0 if none. + * + * XXXRW: Only to be used on stack-owned flags, not driver-owned flags. */ static int if_setflag(struct ifnet *ifp, int flag, int pflag, int *refcount, int onswitch) @@ -1623,6 +1635,9 @@ int error; int oldflags, oldcount; + KASSERT((flag & (IFF_DRV_OACTIVE|IFF_DRV_RUNNING)) == 0, + ("if_setflag: setting driver-ownded flag %d", flag)); + /* Sanity checks to catch programming errors */ if (onswitch) { if (*refcount < 0) { @@ -2259,7 +2274,11 @@ ifp->if_obytes += m->m_pkthdr.len + adjust; if (m->m_flags & (M_BCAST|M_MCAST)) ifp->if_omcasts++; - active = ifp->if_flags & IFF_OACTIVE; + /* + * XXXRW: Technically, we'd like the driver to do this to + * avoid races. + */ + active = ifp->if_drv_flags & IFF_DRV_OACTIVE; } _IF_ENQUEUE(ifq, m); IF_UNLOCK(ifq); ==== //depot/projects/netsmp/src/sys/net/if.h#3 (text+ko) ==== @@ -159,7 +159,7 @@ /* flags set internally only: */ #define IFF_CANTCHANGE \ - (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\ + (IFF_BROADCAST|IFF_POINTOPOINT|IFF_DRV_RUNNING|IFF_DRV_OACTIVE|\ IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_SMART|IFF_PROMISC|\ IFF_POLLING)