From owner-svn-src-all@FreeBSD.ORG Sat Nov 8 15:06:30 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A8513B2D; Sat, 8 Nov 2014 15:06:30 +0000 (UTC) Received: from mx1.sbone.de (mx1.sbone.de [IPv6:2a01:4f8:130:3ffc::401:25]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "mx1.sbone.de", Issuer "SBone.DE" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 390879FD; Sat, 8 Nov 2014 15:06:30 +0000 (UTC) Received: from mail.sbone.de (mail.sbone.de [IPv6:fde9:577b:c1a9:31::2013:587]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.sbone.de (Postfix) with ESMTPS id BA12F25D3892; Sat, 8 Nov 2014 15:06:27 +0000 (UTC) Received: from content-filter.sbone.de (content-filter.sbone.de [IPv6:fde9:577b:c1a9:31::2013:2742]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPS id C641BC7700C; Sat, 8 Nov 2014 15:06:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at sbone.de Received: from mail.sbone.de ([IPv6:fde9:577b:c1a9:31::2013:587]) by content-filter.sbone.de (content-filter.sbone.de [fde9:577b:c1a9:31::2013:2742]) (amavisd-new, port 10024) with ESMTP id 60zX23p9iBLs; Sat, 8 Nov 2014 15:06:25 +0000 (UTC) Received: from [IPv6:fde9:577b:c1a9:4420:cabc:c8ff:fe8b:4fe6] (orange-tun0-ula.sbone.de [IPv6:fde9:577b:c1a9:4420:cabc:c8ff:fe8b:4fe6]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id 232BFC76FF5; Sat, 8 Nov 2014 15:06:23 +0000 (UTC) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: svn commit: r274274 - head/sys/net From: "Bjoern A. Zeeb" In-Reply-To: <201411080723.sA87N2hx046823@svn.freebsd.org> Date: Sat, 8 Nov 2014 15:06:20 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: <8B3F77C9-C79D-4303-ADB6-310B3928D51C@FreeBSD.org> References: <201411080723.sA87N2hx046823@svn.freebsd.org> To: Gleb Smirnoff X-Mailer: Apple Mail (2.1878.6) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org 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: Sat, 08 Nov 2014 15:06:30 -0000 On 08 Nov 2014, at 07:23 , Gleb Smirnoff wrote: > Author: glebius > Date: Sat Nov 8 07:23:01 2014 > New Revision: 274274 > URL: https://svnweb.freebsd.org/changeset/base/274274 >=20 > Log: > ifindex_alloc_locked() never fails and doesn't have no-lock version, > so change the prototype. >=20 > Sponsored by: Netflix > Sponsored by: Nginx, Inc. >=20 > Modified: > head/sys/net/if.c >=20 > Modified: head/sys/net/if.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sys/net/if.c Sat Nov 8 06:43:33 2014 (r274273) > +++ head/sys/net/if.c Sat Nov 8 07:23:01 2014 (r274274) > @@ -265,13 +265,12 @@ ifnet_byindex_ref(u_short idx) > * Allocate an ifindex array entry; return 0 on success or an error on > * failure. > */ > -static int > -ifindex_alloc_locked(u_short *idxp) > +static u_short That feels like going backwards; we should really make sure we can = support ifindexes >> 64k > +ifindex_alloc(void) > { > u_short idx; >=20 > IFNET_WLOCK_ASSERT(); > - > retry: > /* > * Try to find an empty slot below V_if_index. If we fail, take = the > @@ -289,8 +288,7 @@ retry: > } > if (idx > V_if_index) > V_if_index =3D idx; > - *idxp =3D idx; > - return (0); > + return (idx); > } >=20 > static void > @@ -431,11 +429,7 @@ if_alloc(u_char type) >=20 > ifp =3D malloc(sizeof(struct ifnet), M_IFNET, M_WAITOK|M_ZERO); > IFNET_WLOCK(); > - if (ifindex_alloc_locked(&idx) !=3D 0) { > - IFNET_WUNLOCK(); > - free(ifp, M_IFNET); > - return (NULL); > - } > + idx =3D ifindex_alloc(); > ifnet_setbyindex_locked(idx, IFNET_HOLD); > IFNET_WUNLOCK(); > ifp->if_index =3D idx; > @@ -1022,7 +1016,6 @@ if_detach_internal(struct ifnet *ifp, in > void > if_vmove(struct ifnet *ifp, struct vnet *new_vnet) > { > - u_short idx; >=20 > /* > * Detach from current vnet, but preserve LLADDR info, do not > @@ -1054,11 +1047,7 @@ if_vmove(struct ifnet *ifp, struct vnet=20 > CURVNET_SET_QUIET(new_vnet); >=20 > IFNET_WLOCK(); > - if (ifindex_alloc_locked(&idx) !=3D 0) { > - IFNET_WUNLOCK(); > - panic("if_index overflow"); > - } > - ifp->if_index =3D idx; > + ifp->if_index =3D ifindex_alloc(); > ifnet_setbyindex_locked(ifp->if_index, ifp); > IFNET_WUNLOCK(); >=20 >=20 =97=20 Bjoern A. Zeeb "Come on. Learn, goddamn it.", WarGames, 1983