From owner-dev-commits-src-main@freebsd.org Fri Feb 12 01:59:24 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 038B653FAC8; Fri, 12 Feb 2021 01:59:24 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DcGrq2LNSz3lB2; Fri, 12 Feb 2021 01:59:23 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wr1-x436.google.com with SMTP id v7so1079471wrr.12; Thu, 11 Feb 2021 17:59:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=uSzwg90hnmdxnonbGODrdrXO+KD4NKXw7aqH3/LLiow=; b=GAMwETH/xtHn8vtkppDnW3Q7CU/RJl1MzTgJ+NzUBAaZRLQ8X9bW0zhnplPLotZv7z 8rEatau/Ha+ryC1QjtH1iqOFvp9YFRHlHZg48+P2D9KG2dUf8TTYzzWCpeQGPqTiHuRN edT8OKpn25XRwDZzIO8gYDp+YgfxSxXx8kKX7WtrnJgb6jJCc4Z5WjFFxswnzvsugDPR nh/1iFNPK+UzfNOOEF4qJmbyJ1Qbdwbi4mMVLz/I/J7K2Fm93xrMosIdjmgTShTg6dm2 UxyvSo3Hv2KAJjYuqf6865KzJraDwCXO1TRSOwNkixFWOC+TKkPj0rnNJFBOkibvkWmz e/rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=uSzwg90hnmdxnonbGODrdrXO+KD4NKXw7aqH3/LLiow=; b=WgrRabVZKrB76uYumGBG+LKlse6G/vywPPQzL0Nft4mt0Mk8TcPwXw4kFLj9JIToLZ H1cEQvoYMS2z/D/Lb1caBzSH+YQvJcodxFFmMRC3MLLbXUeaqSuvzJoeWBnlH1JNx9Za ir+gCRv/M6helu/gkzLXB8YEp7VvqRJnA/wjsHbSvd+oDrP8QbASgbhds54QC8pMHhSL 96DmMGqurCEBwN1pfNBpZkCaUPa+Bul/UJ/fWlBHZHqCkrMYQtvIdofYpFikL3A9ijiw YvVOmsjgQSz0cngi7s2CQu8cReVOGNVzigQ2c540aPLlz91JLqptcUySSbQyxjEc//Ev aBdw== X-Gm-Message-State: AOAM532xVGg7r2EuVW1xxDcv5eB2Nf+37ohW/85nsayRr3YnMJU5FRsi mSAoOuN2TGg1ZWL6u390Lun5Purrf91LIQGVOswUMGF6VfA= X-Google-Smtp-Source: ABdhPJxwqW36OwyBgKxj7qs8a9gEO1Yhf/1PloifYsWl7W+lu7BHSkghkz118nAJZ1/CRr5elIy5gs4QRvqLqvGYtow= X-Received: by 2002:a05:6000:186f:: with SMTP id d15mr650024wri.237.1613095160559; Thu, 11 Feb 2021 17:59:20 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a5d:464c:0:0:0:0:0 with HTTP; Thu, 11 Feb 2021 17:59:19 -0800 (PST) In-Reply-To: References: <202102112310.11BNABTx015766@gitrepo.freebsd.org> From: Mateusz Guzik Date: Fri, 12 Feb 2021 02:59:19 +0100 Message-ID: Subject: Re: git: 145bf6c0af48 - main - Fix blackhole/reject routes. To: "Alexander V. Chernikov" Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4DcGrq2LNSz3lB2 X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=GAMwETH/; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of mjguzik@gmail.com designates 2a00:1450:4864:20::436 as permitted sender) smtp.mailfrom=mjguzik@gmail.com X-Spamd-Result: default: False [-3.89 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; NEURAL_HAM_MEDIUM(-0.89)[-0.887]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FREEMAIL_FROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; RBL_DBL_DONT_QUERY_IPS(0.00)[2a00:1450:4864:20::436:from]; TO_DN_SOME(0.00)[]; SPAMHAUS_ZRD(0.00)[2a00:1450:4864:20::436:from:127.0.2.255]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::436:from]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[dev-commits-src-all,dev-commits-src-main]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Feb 2021 01:59:24 -0000 I mean *without* INET6 On 2/12/21, Mateusz Guzik wrote: > This breaks building a kernel with INET6 for me, I presume it will > also break LINT-NOINET > > On 2/12/21, Alexander V. Chernikov wrote: >> The branch main has been updated by melifaro: >> >> URL: >> https://cgit.FreeBSD.org/src/commit/?id=145bf6c0af48b89f13465e145f4516de37c31d85 >> >> commit 145bf6c0af48b89f13465e145f4516de37c31d85 >> Author: Alexander V. Chernikov >> AuthorDate: 2021-02-08 23:29:05 +0000 >> Commit: Alexander V. Chernikov >> CommitDate: 2021-02-11 23:08:55 +0000 >> >> Fix blackhole/reject routes. >> >> Traditionally *BSD routing stack required to supply some >> interface data for blackhole/reject routes. This lead to >> varieties of hacks in routing daemons when inserting such routes. >> With the recent routeing stack changes, gateway sockaddr without >> RTF_GATEWAY started to be treated differently, purely as link >> identifier. >> >> This change broke net/bird, which installs blackhole routes with >> 127.0.0.1 gateway without RTF_GATEWAY flags. >> >> Fix this by automatically constructing necessary gateway data at >> rtsock level if RTF_REJECT/RTF_BLACKHOLE is set. >> >> Reported by: Marek Zarychta >> Reviewed by: donner >> MFC after: 1 week >> --- >> sys/net/rtsock.c | 58 >> ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- >> 1 file changed, 56 insertions(+), 2 deletions(-) >> >> diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c >> index ba1182d55439..f67252f9fd5f 100644 >> --- a/sys/net/rtsock.c >> +++ b/sys/net/rtsock.c >> @@ -562,6 +562,50 @@ rtm_get_jailed(struct rt_addrinfo *info, struct >> ifnet >> *ifp, >> return (0); >> } >> >> +static int >> +fill_blackholeinfo(struct rt_addrinfo *info, union sockaddr_union *saun) >> +{ >> + struct ifaddr *ifa; >> + sa_family_t saf; >> + >> + if (V_loif == NULL) { >> + printf("Unable to add blackhole/reject nhop without loopback"); >> + return (ENOTSUP); >> + } >> + info->rti_ifp = V_loif; >> + >> + saf = info->rti_info[RTAX_DST]->sa_family; >> + >> + CK_STAILQ_FOREACH(ifa, &info->rti_ifp->if_addrhead, ifa_link) { >> + if (ifa->ifa_addr->sa_family == saf) { >> + info->rti_ifa = ifa; >> + break; >> + } >> + } >> + if (info->rti_ifa == NULL) >> + return (ENOTSUP); >> + >> + bzero(saun, sizeof(union sockaddr_union)); >> + switch (saf) { >> + case AF_INET: >> + saun->sin.sin_family = AF_INET; >> + saun->sin.sin_len = sizeof(struct sockaddr_in); >> + saun->sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); >> + break; >> + case AF_INET6: >> + saun->sin6.sin6_family = AF_INET6; >> + saun->sin6.sin6_len = sizeof(struct sockaddr_in6); >> + saun->sin6.sin6_addr = in6addr_loopback; >> + break; >> + default: >> + return (ENOTSUP); >> + } >> + info->rti_info[RTAX_GATEWAY] = &saun->sa; >> + info->rti_flags |= RTF_GATEWAY; >> + >> + return (0); >> +} >> + >> /* >> * Fills in @info based on userland-provided @rtm message. >> * >> @@ -944,7 +988,6 @@ route_output(struct mbuf *m, struct socket *so, ...) >> #endif >> int alloc_len = 0, len, error = 0, fibnum; >> sa_family_t saf = AF_UNSPEC; >> - struct walkarg w; >> struct rib_cmd_info rc; >> struct nhop_object *nh; >> >> @@ -972,7 +1015,6 @@ route_output(struct mbuf *m, struct socket *so, ...) >> >> m_copydata(m, 0, len, (caddr_t)rtm); >> bzero(&info, sizeof(info)); >> - bzero(&w, sizeof(w)); >> nh = NULL; >> >> if (rtm->rtm_version != RTM_VERSION) { >> @@ -1004,6 +1046,18 @@ route_output(struct mbuf *m, struct socket *so, >> ...) >> goto flush; >> } >> >> + union sockaddr_union gw_saun; >> + int blackhole_flags = rtm->rtm_flags & (RTF_BLACKHOLE|RTF_REJECT); >> + if (blackhole_flags != 0) { >> + if (blackhole_flags != (RTF_BLACKHOLE | RTF_REJECT)) >> + error = fill_blackholeinfo(&info, &gw_saun); >> + else >> + error = EINVAL; >> + if (error != 0) >> + senderr(error); >> + /* TODO: rebuild rtm from scratch */ >> + } >> + >> switch (rtm->rtm_type) { >> case RTM_ADD: >> case RTM_CHANGE: >> _______________________________________________ >> dev-commits-src-all@freebsd.org mailing list >> https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all >> To unsubscribe, send any mail to >> "dev-commits-src-all-unsubscribe@freebsd.org" >> > > > -- > Mateusz Guzik > -- Mateusz Guzik