Skip to content

Commit 7e60995

Browse files
committed
Optionally allow ULA addresses in prepare.sh
1 parent 1ef2800 commit 7e60995

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

hack/prepare.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ set -Eeuo pipefail
1111

1212
OPT_MULTIPORT=false
1313
OPT_SYNC_BRIDGE=false
14+
OPT_ALLOW_ULA=false
1415

1516
BLUEFIELD_IDENTIFIERS=("MT_0000000543" "MT_0000000541")
1617
MAX_NUMVFS_POSSIBLE=126
@@ -307,13 +308,17 @@ function get_ipv6() {
307308
# 1. Have a "global" scope.
308309
# 2. Have a prefix length of 64 or more.
309310
# 3. Must be in Globally Unique Address (GUA) range (2 or 3).
311+
# (unless --allow-ula is set, then also fc and fd range is allowed)
312+
local addr_regex
313+
addr_regex='^(2|3)'
314+
[[ "$OPT_ALLOW_ULA" == "true" ]] && addr_regex='^(2|3|f[cd])'
310315
local global_address
311-
global_address=$(echo "$ip_json" | jq -r '
316+
global_address=$(echo "$ip_json" | jq -r --arg addr_re "$addr_regex" '
312317
.[0].addr_info[]
313318
| select(
314319
.scope == "global" and
315320
.prefixlen >= 64 and
316-
(.local | test("^(2|3)"))
321+
(.local | test($addr_re))
317322
)
318323
| .local' | head -n 1)
319324

@@ -403,6 +408,9 @@ while [[ $# -gt 0 ]]; do
403408
--sync-bridge)
404409
OPT_SYNC_BRIDGE=true
405410
;;
411+
--allow-ula)
412+
OPT_ALLOW_ULA=true
413+
;;
406414
*)
407415
err "Invalid argument $1"
408416
esac

0 commit comments

Comments
 (0)