poll - Fix events == 0 handling for TAP and TUN, fix console spam
[dragonfly.git] / usr.sbin / route6d / misc / chkrt
blob4ab53841c89a91ebbe34836dbdf31e7b8e88dee8
1 #!/usr/bin/env perl
3 # $FreeBSD: src/usr.sbin/route6d/misc/chkrt,v 1.1 1999/12/28 02:37:10 shin Exp $
5 $dump="/var/tmp/route6d_dump";
6 $pidfile="/var/run/route6d.pid";
8 system("rm -f $dump");
10 open(FD, "< $pidfile") || die "Can not open $pidfile";
11 $_ = <FD>;
12 chop;
13 close(FD);
14 system("kill -INT $_");
16 open(NS, "/usr/local/v6/bin/netstat -r -n|") || die "Can not open netstat";
17 while (<NS>) {
18 chop;
19 next unless (/^3f/ || /^5f/);
20 @f = split(/\s+/);
21 $gw{$f[0]} = $f[1];
22 $int{$f[0]} = $f[3];
24 close(NS);
26 $err=0;
27 sleep(2);
28 open(FD, "< $dump") || die "Can not open $dump";
29 while (<FD>) {
30 chop;
31 next unless (/^ 3f/ || /^ 5f/);
32 @f = split(/\s+/);
33 $dst = $f[1];
34 $f[2] =~ /if\(\d:([a-z0-9]+)\)/;
35 $intf = $1;
36 $f[3] =~ /gw\(([a-z0-9:]+)\)/;
37 $gateway = $1;
38 $f[4] =~ /\[(\d+)\]/;
39 $metric = $1;
40 $f[5] =~ /age\((\d+)\)/;
41 $age = $1;
42 unless (defined($gw{$dst})) {
43 print "NOT FOUND: $dst $intf $gateway $metric $age\n";
44 $err++;
45 next;
47 if ($gw{$dst} ne $gateway && $gw{$dst} !~ /link#\d+/) {
48 print "WRONG GW: $dst $intf $gateway $metric $age\n";
49 print "kernel gw: $gw{$dst}\n";
50 $err++;
51 next;
53 if ($int{$dst} ne $intf) {
54 print "WRONG IF: $dst $intf $gateway $metric $age\n";
55 print "kernel if: $int{$dst}\n";
56 $err++;
57 next;
60 close(FD);
62 if ($err == 0) {
63 print "No error found\n";