selftests: pmtu: Factor out MTU parsing helper
authorStefano Brivio <sbrivio@redhat.com>
Sat, 17 Mar 2018 01:31:40 +0000 (02:31 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 18 Mar 2018 00:15:14 +0000 (20:15 -0400)
...so that it can be used for any iproute command output.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/pmtu.sh

index 0d010f982272e2e38e7f987ceb8a5cd7fd0ec9cf..2d33e533ad361108740cf70c89f860c92cf4a020 100755 (executable)
@@ -97,6 +97,16 @@ mtu() {
        ${ns_cmd} ip link set dev ${dev} mtu ${mtu}
 }
 
+mtu_parse() {
+       input="${1}"
+
+       next=0
+       for i in ${input}; do
+               [ ${next} -eq 1 ] && echo "${i}" && return
+               [ "${i}" = "mtu" ] && next=1
+       done
+}
+
 route_get_dst_exception() {
        ns_cmd="${1}"
        dst="${2}"
@@ -108,12 +118,7 @@ route_get_dst_pmtu_from_exception() {
        ns_cmd="${1}"
        dst="${2}"
 
-       exception="$(route_get_dst_exception "${ns_cmd}" ${dst})"
-       next=0
-       for i in ${exception}; do
-               [ ${next} -eq 1 ] && echo "${i}" && return
-               [ "${i}" = "mtu" ] && next=1
-       done
+       mtu_parse "$(route_get_dst_exception "${ns_cmd}" ${dst})"
 }
 
 test_pmtu_vti6_exception() {