All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pádraig Brady" <P@draigBrady.com>
To: Harald Hoyer <harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Seewer Philippe <philippe.seewer-omB+W0Dpw2o@public.gmane.org>,
	"initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] network: don't die if gateway is down and root server is local
Date: Fri, 15 Oct 2010 15:03:29 +0100	[thread overview]
Message-ID: <4CB85F31.5010207@draigBrady.com> (raw)
In-Reply-To: <4CB85A73.6010902-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

On 15/10/10 14:43, Harald Hoyer wrote:
> 
> please use [ -n "$var" ]
> 

Done, and added a couple of comments.

cheers,
Pádraig.

From 3030d23e31f3975c0c44207b0faae0792d5cc9b0 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Fri, 15 Oct 2010 12:58:31 +0100
Subject: [PATCH] network: don't die if gateway is down and root server is local

* modules.d/40network/netroot: Don't arping the gateway
if we don't need to
---
 modules.d/40network/netroot |   28 ++++++++++++++++++++++------
 1 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/modules.d/40network/netroot b/modules.d/40network/netroot
index 81a9ad3..948f68b 100755
--- a/modules.d/40network/netroot
+++ b/modules.d/40network/netroot
@@ -83,21 +83,37 @@ done
 [ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
 [ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts

-# Handle STP Timeout: arping default router or if not available the
-# root server. Note: This assumes that if no router is present the
+# Handle STP Timeout: arping the default router if root server is
+# unknown or not local, or if not available the root server.
+# Note: This assumes that if no router is present the
 # root server is on the same subnet.
 #
 # TODO There's some netroot variants that don't (yet) have their
 # server-ip netroot
-[ -n "$new_routers" ] && dest=${new_routers%%,*}
-[ -n "$gw" ] && dest=$gw
-if [ -z "$dest" ] ; then
+
+# Get router IP if set
+[ -n "$new_routers" ] && gw_ip=${new_routers%%,*}
+[ -n "$gw" ] && gw_ip=$gw
+# Get root server IP if set
+if [ -n "$netroot" ]; then
     dummy=${netroot#*:}
     dummy=${dummy%%:*}
     case "$dummy" in
-        [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*) dest=$dummy;;
+        [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*) netroot_ip=$dummy;;
     esac
 fi
+# Default arping dest to router
+dest="$gw_ip"
+# Change to arping root server if appropriate
+if [ -n "$netroot_ip" ]; then
+    if [ -z "$dest" ]; then
+         # no gateway so check root server
+        dest="$netroot_ip"
+    elif ! ip route get "$netroot_ip" | grep -qF ' via ' ; then
+        # local root server, so don't arping gateway
+        dest="$netroot_ip"
+    fi
+fi
 if [ -n "$dest" ] && ! arping -q -f -w 60 -I $netif $dest ; then
     die "Resolving $dest via ARP on $netif failed"
 fi
-- 
1.6.2.5

  parent reply	other threads:[~2010-10-15 14:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-08 10:20 dracut requires router Pádraig Brady
     [not found] ` <4CAEF060.8030701-V8g9lnOeT5ydJdNcDFJN0w@public.gmane.org>
2010-10-08 13:30   ` Seewer Philippe
     [not found]     ` <4CAF1D02.6060701-omB+W0Dpw2o@public.gmane.org>
2010-10-08 13:59       ` Pádraig Brady
     [not found]         ` <4CAF23BA.4010605-V8g9lnOeT5ydJdNcDFJN0w@public.gmane.org>
2010-10-08 14:17           ` Seewer Philippe
     [not found]             ` <4CAF27EF.80301-omB+W0Dpw2o@public.gmane.org>
2010-10-08 15:19               ` Pádraig Brady
     [not found]                 ` <4CAF367D.7030707-V8g9lnOeT5ydJdNcDFJN0w@public.gmane.org>
2010-10-15 12:05                   ` [PATCH] network: don't die if gateway is down and root server is local Pádraig Brady
     [not found]                     ` <4CB84390.5060203-V8g9lnOeT5ydJdNcDFJN0w@public.gmane.org>
2010-10-15 13:43                       ` Harald Hoyer
     [not found]                         ` <4CB85A73.6010902-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-10-15 14:03                           ` Pádraig Brady [this message]
     [not found]                             ` <4CB85F31.5010207-V8g9lnOeT5ydJdNcDFJN0w@public.gmane.org>
2010-10-28 15:14                               ` Harald Hoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CB85F31.5010207@draigBrady.com \
    --to=p@draigbrady.com \
    --cc=harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=philippe.seewer-omB+W0Dpw2o@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.