summaryrefslogtreecommitdiff
path: root/usr.sbin/dvmrpd/rde.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/dvmrpd/rde.c')
-rw-r--r--usr.sbin/dvmrpd/rde.c40
1 files changed, 36 insertions, 4 deletions
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 {