From patchwork Fri Nov 4 06:20:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Vehlow X-Patchwork-Id: 1699336 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=yRJJg2s8; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=jv-coder.de header.i=@jv-coder.de header.a=rsa-sha256 header.s=dkim header.b=dG25XEnU; 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 4N3VwX5hY9z23ly for ; Fri, 4 Nov 2022 17:25:00 +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=L+Z1XlXODjL5xUjyTmU2o74fvwELuOvdl9Hk1DyoNMY=; b=yRJJg2s83Rc0es r0s5Kt+P+GdatXxGDm2GfIV1HiLoabauibMir2ADB6FEwILA6PKKXqgSDInligHU25X81hlyKmGC/ Xnt+wcvG+MFu9YqNUDlGMfqxlKgKCYTB0lcRQgBeydjQCHdno4bHOh5BwINZjChx9qYV3N1doX/j8 sA2cRFmHT/T+sGXyk6yHYbaOHys8S9N1BrVRCMuyGCE/V6p3lVdyXgzMT9Jy6zFxDWUlHC1F8pN6X DJl6PBM/wvX3pjkD5EkXWr2i7TrElhh+419DWwZlR9gLXjozQy2vcN0eGfXsNry4AR+nk8/soIXes 6YBPvtqDQwZop6KRwp+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqq5P-002VxY-7z; Fri, 04 Nov 2022 06:21:51 +0000 Received: from mail.jv-coder.de ([5.9.79.73]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqq4g-002Vjg-B2 for openwrt-devel@lists.openwrt.org; Fri, 04 Nov 2022 06:21:11 +0000 Received: from ubuntu.localdomain (unknown [188.192.100.83]) by mail.jv-coder.de (Postfix) with ESMTPSA id C0740A0A37; Fri, 4 Nov 2022 06:21:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jv-coder.de; s=dkim; t=1667542860; bh=EvwbWklj1M6F3i0d03m2hjq0iyh/T/SIRpRSJByoklQ=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=dG25XEnUWSd83Qb/prdNljrmkVXShaY7v8lwP1ROftwRt4ZD8QNbbb9gWYab9nkFH VmYukR7iCvC5w3o8NHHBbNfJWKyj6cZJNP8C+rftdWYbr91zYnM6uL9lWs9OZUPk4W ZNFCXNdoCcOOkQmI6Y+8HBGJgziVxnfO6X9ZSoc0= From: Joerg Vehlow To: openwrt-devel@lists.openwrt.org Cc: Joerg Vehlow Subject: [PATCH 1/6] add device setting for ip forwarding Date: Fri, 4 Nov 2022 07:20:48 +0100 Message-Id: <20221104062053.1236988-2-lkml@jv-coder.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221104062053.1236988-1-lkml@jv-coder.de> References: <20221104062053.1236988-1-lkml@jv-coder.de> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,UNPARSEABLE_RELAY autolearn=disabled version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mail X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221103_232106_608327_18CB3853 X-CRM114-Status: GOOD ( 13.27 ) 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: Joerg Vehlow This allows changing the ip_forwarding setting per device for ipv4 and ipv6 with ip_forwarding and ip6_forwarding --- device.c | 18 ++++++++++++++++++ device.h | 6 ++++++ system-linux.c | 37 +++++++++ [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -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_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: Joerg Vehlow This allows changing the ip_forwarding setting per device for ipv4 and ipv6 with ip_forwarding and ip6_forwarding --- device.c | 18 ++++++++++++++++++ device.h | 6 ++++++ system-linux.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/device.c b/device.c index b3d0e85..4f55906 100644 --- a/device.c +++ b/device.c @@ -63,6 +63,8 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = { [DEV_ATTR_AUTH] = { .name = "auth", .type = BLOBMSG_TYPE_BOOL }, [DEV_ATTR_SPEED] = { .name = "speed", .type = BLOBMSG_TYPE_INT32 }, [DEV_ATTR_DUPLEX] = { .name = "duplex", .type = BLOBMSG_TYPE_BOOL }, + [DEV_ATTR_IP_FORWARDING] = { .name = "ip_forwarding", .type = BLOBMSG_TYPE_BOOL}, + [DEV_ATTR_IP6_FORWARDING] = { .name = "ip6_forwarding", .type = BLOBMSG_TYPE_BOOL}, }; const struct uci_blob_param_list device_attr_list = { @@ -280,6 +282,8 @@ device_merge_settings(struct device *dev, struct device_settings *n) n->auth = s->flags & DEV_OPT_AUTH ? s->auth : os->auth; n->speed = s->flags & DEV_OPT_SPEED ? s->speed : os->speed; n->duplex = s->flags & DEV_OPT_DUPLEX ? s->duplex : os->duplex; + n->ip_forwarding = s->flags & DEV_OPT_IP_FORWARDING ? s->ip_forwarding : os->ip_forwarding; + n->ip6_forwarding = s->flags & DEV_OPT_IP6_FORWARDING ? s->ip6_forwarding : os->ip6_forwarding; n->flags = s->flags | os->flags | os->valid_flags; } @@ -464,6 +468,16 @@ device_init_settings(struct device *dev, struct blob_attr **tb) s->flags |= DEV_OPT_DUPLEX; } + if ((cur = tb[DEV_ATTR_IP_FORWARDING])) { + s->ip_forwarding = blobmsg_get_bool(cur); + s->flags |= DEV_OPT_IP_FORWARDING; + } + + if ((cur = tb[DEV_ATTR_IP6_FORWARDING])) { + s->ip6_forwarding = blobmsg_get_bool(cur); + s->flags |= DEV_OPT_IP6_FORWARDING; + } + device_set_disabled(dev, disabled); } @@ -1210,6 +1224,10 @@ device_dump_status(struct blob_buf *b, struct device *dev) blobmsg_add_u8(b, "arp_accept", st.arp_accept); if (st.flags & DEV_OPT_AUTH) blobmsg_add_u8(b, "auth", st.auth); + if (st.flags & DEV_OPT_IP_FORWARDING) + blobmsg_add_u8(b, "ip_forwarding", st.ip_forwarding); + if (st.flags & DEV_OPT_IP6_FORWARDING) + blobmsg_add_u8(b, "ip6_forwarding", st.ip6_forwarding); } s = blobmsg_open_table(b, "statistics"); diff --git a/device.h b/device.h index 37f8c37..066f537 100644 --- a/device.h +++ b/device.h @@ -62,6 +62,8 @@ enum { DEV_ATTR_AUTH, DEV_ATTR_SPEED, DEV_ATTR_DUPLEX, + DEV_ATTR_IP_FORWARDING, + DEV_ATTR_IP6_FORWARDING, __DEV_ATTR_MAX, }; @@ -126,6 +128,8 @@ enum { DEV_OPT_ARP_ACCEPT = (1ULL << 29), DEV_OPT_SPEED = (1ULL << 30), DEV_OPT_DUPLEX = (1ULL << 31), + DEV_OPT_IP_FORWARDING = (1ULL << 32), + DEV_OPT_IP6_FORWARDING = (1ULL << 33), }; /* events broadcasted to all users of a device */ @@ -203,6 +207,8 @@ struct device_settings { bool auth; unsigned int speed; bool duplex; + bool ip_forwarding; + bool ip6_forwarding; }; /* diff --git a/system-linux.c b/system-linux.c index 0f13a99..6232a26 100644 --- a/system-linux.c +++ b/system-linux.c @@ -460,6 +460,16 @@ static void system_set_arp_accept(struct device *dev, const char *val) system_set_dev_sysctl("ipv4/conf", "arp_accept", dev->ifname, val); } +static void system_set_ip_forwarding(struct device *dev, const char *val) +{ + system_set_dev_sysctl("ipv4/conf", "forwarding", dev->ifname, val); +} + +static void system_set_ip6_forwarding(struct device *dev, const char *val) +{ + system_set_dev_sysctl("ipv6/conf", "forwarding", dev->ifname, val); +} + static void system_bridge_set_multicast_to_unicast(struct device *dev, const char *val) { system_set_dev_sysfs("brport/multicast_to_unicast", dev->ifname, val); @@ -621,6 +631,18 @@ static int system_get_arp_accept(struct device *dev, char *buf, const size_t buf dev->ifname, buf, buf_sz); } +static int system_get_ip_forwarding(struct device *dev, char *buf, const size_t buf_sz) +{ + return system_get_dev_sysctl("ipv4/conf", "forwarding", + dev->ifname, buf, buf_sz); +} + +static int system_get_ip6_forwarding(struct device *dev, char *buf, const size_t buf_sz) +{ + return system_get_dev_sysctl("ipv6/conf", "forwarding", + dev->ifname, buf, buf_sz); +} + /* Evaluate netlink messages */ static int cb_rtnl_event(struct nl_msg *msg, void *arg) { @@ -1795,6 +1817,16 @@ system_if_get_settings(struct device *dev, struct device_settings *s) s->arp_accept = strtoul(buf, NULL, 0); s->flags |= DEV_OPT_ARP_ACCEPT; } + + if (!system_get_ip_forwarding(dev, buf, sizeof(buf))) { + s->ip_forwarding = strtoul(buf, NULL, 0); + s->flags |= DEV_OPT_IP_FORWARDING; + } + + if (!system_get_ip6_forwarding(dev, buf, sizeof(buf))) { + s->ip6_forwarding = strtoul(buf, NULL, 0); + s->flags |= DEV_OPT_IP6_FORWARDING; + } } void @@ -1893,6 +1925,11 @@ system_if_apply_settings(struct device *dev, struct device_settings *s, uint64_t system_set_drop_unsolicited_na(dev, s->drop_unsolicited_na ? "1" : "0"); if (apply_mask & DEV_OPT_ARP_ACCEPT) system_set_arp_accept(dev, s->arp_accept ? "1" : "0"); + if (apply_mask & DEV_OPT_IP_FORWARDING) + system_set_ip_forwarding(dev, s->ip_forwarding ? "1" : "0"); + if (apply_mask & DEV_OPT_IP6_FORWARDING) + system_set_ip6_forwarding(dev, s->ip6_forwarding ? "1" : "0"); + system_set_ethtool_settings(dev, s); } From patchwork Fri Nov 4 06:20:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Vehlow X-Patchwork-Id: 1699335 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=LcU+tidQ; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=jv-coder.de header.i=@jv-coder.de header.a=rsa-sha256 header.s=dkim header.b=UdAXunu6; 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 4N3VwX0N3Vz23ls for ; Fri, 4 Nov 2022 17:24: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: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=cQRE2ExKGxmUE3R1mU12hkW6LjlL/yEEvbp8KNVhsYQ=; b=LcU+tidQG5GTwN tB1mEODk01qkk5BYcqMYhPlb/57IcIFtO78uvSfTSm6uVZvSm0xXDxnhRYjQQPaQIi8AmdniICvkg oakyy/KiB82TSIHLqD/6GpwZHCAT9fkVCcxPvErDFF1GUCqqcbJ9E2IK4qsHA0vqp/HZiKqIpI5dO 8yYO9cXc04g41KsjB4HteB1upI0PJrsEzRh/aBMou/lAFnZH2V1+P3j74JxdSbtV1Zkv38Se0+XHH PbRBpY3QCBGX0Zzotv1NdfMrtQDOYljijYBAuSas6bxOR/XaOnD2ZFxattwkFBJKUpzmgflxZecSO dXwp8+LOvH9X0ROgU1uQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqq50-002VsY-B9; Fri, 04 Nov 2022 06:21:26 +0000 Received: from mail.jv-coder.de ([5.9.79.73]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqq4g-002Vjh-9p for openwrt-devel@lists.openwrt.org; Fri, 04 Nov 2022 06:21:09 +0000 Received: from ubuntu.localdomain (unknown [188.192.100.83]) by mail.jv-coder.de (Postfix) with ESMTPSA id 5457BA0A4A; Fri, 4 Nov 2022 06:21:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jv-coder.de; s=dkim; t=1667542861; bh=jdf2NL4dYmLYsF1a07dWLqSdVoLMq4+Z2Rv2FGLqzkY=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=UdAXunu6RX7cg4Wew2BKuukUBYUwLm8o/wN7bVyyi1PrI9JPBxVuzrI5KZT6K4nBB mYWMm0Orq+NHGN6ELLh+VQzEEJaW7mV3t+J4sWBeNvVF7fIxCijnNe7zoGpZzSsXfY MnPpJGy8lPNi3XqxIxm4jxZqZZX/nMaB8WWFaOUY= From: Joerg Vehlow To: openwrt-devel@lists.openwrt.org Cc: Joerg Vehlow Subject: [PATCH 2/6] add device setting for disabeling arp Date: Fri, 4 Nov 2022 07:20:49 +0100 Message-Id: <20221104062053.1236988-3-lkml@jv-coder.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221104062053.1236988-1-lkml@jv-coder.de> References: <20221104062053.1236988-1-lkml@jv-coder.de> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,UNPARSEABLE_RELAY autolearn=disabled version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mail X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221103_232106_558924_B68B4201 X-CRM114-Status: GOOD ( 11.25 ) 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: Joerg Vehlow --- device.c | 7 +++++++ device.h | 3 +++ system-linux.c | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/device.c b/device.c index 4f55906..9ed50ef 100644 --- a/device.c +++ b/device.c @@ -65,6 +65,7 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = { [DEV_ATTR_DUPLEX] = { .n [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -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_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: Joerg Vehlow --- device.c | 7 +++++++ device.h | 3 +++ system-linux.c | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/device.c b/device.c index 4f55906..9ed50ef 100644 --- a/device.c +++ b/device.c @@ -65,6 +65,7 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = { [DEV_ATTR_DUPLEX] = { .name = "duplex", .type = BLOBMSG_TYPE_BOOL }, [DEV_ATTR_IP_FORWARDING] = { .name = "ip_forwarding", .type = BLOBMSG_TYPE_BOOL}, [DEV_ATTR_IP6_FORWARDING] = { .name = "ip6_forwarding", .type = BLOBMSG_TYPE_BOOL}, + [DEV_ATTR_ARP] = { .name = "arp", .type = BLOBMSG_TYPE_BOOL}, }; const struct uci_blob_param_list device_attr_list = { @@ -284,6 +285,7 @@ device_merge_settings(struct device *dev, struct device_settings *n) n->duplex = s->flags & DEV_OPT_DUPLEX ? s->duplex : os->duplex; n->ip_forwarding = s->flags & DEV_OPT_IP_FORWARDING ? s->ip_forwarding : os->ip_forwarding; n->ip6_forwarding = s->flags & DEV_OPT_IP6_FORWARDING ? s->ip6_forwarding : os->ip6_forwarding; + n->arp = s->flags & DEV_OPT_ARP ? s->arp : os->arp; n->flags = s->flags | os->flags | os->valid_flags; } @@ -478,6 +480,11 @@ device_init_settings(struct device *dev, struct blob_attr **tb) s->flags |= DEV_OPT_IP6_FORWARDING; } + if ((cur = tb[DEV_ATTR_ARP])) { + s->arp = blobmsg_get_bool(cur); + s->flags |= DEV_OPT_ARP; + } + device_set_disabled(dev, disabled); } diff --git a/device.h b/device.h index 066f537..f78bbcb 100644 --- a/device.h +++ b/device.h @@ -64,6 +64,7 @@ enum { DEV_ATTR_DUPLEX, DEV_ATTR_IP_FORWARDING, DEV_ATTR_IP6_FORWARDING, + DEV_ATTR_ARP, __DEV_ATTR_MAX, }; @@ -130,6 +131,7 @@ enum { DEV_OPT_DUPLEX = (1ULL << 31), DEV_OPT_IP_FORWARDING = (1ULL << 32), DEV_OPT_IP6_FORWARDING = (1ULL << 33), + DEV_OPT_ARP = (1ULL << 34), }; /* events broadcasted to all users of a device */ @@ -209,6 +211,7 @@ struct device_settings { bool duplex; bool ip_forwarding; bool ip6_forwarding; + bool arp; }; /* diff --git a/system-linux.c b/system-linux.c index 6232a26..7b82e17 100644 --- a/system-linux.c +++ b/system-linux.c @@ -1736,6 +1736,9 @@ system_if_get_settings(struct device *dev, struct device_settings *s) s->multicast = ifr.ifr_flags & IFF_MULTICAST; s->flags |= DEV_OPT_MULTICAST; + + s->arp = !(ifr.ifr_flags & IFF_NOARP); + s->arp |= DEV_OPT_ARP; } if (!system_get_rpfilter(dev, buf, sizeof(buf))) { @@ -1929,6 +1932,10 @@ system_if_apply_settings(struct device *dev, struct device_settings *s, uint64_t system_set_ip_forwarding(dev, s->ip_forwarding ? "1" : "0"); if (apply_mask & DEV_OPT_IP6_FORWARDING) system_set_ip6_forwarding(dev, s->ip6_forwarding ? "1" : "0"); + if (apply_mask & DEV_OPT_ARP) { + if (system_if_flags(dev->ifname, !s->arp ? IFF_NOARP : 0, s->arp ? IFF_NOARP : 0) < 0) + s->flags &= ~DEV_OPT_ARP; + } system_set_ethtool_settings(dev, s); } From patchwork Fri Nov 4 06:20:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Vehlow X-Patchwork-Id: 1699333 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=M5n9P17d; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=jv-coder.de header.i=@jv-coder.de header.a=rsa-sha256 header.s=dkim header.b=tAVWQqCX; 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 4N3VwR6H6Gz23ly for ; Fri, 4 Nov 2022 17:24:55 +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=x3SZE6PL/pVJWndN5u0TI/X5oswGv0BSLBRXR6Z9+Lw=; b=M5n9P17dRoqKOr 3A2s0mJQQicf++T4ZkgAT9eksu54kdGBuWfDIN44HYrFW6WQ5X8HpkNl255nhJNJfCDUX0u5D9+PE D3ogWEVS8wWhJNCZp9BHWPtjjDxXIeXI9ioqyk8yX++xRE5+DVxfwAwEalxbpDf6EPGAUQIkkoMQw eYrNFNpXlalzh3cJM26ZGEQDzLwwKj+tO/ZFxeqRGSlNDtMaJa8LppHDEcGqMdqmi3jQ4l+g1AgL+ CmX4tHzVZEj5kdb5N1dZep/WVXb8eeIp1R7g4KZCoSQ3JLh95DuZ3k7CwXEJoXmofYWGReAFaui3M xFGkw1B+XooV94jcj8+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqq5c-002W0O-2E; Fri, 04 Nov 2022 06:22:04 +0000 Received: from mail.jv-coder.de ([5.9.79.73]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqq4g-002Vjm-C6 for openwrt-devel@lists.openwrt.org; Fri, 04 Nov 2022 06:21:11 +0000 Received: from ubuntu.localdomain (unknown [188.192.100.83]) by mail.jv-coder.de (Postfix) with ESMTPSA id F10E3A0A4D; Fri, 4 Nov 2022 06:21:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jv-coder.de; s=dkim; t=1667542862; bh=zBYxNUVrt7+3bDY1aIiqrL8UsR8vzOaTAeJ+1JAlGks=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=tAVWQqCX/VYZY8wI8sD1EU2Hatp/SDVUH/Iad7ZmID7A5569OCTrDBUv8efpuv5m/ ELoi9OgwuhUh0RF1UBEXgr+4AUBzQq4xQwSqRT3fuYxR8XyrgdVufQJ5MGOEI5Fi4Y 1Rfo3Mwz7+r2wOPnKlNVzT41GQK+6hddDZB18deE= From: Joerg Vehlow To: openwrt-devel@lists.openwrt.org Cc: Joerg Vehlow Subject: [PATCH 3/6] add device setting for controlling ipv6 routing header Date: Fri, 4 Nov 2022 07:20:50 +0100 Message-Id: <20221104062053.1236988-4-lkml@jv-coder.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221104062053.1236988-1-lkml@jv-coder.de> References: <20221104062053.1236988-1-lkml@jv-coder.de> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,UNPARSEABLE_RELAY autolearn=disabled version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mail X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221103_232106_618794_031052CD X-CRM114-Status: GOOD ( 15.54 ) 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: Joerg Vehlow ip6_accept_routing_header with values: - all: Allow all routing headers - rh2: Allow only routing header 2 - none: Ignore all routing headers --- device.c | 31 +++++++++++++++++++++++++++++++ device.h [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -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_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: Joerg Vehlow ip6_accept_routing_header with values: - all: Allow all routing headers - rh2: Allow only routing header 2 - none: Ignore all routing headers --- device.c | 31 +++++++++++++++++++++++++++++++ device.h | 3 +++ system-linux.c | 20 ++++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/device.c b/device.c index 9ed50ef..0860c55 100644 --- a/device.c +++ b/device.c @@ -12,6 +12,7 @@ * GNU General Public License for more details. */ #include +#include #include #include #include @@ -66,6 +67,7 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = { [DEV_ATTR_IP_FORWARDING] = { .name = "ip_forwarding", .type = BLOBMSG_TYPE_BOOL}, [DEV_ATTR_IP6_FORWARDING] = { .name = "ip6_forwarding", .type = BLOBMSG_TYPE_BOOL}, [DEV_ATTR_ARP] = { .name = "arp", .type = BLOBMSG_TYPE_BOOL}, + [DEV_ATTR_IP6_ACCEPT_ROUTING_HEADER] = { .name = "ip6_accept_routing_header", .type = BLOBMSG_TYPE_STRING }, }; const struct uci_blob_param_list device_attr_list = { @@ -286,6 +288,7 @@ device_merge_settings(struct device *dev, struct device_settings *n) n->ip_forwarding = s->flags & DEV_OPT_IP_FORWARDING ? s->ip_forwarding : os->ip_forwarding; n->ip6_forwarding = s->flags & DEV_OPT_IP6_FORWARDING ? s->ip6_forwarding : os->ip6_forwarding; n->arp = s->flags & DEV_OPT_ARP ? s->arp : os->arp; + n->accept_routing_header = s->flags & DEV_OPT_IP6_ACCEPT_ROUTING_HEADER ? s->accept_routing_header : os->accept_routing_header; n->flags = s->flags | os->flags | os->valid_flags; } @@ -485,6 +488,22 @@ device_init_settings(struct device *dev, struct blob_attr **tb) s->flags |= DEV_OPT_ARP; } + if ((cur = tb[DEV_ATTR_IP6_ACCEPT_ROUTING_HEADER])) { + const char *val = blobmsg_get_string(cur); + if (strcasecmp(val, "all") == 0) { + s->accept_routing_header = 1; + s->flags |= DEV_OPT_IP6_ACCEPT_ROUTING_HEADER; + } else if (strcasecmp(val, "rh2") == 0) { + s->accept_routing_header = 0; + s->flags |= DEV_OPT_IP6_ACCEPT_ROUTING_HEADER; + } else if (strcasecmp(val, "none") == 0) { + s->accept_routing_header = -1; + s->flags |= DEV_OPT_IP6_ACCEPT_ROUTING_HEADER; + } else { + DPRINTF("Invalid value: %s - (use 'all', 'rh2' or 'none')\n", val); + } + } + device_set_disabled(dev, disabled); } @@ -1235,6 +1254,18 @@ device_dump_status(struct blob_buf *b, struct device *dev) blobmsg_add_u8(b, "ip_forwarding", st.ip_forwarding); if (st.flags & DEV_OPT_IP6_FORWARDING) blobmsg_add_u8(b, "ip6_forwarding", st.ip6_forwarding); + if (st.flags & DEV_OPT_IP6_ACCEPT_ROUTING_HEADER) { + const char *val = NULL; + if (st.accept_routing_header == 0) { + val = "rh2"; + } else if (st.accept_routing_header < 0) { + val = "none"; + } else { + val = "all"; + } + + blobmsg_add_string(b, "ip6_accept_routing_header", val); + } } s = blobmsg_open_table(b, "statistics"); diff --git a/device.h b/device.h index f78bbcb..c94a32f 100644 --- a/device.h +++ b/device.h @@ -65,6 +65,7 @@ enum { DEV_ATTR_IP_FORWARDING, DEV_ATTR_IP6_FORWARDING, DEV_ATTR_ARP, + DEV_ATTR_IP6_ACCEPT_ROUTING_HEADER, __DEV_ATTR_MAX, }; @@ -132,6 +133,7 @@ enum { DEV_OPT_IP_FORWARDING = (1ULL << 32), DEV_OPT_IP6_FORWARDING = (1ULL << 33), DEV_OPT_ARP = (1ULL << 34), + DEV_OPT_IP6_ACCEPT_ROUTING_HEADER = (1ULL << 35), }; /* events broadcasted to all users of a device */ @@ -212,6 +214,7 @@ struct device_settings { bool ip_forwarding; bool ip6_forwarding; bool arp; + int accept_routing_header; }; /* diff --git a/system-linux.c b/system-linux.c index 7b82e17..12a7e3f 100644 --- a/system-linux.c +++ b/system-linux.c @@ -470,6 +470,13 @@ static void system_set_ip6_forwarding(struct device *dev, const char *val) system_set_dev_sysctl("ipv6/conf", "forwarding", dev->ifname, val); } +static void system_set_ip6_accept_source_route(struct device *dev, int val) +{ + char sval[10]; + snprintf(sval, sizeof(sval), "%d", val); + system_set_dev_sysctl("ipv6/conf", "accept_source_route", dev->ifname, sval); +} + static void system_bridge_set_multicast_to_unicast(struct device *dev, const char *val) { system_set_dev_sysfs("brport/multicast_to_unicast", dev->ifname, val); @@ -643,6 +650,12 @@ static int system_get_ip6_forwarding(struct device *dev, char *buf, const size_t dev->ifname, buf, buf_sz); } +static int system_get_accept_source_route(struct device *dev, char *buf, const size_t buf_sz) +{ + return system_get_dev_sysctl("ipv6/conf", "accept_source_route", + dev->ifname, buf, buf_sz); +} + /* Evaluate netlink messages */ static int cb_rtnl_event(struct nl_msg *msg, void *arg) { @@ -1830,6 +1843,11 @@ system_if_get_settings(struct device *dev, struct device_settings *s) s->ip6_forwarding = strtoul(buf, NULL, 0); s->flags |= DEV_OPT_IP6_FORWARDING; } + + if (!system_get_accept_source_route(dev, buf, sizeof(buf))) { + s->accept_routing_header = strtoul(buf, NULL, 0); + s->flags |= DEV_OPT_IP6_ACCEPT_ROUTING_HEADER; + } } void @@ -1936,6 +1954,8 @@ system_if_apply_settings(struct device *dev, struct device_settings *s, uint64_t if (system_if_flags(dev->ifname, !s->arp ? IFF_NOARP : 0, s->arp ? IFF_NOARP : 0) < 0) s->flags &= ~DEV_OPT_ARP; } + if (apply_mask & DEV_OPT_IP6_ACCEPT_ROUTING_HEADER) + system_set_ip6_accept_source_route(dev, s->accept_routing_header); system_set_ethtool_settings(dev, s); } From patchwork Fri Nov 4 06:20:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Vehlow X-Patchwork-Id: 1699334 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=DMya4+MU; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=jv-coder.de header.i=@jv-coder.de header.a=rsa-sha256 header.s=dkim header.b=WkYpQZ8w; 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 4N3VwS2Wtxz23m0 for ; Fri, 4 Nov 2022 17:24:56 +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=WrP+mWg0gEl7nny+Y5M0JM0pp3cKetI9WAJouSm2fWE=; b=DMya4+MU5xwP4Q Ahyo9lvlHNsSHonqHTgEVZFZSd7GgU5NL6QnxdP/wUHGP12Y7q7l9UUQSvGfXKuBEcS324yFbVlQH iPyTF8WWROkEMteU9TZ4Rr11LSWjJ59iZ2EoZn54NyU5pcPOS0WO4F290V3zPKiHODFYO4BN4X2Vi uOw9UAryUTvHjSuI5+NEWNEDtMkUJldT/7QA0DXyGb7wsSgG/fFiMEgzUpt+WuN3glieZTkn3YIZB jkbSAazYcLOGyXSrgnQhvq8lm5em7HnG/U2kJgLn1HTQf2E2vTxv4ifWj0nGR5brCXO9/yzToubSf vJDt/FTEL4kZh611csTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqq5D-002Vv1-DC; Fri, 04 Nov 2022 06:21:39 +0000 Received: from mail.jv-coder.de ([5.9.79.73]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqq4g-002Vjp-C1 for openwrt-devel@lists.openwrt.org; Fri, 04 Nov 2022 06:21:11 +0000 Received: from ubuntu.localdomain (unknown [188.192.100.83]) by mail.jv-coder.de (Postfix) with ESMTPSA id 8BF8EA0A58; Fri, 4 Nov 2022 06:21:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jv-coder.de; s=dkim; t=1667542862; bh=LkisW7PI4JpNAqOc6IuRtvWvFN3Ksr4lFdPQrfxLvxI=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=WkYpQZ8wOvvy2IcFYGX9n2H98zFBS0g3XsT2vwql//O54kYXaO03PTMu4XsIytanI NgnnpEpxOhS0pWd2RIL54k11+Tm6Ib69NDmsfAJbnWiX307064Ao5kDPhvql8pOHgi y2luFERZ4Qs0QSOkTpu/YDwaIv/qyI6z64IQQxNA= From: Joerg Vehlow To: openwrt-devel@lists.openwrt.org Cc: Joerg Vehlow Subject: [PATCH 4/6] add global option for ipv4 default ttl Date: Fri, 4 Nov 2022 07:20:51 +0100 Message-Id: <20221104062053.1236988-5-lkml@jv-coder.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221104062053.1236988-1-lkml@jv-coder.de> References: <20221104062053.1236988-1-lkml@jv-coder.de> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,UNPARSEABLE_RELAY autolearn=disabled version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mail X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221103_232106_607097_2739F179 X-CRM114-Status: GOOD ( 12.30 ) 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: Joerg Vehlow --- config.c | 21 +++++++++++++++++---- system-dummy.c | 4 ++++ system-linux.c | 18 ++++++++++++++++++ system.h | 10 ++++++++++ 4 files changed, 49 insertions(+), 4 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -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_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: Joerg Vehlow --- config.c | 21 +++++++++++++++++---- system-dummy.c | 4 ++++ system-linux.c | 18 ++++++++++++++++++ system.h | 10 ++++++++++ 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/config.c b/config.c index 9bbda39..93df20e 100644 --- a/config.c +++ b/config.c @@ -27,6 +27,7 @@ #include "proto.h" #include "wireless.h" #include "config.h" +#include "system.h" bool config_init = false; @@ -528,14 +529,26 @@ config_init_rules(void) static void config_init_globals(void) { - struct uci_section *globals = uci_lookup_section( - uci_ctx, uci_network, "globals"); + struct uci_section *globals = uci_lookup_section(uci_ctx, uci_network, "globals"); if (!globals) return; - const char *ula_prefix = uci_lookup_option_string( - uci_ctx, globals, "ula_prefix"); + const char *ula_prefix = uci_lookup_option_string(uci_ctx, globals, "ula_prefix"); interface_ip_set_ula_prefix(ula_prefix); + + struct global_settings config = {}; + + const char *default_ttl = uci_lookup_option_string(uci_ctx, globals, "ip_default_ttl"); + if (default_ttl) { + config.ttl = strtoul(default_ttl, NULL, 10); + if (config.ttl < 1 || config.ttl > 255) { + netifd_log_message(L_WARNING, "Invalid value '%d' for ip4_default_ttl (allowed 1-255)\n"); + } else { + config.flags |= GLOBAL_OPT_TTL; + } + } + + system_globals_apply_settings(&config); } static void diff --git a/system-dummy.c b/system-dummy.c index b13bc87..f47b1af 100644 --- a/system-dummy.c +++ b/system-dummy.c @@ -379,3 +379,7 @@ int system_vlandev_del(struct device *vlandev) { return 0; } + +void system_globals_apply_settings(const struct global_settings *settings) +{ +} diff --git a/system-linux.c b/system-linux.c index 12a7e3f..66470b6 100644 --- a/system-linux.c +++ b/system-linux.c @@ -332,6 +332,13 @@ dev_sysfs_path(const char *ifname, const char *file) return dev_buf; } +static void +system_set_sysctl(const char *file, const char *val) +{ + snprintf(dev_buf, sizeof(dev_buf), "%s/sys/net/%s", proc_path, file); + write_file(dev_buf, val); +} + static void system_set_dev_sysctl(const char *prefix, const char *file, const char *ifname, const char *val) @@ -4101,3 +4108,14 @@ int system_add_ip_tunnel(const struct device *dev, struct blob_attr *attr) return 0; } + +void system_globals_apply_settings(const struct global_settings *settings) +{ + uint64_t flags = settings->flags; + char buf[12]; + + if (flags & GLOBAL_OPT_TTL) { + snprintf(buf, sizeof(buf), "%d", settings->ttl); + system_set_sysctl("ipv4/ip_default_ttl", buf); + } +} diff --git a/system.h b/system.h index 0f08c26..ee3c03e 100644 --- a/system.h +++ b/system.h @@ -291,6 +291,15 @@ struct bonding_config { int downdelay; }; +enum { + GLOBAL_OPT_TTL = (1ULL << 0), +}; + +struct global_settings { + uint64_t flags; + int ttl; +}; + static inline int system_get_addr_family(unsigned int flags) { if ((flags & DEVADDR_FAMILY) == DEVADDR_INET6) @@ -383,4 +392,5 @@ int system_link_netns_move(struct device *dev, const pid_t target_ns, const char int system_netns_open(const pid_t target_ns); int system_netns_set(int netns_fd); +void system_globals_apply_settings(const struct global_settings *settings); #endif From patchwork Fri Nov 4 06:20:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Vehlow X-Patchwork-Id: 1699337 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=ijZkgtXY; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=jv-coder.de header.i=@jv-coder.de header.a=rsa-sha256 header.s=dkim header.b=eNqtx9U+; 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 4N3Vwn4p3Cz23lK for ; Fri, 4 Nov 2022 17:25:13 +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=qinYLlUYRNU3PBy+cysxT0LJKLFcSLtb3HVeyeEs014=; b=ijZkgtXYgromS8 k4FIrtFAiqGJpgMZ3/jZN2yov28Gy1GpSmABrmARz+GwNAJmlt0on7/hQ6RIRUR2upFaCkkb64Hah eGb2YquKNbsg4txcVf4xBqr7bqaGgTViaAj0YXycnB/wvBFVWC3eLzCTP92UhYH3iZ41dt38VwFJ6 Xyrl8T0ATwYZ2vSLThVQp8HvZT25fwWCpOJZiAj48J8NXilH5fFA9BrhoAgMry0nBqwaRqjoAF2KT P0UrpSUtOsjr16EpDtkiAV6f4a+9VLmob6lv812oS5rrAAGYf0YWil4YxuvqmmMH7j0k0kJgMoc9/ KYLdd/fj5RJu2mOvxkAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqq69-002W8T-5R; Fri, 04 Nov 2022 06:22:37 +0000 Received: from mail.jv-coder.de ([5.9.79.73]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqq4l-002VlI-97 for openwrt-devel@lists.openwrt.org; Fri, 04 Nov 2022 06:21:13 +0000 Received: from ubuntu.localdomain (unknown [188.192.100.83]) by mail.jv-coder.de (Postfix) with ESMTPSA id 3D54BA0A59; Fri, 4 Nov 2022 06:21:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jv-coder.de; s=dkim; t=1667542863; bh=8Y7aMajN5QK4t7FR/ET4w+IFmiqQ5nmea1bOi5WBb+0=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=eNqtx9U+lBf6owZuSd/uTvM3NQReT7976ZEE+mMVze+Oo0qdVsOYSxonjZeXS/Kdl X4LmEgxzLqleZfwyQJGcDCIX68my5T+uUMa+hVn5fcLuj2xhHqW8UlRoAITnULgvXY DnRkYyOqISF4YJ+DtzeYe0KO5gWHNUxecd3ctoYI= From: Joerg Vehlow To: openwrt-devel@lists.openwrt.org Cc: Joerg Vehlow Subject: [PATCH 5/6] add device setting for ipv6 hop limit Date: Fri, 4 Nov 2022 07:20:52 +0100 Message-Id: <20221104062053.1236988-6-lkml@jv-coder.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221104062053.1236988-1-lkml@jv-coder.de> References: <20221104062053.1236988-1-lkml@jv-coder.de> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,UNPARSEABLE_RELAY autolearn=disabled version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mail X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221103_232111_638739_B2EFDD6D X-CRM114-Status: GOOD ( 13.24 ) 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: Joerg Vehlow --- device.c | 9 +++++++++ device.h | 3 +++ system-linux.c | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/device.c b/device.c index 0860c55..80fa359 100644 --- a/device.c +++ b/device.c @@ -68,6 +68,7 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = { [DEV_ATTR_IP6_FORWARDING [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -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_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: Joerg Vehlow --- device.c | 9 +++++++++ device.h | 3 +++ system-linux.c | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/device.c b/device.c index 0860c55..80fa359 100644 --- a/device.c +++ b/device.c @@ -68,6 +68,7 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = { [DEV_ATTR_IP6_FORWARDING] = { .name = "ip6_forwarding", .type = BLOBMSG_TYPE_BOOL}, [DEV_ATTR_ARP] = { .name = "arp", .type = BLOBMSG_TYPE_BOOL}, [DEV_ATTR_IP6_ACCEPT_ROUTING_HEADER] = { .name = "ip6_accept_routing_header", .type = BLOBMSG_TYPE_STRING }, + [DEV_ATTR_IP6_HOP_LIMIT] = { .name = "ip6_hop_limit", .type = BLOBMSG_TYPE_INT32}, }; const struct uci_blob_param_list device_attr_list = { @@ -289,6 +290,7 @@ device_merge_settings(struct device *dev, struct device_settings *n) n->ip6_forwarding = s->flags & DEV_OPT_IP6_FORWARDING ? s->ip6_forwarding : os->ip6_forwarding; n->arp = s->flags & DEV_OPT_ARP ? s->arp : os->arp; n->accept_routing_header = s->flags & DEV_OPT_IP6_ACCEPT_ROUTING_HEADER ? s->accept_routing_header : os->accept_routing_header; + n->hop_limit = s->flags & DEV_OPT_IP6_HOP_LIMIT ? s->hop_limit : os->hop_limit; n->flags = s->flags | os->flags | os->valid_flags; } @@ -504,6 +506,11 @@ device_init_settings(struct device *dev, struct blob_attr **tb) } } + if ((cur = tb[DEV_ATTR_IP6_HOP_LIMIT])) { + s->hop_limit = blobmsg_get_u32(cur); + s->flags |= DEV_OPT_IP6_HOP_LIMIT; + } + device_set_disabled(dev, disabled); } @@ -1266,6 +1273,8 @@ device_dump_status(struct blob_buf *b, struct device *dev) blobmsg_add_string(b, "ip6_accept_routing_header", val); } + if (st.flags & DEV_OPT_IP6_HOP_LIMIT) + blobmsg_add_u32(b, "ip6_hop_limit", st.hop_limit); } s = blobmsg_open_table(b, "statistics"); diff --git a/device.h b/device.h index c94a32f..63be0ae 100644 --- a/device.h +++ b/device.h @@ -66,6 +66,7 @@ enum { DEV_ATTR_IP6_FORWARDING, DEV_ATTR_ARP, DEV_ATTR_IP6_ACCEPT_ROUTING_HEADER, + DEV_ATTR_IP6_HOP_LIMIT, __DEV_ATTR_MAX, }; @@ -134,6 +135,7 @@ enum { DEV_OPT_IP6_FORWARDING = (1ULL << 33), DEV_OPT_ARP = (1ULL << 34), DEV_OPT_IP6_ACCEPT_ROUTING_HEADER = (1ULL << 35), + DEV_OPT_IP6_HOP_LIMIT = (1ULL << 36), }; /* events broadcasted to all users of a device */ @@ -215,6 +217,7 @@ struct device_settings { bool ip6_forwarding; bool arp; int accept_routing_header; + int hop_limit; }; /* diff --git a/system-linux.c b/system-linux.c index 66470b6..462a8cc 100644 --- a/system-linux.c +++ b/system-linux.c @@ -477,6 +477,11 @@ static void system_set_ip6_forwarding(struct device *dev, const char *val) system_set_dev_sysctl("ipv6/conf", "forwarding", dev->ifname, val); } +static void system_set_ip6_hop_limit(struct device *dev, const char *val) +{ + system_set_dev_sysctl("ipv6/conf", "hop_limit", dev->ifname, val); +} + static void system_set_ip6_accept_source_route(struct device *dev, int val) { char sval[10]; @@ -663,6 +668,12 @@ static int system_get_accept_source_route(struct device *dev, char *buf, const s dev->ifname, buf, buf_sz); } +static int system_get_ip6_hop_limit(struct device *dev, char *buf, const size_t buf_sz) +{ + return system_get_dev_sysctl("ipv6/conf", "hop_limit", + dev->ifname, buf, buf_sz); +} + /* Evaluate netlink messages */ static int cb_rtnl_event(struct nl_msg *msg, void *arg) { @@ -1855,6 +1866,11 @@ system_if_get_settings(struct device *dev, struct device_settings *s) s->accept_routing_header = strtoul(buf, NULL, 0); s->flags |= DEV_OPT_IP6_ACCEPT_ROUTING_HEADER; } + + if (!system_get_ip6_hop_limit(dev, buf, sizeof(buf))) { + s->hop_limit = strtoul(buf, NULL, 0); + s->flags |= DEV_OPT_IP6_HOP_LIMIT; + } } void @@ -1964,6 +1980,11 @@ system_if_apply_settings(struct device *dev, struct device_settings *s, uint64_t if (apply_mask & DEV_OPT_IP6_ACCEPT_ROUTING_HEADER) system_set_ip6_accept_source_route(dev, s->accept_routing_header); + if (apply_mask & DEV_OPT_IP6_HOP_LIMIT) { + snprintf(buf, sizeof(buf), "%d", s->hop_limit); + system_set_ip6_hop_limit(dev, buf); + } + system_set_ethtool_settings(dev, s); } From patchwork Fri Nov 4 06:20:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Vehlow X-Patchwork-Id: 1699331 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=bLSHiO6K; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=jv-coder.de header.i=@jv-coder.de header.a=rsa-sha256 header.s=dkim header.b=JlPLZj3F; 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 4N3VwR64KQz23ls for ; Fri, 4 Nov 2022 17:24:55 +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=763eQiMzH5yt9qVsq+FjcHhVl5pH7g6mboXcnoZbz0E=; b=bLSHiO6K3Ha9of lYhDejoX7z8TMnqhvJJTixzts+VEAYl54kB6cN3Z1wlNi/0LUbw1Hg+nwWDR2wChc4rW35sUnKzEP mRDv3nc0Tv7zcUAk8SGVLHu2qmHn9E7PcK59k6HQ0qtxo87/Y88XKql4DTo4lx1seEmgYPipif4nr OQoq8SD9TumDWA0hZY34l7kyyhSBjIVXN3hH0w/SPwRpyYNQZGdkcj2JmBDzuVax+76fZIufApEZ8 OohNReuYU2vbDqtVJKNba1k2HYqoWftLllBisWkZIFd+RyHptq63VSBv9FBOyIcXcrUUOh8LtY63L 8qNK/Nk0lgGB/osCJPZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqq5r-002W46-Ng; Fri, 04 Nov 2022 06:22:19 +0000 Received: from mail.jv-coder.de ([5.9.79.73]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqq4l-002VlJ-9J for openwrt-devel@lists.openwrt.org; Fri, 04 Nov 2022 06:21:13 +0000 Received: from ubuntu.localdomain (unknown [188.192.100.83]) by mail.jv-coder.de (Postfix) with ESMTPSA id B9D13A0A67; Fri, 4 Nov 2022 06:21:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jv-coder.de; s=dkim; t=1667542863; bh=xQQBoFc+QSmdS9IxGT+55W+Q/V2mxZbTe2GdAnXig28=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=JlPLZj3FETJHa6p2W1aEDimx8FXa4IjeTTEBYygNqO2qsmgvrEajSSK1hkM7aeqSE uDK2mYNma18jHrdqpQlQVR6zlbIU7Ys2ZQFw6wy4UoZ2bEiMvDhW9La4AliztvV2UH uIYmMp/EqZVp54mY1Ap7J8Af40YLpaLK/WLgsLw8= From: Joerg Vehlow To: openwrt-devel@lists.openwrt.org Cc: Joerg Vehlow Subject: [PATCH 6/6] add route setting for advertised mss Date: Fri, 4 Nov 2022 07:20:53 +0100 Message-Id: <20221104062053.1236988-7-lkml@jv-coder.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221104062053.1236988-1-lkml@jv-coder.de> References: <20221104062053.1236988-1-lkml@jv-coder.de> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,UNPARSEABLE_RELAY autolearn=disabled version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mail X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221103_232111_651861_420E18F5 X-CRM114-Status: GOOD ( 13.58 ) 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: Joerg Vehlow --- interface-ip.c | 7 +++++++ interface-ip.h | 4 ++++ system-linux.c | 7 +++++-- ubus.c | 4 ++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/interface-ip.c b/interface-ip.c index ab4a5cf..02314cd 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -44,6 +44,7 @@ enum { ROUTE_TYPE, ROUTE_PROTO, ROUTE_DISABLED, + ROUTE_ADVMSS, _ [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -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_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: Joerg Vehlow --- interface-ip.c | 7 +++++++ interface-ip.h | 4 ++++ system-linux.c | 7 +++++-- ubus.c | 4 ++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/interface-ip.c b/interface-ip.c index ab4a5cf..02314cd 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -44,6 +44,7 @@ enum { ROUTE_TYPE, ROUTE_PROTO, ROUTE_DISABLED, + ROUTE_ADVMSS, __ROUTE_MAX }; @@ -61,6 +62,7 @@ static const struct blobmsg_policy route_attr[__ROUTE_MAX] = { [ROUTE_TYPE] = { .name = "type", .type = BLOBMSG_TYPE_STRING }, [ROUTE_PROTO] = { .name = "proto", .type = BLOBMSG_TYPE_STRING }, [ROUTE_DISABLED] = { .name = "disabled", .type = BLOBMSG_TYPE_BOOL }, + [ROUTE_ADVMSS] = { .name ="advmss", .type = BLOBMSG_TYPE_INT32 }, }; const struct uci_blob_param_list route_attr_list = { @@ -460,6 +462,11 @@ interface_ip_add_route(struct interface *iface, struct blob_attr *attr, bool v6) route->flags |= DEVROUTE_MTU; } + if ((cur = tb[ROUTE_ADVMSS]) != NULL) { + route->advmss = blobmsg_get_u32(cur); + route->flags |= DEVROUTE_ADVMSS; + } + /* Use source-based routing */ if ((cur = tb[ROUTE_SOURCE]) != NULL) { char *saveptr, *source = alloca(blobmsg_data_len(cur)); diff --git a/interface-ip.h b/interface-ip.h index 8843349..eabdb39 100644 --- a/interface-ip.h +++ b/interface-ip.h @@ -51,6 +51,9 @@ enum device_addr_flags { /* neighbor mac address */ DEVNEIGH_MAC = (1 << 11), + + /* advertised mss */ + DEVROUTE_ADVMSS = (1 << 12), }; union if_addr { @@ -98,6 +101,7 @@ struct device_route { unsigned int type; unsigned int proto; time_t valid_until; + unsigned int advmss; /* must be last */ enum device_addr_flags flags; diff --git a/system-linux.c b/system-linux.c index 462a8cc..060c21d 100644 --- a/system-linux.c +++ b/system-linux.c @@ -2828,13 +2828,16 @@ static int system_rt(struct device *dev, struct device_route *route, int cmd) if (table >= 256) nla_put_u32(msg, RTA_TABLE, table); - if (route->flags & DEVROUTE_MTU) { + if (route->flags & (DEVROUTE_MTU | DEVROUTE_ADVMSS)) { struct nlattr *metrics; if (!(metrics = nla_nest_start(msg, RTA_METRICS))) goto nla_put_failure; - nla_put_u32(msg, RTAX_MTU, route->mtu); + if (route->flags & DEVROUTE_MTU) + nla_put_u32(msg, RTAX_MTU, route->mtu); + if (route->flags & DEVROUTE_ADVMSS) + nla_put_u32(msg, RTAX_ADVMSS, route->advmss); nla_nest_end(msg, metrics); } diff --git a/ubus.c b/ubus.c index 3cb5c1a..8f7082d 100644 --- a/ubus.c +++ b/ubus.c @@ -642,6 +642,9 @@ interface_ip_dump_route_list(struct interface_ip_settings *ip, bool enabled) if (route->flags & DEVROUTE_MTU) blobmsg_add_u32(&b, "mtu", route->mtu); + if (route->flags & DEVROUTE_ADVMSS) + blobmsg_add_u32(&b, "advmss", route->advmss); + if (route->flags & DEVROUTE_METRIC) blobmsg_add_u32(&b, "metric", route->metric); @@ -651,6 +654,7 @@ interface_ip_dump_route_list(struct interface_ip_settings *ip, bool enabled) if (route->valid_until) blobmsg_add_u32(&b, "valid", route->valid_until - now); + buf = blobmsg_alloc_string_buffer(&b, "source", buflen); inet_ntop(af, &route->source, buf, buflen); snprintf(buf + strlen(buf), buflen - strlen(buf), "/%u", route->sourcemask);