Commit e77bf5ef authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Implement handling of ifindex change in filters.

parent 18d35651
......@@ -221,6 +221,7 @@ parse_filter(gnc_t gnc, void *closure)
c = getword(c, &interface, gnc, closure);
if(c < -1)
goto error;
filter->ifname = strdup(interface);
filter->ifindex = if_nametoindex(interface);
} else if(strcmp(token, "allow") == 0) {
filter->result = 0;
......@@ -360,6 +361,24 @@ parse_config_from_string(char *string)
return parse_config((gnc_t)gnc_string, &s);
}
static void
renumber_filter(struct filter *filter)
{
while(filter) {
if(filter->ifname)
filter->ifindex = if_nametoindex(filter->ifname);
filter = filter->next;
}
}
void
renumber_filters()
{
renumber_filter(input_filters);
renumber_filter(output_filters);
renumber_filter(redistribute_filters);
}
static int
filter_match(struct filter *f, const unsigned char *id,
const unsigned char *prefix, unsigned short plen,
......
......@@ -24,6 +24,7 @@ THE SOFTWARE.
struct filter {
int af;
char *ifname;
unsigned int ifindex;
unsigned char *id;
unsigned char *prefix;
......@@ -37,6 +38,7 @@ struct filter {
int parse_config_from_file(char *filename);
int parse_config_from_string(char *string);
void renumber_filters(void);
int input_filter(const unsigned char *id,
const unsigned char *prefix, unsigned short plen,
......
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