Commit 73d2c811 authored by Julien Muchembled's avatar Julien Muchembled

Make deny & src-prefix actions work in install filter

parent 378be94a
...@@ -578,8 +578,26 @@ For a redistribute filter, redistribute this route with metric ...@@ -578,8 +578,26 @@ For a redistribute filter, redistribute this route with metric
.IR value . .IR value .
.TP .TP
.BI src-prefix " prefix" .BI src-prefix " prefix"
.RS
On Linux, this action is about the
.BR from
option in
.BR ip-route (8).
For a redistribute filter, set the source prefix of this route to For a redistribute filter, set the source prefix of this route to
.IR prefix . .IR prefix .
For an install filter:
.IP \(bu 2
when
.IR prefix
matches exactly the source prefix of the route to install,
the latter is cleared at install;
.IP \(bu
otherwise, the route is not installed.
.P
The purpose of such an install filter is mainly to provide a fallback for
routers without support of source-specific routes: only one route is kept,
to a router that will be able to route correctly.
.RE
.TP .TP
.BI table " table" .BI table " table"
In an In an
......
...@@ -1511,12 +1511,8 @@ install_filter(const unsigned char *prefix, unsigned short plen, ...@@ -1511,12 +1511,8 @@ install_filter(const unsigned char *prefix, unsigned short plen,
unsigned int ifindex, unsigned int ifindex,
struct filter_result *result) struct filter_result *result)
{ {
int res; return do_filter(install_filters, NULL, prefix, plen,
res = do_filter(install_filters, NULL, prefix, plen, src_prefix, src_plen, NULL, ifindex, 0, result);
src_prefix, src_plen, NULL, ifindex, 0, result);
if(res < 0)
res = INFINITY;
return res;
} }
int int
......
...@@ -215,7 +215,7 @@ is_installed(struct zone *zone) ...@@ -215,7 +215,7 @@ is_installed(struct zone *zone)
} }
static int static int
change_route(int operation, const struct zone *zone, change_route(int operation, struct zone *zone,
const struct babel_route *route, int metric, const struct babel_route *route, int metric,
const unsigned char *new_next_hop, const unsigned char *new_next_hop,
int new_ifindex, int new_metric) int new_ifindex, int new_metric)
...@@ -227,8 +227,19 @@ change_route(int operation, const struct zone *zone, ...@@ -227,8 +227,19 @@ change_route(int operation, const struct zone *zone,
int m = install_filter(zone->dst_prefix, zone->dst_plen, int m = install_filter(zone->dst_prefix, zone->dst_plen,
zone->src_prefix, zone->src_plen, zone->src_prefix, zone->src_plen,
ifindex, &filter_result); ifindex, &filter_result);
if (m < INFINITY) if(m >= 0) {
if(m == INFINITY)
return 0;
if(filter_result.src_prefix) {
if(prefix_cmp(zone->src_prefix, zone->src_plen,
filter_result.src_prefix, filter_result.src_plen)
!= PST_EQUALS)
return 0;
zone->src_plen = zone->src_plen >= 96 && v4mapped(zone->src_prefix)
? 96 : 0;
}
pref_src = filter_result.pref_src; pref_src = filter_result.pref_src;
}
int table = filter_result.table ? filter_result.table : int table = filter_result.table ? filter_result.table :
find_table(zone->dst_prefix, zone->dst_plen, find_table(zone->dst_prefix, zone->dst_plen,
...@@ -242,21 +253,21 @@ change_route(int operation, const struct zone *zone, ...@@ -242,21 +253,21 @@ change_route(int operation, const struct zone *zone,
} }
static int static int
add_route(const struct zone *zone, const struct babel_route *route) add_route(struct zone *zone, const struct babel_route *route)
{ {
return change_route(ROUTE_ADD, zone, route, return change_route(ROUTE_ADD, zone, route,
metric_to_kernel(route_metric(route)), NULL, 0, 0); metric_to_kernel(route_metric(route)), NULL, 0, 0);
} }
static int static int
del_route(const struct zone *zone, const struct babel_route *route) del_route(struct zone *zone, const struct babel_route *route)
{ {
return change_route(ROUTE_FLUSH, zone, route, return change_route(ROUTE_FLUSH, zone, route,
metric_to_kernel(route_metric(route)), NULL, 0, 0); metric_to_kernel(route_metric(route)), NULL, 0, 0);
} }
static int static int
chg_route(const struct zone *zone, const struct babel_route *old, chg_route(struct zone *zone, const struct babel_route *old,
const struct babel_route *new) const struct babel_route *new)
{ {
return change_route(ROUTE_MODIFY, zone, old, return change_route(ROUTE_MODIFY, zone, old,
...@@ -266,7 +277,7 @@ chg_route(const struct zone *zone, const struct babel_route *old, ...@@ -266,7 +277,7 @@ chg_route(const struct zone *zone, const struct babel_route *old,
} }
static int static int
chg_route_metric(const struct zone *zone, const struct babel_route *route, chg_route_metric(struct zone *zone, const struct babel_route *route,
int old_metric, int new_metric) int old_metric, int new_metric)
{ {
return change_route(ROUTE_MODIFY, zone, route, return change_route(ROUTE_MODIFY, zone, route,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment