aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2023-01-18 10:02:50 +0100
committert3sserakt <t3ss@posteo.de>2023-01-18 10:02:50 +0100
commit4aec035eadd8f9d642c24c88ec97a2b9dcee4995 (patch)
treeee758ad9b07656cb49bdcdd28391eb92fa08531a
parentc524f91a6250a2b22da30cd7efbec817c2d8568d (diff)
downloadgnunet-4aec035eadd8f9d642c24c88ec97a2b9dcee4995.tar.gz
gnunet-4aec035eadd8f9d642c24c88ec97a2b9dcee4995.zip
TNG: Changed the format of the interface names to make miniupnpd happy.
-rwxr-xr-xcontrib/netjail/netjail_core.sh19
-rw-r--r--src/testing/testing_api_cmd_netjail_start_cmds_helper.c3
2 files changed, 12 insertions, 10 deletions
diff --git a/contrib/netjail/netjail_core.sh b/contrib/netjail/netjail_core.sh
index 8c1744853..302ae922f 100755
--- a/contrib/netjail/netjail_core.sh
+++ b/contrib/netjail/netjail_core.sh
@@ -1,7 +1,8 @@
1#!/bin/bash 1#!/bin/bash
2# 2#
3 3
4 4INTERFACE_FORMAT_STRING="%s%06x-%06x"
5PREPREFIX=if
5PREFIX=${PPID:?must run from a parent process} 6PREFIX=${PPID:?must run from a parent process}
6 7
7# running with `sudo` is required to be 8# running with `sudo` is required to be
@@ -93,7 +94,7 @@ netjail_check_bin() {
93netjail_bridge() { 94netjail_bridge() {
94 netjail_next_interface 95 netjail_next_interface
95 local NUM=$RESULT 96 local NUM=$RESULT
96 local BRIDGE=$(printf "%06x-%08x" $PREFIX $NUM) 97 local BRIDGE=$(printf $INTERFACE_FORMAT_STRING $PREPREFIX $PREFIX $NUM)
97 98
98 ip link add $BRIDGE type bridge 99 ip link add $BRIDGE type bridge
99 ip link set dev $BRIDGE up 100 ip link set dev $BRIDGE up
@@ -104,7 +105,7 @@ netjail_bridge() {
104netjail_bridge_name() { 105netjail_bridge_name() {
105 netjail_next_interface 106 netjail_next_interface
106 local NUM=$RESULT 107 local NUM=$RESULT
107 local BRIDGE=$(printf "%06x-%08x" $PREFIX $NUM) 108 local BRIDGE=$(printf $INTERFACE_FORMAT_STRING $PREPREFIX $PREFIX $NUM)
108 109
109 RESULT=$BRIDGE 110 RESULT=$BRIDGE
110} 111}
@@ -118,7 +119,7 @@ netjail_bridge_clear() {
118netjail_node() { 119netjail_node() {
119 netjail_next_namespace 120 netjail_next_namespace
120 local NUM=$RESULT 121 local NUM=$RESULT
121 local NODE=$(printf "%06x-%08x" $PREFIX $NUM) 122 local NODE=$(printf $INTERFACE_FORMAT_STRING $PREPREFIX $PREFIX $NUM)
122 123
123 ip netns add $NODE 124 ip netns add $NODE
124 125
@@ -128,7 +129,7 @@ netjail_node() {
128netjail_node_name() { 129netjail_node_name() {
129 netjail_next_namespace 130 netjail_next_namespace
130 local NUM=$RESULT 131 local NUM=$RESULT
131 local NODE=$(printf "%06x-%08x" $PREFIX $NUM) 132 local NODE=$(printf $INTERFACE_FORMAT_STRING $PREPREFIX $PREFIX $NUM)
132 133
133 RESULT=$NODE 134 RESULT=$NODE
134} 135}
@@ -150,8 +151,8 @@ netjail_node_link_bridge() {
150 netjail_next_interface 151 netjail_next_interface
151 local NUM_BR=$RESULT 152 local NUM_BR=$RESULT
152 153
153 local LINK_IF=$(printf "%06x-%08x" $PREFIX $NUM_IF) 154 local LINK_IF=$(printf $INTERFACE_FORMAT_STRING $PREPREFIX $PREFIX $NUM_IF)
154 local LINK_BR=$(printf "%06x-%08x" $PREFIX $NUM_BR) 155 local LINK_BR=$(printf $INTERFACE_FORMAT_STRING $PREPREFIX $PREFIX $NUM_BR)
155 156
156 ip link add $LINK_IF type veth peer name $LINK_BR 157 ip link add $LINK_IF type veth peer name $LINK_BR
157 ip link set $LINK_IF netns $NODE 158 ip link set $LINK_IF netns $NODE
@@ -172,7 +173,7 @@ netjail_node_link_bridge_name() {
172 netjail_next_interface 173 netjail_next_interface
173 local NUM_BR=$RESULT 174 local NUM_BR=$RESULT
174 175
175 local LINK_BR=$(printf "%06x-%08x" $PREFIX $NUM_BR) 176 local LINK_BR=$(printf $INTERFACE_FORMAT_STRING $PREPREFIX $PREFIX $NUM_BR)
176 177
177 RESULT=$LINK_BR 178 RESULT=$LINK_BR
178} 179}
@@ -192,7 +193,7 @@ netjail_node_add_nat() {
192 ip netns exec $NODE nft add table nat 193 ip netns exec $NODE nft add table nat
193 ip netns exec $NODE nft add chain nat postrouting { type nat hook postrouting priority 0 \; } 194 ip netns exec $NODE nft add chain nat postrouting { type nat hook postrouting priority 0 \; }
194 ip netns exec $NODE nft add rule ip nat postrouting ip saddr "$ADDRESS/$MASK" counter masquerade 195 ip netns exec $NODE nft add rule ip nat postrouting ip saddr "$ADDRESS/$MASK" counter masquerade
195 # ip netns exec $NODE iptables -t nat -A POSTROUTING -s "$ADDRESS/$MASK" -j MASQUERADE 196 # ip netns exec $NODE iptables -t nat -A POSTROUTING -s "$ADDRESS/$MASK" -j MASQUERADE
196} 197}
197 198
198netjail_node_add_default() { 199netjail_node_add_default() {
diff --git a/src/testing/testing_api_cmd_netjail_start_cmds_helper.c b/src/testing/testing_api_cmd_netjail_start_cmds_helper.c
index c0f238530..545b89b33 100644
--- a/src/testing/testing_api_cmd_netjail_start_cmds_helper.c
+++ b/src/testing/testing_api_cmd_netjail_start_cmds_helper.c
@@ -612,7 +612,8 @@ start_helper (struct NetJailState *ns,
612 GNUNET_asprintf (&local_m_char, "%u", ns->local_m); 612 GNUNET_asprintf (&local_m_char, "%u", ns->local_m);
613 GNUNET_asprintf (&global_n_char, "%u",ns->global_n); 613 GNUNET_asprintf (&global_n_char, "%u",ns->global_n);
614 GNUNET_asprintf (&known_char, "%u",ns->known); 614 GNUNET_asprintf (&known_char, "%u",ns->known);
615 GNUNET_asprintf (&node_id, "%06x-%08x\n", 615 GNUNET_asprintf (&node_id, "%s%06x-%06x\n",
616 "if",
616 pid, 617 pid,
617 script_num); 618 script_num);
618 // GNUNET_asprintf (&topology_data, "'%s'", ns->topology_data); 619 // GNUNET_asprintf (&topology_data, "'%s'", ns->topology_data);