From patchwork Tue Oct 26 21:59:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Angelo Daros de Luca X-Patchwork-Id: 1546636 X-Patchwork-Delegate: nbd@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=3pOhzIUF; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=mMUrWJMg; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hf5Vj3G3yz9sX3 for ; Wed, 27 Oct 2021 09:05:48 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=XAAToPx+blsSkgjNSUuMCL5eWSNX4zEP4u4XmcVoxpo=; b=3pOhzIUF+FtZWD 6jWrkRpiX8FMMzHzQRQM0nFDvoyyMDdnz6cb+RKjUn9mViOHMRV9CnGMLxk30o4bd0+PhJxlN+RoP hip6ox2otWPbTdiIktl29OyB7nDEnJnkjfVngH1adzc/Gj//99DWNJFcgsiLfpZPPnQSk5INN6U1m ea4GHvEPUSC9c4HqPWNPMuA1EoL2p+9xNwhGuHuxNKTr9uN68pDDK7DyxiMDJ4VMj0HDG0nrgY2HX l3IYgegACJMkIe4YtSA2aVWOML8yVvRYeo+r2T0S3rF6XP95PU6Ptxp7dFJKTsXiK0a05gflBE2ca 6hjj5F5QRKbCTTvdY0Bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfUUY-003B7l-Tn; Tue, 26 Oct 2021 22:00:23 +0000 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfUUT-003B7U-QX for openwrt-devel@lists.openwrt.org; Tue, 26 Oct 2021 22:00:19 +0000 Received: by mail-qt1-x834.google.com with SMTP id w2so729186qtn.0 for ; Tue, 26 Oct 2021 15:00:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LjCXSBV2NcGetCbamgc7fbY8iGW49jdHI9M7U6UAYZE=; b=mMUrWJMgBF9h/9hkAJC82TjhMXtasMDAkdVVRu93yg9eLdWK2gD3zgJP6ftkaJuXd2 wfvMNwajX9HTmntb0p9503FruWBu5Ia8CwaLwYuKATPnLddw/F2UwZLCx6k5xs5jdurq FeL6NFsW0rOsGuEAMm6sR1LLXlOo85N7R2x5GEFrqQojDiTCJtYWYk1Upx4Xkup1OJik 6fKs7fRvZuma5274DChkdmFlHTiFSLd/h5BxLWA3T48dGUIrrnFIOcsaBJJ9Yq+w29Zy liQzfPmvBw4fgutEWqOuFRFxIsNdVuJmUPGYBrpS1uNY62RNZxqPcBFlLZkhj9cn21BJ jR4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LjCXSBV2NcGetCbamgc7fbY8iGW49jdHI9M7U6UAYZE=; b=tMqmBst6HWSBPiKS8MZIfOtamHlFUyI/DX+CEXQUunmSQaNek2EBqUK9O59st1sM/b a5MDjEgdAfn6n3I2ha7vw4V4VIeZRnJ9+jG3gftJ/qw8WqrfAVoU0Bt3nLMNpzrDEe8p fR5pHj5slzBvAtHclnpB1aXJAZfcSjNMFz0BK6jdDQoptq6cTooVZoH5EIYxsG2/gMCw dIJ2UBTlXDiKW8PMJzDh8MJucAvw9kJ9vQI39KKqg/G9A2TQ4frk2njWa4RzvtZn7H2a pUAZnsLm81zRYx4HQSrbASup4xdsqAtogodI5+3UdRDsl2L/gspKADyAd1u0cKWc7X53 dj/Q== X-Gm-Message-State: AOAM532uoHCKtZrffqHeQ1KcXU+Sa4ucVOziF8Au3wdLlEvgBNHRRaAm zvV7Ja2M2tJ0RNabcpShy3s51kNONqTuqSe9 X-Google-Smtp-Source: ABdhPJx3xGbKFLFo7QdffJVkmsRHlpLKdS/H/k5v6jI+byItv4Dm9fGbFPyTzEw60l858nqCZbEy1g== X-Received: by 2002:a05:622a:55:: with SMTP id y21mr28350578qtw.39.1635285616071; Tue, 26 Oct 2021 15:00:16 -0700 (PDT) Received: from tresc043793.tre-sc.gov.br ([187.94.103.218]) by smtp.gmail.com with ESMTPSA id t22sm6182903qtw.21.2021.10.26.15.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 15:00:14 -0700 (PDT) From: luizluca@gmail.com To: openwrt-devel@lists.openwrt.org Cc: nbd@nbd.name, Luiz Angelo Daros de Luca Subject: [PATCH 1/2] interface-ip: copy more info for target host route Date: Tue, 26 Oct 2021 18:59:52 -0300 Message-Id: <20211026215953.8951-1-luizluca@gmail.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211026_150017_926568_3033384D X-CRM114-Status: UNSURE ( 8.14 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Luiz Angelo Daros de Luca interface_ip_add_target_route was adding a host route without copying other confs like type, source, online). The result was that this: unreachable 192.168.0.9 metric 123 Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:834 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [luizluca[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Luiz Angelo Daros de Luca interface_ip_add_target_route was adding a host route without copying other confs like type, source, online). The result was that this: unreachable 192.168.0.9 metric 123 was being converted to: 192.168.0.9 dev lo scope link metric 123 Signed-off-by: Luiz Angelo Daros de Luca --- interface-ip.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/interface-ip.c b/interface-ip.c index 648f521..7c60fec 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -301,9 +301,26 @@ interface_ip_add_target_route(union if_addr *addr, bool v6, struct interface *if route->mask = v6 ? 128 : 32; memcpy(&route->addr, addr, addrsize); memcpy(&route->nexthop, &r_next->nexthop, sizeof(route->nexthop)); - route->mtu = r_next->mtu; - route->metric = r_next->metric; - route->table = r_next->table; + if (r_next->flags & DEVROUTE_MTU) { + route->mtu = r_next->mtu; + route->flags |= DEVROUTE_MTU; + } + if (r_next->flags & DEVROUTE_METRIC) { + route->metric = r_next->metric; + route->flags |= DEVROUTE_METRIC; + } + if (r_next->flags & DEVROUTE_TABLE) { + route->table = r_next->table; + route->flags |= DEVROUTE_TABLE; + } + if (r_next->flags & DEVROUTE_TYPE) { + route->type = r_next->type; + route->flags |= DEVROUTE_TYPE; + } + if (r_next->flags & DEVROUTE_ONLINK) + route->flags |= DEVROUTE_ONLINK; + memcpy(&route->source, &r_next->source, addrsize); + route->sourcemask = r_next->sourcemask; route->iface = iface; vlist_add(&iface->host_routes, &route->node, route);