From 9d219445d9f764f6a3ba1b46a49beef08cbd3cb1 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Mon, 16 Apr 2012 11:40:36 -0700 Subject: [PATCH] Make 'show routing work with iproute 20111117 Signed-off-by: Tom Eastep --- Shorewall-core/lib.cli | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Shorewall-core/lib.cli b/Shorewall-core/lib.cli index 38fad2de5..6dd835d6a 100644 --- a/Shorewall-core/lib.cli +++ b/Shorewall-core/lib.cli @@ -456,16 +456,26 @@ sort_routes() { done | sort -r | while read dest rest; do echo $rest; done } +# +# Isolate the table in the routing rules being read from stdin +# +find_tables() { + sed -r 's/[[:space:]]+$//' | while read rule; do + echo ${rule##* } + done +} + # # Show routing configuration # show_routing() { + local rule + local table + if [ -n "$(ip -$g_family rule list)" ]; then heading "Routing Rules" ip -$g_family rule list - ip -$g_family rule list | while read rule; do - echo ${rule##* } - done | sort -u | while read table; do + ip -$g_family rule list | find_tables | sort -u | while read table; do heading "Table $table:" if [ $g_family -eq 6 ]; then ip -$g_family -o route list table $table | fgrep -v cache