From 4b419f7497615e3bad245f714a5049024ea61a0b Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Sat, 22 Oct 2011 12:48:07 -0700 Subject: [PATCH] Cleanup if IPv6 provider work Signed-off-by: Tom Eastep --- Shorewall/Perl/Shorewall/Providers.pm | 11 +++++++- Shorewall/Perl/prog.footer6 | 36 ++++++++++++++++++++++++++- Shorewall/Perl/prog.header6 | 29 +++++++++++++++++++++ manpages6/shorewall6-providers.xml | 24 ++++++++++++++++++ 4 files changed, 98 insertions(+), 2 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Providers.pm b/Shorewall/Perl/Shorewall/Providers.pm index 0407ad7a0..7da485a7c 100644 --- a/Shorewall/Perl/Shorewall/Providers.pm +++ b/Shorewall/Perl/Shorewall/Providers.pm @@ -217,6 +217,9 @@ sub balance_default_route( $$$$ ) { emit "DEFAULT_ROUTE=\"nexthop dev $interface weight $weight $realm\""; } } else { + # + # IPv6 doesn't support multi-hop routes + # if ( $gateway ) { emit "DEFAULT_ROUTE=\"via $gateway dev $interface $realm\""; } else { @@ -251,6 +254,9 @@ sub balance_fallback_route( $$$$ ) { emit "FALLBACK_ROUTE=\"nexthop dev $interface weight $weight $realm\""; } } else { + # + # IPv6 doesn't support multi-hop routes + # if ( $gateway ) { emit "FALLBACK_ROUTE=\"via $gateway dev $interface $realm\""; } else { @@ -657,6 +663,9 @@ sub add_a_provider( $$ ) { emit qq(add_gateway "nexthop dev $physical weight $weight $realm" ) . $tbl; } } else { + # + # IPv6 doesn't support multi-hop routes + # if ( $gateway ) { emit qq(add_gateway "via $gateway dev $physical $realm" ) . $tbl; } else { @@ -737,7 +746,7 @@ sub add_a_provider( $$ ) { $via = "dev $physical"; } - $via .= " weight $weight" unless $weight < 0 or $family == F_IPV6; + $via .= " weight $weight" unless $weight < 0 or $family == F_IPV6; # IPv6 doesn't support route weights $via .= " $realm" if $realm; emit( qq(delete_gateway "$via" $tbl $physical) ); diff --git a/Shorewall/Perl/prog.footer6 b/Shorewall/Perl/prog.footer6 index 66cc97a50..28e68f381 100644 --- a/Shorewall/Perl/prog.footer6 +++ b/Shorewall/Perl/prog.footer6 @@ -5,7 +5,21 @@ # Give Usage Information # usage() { - echo "Usage: $0 [ options ] [ start|stop|clear|down|reset|refresh|restart|status|up|version ]" + echo "Usage: $0 [ options ] " + echo + echo " is one of:" + echo " start" + echo " stop" + echo " clear" + echo " disable " + echo " down " + echo " enable " + echo " reset" + echo " refresh" + echo " restart" + echo " status" + echo " up " + echo " version" echo echo "Options are:" echo @@ -330,6 +344,26 @@ case "$COMMAND" in updown $1 status=0 ;; + enable) + [ $# -eq 1 ] && exit 0 + shift + [ $# -ne 1 ] && usage 2 + if shorewall6_is_started; then + detect_configuration + enable_provider $1 + fi + status=0 + ;; + disable) + [ $# -eq 1 ] && exit 0 + shift + [ $# -ne 1 ] && usage 2 + if shorewall6_is_started; then + detect_configuration + disable_provider $1 + fi + status=0 + ;; version) [ $# -ne 1 ] && usage 2 echo $SHOREWALL_VERSION diff --git a/Shorewall/Perl/prog.header6 b/Shorewall/Perl/prog.header6 index a5fae16c0..49ca7bdbf 100644 --- a/Shorewall/Perl/prog.header6 +++ b/Shorewall/Perl/prog.header6 @@ -196,6 +196,35 @@ find_interface_full_addresses() # $1 = interface $IP -f inet6 addr show $1 2> /dev/null | grep 'inet6 ' | sed 's/\s*inet6 //;s/ scope.*//;s/ peer.*//' } +# +# Add an additional gateway to the default route +# +add_gateway() # $1 = Delta $2 = Table Number +{ + local route + local weight + local delta + local dev + + run_ip route add default scope global table $2 $1 +} + +# +# Remove a gateway from the default route +# +delete_gateway() # $! = Description of the Gateway $2 = table number $3 = device +{ + local route + local gateway + local dev + + route=`$IP -6 -o route ls table $2 | grep ^default | sed 's/[\]//g'` + gateway=$1 + + dev=$(find_device $route) + [ "$dev" = "$3" ] && run_ip route delete default table $2 +} + # # echo the list of networks routed out of a given interface # diff --git a/manpages6/shorewall6-providers.xml b/manpages6/shorewall6-providers.xml index e66d17a86..dcfa6537f 100644 --- a/manpages6/shorewall6-providers.xml +++ b/manpages6/shorewall6-providers.xml @@ -141,6 +141,30 @@ embedded whitespace. + + balance + + + Added in Shorewall 4.4.25. Causes a default route to + this provider's gateway to be added to the main routing table (USE_DEFAULT_RT=No) + or to the balance routing + table (USE_DEFAULT_RT=Yes). At most one provider can specify + this option. + + + + + fallback + + + Added in Shorewall 4.4.25. Causes a default route to + this provider's gateway to be added to the default routing table.At most one + provider can specify this option. + + + track