svn commit: r333476 - head/sys/net
Rodney W. Grimes
freebsd at pdx.rh.CN85.dnsmgr.net
Fri May 11 01:02:00 UTC 2018
> Author: des
> Date: Fri May 11 00:19:49 2018
> New Revision: 333476
> URL: https://svnweb.freebsd.org/changeset/base/333476
>
> Log:
> Slight cleanup of interface event logging.
>
> Make if_printf() use vlog() instead of vprintf(). This means it can no
> longer return the number of characters printed, as it used to, but every
> single call to if_printf() in the entire kernel ignores the return value
> anyway; just return 0 so we don't have to change the prototype.
>
> Consistently use if_printf() throughout sys/net/if.c, instead of a
> mixture of if_printf() and log().
>
> In ifa_maintain_loopback_route(), don't needlessly log an error if we
> either failed to add a route because it already existed or failed to
> remove one because it did not. We still return an error code, though.
Those are the only conditions under which I have ever
seen this code log anything. These usually occur for
me when a tunX device is going down, the route gets
ripped out long before maintain_loopback ever has a
chance to remove it.
I still feel this whole maintain_loopback_route() is a
implementaton of a hardcoded route policy in the kernel
that we do not need, or want.
> MFC after: 1 week
>
> Modified:
> head/sys/net/if.c
>
> Modified: head/sys/net/if.c
> ==============================================================================
> --- head/sys/net/if.c Fri May 11 00:01:43 2018 (r333475)
> +++ head/sys/net/if.c Fri May 11 00:19:49 2018 (r333476)
> @@ -1832,9 +1832,10 @@ ifa_maintain_loopback_route(int cmd, const char *otype
>
> error = rtrequest1_fib(cmd, &info, NULL, ifp->if_fib);
>
> - if (error != 0)
> - log(LOG_DEBUG, "%s: %s failed for interface %s: %u\n",
> - __func__, otype, if_name(ifp), error);
> + if (error != 0 &&
> + !(cmd == RTM_ADD && error == EEXIST) &&
> + !(cmd == RTM_DELETE && error == ENOENT))
> + if_printf(ifp, "%s failed: %d\n", otype, error);
>
> return (error);
> }
> @@ -2328,7 +2329,7 @@ do_link_state_change(void *arg, int pending)
> if (pending > 1)
> if_printf(ifp, "%d link states coalesced\n", pending);
> if (log_link_state_change)
> - log(LOG_NOTICE, "%s: link state changed to %s\n", ifp->if_xname,
> + if_printf(ifp, "link state changed to %s\n",
> (link_state == LINK_STATE_UP) ? "UP" : "DOWN" );
> EVENTHANDLER_INVOKE(ifnet_link_event, ifp, link_state);
> CURVNET_RESTORE();
> @@ -2631,8 +2632,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data,
> else if (ifp->if_pcount == 0)
> ifp->if_flags &= ~IFF_PROMISC;
> if (log_promisc_mode_change)
> - log(LOG_INFO, "%s: permanently promiscuous mode %s\n",
> - ifp->if_xname,
> + if_printf(ifp, "permanently promiscuous mode %s\n",
> ((new_flags & IFF_PPROMISC) ?
> "enabled" : "disabled"));
> }
> @@ -2695,8 +2695,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data,
> rt_ifannouncemsg(ifp, IFAN_DEPARTURE);
> EVENTHANDLER_INVOKE(ifnet_departure_event, ifp);
>
> - log(LOG_INFO, "%s: changing name to '%s'\n",
> - ifp->if_xname, new_name);
> + if_printf(ifp, "changing name to '%s'\n", new_name);
>
> IF_ADDR_WLOCK(ifp);
> strlcpy(ifp->if_xname, new_name, sizeof(ifp->if_xname));
> @@ -3199,8 +3198,7 @@ ifpromisc(struct ifnet *ifp, int pswitch)
> /* If promiscuous mode status has changed, log a message */
> if (error == 0 && ((ifp->if_flags ^ oldflags) & IFF_PROMISC) &&
> log_promisc_mode_change)
> - log(LOG_INFO, "%s: promiscuous mode %s\n",
> - ifp->if_xname,
> + if_printf(ifp, "promiscuous mode %s\n",
> (ifp->if_flags & IFF_PROMISC) ? "enabled" : "disabled");
> return (error);
> }
> @@ -3905,16 +3903,16 @@ if_initname(struct ifnet *ifp, const char *name, int u
> }
>
> int
> -if_printf(struct ifnet *ifp, const char * fmt, ...)
> +if_printf(struct ifnet *ifp, const char *fmt, ...)
> {
> + char if_fmt[256];
> va_list ap;
> - int retval;
>
> - retval = printf("%s: ", ifp->if_xname);
> + snprintf(if_fmt, sizeof(if_fmt), "%s: %s", ifp->if_xname, fmt);
> va_start(ap, fmt);
> - retval += vprintf(fmt, ap);
> + vlog(LOG_INFO, if_fmt, ap);
> va_end(ap);
> - return (retval);
> + return (0);
> }
>
> void
>
>
--
Rod Grimes rgrimes at freebsd.org
More information about the svn-src-all
mailing list