summaryrefslogtreecommitdiff
path: root/proto/rip
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2012-08-14 16:25:22 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2012-08-14 16:46:43 +0200
commit094d2bdb79e1ffa0a02761fd651aa0f0b6b0c585 (patch)
treef7cb65c540403ed152677dde3b803c3dd117d8e5 /proto/rip
parentd760229ab897fa1bf1fd0fe7019cc2431d21a1cc (diff)
Implements ADD-PATH extension for BGP.
Allows to send and receive multiple routes for one network by one BGP session. Also contains necessary core changes to support this (routing tables accepting several routes for one network from one protocol). It needs some more cleanup before merging to the master branch.
Diffstat (limited to 'proto/rip')
-rw-r--r--proto/rip/rip.c38
-rw-r--r--proto/rip/rip.h1
2 files changed, 17 insertions, 22 deletions
diff --git a/proto/rip/rip.c b/proto/rip/rip.c
index 281296a5..9f4f0856 100644
--- a/proto/rip/rip.c
+++ b/proto/rip/rip.c
@@ -263,16 +263,18 @@ find_interface(struct proto *p, struct iface *what)
* This part is responsible for any updates that come from network
*/
+static int rip_rte_better(struct rte *new, struct rte *old);
+
static void
rip_rte_update_if_better(rtable *tab, net *net, struct proto *p, rte *new)
{
rte *old;
- old = rte_find(net, p);
- if (!old || p->rte_better(new, old) ||
+ old = rte_find(net, p->main_source);
+ if (!old || rip_rte_better(new, old) ||
(ipa_equal(old->attrs->from, new->attrs->from) &&
(old->u.rip.metric != new->u.rip.metric)) )
- rte_update(tab, net, p, p, new);
+ rte_update(p, net, new);
else
rte_free(new);
}
@@ -295,7 +297,7 @@ advertise_entry( struct proto *p, struct rip_block *b, ip_addr whotoldme, struct
int pxlen;
bzero(&A, sizeof(A));
- A.proto = p;
+ A.src= p->main_source;
A.source = RTS_RIP;
A.scope = SCOPE_UNIVERSE;
A.cast = RTC_UNICAST;
@@ -604,20 +606,10 @@ rip_start(struct proto *p)
add_head( &P->interfaces, NODE rif );
CHK_MAGIC;
- rip_init_instance(p);
-
DBG( "RIP: ...done\n");
return PS_UP;
}
-static struct proto *
-rip_init(struct proto_config *cfg)
-{
- struct proto *p = proto_new(cfg, sizeof(struct rip_proto));
-
- return p;
-}
-
static void
rip_dump(struct proto *p)
{
@@ -843,7 +835,7 @@ rip_gen_attrs(struct linpool *pool, int metric, u16 tag)
static int
rip_import_control(struct proto *p, struct rte **rt, struct ea_list **attrs, struct linpool *pool)
{
- if ((*rt)->attrs->proto == p) /* My own must not be touched */
+ if ((*rt)->attrs->src->proto == p) /* My own must not be touched */
return 1;
if ((*rt)->attrs->source != RTS_RIP) {
@@ -895,7 +887,7 @@ rip_rt_notify(struct proto *p, struct rtable *table UNUSED, struct network *net,
if (e->metric > P_CF->infinity)
e->metric = P_CF->infinity;
- if (new->attrs->proto == p)
+ if (new->attrs->src->proto == p)
e->whotoldme = new->attrs->from;
if (!e->metric) /* That's okay: this way user can set his own value for external
@@ -917,7 +909,7 @@ rip_rte_same(struct rte *new, struct rte *old)
static int
rip_rte_better(struct rte *new, struct rte *old)
{
- struct proto *p = new->attrs->proto;
+ struct proto *p = new->attrs->src->proto;
if (ipa_equal(old->attrs->from, new->attrs->from))
return 1;
@@ -928,7 +920,7 @@ rip_rte_better(struct rte *new, struct rte *old)
if (old->u.rip.metric > new->u.rip.metric)
return 1;
- if (old->attrs->proto == new->attrs->proto) /* This does not make much sense for different protocols */
+ if (old->attrs->src->proto == new->attrs->src->proto) /* This does not make much sense for different protocols */
if ((old->u.rip.metric == new->u.rip.metric) &&
((now - old->lastmod) > (P_CF->timeout_time / 2)))
return 1;
@@ -944,7 +936,7 @@ rip_rte_better(struct rte *new, struct rte *old)
static void
rip_rte_insert(net *net UNUSED, rte *rte)
{
- struct proto *p = rte->attrs->proto;
+ struct proto *p = rte->attrs->src->proto;
CHK_MAGIC;
DBG( "rip_rte_insert: %p\n", rte );
add_head( &P->garbage, &rte->u.rip.garbage );
@@ -962,9 +954,11 @@ rip_rte_remove(net *net UNUSED, rte *rte)
rem_node( &rte->u.rip.garbage );
}
-void
-rip_init_instance(struct proto *p)
+static struct proto *
+rip_init(struct proto_config *cfg)
{
+ struct proto *p = proto_new(cfg, sizeof(struct rip_proto));
+
p->accept_ra_types = RA_OPTIMAL;
p->if_notify = rip_if_notify;
p->rt_notify = rip_rt_notify;
@@ -975,6 +969,8 @@ rip_init_instance(struct proto *p)
p->rte_same = rip_rte_same;
p->rte_insert = rip_rte_insert;
p->rte_remove = rip_rte_remove;
+
+ return p;
}
void
diff --git a/proto/rip/rip.h b/proto/rip/rip.h
index 896fab64..6a8af379 100644
--- a/proto/rip/rip.h
+++ b/proto/rip/rip.h
@@ -172,7 +172,6 @@ struct rip_proto {
#endif
-void rip_init_instance(struct proto *p);
void rip_init_config(struct rip_proto_config *c);
/* Authentication functions */