The following commit has been merged in the master branch: commit 78ccf9b3afff1caddd983fc9a27f3cb158c99f77 Author: Marek Lindner lindner_marek@yahoo.de Date: Thu Dec 14 12:08:27 2006 +0100
rp_filter patch for interface aliases
diff --git a/batman.h b/batman.h index 5355996..60ba2ae 100644 --- a/batman.h +++ b/batman.h @@ -142,7 +142,7 @@ struct batman_if int tcp_gw_sock; int tunnel_sock; int if_num; - int if_rp_filter_old; + int if_rp_filter_old; pthread_t listen_thread_id; struct sockaddr_in addr; struct sockaddr_in broad; diff --git a/linux.c b/linux.c index 937b097..8c94814 100644 --- a/linux.c +++ b/linux.c @@ -45,22 +45,34 @@ void set_rp_filter(int state, char* dev) { FILE *f; - char filename[100]; - sprintf( filename, "/proc/sys/net/ipv4/conf/%s/rp_filter", dev); + char filename[100], *colon_ptr; + + /* if given interface is an alias use parent interface */ + if ( ( colon_ptr = strchr( dev, ':' ) ) != NULL ) + *colon_ptr = '\0';
+ sprintf( filename, "/proc/sys/net/ipv4/conf/%s/rp_filter", dev);
if((f = fopen(filename, "w")) == NULL) return;
fprintf(f, "%d", state); fclose(f); + + if ( colon_ptr != NULL ) + *colon_ptr = ':'; }
int get_rp_filter(char *dev) { FILE *f; int state = 0; - char filename[100]; + char filename[100], *colon_ptr; + + /* if given interface is an alias use parent interface */ + if ( ( colon_ptr = strchr( dev, ':' ) ) != NULL ) + *colon_ptr = '\0'; + sprintf( filename, "/proc/sys/net/ipv4/conf/%s/rp_filter", dev);
if((f = fopen(filename, "r")) == NULL) @@ -69,6 +81,9 @@ int get_rp_filter(char *dev) fscanf(f, "%d", &state); fclose(f);
+ if ( colon_ptr != NULL ) + *colon_ptr = ':'; + return state; }
diff --git a/posix.c b/posix.c index 3287fb0..e636c28 100644 --- a/posix.c +++ b/posix.c @@ -1148,44 +1148,6 @@ int main(int argc, char *argv[])
}
- - /* FIXME: does that help ? - socklen_t get_len; - int get_value; - get_len = sizeof (get_value); - if ( getsockopt( batman_if->udp_recv_sock, SOL_SOCKET, SO_RCVBUF, &get_value, &get_len ) < 0 ) { - - do_log( "Error - can't get socket option: %s\n", strerror(errno) ); - close_all_sockets(); - exit(EXIT_FAILURE); - - } - - printf( "receive buffer (%s): %i (before)\n", batman_if->dev, get_value ); - - get_value = get_value * 2; - - if ( setsockopt( batman_if->udp_recv_sock, SOL_SOCKET, SO_RCVBUF, &get_value, sizeof (int) ) < 0 ) { - - do_log( "Error - can't set recv buffer size: %s\n", strerror(errno) ); - close_all_sockets(); - exit(EXIT_FAILURE); - - } - - if ( getsockopt( batman_if->udp_recv_sock, SOL_SOCKET, SO_RCVBUF, &get_value, &get_len ) < 0 ) { - - do_log( "Error - can't get socket option: %s\n", strerror(errno) ); - close_all_sockets(); - exit(EXIT_FAILURE); - - } - - printf( "receive buffer (%s): %i (now)\n", batman_if->dev, get_value ); - - */ - - memset(&int_req, 0, sizeof (struct ifreq)); strncpy(int_req.ifr_name, batman_if->dev, IFNAMSIZ - 1);