diff options
author | Michele Marchetto <michele@cvs.openbsd.org> | 2009-01-19 20:40:32 +0000 |
---|---|---|
committer | Michele Marchetto <michele@cvs.openbsd.org> | 2009-01-19 20:40:32 +0000 |
commit | 876ffe015144dd1318edeac08ebe9282e1f49998 (patch) | |
tree | c30d25d4991db5c6f7d6ea1e4533128818ba4007 | |
parent | 2f66bc06a639c063a93de742008c3df5bc043808 (diff) |
When inserting a new route into the kernel set as
downstream interfaces the ones with neighbors or
group members.
ok norby@
-rw-r--r-- | usr.sbin/dvmrpd/dvmrpd.h | 4 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/interface.c | 3 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/rde.c | 40 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/rde.h | 3 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/rde_srt.c | 15 |
5 files changed, 54 insertions, 11 deletions
diff --git a/usr.sbin/dvmrpd/dvmrpd.h b/usr.sbin/dvmrpd/dvmrpd.h index 3321d7f5c1f..5a7e5df4eca 100644 --- a/usr.sbin/dvmrpd/dvmrpd.h +++ b/usr.sbin/dvmrpd/dvmrpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dvmrpd.h,v 1.11 2008/12/07 16:37:04 michele Exp $ */ +/* $OpenBSD: dvmrpd.h,v 1.12 2009/01/19 20:40:31 michele Exp $ */ /* * Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org> @@ -234,7 +234,6 @@ struct iface { int fd; int state; int mtu; - int nbr_cnt; int adj_cnt; u_int16_t flags; @@ -323,7 +322,6 @@ struct ctl_iface { unsigned int ifindex; int state; int mtu; - int nbr_cnt; int adj_cnt; u_int16_t flags; diff --git a/usr.sbin/dvmrpd/interface.c b/usr.sbin/dvmrpd/interface.c index cbe3f67c121..3b3202bd14b 100644 --- a/usr.sbin/dvmrpd/interface.c +++ b/usr.sbin/dvmrpd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.5 2007/09/11 18:23:05 claudio Exp $ */ +/* $OpenBSD: interface.c,v 1.6 2009/01/19 20:40:31 michele Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -643,7 +643,6 @@ if_to_ctl(struct iface *iface) ictl.ifindex = iface->ifindex; ictl.state = iface->state; ictl.mtu = iface->mtu; - ictl.nbr_cnt = iface->nbr_cnt; ictl.adj_cnt = iface->adj_cnt; ictl.gen_id = iface->gen_id; diff --git a/usr.sbin/dvmrpd/rde.c b/usr.sbin/dvmrpd/rde.c index b1e3e9071a7..1c9be751935 100644 --- a/usr.sbin/dvmrpd/rde.c +++ b/usr.sbin/dvmrpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.6 2008/12/02 13:42:44 michele Exp $ */ +/* $OpenBSD: rde.c,v 1.7 2009/01/19 20:40:31 michele Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -39,6 +39,8 @@ #include "log.h" #include "rde.h" +void rde_ds_iface(struct mfc *, struct iface *, struct rt_node *); + void rde_nbr_init(u_int32_t); void rde_nbr_free(void); struct rde_nbr *rde_nbr_find(u_int32_t); @@ -198,6 +200,7 @@ rde_dispatch_imsg(int fd, short event, void *bula) struct imsg imsg; struct route_report rr; struct rde_nbr rn; + struct rt_node *r; int i, n, connected = 0; struct iface *iface; @@ -260,11 +263,16 @@ rde_dispatch_imsg(int fd, short event, void *bula) for (i = 0; i < MAXVIFS; i++) mfc.ttls[i] = 0; - LIST_FOREACH(iface, &rdeconf->iface_list, entry) { - if (mfc.ifindex != iface->ifindex) - mfc.ttls[iface->ifindex] = 1; + r = rt_matchorigin(mfc.origin.s_addr); + if (r == NULL) { + log_debug("rde_dispatch_imsg: " + "packet from unknown origin"); + break; } + LIST_FOREACH(iface, &rdeconf->iface_list, entry) + rde_ds_iface(&mfc, iface, r); + mfc_update(&mfc); #endif break; @@ -299,6 +307,30 @@ rde_dispatch_imsg(int fd, short event, void *bula) imsg_event_add(ibuf); } +/* 1) Add interfaces with downstream routers for this + source. + 2) Add interfaces with member for this group if i am + the designated forwarder. +*/ +void +rde_ds_iface(struct mfc *mfc, struct iface *iface, struct rt_node *r) +{ + if (mfc->ifindex == iface->ifindex) { + return; + } + + if (r->ds_cnt[iface->ifindex] != 0) { + mfc->ttls[iface->ifindex] = 1; + return; + } + + if (group_list_find(iface, mfc->group.s_addr) && + r->adv_rtr[iface->ifindex].addr.s_addr == iface->addr.s_addr) { + mfc->ttls[iface->ifindex] = 1; + return; + } +} + LIST_HEAD(rde_nbr_head, rde_nbr); struct nbr_table { diff --git a/usr.sbin/dvmrpd/rde.h b/usr.sbin/dvmrpd/rde.h index 364aa1aa64b..29c7bf95ecf 100644 --- a/usr.sbin/dvmrpd/rde.h +++ b/usr.sbin/dvmrpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.7 2008/12/07 16:37:04 michele Exp $ */ +/* $OpenBSD: rde.h,v 1.8 2009/01/19 20:40:31 michele Exp $ */ /* * Copyright (c) 2005, 2006 Esben Norby <norby@openbsd.org> @@ -96,6 +96,7 @@ void mfc_delete(struct mfc *); void rt_init(void); int rt_compare(struct rt_node *, struct rt_node *); struct rt_node *rt_find(in_addr_t, u_int8_t); +struct rt_node *rt_matchorigin(in_addr_t); struct rt_node *rr_new_rt(struct route_report *, u_int32_t, int); int rt_insert(struct rt_node *); void rt_update(struct rt_node *); diff --git a/usr.sbin/dvmrpd/rde_srt.c b/usr.sbin/dvmrpd/rde_srt.c index f714dc98e91..29a1677426f 100644 --- a/usr.sbin/dvmrpd/rde_srt.c +++ b/usr.sbin/dvmrpd/rde_srt.c @@ -1,6 +1,7 @@ -/* $OpenBSD: rde_srt.c,v 1.12 2008/12/07 16:37:04 michele Exp $ */ +/* $OpenBSD: rde_srt.c,v 1.13 2009/01/19 20:40:31 michele Exp $ */ /* + * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> * Copyright (c) 2005, 2006 Esben Norby <norby@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any @@ -162,6 +163,18 @@ rt_find(in_addr_t prefix, u_int8_t prefixlen) } struct rt_node * +rt_matchorigin(in_addr_t src) +{ + struct rt_node *r; + + RB_FOREACH(r, rt_tree, &rt) + if (r->prefix.s_addr == (src & prefixlen2mask(r->prefixlen))) + return (r); + + return (NULL); +} + +struct rt_node * rr_new_rt(struct route_report *rr, u_int32_t adj_metric, int connected) { struct timespec now; |