From owner-svn-src-head@freebsd.org Tue Aug 21 21:33:38 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0CED7107FE8E; Tue, 21 Aug 2018 21:33:38 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (glebi.us [198.45.61.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 90A8C9773F; Tue, 21 Aug 2018 21:33:37 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id w7LLXa7a055112 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 21 Aug 2018 14:33:36 -0700 (PDT) (envelope-from glebius@freebsd.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id w7LLXaS4055111; Tue, 21 Aug 2018 14:33:36 -0700 (PDT) (envelope-from glebius@freebsd.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@freebsd.org using -f Date: Tue, 21 Aug 2018 14:33:36 -0700 From: Gleb Smirnoff To: Navdeep Parhar Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r337932 - in head/sys: net netinet Message-ID: <20180821213336.GO27633@FreeBSD.org> References: <201808162346.w7GNkc2p006822@repo.freebsd.org> <20180821212628.GN27633@FreeBSD.org> <1e809525-77bd-19e2-6908-a984c3414aed@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1e809525-77bd-19e2-6908-a984c3414aed@FreeBSD.org> User-Agent: Mutt/1.10.0 (2018-05-17) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Aug 2018 21:33:38 -0000 On Tue, Aug 21, 2018 at 02:28:27PM -0700, Navdeep Parhar wrote: N> On 8/21/18 2:26 PM, Gleb Smirnoff wrote: N> > Navdeep, N> > N> > On Thu, Aug 16, 2018 at 11:46:38PM +0000, Navdeep Parhar wrote: N> > N> Author: np N> > N> Date: Thu Aug 16 23:46:38 2018 N> > N> New Revision: 337932 N> > N> URL: https://svnweb.freebsd.org/changeset/base/337932 N> > N> N> > N> Log: N> > N> Add the ability to look up the 3b PCP of a VLAN interface. Use it in N> > N> toe_l2_resolve to fill up the complete vtag and not just the vid. N> > N> N> > N> Reviewed by: kib@ N> > N> MFC after: 1 week N> > N> Sponsored by: Chelsio Communications N> > N> Differential Revision: https://reviews.freebsd.org/D16752 N> > ... N> > N> +static int N> > N> +vlan_pcp(struct ifnet *ifp, uint16_t *pcpp) N> > N> +{ N> > N> + struct ifvlan *ifv; N> > N> + N> > N> + if (ifp->if_type != IFT_L2VLAN) N> > N> + return (EINVAL); N> > N> + ifv = ifp->if_softc; N> > N> + *pcpp = ifv->ifv_pcp; N> > N> + return (0); N> > N> +} N> > N> > Is there any good reason not to assert that ifp->if_type == IFT_L2VLAN? N> > N> N> I can't think of any. But I wrote it this way to match the vlan_tag() N> function a few lines above. Hmm, this comes from OFED import. But at the same time it brings macros like this: + (_ifp)->if_type == IFT_L2VLAN ? (*vlan_trunkdev_p)((_ifp)) : NULL +#define VLAN_TAG(_ifp, _tag) \ + (_ifp)->if_type == IFT_L2VLAN ? (*vlan_tag_p)((_ifp), (_tag)) : EINVAL +#define VLAN_COOKIE(_ifp) \ + (_ifp)->if_type == IFT_L2VLAN ? (*vlan_cookie_p)((_ifp)) : NULL +#define VLAN_SETCOOKIE(_ifp, _cookie) \ + (_ifp)->if_type == IFT_L2VLAN ? \ + (*vlan_setcookie_p)((_ifp), (_cookie)) : EINVAL +#define VLAN_DEVAT(_ifp, _tag) \ + (_ifp)->if_vlantrunk != NULL ? (*vlan_devat_p)((_ifp), (_tag)) : NULL I think it is entirely safe to convert these checks inside functions into assertions. -- Gleb Smirnoff