Subject: bin/15672: route monitor missing info
To: None <gnats-bugs@gnats.netbsd.org>
From: None <lha@stacken.kth.se>
List: netbsd-bugs
Date: 02/19/2002 20:42:11
>Number: 15672
>Category: bin
>Synopsis: route monitor missing info
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Feb 19 11:43:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Love
>Release: NetBSD 1.5ZA
>Organization:
Stacken Computer Club
>Environment:
System: NetBSD nutcracker.stacken.kth.se 1.5ZA NetBSD 1.5ZA (NUTCRACKER) #0: Sun Feb 3 14:54:01 CET 2002 lha@nutcracker.stacken.kth.se:/usr/src/sys/arch/i386/compile/NUTCRACKER i386
Architecture: i386
Machine: i386
>Description:
When pulling out and re-inserting my network cable (using ex)
I get this message:
got message of size 144 on Tue Feb 19 20:32:52 2002
RTM_IFINFO: iface status change: len 144, if# 1, flags:<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST>
got message of size 144 on Tue Feb 19 20:32:55 2002
RTM_IFINFO: iface status change: len 144, if# 1, flags:<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST>
Doing this a couple of times make you quickly lose trace of
what is happening since the mssage is the same for extraction
and insertion.
>How-To-Repeat:
run route monitor
>Fix:
Print out the carrier status.
Index: route.c
===================================================================
RCS file: /cvsroot/basesrc/sbin/route/route.c,v
retrieving revision 1.52
diff -w -u -r1.52 route.c
--- route.c 2001/11/15 21:25:08 1.52
+++ route.c 2002/02/19 17:12:42
@@ -97,7 +97,8 @@
static void interfaces __P((void));
static void monitor __P((void));
static void print_getmsg __P((struct rt_msghdr *, int));
-#endif
+static void print_linkstate __P((struct if_msghdr *));
+#endif /* SMALL */
static int rtmsg __P((int, int ));
static void mask_addr __P((void));
static void print_rtmsg __P((struct rt_msghdr *, int));
@@ -1628,7 +1629,31 @@
char addrnames[] =
"\1DST\2GATEWAY\3NETMASK\4GENMASK\5IFP\6IFA\7AUTHOR\010BRD";
+
+#ifndef SMALL
static void
+print_linkstate(ifm)
+ struct if_msghdr *ifm;
+{
+
+ switch (ifm->ifm_data.ifi_link_state) {
+ case LINK_STATE_UNKNOWN:
+ printf("\ncarrier: unknown");
+ break;
+ case LINK_STATE_DOWN:
+ printf("\ncarrier: no carrier");
+ break;
+ case LINK_STATE_UP:
+ printf("\ncarrier: active");
+ break;
+ default:
+ printf("\ncarrier: 0x%x",ifm->ifm_data.ifi_link_state);
+ break;
+ }
+}
+#endif /* SMALL */
+
+static void
print_rtmsg(rtm, msglen)
struct rt_msghdr *rtm;
int msglen;
@@ -1654,6 +1679,9 @@
ifm = (struct if_msghdr *)rtm;
(void) printf("if# %d, flags:", ifm->ifm_index);
bprintf(stdout, ifm->ifm_flags, ifnetflags);
+#ifndef SMALL
+ print_linkstate(ifm);
+#endif /* SMALL */
pmsg_addrs((char *)(ifm + 1), ifm->ifm_addrs);
break;
case RTM_NEWADDR:
Now the output look like this:
: root@nutcracker ; route -n monitor
got message of size 144 on Tue Feb 19 20:42:52 2002
RTM_IFINFO: iface status change: len 144, if# 1, flags:<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST>
carrier: no carrier
got message of size 144 on Tue Feb 19 20:42:55 2002
RTM_IFINFO: iface status change: len 144, if# 1, flags:<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST>
carrier: active
>Release-Note:
>Audit-Trail:
>Unformatted: