wireguard: Add support for ip6prefix config option

This makes it easier to distribute prefixes over a wireguard tunnel
interface, by simply setting the ip6prefix option in uci (just like with
other protocols).

Obviously, routing etc needs to be setup properly for things to work; this
just adds the config option so the prefix can be assigned to other
interfaces.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
This commit is contained in:
Toke Høiland-Jørgensen 2018-05-13 20:15:50 +02:00 committed by John Crispin
parent 4424a9ff20
commit 50913b77e4

View file

@ -113,6 +113,7 @@ proto_wireguard_setup() {
config_get addresses "${config}" "addresses" config_get addresses "${config}" "addresses"
config_get mtu "${config}" "mtu" config_get mtu "${config}" "mtu"
config_get fwmark "${config}" "fwmark" config_get fwmark "${config}" "fwmark"
config_get ip6prefix "${config}" "ip6prefix"
# create interface # create interface
ip link del dev "${config}" 2>/dev/null ip link del dev "${config}" 2>/dev/null
@ -169,6 +170,11 @@ proto_wireguard_setup() {
esac esac
done done
# support ip6 prefixes
for prefix in ${ip6prefix}; do
proto_add_ipv6_prefix "$prefix"
done
# endpoint dependency # endpoint dependency
wg show "${config}" endpoints | \ wg show "${config}" endpoints | \
sed -E 's/\[?([0-9.:a-f]+)\]?:([0-9]+)/\1 \2/' | \ sed -E 's/\[?([0-9.:a-f]+)\]?:([0-9]+)/\1 \2/' | \