aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/send.c
diff options
context:
space:
mode:
authorMarek Lindner <lindner_marek@yahoo.de>2011-07-29 11:31:50 -0400
committerMarek Lindner <lindner_marek@yahoo.de>2011-09-08 11:37:51 -0400
commitb6da4bf5d7951aba4f86d65546474c4e718f650f (patch)
tree960ba68ea86c341ec938178f9c27a09cf151861c /net/batman-adv/send.c
parenta943cac144e035c21d4f1b31b95f15b33c33a480 (diff)
batman-adv: rename all instances of batman_packet to batman_ogm_packet
The follow-up routing code changes are going to introduce additional routing packet types which make this distinction necessary. Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv/send.c')
-rw-r--r--net/batman-adv/send.c130
1 files changed, 67 insertions, 63 deletions
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index 57ae80936911..40a5fcd67136 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -107,7 +107,7 @@ static void send_packet_to_if(struct forw_packet *forw_packet,
107 char *fwd_str; 107 char *fwd_str;
108 uint8_t packet_num; 108 uint8_t packet_num;
109 int16_t buff_pos; 109 int16_t buff_pos;
110 struct batman_packet *batman_packet; 110 struct batman_ogm_packet *batman_ogm_packet;
111 struct sk_buff *skb; 111 struct sk_buff *skb;
112 112
113 if (hard_iface->if_status != IF_ACTIVE) 113 if (hard_iface->if_status != IF_ACTIVE)
@@ -115,20 +115,20 @@ static void send_packet_to_if(struct forw_packet *forw_packet,
115 115
116 packet_num = 0; 116 packet_num = 0;
117 buff_pos = 0; 117 buff_pos = 0;
118 batman_packet = (struct batman_packet *)forw_packet->skb->data; 118 batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data;
119 119
120 /* adjust all flags and log packets */ 120 /* adjust all flags and log packets */
121 while (aggregated_packet(buff_pos, 121 while (aggregated_packet(buff_pos,
122 forw_packet->packet_len, 122 forw_packet->packet_len,
123 batman_packet->tt_num_changes)) { 123 batman_ogm_packet->tt_num_changes)) {
124 124
125 /* we might have aggregated direct link packets with an 125 /* we might have aggregated direct link packets with an
126 * ordinary base packet */ 126 * ordinary base packet */
127 if ((forw_packet->direct_link_flags & (1 << packet_num)) && 127 if ((forw_packet->direct_link_flags & (1 << packet_num)) &&
128 (forw_packet->if_incoming == hard_iface)) 128 (forw_packet->if_incoming == hard_iface))
129 batman_packet->flags |= DIRECTLINK; 129 batman_ogm_packet->flags |= DIRECTLINK;
130 else 130 else
131 batman_packet->flags &= ~DIRECTLINK; 131 batman_ogm_packet->flags &= ~DIRECTLINK;
132 132
133 fwd_str = (packet_num > 0 ? "Forwarding" : (forw_packet->own ? 133 fwd_str = (packet_num > 0 ? "Forwarding" : (forw_packet->own ?
134 "Sending own" : 134 "Sending own" :
@@ -137,18 +137,19 @@ static void send_packet_to_if(struct forw_packet *forw_packet,
137 "%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d," 137 "%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d,"
138 " IDF %s, ttvn %d) on interface %s [%pM]\n", 138 " IDF %s, ttvn %d) on interface %s [%pM]\n",
139 fwd_str, (packet_num > 0 ? "aggregated " : ""), 139 fwd_str, (packet_num > 0 ? "aggregated " : ""),
140 batman_packet->orig, ntohl(batman_packet->seqno), 140 batman_ogm_packet->orig,
141 batman_packet->tq, batman_packet->ttl, 141 ntohl(batman_ogm_packet->seqno),
142 (batman_packet->flags & DIRECTLINK ? 142 batman_ogm_packet->tq, batman_ogm_packet->ttl,
143 (batman_ogm_packet->flags & DIRECTLINK ?
143 "on" : "off"), 144 "on" : "off"),
144 batman_packet->ttvn, hard_iface->net_dev->name, 145 batman_ogm_packet->ttvn, hard_iface->net_dev->name,
145 hard_iface->net_dev->dev_addr); 146 hard_iface->net_dev->dev_addr);
146 147
147 buff_pos += sizeof(*batman_packet) + 148 buff_pos += BATMAN_OGM_LEN +
148 tt_len(batman_packet->tt_num_changes); 149 tt_len(batman_ogm_packet->tt_num_changes);
149 packet_num++; 150 packet_num++;
150 batman_packet = (struct batman_packet *) 151 batman_ogm_packet = (struct batman_ogm_packet *)
151 (forw_packet->skb->data + buff_pos); 152 (forw_packet->skb->data + buff_pos);
152 } 153 }
153 154
154 /* create clone because function is called more than once */ 155 /* create clone because function is called more than once */
@@ -164,9 +165,11 @@ static void send_packet(struct forw_packet *forw_packet)
164 struct net_device *soft_iface; 165 struct net_device *soft_iface;
165 struct bat_priv *bat_priv; 166 struct bat_priv *bat_priv;
166 struct hard_iface *primary_if = NULL; 167 struct hard_iface *primary_if = NULL;
167 struct batman_packet *batman_packet = 168 struct batman_ogm_packet *batman_ogm_packet =
168 (struct batman_packet *)(forw_packet->skb->data); 169 (struct batman_ogm_packet *)(forw_packet->skb->data);
169 int directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0); 170 unsigned char directlink;
171
172 directlink = (batman_ogm_packet->flags & DIRECTLINK ? 1 : 0);
170 173
171 if (!forw_packet->if_incoming) { 174 if (!forw_packet->if_incoming) {
172 pr_err("Error - can't forward packet: incoming iface not " 175 pr_err("Error - can't forward packet: incoming iface not "
@@ -186,7 +189,7 @@ static void send_packet(struct forw_packet *forw_packet)
186 189
187 /* multihomed peer assumed */ 190 /* multihomed peer assumed */
188 /* non-primary OGMs are only broadcasted on their interface */ 191 /* non-primary OGMs are only broadcasted on their interface */
189 if ((directlink && (batman_packet->ttl == 1)) || 192 if ((directlink && (batman_ogm_packet->ttl == 1)) ||
190 (forw_packet->own && (forw_packet->if_incoming != primary_if))) { 193 (forw_packet->own && (forw_packet->if_incoming != primary_if))) {
191 194
192 /* FIXME: what about aggregated packets ? */ 195 /* FIXME: what about aggregated packets ? */
@@ -194,8 +197,9 @@ static void send_packet(struct forw_packet *forw_packet)
194 "%s packet (originator %pM, seqno %d, TTL %d) " 197 "%s packet (originator %pM, seqno %d, TTL %d) "
195 "on interface %s [%pM]\n", 198 "on interface %s [%pM]\n",
196 (forw_packet->own ? "Sending own" : "Forwarding"), 199 (forw_packet->own ? "Sending own" : "Forwarding"),
197 batman_packet->orig, ntohl(batman_packet->seqno), 200 batman_ogm_packet->orig,
198 batman_packet->ttl, 201 ntohl(batman_ogm_packet->seqno),
202 batman_ogm_packet->ttl,
199 forw_packet->if_incoming->net_dev->name, 203 forw_packet->if_incoming->net_dev->name,
200 forw_packet->if_incoming->net_dev->dev_addr); 204 forw_packet->if_incoming->net_dev->dev_addr);
201 205
@@ -223,17 +227,16 @@ out:
223} 227}
224 228
225static void realloc_packet_buffer(struct hard_iface *hard_iface, 229static void realloc_packet_buffer(struct hard_iface *hard_iface,
226 int new_len) 230 int new_len)
227{ 231{
228 unsigned char *new_buff; 232 unsigned char *new_buff;
229 struct batman_packet *batman_packet;
230 233
231 new_buff = kmalloc(new_len, GFP_ATOMIC); 234 new_buff = kmalloc(new_len, GFP_ATOMIC);
232 235
233 /* keep old buffer if kmalloc should fail */ 236 /* keep old buffer if kmalloc should fail */
234 if (new_buff) { 237 if (new_buff) {
235 memcpy(new_buff, hard_iface->packet_buff, 238 memcpy(new_buff, hard_iface->packet_buff,
236 sizeof(*batman_packet)); 239 BATMAN_OGM_LEN);
237 240
238 kfree(hard_iface->packet_buff); 241 kfree(hard_iface->packet_buff);
239 hard_iface->packet_buff = new_buff; 242 hard_iface->packet_buff = new_buff;
@@ -246,39 +249,39 @@ static void prepare_packet_buffer(struct bat_priv *bat_priv,
246 struct hard_iface *hard_iface) 249 struct hard_iface *hard_iface)
247{ 250{
248 int new_len; 251 int new_len;
249 struct batman_packet *batman_packet; 252 struct batman_ogm_packet *batman_ogm_packet;
250 253
251 new_len = BAT_PACKET_LEN + 254 new_len = BATMAN_OGM_LEN +
252 tt_len((uint8_t)atomic_read(&bat_priv->tt_local_changes)); 255 tt_len((uint8_t)atomic_read(&bat_priv->tt_local_changes));
253 256
254 /* if we have too many changes for one packet don't send any 257 /* if we have too many changes for one packet don't send any
255 * and wait for the tt table request which will be fragmented */ 258 * and wait for the tt table request which will be fragmented */
256 if (new_len > hard_iface->soft_iface->mtu) 259 if (new_len > hard_iface->soft_iface->mtu)
257 new_len = BAT_PACKET_LEN; 260 new_len = BATMAN_OGM_LEN;
258 261
259 realloc_packet_buffer(hard_iface, new_len); 262 realloc_packet_buffer(hard_iface, new_len);
260 batman_packet = (struct batman_packet *)hard_iface->packet_buff; 263 batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff;
261 264
262 atomic_set(&bat_priv->tt_crc, tt_local_crc(bat_priv)); 265 atomic_set(&bat_priv->tt_crc, tt_local_crc(bat_priv));
263 266
264 /* reset the sending counter */ 267 /* reset the sending counter */
265 atomic_set(&bat_priv->tt_ogm_append_cnt, TT_OGM_APPEND_MAX); 268 atomic_set(&bat_priv->tt_ogm_append_cnt, TT_OGM_APPEND_MAX);
266 269
267 batman_packet->tt_num_changes = tt_changes_fill_buffer(bat_priv, 270 batman_ogm_packet->tt_num_changes = tt_changes_fill_buffer(bat_priv,
268 hard_iface->packet_buff + BAT_PACKET_LEN, 271 hard_iface->packet_buff + BATMAN_OGM_LEN,
269 hard_iface->packet_len - BAT_PACKET_LEN); 272 hard_iface->packet_len - BATMAN_OGM_LEN);
270 273
271} 274}
272 275
273static void reset_packet_buffer(struct bat_priv *bat_priv, 276static void reset_packet_buffer(struct bat_priv *bat_priv,
274 struct hard_iface *hard_iface) 277 struct hard_iface *hard_iface)
275{ 278{
276 struct batman_packet *batman_packet; 279 struct batman_ogm_packet *batman_ogm_packet;
277 280
278 realloc_packet_buffer(hard_iface, BAT_PACKET_LEN); 281 realloc_packet_buffer(hard_iface, BATMAN_OGM_LEN);
279 282
280 batman_packet = (struct batman_packet *)hard_iface->packet_buff; 283 batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff;
281 batman_packet->tt_num_changes = 0; 284 batman_ogm_packet->tt_num_changes = 0;
282} 285}
283 286
284void schedule_own_packet(struct hard_iface *hard_iface) 287void schedule_own_packet(struct hard_iface *hard_iface)
@@ -286,7 +289,7 @@ void schedule_own_packet(struct hard_iface *hard_iface)
286 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 289 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
287 struct hard_iface *primary_if; 290 struct hard_iface *primary_if;
288 unsigned long send_time; 291 unsigned long send_time;
289 struct batman_packet *batman_packet; 292 struct batman_ogm_packet *batman_ogm_packet;
290 int vis_server; 293 int vis_server;
291 294
292 if ((hard_iface->if_status == IF_NOT_IN_USE) || 295 if ((hard_iface->if_status == IF_NOT_IN_USE) ||
@@ -322,26 +325,27 @@ void schedule_own_packet(struct hard_iface *hard_iface)
322 * NOTE: packet_buff might just have been re-allocated in 325 * NOTE: packet_buff might just have been re-allocated in
323 * prepare_packet_buffer() or in reset_packet_buffer() 326 * prepare_packet_buffer() or in reset_packet_buffer()
324 */ 327 */
325 batman_packet = (struct batman_packet *)hard_iface->packet_buff; 328 batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff;
326 329
327 /* change sequence number to network order */ 330 /* change sequence number to network order */
328 batman_packet->seqno = 331 batman_ogm_packet->seqno =
329 htonl((uint32_t)atomic_read(&hard_iface->seqno)); 332 htonl((uint32_t)atomic_read(&hard_iface->seqno));
330 333
331 batman_packet->ttvn = atomic_read(&bat_priv->ttvn); 334 batman_ogm_packet->ttvn = atomic_read(&bat_priv->ttvn);
332 batman_packet->tt_crc = htons((uint16_t)atomic_read(&bat_priv->tt_crc)); 335 batman_ogm_packet->tt_crc = htons((uint16_t)
336 atomic_read(&bat_priv->tt_crc));
333 337
334 if (vis_server == VIS_TYPE_SERVER_SYNC) 338 if (vis_server == VIS_TYPE_SERVER_SYNC)
335 batman_packet->flags |= VIS_SERVER; 339 batman_ogm_packet->flags |= VIS_SERVER;
336 else 340 else
337 batman_packet->flags &= ~VIS_SERVER; 341 batman_ogm_packet->flags &= ~VIS_SERVER;
338 342
339 if ((hard_iface == primary_if) && 343 if ((hard_iface == primary_if) &&
340 (atomic_read(&bat_priv->gw_mode) == GW_MODE_SERVER)) 344 (atomic_read(&bat_priv->gw_mode) == GW_MODE_SERVER))
341 batman_packet->gw_flags = 345 batman_ogm_packet->gw_flags =
342 (uint8_t)atomic_read(&bat_priv->gw_bandwidth); 346 (uint8_t)atomic_read(&bat_priv->gw_bandwidth);
343 else 347 else
344 batman_packet->gw_flags = NO_FLAGS; 348 batman_ogm_packet->gw_flags = NO_FLAGS;
345 349
346 atomic_inc(&hard_iface->seqno); 350 atomic_inc(&hard_iface->seqno);
347 351
@@ -358,7 +362,7 @@ void schedule_own_packet(struct hard_iface *hard_iface)
358 362
359void schedule_forward_packet(struct orig_node *orig_node, 363void schedule_forward_packet(struct orig_node *orig_node,
360 const struct ethhdr *ethhdr, 364 const struct ethhdr *ethhdr,
361 struct batman_packet *batman_packet, 365 struct batman_ogm_packet *batman_ogm_packet,
362 int directlink, 366 int directlink,
363 struct hard_iface *if_incoming) 367 struct hard_iface *if_incoming)
364{ 368{
@@ -368,19 +372,19 @@ void schedule_forward_packet(struct orig_node *orig_node,
368 unsigned long send_time; 372 unsigned long send_time;
369 uint8_t tt_num_changes; 373 uint8_t tt_num_changes;
370 374
371 if (batman_packet->ttl <= 1) { 375 if (batman_ogm_packet->ttl <= 1) {
372 bat_dbg(DBG_BATMAN, bat_priv, "ttl exceeded\n"); 376 bat_dbg(DBG_BATMAN, bat_priv, "ttl exceeded\n");
373 return; 377 return;
374 } 378 }
375 379
376 router = orig_node_get_router(orig_node); 380 router = orig_node_get_router(orig_node);
377 381
378 in_tq = batman_packet->tq; 382 in_tq = batman_ogm_packet->tq;
379 in_ttl = batman_packet->ttl; 383 in_ttl = batman_ogm_packet->ttl;
380 tt_num_changes = batman_packet->tt_num_changes; 384 tt_num_changes = batman_ogm_packet->tt_num_changes;
381 385
382 batman_packet->ttl--; 386 batman_ogm_packet->ttl--;
383 memcpy(batman_packet->prev_sender, ethhdr->h_source, ETH_ALEN); 387 memcpy(batman_ogm_packet->prev_sender, ethhdr->h_source, ETH_ALEN);
384 388
385 /* rebroadcast tq of our best ranking neighbor to ensure the rebroadcast 389 /* rebroadcast tq of our best ranking neighbor to ensure the rebroadcast
386 * of our best tq value */ 390 * of our best tq value */
@@ -388,10 +392,10 @@ void schedule_forward_packet(struct orig_node *orig_node,
388 392
389 /* rebroadcast ogm of best ranking neighbor as is */ 393 /* rebroadcast ogm of best ranking neighbor as is */
390 if (!compare_eth(router->addr, ethhdr->h_source)) { 394 if (!compare_eth(router->addr, ethhdr->h_source)) {
391 batman_packet->tq = router->tq_avg; 395 batman_ogm_packet->tq = router->tq_avg;
392 396
393 if (router->last_ttl) 397 if (router->last_ttl)
394 batman_packet->ttl = router->last_ttl - 1; 398 batman_ogm_packet->ttl = router->last_ttl - 1;
395 } 399 }
396 400
397 tq_avg = router->tq_avg; 401 tq_avg = router->tq_avg;
@@ -401,28 +405,28 @@ void schedule_forward_packet(struct orig_node *orig_node,
401 neigh_node_free_ref(router); 405 neigh_node_free_ref(router);
402 406
403 /* apply hop penalty */ 407 /* apply hop penalty */
404 batman_packet->tq = hop_penalty(batman_packet->tq, bat_priv); 408 batman_ogm_packet->tq = hop_penalty(batman_ogm_packet->tq, bat_priv);
405 409
406 bat_dbg(DBG_BATMAN, bat_priv, 410 bat_dbg(DBG_BATMAN, bat_priv,
407 "Forwarding packet: tq_orig: %i, tq_avg: %i, " 411 "Forwarding packet: tq_orig: %i, tq_avg: %i, "
408 "tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n", 412 "tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n",
409 in_tq, tq_avg, batman_packet->tq, in_ttl - 1, 413 in_tq, tq_avg, batman_ogm_packet->tq, in_ttl - 1,
410 batman_packet->ttl); 414 batman_ogm_packet->ttl);
411 415
412 batman_packet->seqno = htonl(batman_packet->seqno); 416 batman_ogm_packet->seqno = htonl(batman_ogm_packet->seqno);
413 batman_packet->tt_crc = htons(batman_packet->tt_crc); 417 batman_ogm_packet->tt_crc = htons(batman_ogm_packet->tt_crc);
414 418
415 /* switch of primaries first hop flag when forwarding */ 419 /* switch of primaries first hop flag when forwarding */
416 batman_packet->flags &= ~PRIMARIES_FIRST_HOP; 420 batman_ogm_packet->flags &= ~PRIMARIES_FIRST_HOP;
417 if (directlink) 421 if (directlink)
418 batman_packet->flags |= DIRECTLINK; 422 batman_ogm_packet->flags |= DIRECTLINK;
419 else 423 else
420 batman_packet->flags &= ~DIRECTLINK; 424 batman_ogm_packet->flags &= ~DIRECTLINK;
421 425
422 send_time = forward_send_time(); 426 send_time = forward_send_time();
423 add_bat_packet_to_list(bat_priv, 427 add_bat_packet_to_list(bat_priv,
424 (unsigned char *)batman_packet, 428 (unsigned char *)batman_ogm_packet,
425 sizeof(*batman_packet) + tt_len(tt_num_changes), 429 BATMAN_OGM_LEN + tt_len(tt_num_changes),
426 if_incoming, 0, send_time); 430 if_incoming, 0, send_time);
427} 431}
428 432