Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 505050 Details for
Bug 637394
net-misc/netifrc - add support for route types without dev option (iproute2)
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
netifrc-iproute2-total.patch
netifrc-iproute2-total.patch (text/plain), 4.98 KB, created by
Alexander Zubkov
on 2017-11-20 00:28:52 UTC
(
hide
)
Description:
netifrc-iproute2-total.patch
Filename:
MIME Type:
Creator:
Alexander Zubkov
Created:
2017-11-20 00:28:52 UTC
Size:
4.98 KB
patch
obsolete
>diff --git a/net/iproute2.sh b/net/iproute2.sh >index 7dea195..7aef49f 100644 >--- a/net/iproute2.sh >+++ b/net/iproute2.sh >@@ -195,8 +195,8 @@ _add_address() > error|fatal) msgfunc=eerror rc=1;; > *) msgfunc=eerror rc=1 ; eerror "Unknown error behavior: $eh_behavior" ;; > esac >- eval $msgfunc "Address ${address}${netmask:+/}${netmask} already existed!" >- eval $msgfunc \"$(ip addr show to "${address}/${family_maxnetmask}" dev "${IFACE}" 2>&1)\" >+ $msgfunc "Address ${address}${netmask:+/}${netmask} already existed!" >+ $msgfunc "$(ip -o addr show to "${address}/${family_maxnetmask}" dev "${IFACE}" 2>&1)" > else > : # TODO: Handle other errors > fi >@@ -204,6 +204,30 @@ _add_address() > return $rc > } > >+_filter_metric() >+{ >+ # ip route show does not allow to filter by metric >+ # so we need to filter metric manually >+ local metric_value="$1" >+ shift >+ >+ if [ "${metric_value}" -eq 0 ]; then >+ # metric 0 is not displayed >+ ip -o "$@" | fgrep -vs " metric " >+ else >+ # add trailing space for matching >+ ip -o "$@" | sed 's/$/ /' | fgrep -s " metric ${metric_value} " >+ fi >+} >+ >+_is_route_type() >+{ >+ case "$1" in >+ unicast|multicast|local|broadcast|throw|unreachable|prohibit|blackhole) true ;; >+ *) false ;; >+ esac >+} >+ > _add_route() > { > local family= >@@ -219,41 +243,92 @@ _add_route() > shift > fi > >- if [ $# -eq 3 ]; then >+ if _is_route_type "$2"; then >+ : >+ elif [ $# -eq 3 ]; then > set -- "$1" "$2" via "$3" > elif [ "$3" = "gw" ]; then >- local one=$1 two=$2 >+ local one="$1" two="$2" > shift; shift; shift > set -- "${one}" "${two}" via "$@" > fi > >- local cmd= cmd_nometric= have_metric=false >+ local cmd_prefix= cmd_add= cmd_show= metric_value= table_value= >+ local have_metric=false have_table=false have_prefix=false nodev=false > while [ -n "$1" ]; do > case "$1" in >- metric) metric=$2 ; cmd="${cmd} metric $2" ; shift ; have_metric=true ;; >- netmask) x="/$(_netmask2cidr "$2")" ; cmd="${cmd}${x}" ; cmd_nometric="${cmd}${x}" ; shift;; >+ metric|priority|preference) >+ cmd_prefix="${cmd_prefix} ${1} ${2}" >+ metric_value="$2" >+ have_metric=true >+ shift ;; >+ netmask) >+ x="/$(_netmask2cidr "$2")" >+ cmd_prefix="${cmd_prefix}${x}" >+ cmd_show="${cmd_show}${x}" >+ have_prefix=true >+ shift ;; >+ tos) >+ cmd_add="${cmd_add} ${1} ${2}" >+ cmd_show="${cmd_show} ${1} ${2}" >+ shift ;; >+ table) >+ cmd_add="${cmd_add} ${1} ${2}" >+ cmd_show="${cmd_show} ${1} ${2}" >+ have_table=true >+ shift ;; >+ unicast|multicast) >+ cmd_prefix="${cmd_prefix} ${1}" >+ ;; >+ local|broadcast) >+ # those are added to table local by default >+ cmd_prefix="${cmd_prefix} ${1}" >+ table_value="local" >+ ;; >+ throw|unreachable|prohibit|blackhole) >+ cmd_prefix="${cmd_prefix} ${1}" >+ nodev=true >+ ;; > -host|-net);; >- *) cmd="${cmd} ${1}" ; cmd_nometric="${cmd_nometric} ${1}" ;; >+ *) >+ if ${have_prefix}; then >+ cmd_add="${cmd_add} ${1}" >+ else >+ cmd_prefix="${cmd_prefix} ${1}" >+ cmd_show="${cmd_show} ${1}" >+ have_prefix=true >+ fi ;; > esac > shift > done > >- # We cannot use a metric if we're using a nexthop >- if ! ${have_metric} && \ >- [ -n "${metric}" -a \ >- "${cmd##* nexthop }" = "$cmd" ] >- then >- cmd="${cmd} metric ${metric}" >+ # Add table for special types >+ if ! ${have_table} && [ -n "${table_value}" ]; then >+ cmd_show="${cmd_show} table ${table_value}" > fi > >+ # Add interface's metric by default >+ if ! ${have_metric} && [ -n "${metric}" ]; then >+ cmd_prefix="${cmd_prefix} metric ${metric}" >+ metric_value="${metric}" >+ fi >+ >+ cmd_add="${cmd_prefix}${cmd_add}" >+ > # Check for route already existing: >- ip ${family} route show ${cmd_nometric} dev "${IFACE}" 2>/dev/null | \ >- fgrep -sq "${cmd%% *}" >+ ip ${family} route test ${cmd_add} 2>&1 | grep -q 'RTNETLINK answers: File exists' > route_already_exists=$? > >- veinfo ip ${family} route append ${cmd} dev "${IFACE}" >- ip ${family} route append ${cmd} dev "${IFACE}" >- rc=$? >+ if yesno "${nodev}"; then >+ veinfo ip ${family} route append ${cmd_add} >+ ip ${family} route append ${cmd_add} >+ rc=$? >+ else >+ veinfo ip ${family} route append ${cmd_add} dev "${IFACE}" >+ ip ${family} route append ${cmd_add} dev "${IFACE}" >+ rc=$? >+ fi >+ > # Check return code in some cases > if [ $rc -ne 0 ]; then > # If the route already exists, our default behavior is to WARN but continue. >@@ -267,8 +342,15 @@ _add_route() > error|fatal) msgfunc=eerror rc=1;; > *) msgfunc=eerror rc=1 ; eerror "Unknown error behavior: $eh_behavior" ;; > esac >- eval $msgfunc "Route '$cmd_nometric' already existed:" >- eval $msgfunc \"$(ip $family route show ${cmd_nometric} dev "${IFACE}" 2>&1)\" >+ local metric_show= >+ if [ -n "${metric_value}" -a "${metric_value}" != 0 ]; then >+ metric_show=" metric ${metric_value}" >+ fi >+ $msgfunc "Route '${cmd_show# }${metric_show}' already existed:" >+ eindent >+ _filter_metric "${metric_value}" ${family} route show ${cmd_show} 2>&1 | \ >+ while read l; do $msgfunc "$l"; done >+ eoutdent > else > : # TODO: Handle other errors > fi
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 637394
:
504106
|
504454
|
504470
|
504532
| 505050