Commit 928a970f authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Simplify interface of input/output filter.

parent 0bffdbe3
...@@ -1005,6 +1005,7 @@ do_filter(struct filter *f, const unsigned char *id, ...@@ -1005,6 +1005,7 @@ do_filter(struct filter *f, const unsigned char *id,
{ {
if(result) if(result)
memset(result, 0, sizeof(struct filter_result)); memset(result, 0, sizeof(struct filter_result));
while(f) { while(f) {
if(filter_match(f, id, prefix, plen, src_prefix, src_plen, if(filter_match(f, id, prefix, plen, src_prefix, src_plen,
neigh, ifindex, proto)) { neigh, ifindex, proto)) {
...@@ -1014,6 +1015,7 @@ do_filter(struct filter *f, const unsigned char *id, ...@@ -1014,6 +1015,7 @@ do_filter(struct filter *f, const unsigned char *id,
} }
f = f->next; f = f->next;
} }
return -1; return -1;
} }
...@@ -1021,12 +1023,11 @@ int ...@@ -1021,12 +1023,11 @@ int
input_filter(const unsigned char *id, input_filter(const unsigned char *id,
const unsigned char *prefix, unsigned short plen, const unsigned char *prefix, unsigned short plen,
const unsigned char *src_prefix, unsigned short src_plen, const unsigned char *src_prefix, unsigned short src_plen,
const unsigned char *neigh, unsigned int ifindex, const unsigned char *neigh, unsigned int ifindex)
struct filter_result *result)
{ {
int res; int res;
res = do_filter(input_filters, id, prefix, plen, res = do_filter(input_filters, id, prefix, plen,
src_prefix, src_plen, neigh, ifindex, 0, result); src_prefix, src_plen, neigh, ifindex, 0, NULL);
if(res < 0) if(res < 0)
res = 0; res = 0;
return res; return res;
...@@ -1036,12 +1037,11 @@ int ...@@ -1036,12 +1037,11 @@ int
output_filter(const unsigned char *id, output_filter(const unsigned char *id,
const unsigned char *prefix, unsigned short plen, const unsigned char *prefix, unsigned short plen,
const unsigned char *src_prefix, unsigned short src_plen, const unsigned char *src_prefix, unsigned short src_plen,
unsigned int ifindex, unsigned int ifindex)
struct filter_result *result)
{ {
int res; int res;
res = do_filter(output_filters, id, prefix, plen, res = do_filter(output_filters, id, prefix, plen,
src_prefix, src_plen, NULL, ifindex, 0, result); src_prefix, src_plen, NULL, ifindex, 0, NULL);
if(res < 0) if(res < 0)
res = 0; res = 0;
return res; return res;
......
...@@ -52,13 +52,11 @@ void renumber_filters(void); ...@@ -52,13 +52,11 @@ void renumber_filters(void);
int input_filter(const unsigned char *id, int input_filter(const unsigned char *id,
const unsigned char *prefix, unsigned short plen, const unsigned char *prefix, unsigned short plen,
const unsigned char *src_prefix, unsigned short src_plen, const unsigned char *src_prefix, unsigned short src_plen,
const unsigned char *neigh, unsigned int ifindex, const unsigned char *neigh, unsigned int ifindex);
struct filter_result *result);
int output_filter(const unsigned char *id, int output_filter(const unsigned char *id,
const unsigned char *prefix, unsigned short plen, const unsigned char *prefix, unsigned short plen,
const unsigned char *src_prefix, unsigned short src_plen, const unsigned char *src_prefix, unsigned short src_plen,
unsigned int ifindex, unsigned int ifindex);
struct filter_result *result);
int redistribute_filter(const unsigned char *prefix, unsigned short plen, int redistribute_filter(const unsigned char *prefix, unsigned short plen,
const unsigned char *src_prefix, unsigned short src_plen, const unsigned char *src_prefix, unsigned short src_plen,
unsigned int ifindex, int proto, unsigned int ifindex, int proto,
......
...@@ -1160,7 +1160,7 @@ really_send_update(struct interface *ifp, ...@@ -1160,7 +1160,7 @@ really_send_update(struct interface *ifp,
return; return;
add_metric = output_filter(id, prefix, plen, src_prefix, add_metric = output_filter(id, prefix, plen, src_prefix,
src_plen, ifp->ifindex, NULL); src_plen, ifp->ifindex);
if(add_metric >= INFINITY) if(add_metric >= INFINITY)
return; return;
......
...@@ -97,11 +97,10 @@ record_resend(int kind, const unsigned char *prefix, unsigned char plen, ...@@ -97,11 +97,10 @@ record_resend(int kind, const unsigned char *prefix, unsigned char plen,
if((kind == RESEND_REQUEST && if((kind == RESEND_REQUEST &&
input_filter(NULL, prefix, plen, src_prefix, src_plen, NULL, input_filter(NULL, prefix, plen, src_prefix, src_plen, NULL,
ifindex, NULL) >= ifindex) >=
INFINITY) || INFINITY) ||
(kind == RESEND_UPDATE && (kind == RESEND_UPDATE &&
output_filter(NULL, prefix, plen, src_prefix, src_plen, output_filter(NULL, prefix, plen, src_prefix, src_plen, ifindex) >=
ifindex, NULL) >=
INFINITY)) INFINITY))
return 0; return 0;
......
...@@ -806,7 +806,7 @@ update_route_metric(struct babel_route *route) ...@@ -806,7 +806,7 @@ update_route_metric(struct babel_route *route)
route->src->src_prefix, route->src->src_prefix,
route->src->src_plen, route->src->src_plen,
neigh->address, neigh->address,
neigh->ifp->ifindex, NULL); neigh->ifp->ifindex);
change_route_metric(route, route->refmetric, change_route_metric(route, route->refmetric,
neighbour_cost(route->neigh), add_metric); neighbour_cost(route->neigh), add_metric);
if(route_metric(route) != oldmetric || if(route_metric(route) != oldmetric ||
...@@ -889,8 +889,7 @@ update_route(const unsigned char *id, ...@@ -889,8 +889,7 @@ update_route(const unsigned char *id,
add_metric = input_filter(id, prefix, plen, src_prefix, src_plen, add_metric = input_filter(id, prefix, plen, src_prefix, src_plen,
neigh->address, neigh->ifp->ifindex, neigh->address, neigh->ifp->ifindex);
NULL);
if(add_metric >= INFINITY) if(add_metric >= INFINITY)
return NULL; return NULL;
......
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