Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net/lagg Use addlog(4) for putting 2 messages to one line



details:   https://anonhg.NetBSD.org/src/rev/df8cc892e980
branches:  trunk
changeset: 364606:df8cc892e980
user:      yamaguchi <yamaguchi%NetBSD.org@localhost>
date:      Thu Mar 31 03:15:15 2022 +0000

description:
Use addlog(4) for putting 2 messages to one line

diffstat:

 sys/net/lagg/if_lagg.c      |  91 ++++++++++++++++----------------------------
 sys/net/lagg/if_lagg_lacp.c |   8 +-
 sys/net/lagg/if_laggproto.h |  22 +++++++++-
 3 files changed, 57 insertions(+), 64 deletions(-)

diffs (truncated from 354 to 300 lines):

diff -r 27d4ff43cbcd -r df8cc892e980 sys/net/lagg/if_lagg.c
--- a/sys/net/lagg/if_lagg.c    Thu Mar 31 03:12:31 2022 +0000
+++ b/sys/net/lagg/if_lagg.c    Thu Mar 31 03:15:15 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_lagg.c,v 1.41 2022/03/31 03:12:31 yamaguchi Exp $   */
+/*     $NetBSD: if_lagg.c,v 1.42 2022/03/31 03:15:15 yamaguchi Exp $   */
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter <reyk%openbsd.org@localhost>
@@ -20,7 +20,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.41 2022/03/31 03:12:31 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg.c,v 1.42 2022/03/31 03:15:15 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -244,15 +244,6 @@
        return s;
 }
 
-static bool
-lagg_debug_enable(struct lagg_softc *sc)
-{
-       if (__predict_false(ISSET(sc->sc_if.if_flags, IFF_DEBUG)))
-               return true;
-
-       return false;
-}
-
 static void
 lagg_evcnt_attach(struct lagg_softc *sc,
     struct evcnt *ev, const char *name)
