commit
754e652061
3 changed files with 41 additions and 17 deletions
|
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||||
include $(INCLUDE_DIR)/kernel.mk
|
include $(INCLUDE_DIR)/kernel.mk
|
||||||
|
|
||||||
PKG_NAME:=nat46
|
PKG_NAME:=nat46
|
||||||
PKG_VERSION:=9
|
PKG_VERSION:=10
|
||||||
PKG_RELEASE:=$(PKG_SOURCE_VERSION)
|
PKG_RELEASE:=$(PKG_SOURCE_VERSION)
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||||
|
@ -33,7 +33,7 @@ endef
|
||||||
define Package/464xlat
|
define Package/464xlat
|
||||||
SECTION:=net
|
SECTION:=net
|
||||||
CATEGORY:=Network
|
CATEGORY:=Network
|
||||||
DEPENDS:=+kmod-nat46
|
DEPENDS:=+kmod-nat46 +ip
|
||||||
TITLE:=464xlat CLAT support
|
TITLE:=464xlat CLAT support
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,11 @@ proto_464xlat_setup() {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ip -6 rule del from all lookup local
|
||||||
|
ip -6 rule add from all lookup local pref 1
|
||||||
|
ip -6 rule add to $ip6addr lookup prelocal pref 0
|
||||||
|
echo "$ip6addr" > /tmp/464-$cfg-anycast
|
||||||
|
|
||||||
proto_init_update "$link" 1
|
proto_init_update "$link" 1
|
||||||
proto_add_ipv4_route "0.0.0.0" 0 "" "" 2048
|
proto_add_ipv4_route "0.0.0.0" 0 "" "" 2048
|
||||||
proto_add_ipv6_route $ip6addr 128 "" "" "" "" 128
|
proto_add_ipv6_route $ip6addr 128 "" "" "" "" 128
|
||||||
|
@ -74,7 +79,20 @@ proto_464xlat_setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
proto_464xlat_teardown() {
|
proto_464xlat_teardown() {
|
||||||
464xlatcfg "464-$1"
|
local cfg="$1"
|
||||||
|
local link="464-$cfg"
|
||||||
|
local ip6addr=$(cat /tmp/464-$cfg-anycast)
|
||||||
|
local anycast_active
|
||||||
|
|
||||||
|
464xlatcfg "$link"
|
||||||
|
|
||||||
|
rm -rf /tmp/464-$cfg-anycast
|
||||||
|
ip -6 rule del to $ip6addr lookup prelocal
|
||||||
|
|
||||||
|
if [ -z "$(ls /tmp/464-*-anycast 2>&-)" ]; then
|
||||||
|
ip -6 rule del from all lookup local
|
||||||
|
ip -6 rule add from all lookup local pref 0
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
proto_464xlat_init_config() {
|
proto_464xlat_init_config() {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* 464xlatcfg.c
|
/* 464xlatcfg.c
|
||||||
*
|
*
|
||||||
* Copyright (c) 2015 Steven Barth <cyrus@openwrt.org>
|
* Copyright (c) 2015 Steven Barth <cyrus@openwrt.org>
|
||||||
|
* Copyright (c) 2017 Hans Dedecker <dedeckeh@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2
|
* it under the terms of the GNU General Public License version 2
|
||||||
|
@ -40,8 +41,9 @@ int main(int argc, const char *argv[])
|
||||||
snprintf(buf, sizeof(buf), "/var/run/%s.pid", argv[1]);
|
snprintf(buf, sizeof(buf), "/var/run/%s.pid", argv[1]);
|
||||||
FILE *fp = fopen(buf, "r");
|
FILE *fp = fopen(buf, "r");
|
||||||
if (fp) {
|
if (fp) {
|
||||||
fscanf(fp, "%d", &pid);
|
if (fscanf(fp, "%d", &pid) == 1)
|
||||||
kill(pid, SIGTERM);
|
kill(pid, SIGTERM);
|
||||||
|
|
||||||
unlink(buf);
|
unlink(buf);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
@ -52,7 +54,9 @@ int main(int argc, const char *argv[])
|
||||||
if (!argv[3] || !argv[4] || !(fp = fopen(buf, "wx")))
|
if (!argv[3] || !argv[4] || !(fp = fopen(buf, "wx")))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
signal(SIGTERM, sighandler);
|
signal(SIGTERM, SIG_DFL);
|
||||||
|
setvbuf(fp, NULL, _IOLBF, 0);
|
||||||
|
fprintf(fp, "%d\n", getpid());
|
||||||
|
|
||||||
prefix[sizeof(prefix) - 1] = 0;
|
prefix[sizeof(prefix) - 1] = 0;
|
||||||
strncpy(prefix, argv[3], sizeof(prefix) - 1);
|
strncpy(prefix, argv[3], sizeof(prefix) - 1);
|
||||||
|
@ -133,6 +137,7 @@ int main(int argc, const char *argv[])
|
||||||
fclose(stderr);
|
fclose(stderr);
|
||||||
chdir("/");
|
chdir("/");
|
||||||
setsid();
|
setsid();
|
||||||
|
signal(SIGTERM, sighandler);
|
||||||
pause();
|
pause();
|
||||||
|
|
||||||
nat46 = fopen("/proc/net/nat46/control", "w");
|
nat46 = fopen("/proc/net/nat46/control", "w");
|
||||||
|
@ -141,6 +146,7 @@ int main(int argc, const char *argv[])
|
||||||
fclose(nat46);
|
fclose(nat46);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
rewind(fp);
|
||||||
fprintf(fp, "%d\n", pid);
|
fprintf(fp, "%d\n", pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue