From owner-svn-src-all@FreeBSD.ORG Sat Nov 8 07:23:02 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 C9387D7; Sat, 8 Nov 2014 07:23:02 +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 9B8E7C29; Sat, 8 Nov 2014 07:23:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sA87N2GX046824; Sat, 8 Nov 2014 07:23:02 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sA87N2hx046823; Sat, 8 Nov 2014 07:23:02 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201411080723.sA87N2hx046823@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Sat, 8 Nov 2014 07:23:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r274274 - 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: Sat, 08 Nov 2014 07:23:02 -0000 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 +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();