Commit c6c00908 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 3ca44042
......@@ -577,7 +577,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"
......
......@@ -444,23 +444,26 @@ change_route(int operation, const struct babel_route *route, int metric,
int new_ifindex, int new_metric)
{
struct filter_result filter_result;
unsigned char *pref_src = NULL;
struct source *src = route->src;
unsigned char *pref_src = NULL, *src_prefix;
unsigned int ifindex = route->neigh->ifp->ifindex;
int m, table;
m = install_filter(route->src->prefix, route->src->plen,
route->src->src_prefix, route->src->src_plen,
m = install_filter(src->prefix, src->plen,
src->src_prefix, src->src_plen,
ifindex, &filter_result);
if(m >= INFINITY && operation == ROUTE_ADD) {
errno = EPERM;
return -1;
}
pref_src = filter_result.pref_src;
src_prefix = filter_result.src_prefix;
table = filter_result.table ? filter_result.table : export_table;
return kernel_route(operation, table, route->src->prefix, route->src->plen,
route->src->src_prefix, route->src->src_plen, pref_src,
return kernel_route(operation, table, src->prefix, src->plen,
src_prefix ? src_prefix : src->src_prefix,
src_prefix ? filter_result.src_plen : src->src_plen,
filter_result.pref_src,
route->nexthop, ifindex,
metric, new_next_hop, new_ifindex, new_metric,
operation == ROUTE_MODIFY ? table : 0);
......
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