From patchwork Wed Mar 13 13:56:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 1056050 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="W7zQQ9oh"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PZ3nAemK"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44KD0X0xQ0z9s4V for ; Thu, 14 Mar 2019 00:56:44 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date: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=zQPFA4khnPXvI0V5IOiv9RYv2x2cJn/JcexAlEau3Gw=; b=W7zQQ9ohWb9ufz WoS5REXE3CBIbVYZ5+nscSCJFW7rSIuFO9HLYCZuRM72CC3i+OW0DjI2zLsRY6Fd7tpg44GFxIR4x 6h3sa0uQPsSEo7K5lF4SCr8uFWhfLS3+Pe4HM7kvsl+1aSWV/HRaymJ642g/Iuvc3fGYs+wKwbrVZ EWdfw9EaNfdaxp/k2aa7+hWLL4S/XXBtvbEquGtF57iKAfIzOLY6Svacu2Kkkt+tTzOjcmYj0Gpwg l6dEk34c2rwJ11GAFUm8V3Ap5maQ/rlOxjjTj6e+Mpn8bwOkom/xfPOklAKmAbiNXEExeAPzhAJ9N 8A83A7+19P6jvpLWL6JQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h44Mw-0008Ck-UR; Wed, 13 Mar 2019 13:56:30 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h44Mt-0008CG-UC for openwrt-devel@lists.openwrt.org; Wed, 13 Mar 2019 13:56:29 +0000 Received: by mail-wr1-x441.google.com with SMTP id d17so2100773wre.10 for ; Wed, 13 Mar 2019 06:56:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tnD/wvKMkTRoEJwnlIWW768nGFQA8tCQtpNNwCw6eQI=; b=PZ3nAemKIwVkPEM9CeS4xN9tXWz79JHHQgxCJGuI/Au/gmnloqb/08UwgHf7s4EdWc AyhXmFT9/AxSqTYKjmzfXGq96wPWl1Fi06PpiFzFAYKYD3DEzK+uhhkQxhRTp2sxmvxE SJ2iCHK7V8p5WHKQvwaNiZFEhNqauuum+Mjemyp9TxwkuUj9WkNhdmmPqeTU92DIgFj9 /d04qHdtVvqhkRtetBhUL7PjxDMrZBHJ2Wz/aVmMFmlXdOeOSNdv6d6sH64NMLZh6cYw xp4aNsLuvcWe6NKa7YisrTE5UtdYXUPtLWQ7YfGkXJSWDIN2wF+yoVYGUlXab68EwBVz Bepg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tnD/wvKMkTRoEJwnlIWW768nGFQA8tCQtpNNwCw6eQI=; b=OAbrRmjzYXmILcpx+yd5gAvutVnTBl+XE0Hlu1HraTBuM+1xvMjpbalXmkadIRUe5v 0Dg6JmomdBxdFUtoSeeq34gQkTYsjnd4ZPnfFcqO7x06pDT1Nt/JwQAMd8BZ5rYkoRcv S3zR8G/w7XgxwW9KKj0yz/fzHOmMGsrcsShNReVwxoFxoWD+u+sp3+gY7ywYvaGBuR/2 3H2jxoVEOxbvbCgg+kRYszBfVP9R2K+GyQ9DuJJFCsT31Bg9Al6SdtFptHBNKRPRKray hgvnDJ7yJrx+UWO6wSiM+p1Kkf+Ybq5PXIUwno2/ETLyd0120IwneTXLWBniN14fQy0u 8HlA== X-Gm-Message-State: APjAAAXn920eHvhpTB6x6W8rg/sILSvUpDlN4LHs7F/Bndio5gxqe5hl PTz1qNBTPiti36IzatIEC+JWcBE4 X-Google-Smtp-Source: APXvYqzO1xbRFmieccbLVzHg3gdTCM9e6gzgfgH0KOwbuMnQ6MM50pwK33O6pySXpxNUBjxphgYEPA== X-Received: by 2002:adf:ffc2:: with SMTP id x2mr26385284wrs.157.1552485385968; Wed, 13 Mar 2019 06:56:25 -0700 (PDT) Received: from cplx43.eu.thmulti.com (14.125.146.82.ipv4.evonet.be. [82.146.125.14]) by smtp.gmail.com with ESMTPSA id z6sm2424369wml.40.2019.03.13.06.56.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Mar 2019 06:56:25 -0700 (PDT) From: Hans Dedecker To: openwrt-devel@lists.openwrt.org, nbd@nbd.name Date: Wed, 13 Mar 2019 14:56:21 +0100 Message-Id: <20190313135621.31673-1-dedeckeh@gmail.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190313_065627_968188_BFC263C5 X-CRM114-Status: GOOD ( 11.62 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) 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:441 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dedeckeh[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain Subject: [OpenWrt-Devel] [PATCH netifd] interface-ip: fix delegate config update on reload (FS#2087) X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hans Dedecker Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Update the no_delegation parameter on a config reload; in case prefixes are present update the prefix assignments as well according to the no_delegation status Signed-off-by: Hans Dedecker --- interface-ip.c | 14 ++++++++++++++ interface-ip.h | 1 + interface.c | 10 +++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/interface-ip.c b/interface-ip.c index 1a6c28d..83f1dfa 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -1053,6 +1053,20 @@ void interface_refresh_assignments(bool hint) refresh = hint; } +void interface_update_prefix_delegation(struct interface_ip_settings *ip) +{ + struct device_prefix *prefix; + + vlist_for_each_element(&ip->prefix, prefix, node) { + interface_update_prefix_assignments(prefix, !ip->no_delegation); + + if (ip->no_delegation) { + if (prefix->head.next) + list_del(&prefix->head); + } else + list_add(&prefix->head, &prefixes); + } +} static void interface_update_prefix(struct vlist_tree *tree, diff --git a/interface-ip.h b/interface-ip.h index ec6d7fb..21c6e9b 100644 --- a/interface-ip.h +++ b/interface-ip.h @@ -172,5 +172,6 @@ struct device_prefix* interface_ip_add_device_prefix(struct interface *iface, struct in6_addr *excl_addr, uint8_t excl_length, const char *pclass); void interface_ip_set_ula_prefix(const char *prefix); void interface_refresh_assignments(bool hint); +void interface_update_prefix_delegation(struct interface_ip_settings *ip); #endif diff --git a/interface.c b/interface.c index b21d234..b8c4ae2 100644 --- a/interface.c +++ b/interface.c @@ -1197,7 +1197,7 @@ static void interface_change_config(struct interface *if_old, struct interface *if_new) { struct blob_attr *old_config = if_old->config; - bool reload = false, reload_ip = false; + bool reload = false, reload_ip = false, update_prefix_delegation = false; #define FIELD_CHANGED_STR(field) \ ((!!if_old->field != !!if_new->field) || \ @@ -1247,6 +1247,11 @@ interface_change_config(struct interface *if_old, struct interface *if_new) if_old->force_link = if_new->force_link; if_old->dns_metric = if_new->dns_metric; + if (if_old->proto_ip.no_delegation != if_new->proto_ip.no_delegation) { + if_old->proto_ip.no_delegation = if_new->proto_ip.no_delegation; + update_prefix_delegation = true; + } + if_old->proto_ip.no_dns = if_new->proto_ip.no_dns; interface_replace_dns(&if_old->config_ip, &if_new->config_ip); @@ -1276,6 +1281,9 @@ interface_change_config(struct interface *if_old, struct interface *if_new) interface_ip_set_enabled(&if_old->config_ip, config_ip_enabled); } + if (update_prefix_delegation) + interface_update_prefix_delegation(&if_old->proto_ip); + interface_write_resolv_conf(); if (if_old->main_dev.dev) interface_check_state(if_old);