summaryrefslogtreecommitdiffstats
path: root/proto/static
diff options
context:
space:
mode:
Diffstat (limited to 'proto/static')
-rw-r--r--proto/static/config.Y4
-rw-r--r--proto/static/static.c18
-rw-r--r--proto/static/static.h1
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 */
};