Author: marek
Date: 2006-12-06 02:25:43 +0000 (Wed, 06 Dec 2006)
New Revision: 143
Modified:
trunk/batman/batman.c
Log:
- fix crashes in schedule_forward_packet && send_outstanding_packets
Modified: trunk/batman/batman.c
===================================================================
--- trunk/batman/batman.c 2006-12-06 01:49:21 UTC (rev 142)
+++ trunk/batman/batman.c 2006-12-06 02:25:43 UTC (rev 143)
@@ -790,42 +790,42 @@
output( "ttl exceeded \n" );
} else {
- forw_node_new = alloc_memory(sizeof (struct forw_node));
- INIT_LIST_HEAD(&forw_node_new->list);
+ /* list_for_each(forw_pos, &forw_list) {
+ forw_node = list_entry(forw_pos, struct forw_node, list);
+ if ((int)(forw_node->when - forw_node_new->when) > 0)
+ break;
+ } */
- memcpy(&forw_node_new->pack, in, sizeof (struct packet));
+ if ( unidirectional ) {
- forw_node_new->pack.ttl--;
- forw_node_new->when = get_time();
+ forw_node_new = alloc_memory(sizeof (struct forw_node));
+ INIT_LIST_HEAD(&forw_node_new->list);
- if ( hna_buff_len > 0 ) {
+ memcpy(&forw_node_new->pack, in, sizeof (struct packet));
- forw_node_new->hna_buff = alloc_memory( hna_buff_len );
- forw_node_new->hna_buff_len = hna_buff_len;
+ forw_node_new->pack.ttl--;
+ forw_node_new->when = get_time();
- memcpy( forw_node_new->hna_buff, hna_recv_buff, hna_buff_len );
+ if ( hna_buff_len > 0 ) {
- } else {
+ forw_node_new->hna_buff = alloc_memory( hna_buff_len );
+ forw_node_new->hna_buff_len = hna_buff_len;
- forw_node_new->hna_buff = NULL;
- forw_node_new->hna_buff_len = 0;
+ memcpy( forw_node_new->hna_buff, hna_recv_buff, hna_buff_len );
- }
+ } else {
- list_for_each(forw_pos, &forw_list) {
- forw_node = list_entry(forw_pos, struct forw_node, list);
- if ((int)(forw_node->when - forw_node_new->when) > 0)
- break;
- }
+ forw_node_new->hna_buff = NULL;
+ forw_node_new->hna_buff_len = 0;
- if ( unidirectional ) {
+ }
forw_node_new->pack.flags = ( UNIDIRECTIONAL | DIRECTLINK );
if ( if_outgoing != NULL ) {
forw_node_new->if_outgoing = if_outgoing;
- list_add( &forw_node_new->list, (forw_node == NULL ? &forw_list : forw_pos) );
+ list_add( &forw_node_new->list, /* ( forw_node == NULL ? &forw_list : forw_pos )*/ &forw_list );
} else {
@@ -845,13 +845,35 @@
batman_if = list_entry(if_pos, struct batman_if, list);
+ forw_node_new = alloc_memory(sizeof (struct forw_node));
+ INIT_LIST_HEAD(&forw_node_new->list);
+
+ memcpy(&forw_node_new->pack, in, sizeof (struct packet));
+
+ forw_node_new->pack.ttl--;
+ forw_node_new->when = get_time();
+
+ if ( hna_buff_len > 0 ) {
+
+ forw_node_new->hna_buff = alloc_memory( hna_buff_len );
+ forw_node_new->hna_buff_len = hna_buff_len;
+
+ memcpy( forw_node_new->hna_buff, hna_recv_buff, hna_buff_len );
+
+ } else {
+
+ forw_node_new->hna_buff = NULL;
+ forw_node_new->hna_buff_len = 0;
+
+ }
+
if ( ( direct_link ) && ( if_outgoing == batman_if ) )
forw_node_new->pack.flags = DIRECTLINK;
else
forw_node_new->pack.flags = 0x00;
forw_node_new->if_outgoing = batman_if;
- list_add( &forw_node_new->list, (forw_node == NULL ? &forw_list : forw_pos) );
+ list_add( &forw_node_new->list, &forw_list );
}
@@ -892,8 +914,8 @@
}
if ( debug_level == 4 ) {
- addr_to_string(forw_node->pack.orig, orig_str, ADDR_STR_LEN);
- output("Forwarding packet (originator %s, seqno %d, TTL %d)\n", orig_str, forw_node->pack.seqno, forw_node->pack.ttl);
+ addr_to_string( forw_node->pack.orig, orig_str, ADDR_STR_LEN );
+ output( "Forwarding packet (originator %s, seqno %d, TTL %d) on interface %s\n", orig_str, forw_node->pack.seqno, forw_node->pack.ttl, forw_node->if_outgoing->dev );
}
if ( send_packet( send_buff, sizeof (struct packet) + forw_node->hna_buff_len, &forw_node->if_outgoing->broad, forw_node->if_outgoing->udp_send_sock ) < 0 ) {