From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 34559138B07 for ; Sun, 23 Oct 2016 23:50:21 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D2E20E0810; Sun, 23 Oct 2016 23:50:18 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B3C5EE0810 for ; Sun, 23 Oct 2016 23:50:18 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 4FABF34165F for ; Sun, 23 Oct 2016 23:50:17 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 96C12249B for ; Sun, 23 Oct 2016 23:50:15 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <1477266608.f9793bb67a40dc58c97772a9731a2b6dfcb1422f.robbat2@OpenRC> Subject: [gentoo-commits] proj/netifrc:master commit in: net/ X-VCS-Repository: proj/netifrc X-VCS-Files: net/iproute2.sh X-VCS-Directories: net/ X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: f9793bb67a40dc58c97772a9731a2b6dfcb1422f X-VCS-Branch: master Date: Sun, 23 Oct 2016 23:50:15 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: dd36f795-db26-4f44-8f1c-f664ed3aa570 X-Archives-Hash: 34d08c75cb805d6d29f6c62f6f03a9bc commit: f9793bb67a40dc58c97772a9731a2b6dfcb1422f Author: Robin H. Johnson gentoo org> AuthorDate: Sun Oct 23 23:50:08 2016 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Sun Oct 23 23:50:08 2016 +0000 URL: https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=f9793bb6 iproute2: treat EEXIST error on routes as non-fatal. Signed-off-by: Robin H. Johnson gentoo.org> net/iproute2.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/net/iproute2.sh b/net/iproute2.sh index d03548e..779d334 100644 --- a/net/iproute2.sh +++ b/net/iproute2.sh @@ -251,10 +251,33 @@ _add_route() cmd="${cmd} metric ${metric}" fi + # Check for route already existing: + ip ${family} route show ${cmd} dev "${IFACE}" 2>/dev/null | \ + fgrep -sq "${cmd%% *}" + route_already_exists=$? + veinfo ip ${family} route append ${cmd} dev "${IFACE}" ip ${family} route append ${cmd} dev "${IFACE}" rc=$? - # TODO: check return code in some cases + # Check return code in some cases + if [ $rc -ne 0 ]; then + # If the route already exists, our default behavior is to WARN but continue. + # You can completely silence this with: errh_IFVAR_route_EEXIST=continue + if [ $route_already_exists -eq 0 ]; then + eh_behavior=$(_get_errorhandler_behavior "$IFVAR" "route" "EEXIST" "warn") + abort=0 + case $eh_behavior in + continue) msgfunc=true ;; + info) msgfunc=einfo ;; + warn) msgfunc=ewarn ;; + error|fatal) msgfunc=eerror abort=1;; + esac + $msgfunc "Route '$cmd' already existed: $(ip $family route show $cmd dev "${IFACE}" 2>&1)" + [ $abort -eq 1 ] && rc=1 + else + # TODO: Handle other errors + fi + fi eend $rc }