From nobody Fri Aug 12 09:40:11 2022 X-Original-To: dev-commits-src-main@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 4M3zDW365pz4XxWy; Fri, 12 Aug 2022 09:40:11 +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 4M3zDW2fY9z42xY; Fri, 12 Aug 2022 09:40:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660297211; 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=BVCH3wH4zvY7C93GWgh+meQT4qDJsXx72ti9twG2ipE=; b=QzrCfHp1BCT5PM/TmgWCFN7MgJdN2fCn1MMFjfbnf3B39Fqcytg1bqQtVl1JFLLbbzJ9OO orCPWnE4qnYPP7hqRJP66eQg/1uPaSHv8HBRflL4tW0L89ZwPj9NkciBiGWld4MDwC5sc9 k9VD4gxcAP+vbe7FolOcs88P7o4nIK/TmkWQkuCmlgmaWq3lFXqf0O2vDY30S8vXJpAApR lHDxn6Hry0+s4yRW4d7ThUEdLbts/HKpk5opF9AGfbCtIX/Sw9cBa3F0fqUtDhMghzPvxn lnvNNxXVMoLP3Aat9VMJHAl4f+67CWF8uRoUIlkydDy5J+zQBS5HCYlwM17aSw== 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 4M3zDW1b26zRDR; Fri, 12 Aug 2022 09:40:11 +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 27C9eB6w056530; Fri, 12 Aug 2022 09:40:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27C9eBI7056527; Fri, 12 Aug 2022 09:40:11 GMT (envelope-from git) Date: Fri, 12 Aug 2022 09:40:11 GMT Message-Id: <202208120940.27C9eBI7056527@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: 730bfa280574 - main - routing: add rib_match_gw() helper List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 730bfa28057405b44a0b55a4dc35cdc42144ff6d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660297211; 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=BVCH3wH4zvY7C93GWgh+meQT4qDJsXx72ti9twG2ipE=; b=S0/h6Gwmg2c5sHx2MR9o6xsU1Paqp8NZU1xqe7Wiy8B6PyLAhb54dd0/OAesBu4lGawNEI eYEPl6lr0ECD2nbits1Vqb8hMCuERqwbWTQcww2FuCue3KOSUsG4wbT2rzEVlLHS3l+N0A TN89Su2iiGn1MgiUS2XYkToKrSi2to5kAGoQt7JMrW7BYRL+BpKFRD5chN8OZnoOW5IoLJ CRtifniMuUuasmE8Lf+r2/D654ldqdJ7y9i0tafrUfj1n8KEwTW46pHs9iB2uoQzF1OdIc eoQ1LZKh9SHYMUku+9VE5zI7k7wv9BbxlY3bhLXU9lWkb2JKGUij6TBosIccmw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660297211; a=rsa-sha256; cv=none; b=cyty97Ur7YASbOciEIYE9+A8ZhCOzPphM7reGPr05GigSP2FznX52Q6WJgNLXU99Wli8wm WPPW/35F9aGzirjulmYuNjKt39Wxeb56NqbfW+GZAC4nw9urXIc1jf1UcPIWf95hosDKg4 ObmJv54CO5wnKObWfWtxPV8rOF4hT+0S0LZxUY85/if7CRiPxwz3vd2TVMQxSoPVqpkfXr DcYcRe2WJh7jTnd3f3Z2D816eIv/FVsQfZI06SULhO38gFKS0jn4A7B4XC5JGWqF+C3euY Zdfpv5+1vip6to1Js/Pi6dai20TH6MRmd4PYXo9yOdINxJHzJF8tIzh6jRYHzQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=730bfa28057405b44a0b55a4dc35cdc42144ff6d commit 730bfa28057405b44a0b55a4dc35cdc42144ff6d Author: Alexander V. Chernikov AuthorDate: 2022-08-12 09:31:21 +0000 Commit: Alexander V. Chernikov CommitDate: 2022-08-12 09:31:21 +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 --- 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);