From nobody Fri Jan 13 21:25:09 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 4NtvZt2CQmz2ql4b; Fri, 13 Jan 2023 21:25:10 +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 4NtvZt1Tp1z41rc; Fri, 13 Jan 2023 21:25:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673645110; 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=9PlAAUgYT7HVN01FVgiYpStbLJ2DnfEiovhTnvuJeBM=; b=j+vuz5dDYLCIc7zF/im2KztVcoNkoVlGXYaibB7agvlaKKR1kED272iu4ye2fp7Plyfo4U /EagN1XuTYuVxkXIFph/yOgdOLr6UukRrcvibD8DcxA7/YWZKihvi+XKgKS12HXW7KCehF 8jS6jpk9jVRDHp9l8cvmD3w+pH8ThHDq1XU8baG9aOMuUQoLbHBQJ1sIhhU++KbVg3vk/x 0uXH3V8L7Bwi8GNVQW4tv1P0AbnWp7u3y6zBWBgWo1p/oUzbI8yHHrQ8YIpZ32cakClH1H ImUm5JZh7W9zDQ6yX4m8AsU4qCoPSKAxXs1wdxjV1jaUgsCLICoYRoHbWdPROQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673645110; 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=9PlAAUgYT7HVN01FVgiYpStbLJ2DnfEiovhTnvuJeBM=; b=rQDvl7Lf9NwPSEDqHZDJkY9yEuGHrW3Ps9CQSHVP1IKyfsXg4lw+0yoWAfcW1UlUkJSkf1 5S7dEndy1PV/JcoRDwkGFi+FGt+R862fWeX8AwkO06OmDU8d0x+NMALuT/Nk+/32i0d+dv CAtesgwq44VSux9n0FhLuc+YeQhEIsQDtEas90WPbMiSVCJwNeL905YCxfF5B365hBUZid ixvzJ9fdYd8laKKIv6Q4hVppJRzl6ShnknNnmBKu4DulzV09kgCkAjyLHCyjZjOPyTuwdY Dxj1qCLSs6YjdcR8GQjMO/v5uVIFtKRp9TjKNAEfqCDhtLNexL98SvIZ4Yzllw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673645110; a=rsa-sha256; cv=none; b=pWg+wBIAg8s5HYbJhTASuebj4sIURaY56TDHx8HhFL2+7ctNLGrbbX06TgKC0/+9nvCM/J gQobSNW6ELePGWYWqQkFuL6OwXB8QhczI/MJZsdrncAj72SS2GtOexpFUGfyrOAj+yGlJU uKsw40Ne6CNeVzkkE1HiKWCxwRPpic+2TKLwbdLhAaweCMNUUvckh3i7J62q0T03aoMBY2 Z97iUEi2OumPTlCfvfyGwQI/9wPGfPZnhW653kfn6VYRZ+8WrvhqAUbLp4vnp9EWY/sehK 56GlCaB8RupO07Tfe5DQck8+HchF36iZnD4KZ8oQ1G4oZe0JQxNFBew58p8MZQ== 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 4NtvZt0YyYzNDG; Fri, 13 Jan 2023 21:25:10 +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 30DLP9CA041473; Fri, 13 Jan 2023 21:25:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30DLP97u041472; Fri, 13 Jan 2023 21:25:09 GMT (envelope-from git) Date: Fri, 13 Jan 2023 21:25:09 GMT Message-Id: <202301132125.30DLP97u041472@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: e0621d33ab3e - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: e0621d33ab3e347bee81ff5fe6aec63102d088a4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=e0621d33ab3e347bee81ff5fe6aec63102d088a4 commit e0621d33ab3e347bee81ff5fe6aec63102d088a4 Author: Alexander V. Chernikov AuthorDate: 2022-08-11 11:41:42 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-01-13 21:18:27 +0000 routing: fixup empty mask prefix handling after 2ce553854cbd. MFC after: 1 month (cherry picked from commit 02e05b8faec1ea79d3fa2deee7fb55f1bdddfbc1) --- 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 */