diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/dvmrpd/rde.h | 3 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/rde_mfc.c | 45 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/rde_srt.c | 15 |
3 files changed, 54 insertions, 9 deletions
diff --git a/usr.sbin/dvmrpd/rde.h b/usr.sbin/dvmrpd/rde.h index 77c7b38d654..78e85b58bec 100644 --- a/usr.sbin/dvmrpd/rde.h +++ b/usr.sbin/dvmrpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.9 2009/01/20 01:35:34 todd Exp $ */ +/* $OpenBSD: rde.h,v 1.10 2009/02/03 16:21:19 michele Exp $ */ /* * Copyright (c) 2005, 2006 Esben Norby <norby@openbsd.org> @@ -91,6 +91,7 @@ void mfc_clear(void); void mfc_dump(pid_t); void mfc_update(struct mfc *); void mfc_delete(struct mfc *); +void mfc_update_source(struct rt_node *); /* rde_srt.c */ void rt_init(void); diff --git a/usr.sbin/dvmrpd/rde_mfc.c b/usr.sbin/dvmrpd/rde_mfc.c index 3ca5ff6fb43..85e738255bd 100644 --- a/usr.sbin/dvmrpd/rde_mfc.c +++ b/usr.sbin/dvmrpd/rde_mfc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_mfc.c,v 1.2 2006/12/03 20:14:37 michele Exp $ */ +/* $OpenBSD: rde_mfc.c,v 1.3 2009/02/03 16:21:19 michele Exp $ */ /* * Copyright (c) 2006 Esben Norby <norby@openbsd.org> @@ -36,6 +36,7 @@ void mfc_invalidate(void); void mfc_expire_timer(int, short, void *); int mfc_start_expire_timer(struct mfc_node *); +int mfc_reset_expire_timer(struct mfc_node *); int mfc_compare(struct mfc_node *, struct mfc_node *); RB_HEAD(mfc_tree, mfc_node) mfc; @@ -63,10 +64,22 @@ mfc_expire_timer(int fd, short event, void *arg) } int +mfc_reset_expire_timer(struct mfc_node *mn) +{ + struct timeval tv; + + timerclear(&tv); + tv.tv_sec = ROUTE_EXPIRATION_TIME; + return (evtimer_add(&mn->expiration_timer, &tv)); +} + +int mfc_start_expire_timer(struct mfc_node *mn) { struct timeval tv; + log_debug("mfc_start_expire_timer: group %s", inet_ntoa(mn->group)); + timerclear(&tv); tv.tv_sec = ROUTE_EXPIRATION_TIME; return (evtimer_add(&mn->expiration_timer, &tv)); @@ -173,6 +186,36 @@ mfc_dump(pid_t pid) } void +mfc_update_source(struct rt_node *rn) +{ + struct mfc_node *mn; + struct mfc m; + int i; + + RB_FOREACH(mn, mfc_tree, &mfc) { + if (rn->prefix.s_addr == mn->origin.s_addr) { + mn->ifindex = rn->ifindex; + + for (i = 0; i < MAXVIFS; i++) + mn->ttls[i] = rn->ttls[i]; + + m.origin.s_addr = mn->origin.s_addr; + m.group.s_addr = mn->group.s_addr; + m.ifindex = mn->ifindex; + + for (i = 0; i < MAXVIFS; i++) + m.ttls[i] = mn->ttls[i]; + + if (mn->origin.s_addr != 0) + rde_imsg_compose_parent(IMSG_MFC_ADD, 0, &m, + sizeof(m)); + + mfc_reset_expire_timer(mn); + } + } +} + +void mfc_update(struct mfc *nmfc) { struct timespec now; diff --git a/usr.sbin/dvmrpd/rde_srt.c b/usr.sbin/dvmrpd/rde_srt.c index 2b8189555a8..5a633455da8 100644 --- a/usr.sbin/dvmrpd/rde_srt.c +++ b/usr.sbin/dvmrpd/rde_srt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_srt.c,v 1.16 2009/01/25 15:24:21 michele Exp $ */ +/* $OpenBSD: rde_srt.c,v 1.17 2009/02/03 16:21:19 michele Exp $ */ /* * Copyright (c) 2005, 2006 Esben Norby <norby@openbsd.org> @@ -439,9 +439,10 @@ srt_current_forwarder(struct rt_node *rn, struct iface *iface, adv->addr.s_addr = nbr_report; adv->metric = metric; + + mfc_update_source(rn); } - /* XXX: update the kernel */ } void @@ -460,8 +461,6 @@ srt_update_ds_forwarders(struct rt_node *rn, struct iface *iface, srt_set_forwarder_self(rn, ifa); } } - - /* XXX: update the kernel */ } void @@ -471,7 +470,7 @@ srt_set_forwarder_self(struct rt_node *rn, struct iface *iface) rn->adv_rtr[iface->ifindex].metric = rn->cost; rn->ttls[iface->ifindex] = 1; - /* XXX: update the kernel */ + mfc_update_source(rn); } void @@ -481,6 +480,8 @@ srt_set_upstream(struct rt_node *rn, u_int32_t ifindex) rn->ttls[rn->ifindex] = 1; rn->ifindex = ifindex; } + + mfc_update_source(rn); } void @@ -517,8 +518,8 @@ srt_delete_ds(struct rt_node *rn, struct ds_nbr *ds_nbr, struct iface *iface) free(ds_nbr); rn->ds_cnt[iface->ifindex]--; - /* XXX: check if there are group with this source */ - if (!rn->ds_cnt[iface->ifindex] && group_list_empty(iface)) + /* XXX */ + if (!rn->ds_cnt[iface->ifindex]) rn->ttls[iface->ifindex] = 0; } |