Commit a2c5c220 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Add support for listening on kernel sockets.

parent 93d30327
...@@ -71,6 +71,7 @@ char *state_file = "/var/lib/babel-state"; ...@@ -71,6 +71,7 @@ char *state_file = "/var/lib/babel-state";
int protocol_port; int protocol_port;
unsigned char protocol_group[16]; unsigned char protocol_group[16];
int protocol_socket = -1; int protocol_socket = -1;
int kernel_socket = -1;
static volatile sig_atomic_t exiting = 0, dumping = 0; static volatile sig_atomic_t exiting = 0, dumping = 0;
...@@ -389,7 +390,10 @@ main(int argc, char **argv) ...@@ -389,7 +390,10 @@ main(int argc, char **argv)
if(timeval_compare(&tv, &now) > 0) { if(timeval_compare(&tv, &now) > 0) {
timeval_minus(&tv, &tv, &now); timeval_minus(&tv, &tv, &now);
FD_SET(protocol_socket, &readfds); FD_SET(protocol_socket, &readfds);
rc = select(protocol_socket + 1, &readfds, NULL, NULL, &tv); if(kernel_socket >= 0)
FD_SET(kernel_socket, &readfds);
rc = select(MAX(protocol_socket, kernel_socket) + 1,
&readfds, NULL, NULL, &tv);
if(rc < 0 && errno != EINTR) { if(rc < 0 && errno != EINTR) {
perror("select"); perror("select");
sleep(1); sleep(1);
...@@ -402,6 +406,10 @@ main(int argc, char **argv) ...@@ -402,6 +406,10 @@ main(int argc, char **argv)
if(exiting) if(exiting)
break; break;
if(kernel_socket >= 0 && FD_ISSET(kernel_socket, &readfds)) {
kernel_callback();
}
if(FD_ISSET(protocol_socket, &readfds)) { if(FD_ISSET(protocol_socket, &readfds)) {
rc = babel_recv(protocol_socket, buf, maxmtu, rc = babel_recv(protocol_socket, buf, maxmtu,
(struct sockaddr*)&sin6, sizeof(sin6)); (struct sockaddr*)&sin6, sizeof(sin6));
......
...@@ -30,6 +30,10 @@ THE SOFTWARE. ...@@ -30,6 +30,10 @@ THE SOFTWARE.
#define INFINITY ((unsigned short)(~0)) #define INFINITY ((unsigned short)(~0))
#ifndef RTPROT_BABEL
#define RTPROT_BABEL 42
#endif
#undef MAX #undef MAX
#undef MIN #undef MIN
...@@ -90,3 +94,4 @@ extern int numnets; ...@@ -90,3 +94,4 @@ extern int numnets;
extern int protocol_port; extern int protocol_port;
extern unsigned char protocol_group[16]; extern unsigned char protocol_group[16];
extern int protocol_socket; extern int protocol_socket;
extern int kernel_socket;
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