From owner-dev-commits-src-all@freebsd.org Mon Apr 19 20:39:06 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 710F25FED97; Mon, 19 Apr 2021 20:39:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FPJZL2Jvqz4qdX; Mon, 19 Apr 2021 20:39:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3B2B425D41; Mon, 19 Apr 2021 20:39:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13JKd6Tm007358; Mon, 19 Apr 2021 20:39:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13JKd6og007357; Mon, 19 Apr 2021 20:39:06 GMT (envelope-from git) Date: Mon, 19 Apr 2021 20:39:06 GMT Message-Id: <202104192039.13JKd6og007357@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 758c9d54d44f - main - Improve error reporting in rtsock.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 758c9d54d44f8ce957570b8c2ef6d1b3f28a792d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Apr 2021 20:39:06 -0000 The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=758c9d54d44f8ce957570b8c2ef6d1b3f28a792d commit 758c9d54d44f8ce957570b8c2ef6d1b3f28a792d Author: Alexander V. Chernikov AuthorDate: 2021-04-19 20:36:41 +0000 Commit: Alexander V. Chernikov CommitDate: 2021-04-19 20:36:41 +0000 Improve error reporting in rtsock.c MFC after: 3 days --- sys/net/rtsock.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index c0996d318fb2..5194a2a15c1e 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -126,6 +126,9 @@ struct ifa_msghdrl32 { #endif /* COMPAT_FREEBSD32 */ +#define RTS_PID_PRINTF(_fmt, ...) \ + printf("rtsock:%s(): PID %d: " _fmt "\n", __func__, curproc->p_pid, ## __VA_ARGS__) + MALLOC_DEFINE(M_RTABLE, "routetbl", "routing tables"); /* NB: these are not modified */ @@ -571,7 +574,7 @@ fill_blackholeinfo(struct rt_addrinfo *info, union sockaddr_union *saun) sa_family_t saf; if (V_loif == NULL) { - printf("Unable to add blackhole/reject nhop without loopback"); + RTS_PID_PRINTF("Unable to add blackhole/reject nhop without loopback"); return (ENOTSUP); } info->rti_ifp = V_loif; @@ -1360,7 +1363,7 @@ cleanup_xaddrs_gateway(struct rt_addrinfo *info) { struct sockaddr_in *gw_sin = (struct sockaddr_in *)gw; if (gw_sin->sin_len < sizeof(struct sockaddr_in)) { - printf("gw sin_len too small\n"); + RTS_PID_PRINTF("gateway sin_len too small: %d", gw->sa_len); return (EINVAL); } fill_sockaddr_inet(gw_sin, gw_sin->sin_addr); @@ -1372,7 +1375,7 @@ cleanup_xaddrs_gateway(struct rt_addrinfo *info) { struct sockaddr_in6 *gw_sin6 = (struct sockaddr_in6 *)gw; if (gw_sin6->sin6_len < sizeof(struct sockaddr_in6)) { - printf("gw sin6_len too small\n"); + RTS_PID_PRINTF("gateway sin6_len too small: %d", gw->sa_len); return (EINVAL); } fill_sockaddr_inet6(gw_sin6, &gw_sin6->sin6_addr, 0); @@ -1386,7 +1389,7 @@ cleanup_xaddrs_gateway(struct rt_addrinfo *info) size_t sdl_min_len = offsetof(struct sockaddr_dl, sdl_data); gw_sdl = (struct sockaddr_dl *)gw; if (gw_sdl->sdl_len < sdl_min_len) { - printf("gw sdl_len too small\n"); + RTS_PID_PRINTF("gateway sdl_len too small: %d", gw_sdl->sdl_len); return (EINVAL); } @@ -1433,7 +1436,7 @@ cleanup_xaddrs_inet(struct rt_addrinfo *info) return (EINVAL); } if (mask_sa && mask_sa->sin_len < sizeof(struct sockaddr_in)) { - printf("mask sin_len too small\n"); + RTS_PID_PRINTF("prefix mask sin_len too small: %d", mask_sa->sin_len); return (EINVAL); } fill_sockaddr_inet(dst_sa, dst); @@ -1466,11 +1469,11 @@ cleanup_xaddrs_inet6(struct rt_addrinfo *info) IN6_MASK_ADDR(&dst_sa->sin6_addr, &mask); if (dst_sa->sin6_len < sizeof(struct sockaddr_in6)) { - printf("dst sin6_len too small\n"); + RTS_PID_PRINTF("prefix dst sin6_len too small: %d", dst_sa->sin6_len); return (EINVAL); } if (mask_sa && mask_sa->sin6_len < sizeof(struct sockaddr_in6)) { - printf("mask sin6_len too small\n"); + RTS_PID_PRINTF("rtsock: prefix mask sin6_len too small: %d", mask_sa->sin6_len); return (EINVAL); } fill_sockaddr_inet6(dst_sa, &dst_sa->sin6_addr, 0); @@ -2092,9 +2095,9 @@ rt_dispatch(struct mbuf *m, sa_family_t saf) } /* - * Checks if rte can be exported v.r.t jails/vnets. + * Checks if rte can be exported w.r.t jails/vnets. * - * Returns 1 if it can, 0 otherwise. + * Returns true if it can, false otherwise. */ static bool can_export_rte(struct ucred *td_ucred, bool rt_is_host,