From 07f8c9f4f1f62b8fd2e6d281edfdb37da17422cd Mon Sep 17 00:00:00 2001 From: Wojciech Kosior Date: Tue, 16 Jun 2020 21:03:10 +0200 Subject: use vpn_id instead of pid for tagging namespaces --- src/hourly.py | 3 ++- src/vpn_wrapper.sh | 8 +++++--- 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 (/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 -- cgit v1.2.3