aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojciech Kosior <kwojtus@protonmail.com>2020-06-16 21:03:10 +0200
committerWojciech Kosior <kwojtus@protonmail.com>2020-06-16 21:03:10 +0200
commit07f8c9f4f1f62b8fd2e6d281edfdb37da17422cd (patch)
treee5bee67be8cf6c05e3e153f039a2300c3989730f
parent5029d161a6b1243b4c1fe80997e7a218b567bcc1 (diff)
download0tdns-07f8c9f4f1f62b8fd2e6d281edfdb37da17422cd.tar.gz
0tdns-07f8c9f4f1f62b8fd2e6d281edfdb37da17422cd.zip
use vpn_id instead of pid for tagging namespaces
-rwxr-xr-xsrc/hourly.py3
-rwxr-xr-xsrc/vpn_wrapper.sh8
2 files changed, 7 insertions, 4 deletions
diff --git a/src/hourly.py b/src/hourly.py
index 7af7fd9..1bd01b7 100755
--- a/src/hourly.py
+++ b/src/hourly.py
@@ -213,8 +213,9 @@ def do_hourly_work(hour, logfile):
command_in_namespace = [perform_queries, hour, str(vpn_id)]
logfile.write("Running connection for vpn {}\n".format(vpn_id))
+ # see into vpn_wrapper.sh for explaination of its arguments
p = subprocess.Popen([wrapper, config_path, physical_ip, veth_addr1,
- veth_addr2, route_through_veth] +
+ veth_addr2, route_through_veth, str(vpn_id)] +
command_in_namespace)
pids_wrappers[p.pid] = (vpn_id, subnet, p)
diff --git a/src/vpn_wrapper.sh b/src/vpn_wrapper.sh
index 2dbb821..2368839 100755
--- a/src/vpn_wrapper.sh
+++ b/src/vpn_wrapper.sh
@@ -19,15 +19,17 @@ VETH_HOST1="$4"
# caller specifies space-delimited subnets, traffic to which should not be
# routed through the vpn (<database_ip>/32 is going to be here)
ROUTE_THROUGH_VETH="$5"
+# we use a unique id provided in 6th argument to tag namespace name
+ID="$6"
# rest of args is the command to run in network namespace
-for _ in `seq 5`; do
+for _ in `seq 6`; do
shift
done
# to enable multiple instances of this script to run simultaneously,
-# we tag namespace name with this shell's PID
-NAMESPACE_NAME=0tdns$$
+# we tag namespace name
+NAMESPACE_NAME=0tdns$ID
NETNS_SCRIPT=/var/lib/0tdns/netns-script
# in case we want some process in the namespace to be able