Skip to content

Commit c8d9b90

Browse files
committed
testenv: fix the --legacy-ip option implementation
The implementation of the '--legacy-ip' option was broken in two places. First, the 'ip route' program was called to add a IPv4 route with a network prefix ending with the IPv6 '::' notation. Second, the 'get_num' function returns the number of a test environment in hex, and this return value is used when defining IPv6 and/or IPv4 network prefixes. In the IPv4 case we need to convert it to decimal, or some prefixes, starting from the tenth test environment, e.g., '10.11.a' or '10.11.b', will be incorrect. Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
1 parent cab4d29 commit c8d9b90

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

testenv/testenv.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ setup()
196196
local NUM=$(get_num "$NS")
197197
local PEERNAME="testl-ve-$NUM"
198198
[ -z "$IP6_PREFIX" ] && IP6_PREFIX="${IP6_SUBNET}:${NUM}::"
199-
[ -z "$IP4_PREFIX" ] && IP4_PREFIX="${IP4_SUBNET}.${NUM}."
199+
[ -z "$IP4_PREFIX" ] && IP4_PREFIX="${IP4_SUBNET}.$((0x$NUM))."
200200

201201
INSIDE_IP6="${IP6_PREFIX}2"
202202
INSIDE_IP4="${IP4_PREFIX}2"
@@ -240,7 +240,7 @@ setup()
240240
ip -n "$NS" addr add dev veth0 "${INSIDE_IP4}/${IP4_PREFIX_SIZE}"
241241
ip neigh add "$INSIDE_IP4" lladdr "$INSIDE_MAC" dev "$NS" nud permanent
242242
ip -n "$NS" neigh add "$OUTSIDE_IP4" lladdr "$OUTSIDE_MAC" dev veth0 nud permanent
243-
ip -n "$NS" route add "${IP4_SUBNET}::/$IP4_FULL_PREFIX_SIZE" via "$OUTSIDE_IP4" dev veth0
243+
ip -n "$NS" route add "${IP4_SUBNET}/${IP4_FULL_PREFIX_SIZE}" via "$OUTSIDE_IP4" dev veth0
244244
ENABLE_IPV4=1
245245
else
246246
ENABLE_IPV4=0

0 commit comments

Comments
 (0)