Commit 732e271d authored by Julien Muchembled's avatar Julien Muchembled

Make src-prefix action work in install filter

The purpose is to override *locally* RTA_SRC ('from' option in ip-route).
parent 4b06eebb
......@@ -578,7 +578,7 @@ For a redistribute filter, redistribute this route with metric
.IR value .
.TP
.BI src-prefix " prefix"
For a redistribute filter, set the source prefix of this route to
For a redistribute or install filter, set the source prefix of this route to
.IR prefix .
.TP
.BI table " table"
......
......@@ -215,7 +215,7 @@ is_installed(struct zone *zone)
}
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 unsigned char *new_next_hop,
int new_ifindex, int new_metric)
......@@ -223,15 +223,23 @@ change_route(int operation, const struct zone *zone,
struct filter_result filter_result;
unsigned char *pref_src = NULL;
unsigned int ifindex = route->neigh->ifp->ifindex;
int table;
int m = install_filter(zone->dst_prefix, zone->dst_plen,
zone->src_prefix, zone->src_plen,
ifindex, &filter_result);
if (m < INFINITY)
if (m < INFINITY) {
pref_src = filter_result.pref_src;
int table = filter_result.table ? filter_result.table :
find_table(zone->dst_prefix, zone->dst_plen,
if(filter_result.src_prefix) {
zone->src_prefix = filter_result.src_prefix;
zone->src_plen = filter_result.src_plen;
}
table = filter_result.table;
} else {
table = 0;
}
if (!table)
table = find_table(zone->dst_prefix, zone->dst_plen,
zone->src_prefix, zone->src_plen);
return kernel_route(operation, table, zone->dst_prefix, zone->dst_plen,
......@@ -242,21 +250,21 @@ change_route(int operation, const struct zone *zone,
}
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,
metric_to_kernel(route_metric(route)), NULL, 0, 0);
}
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,
metric_to_kernel(route_metric(route)), NULL, 0, 0);
}
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)
{
return change_route(ROUTE_MODIFY, zone, old,
......@@ -266,7 +274,7 @@ chg_route(const struct zone *zone, const struct babel_route *old,
}
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)
{
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