add updated olsrd fixes and optimizations from sven-ola
[openwrt/svn-archive/archive.git] / net / olsrd / patches / 130-olsrd_fixes.patch
1 diff -Nur olsrd-0.4.10.orig/src/defs.h olsrd-0.4.10/src/defs.h
2 --- olsrd-0.4.10.orig/src/defs.h 2006-01-01 16:59:02.000000000 +0100
3 +++ olsrd-0.4.10/src/defs.h 2006-10-31 19:34:52.000000000 +0100
4 @@ -68,10 +68,10 @@
5 #define OLSRD_GLOBAL_CONF_FILE "/etc/" OLSRD_CONF_FILE_NAME
6 #endif
7
8 -#define HOPCNT_MAX 32 /* maximum hops number */
9 +#define HOPCNT_MAX 64 /* maximum hops number */
10 #define MAXMESSAGESIZE 1500 /* max broadcast size */
11 #define UDP_IPV4_HDRSIZE 28
12 -#define UDP_IPV6_HDRSIZE 48
13 +#define UDP_IPV6_HDRSIZE 62
14 #define MAX_IFS 16
15
16 /* Debug helper macro */
17 diff -Nur olsrd-0.4.10.orig/src/interfaces.h olsrd-0.4.10/src/interfaces.h
18 --- olsrd-0.4.10.orig/src/interfaces.h 2005-06-03 10:00:55.000000000 +0200
19 +++ olsrd-0.4.10/src/interfaces.h 2006-10-31 19:44:52.000000000 +0100
20 @@ -136,6 +136,8 @@
21 struct vtimes valtimes;
22
23 struct if_gen_property *gen_properties;/* Generic interface properties */
24 +
25 + int ttl_index; /* index in TTL array for fish-eye */
26
27 struct interface *int_next;
28 };
29 diff -Nur olsrd-0.4.10.orig/src/link_set.c olsrd-0.4.10/src/link_set.c
30 --- olsrd-0.4.10.orig/src/link_set.c 2005-11-17 05:25:44.000000000 +0100
31 +++ olsrd-0.4.10/src/link_set.c 2006-10-31 19:31:19.000000000 +0100
32 @@ -952,8 +952,9 @@
33
34 entry->loss_link_quality =
35 (float)(entry->total_packets - entry->lost_packets) /
36 - (float)(entry->loss_window_size);
37 -
38 + (float)(entry->loss_window_size < (2 * 4) ? entry->loss_window_size:
39 + 4 * ((entry->loss_window_size / 4 - 1) * entry->total_packets + entry->loss_window_size) / entry->loss_window_size);
40 +
41 // multiply the calculated link quality with the user-specified multiplier
42
43 entry->loss_link_quality *= entry->loss_link_multiplier;
44 diff -Nur olsrd-0.4.10.orig/src/lq_packet.c olsrd-0.4.10/src/lq_packet.c
45 --- olsrd-0.4.10.orig/src/lq_packet.c 2005-11-17 02:58:51.000000000 +0100
46 +++ olsrd-0.4.10/src/lq_packet.c 2006-10-31 21:51:11.000000000 +0100
47 @@ -149,9 +149,8 @@
48 int i;
49 struct neighbor_entry *walker;
50 struct link_entry *link;
51 - static int ttl_list[] = { MAX_TTL, 3, 2, 1, 2, 1, 1, 3, 2, 1, 2, 1, 1, 0 };
52 - static int ttl_index = 0;
53 -
54 + static int ttl_list[] = { 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1, MAX_TTL-1, 0};
55 +
56 // remember that we have generated an LQ TC message; this is
57 // checked in net_output()
58
59 @@ -167,10 +166,13 @@
60
61 if (olsr_cnf->lq_fish > 0)
62 {
63 - if (ttl_list[ttl_index] == 0)
64 - ttl_index = 0;
65 + // SVEN_OLA: Too lazy to find the different iface inits. This will do it too.
66 + if (outif->ttl_index >= sizeof(ttl_list) / sizeof(ttl_list[0])) outif->ttl_index = 0;
67 +
68 + if (ttl_list[outif->ttl_index] == 0)
69 + outif->ttl_index = 0;
70
71 - lq_tc->comm.ttl = ttl_list[ttl_index++];
72 + lq_tc->comm.ttl = ttl_list[outif->ttl_index++];
73
74 OLSR_PRINTF(3, "Creating LQ TC with TTL %d.\n", lq_tc->comm.ttl);
75 }
76 diff -Nur olsrd-0.4.10.orig/src/olsr.c olsrd-0.4.10/src/olsr.c
77 --- olsrd-0.4.10.orig/src/olsr.c 2005-11-17 05:25:44.000000000 +0100
78 +++ olsrd-0.4.10/src/olsr.c 2006-10-31 19:31:19.000000000 +0100
79 @@ -68,6 +68,7 @@
80 olsr_bool changes_topology;
81 olsr_bool changes_neighborhood;
82 olsr_bool changes_hna;
83 +olsr_bool changes_force;
84
85 /**
86 * Process changes functions
87 @@ -142,6 +143,11 @@
88 OLSR_PRINTF(3, "CHANGES IN HNA\n")
89 #endif
90
91 + if(!changes_force &&
92 + 2 <= olsr_cnf->lq_level &&
93 + 0 >= olsr_cnf->lq_dlimit)
94 + return;
95 +
96 if(!changes_neighborhood &&
97 !changes_topology &&
98 !changes_hna)
99 @@ -171,11 +177,6 @@
100 olsr_calculate_routing_table();
101 olsr_calculate_hna_routes();
102 }
103 -
104 - else
105 - {
106 - olsr_calculate_lq_routing_table();
107 - }
108 }
109
110 else if (changes_topology)
111 @@ -187,11 +188,6 @@
112 olsr_calculate_routing_table();
113 olsr_calculate_hna_routes();
114 }
115 -
116 - else
117 - {
118 - olsr_calculate_lq_routing_table();
119 - }
120 }
121
122 else if (changes_hna)
123 @@ -202,11 +198,11 @@
124 {
125 olsr_calculate_hna_routes();
126 }
127 -
128 - else
129 - {
130 - olsr_calculate_lq_routing_table();
131 - }
132 + }
133 +
134 + if (olsr_cnf->lq_level >= 2)
135 + {
136 + olsr_calculate_lq_routing_table();
137 }
138
139 if (olsr_cnf->debug_level > 0)
140 @@ -239,6 +235,7 @@
141 changes_neighborhood = OLSR_FALSE;
142 changes_topology = OLSR_FALSE;
143 changes_hna = OLSR_FALSE;
144 + changes_force = OLSR_FALSE;
145
146
147 return;
148 diff -Nur olsrd-0.4.10.orig/src/olsr.h olsrd-0.4.10/src/olsr.h
149 --- olsrd-0.4.10.orig/src/olsr.h 2005-05-29 14:47:45.000000000 +0200
150 +++ olsrd-0.4.10/src/olsr.h 2006-10-31 19:31:19.000000000 +0100
151 @@ -49,6 +49,7 @@
152 extern olsr_bool changes_topology;
153 extern olsr_bool changes_neighborhood;
154 extern olsr_bool changes_hna;
155 +extern olsr_bool changes_force;
156
157 void
158 register_pcf(int (*)(int, int, int));
159 diff -Nur olsrd-0.4.10.orig/src/scheduler.c olsrd-0.4.10/src/scheduler.c
160 --- olsrd-0.4.10.orig/src/scheduler.c 2005-12-29 23:34:37.000000000 +0100
161 +++ olsrd-0.4.10/src/scheduler.c 2006-10-31 19:31:19.000000000 +0100
162 @@ -70,6 +70,7 @@
163
164 changes_neighborhood = OLSR_TRUE;
165 changes_topology = OLSR_TRUE;
166 + changes_force = OLSR_TRUE;
167 }
168
169 /**
170 diff -Nur olsrd-0.4.10.orig/src/unix/ifnet.c olsrd-0.4.10/src/unix/ifnet.c
171 --- olsrd-0.4.10.orig/src/unix/ifnet.c 2005-12-29 19:37:16.000000000 +0100
172 +++ olsrd-0.4.10/src/unix/ifnet.c 2006-10-31 21:44:59.000000000 +0100
173 @@ -689,6 +689,17 @@
174 return 1;
175 }
176
177 +static char basename[32];
178 +char* if_basename(char* name);
179 +char* if_basename(char* name)
180 +{
181 + char *p = strchr(name, ':');
182 + if (0 == p || p - name >= (int)(sizeof(basename) / sizeof(basename[0]) - 1)) return name;
183 + memcpy(basename, name, p - name);
184 + basename[p - name] = 0;
185 + return basename;
186 +}
187 +
188 /**
189 * Initializes a interface described by iface,
190 * if it is set up and is of the correct type.
191 @@ -832,10 +843,10 @@
192 }
193
194 /* Deactivate IP spoof filter */
195 - deactivate_spoof(ifr.ifr_name, iface->index, olsr_cnf->ip_version);
196 + deactivate_spoof(if_basename(ifr.ifr_name), iface->index, olsr_cnf->ip_version);
197
198 /* Disable ICMP redirects */
199 - disable_redirects(ifr.ifr_name, iface->index, olsr_cnf->ip_version);
200 + disable_redirects(if_basename(ifr.ifr_name), iface->index, olsr_cnf->ip_version);
201
202 }
203
204 @@ -894,7 +907,7 @@
205 ifp->gen_properties = NULL;
206 ifp->int_name = olsr_malloc(strlen(ifr.ifr_name) + 1, "Interface update 3");
207
208 - strcpy(ifp->int_name, ifr.ifr_name);
209 + strcpy(ifp->int_name, if_basename(ifr.ifr_name));
210 /* Segfaults if using strncpy(IFNAMSIZ) why oh why?? */
211 ifp->int_next = ifnet;
212 ifnet = ifp;