From patchwork Sun Mar 19 18:38:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1758758 X-Patchwork-Delegate: ansuelsmth@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.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=zzkjF6QZ; 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=YLgENA2k; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PfmvL6lPJz2476 for ; Mon, 20 Mar 2023 05:42:37 +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=zTZdVvjqh7S/WTu9ov4woDe4tW+VUDIgzmoZSNP3Hb0=; b=zzkjF6QZaIdI8C c8I8AjIn47wV3SYm4jeORXTWQFTWZV+fluvUai2ja772qYEn/QOE56OGu7qCV7ZEOfMA4TE5B58d1 18D0afh8hbkjqXJbAYc2u1lhESTfzzRsd9+NVYey+29WNtTI1aV5HnX/w/fDa13yJfTE0ya5ny1mK RlXpU3gU2MFpEwuFwvDFYwBuVmmRQfRl313QmKY3sYbvSYG3oIBoAnrxXoxinyPVZjKjNACkJHC75 nhn8RV5ibPL/vK1BRup1Qf+rgmgHxNngeEgLwvVYFc8/2Q7sYPQs/6bzsZsZ/htyCWWmDdVDWSd8d tl5jVk8e2g+gBajlbdmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdxw7-007B0g-1O; Sun, 19 Mar 2023 18:39:19 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdxw4-007Azy-0s for openwrt-devel@lists.openwrt.org; Sun, 19 Mar 2023 18:39:17 +0000 Received: by mail-wm1-x332.google.com with SMTP id p16so6166751wmq.5 for ; Sun, 19 Mar 2023 11:39:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679251153; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=BQjKYKWYxEDMDHd2GdO2vdJ1ihepklKy9YK51iKhKAI=; b=YLgENA2katyzHvzc4FfCS7DwDHBg1rRLWw08SUZuLOPlel4p1pH8dV0QxzBdIrD3Nq 6lNxA7joOAiEOvv2TlCNd0Lous6fsuaE6zOSRllKRw12jCnNms4HWcFopXfcG5u7qW4M EDOt8pAuwqQfc+OcKyMPz04+LRO5Y8YnjlGtXUK/7WVR1P3GqPvTl1PguYun9dYTohvh DMN4c7aERXT/2Hi5KSFRZEO4WQp3bXxCuy1pymbI956mH03ClcY6ERRZAtI/C1DIO80O YjdnOOc5uj08VPKymi4KCNFfjVZ+XwJ+tPf0Z+9Azxf/H3jugxXrssH9yIHifQ2wpTwG Px9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679251153; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BQjKYKWYxEDMDHd2GdO2vdJ1ihepklKy9YK51iKhKAI=; b=78IQNUCL6wumaEhrF76y9l16lAo/8lhDKFg/s99+Wii2edmWUCQj5Qs05Nl9aosMrZ jlfKPnQzcHMmu4RHi7pE5tKeDsg/0H1ZQuDKti0HC9YzMuCL4r6FcxECbuhreUbUkeCF 64dpdHvJgY4E4Scf22rzKlgOpXcOWsDQpZiSGNEJsbmNtFpgV8GW4dAIcGwJZuTSE8yY HV8NBgfos508h1IRicq0C3IutEvzUdVcFDYgu1gdKlrTqh0fUiDZdmaWvza8+hZ955u1 cMjYdFhJjOS5/3jNFjESQKSa9ZoZeVeQbCzUj0YQGzkcDfkdIBC2vyiSoxyrxl4gLtv/ YUcg== X-Gm-Message-State: AO0yUKUS3boFwAryqNNnzTKTlu/L9dylT8gU/poZ+oqh4FTvZdAqHKd9 j1doR/uB/TUbwt/kqNmDBfo= X-Google-Smtp-Source: AK7set83zWIp9VPKMEeyex/8KYBVpv4py1Odv+c6ylU2AryFtqyrUs5tcfEWf6U0eYpr9qtLonRR2Q== X-Received: by 2002:a05:600c:4f05:b0:3ed:2dbf:6a80 with SMTP id l5-20020a05600c4f0500b003ed2dbf6a80mr7464715wmq.5.1679251153445; Sun, 19 Mar 2023 11:39:13 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id v15-20020a05600c444f00b003edddce5b00sm2214057wmn.12.2023.03.19.11.39.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 11:39:12 -0700 (PDT) From: Christian Marangi To: Jo-Philipp Wich , Stijn Tintel , OpenWrt Development List Cc: Christian Marangi , Hans Dedecker Subject: [odhcpd PATCH v2 1/2] config: skip interface setup if interface not IFF_RUNNING Date: Sun, 19 Mar 2023 19:38:56 +0100 Message-Id: <20230319183857.1519-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_113916_333081_94A2B9DB X-CRM114-Status: GOOD ( 13.60 ) 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: We currently setup odhcp service even if the interface is not running. This is the case for bridge or specific interface that are flagged as UP but have no carrier as nothing is connected to it. This [...] 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 [2a00:1450:4864:20:0:0:0:332 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 [ansuelsmth[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 We currently setup odhcp service even if the interface is not running. This is the case for bridge or specific interface that are flagged as UP but have no carrier as nothing is connected to it. This cause a similar error like: Failed to send to ff02::1%br-lan (Address not available) This is caused by the kernel assigning IPV6 address only when the interface is set to IFF_RUNNING. A LINK-LOCAL IPV6 address is required for odhcpd_send() to work or every request will be rejected. To fix this setup services only when interface is in IFF_RUNNING state. When an interface change state, odhcpd is reloaded and the services are correctly setup again. Signed-off-by: Christian Marangi Acked-by: Hans Dedecker --- src/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.c b/src/config.c index 9b1f659..30da879 100644 --- a/src/config.c +++ b/src/config.c @@ -1303,7 +1303,7 @@ void odhcpd_reload(void) avl_for_each_element_safe(&interfaces, i, avl, tmp) { - if (i->inuse) { + if (i->inuse && i->ifflags & IFF_RUNNING) { /* Resolve hybrid mode */ if (i->dhcpv6 == MODE_HYBRID) i->dhcpv6 = (master && master->dhcpv6 == MODE_RELAY) ? From patchwork Sun Mar 19 18:38:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1758757 X-Patchwork-Delegate: ansuelsmth@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.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=2e7YfTUq; 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=pXA/orLr; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PfmvL6h5dz246f for ; Mon, 20 Mar 2023 05:42:37 +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:References:In-Reply-To: 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: List-Owner; bh=zis0KqVceYUJjZ1biHJNd0LeNXatbqCdX3dERNqWMjY=; b=2e7YfTUqebSN+w p9A7/EA/0zRpM4mbmFx0PHKD/ZqzLeY7kc9vLJQZnFU54EUEjTmz/gO0ODJp7zomL34mSBR8QXNIs /nqFA90XD4n4DjzFP4h6dWfmEYiaKxLiAGB+I2IeEPnyEqDJmSGKQUbM6fPIflZjFA5PvGky0tVX0 gkMDgO77lK3JLxksWcredQ6yXX2BYhrLFWu1Rse2Uw4kB0Y40yhgn9ooQyaHNJTwfuxlI+mUPvFB2 lRFT82Qk4BZFypRkaePR4KOIrIBqOf92idkdIKlnOG2CSmdB8F+qbeDCrJH6jMUA28XVRYgswXJjI MP8gMDUGugrnuMX3dXpw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdxw8-007B0l-1y; Sun, 19 Mar 2023 18:39:20 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdxw4-007Azz-2o for openwrt-devel@lists.openwrt.org; Sun, 19 Mar 2023 18:39:18 +0000 Received: by mail-wm1-x32f.google.com with SMTP id r19-20020a05600c459300b003eb3e2a5e7bso6241540wmo.0 for ; Sun, 19 Mar 2023 11:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679251154; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2rb1w96gQRv3mddp2nZ348c+Kv6jLh8AFwvHq+JhDUs=; b=pXA/orLrg/jDE01tX6q5PN2Vv6pAGoJUaNpC573uWvhnPYf+6c3qHygA+dFh1Ug60c GyP7Uc9Ak3i1MlMUdvZBrbcN9RKB88/YXgLvUYNblLkE7vd50aUVouQTjBG9oYv3QX4y vBsHTOb0KnmNILpmKtrza8I2UuwDxrk+o+L0tZCEW0pm+H6l5Z3XApRQoq4XTBv88LwJ uLqst9zSrFBP8uGepO3MpzmJZUZx4lPCjRRfK5SbP8F8SBRaH6DfNuAIHkhrTpap3BiE fZcIk53tCwVF22Fj8R2606KBE7PSFVj5DnEgS4kApya3sSG+70Nmfays++ZryyfVpfS4 beVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679251154; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2rb1w96gQRv3mddp2nZ348c+Kv6jLh8AFwvHq+JhDUs=; b=oa8ozsKEVC/KePBdzjyks2vt9BmfIxMSVtlyGw0fGXLzJP7NyxqWFzT6M4n+ijuhP3 PIHpy4PYTBW3T73hYaj0HTPBZRwLxdhrteJ3texvIjAELWRpoYvQRbAZhLL0pIEvp6oy TF/FHNVChlWXWEBxrWhvGZrvWUixuCDWsq4OZrwqtNX9yzQMFEnt1YZX2XLtY6B3XZtp 4dn5wCG1ZAILNdJTkOmdG72GD/wkupJa/S036N6bu5PMzvjBBIm0S970FJQ9SspBgT/t dKcMhIPLIJp8sLJtN+Gtpt1D8DuhPt9FQLB29Qh8uyz5LnChAskgPLbRh8gB/4c2RSNi MRWA== X-Gm-Message-State: AO0yUKUUXIs6Xirh6TvExz8LMOURW5XvVxx6oOg5MronTAsSzHD1WZrY 9XGdLnwjFb+nJuNlb4jhjkQ= X-Google-Smtp-Source: AK7set9y4BV9TG3zTM8J9CezqAeQ9DNOrM233xjXKz6DZZunvPuR8GLDbGCceJvNIgS5HwG0bJ4Yew== X-Received: by 2002:a05:600c:4448:b0:3dc:1687:9ba2 with SMTP id v8-20020a05600c444800b003dc16879ba2mr29486438wmn.35.1679251154424; Sun, 19 Mar 2023 11:39:14 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id v15-20020a05600c444f00b003edddce5b00sm2214057wmn.12.2023.03.19.11.39.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 11:39:13 -0700 (PDT) From: Christian Marangi To: Jo-Philipp Wich , Stijn Tintel , OpenWrt Development List Cc: Christian Marangi Subject: [odhcpd PATCH v2 2/2] router: skip RA and wait for LINK-LOCAL to be assigned Date: Sun, 19 Mar 2023 19:38:57 +0100 Message-Id: <20230319183857.1519-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319183857.1519-1-ansuelsmth@gmail.com> References: <20230319183857.1519-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_113916_911174_1244EA97 X-CRM114-Status: GOOD ( 22.84 ) 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: This fix a specific and corner case when the following error and similar is printed in the log: Failed to send to ff02::1%br-lan (Address not available) The cause for this was tracked down to the lack of the interface of a configured LINK-LOCAL IPV6 address resulting in odhcpd_send() always failing. 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 [2a00:1450:4864:20:0:0:0:32f 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 [ansuelsmth[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 This fix a specific and corner case when the following error and similar is printed in the log: Failed to send to ff02::1%br-lan (Address not available) The cause for this was tracked down to the lack of the interface of a configured LINK-LOCAL IPV6 address resulting in odhcpd_send() always failing. A LINK-LOCAL IPV6 address is assigned only after the interface has carrier and is set to IFF_RUNNING and require some time for the address to be assigned due to DAD logic. In the case where an interface was just UP, odhcpd RA may fail since the LINK-LOCAL IPV6 address still needs to be assigned as it still need to be "trained". From the kernel view this is flagged in the IPV6 interface address with the flag IFA_F_TENTATIVE, that means the address still needs to be checked and follow DAD process. This is only a transient problem and the DAD process is required only once till the interface is not set DOWN. To handle this, add some check to verify if the address has to be checked and add an additional bool to flag if the interface have a LINK-LOCAL assigned. Skip sending RA if the interface still doesn't have finished the DAD process and retry at the next RA. A notice log is added to track this special case to track problematic case and even more corner case. Logic to check if interface have LINK-LOCAL are: - When interface is setup, on scanning for the interface ipv6 address check if at least one address is NOT in IFA_F_TENTATIVE state. - With interface already up but with still no LINK-LOCAL react on the RTM_NEWADDR event and set LINK-LOCAL if the addrs added by the event is a LINK-LOCAL reflecting that the interface finally ended the DAD process and have a correct address. Signed-off-by: Christian Marangi Acked-by: Hans Dedecker --- src/config.c | 9 +++++++++ src/netlink.c | 11 ++++++++++- src/odhcpd.h | 2 ++ src/router.c | 6 ++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/config.c b/src/config.c index 30da879..ee7219f 100644 --- a/src/config.c +++ b/src/config.c @@ -594,6 +594,15 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr if (len > 0) iface->addr6_len = len; + for (size_t i = 0; i < iface->addr6_len; i++) { + struct odhcpd_ipaddr *addr = &iface->addr6[i]; + + if (!addr->tentative) { + iface->have_link_local = true; + break; + } + } + len = netlink_get_interface_addrs(iface->ifindex, false, &iface->addr4); if (len > 0) diff --git a/src/netlink.c b/src/netlink.c index 4a352a6..0a2da03 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -386,7 +386,7 @@ static int handle_rtm_addr(struct nlmsghdr *hdr, bool add) nla_memcpy(&event_info.addr, nla[IFA_ADDRESS], sizeof(event_info.addr)); - if (IN6_IS_ADDR_LINKLOCAL(&event_info.addr) || IN6_IS_ADDR_MULTICAST(&event_info.addr)) + if (IN6_IS_ADDR_MULTICAST(&event_info.addr)) return NL_SKIP; inet_ntop(AF_INET6, &event_info.addr, buf, sizeof(buf)); @@ -395,6 +395,11 @@ static int handle_rtm_addr(struct nlmsghdr *hdr, bool add) if (iface->ifindex != (int)ifa->ifa_index) continue; + if (add && IN6_IS_ADDR_LINKLOCAL(&event_info.addr)) { + iface->have_link_local = true; + return NL_SKIP; + } + syslog(LOG_DEBUG, "Netlink %s %s on %s", add ? "newaddr" : "deladdr", buf, iface->name); @@ -625,6 +630,10 @@ static int cb_addr_valid(struct nl_msg *msg, void *arg) if (ifa->ifa_flags & IFA_F_DEPRECATED) addrs[ctxt->ret].preferred = 0; + if (ifa->ifa_family == AF_INET6 && + ifa->ifa_flags & IFA_F_TENTATIVE) + addrs[ctxt->ret].tentative = true; + ctxt->ret++; *(ctxt->addrs) = addrs; diff --git a/src/odhcpd.h b/src/odhcpd.h index d829033..0550bc2 100644 --- a/src/odhcpd.h +++ b/src/odhcpd.h @@ -131,6 +131,7 @@ struct odhcpd_ipaddr { struct { uint8_t dprefix; uint8_t invalid_advertisements; + bool tentative; }; /* ipv4 only */ @@ -300,6 +301,7 @@ struct interface { bool ra_useleasetime; bool ra_dns; bool no_dynamic_dhcp; + bool have_link_local; uint8_t pio_filter_length; struct in6_addr pio_filter_addr; int default_router; diff --git a/src/router.c b/src/router.c index 7e66e3c..eca0bf7 100644 --- a/src/router.c +++ b/src/router.c @@ -621,6 +621,11 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr msecs = calc_adv_interval(iface, minvalid, &maxival); lifetime = calc_ra_lifetime(iface, maxival); + if (!iface->have_link_local) { + syslog(LOG_NOTICE, "Skip sending a RA on %s as no link local address is available", iface->name); + goto out; + } + if (default_route && valid_prefix) { adv.h.nd_ra_router_lifetime = htons(lifetime < UINT16_MAX ? lifetime : UINT16_MAX); } else { @@ -782,6 +787,7 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr if (odhcpd_send(iface->router_event.uloop.fd, &dest, iov, ARRAY_SIZE(iov), iface) > 0) iface->ra_sent++; +out: free(pfxs); free(routes);