From owner-dev-commits-src-all@freebsd.org Mon Apr 26 09:12:04 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 688915F9943; Mon, 26 Apr 2021 09:12:04 +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 4FTK0M6fNVz58Dr; Mon, 26 Apr 2021 09:12:03 +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 BF92124C26; Mon, 26 Apr 2021 09:12:03 +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 13Q9C3Tv091219; Mon, 26 Apr 2021 09:12:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13Q9C3fd091218; Mon, 26 Apr 2021 09:12:03 GMT (envelope-from git) Date: Mon, 26 Apr 2021 09:12:03 GMT Message-Id: <202104260912.13Q9C3fd091218@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: fe04896da3fb - stable/13 - Improve debugging output on routing tests failure. 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/stable/13 X-Git-Reftype: branch X-Git-Commit: fe04896da3fbfc6c57154024dee090f365c8f1b1 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, 26 Apr 2021 09:12:04 -0000 The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=fe04896da3fbfc6c57154024dee090f365c8f1b1 commit fe04896da3fbfc6c57154024dee090f365c8f1b1 Author: Alexander V. Chernikov AuthorDate: 2021-04-23 21:28:38 +0000 Commit: Alexander V. Chernikov CommitDate: 2021-04-26 08:49:14 +0000 Improve debugging output on routing tests failure. Most of the routing tests create per-test VNET, making it harder to repeat the failure with CLI tools. Provide an additional route/nexthop data on failure. Differential Revision: https://reviews.freebsd.org/D29957 Reviewed by: kp MFC after: 2 weeks (cherry picked from commit bddae5c8a64dc6b292198945cbe676bb2158d438) --- tests/sys/net/routing/rtsock_print.h | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/sys/net/routing/rtsock_print.h b/tests/sys/net/routing/rtsock_print.h index b44fcca25053..20bb1c51bc33 100644 --- a/tests/sys/net/routing/rtsock_print.h +++ b/tests/sys/net/routing/rtsock_print.h @@ -40,7 +40,10 @@ #define RTSOCK_ATF_REQUIRE_MSG(_rtm, _cond, _fmt, ...) do { \ if (!(_cond)) { \ printf("-- CONDITION FAILED, rtm dump --\n\n");\ - rtsock_print_message(_rtm); \ + rtsock_print_message(_rtm); \ + rtsock_print_table(AF_INET); \ + rtsock_print_table(AF_INET6); \ + printf("===================================\n");\ } \ ATF_REQUIRE_MSG(_cond, _fmt, ##__VA_ARGS__); \ } while (0); @@ -381,4 +384,31 @@ rtsock_print_message(struct rt_msghdr *rtm) } } +static void +print_command(char *cmd) +{ + char line[1024]; + + FILE *fp = popen(cmd, "r"); + if (fp != NULL) { + while (fgets(line, sizeof(line), fp) != NULL) + printf("%s", line); + pclose(fp); + } +} + +void +rtsock_print_table(int family) +{ + char cmdbuf[128]; + char *key = (family == AF_INET) ? "4" : "6"; + + snprintf(cmdbuf, sizeof(cmdbuf), "/usr/bin/netstat -%srnW", key); + printf("==== %s ===\n", cmdbuf); + print_command(cmdbuf); + snprintf(cmdbuf, sizeof(cmdbuf), "/usr/bin/netstat -%sonW", key); + printf("==== %s ===\n", cmdbuf); + print_command(cmdbuf); +} + #endif