summaryrefslogtreecommitdiff
path: root/usr.sbin/ospfd/kroute.c
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2006-04-16 11:38:12 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2006-04-16 11:38:12 +0000
commitafc789991f1b30c4067754d09f331f6bc5f77e11 (patch)
tree35581ccc6034ac29ba854c2526c7b742715e5a30 /usr.sbin/ospfd/kroute.c
parent2f0d07ed496beb5a7c4f4dd19fd4f62c9dbeb41f (diff)
only look at later rt_msghdr fields for those messages actually using
rt_msghdr, same as in bgpd, ok claudio norby
Diffstat (limited to 'usr.sbin/ospfd/kroute.c')
-rw-r--r--usr.sbin/ospfd/kroute.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/usr.sbin/ospfd/kroute.c b/usr.sbin/ospfd/kroute.c
index d707a3d3e3a..cc7a58591ec 100644
--- a/usr.sbin/ospfd/kroute.c
+++ b/usr.sbin/ospfd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.26 2006/03/08 13:49:07 claudio Exp $ */
+/* $OpenBSD: kroute.c,v 1.27 2006/04/16 11:38:11 henning Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -973,7 +973,7 @@ dispatch_rtmsg(void)
struct in_addr prefix, nexthop;
u_int8_t prefixlen;
int flags;
- u_short ifindex;
+ u_short ifindex = 0;
if ((n = read(kr_state.fd, &buf, sizeof(buf))) == -1) {
log_warn("dispatch_rtmsg: read error");
@@ -988,24 +988,26 @@ dispatch_rtmsg(void)
lim = buf + n;
for (next = buf; next < lim; next += rtm->rtm_msglen) {
rtm = (struct rt_msghdr *)next;
- sa = (struct sockaddr *)(rtm + 1);
- get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
prefix.s_addr = 0;
prefixlen = 0;
flags = F_KERNEL;
nexthop.s_addr = 0;
- if (rtm->rtm_pid == kr_state.pid) /* cause by us */
- continue;
-
- if (rtm->rtm_errno) /* failed attempts... */
- continue;
-
if (rtm->rtm_type == RTM_ADD || rtm->rtm_type == RTM_CHANGE ||
rtm->rtm_type == RTM_DELETE) {
+ sa = (struct sockaddr *)(rtm + 1);
+ get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
+
+ if (rtm->rtm_pid == kr_state.pid) /* cause by us */
+ continue;
+
+ if (rtm->rtm_errno) /* failed attempts... */
+ continue;
+
if (rtm->rtm_flags & RTF_LLINFO) /* arp cache */
continue;
+
switch (sa->sa_family) {
case AF_INET:
prefix.s_addr =
@@ -1031,19 +1033,20 @@ dispatch_rtmsg(void)
default:
continue;
}
- }
- ifindex = rtm->rtm_index;
- if ((sa = rti_info[RTAX_GATEWAY]) != NULL)
- switch (sa->sa_family) {
- case AF_INET:
- nexthop.s_addr =
- ((struct sockaddr_in *)sa)->sin_addr.s_addr;
- break;
- case AF_LINK:
- flags |= F_CONNECTED;
- break;
+ ifindex = rtm->rtm_index;
+ if ((sa = rti_info[RTAX_GATEWAY]) != NULL) {
+ switch (sa->sa_family) {
+ case AF_INET:
+ nexthop.s_addr =
+ ((struct sockaddr_in *)sa)->sin_addr.s_addr;
+ break;
+ case AF_LINK:
+ flags |= F_CONNECTED;
+ break;
+ }
}
+ }
switch (rtm->rtm_type) {
case RTM_ADD: