From f98e2915794e8641f0704b22cbd9b574514f5b23 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 1 Jun 2009 14:07:13 +0200 Subject: The pipe cleanup. --- nest/proto-hooks.c | 15 ++++++++++++--- nest/route.h | 3 +-- nest/rt-dev.c | 4 ++-- nest/rt-table.c | 40 +++++++++++++++++++++++++--------------- 4 files changed, 40 insertions(+), 22 deletions(-) (limited to 'nest') diff --git a/nest/proto-hooks.c b/nest/proto-hooks.c index 9af6ef5..c30b107 100644 --- a/nest/proto-hooks.c +++ b/nest/proto-hooks.c @@ -179,8 +179,8 @@ void ifa_notify(struct proto *p, unsigned flags, struct ifa *a) * rt_notify - notify instance about routing table change * @p: protocol instance * @net: a network entry - * @new: new optimal route for the network - * @old: old optimal route for the network + * @new: new route for the network + * @old: old route for the network * @attrs: extended attributes associated with the @new entry * * The rt_notify() hook is called to inform the protocol instance about @@ -189,7 +189,16 @@ void ifa_notify(struct proto *p, unsigned flags, struct ifa *a) * extended attributes @attrs. Either @new or @old or both can be %NULL * if the corresponding route doesn't exist. * - * FIXME documentation + * If the type of route announcement is RA_OPTIMAL, it is an + * announcement of optimal route change, @new stores the new optimal + * route and @old stores the old optimal route. + * + * If the type of route announcement is RA_ANY, it is an announcement + * of any route change, @new stores the new route and @old stores the + * old route from the same protocol. + * + * @p->accept_ra_types specifies which kind of route announcements + * protocol wants to receive. */ void rt_notify(struct proto *p, net *net, rte *new, rte *old, ea_list *attrs) { DUMMY; } diff --git a/nest/route.h b/nest/route.h index e55ae1d..1bd23a6 100644 --- a/nest/route.h +++ b/nest/route.h @@ -195,8 +195,7 @@ static inline net *net_find(rtable *tab, ip_addr addr, unsigned len) { return (n static inline net *net_get(rtable *tab, ip_addr addr, unsigned len) { return (net *) fib_get(&tab->fib, &addr, len); } rte *rte_find(net *net, struct proto *p); rte *rte_get_temp(struct rta *); -void rte_update(rtable *tab, net *net, struct proto *p, rte *new); -void rte_update2(rtable *tab, net *net, struct proto *p, struct proto *src, rte *new); +void rte_update(rtable *tab, net *net, struct proto *p, struct proto *src, rte *new); void rte_discard(rtable *tab, rte *old); void rte_dump(rte *); void rte_free(rte *); diff --git a/nest/rt-dev.c b/nest/rt-dev.c index 348bcc2..b86015d 100644 --- a/nest/rt-dev.c +++ b/nest/rt-dev.c @@ -44,7 +44,7 @@ dev_ifa_notify(struct proto *p, unsigned c, struct ifa *ad) DBG("dev_if_notify: device shutdown: prefix not found\n"); return; } - rte_update(p->table, n, p, NULL); + rte_update(p->table, n, p, p, NULL); } else if (c & IF_CHANGE_UP) { @@ -66,7 +66,7 @@ dev_ifa_notify(struct proto *p, unsigned c, struct ifa *ad) e = rte_get_temp(a); e->net = n; e->pflags = 0; - rte_update(p->table, n, p, e); + rte_update(p->table, n, p, p, e); } } diff --git a/nest/rt-table.c b/nest/rt-table.c index 176e2de..235e534 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -241,16 +241,24 @@ do_rte_announce(struct announce_hook *a, int type, net *net, rte *new, rte *old, * @tmpa: a list of temporary attributes belonging to the new route * * This function gets a routing table update and announces it - * to all protocols connected to the same table by their announcement hooks. + * to all protocols that acccepts given type of route announcement + * and are connected to the same table by their announcement hooks. * - * previous optimal route for the same network FIXME + * Route announcement of type RA_OPTIMAL si generated when optimal + * route (in routing table @tab) changes. In that case @old stores the + * old optimal route. * - * For each such protocol, we first call its import_control() hook which - * performs basic checks on the route (each protocol has a right to veto - * or force accept of the route before any filter is asked) and adds default - * values of attributes specific to the new protocol (metrics, tags etc.). - * Then it consults the protocol's export filter and if it accepts the - * route, the rt_notify() hook of the protocol gets called. + * Route announcement of type RA_ANY si generated when any route (in + * routing table @tab) changes In that case @old stores the old route + * from the same protocol. + * + * For each appropriate protocol, we first call its import_control() + * hook which performs basic checks on the route (each protocol has a + * right to veto or force accept of the route before any filter is + * asked) and adds default values of attributes specific to the new + * protocol (metrics, tags etc.). Then it consults the protocol's + * export filter and if it accepts the route, the rt_notify() hook of + * the protocol gets called. */ static void rte_announce(rtable *tab, int type, net *net, rte *new, rte *old, ea_list *tmpa) @@ -455,6 +463,7 @@ rte_update_unlock(void) * @table: table to be updated * @net: network node * @p: protocol submitting the update + * @src: protocol originating the update * @new: a &rte representing the new route or %NULL for route removal. * * This function is called by the routing protocols whenever they discover @@ -465,6 +474,12 @@ rte_update_unlock(void) * rta_clone()), call rte_get_temp() to obtain a temporary &rte, fill in all * the appropriate data and finally submit the new &rte by calling rte_update(). * + * @src specifies the protocol that originally created the route and the meaning + * of protocol-dependent data of @new. If @new is not %NULL, @src have to be the + * same value as @new->attrs->proto. @p specifies the protocol that called + * rte_update(). In most cases it is the same protocol as @src. rte_update() + * stores @p in @new->sender; + * * When rte_update() gets any route, it automatically validates it (checks, * whether the network and next hop address are valid IP addresses and also * whether a normal routing protocol doesn't try to smuggle a host or link @@ -474,7 +489,7 @@ rte_update_unlock(void) * stores the temporary attributes back to the &rte. * * Now, having a "public" version of the route, we - * automatically find any old route defined by the protocol @p + * automatically find any old route defined by the protocol @src * for network @n, replace it by the new one (or removing it if @new is %NULL), * recalculate the optimal route for this destination and finally broadcast * the change (if any) to all routing protocols by calling rte_announce(). @@ -483,14 +498,9 @@ rte_update_unlock(void) * from a special linear pool @rte_update_pool and freed when rte_update() * finishes. */ -void -rte_update(rtable *table, net *net, struct proto *p, rte *new) -{ - rte_update2(table, net, p, p, new); -} void -rte_update2(rtable *table, net *net, struct proto *p, struct proto *src, rte *new) +rte_update(rtable *table, net *net, struct proto *p, struct proto *src, rte *new) { ea_list *tmpa = NULL; -- cgit v1.2.3