From nobody Fri Jan 13 21:24:50 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NtvZW2Q46z2qkZ3; Fri, 13 Jan 2023 21:24:51 +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 4NtvZW1Cs3z40vg; Fri, 13 Jan 2023 21:24:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673645091; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3O2mDdeUzrYT0OlmcuAt8OJB6I7UGprgH94JiRKeBmk=; b=xFRolKW8M5COQAA770n+liqw37apXvjcCdOvqiDIXyiG3jwHSOkJ/HCT4KzX2R/FT6EKYN 5hvLw4182grSqRlVvtDuRxXDdCeR3h5XFQ6G+1n0oSOryHdzV5/KdiwUqBp7V/gWlgJ+Tj J0GczDB/74jMgrStF0dq2EiZJnQFJowx5fepiund80A6ky6+FQ6Ji3RVq0HeyyOi3xRxc8 0WExEJsEDMkscsLAX48qoUYdaEnYCWcIcM6VQ7Z46nqxN/B4mcUyaQCxqCe02fyQLU1vBi V7s8ahWh/mA/lfeYwwjWJKtph5DWNFAE0zumdCSyP6TwC6Y8yETfmraMj8d0RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673645091; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3O2mDdeUzrYT0OlmcuAt8OJB6I7UGprgH94JiRKeBmk=; b=EvnGuPJICHUwP8hKT1/jEssIG6JToTXaeQa1yVNdztRCfSd8jPk+j793Lr/PJRGWKRBKL3 NKcq0Xj5IdqFc9T9ijNSTbag0it/8ckTlrrYI/PnKkNehMEELl/0qb2Uu6diGZuWSLKk5/ Vn7NexRzJKrlybLhMrzLp3TedTQ9/hyaZCdkQi6TMfiSl5hYg1mx1jm2Jen10Ss50sCKlD /HWH0PdCN2JIHKPWuRvOdxIZrIqoZQ9Pjx9xbDaZJCWTPXCyfzANGp/krEfqJWrEKFiUy1 hEZ3hthOxUEjZQRD8/mufHuj4pHf26k01sgyNv5+SKVAZMs2EHj9RnpF+oFH/g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673645091; a=rsa-sha256; cv=none; b=Cassg70aNK4N6hNv+djFAai6XVwiqbPL9KL21Bb2ja7T1bzx59QMuheCSTu0YhU1VPdjQM F6wpjxKXfIrjGzWoQHyCF656XyCfVrxYA1WeR8DSQ3/QLlV6oSIshDR0DolV64BqutZC6J CxIGX8swMk1r+AS5mc3//OV0qsP1kaOvr8hHz0PgWwtSxmEzlAxQRdICKT74ShqKnQq3W5 dxSgAZTbBPccsoGZpzcR30yE2xqK76REJpZJAo7JE4XAWjgv6JvV7xL4esvGb6KqJEh110 DQv768WzJJ4b7Bb9PfqbG8JO/zvqMixKzkYCJRy11iFi0Am2s3JCLqJytNzfSA== 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 4NtvZW09WBzNBW; Fri, 13 Jan 2023 21:24:51 +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 30DLOo5C040853; Fri, 13 Jan 2023 21:24:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30DLOoWe040852; Fri, 13 Jan 2023 21:24:50 GMT (envelope-from git) Date: Fri, 13 Jan 2023 21:24:50 GMT Message-Id: <202301132124.30DLOoWe040852@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: 1d5633bdb56f - stable/13 - routing: add debug printing helpers for rtentry and RTM* cmds. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org 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: 1d5633bdb56fb98ce75c55ceb3dd5699be5da487 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=1d5633bdb56fb98ce75c55ceb3dd5699be5da487 commit 1d5633bdb56fb98ce75c55ceb3dd5699be5da487 Author: Alexander V. Chernikov AuthorDate: 2022-07-31 09:00:42 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-01-13 21:18:25 +0000 routing: add debug printing helpers for rtentry and RTM* cmds. MFC after: 2 weeks (cherry picked from commit 27f107e1b434aae073a0bffebdf426125e7d83aa) --- sys/net/route/route_debug.h | 3 +++ sys/net/route/route_helpers.c | 57 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/sys/net/route/route_debug.h b/sys/net/route/route_debug.h index b2bb8426a816..30d2a1c9a99f 100644 --- a/sys/net/route/route_debug.h +++ b/sys/net/route/route_debug.h @@ -152,6 +152,7 @@ struct nhop_object; struct nhgrp_object; struct llentry; struct nhop_neigh; +struct rtentry; #define NHOP_PRINT_BUFSIZE 48 char *nhop_print_buf(const struct nhop_object *nh, char *buf, size_t bufsize); @@ -161,5 +162,7 @@ char *llentry_print_buf(const struct llentry *lle, struct ifnet *ifp, int family size_t bufsize); char *llentry_print_buf_lltable(const struct llentry *lle, char *buf, size_t bufsize); char *neigh_print_buf(const struct nhop_neigh *nn, char *buf, size_t bufsize); +char *rt_print_buf(const struct rtentry *rt, char *buf, size_t bufsize); +const char *rib_print_cmd(int rib_cmd); #endif diff --git a/sys/net/route/route_helpers.c b/sys/net/route/route_helpers.c index ff6688a8434f..001ebc5e388b 100644 --- a/sys/net/route/route_helpers.c +++ b/sys/net/route/route_helpers.c @@ -565,3 +565,60 @@ rt_get_inet6_parent(uint32_t fibnum, const struct in6_addr *paddr, int plen) return (NULL); } #endif + +/* + * Prints rtentry @rt data in the provided @buf. + * Example: rt/192.168.0.0/24 + */ +char * +rt_print_buf(const struct rtentry *rt, char *buf, size_t bufsize) +{ + char abuf[INET6_ADDRSTRLEN]; + uint32_t scopeid; + int plen; + + switch (rt_get_family(rt)) { +#ifdef INET + case AF_INET: + { + struct in_addr addr4; + rt_get_inet_prefix_plen(rt, &addr4, &plen, &scopeid); + inet_ntop(AF_INET, &addr4, abuf, sizeof(abuf)); + snprintf(buf, bufsize, "rt/%s/%d", abuf, plen); + } + break; +#endif +#ifdef INET6 + case AF_INET6: + { + struct in6_addr addr6; + rt_get_inet6_prefix_plen(rt, &addr6, &plen, &scopeid); + inet_ntop(AF_INET6, &addr6, abuf, sizeof(abuf)); + snprintf(buf, bufsize, "rt/%s/%d", abuf, plen); + } + break; +#endif + default: + snprintf(buf, bufsize, "rt/unknown_af#%d", rt_get_family(rt)); + break; + } + + return (buf); +} + +const char * +rib_print_cmd(int rib_cmd) +{ + switch (rib_cmd) { + case RTM_ADD: + return ("RTM_ADD"); + case RTM_CHANGE: + return ("RTM_CHANGE"); + case RTM_DELETE: + return ("RTM_DELETE"); + case RTM_GET: + return ("RTM_GET"); + } + + return ("UNKNOWN"); +}