Don't assume that all nexthop routes are default routes

This commit is contained in:
Tom Eastep 2011-04-13 13:53:18 -07:00
parent a0b16e2803
commit 16276b9900
3 changed files with 23 additions and 1 deletions

View File

@ -730,7 +730,7 @@ sub start_providers() {
emit ( '#',
'# Capture the default route(s) if we don\'t have it (them) already.',
'#',
'[ -f ${VARDIR}/default_route ] || $IP -' . $family . ' route list | grep -E \'^\s*(default |nexthop )\' > ${VARDIR}/default_route',
"[ -f \${VARDIR}/default_route ] || \$IP -$family route ls | save_default_route > \${VARDIR}/default_route",
'#',
'# Initialize the file that holds \'undo\' commands',
'#',

View File

@ -504,6 +504,17 @@ undo_routing() {
}
#
# Save the default route
#
save_default_route() {
awk \
'BEGIN {default=0;}; \
/^default / {default=1; print; next}; \
/nexthop/ {if (default == 1 ) {print ; next} }; \
{ default=0; };'
}
#
# Restore the default route that was in place before the initial 'shorewall start'
#

View File

@ -492,6 +492,17 @@ undo_routing() {
}
#
# Save the default route
#
save_default_route() {
awk \
'BEGIN {default=0;}; \
/^default / {default=1; print; next}; \
/nexthop/ {if (default == 1 ) {print ; next} }; \
{ default=0; };'
}
#
# Restore the default route that was in place before the initial 'shorewall start'
#