]> git.proxmox.com Git - mirror_iproute2.git/blob - ip/routel
iproute: Set ip/ip6 lwtunnel flags
[mirror_iproute2.git] / ip / routel
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
3
4 #
5 # Script created by: Stephen R. van den Berg <srb@cuci.nl>, 1999/04/18
6 # Donated to the public domain.
7 #
8 # This script transforms the output of "ip" into more readable text.
9 # "ip" is the Linux-advanced-routing configuration tool part of the
10 # iproute package.
11 #
12
13 test "X-h" = "X$1" && echo "Usage: $0 [tablenr [raw ip args...]]" && exit 64
14
15 test -z "$*" && set 0
16
17 ip route list table "$@" |
18 while read network rest
19 do set xx $rest
20 shift
21 proto=""
22 via=""
23 dev=""
24 scope=""
25 src=""
26 table=""
27 case $network in
28 broadcast|local|unreachable) via=$network
29 network=$1
30 shift
31 ;;
32 esac
33 while test $# != 0
34 do
35 case "$1" in
36 proto|via|dev|scope|src|table)
37 key=$1
38 val=$2
39 eval "$key='$val'"
40 shift 2
41 ;;
42 dead|onlink|pervasive|offload|notify|linkdown|unresolved)
43 shift
44 ;;
45 *)
46 # avoid infinite loop on unknown keyword without value at line end
47 shift
48 shift
49 ;;
50 esac
51 done
52 echo "$network $via $src $proto $scope $dev $table"
53 done | awk -F ' ' '
54 BEGIN {
55 format="%15s%-3s %15s %15s %8s %8s%7s %s\n";
56 printf(format,"target","","gateway","source","proto","scope","dev","tbl");
57 }
58 { network=$1;
59 mask="";
60 if(match(network,"/"))
61 { mask=" "substr(network,RSTART+1);
62 network=substr(network,0,RSTART);
63 }
64 via=$2;
65 src=$3;
66 proto=$4;
67 scope=$5;
68 dev=$6;
69 table=$7;
70 printf(format,network,mask,via,src,proto,scope,dev,table);
71 }
72 '