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 ...@@ -578,7 +578,7 @@ For a redistribute filter, redistribute this route with metric
.IR value . .IR value .
.TP .TP
.BI src-prefix " prefix" .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 . .IR prefix .
.TP .TP
.BI table " table" .BI table " table"
......
...@@ -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)
...@@ -223,16 +223,24 @@ change_route(int operation, const struct zone *zone, ...@@ -223,16 +223,24 @@ change_route(int operation, const struct zone *zone,
struct filter_result filter_result; struct filter_result filter_result;
unsigned char *pref_src = NULL; unsigned char *pref_src = NULL;
unsigned int ifindex = route->neigh->ifp->ifindex; unsigned int ifindex = route->neigh->ifp->ifindex;
int table;
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 < INFINITY) {
pref_src = filter_result.pref_src; pref_src = filter_result.pref_src;
if(filter_result.src_prefix) {
int table = filter_result.table ? filter_result.table : zone->src_prefix = filter_result.src_prefix;
find_table(zone->dst_prefix, zone->dst_plen, zone->src_plen = filter_result.src_plen;
zone->src_prefix, zone->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, return kernel_route(operation, table, zone->dst_prefix, zone->dst_plen,
zone->src_prefix, zone->src_plen, pref_src, zone->src_prefix, zone->src_plen, pref_src,
...@@ -242,21 +250,21 @@ change_route(int operation, const struct zone *zone, ...@@ -242,21 +250,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 +274,7 @@ chg_route(const struct zone *zone, const struct babel_route *old, ...@@ -266,7 +274,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