From nobody Thu Aug 11 12:51:14 2022 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 4M3RWR28WKz4YmL6; Thu, 11 Aug 2022 12:51:15 +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 4M3RWR1f2pz44nt; Thu, 11 Aug 2022 12:51:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660222275; 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=wfpvCUI+Uduc2TZ7jo00xaWnu5O3chTqH78TBjXEnjs=; b=URu7PXLkDWWqHYqiVlVOsPqg+b6cHa/n6Sf/P7l8rb0wGnqFWg8wbtb6pP/psLPd7oF0dP cXfvYfc5AUBxzEpkovsSaAKe2MpsSPIyKQMwMm3Tc76fhQpFAK0vmcdVLgZJ0anmHCsMx1 n8Ibu0CeL3OpmHIKsFQyEqEMXhrx3Iia17IfmsVBF5znrPUn9eyYQI8USR6Ere3Rd32u+V erbbzo2+b+Ls1rf0tqY/37aycOcPcEHqVjtBFKB8zlYlqZPciWsKtv60uxr5NByslSZGGV 07CNKMMpgebTo8GVEofOCOwyPB5VveivSnstyO2uj6nogh1qDNbyAfW/5mSi/Q== 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 4M3RWR0Pn4zrt4; Thu, 11 Aug 2022 12:51:15 +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 27BCpElf066663; Thu, 11 Aug 2022 12:51:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27BCpE3p066662; Thu, 11 Aug 2022 12:51:14 GMT (envelope-from git) Date: Thu, 11 Aug 2022 12:51:14 GMT Message-Id: <202208111251.27BCpE3p066662@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: 02e05b8faec1 - main - routing: fixup empty mask prefix handling after 2ce553854cbd. 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/main X-Git-Reftype: branch X-Git-Commit: 02e05b8faec1ea79d3fa2deee7fb55f1bdddfbc1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660222275; 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=wfpvCUI+Uduc2TZ7jo00xaWnu5O3chTqH78TBjXEnjs=; b=bdrhLBGB0FMy4udelq5L2iuWS7LlrK1qnRFJHTH/0MuRmNsKXsZSHX0N02nOjy6U9BaaTR rMb1ow9JFqUuGyNJf9kEH4WnTKqJx0TEG/ZAO8XzqtyG1Ty0xcwHMZhZfmePUezG0dxzpc UAXmmVDB8PxZlBNHs8KKu5wf45pyzobMuZuNqLCcuioefJHfahgJ6oHAem3CYlUxVuv7tL THLxF7qQLLk3jR07fmLhN6pJdQYpndrSopWsZpf04Oq7PQktNQw7hJN4jFzPdn0wJIUj0p aUUxCtsjNzuzwBHjGEcryc5sRBEwJOLVjV9PULaQOzhoNHYBprjSEsPs5TC92w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660222275; a=rsa-sha256; cv=none; b=GntwTGnxYWRP5NGRDZu0D9DmpKi2bDVb6GWGeNtBERykan6YJBqvZTJI1gbWSbqLcIJIM6 aLcS/WCoxzCeyFcnJNmnVWYtLrBB/WQHV+agl78PoOeLgxUCeMzST1gOIrvgnZE4mRvPT6 RVGfDQczN+1pU/pKZGl8oDg9yOkTNO3KVAYL9HxXXE2Wr1IumeKlhch81n9AB9bY/u2s4K i2qzHRjPV89XFS6Hd6gVT+4Gx209hJorFiKjzYCH+6Ua60C3KbISR+7R6Mtpaei50XGZOy RAbJDaDCACjST2q43t0YttJYFSfWJvlMSG5z/7PKYNR3c/RpPgcviBsZhlxc7w== 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=02e05b8faec1ea79d3fa2deee7fb55f1bdddfbc1 commit 02e05b8faec1ea79d3fa2deee7fb55f1bdddfbc1 Author: Alexander V. Chernikov AuthorDate: 2022-08-11 11:41:42 +0000 Commit: Alexander V. Chernikov CommitDate: 2022-08-11 12:48:04 +0000 routing: fixup empty mask prefix handling after 2ce553854cbd. MFC after: 1 month --- sys/net/route/route_ctl.c | 37 ++++++++++++++++++++++++++----------- sys/net/route/route_ctl.h | 6 +++--- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/sys/net/route/route_ctl.c b/sys/net/route/route_ctl.c index 1b7bcde7594f..e2e48302a8c2 100644 --- a/sys/net/route/route_ctl.c +++ b/sys/net/route/route_ctl.c @@ -296,7 +296,7 @@ struct gw_filter_data { }; static int -gw_filter_func(const struct rtentry *rt, const struct nhop_object *nh, void *_data) +gw_fulter_func(const struct rtentry *rt, const struct nhop_object *nh, void *_data) { struct gw_filter_data *gwd = (struct gw_filter_data *)_data; @@ -385,17 +385,22 @@ static bool fill_pxmask_family(int family, int plen, struct sockaddr *_dst, struct sockaddr **pmask) { + if (plen == -1) { + *pmask = NULL; + return (true); + } + switch (family) { #ifdef INET case AF_INET: { - struct sockaddr_in *mask = (struct sockaddr_in *)pmask; + struct sockaddr_in *mask = (struct sockaddr_in *)(*pmask); struct sockaddr_in *dst= (struct sockaddr_in *)_dst; memset(mask, 0, sizeof(*mask)); mask->sin_family = family; mask->sin_len = sizeof(*mask); - if (plen == 32 || plen == -1) + if (plen == 32) *pmask = NULL; else if (plen > 32 || plen < 0) return (false); @@ -414,13 +419,13 @@ fill_pxmask_family(int family, int plen, struct sockaddr *_dst, #ifdef INET6 case AF_INET6: { - struct sockaddr_in6 *mask = (struct sockaddr_in6 *)pmask; + struct sockaddr_in6 *mask = (struct sockaddr_in6 *)(*pmask); struct sockaddr_in6 *dst = (struct sockaddr_in6 *)_dst; memset(mask, 0, sizeof(*mask)); mask->sin6_family = family; mask->sin6_len = sizeof(*mask); - if (plen == 128 || plen == -1) + if (plen == 128) *pmask = NULL; else if (plen > 128 || plen < 0) return (false); @@ -449,7 +454,7 @@ fill_pxmask_family(int family, int plen, struct sockaddr *_dst, * Returns 0 on success. */ int -rib_add_route_px(uint32_t fibnum, struct sockaddr *dst, unsigned int plen, +rib_add_route_px(uint32_t fibnum, struct sockaddr *dst, int plen, struct route_nhop_data *rnd, int op_flags, struct rib_cmd_info *rc) { union sockaddr_union mask_storage; @@ -471,8 +476,10 @@ rib_add_route_px(uint32_t fibnum, struct sockaddr *dst, unsigned int plen, } if (op_flags & RTM_F_CREATE) { - if ((rt = rt_alloc(rnh, dst, netmask)) == NULL) + if ((rt = rt_alloc(rnh, dst, netmask)) == NULL) { + FIB_RH_LOG(LOG_INFO, rnh, "rtentry allocation failed"); return (ENOMEM); + } } else { struct route_nhop_data rnd_tmp; @@ -481,6 +488,14 @@ rib_add_route_px(uint32_t fibnum, struct sockaddr *dst, unsigned int plen, return (ESRCH); } +#if DEBUG_MAX_LEVEL >= LOG_DEBUG2 + { + char nhbuf[NHOP_PRINT_BUFSIZE], rtbuf[NHOP_PRINT_BUFSIZE]; + nhop_print_buf_any(rnd->rnd_nhop, nhbuf, sizeof(nhbuf)); + rt_print_buf(rt, rtbuf, sizeof(rtbuf)); + FIB_RH_LOG(LOG_DEBUG2, rnh, "request %s -> %s", rtbuf, nhbuf); + } +#endif return (add_route_flags(rnh, rt, rnd, op_flags, rc)); } @@ -498,12 +513,12 @@ rib_add_route_px(uint32_t fibnum, struct sockaddr *dst, unsigned int plen, * Returns 0 on success. */ int -rib_del_route_px_gw(uint32_t fibnum, struct sockaddr *dst, unsigned int plen, +rib_del_route_px_gw(uint32_t fibnum, struct sockaddr *dst, int plen, const struct sockaddr *gw, int op_flags, struct rib_cmd_info *rc) { struct gw_filter_data gwd = { .gw = gw }; - return (rib_del_route_px(fibnum, dst, plen, gw_filter_func, &gwd, op_flags, rc)); + return (rib_del_route_px(fibnum, dst, plen, gw_fulter_func, &gwd, op_flags, rc)); } /* @@ -521,7 +536,7 @@ rib_del_route_px_gw(uint32_t fibnum, struct sockaddr *dst, unsigned int plen, * Returns 0 on success. */ int -rib_del_route_px(uint32_t fibnum, struct sockaddr *dst, unsigned int plen, +rib_del_route_px(uint32_t fibnum, struct sockaddr *dst, int plen, rib_filter_f_t *filter_func, void *filter_arg, int op_flags, struct rib_cmd_info *rc) { @@ -875,7 +890,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_filter_func; + filter_func = gw_fulter_func; filter_arg = &gwd; } diff --git a/sys/net/route/route_ctl.h b/sys/net/route/route_ctl.h index dfdeca79153d..299885d5be2b 100644 --- a/sys/net/route/route_ctl.h +++ b/sys/net/route/route_ctl.h @@ -52,12 +52,12 @@ struct route_nhop_data { uint32_t rnd_weight; }; -int rib_add_route_px(uint32_t fibnum, struct sockaddr *dst, unsigned int plen, +int rib_add_route_px(uint32_t fibnum, struct sockaddr *dst, int plen, struct route_nhop_data *rnd, int op_flags, struct rib_cmd_info *rc); -int rib_del_route_px(uint32_t fibnum, struct sockaddr *dst, unsigned int plen, +int rib_del_route_px(uint32_t fibnum, struct sockaddr *dst, int plen, rib_filter_f_t *filter_func, void *filter_arg, int op_flags, struct rib_cmd_info *rc); -int rib_del_route_px_gw(uint32_t fibnum, struct sockaddr *dst, unsigned int plen, +int rib_del_route_px_gw(uint32_t fibnum, struct sockaddr *dst, int plen, const struct sockaddr *gw, int op_flags, struct rib_cmd_info *rc); /* operation flags */