From nobody Fri Jan 13 21:25:13 2023 X-Original-To: dev-commits-src-branches@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 4NtvZx5lrkz2ql01; Fri, 13 Jan 2023 21:25:13 +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 4NtvZx4n45z41mK; Fri, 13 Jan 2023 21:25:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673645113; 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=3RSEShSUu9ixJbX2J5C2B0YBKSAUt0wH7wvfMKi/UiI=; b=S0l4HWFjI3UZIdtt61x9nc9LoGDPe96j+rsFr20k0Eb4VgeqjL8nYN93q6QXty6F7adFHr gHTO/KTYv8ufEG74Ldt2Cq5vss2wgpmK4nqNttNdYbMDIVzyfE8tQVKFBxix/82NpwYt4q bakJV9iPO9sAZvE372zJjL4lw3SrtsNstdPPbex4qyswzemDMmuMBG9n9rkZhuerAImZTD KX/fUwNnMXUQnl3P6z8/09+ZpxTu4qPZs9InI5MACrN5kMtRhO+adjcLucdElUkpLLqIya vFfGtDjbi05I1Eeq7FLCEjctQ5v9TKf2RIyiYSbb7fZwmkV8hzlR1tQueQ3yYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673645113; 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=3RSEShSUu9ixJbX2J5C2B0YBKSAUt0wH7wvfMKi/UiI=; b=rpfxG59h5k8Z2PZz+U2BTeigFo9R08TrAjzu1tjKNEKRuT4+HJBhx5VAczUk7BxZnzOj8O 8QRsm5476NZKZi9tf4D+oA1SaB4Pbizyn0YJt+Rn3OqbQdZnlhkFC4/MX50rqxUiS4x+Ri +sXHd3sHF3vB1vn8Rtav/4w2DFEHBLUMPRiQG5t95g9GGavDewRvUsHC8c2MtR/wV+qiY0 Cdw3dO6+oe1v/8g1ZeMA3lqW9lLY6aSrXrCYFZzA1TvXa6KdFZxNqeuCC6GJL9fQI5bW6b 1rlZkVn8gvTVSny30YXHxJ5K2JBSeSjnVFX5lOZsUGGM/j5ezb145NEFuWBmag== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673645113; a=rsa-sha256; cv=none; b=TZVQVyUm635TgxHJr71mv0mqbpQjRBSJPOj47TF+SMCMX8C8EZYDHiHr7ntNp71Bez0K/9 CH6UtXhLWhcVeTGalxrva40HiaRhcAyp6O+rgwpGnE/dwpOSTA3Mr9t9ZDQc2IgqL2xG2A PNjTx/UpMijpWTUV1WXCRUezFw/CX+jcprfZtm7PAGhmVKcq0bR9X4JbHdL5kGe1jGG657 tZBriTEseuPq3aoqPev14BQX88x4WH0NfKokZWZfmBAqKQdK/iaGDysxA9/ExMJ76QdmpD w83JuSoyoRyBS05XHofIlRS/+EUqB+z7Sa4hnXGcKWT3LazRea6+9L2HKzVmXw== 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 4NtvZx3tqFzN2J; Fri, 13 Jan 2023 21:25:13 +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 30DLPDvL041545; Fri, 13 Jan 2023 21:25:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30DLPDsS041544; Fri, 13 Jan 2023 21:25:13 GMT (envelope-from git) Date: Fri, 13 Jan 2023 21:25:13 GMT Message-Id: <202301132125.30DLPDsS041544@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: ced68927c75c - stable/13 - routing: add rib_match_gw() helper List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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: ced68927c75ce510319563e33cadae1b2f578045 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=ced68927c75ce510319563e33cadae1b2f578045 commit ced68927c75ce510319563e33cadae1b2f578045 Author: Alexander V. Chernikov AuthorDate: 2022-08-12 09:31:21 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-01-13 21:18:27 +0000 routing: add rib_match_gw() helper Finish 02e05b8faec1: * add gateway matcher function that can be used in rib_del_route_px() or any rib_walk-family functions. It will be used in the upcoming migration to the new KPI * rename gw_fulter_func to match_gw_one() to better signal the function purpose / semantic. MFC after: 1 month (cherry picked from commit 730bfa28057405b44a0b55a4dc35cdc42144ff6d) --- sys/net/route/route_ctl.c | 21 ++++++++++++++++++--- sys/net/route/route_ctl.h | 3 +++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/sys/net/route/route_ctl.c b/sys/net/route/route_ctl.c index a2ac05d2afc8..dbfa25500df4 100644 --- a/sys/net/route/route_ctl.c +++ b/sys/net/route/route_ctl.c @@ -290,13 +290,28 @@ match_nhop_gw(const struct nhop_object *nh, const struct sockaddr *gw) return (false); } +/* + * Matches all nexthop with given @gw. + * Can be used as rib_filter_f callback. + */ +int +rib_match_gw(const struct rtentry *rt, const struct nhop_object *nh, void *gw_sa) +{ + const struct sockaddr *gw = (const struct sockaddr *)gw_sa; + + return (match_nhop_gw(nh, gw)); +} + struct gw_filter_data { const struct sockaddr *gw; int count; }; +/* + * Matches first occurence of the gateway provided in @gwd + */ static int -gw_fulter_func(const struct rtentry *rt, const struct nhop_object *nh, void *_data) +match_gw_one(const struct rtentry *rt, const struct nhop_object *nh, void *_data) { struct gw_filter_data *gwd = (struct gw_filter_data *)_data; @@ -518,7 +533,7 @@ rib_del_route_px_gw(uint32_t fibnum, struct sockaddr *dst, int plen, { struct gw_filter_data gwd = { .gw = gw }; - return (rib_del_route_px(fibnum, dst, plen, gw_fulter_func, &gwd, op_flags, rc)); + return (rib_del_route_px(fibnum, dst, plen, match_gw_one, &gwd, op_flags, rc)); } /* @@ -955,7 +970,7 @@ rib_del_route(uint32_t fibnum, struct rt_addrinfo *info, struct rib_cmd_info *rc filter_func = info->rti_filter; filter_arg = info->rti_filterdata; } else if (gwd.gw != NULL) { - filter_func = gw_fulter_func; + filter_func = match_gw_one; filter_arg = &gwd; } diff --git a/sys/net/route/route_ctl.h b/sys/net/route/route_ctl.h index 299885d5be2b..19fe5362b6ec 100644 --- a/sys/net/route/route_ctl.h +++ b/sys/net/route/route_ctl.h @@ -77,6 +77,9 @@ int rib_action(uint32_t fibnum, int action, struct rt_addrinfo *info, struct rib_cmd_info *rc); int rib_handle_ifaddr_info(uint32_t fibnum, int cmd, struct rt_addrinfo *info); +int rib_match_gw(const struct rtentry *rt, const struct nhop_object *nh, + void *gw_sa); + typedef void route_notification_t(struct rib_cmd_info *rc, void *); void rib_decompose_notification(struct rib_cmd_info *rc, route_notification_t *cb, void *cbdata);