summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Marchetto <michele@cvs.openbsd.org>2009-03-31 09:11:46 +0000
committerMichele Marchetto <michele@cvs.openbsd.org>2009-03-31 09:11:46 +0000
commit27fa11aa3624d5595c2b159fcfbe0e2f4b35ed37 (patch)
tree6d0c8127f06293d8a16c8c3dfa12df1937df8911
parentcbec2d7db896cb69945c76003177cf61c46993b5 (diff)
Assign the correct metric to the routes learned from the kernel while ripd is
running. Issue spotted and diff tested by Steven Surdock. ok claudio@
-rw-r--r--usr.sbin/ripd/kroute.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/usr.sbin/ripd/kroute.c b/usr.sbin/ripd/kroute.c
index 85222ee950b..3bd2a0d68bd 100644
--- a/usr.sbin/ripd/kroute.c
+++ b/usr.sbin/ripd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.13 2008/05/09 12:47:42 henning Exp $ */
+/* $OpenBSD: kroute.c,v 1.14 2009/03/31 09:11:45 michele Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -917,7 +917,7 @@ fetchtable(void)
if (iface != NULL)
kr->r.metric = iface->cost;
else
- kr->r.metric = 1;
+ kr->r.metric = DEFAULT_COST;
if ((sa = rti_info[RTAX_GATEWAY]) != NULL)
switch (sa->sa_family) {
@@ -1036,8 +1036,10 @@ dispatch_rtmsg(void)
struct sockaddr_rtlabel *label;
struct kroute_node *kr;
struct in_addr prefix, nexthop, netmask;
+ struct iface *iface = NULL;
int flags;
u_short ifindex = 0;
+ u_int8_t metric;
if ((n = read(kr_state.fd, &buf, sizeof(buf))) == -1) {
log_warn("dispatch_rtmsg: read error");
@@ -1162,9 +1164,17 @@ dispatch_rtmsg(void)
log_warn("dispatch_rtmsg");
return (-1);
}
+
+ iface = if_find_index(rtm->rtm_index);
+ if (iface != NULL)
+ metric = iface->cost;
+ else
+ metric = DEFAULT_COST;
+
kr->r.prefix.s_addr = prefix.s_addr;
kr->r.netmask.s_addr = netmask.s_addr;
kr->r.nexthop.s_addr = nexthop.s_addr;
+ kr->r.metric = metric;
kr->r.flags = flags;
kr->r.ifindex = ifindex;