@@ -743,7 +734,7 @@
                        error = lagg_lp_ioctl(lp, cmd, (void *)ifr);
 
                        if (error != 0) {
-                               lagg_log(sc, LOG_ERR,
+                               LAGG_LOG(sc, LOG_ERR,
                                    "failed to change MTU to %d on port %s, "
                                    "reverting all ports to original "
                                    "MTU(%" PRIu64 ")\n",
@@ -798,65 +789,65 @@
 static int
 lagg_setup_sysctls(struct lagg_softc *sc)
 {
-       struct sysctllog **log;
+       struct sysctllog **slog;
        const struct sysctlnode **rnode, *hashnode;
        const char *ifname;
        int error;
 
-       log = &sc->sc_sysctllog;
+       slog = &sc->sc_sysctllog;
        rnode = &sc->sc_sysctlnode;
        ifname = sc->sc_if.if_xname;
 
-       error = sysctl_createv(log, 0, NULL, rnode,
+       error = sysctl_createv(slog, 0, NULL, rnode,
            CTLFLAG_PERMANENT, CTLTYPE_NODE, ifname,
            SYSCTL_DESCR("lagg information and settings"),
            NULL, 0, NULL, 0, CTL_NET, CTL_CREATE, CTL_EOL);
        if (error != 0)
                goto done;
 
-       error = sysctl_createv(log, 0, rnode, &hashnode,
+       error = sysctl_createv(slog, 0, rnode, &hashnode,
            CTLFLAG_PERMANENT, CTLTYPE_NODE, "hash",
            SYSCTL_DESCR("hash calculation settings"),
            NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL);
        if (error != 0)
                goto done;
 
-       error = sysctl_createv(log, 0, &hashnode, NULL,
+       error = sysctl_createv(slog, 0, &hashnode, NULL,
            CTLFLAG_READWRITE, CTLTYPE_BOOL, "macaddr",
            SYSCTL_DESCR("use src/dst mac addresses"),
            NULL, 0, &sc->sc_hash_mac, 0, CTL_CREATE, CTL_EOL);
        if (error != 0)
                goto done;
 
-       error = sysctl_createv(log, 0, &hashnode, NULL,
+       error = sysctl_createv(slog, 0, &hashnode, NULL,
            CTLFLAG_READWRITE, CTLTYPE_BOOL, "ipaddr",
            SYSCTL_DESCR("use src/dst IPv4 addresses"),
            NULL, 0, &sc->sc_hash_ipaddr, 0, CTL_CREATE, CTL_EOL);
        if (error != 0)
                goto done;
 
-       error = sysctl_createv(log, 0, &hashnode, NULL,
+       error = sysctl_createv(slog, 0, &hashnode, NULL,
            CTLFLAG_READWRITE, CTLTYPE_BOOL, "ip6addr",
            SYSCTL_DESCR("use src/dst IPv6 addresses"),
            NULL, 0, &sc->sc_hash_ip6addr, 0, CTL_CREATE, CTL_EOL);
        if (error != 0)
                goto done;
 
-       error = sysctl_createv(log, 0, &hashnode, NULL,
+       error = sysctl_createv(slog, 0, &hashnode, NULL,
            CTLFLAG_READWRITE, CTLTYPE_BOOL, "tcp",
            SYSCTL_DESCR("use TCP src/dst port"),
            NULL, 0, &sc->sc_hash_tcp, 0, CTL_CREATE, CTL_EOL);
        if (error != 0)
                goto done;
 
-       error = sysctl_createv(log, 0, &hashnode, NULL,
+       error = sysctl_createv(slog, 0, &hashnode, NULL,
           CTLFLAG_READWRITE, CTLTYPE_BOOL, "udp",
           SYSCTL_DESCR("use UDP src/dst port"),
           NULL, 0, &sc->sc_hash_udp, 0, CTL_CREATE, CTL_EOL);
 done:
        if (error != 0) {
-               lagg_log(sc, LOG_ERR, "unable to create sysctl node\n");
-               sysctl_teardown(log);
+               LAGG_LOG(sc, LOG_ERR, "unable to create sysctl node\n");
+               sysctl_teardown(slog);
        }
 
        return error;
@@ -1243,7 +1234,7 @@
        LAGG_PORTS_FOREACH(sc, lp) {
                error = lagg_port_vlan_cb(lp, lvt, set);
                if (error != 0) {
-                       lagg_log(sc, LOG_WARNING,
+                       LAGG_LOG(sc, LOG_WARNING,
                            "%s failed to configure vlan on %d\n",
                            lp->lp_ifp->if_xname, error);
                }
@@ -1763,7 +1754,7 @@
        TAILQ_FOREACH(lvt, &sc->sc_vtags, lvt_entry) {
                error = lagg_port_vlan_cb(lp, lvt, set);
                if (error != 0) {
-                       lagg_log(sc, LOG_WARNING,
+                       LAGG_LOG(sc, LOG_WARNING,
                            "%s failed to configure vlan on %d\n",
                            lp->lp_ifp->if_xname, error);
                }
@@ -1817,9 +1808,9 @@
                error = lagg_setifcaps(lp, ifp->if_capenable);
 
                if (error != 0) {
-                       lagg_log(sc, LOG_WARNING,
+                       LAGG_LOG(sc, LOG_WARNING,
                            "failed to update capabilities "
-                           "of %s, error=%d",
+                           "of %s, error=%d\n",
                            lp->lp_ifp->if_xname, error);
                }
        }
@@ -1865,9 +1856,9 @@
 
                error = lagg_setethcaps(lp, ec->ec_capenable);
                if (error != 0) {
-                       lagg_log(sc, LOG_WARNING,
+                       LAGG_LOG(sc, LOG_WARNING,
                            "failed to update ether "
-                           "capabilities"" of %s, error=%d",
+                           "capabilities"" of %s, error=%d\n",
                            lp->lp_ifp->if_xname, error);
                }
 
@@ -1914,8 +1905,8 @@
        }
 
        if (pena != ena) {
-               lagg_log(sc, LOG_DEBUG, "couldn't set "
-                   "capabilities 0x%08"PRIx64, pena);
+               LAGG_LOG(sc, LOG_DEBUG, "couldn't set "
+                   "capabilities 0x%08"PRIx64"\n", pena);
        }
 
        ifp = &sc->sc_if;
@@ -1925,8 +1916,8 @@
                ifp->if_capabilities = cap;
                ifp->if_capenable = ena;
 
-               lagg_log(sc, LOG_DEBUG,"capabilities "
-                   "0x%08"PRIx64" enabled 0x%08"PRIx64,
+               LAGG_LOG(sc, LOG_DEBUG,"capabilities "
+                   "0x%08"PRIx64" enabled 0x%08"PRIx64"\n",
                    cap, ena);
        }
 }
@@ -1989,8 +1980,8 @@
        }
 
        if (pena != ena) {
-               lagg_log(sc, LOG_DEBUG, "couldn't set "
-                   "ether capabilities 0x%08x", pena);
+               LAGG_LOG(sc, LOG_DEBUG, "couldn't set "
+                   "ether capabilities 0x%08x\n", pena);
        }
 
        ec = (struct ethercom *)&sc->sc_if;
@@ -2000,9 +1991,9 @@
                ec->ec_capabilities = cap;
                ec->ec_capenable = ena;
 
-               lagg_log(sc, LOG_DEBUG,
+               LAGG_LOG(sc, LOG_DEBUG,
                    "ether capabilities 0x%08x"
-                   " enabled 0x%08x", cap, ena);
+                   " enabled 0x%08x\n", cap, ena);
        }
 }
 
@@ -2077,7 +2068,7 @@
                ifr.ifr_mtu = lp->lp_mtu;
                error = lp->lp_ioctl(ifp_port, SIOCSIFMTU, (void *)&ifr);
                if (error != 0) {
-                       lagg_log(sc, LOG_WARNING,
+                       LAGG_LOG(sc, LOG_WARNING,
                            "failed to reset MTU %d to %s\n",
                            ifr.ifr_mtu, ifp_port->if_xname);
                }
@@ -2116,7 +2107,7 @@
                                error = if_init(ifp_port);
 
                        if (error != 0) {
-                               lagg_log(lp->lp_softc, LOG_WARNING,
+                               LAGG_LOG(lp->lp_softc, LOG_WARNING,
                                    "%s failed to if_init() on %d\n",
                                    ifp_port->if_xname, error);
                        }
@@ -2158,7 +2149,7 @@
                                error = if_init(ifp_port);
 
                        if (error != 0) {
-                               lagg_log(lp->lp_softc, LOG_WARNING,
+                               LAGG_LOG(lp->lp_softc, LOG_WARNING,
                                    "%s failed to if_init() on %d\n",
                                    ifp_port->if_xname, error);
                        }
@@ -2409,7 +2400,7 @@
        lagg_in6_ifdetach(ifp_port);
        if (stopped) {
                if (if_init(ifp_port) != 0) {
-                       lagg_log(sc, LOG_WARNING,
+                       LAGG_LOG(sc, LOG_WARNING,
                            "couldn't re-start port %s\n",
                            ifp_port->if_xname);
                }
@@ -2667,7 +2658,7 @@
        if (error == 0) {
                lp->lp_promisc = promisc;
        } else {
-               lagg_log(sc, LOG_WARNING,
+               LAGG_LOG(sc, LOG_WARNING,
                    "couldn't %s promisc on %s\n",
                    promisc ? "set" : "unset",
                    ifp_port->if_xname);
@@ -2693,7 +2684,7 @@
        }
 
        if (error != 0) {
-               lagg_log(sc, LOG_WARNING,
+               LAGG_LOG(sc, LOG_WARNING,
                    "couldn't unset promisc on %s\n",
                    ifp_port->if_xname);
        }
@@ -2860,20 +2851,6 @@
        psref_release(psref, &lp->lp_psref, lagg_port_psref_class);
 }
 
-void
-lagg_log(struct lagg_softc *sc, int lvl, const char *fmt, ...)
-{
-       va_list ap;
-
-       if (lvl == LOG_DEBUG && !lagg_debug_enable(sc))
-               return;
-
-       log(lvl, "%s: ", sc->sc_if.if_xname);
-       va_start(ap, fmt);
-       vlog(lvl, fmt, ap);
-       va_end(ap);
-}
-
 static void
 lagg_workq_work(struct work *wk, void *context)
 {
diff -r 27d4ff43cbcd -r df8cc892e980 sys/net/lagg/if_lagg_lacp.c
--- a/sys/net/lagg/if_lagg_lacp.c       Thu Mar 31 03:12:31 2022 +0000
+++ b/sys/net/lagg/if_lagg_lacp.c       Thu Mar 31 03:15:15 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_lagg_lacp.c,v 1.19 2022/03/31 03:04:04 yamaguchi Exp $      */
+/*     $NetBSD: if_lagg_lacp.c,v 1.20 2022/03/31 03:15:15 yamaguchi Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.19 2022/03/31 03:04:04 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_lagg_lacp.c,v 1.20 2022/03/31 03:15:15 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lagg.h"



Home | Main Index | Thread Index | Old Index