From owner-svn-src-all@FreeBSD.ORG Fri Mar 20 21:09:05 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 32654CD0; Fri, 20 Mar 2015 21:09:05 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 03BA1C23; Fri, 20 Mar 2015 21:09:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2KL94Lf058613; Fri, 20 Mar 2015 21:09:04 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2KL941E058612; Fri, 20 Mar 2015 21:09:04 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201503202109.t2KL941E058612@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Fri, 20 Mar 2015 21:09:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r280303 - head/sys/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Mar 2015 21:09:05 -0000 Author: glebius Date: Fri Mar 20 21:09:03 2015 New Revision: 280303 URL: https://svnweb.freebsd.org/changeset/base/280303 Log: Make vlan_config() the signle point of validity checks. Sponsored by: Nginx, Inc. Modified: head/sys/net/if_vlan.c Modified: head/sys/net/if_vlan.c ============================================================================== --- head/sys/net/if_vlan.c Fri Mar 20 20:42:58 2015 (r280302) +++ head/sys/net/if_vlan.c Fri Mar 20 21:09:03 2015 (r280303) @@ -817,14 +817,6 @@ vlan_clone_match_ethervid(const char *na *cp = '\0'; if ((ifp = ifunit(ifname)) == NULL) return (NULL); - /* - * We can handle non-ethernet hardware types as long as - * they handle the tagging and headers themselves. - */ - if (ifp->if_type != IFT_ETHER && - (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) == 0) - return (NULL); - /* Parse VID. */ if (*++cp == '\0') return (NULL); @@ -892,13 +884,7 @@ vlan_clone_create(struct if_clone *ifc, return error; p = ifunit(vlr.vlr_parent); if (p == NULL) - return ENXIO; - /* - * Don't let the caller set up a VLAN VID with - * anything except VLID bits. - */ - if (vlr.vlr_tag & ~EVL_VLID_MASK) - return (EINVAL); + return (ENXIO); error = ifc_name2unit(name, &unit); if (error != 0) return (error); @@ -910,13 +896,6 @@ vlan_clone_create(struct if_clone *ifc, ethertag = 1; unit = -1; wildcard = 0; - - /* - * Don't let the caller set up a VLAN VID with - * anything except VLID bits. - */ - if (vid & ~EVL_VLID_MASK) - return (EINVAL); } else { ethertag = 0; @@ -1198,14 +1177,22 @@ vlan_config(struct ifvlan *ifv, struct i struct ifnet *ifp; int error = 0; - /* VID numbers 0x0 and 0xFFF are reserved */ - if (vid == 0 || vid == 0xFFF) - return (EINVAL); + /* + * We can handle non-ethernet hardware types as long as + * they handle the tagging and headers themselves. + */ if (p->if_type != IFT_ETHER && (p->if_capenable & IFCAP_VLAN_HWTAGGING) == 0) return (EPROTONOSUPPORT); if ((p->if_flags & VLAN_IFFLAGS) != VLAN_IFFLAGS) return (EPROTONOSUPPORT); + /* + * Don't let the caller set up a VLAN VID with + * anything except VLID bits. + * VID numbers 0x0 and 0xFFF are reserved. + */ + if (vid == 0 || vid == 0xFFF || (vid & ~EVL_VLID_MASK)) + return (EINVAL); if (ifv->ifv_trunk) return (EBUSY); @@ -1670,14 +1657,6 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd error = ENOENT; break; } - /* - * Don't let the caller set up a VLAN VID with - * anything except VLID bits. - */ - if (vlr.vlr_tag & ~EVL_VLID_MASK) { - error = EINVAL; - break; - } error = vlan_config(ifv, p, vlr.vlr_tag); if (error) break;