Skip to content

Commit

Permalink
Allow prefix length in IPv6 alias address
Browse files Browse the repository at this point in the history
`jail(8)` manual page states that the `ip6.addr` parameter supports
the format `interface|ip-address/prefix param ...`.  Same approach to
the problem as the previous commit, with slightly different terminology.

Part of bsdpot#268
  • Loading branch information
tnalpgge committed Nov 5, 2023
1 parent 193c41d commit ce9bdfb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion share/pot/network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ _get_alias_ipv4()
# $2 ipaddr
_get_alias_ipv6()
{
local _i _ip _nic _output
local _i _ip _nic _output _pfxlen
_output=
if [ "$( _get_pot_network_stack "$1" )" != "ipv4" ]; then
for _i in $2 ; do
Expand All @@ -254,12 +254,21 @@ _get_alias_ipv6()
_nic="$POT_EXTIF"
_ip="$_i"
fi
if echo "$_ip" | grep -qF '/' ; then
_pfxlen="$(echo "$_ip" | cut -f 2 -d '/' )"
_ip="$(echo "$_ip" | cut -f 1 -d '/' )"
else
_pfxlen=""
fi
if potnet ip6check -H "$_ip" 2> /dev/null ; then
if [ -z "$_output" ]; then
_output="$_nic|$_ip"
else
_output="$_output,$_nic|$_ip"
fi
if [ -n "$_pfxlen" ]; then
_output="$_output/$_pfxlen"
fi
fi
done
fi
Expand Down

0 comments on commit ce9bdfb

Please sign in to comment.