Commit a903a1f3 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Call back into babel when a route changes.

parent 458af5c3
...@@ -79,6 +79,7 @@ struct network *add_network(char *ifname, int ifindex, int bufsize, ...@@ -79,6 +79,7 @@ struct network *add_network(char *ifname, int ifindex, int bufsize,
int wired, unsigned int cost, int hello_interval); int wired, unsigned int cost, int hello_interval);
void expire_routes(void); void expire_routes(void);
static int kernel_routes_changed(void *closure);
static void init_signals(void); static void init_signals(void);
static void dump_tables(FILE *out); static void dump_tables(FILE *out);
...@@ -407,7 +408,7 @@ main(int argc, char **argv) ...@@ -407,7 +408,7 @@ main(int argc, char **argv)
break; break;
if(kernel_socket >= 0 && FD_ISSET(kernel_socket, &readfds)) { if(kernel_socket >= 0 && FD_ISSET(kernel_socket, &readfds)) {
kernel_callback(); kernel_callback(kernel_routes_changed, NULL);
} }
if(FD_ISSET(protocol_socket, &readfds)) { if(FD_ISSET(protocol_socket, &readfds)) {
...@@ -620,6 +621,12 @@ dump_tables(FILE *out) ...@@ -620,6 +621,12 @@ dump_tables(FILE *out)
fflush(out); fflush(out);
} }
static int
kernel_routes_changed(void *closure)
{
return 0;
}
struct network * struct network *
add_network(char *ifname, int ifindex, int mtu, add_network(char *ifname, int ifindex, int mtu,
int wired, unsigned int cost, int hello_interval) int wired, unsigned int cost, int hello_interval)
......
...@@ -790,10 +790,16 @@ kernel_routes(int maxplen, struct kernel_route *routes, int maxroutes) ...@@ -790,10 +790,16 @@ kernel_routes(int maxplen, struct kernel_route *routes, int maxroutes)
} }
int int
kernel_callback() kernel_callback(int (*fn)(void*), void *closure)
{ {
int rc;
if(nl_listen.sock < 0) if(nl_listen.sock < 0)
return -1; return -1;
return netlink_listen(monitor_kernel_route, NULL); rc = netlink_listen(monitor_kernel_route, NULL);
if(rc)
return fn(closure);
return 0;
} }
...@@ -42,4 +42,4 @@ int kernel_route(int operation, const unsigned char *dest, unsigned short plen, ...@@ -42,4 +42,4 @@ int kernel_route(int operation, const unsigned char *dest, unsigned short plen,
const unsigned char *gate, int ifindex, const unsigned char *gate, int ifindex,
unsigned int metric, unsigned int newmetric); unsigned int metric, unsigned int newmetric);
int kernel_routes(int maxplen, struct kernel_route *routes, int maxroutes); int kernel_routes(int maxplen, struct kernel_route *routes, int maxroutes);
int kernel_callback(void); int kernel_callback(int (*fn)(void*), void *closure);
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