From patchwork Sat Feb 3 06:11:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ms@missing233.com X-Patchwork-Id: 1894857 X-Patchwork-Delegate: gch981213@gmail.com 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=cRfOP/sV; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=missing233.com header.i=@missing233.com header.a=rsa-sha256 header.s=qjcj2303 header.b=kD5m7Sd/; 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 4TRj613M1qz23gM for ; Sat, 3 Feb 2024 17:14:32 +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=WohAT/2LrCjtAsulWl8VdtJIaPVPnwcOS6hzFtGSmII=; b=cRfOP/sVATRF/A YDwvCFPfoCjI7Xm/RY5wA0yZtX+wFQ05rMa5Z6sU1DbuH3ZccIcZQAFIiCbdwj6JNJ66RUOtbktHw oYDgaFhnQUv9Dw7NVk9HM7d+OX98k7TUjz9GqpTGRElUPKgIukV6RliAd+dy/nuvnTOhQmeFazz6K HJUiezouWPa1WGOxzxIq9zyYgMnFpZG97yITpUYqrngJChAiFt6z09TfrdtBSv/zimENgIs5gWPFP sme24FqaBB1pzkJQULDjh2yPDq15OCSf6GMTYqd9fZin1rdHWZTOrYu4KNTRK7otqljcazf1RTWgG Zckr01xv2p4J5Anuo/bQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rW9Gn-0000000FZEO-3h0U; Sat, 03 Feb 2024 06:12:53 +0000 Received: from bg4.exmail.qq.com ([43.154.221.58]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rW9Gk-0000000FZCc-1vuV for openwrt-devel@lists.openwrt.org; Sat, 03 Feb 2024 06:12:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=missing233.com; s=qjcj2303; t=1706940763; bh=zT0rnjPAQaZVL/85GvawTKO/aTIlKVXalcmml9iBPM0=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=kD5m7Sd/IAdc4kOpmyYIK2NORd7mnWd3K0GE7FJo9RLBSFV+3l3mRo69qj/vpVlv+ AiGcx96/CuJ8dyavd7eVOugFjKxAKOPCtaOtzP1fRCrR2H+RpVtic95BlfsiD3UFlx XL7e20PgOtfkqU3beI4zTc/1z91tiE5t7WZ40LxQ= X-QQ-mid: bizesmtpipv602t1706940759t95q X-QQ-Originating-IP: LXsclQfzMcMUzppjXrZExYEUD/jbr7inxuX/ERNIj3g= Received: from localhost.localdomain ( [255.78.22.9]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 03 Feb 2024 14:12:35 +0800 (CST) X-QQ-SSF: 0100000000000030D000000A0000000 X-QQ-FEAT: ORfRNHy8Hg8Q+K0FXm8WHQBlrbpegLu2eWbURQwmD1vv8pRj9JAVohttVaXDG J7CqqWItjVfuXarfKv/n1KPNCiDVutkQFl0LHe5wOYxv6e6doxmpI9Oj/Dd/HCm5okRPHxB 8oFHdpLB2kU7+FIIrOPcRS028t9tsmM0OvMRJ0MBDxHt6klzPDThEW8+BRGSP0P30TO9tgF a8q4l9CKaUMhieHCNMpZNWQRbRClD4bsua4j0KFH+kQ6QiSwBiH//OlEZVPerjQPLQKCU8x Y8I8Vj0uRZX6P1O2tv4OU1ITfsqeJyyR5SiQMTy68Th8RZ1iEmj69PUBg3B2Mp4NdU7Svm5 vN8FhUrS7llpQH1K2M= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 8355046183441738119 From: ms@missing233.com To: openwrt-devel@lists.openwrt.org Cc: Arayuki Mago Subject: [PATCH 1/2] ipip6: add new package for IPIP6(RFC2473) support Add Generic Packet Tunneling in IPv6 Specification (RFC 2473) support. (For NTT Broadband V6Plus/transix/Xpass Fixed IP) Date: Sat, 3 Feb 2024 15:11:23 +0900 Message-Id: <20240203061123.369-1-ms@missing233.com> X-Mailer: git-send-email 2.40.1.windows.1 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpipv:missing233.com:qybglogicsvrgz:qybglogicsvrgz7a-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240202_221250_869908_E300164E X-CRM114-Status: GOOD ( 14.64 ) X-Spam-Score: 1.1 (+) 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: Arayuki Mago Signed-off-by: Arayuki Mago --- package/network/ipv6/ipip6/Makefile | 44 +++++++++ package/network/ipv6/ipip6/files/ipip6.sh | 106 ++++++++++++++++++++++ 2 files changed, 150 inser [...] Content analysis details: (1.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [43.154.221.58 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 1.3 RCVD_ILLEGAL_IP Received: contains illegal IP address -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [43.154.221.58 listed in wl.mailspike.net] -0.0 T_SCC_BODY_TEXT_LINE No description available. 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: Arayuki Mago Signed-off-by: Arayuki Mago --- package/network/ipv6/ipip6/Makefile | 44 +++++++++ package/network/ipv6/ipip6/files/ipip6.sh | 106 ++++++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 package/network/ipv6/ipip6/Makefile create mode 100644 package/network/ipv6/ipip6/files/ipip6.sh diff --git a/package/network/ipv6/ipip6/Makefile b/package/network/ipv6/ipip6/Makefile new file mode 100644 index 0000000000..034f17e0c0 --- /dev/null +++ b/package/network/ipv6/ipip6/Makefile @@ -0,0 +1,44 @@ +# +# Copyright (C) 2013 OpenWrt.org +# Copyright (C) 2021 kenjiuno +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=ipip6 +PKG_VERSION:=0.1 +PKG_RELEASE:=6 +PKG_LICENSE:=GPL-2.0 +PKG_MAINTAINER:=kenjiuno + +include $(INCLUDE_DIR)/package.mk + +define Package/ipip6 + SECTION:=net + CATEGORY:=Network + DEPENDS:=@IPV6 +kmod-ip6-tunnel +resolveip + TITLE:=IPv4 over IPv6 (RFC2473) configuration support + MAINTAINER:=kenjiuno + PKGARCH:=all +endef + +define Package/ipip6/description +Provides support for IPv4 over IPv6 (RFC2473) in /etc/config/network. +endef + +define Build/Compile +endef + +define Build/Configure +endef + +define Package/ipip6/install + $(INSTALL_DIR) $(1)/lib/netifd/proto + $(INSTALL_BIN) ./files/ipip6.sh $(1)/lib/netifd/proto/ipip6.sh + +endef + +$(eval $(call BuildPackage,ipip6)) diff --git a/package/network/ipv6/ipip6/files/ipip6.sh b/package/network/ipv6/ipip6/files/ipip6.sh new file mode 100644 index 0000000000..ceadf71f67 --- /dev/null +++ b/package/network/ipv6/ipip6/files/ipip6.sh @@ -0,0 +1,106 @@ +#!/bin/sh +# ipip6.sh - ipip6 tunnel(RFC2473) backend +# Copyright (c) 2013 OpenWrt.org +# Copyright (c) 2021 kenjiuno + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . /lib/functions/network.sh + . ../netifd-proto.sh + init_proto "$@" +} + +proto_ipip6_setup() { + local cfg="$1" + local iface="$2" + local link="ipip6-$cfg" + local remoteip6 + + local mtu ttl peeraddr ip6addr tunlink zone weakif encaplimit ip4ifaddr + json_get_vars mtu ttl peeraddr ip6addr tunlink zone weakif encaplimit ip4ifaddr + + [ -z "$peeraddr" ] && { + proto_notify_error "$cfg" "MISSING_ADDRESS" + proto_block_restart "$cfg" + return + } + + ( proto_add_host_dependency "$cfg" "::" "$tunlink" ) + + remoteip6=$(resolveip -6 "$peeraddr") + if [ -z "$remoteip6" ]; then + sleep 3 + remoteip6=$(resolveip -6 "$peeraddr") + if [ -z "$remoteip6" ]; then + proto_notify_error "$cfg" "AFTR_DNS_FAIL" + return + fi + fi + + for ip6 in $remoteip6; do + peeraddr=$ip6 + break + done + + [ -z "$ip6addr" ] && { + local wanif="$tunlink" + if [ -z "$wanif" ] && ! network_find_wan6 wanif; then + proto_notify_error "$cfg" "NO_WAN_LINK" + return + fi + + if ! network_get_ipaddr6 ip6addr "$wanif"; then + [ -z "$weakif" ] && weakif="lan" + if ! network_get_ipaddr6 ip6addr "$weakif"; then + proto_notify_error "$cfg" "NO_WAN_LINK" + return + fi + fi + } + + proto_init_update "$link" 1 + proto_add_ipv4_route "0.0.0.0" 0 + proto_add_ipv4_address "$ip4ifaddr" "" "" "0.0.0.0" + + proto_add_tunnel + json_add_string mode ipip6 + json_add_int mtu "${mtu:-1280}" + json_add_int ttl "${ttl:-64}" + json_add_string local "$ip6addr" + json_add_string remote "$peeraddr" + [ -n "$tunlink" ] && json_add_string link "$tunlink" + json_add_object "data" + [ -n "$encaplimit" ] && json_add_string encaplimit "$encaplimit" + json_close_object + proto_close_tunnel + + proto_add_data + [ -n "$zone" ] && json_add_string zone "$zone" + + proto_close_data + + proto_send_update "$cfg" +} + +proto_ipip6_teardown() { + local cfg="$1" +} + +proto_ipip6_init_config() { + no_device=1 + available=1 + + proto_config_add_string "ip6addr" + proto_config_add_string "peeraddr" + proto_config_add_string "tunlink" + proto_config_add_int "mtu" + proto_config_add_int "ttl" + proto_config_add_string "encaplimit" + proto_config_add_string "zone" + proto_config_add_string "weakif" + proto_config_add_string "ip4ifaddr" +} + +[ -n "$INCLUDE_ONLY" ] || { + add_protocol ipip6 +} From patchwork Sat Feb 3 06:13:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ms@missing233.com X-Patchwork-Id: 1894858 X-Patchwork-Delegate: gch981213@gmail.com 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=yDkaAs8k; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=missing233.com header.i=@missing233.com header.a=rsa-sha256 header.s=qjcj2303 header.b=EtEYTwWD; 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 4TRj6167dQz23gY for ; Sat, 3 Feb 2024 17:14:33 +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=kIPPXEYZ5K1e5+7dt/8I7IAW2FO4PIV0Yr1g7u3QPXg=; b=yDkaAs8kVr00kM mSESsFBbNkfoswdOO6LZkNCLkS55BIOlVBkMkAa5SM84haFcdkoGjV1qxBma4juIdQF2saiMK7Lmv 2Mvnan039XZ6ioALxwOsWUrVoFq+B9soZVLbbkBPGOq8ajjLl+HQExAef1KriIKSJND+gfXilE8Ml mQSXrr+WgUWvR6MDSLLJVlfdqW8nEf11+qdBbSYrq0Bf5/AyjEocwwUz0aWlBM1X7pf2YfrzaAxF3 LCl9saNNR1QFXbFNDB2OjIwJ/cXM8FEqMjiTffvHeYaQvbdgQTnsWNJW+9RR/JawHTwqmvCuCfa6U cCtuxoxYhIubeG3mDuOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rW9HR-0000000FZOE-1B4h; Sat, 03 Feb 2024 06:13:33 +0000 Received: from bg4.exmail.qq.com ([43.154.221.58]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rW9HN-0000000FZMI-0zmq for openwrt-devel@lists.openwrt.org; Sat, 03 Feb 2024 06:13:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=missing233.com; s=qjcj2303; t=1706940806; bh=69RL0ixCWNEbjJ7C5nHcJwvZb8Zk/A3gG57ZJ8COKCc=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=EtEYTwWDgLvFbsCWrlGkphgCFI7KflJn4LEbRMUlR0E04oWUyQ6DFPwgGhlDgJ/sr q7gIa9r1IDYDqU4RNnaZr01gxwnE2fmjWR149w4GHtBnksQG+joyyAiQ1HHdma+nng 5IaybwWwcw05X5ki3zn8WulbLvxhwGWDRfyvDCx0= X-QQ-mid: bizesmtpipv603t1706940803trke X-QQ-Originating-IP: DyKPNE1a1sLLOjQhUQ2CFUbEPUWdYOdVHE5YgEiTR78= Received: from localhost.localdomain ( [255.78.22.9]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 03 Feb 2024 14:13:19 +0800 (CST) X-QQ-SSF: 0100000000000030D000000A0000000 X-QQ-FEAT: FIcCx1gKdjZOa4mcLpGn5gmyC4qM/2s0L82mGYpRLGW6ZtjJWLBK9B+8RMfXi Eiu5QjLFGKV0y7RtfQjXJ8ayWhcRH6/wnkrpORv8SV6+C74e2/fQ7R/nicXr10kRSArh7a3 S2pK4Pf71UFW2L7+A3Oqys+pfHu3K4OWQVPgN33QpFutqUvqF3H3MvP6LWjagd9zSeGaQeW s/xRcNE8rqOFOVw2fmuhmmsdcDTw2Ae3rLkVVoyhF1iwal2wizwlC/aVFVeooUhXiANfjSq QnnfDbkDc8Cn56QWZ2oEQ/yHB2Ly07+kEDVXciVjHbOVQ4eTNDMo6MZnmELODRITryMTqt/ 9KVyv197JygH9eS22EU2U8qg8iEIbWuuUGxLhZtjNoHcmqWZNE= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 17036486764650813210 From: ms@missing233.com To: openwrt-devel@lists.openwrt.org Cc: Arayuki Mago Subject: [PATCH 2/2] ipip6/ds-lite: Integrate ds-lite and ipip6 ds-lite and ipip6 now use the same backend ipip6.sh Date: Sat, 3 Feb 2024 15:13:00 +0900 Message-Id: <20240203061300.533-1-ms@missing233.com> X-Mailer: git-send-email 2.40.1.windows.1 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpipv:missing233.com:qybglogicsvrgz:qybglogicsvrgz7a-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240202_221329_659407_73FDBE1A X-CRM114-Status: GOOD ( 12.39 ) X-Spam-Score: 1.1 (+) 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: Arayuki Mago Signed-off-by: Arayuki Mago --- package/network/ipv6/ds-lite/Makefile | 2 +- .../ds-lite/files/{dslite.sh => ipip6.sh} | 72 +++++++++++++------ package/network/ipv6/ipip6/Makefile [...] Content analysis details: (1.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [43.154.221.58 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [43.154.221.58 listed in wl.mailspike.net] 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 1.3 RCVD_ILLEGAL_IP Received: contains illegal IP address -0.0 T_SCC_BODY_TEXT_LINE No description available. 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: Arayuki Mago Signed-off-by: Arayuki Mago --- package/network/ipv6/ds-lite/Makefile | 2 +- .../ds-lite/files/{dslite.sh => ipip6.sh} | 72 +++++++++++++------ package/network/ipv6/ipip6/Makefile | 13 ++-- package/network/ipv6/ipip6/files/ipip6.sh | 68 +++++++++++++----- 4 files changed, 109 insertions(+), 46 deletions(-) rename package/network/ipv6/ds-lite/files/{dslite.sh => ipip6.sh} (67%) diff --git a/package/network/ipv6/ds-lite/Makefile b/package/network/ipv6/ds-lite/Makefile index 502da366a9..a6ea315c88 100644 --- a/package/network/ipv6/ds-lite/Makefile +++ b/package/network/ipv6/ds-lite/Makefile @@ -36,7 +36,7 @@ endef define Package/ds-lite/install $(INSTALL_DIR) $(1)/lib/netifd/proto - $(INSTALL_BIN) ./files/dslite.sh $(1)/lib/netifd/proto/dslite.sh + $(INSTALL_BIN) ./files/ipip6.sh $(1)/lib/netifd/proto/ipip6.sh endef $(eval $(call BuildPackage,ds-lite)) diff --git a/package/network/ipv6/ds-lite/files/dslite.sh b/package/network/ipv6/ds-lite/files/ipip6.sh similarity index 67% rename from package/network/ipv6/ds-lite/files/dslite.sh rename to package/network/ipv6/ds-lite/files/ipip6.sh index 017963926d..5c2755df76 100644 --- a/package/network/ipv6/ds-lite/files/dslite.sh +++ b/package/network/ipv6/ds-lite/files/ipip6.sh @@ -1,5 +1,5 @@ #!/bin/sh -# dslite.sh - IPv4-in-IPv6 tunnel backend +# ipip6.sh - IPv4-in-IPv6 tunnel backend for ipip6 and ds-lite # Copyright (c) 2013 OpenWrt.org [ -n "$INCLUDE_ONLY" ] || { @@ -9,10 +9,13 @@ init_proto "$@" } -proto_dslite_setup() { +tnl_setup() { local cfg="$1" local iface="$2" - local link="ds-$cfg" + local tnl_type="$3" + local ip4addr="$4" + local ip4gateway="$5" + local link="$tnl_type-$cfg" local remoteip6 local mtu ttl peeraddr ip6addr tunlink zone weakif encaplimit @@ -24,7 +27,7 @@ proto_dslite_setup() { return } - ( proto_add_host_dependency "$cfg" "::" "$tunlink" ) + proto_add_host_dependency "$cfg" "::" "$tunlink" remoteip6=$(resolveip -6 "$peeraddr") if [ -z "$remoteip6" ]; then @@ -36,10 +39,7 @@ proto_dslite_setup() { fi fi - for ip6 in $remoteip6; do - peeraddr=$ip6 - break - done + peeraddr=$(echo "$remoteip6" | head -n 1) [ -z "$ip6addr" ] && { local wanif="$tunlink" @@ -59,7 +59,7 @@ proto_dslite_setup() { proto_init_update "$link" 1 proto_add_ipv4_route "0.0.0.0" 0 - proto_add_ipv4_address "192.0.0.2" "" "" "192.0.0.1" + proto_add_ipv4_address "$ip4addr" "" "" "$ip4gateway" proto_add_tunnel json_add_string mode ipip6 @@ -76,23 +76,22 @@ proto_dslite_setup() { proto_add_data [ -n "$zone" ] && json_add_string zone "$zone" - json_add_array firewall - json_add_object "" - json_add_string type nat - json_add_string target ACCEPT - json_close_object - json_close_array + if [ "$tnl_type" = "ds" ]; then + json_add_array firewall + json_add_object "" + json_add_string type nat + json_add_string target ACCEPT + json_close_object + json_close_array + fi + proto_close_data proto_send_update "$cfg" } -proto_dslite_teardown() { - local cfg="$1" -} - -proto_dslite_init_config() { - no_device=1 +init_config() { + no_device=1 available=1 proto_config_add_string "ip6addr" @@ -105,6 +104,35 @@ proto_dslite_init_config() { proto_config_add_string "weakif" } +proto_ipip6_init_config() { + init_config + proto_config_add_string "ip4ifaddr" +} + +proto_ipip6_setup() { + local ip4ifaddr + json_get_vars ip4ifaddr + tnl_setup "$1" "$2" "ipip6" "$ip4ifaddr" "0.0.0.0" +} + +proto_ipip6_teardown() { + local cfg="$1" +} + +proto_dslite_init_config() { + init_config +} + +proto_dslite_setup() { + tnl_setup "$1" "$2" "ds" "192.0.0.2" "192.0.0.1" +} + +proto_dslite_teardown() { + local cfg="$1" +} + [ -n "$INCLUDE_ONLY" ] || { - add_protocol dslite + + add_protocol ipip6; + add_protocol dslite; } diff --git a/package/network/ipv6/ipip6/Makefile b/package/network/ipv6/ipip6/Makefile index 034f17e0c0..32d16181b0 100644 --- a/package/network/ipv6/ipip6/Makefile +++ b/package/network/ipv6/ipip6/Makefile @@ -1,6 +1,7 @@ # # Copyright (C) 2013 OpenWrt.org -# Copyright (C) 2021 kenjiuno +# +# Original Maintainers: Steven Barth , kenjiuno # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -9,10 +10,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ipip6 -PKG_VERSION:=0.1 PKG_RELEASE:=6 PKG_LICENSE:=GPL-2.0 -PKG_MAINTAINER:=kenjiuno include $(INCLUDE_DIR)/package.mk @@ -20,13 +19,15 @@ define Package/ipip6 SECTION:=net CATEGORY:=Network DEPENDS:=@IPV6 +kmod-ip6-tunnel +resolveip - TITLE:=IPv4 over IPv6 (RFC2473) configuration support - MAINTAINER:=kenjiuno + TITLE:=IPv4 over IPv6 (RFC2473/DS-Lite) configuration support + MAINTAINER:=missing233 PKGARCH:=all endef define Package/ipip6/description -Provides support for IPv4 over IPv6 (RFC2473) in /etc/config/network. +Provides support for IPv4 over IPv6 (RFC2473/DS-Lite) in /etc/config/network. +Refer to http://wiki.openwrt.org/doc/uci/network for +configuration details. endef define Build/Compile diff --git a/package/network/ipv6/ipip6/files/ipip6.sh b/package/network/ipv6/ipip6/files/ipip6.sh index ceadf71f67..1fcf21adf5 100644 --- a/package/network/ipv6/ipip6/files/ipip6.sh +++ b/package/network/ipv6/ipip6/files/ipip6.sh @@ -1,7 +1,8 @@ #!/bin/sh -# ipip6.sh - ipip6 tunnel(RFC2473) backend +# ipip6.sh - IPv4-in-IPv6 tunnel backend for ipip6 and ds-lite # Copyright (c) 2013 OpenWrt.org # Copyright (c) 2021 kenjiuno +# Copyright (c) 2024 missing233 [ -n "$INCLUDE_ONLY" ] || { . /lib/functions.sh @@ -10,14 +11,17 @@ init_proto "$@" } -proto_ipip6_setup() { +tnl_setup() { local cfg="$1" local iface="$2" - local link="ipip6-$cfg" + local tnl_type="$3" + local ip4addr="$4" + local ip4gateway="$5" + local link="$tnl_type-$cfg" local remoteip6 - local mtu ttl peeraddr ip6addr tunlink zone weakif encaplimit ip4ifaddr - json_get_vars mtu ttl peeraddr ip6addr tunlink zone weakif encaplimit ip4ifaddr + local mtu ttl peeraddr ip6addr tunlink zone weakif encaplimit + json_get_vars mtu ttl peeraddr ip6addr tunlink zone weakif encaplimit [ -z "$peeraddr" ] && { proto_notify_error "$cfg" "MISSING_ADDRESS" @@ -25,7 +29,7 @@ proto_ipip6_setup() { return } - ( proto_add_host_dependency "$cfg" "::" "$tunlink" ) + proto_add_host_dependency "$cfg" "::" "$tunlink" remoteip6=$(resolveip -6 "$peeraddr") if [ -z "$remoteip6" ]; then @@ -37,10 +41,7 @@ proto_ipip6_setup() { fi fi - for ip6 in $remoteip6; do - peeraddr=$ip6 - break - done + peeraddr=$(echo "$remoteip6" | head -n 1) [ -z "$ip6addr" ] && { local wanif="$tunlink" @@ -60,7 +61,7 @@ proto_ipip6_setup() { proto_init_update "$link" 1 proto_add_ipv4_route "0.0.0.0" 0 - proto_add_ipv4_address "$ip4ifaddr" "" "" "0.0.0.0" + proto_add_ipv4_address "$ip4addr" "" "" "$ip4gateway" proto_add_tunnel json_add_string mode ipip6 @@ -77,16 +78,21 @@ proto_ipip6_setup() { proto_add_data [ -n "$zone" ] && json_add_string zone "$zone" + if [ "$tnl_type" = "ds" ]; then + json_add_array firewall + json_add_object "" + json_add_string type nat + json_add_string target ACCEPT + json_close_object + json_close_array + fi + proto_close_data proto_send_update "$cfg" } -proto_ipip6_teardown() { - local cfg="$1" -} - -proto_ipip6_init_config() { +init_config() { no_device=1 available=1 @@ -98,9 +104,37 @@ proto_ipip6_init_config() { proto_config_add_string "encaplimit" proto_config_add_string "zone" proto_config_add_string "weakif" +} + +proto_ipip6_init_config() { + init_config proto_config_add_string "ip4ifaddr" } +proto_ipip6_setup() { + local ip4ifaddr + json_get_vars ip4ifaddr + tnl_setup "$1" "$2" "ipip6" "$ip4ifaddr" "0.0.0.0" +} + +proto_ipip6_teardown() { + local cfg="$1" +} + +proto_dslite_init_config() { + init_config +} + +proto_dslite_setup() { + tnl_setup "$1" "$2" "ds" "192.0.0.2" "192.0.0.1" +} + +proto_dslite_teardown() { + local cfg="$1" +} + [ -n "$INCLUDE_ONLY" ] || { - add_protocol ipip6 + + add_protocol ipip6; + add_protocol dslite; }