On 08 Nov 2014, at 07:23 , Gleb Smirnoff <gleb...@freebsd.org> wrote:

> Author: glebius
> Date: Sat Nov  8 07:23:01 2014
> New Revision: 274274
> URL: https://svnweb.freebsd.org/changeset/base/274274
> 
> Log:
>  ifindex_alloc_locked() never fails and doesn't have no-lock version,
>  so change the prototype.
> 
>  Sponsored by:        Netflix
>  Sponsored by:        Nginx, Inc.
> 
> Modified:
>  head/sys/net/if.c
> 
> Modified: head/sys/net/if.c
> ==============================================================================
> --- 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;
> 
>       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 = idx;
> -     *idxp = idx;
> -     return (0);
> +     return (idx);
> }
> 
> static void
> @@ -431,11 +429,7 @@ if_alloc(u_char type)
> 
>       ifp = malloc(sizeof(struct ifnet), M_IFNET, M_WAITOK|M_ZERO);
>       IFNET_WLOCK();
> -     if (ifindex_alloc_locked(&idx) != 0) {
> -             IFNET_WUNLOCK();
> -             free(ifp, M_IFNET);
> -             return (NULL);
> -     }
> +     idx = ifindex_alloc();
>       ifnet_setbyindex_locked(idx, IFNET_HOLD);
>       IFNET_WUNLOCK();
>       ifp->if_index = 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;
> 
>       /*
>        * Detach from current vnet, but preserve LLADDR info, do not
> @@ -1054,11 +1047,7 @@ if_vmove(struct ifnet *ifp, struct vnet 
>       CURVNET_SET_QUIET(new_vnet);
> 
>       IFNET_WLOCK();
> -     if (ifindex_alloc_locked(&idx) != 0) {
> -             IFNET_WUNLOCK();
> -             panic("if_index overflow");
> -     }
> -     ifp->if_index = idx;
> +     ifp->if_index = ifindex_alloc();
>       ifnet_setbyindex_locked(ifp->if_index, ifp);
>       IFNET_WUNLOCK();
> 
> 

— 
Bjoern A. Zeeb             "Come on. Learn, goddamn it.", WarGames, 1983

_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to