From patchwork Tue Apr 2 13:02:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Donald X-Patchwork-Id: 1918786 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=n+iHVc/y; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Q3lJs5Rm; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V87PC4F66z1yZB for ; Wed, 3 Apr 2024 00:03:59 +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:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=+DgNY/4nc0qkkFZ89+13QRXYy5zmQ2O1gE2/NydjvBc=; b=n+iHVc/yEFapmI hA0bGKfCRDQQDMFgfuulvGcQQaa6T2DdVz6cvNtQgbvaW7MTiJGIP/gM2ozWkhAJ1rQBcDlZ1evsq kgV0L9/Jhq+5bM41pEoQDVHSD5h2h9gjY+V1c1bss1fSP0luuSiFeTTSZd2VO+s9tBEuB+YoGbT/T xu01gmQzbZDM9cw1sF2qrZamWEmg99SDDX1A/99bZGsbXHaeFXZjNYgVPdXFvoSzDcICg7a6a2tLw sCIjzW7HuBbiC1lu8Os/Y6DZIg71iF9NUh3Qi9X7KbNKWvkMcxYCYaidQ6hVFPs3URS6uotrrRflW G2u4CI3AmpIwHPGIg+cA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rrdmW-0000000BDQx-22eM; Tue, 02 Apr 2024 13:02:28 +0000 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rrdmT-0000000BDPq-0l2G for openwrt-devel@lists.openwrt.org; Tue, 02 Apr 2024 13:02:26 +0000 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-513e10a4083so5869866e87.1 for ; Tue, 02 Apr 2024 06:02:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712062942; x=1712667742; darn=lists.openwrt.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:sender:from:to:cc:subject:date:message-id:reply-to; bh=ImfS2UxrHK3gDoolN8yX9t2R8fpZ4tJGTf5l8TI0prk=; b=Q3lJs5RmXzK+DyA2XtMdtllrLaaUV5ea/uNsHWmhahjJMUzDYavJEOemMXagnjxiHx a57voePikObCcJ+erHBS8Aaw/Ls2HC1BxkRdEdmsDElF9EDlC3qj2bQnlMaA6c3d8Mac px3QUjL3RBEqugTD7ewQM9sSiLujagLGygot6laRo+94w6k4AtT1Mg7/w0BnSY+CZ1bh yzEGIxy1vNjMA1mJ9SrhLLiDpxMj1yFaF/iIASZ+o/AoYIMPA5wNUBIoP4R9kr/08cCi hEZNUmkQ9/C5D+oHRMXQlfU02FkUTka1BM/BGYL3Lm1REtHAvI70JQnDkQ5qNXqEmsjt oPCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712062942; x=1712667742; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ImfS2UxrHK3gDoolN8yX9t2R8fpZ4tJGTf5l8TI0prk=; b=eYSmg2btS2xb0a1xjkuNivg4i5iC2Y4dY+IJKF35gmQZLQ2AEPNLYR/G5h+2hqfCwm 1vlyU/X1Wv0f03dU1KDxlucx3j0oiyM3tv/znBoBZChvRHSJaB/0IAvoONOLrydI9OlJ LgRqGFiSTVzttexxXCtDEQKkV06E6X/Fhpkts8hgTadAODpJNQfEmKHHzYg6kC2Fikhq +jRbooJld0tIYJo6VlgSN5nsZqz7hKqgvluAMRJGNEAFu8xV6P9K7XszC9g1nkLkq2ep ACTterBtrR3usi4QYJJ8QssVeTEgv5CoCck8tjBNK0KmrEN357vu89nsm72Z6H+9736S cWNA== X-Gm-Message-State: AOJu0YwMwTj54Xmx5EGK+/RZWugJaeamirbk9J78Tf1Ty30JseISlmqe 6HNzFkcob/8G6lhbX0Puyw9RjvUYjSYpI7pbVH2iCjGGFJVja/vUZDu+0mGw X-Google-Smtp-Source: AGHT+IET6eGv29Ysk8Qu2nX25db2tps6znT96U129IH/BvyfgZyx+QgeupYwMdEj85lYqE0IYQCiBg== X-Received: by 2002:a05:6512:3e4:b0:515:ccd8:37c2 with SMTP id n4-20020a05651203e400b00515ccd837c2mr7234906lfq.44.1712062942389; Tue, 02 Apr 2024 06:02:22 -0700 (PDT) Received: from blackhol3 ([2001:9b0:40::cae3:cb03]) by smtp.gmail.com with ESMTPSA id d8-20020ac241c8000000b00515fc468f45sm995071lfi.31.2024.04.02.06.02.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 06:02:22 -0700 (PDT) From: Paul Donald To: openwrt-devel@lists.openwrt.org Subject: [PATCH 1/7] lldpd: fixed interface(s) parsing Date: Tue, 2 Apr 2024 15:02:15 +0200 Message-ID: <20240402130221.58706-1-newtwen+github@gmail.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240402_060225_497693_F6D94CAC X-CRM114-Status: GOOD ( 11.68 ) 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: For interface type parameters, the man page documents patterns: ``` *,!eth*,!!eth1 uses all interfaces, except interfaces starting with "eth", but including "eth1". ``` While we must check that interfaces exist, first strip any prefixed "!" then pass the original string (with `!` prefix) again, to command lines. 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:12f 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.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 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [newtwen+github(at)gmail.com] 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 For interface type parameters, the man page documents patterns: ``` *,!eth*,!!eth1 uses all interfaces, except interfaces starting with "eth", but including "eth1". ``` While we must check that interfaces exist, first strip any prefixed "!" then pass the original string (with `!` prefix) again, to command lines. * Renamed `_ifname` to `_l3dev`. * Glob pattern `*` is also valid - pass those verbatim. The net result is that now interface 'names' including globs '*' and '!' inversions now are included in the generated lldpd configs. We must also `set -o noglob` and `set +o noglob` to disable and enable globbing respectively, because when we pass `*` as an interface choice everything goes to hell without them. Tested extensively on: 22.03.6 Signed-off-by: Paul Donald --- .../network/services/lldpd/files/lldpd.init | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 67ee011ae2..fc53520c5b 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -76,18 +76,32 @@ get_config_restart_hash() { } get_config_cid_ifaces() { + set -o noglob local _ifaces config_get _ifaces 'config' "$2" local _iface _ifnames="" for _iface in $_ifaces; do - local _ifname="" - if network_get_device _ifname "$_iface" || [ -e "/sys/class/net/$_iface" ]; then - append _ifnames "${_ifname:-$_iface}" "," + local _l3dev="" + # save any "!" or "!!" prefix from the interface name + _suffix=${_iface##*"!"} + _prefix=${_iface%%"$_suffix"} + + if network_get_device _l3dev "$_suffix" || [ -e "/sys/class/net/$_suffix" ]; then + # prepend the stripped "!" or "!!" prefix here if we had one + append _ifnames "$_prefix${_l3dev:-$_suffix}" "," + else + case $_iface in + *"*"*) + # Append any interface names including a glob '*' pattern + append _ifnames "$_iface" "," + ;; + esac fi done export -n "${1}=$_ifnames" + set +o noglob } write_lldpd_conf()