From owner-svn-src-all@FreeBSD.ORG Sat Feb 22 19:20:41 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3D415634; Sat, 22 Feb 2014 19:20:41 +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 1B80C158C; Sat, 22 Feb 2014 19:20:41 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s1MJKeah007646; Sat, 22 Feb 2014 19:20:40 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s1MJKeGr007645; Sat, 22 Feb 2014 19:20:40 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201402221920.s1MJKeGr007645@svn.freebsd.org> From: Gleb Smirnoff Date: Sat, 22 Feb 2014 19:20:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262341 - 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: Sat, 22 Feb 2014 19:20:41 -0000 Author: glebius Date: Sat Feb 22 19:20:40 2014 New Revision: 262341 URL: http://svnweb.freebsd.org/changeset/base/262341 Log: Improve logging of send errors, reporting error code and interface. Reduce code duplication between INET and INET6. Tested by: Lytochkin Boris Modified: head/sys/netinet/ip_carp.c Modified: head/sys/netinet/ip_carp.c ============================================================================== --- head/sys/netinet/ip_carp.c Sat Feb 22 19:10:58 2014 (r262340) +++ head/sys/netinet/ip_carp.c Sat Feb 22 19:20:40 2014 (r262341) @@ -764,6 +764,35 @@ carp_send_ad(void *v) } static void +carp_send_ad_error(struct carp_softc *sc, int error) +{ + + if (error) { + if (sc->sc_sendad_errors < INT_MAX) + sc->sc_sendad_errors++; + if (sc->sc_sendad_errors == CARP_SENDAD_MAX_ERRORS) { + static const char fmt[] = "send error %d on %s"; + char msg[sizeof(fmt) + IFNAMSIZ]; + + sprintf(msg, fmt, error, sc->sc_carpdev->if_xname); + carp_demote_adj(V_carp_senderr_adj, msg); + } + sc->sc_sendad_success = 0; + } else { + if (sc->sc_sendad_errors >= CARP_SENDAD_MAX_ERRORS && + ++sc->sc_sendad_success >= CARP_SENDAD_MIN_SUCCESS) { + static const char fmt[] = "send ok on %s"; + char msg[sizeof(fmt) + IFNAMSIZ]; + + sprintf(msg, fmt, sc->sc_carpdev->if_xname); + carp_demote_adj(-V_carp_senderr_adj, msg); + sc->sc_sendad_errors = 0; + } else + sc->sc_sendad_errors = 0; + } +} + +static void carp_send_ad_locked(struct carp_softc *sc) { struct carp_header ch; @@ -839,25 +868,8 @@ carp_send_ad_locked(struct carp_softc *s CARPSTATS_INC(carps_opackets); - if (ip_output(m, NULL, NULL, IP_RAWOUTPUT, - &sc->sc_carpdev->if_carp->cif_imo, NULL)) { - if (sc->sc_sendad_errors < INT_MAX) - sc->sc_sendad_errors++; - if (sc->sc_sendad_errors == CARP_SENDAD_MAX_ERRORS) - carp_demote_adj(V_carp_senderr_adj, - "send error"); - sc->sc_sendad_success = 0; - } else { - if (sc->sc_sendad_errors >= CARP_SENDAD_MAX_ERRORS) { - if (++sc->sc_sendad_success >= - CARP_SENDAD_MIN_SUCCESS) { - carp_demote_adj(-V_carp_senderr_adj, - "send ok"); - sc->sc_sendad_errors = 0; - } - } else - sc->sc_sendad_errors = 0; - } + carp_send_ad_error(sc, ip_output(m, NULL, NULL, IP_RAWOUTPUT, + &sc->sc_carpdev->if_carp->cif_imo, NULL)); } #endif /* INET */ #ifdef INET6 @@ -913,25 +925,8 @@ carp_send_ad_locked(struct carp_softc *s CARPSTATS_INC(carps_opackets6); - if (ip6_output(m, NULL, NULL, 0, - &sc->sc_carpdev->if_carp->cif_im6o, NULL, NULL)) { - if (sc->sc_sendad_errors < INT_MAX) - sc->sc_sendad_errors++; - if (sc->sc_sendad_errors == CARP_SENDAD_MAX_ERRORS) - carp_demote_adj(V_carp_senderr_adj, - "send6 error"); - sc->sc_sendad_success = 0; - } else { - if (sc->sc_sendad_errors >= CARP_SENDAD_MAX_ERRORS) { - if (++sc->sc_sendad_success >= - CARP_SENDAD_MIN_SUCCESS) { - carp_demote_adj(-V_carp_senderr_adj, - "send6 ok"); - sc->sc_sendad_errors = 0; - } - } else - sc->sc_sendad_errors = 0; - } + carp_send_ad_error(sc, ip6_output(m, NULL, NULL, 0, + &sc->sc_carpdev->if_carp->cif_im6o, NULL, NULL)); } #endif /* INET6 */