aboutsummaryrefslogtreecommitdiff
path: root/dgd/dgd
diff options
context:
space:
mode:
Diffstat (limited to 'dgd/dgd')
-rwxr-xr-xdgd/dgd31
1 files changed, 19 insertions, 12 deletions
diff --git a/dgd/dgd b/dgd/dgd
index f809cc8..1b37c3a 100755
--- a/dgd/dgd
+++ b/dgd/dgd
@@ -185,8 +185,8 @@ sub check_mandatory {
my $err = 0;
while (my ($k, $d) = each %{$kw}) {
if (ref($d) eq 'HASH'
- and $d->{mandatory}
- and !exists($section->{$k})) {
+ && $d->{mandatory}
+ && !exists($section->{$k})) {
if (exists($d->{section})) {
if ($s) {
error("$loc: mandatory section [$k] not present");
@@ -247,7 +247,7 @@ sub readconfig {
if (ref($param{kw}) eq 'HASH') {
if (defined($rootname)) {
if (ref($param{kw}{$rootname}) eq 'HASH'
- and exists($param{kw}{$rootname}{section})) {
+ && exists($param{kw}{$rootname}{section})) {
$kw = $param{kw}{$rootname}{section};
} else {
error("$file:$line: unknown section");
@@ -293,7 +293,7 @@ sub readconfig {
next;
}
if (exists($x->{check})
- and !&{$x->{check}}($v, "$file:$line")) {
+ && !&{$x->{check}}($v, "$file:$line")) {
++$err;
next;
}
@@ -302,7 +302,7 @@ sub readconfig {
++$err;
next;
}
- } elsif (!exists($x->{var}) and !exists($x->{mandatory})) {
+ } elsif (!exists($x->{var}) && !exists($x->{mandatory})) {
error("$file:$line: unknown keyword $k");
++$err;
next;
@@ -318,7 +318,7 @@ sub readconfig {
}
}
close $fd;
- # if (defined($param{kw}) and !$param{include}) {
+ # if (defined($param{kw}) && !$param{include}) {
# $err += check_mandatory($conf, $param{kw}, "$file:$line", 1);
# }
return $err;
@@ -434,18 +434,25 @@ sub link_is_alive {
sub check_links {
my $link;
foreach $link (@links) {
+ $link->{prevstate} = link_is_alive($link);
$link->{alive} = 0;
}
- debug(1, "checking links ".($#links+1).", probes $config{core}{probes}");
+ debug(2, "checking links ".($#links+1).", probes $config{core}{probes}");
for (my $i = 0; $i < $config{core}{probes}; $i++) {
foreach $link (@links) {
next if link_is_alive($link);
- debug(3, "ping $link->{name}");
+ debug(3, "ping $link->{name} $link->{gw} $link->{if}");
my $p = Net::Ping->new("icmp", $config{core}{timeout}, undef,
$link->{if});
++$link->{alive} if $p->ping($link->{gw});
- $p->close();
- debug(3, "$link->{name} " . ($link->{alive} ? "alive" : "dead"));
+ }
+ }
+ if ($debug) {
+ foreach $link (@links) {
+ if ($link->{prevstate} != link_is_alive($link)) {
+ debug(1, "$link->{name} state changed to " . (link_is_alive($link) ? "alive" : "dead"));
+ }
+# print "Link $link->{name} is ".(link_is_alive($link)?"up":"down")."\n";
}
}
if (!defined($active_link)) {
@@ -575,7 +582,7 @@ $SIG{HUP} = sub {
}
};
-$use_syslog = defined $config{syslog}{facility};
+$use_syslog = defined $config{syslog}{facility} && !$foreground;
while (1) {
if (check_links()) {
@@ -583,7 +590,7 @@ while (1) {
} elsif ($active_link > 0) {
for (my $i = 0; $i < $active_link; $i++) {
if (link_is_alive($i)
- and $links[$i]->{priority} < $links[$active_link]->{priority}) {
+ && $links[$i]->{priority} < $links[$active_link]->{priority}) {
diag('info', "switching to higher priority link $links[$i]->{name}");
updown('down', $links[$active_link]->{name});

Return to:

Send suggestions and report system problems to the System administrator.