diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2010-11-14 05:49:56 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2010-11-14 05:49:56 +0100 |
commit | 2ef9177a47e7137dd09b06a353a6e5f6e671c951 (patch) | |
tree | 3fb8f3e25eec4dd513cb87399caf7c0e6ff5f955 /proto/static | |
parent | 9d35f8c51f1062ddd8e2f41cf535d8a8d69ec6be (diff) | |
download | bird-2ef9177a47e7137dd09b06a353a6e5f6e671c951.tar bird-2ef9177a47e7137dd09b06a353a6e5f6e671c951.zip |
Add multicast support to static protocol and generic route handling.
Diffstat (limited to 'proto/static')
-rw-r--r-- | proto/static/config.Y | 4 | ||||
-rw-r--r-- | proto/static/static.c | 18 | ||||
-rw-r--r-- | proto/static/static.h | 1 |
3 files changed, 13 insertions, 10 deletions
diff --git a/proto/static/config.Y b/proto/static/config.Y index a7e5016..b089864 100644 --- a/proto/static/config.Y +++ b/proto/static/config.Y @@ -16,7 +16,7 @@ static struct static_route *this_srt; CF_DECLS -CF_KEYWORDS(STATIC, ROUTE, VIA, DROP, REJECT, PROHIBIT, PREFERENCE) +CF_KEYWORDS(STATIC, ROUTE, VIA, DROP, REJECT, PROHIBIT, PREFERENCE, MULTICAST) CF_GRAMMAR @@ -39,6 +39,7 @@ stat_route0: ROUTE prefix { add_tail(&((struct static_config *) this_proto)->other_routes, &this_srt->n); this_srt->net = $2.addr; this_srt->masklen = $2.len; + this_srt->cast = RTC_UNICAST; } ; @@ -56,6 +57,7 @@ stat_route: | stat_route0 DROP { this_srt->dest = RTD_BLACKHOLE; } | stat_route0 REJECT { this_srt->dest = RTD_UNREACHABLE; } | stat_route0 PROHIBIT { this_srt->dest = RTD_PROHIBIT; } + | stat_route MULTICAST { this_srt->cast = RTC_MULTICAST; } ; CF_CLI(SHOW STATIC, optsym, [<name>], [[Show details of static protocol]]) diff --git a/proto/static/static.c b/proto/static/static.c index 6b42a37..e15a43b 100644 --- a/proto/static/static.c +++ b/proto/static/static.c @@ -23,7 +23,7 @@ * newly added routes and removes the obsolete ones. */ -#undef LOCAL_DEBUG +#define LOCAL_DEBUG #include "nest/bird.h" #include "nest/iface.h" @@ -45,18 +45,18 @@ static_install(struct proto *p, struct static_route *r, struct iface *ifa) if (r->installed) return; - DBG("Installing static route %I/%d, rtd=%d\n", r->net, r->masklen, r->dest); + DBG("Installing static route %I/%d, rtd=%d%s\n", r->net, r->masklen, r->dest, (r->cast == RTC_MULTICAST) ? ", multicast" : ""); bzero(&a, sizeof(a)); a.proto = p; a.source = (r->dest == RTD_DEVICE) ? RTS_STATIC_DEVICE : RTS_STATIC; a.scope = SCOPE_UNIVERSE; - a.cast = RTC_UNICAST; + a.cast = r->cast; a.dest = r->dest; a.gw = r->via; a.iface = ifa; aa = rta_lookup(&a); - n = net_get(p->table, r->net, r->masklen); + n = net_get2(p->table, r->net, r->masklen, r->cast); e = rte_get_temp(aa); e->net = n; e->pflags = 0; @@ -72,8 +72,8 @@ static_remove(struct proto *p, struct static_route *r) if (!r->installed) return; - DBG("Removing static route %I/%d\n", r->net, r->masklen); - n = net_find(p->table, r->net, r->masklen); + DBG("Removing static route %I/%d%s\n", r->net, r->masklen, (r->cast == RTC_MULTICAST) ? ", multicast" : ""); + n = net_find2(p->table, r->net, r->masklen, r->cast); if (n) rte_update(p->table, n, p, p, NULL); r->installed = 0; @@ -247,13 +247,13 @@ static_match(struct proto *p, struct static_route *r, struct static_config *n) if (r->neigh) r->neigh->data = NULL; WALK_LIST(t, n->iface_routes) - if (static_same_net(r, t)) + if (static_same_net(r, t) && r->cast == t->cast) { t->installed = static_same_dest(r, t); return; } WALK_LIST(t, n->other_routes) - if (static_same_net(r, t)) + if (static_same_net(r, t) && r->cast == t->cast) { t->installed = static_same_dest(r, t); return; @@ -311,7 +311,7 @@ static_show_rt(struct static_route *r) case RTD_PROHIBIT: bsprintf(via, "prohibited"); break; default: bsprintf(via, "???"); } - cli_msg(-1009, "%I/%d %s%s", r->net, r->masklen, via, r->installed ? "" : " (dormant)"); + cli_msg(-1009, "%I/%d %s%s%s", r->net, r->masklen, via, r->cast == RTC_MULTICAST ? "" : " multicast", r->installed ? "" : " (dormant)"); } void diff --git a/proto/static/static.h b/proto/static/static.h index 5d2bd21..e100068 100644 --- a/proto/static/static.h +++ b/proto/static/static.h @@ -26,6 +26,7 @@ struct static_route { ip_addr via; /* Destination router */ struct neighbor *neigh; byte *if_name; /* Name for RTD_DEVICE routes */ + int cast; int installed; /* Installed in master table */ }; |