The branch main has been updated by melifaro:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=bddae5c8a64dc6b292198945cbe676bb2158d438

commit bddae5c8a64dc6b292198945cbe676bb2158d438
Author:     Alexander V. Chernikov <[email protected]>
AuthorDate: 2021-04-23 21:28:38 +0000
Commit:     Alexander V. Chernikov <[email protected]>
CommitDate: 2021-04-24 22:41:27 +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
---
 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
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main
To unsubscribe, send any mail to "[email protected]"

Reply via email to