Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 Nov 2014 15:06:20 +0000
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        Gleb Smirnoff <glebius@FreeBSD.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r274274 - head/sys/net
Message-ID:  <8B3F77C9-C79D-4303-ADB6-310B3928D51C@FreeBSD.org>
In-Reply-To: <201411080723.sA87N2hx046823@svn.freebsd.org>
References:  <201411080723.sA87N2hx046823@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

On 08 Nov 2014, at 07:23 , Gleb Smirnoff <glebius@FreeBSD.org> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8B3F77C9-C79D-4303-ADB6-310B3928D51C>