In order to set up routing exclusions properly, we now ask for routes without
specified prefixlen and later add it manually before calling `ip route add`.
Older versions of `ip` silently ignored the prefixlen -- as confirmed in:
https://www.spinics.net/lists/netdev/msg570803.html.
Reproduction:
$ ip route get 1.2.0.0/24
Error: ipv4: Invalid values in header for route get request.
Signed-off-by: Rafał Florczak <rafal.florczak@nokia.com>
if [ -n "$IPROUTE" ]; then
fix_ip_get_output () {
sed -e 's/ /\n/g' | \
- sed -ne '1p;/via/{N;p};/dev/{N;p};/src/{N;p};/mtu/{N;p}'
+ sed -ne '1p;/via/{N;p};/dev/{N;p};/src/{N;p};/mtu/{N;p}' | \
+ sed -e "1 s|$|${1}|"
}
set_vpngateway_route() {
NETWORK="$1"
NETMASK="$2"
NETMASKLEN="$3"
- $IPROUTE route add `$IPROUTE route get "$NETWORK/$NETMASKLEN" | fix_ip_get_output`
+ $IPROUTE route add `$IPROUTE route get "$NETWORK" | fix_ip_get_output "/$NETMASKLEN"`
$IPROUTE route flush cache 2>/dev/null
}
# (keep traffic separate from VPN tunnel)
NETWORK="$1"
NETMASKLEN="$2"
- $IPROUTE -6 route add `$IPROUTE route get "$NETWORK/$NETMASKLEN" | fix_ip_get_output`
+ $IPROUTE -6 route add `$IPROUTE route get "$NETWORK" | fix_ip_get_output "/$NETMASKLEN"`
$IPROUTE route flush cache 2>/dev/null
}