From owner-svn-src-all@FreeBSD.ORG Fri Jan 3 11:03:13 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1C0DB636; Fri, 3 Jan 2014 11:03:13 +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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id E1A6311A1; Fri, 3 Jan 2014 11:03:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s03B3CKR013124; Fri, 3 Jan 2014 11:03:12 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s03B3CAf013123; Fri, 3 Jan 2014 11:03:12 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201401031103.s03B3CAf013123@svn.freebsd.org> From: Gleb Smirnoff Date: Fri, 3 Jan 2014 11:03:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r260224 - head/sys/netinet 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.17 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: Fri, 03 Jan 2014 11:03:13 -0000 Author: glebius Date: Fri Jan 3 11:03:12 2014 New Revision: 260224 URL: http://svnweb.freebsd.org/changeset/base/260224 Log: Make failure of ifpromisc() a non-fatal error. This makes it possible to run carp(4) on vtnet(4). Sponsored by: Nginx, Inc. Modified: head/sys/netinet/ip_carp.c Modified: head/sys/netinet/ip_carp.c ============================================================================== --- head/sys/netinet/ip_carp.c Fri Jan 3 09:10:04 2014 (r260223) +++ head/sys/netinet/ip_carp.c Fri Jan 3 11:03:12 2014 (r260224) @@ -145,6 +145,8 @@ struct carp_if { #endif struct ifnet *cif_ifp; struct mtx cif_mtx; + uint32_t cif_flags; +#define CIF_PROMISC 0x00000001 }; #define CARP_INET 0 @@ -1483,11 +1485,8 @@ carp_alloc(struct ifnet *ifp) struct carp_softc *sc; struct carp_if *cif; - if ((cif = ifp->if_carp) == NULL) { + if ((cif = ifp->if_carp) == NULL) cif = carp_alloc_if(ifp); - if (cif == NULL) - return (NULL); - } sc = malloc(sizeof(*sc), M_CARP, M_WAITOK|M_ZERO); @@ -1572,11 +1571,15 @@ static struct carp_if* carp_alloc_if(struct ifnet *ifp) { struct carp_if *cif; + int error; cif = malloc(sizeof(*cif), M_CARP, M_WAITOK|M_ZERO); - if (ifpromisc(ifp, 1) != 0) - goto cleanup; + if ((error = ifpromisc(ifp, 1)) != 0) + printf("%s: ifpromisc(%s) failed: %d\n", + __func__, ifp->if_xname, error); + else + cif->cif_flags |= CIF_PROMISC; CIF_LOCK_INIT(cif); cif->cif_ifp = ifp; @@ -1588,11 +1591,6 @@ carp_alloc_if(struct ifnet *ifp) IF_ADDR_WUNLOCK(ifp); return (cif); - -cleanup: - free(cif, M_CARP); - - return (NULL); } static void @@ -1610,7 +1608,8 @@ carp_free_if(struct carp_if *cif) CIF_LOCK_DESTROY(cif); - ifpromisc(ifp, 0); + if (cif->cif_flags & CIF_PROMISC) + ifpromisc(ifp, 0); if_rele(ifp); free(cif, M_CARP); @@ -1683,11 +1682,6 @@ carp_ioctl(struct ifreq *ifr, u_long cmd } if (sc == NULL) { sc = carp_alloc(ifp); - if (sc == NULL) { - error = EINVAL; /* XXX: ifpromisc failed */ - break; - } - CARP_LOCK(sc); sc->sc_vhid = carpr.carpr_vhid; LLADDR(&sc->sc_addr)[0] = 0;