aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2012-06-05 16:31:30 -0400
committerAntonio Quartulli <ordex@autistici.org>2012-07-01 16:47:21 -0400
commit96412690116afcc1b2705615b5a7c8dc6c5e905f (patch)
tree0eb2a1a557e2997175b27f3ab925bbdc29ece54d
parentb4d66b877bc21ce907938bfd027dfe016617fac0 (diff)
batman-adv: Prefix packet structs with batadv_
Reported-by: Martin Hundebøll <martin@hundeboll.net> Signed-off-by: Sven Eckelmann <sven@narfation.org>
-rw-r--r--net/batman-adv/bat_iv_ogm.c258
-rw-r--r--net/batman-adv/bridge_loop_avoidance.c12
-rw-r--r--net/batman-adv/bridge_loop_avoidance.h4
-rw-r--r--net/batman-adv/hard-interface.c4
-rw-r--r--net/batman-adv/icmp_socket.c22
-rw-r--r--net/batman-adv/icmp_socket.h2
-rw-r--r--net/batman-adv/main.c10
-rw-r--r--net/batman-adv/packet.h44
-rw-r--r--net/batman-adv/routing.c88
-rw-r--r--net/batman-adv/routing.h2
-rw-r--r--net/batman-adv/send.c4
-rw-r--r--net/batman-adv/soft-interface.c4
-rw-r--r--net/batman-adv/translation-table.c119
-rw-r--r--net/batman-adv/translation-table.h4
-rw-r--r--net/batman-adv/types.h10
-rw-r--r--net/batman-adv/unicast.c38
-rw-r--r--net/batman-adv/unicast.h6
-rw-r--r--net/batman-adv/vis.c81
-rw-r--r--net/batman-adv/vis.h4
19 files changed, 369 insertions, 347 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index f9981e608c13..a2bafd9e4fb7 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -56,7 +56,7 @@ out:
56 56
57static int batadv_iv_ogm_iface_enable(struct hard_iface *hard_iface) 57static int batadv_iv_ogm_iface_enable(struct hard_iface *hard_iface)
58{ 58{
59 struct batman_ogm_packet *batman_ogm_packet; 59 struct batadv_ogm_packet *batadv_ogm_packet;
60 uint32_t random_seqno; 60 uint32_t random_seqno;
61 int res = -ENOMEM; 61 int res = -ENOMEM;
62 62
@@ -70,14 +70,14 @@ static int batadv_iv_ogm_iface_enable(struct hard_iface *hard_iface)
70 if (!hard_iface->packet_buff) 70 if (!hard_iface->packet_buff)
71 goto out; 71 goto out;
72 72
73 batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; 73 batadv_ogm_packet = (struct batadv_ogm_packet *)hard_iface->packet_buff;
74 batman_ogm_packet->header.packet_type = BATADV_IV_OGM; 74 batadv_ogm_packet->header.packet_type = BATADV_IV_OGM;
75 batman_ogm_packet->header.version = BATADV_COMPAT_VERSION; 75 batadv_ogm_packet->header.version = BATADV_COMPAT_VERSION;
76 batman_ogm_packet->header.ttl = 2; 76 batadv_ogm_packet->header.ttl = 2;
77 batman_ogm_packet->flags = BATADV_NO_FLAGS; 77 batadv_ogm_packet->flags = BATADV_NO_FLAGS;
78 batman_ogm_packet->tq = BATADV_TQ_MAX_VALUE; 78 batadv_ogm_packet->tq = BATADV_TQ_MAX_VALUE;
79 batman_ogm_packet->tt_num_changes = 0; 79 batadv_ogm_packet->tt_num_changes = 0;
80 batman_ogm_packet->ttvn = 0; 80 batadv_ogm_packet->ttvn = 0;
81 81
82 res = 0; 82 res = 0;
83 83
@@ -93,22 +93,22 @@ static void batadv_iv_ogm_iface_disable(struct hard_iface *hard_iface)
93 93
94static void batadv_iv_ogm_iface_update_mac(struct hard_iface *hard_iface) 94static void batadv_iv_ogm_iface_update_mac(struct hard_iface *hard_iface)
95{ 95{
96 struct batman_ogm_packet *batman_ogm_packet; 96 struct batadv_ogm_packet *batadv_ogm_packet;
97 97
98 batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; 98 batadv_ogm_packet = (struct batadv_ogm_packet *)hard_iface->packet_buff;
99 memcpy(batman_ogm_packet->orig, 99 memcpy(batadv_ogm_packet->orig,
100 hard_iface->net_dev->dev_addr, ETH_ALEN); 100 hard_iface->net_dev->dev_addr, ETH_ALEN);
101 memcpy(batman_ogm_packet->prev_sender, 101 memcpy(batadv_ogm_packet->prev_sender,
102 hard_iface->net_dev->dev_addr, ETH_ALEN); 102 hard_iface->net_dev->dev_addr, ETH_ALEN);
103} 103}
104 104
105static void batadv_iv_ogm_primary_iface_set(struct hard_iface *hard_iface) 105static void batadv_iv_ogm_primary_iface_set(struct hard_iface *hard_iface)
106{ 106{
107 struct batman_ogm_packet *batman_ogm_packet; 107 struct batadv_ogm_packet *batadv_ogm_packet;
108 108
109 batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; 109 batadv_ogm_packet = (struct batadv_ogm_packet *)hard_iface->packet_buff;
110 batman_ogm_packet->flags = BATADV_PRIMARIES_FIRST_HOP; 110 batadv_ogm_packet->flags = BATADV_PRIMARIES_FIRST_HOP;
111 batman_ogm_packet->header.ttl = BATADV_TTL; 111 batadv_ogm_packet->header.ttl = BATADV_TTL;
112} 112}
113 113
114/* when do we schedule our own ogm to be sent */ 114/* when do we schedule our own ogm to be sent */
@@ -162,7 +162,7 @@ static void batadv_iv_ogm_send_to_if(struct forw_packet *forw_packet,
162 char *fwd_str; 162 char *fwd_str;
163 uint8_t packet_num; 163 uint8_t packet_num;
164 int16_t buff_pos; 164 int16_t buff_pos;
165 struct batman_ogm_packet *batman_ogm_packet; 165 struct batadv_ogm_packet *batadv_ogm_packet;
166 struct sk_buff *skb; 166 struct sk_buff *skb;
167 167
168 if (hard_iface->if_status != BATADV_IF_ACTIVE) 168 if (hard_iface->if_status != BATADV_IF_ACTIVE)
@@ -170,20 +170,20 @@ static void batadv_iv_ogm_send_to_if(struct forw_packet *forw_packet,
170 170
171 packet_num = 0; 171 packet_num = 0;
172 buff_pos = 0; 172 buff_pos = 0;
173 batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data; 173 batadv_ogm_packet = (struct batadv_ogm_packet *)forw_packet->skb->data;
174 174
175 /* adjust all flags and log packets */ 175 /* adjust all flags and log packets */
176 while (batadv_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len, 176 while (batadv_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len,
177 batman_ogm_packet->tt_num_changes)) { 177 batadv_ogm_packet->tt_num_changes)) {
178 178
179 /* we might have aggregated direct link packets with an 179 /* we might have aggregated direct link packets with an
180 * ordinary base packet 180 * ordinary base packet
181 */ 181 */
182 if ((forw_packet->direct_link_flags & (1 << packet_num)) && 182 if ((forw_packet->direct_link_flags & (1 << packet_num)) &&
183 (forw_packet->if_incoming == hard_iface)) 183 (forw_packet->if_incoming == hard_iface))
184 batman_ogm_packet->flags |= BATADV_DIRECTLINK; 184 batadv_ogm_packet->flags |= BATADV_DIRECTLINK;
185 else 185 else
186 batman_ogm_packet->flags &= ~BATADV_DIRECTLINK; 186 batadv_ogm_packet->flags &= ~BATADV_DIRECTLINK;
187 187
188 fwd_str = (packet_num > 0 ? "Forwarding" : (forw_packet->own ? 188 fwd_str = (packet_num > 0 ? "Forwarding" : (forw_packet->own ?
189 "Sending own" : 189 "Sending own" :
@@ -191,18 +191,18 @@ static void batadv_iv_ogm_send_to_if(struct forw_packet *forw_packet,
191 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 191 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
192 "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n", 192 "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n",
193 fwd_str, (packet_num > 0 ? "aggregated " : ""), 193 fwd_str, (packet_num > 0 ? "aggregated " : ""),
194 batman_ogm_packet->orig, 194 batadv_ogm_packet->orig,
195 ntohl(batman_ogm_packet->seqno), 195 ntohl(batadv_ogm_packet->seqno),
196 batman_ogm_packet->tq, batman_ogm_packet->header.ttl, 196 batadv_ogm_packet->tq, batadv_ogm_packet->header.ttl,
197 (batman_ogm_packet->flags & BATADV_DIRECTLINK ? 197 (batadv_ogm_packet->flags & BATADV_DIRECTLINK ?
198 "on" : "off"), 198 "on" : "off"),
199 batman_ogm_packet->ttvn, hard_iface->net_dev->name, 199 batadv_ogm_packet->ttvn, hard_iface->net_dev->name,
200 hard_iface->net_dev->dev_addr); 200 hard_iface->net_dev->dev_addr);
201 201
202 buff_pos += BATADV_OGM_HLEN; 202 buff_pos += BATADV_OGM_HLEN;
203 buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes); 203 buff_pos += batadv_tt_len(batadv_ogm_packet->tt_num_changes);
204 packet_num++; 204 packet_num++;
205 batman_ogm_packet = (struct batman_ogm_packet *) 205 batadv_ogm_packet = (struct batadv_ogm_packet *)
206 (forw_packet->skb->data + buff_pos); 206 (forw_packet->skb->data + buff_pos);
207 } 207 }
208 208
@@ -223,12 +223,12 @@ static void batadv_iv_ogm_emit(struct forw_packet *forw_packet)
223 struct net_device *soft_iface; 223 struct net_device *soft_iface;
224 struct bat_priv *bat_priv; 224 struct bat_priv *bat_priv;
225 struct hard_iface *primary_if = NULL; 225 struct hard_iface *primary_if = NULL;
226 struct batman_ogm_packet *batman_ogm_packet; 226 struct batadv_ogm_packet *batadv_ogm_packet;
227 unsigned char directlink; 227 unsigned char directlink;
228 228
229 batman_ogm_packet = (struct batman_ogm_packet *) 229 batadv_ogm_packet = (struct batadv_ogm_packet *)
230 (forw_packet->skb->data); 230 (forw_packet->skb->data);
231 directlink = (batman_ogm_packet->flags & BATADV_DIRECTLINK ? 1 : 0); 231 directlink = (batadv_ogm_packet->flags & BATADV_DIRECTLINK ? 1 : 0);
232 232
233 if (!forw_packet->if_incoming) { 233 if (!forw_packet->if_incoming) {
234 pr_err("Error - can't forward packet: incoming iface not specified\n"); 234 pr_err("Error - can't forward packet: incoming iface not specified\n");
@@ -248,16 +248,16 @@ static void batadv_iv_ogm_emit(struct forw_packet *forw_packet)
248 /* multihomed peer assumed 248 /* multihomed peer assumed
249 * non-primary OGMs are only broadcasted on their interface 249 * non-primary OGMs are only broadcasted on their interface
250 */ 250 */
251 if ((directlink && (batman_ogm_packet->header.ttl == 1)) || 251 if ((directlink && (batadv_ogm_packet->header.ttl == 1)) ||
252 (forw_packet->own && (forw_packet->if_incoming != primary_if))) { 252 (forw_packet->own && (forw_packet->if_incoming != primary_if))) {
253 253
254 /* FIXME: what about aggregated packets ? */ 254 /* FIXME: what about aggregated packets ? */
255 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 255 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
256 "%s packet (originator %pM, seqno %u, TTL %d) on interface %s [%pM]\n", 256 "%s packet (originator %pM, seqno %u, TTL %d) on interface %s [%pM]\n",
257 (forw_packet->own ? "Sending own" : "Forwarding"), 257 (forw_packet->own ? "Sending own" : "Forwarding"),
258 batman_ogm_packet->orig, 258 batadv_ogm_packet->orig,
259 ntohl(batman_ogm_packet->seqno), 259 ntohl(batadv_ogm_packet->seqno),
260 batman_ogm_packet->header.ttl, 260 batadv_ogm_packet->header.ttl,
261 forw_packet->if_incoming->net_dev->name, 261 forw_packet->if_incoming->net_dev->name,
262 forw_packet->if_incoming->net_dev->dev_addr); 262 forw_packet->if_incoming->net_dev->dev_addr);
263 263
@@ -287,20 +287,20 @@ out:
287 287
288/* return true if new_packet can be aggregated with forw_packet */ 288/* return true if new_packet can be aggregated with forw_packet */
289static bool 289static bool
290batadv_iv_ogm_can_aggregate(const struct batman_ogm_packet *new_bat_ogm_packet, 290batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet,
291 struct bat_priv *bat_priv, 291 struct bat_priv *bat_priv,
292 int packet_len, unsigned long send_time, 292 int packet_len, unsigned long send_time,
293 bool directlink, 293 bool directlink,
294 const struct hard_iface *if_incoming, 294 const struct hard_iface *if_incoming,
295 const struct forw_packet *forw_packet) 295 const struct forw_packet *forw_packet)
296{ 296{
297 struct batman_ogm_packet *batman_ogm_packet; 297 struct batadv_ogm_packet *batadv_ogm_packet;
298 int aggregated_bytes = forw_packet->packet_len + packet_len; 298 int aggregated_bytes = forw_packet->packet_len + packet_len;
299 struct hard_iface *primary_if = NULL; 299 struct hard_iface *primary_if = NULL;
300 bool res = false; 300 bool res = false;
301 unsigned long aggregation_end_time; 301 unsigned long aggregation_end_time;
302 302
303 batman_ogm_packet = (struct batman_ogm_packet *)forw_packet->skb->data; 303 batadv_ogm_packet = (struct batadv_ogm_packet *)forw_packet->skb->data;
304 aggregation_end_time = send_time; 304 aggregation_end_time = send_time;
305 aggregation_end_time += msecs_to_jiffies(BATADV_MAX_AGGREGATION_MS); 305 aggregation_end_time += msecs_to_jiffies(BATADV_MAX_AGGREGATION_MS);
306 306
@@ -330,8 +330,8 @@ batadv_iv_ogm_can_aggregate(const struct batman_ogm_packet *new_bat_ogm_packet,
330 * are flooded through the net 330 * are flooded through the net
331 */ 331 */
332 if ((!directlink) && 332 if ((!directlink) &&
333 (!(batman_ogm_packet->flags & BATADV_DIRECTLINK)) && 333 (!(batadv_ogm_packet->flags & BATADV_DIRECTLINK)) &&
334 (batman_ogm_packet->header.ttl != 1) && 334 (batadv_ogm_packet->header.ttl != 1) &&
335 335
336 /* own packets originating non-primary 336 /* own packets originating non-primary
337 * interfaces leave only that interface 337 * interfaces leave only that interface
@@ -353,7 +353,7 @@ batadv_iv_ogm_can_aggregate(const struct batman_ogm_packet *new_bat_ogm_packet,
353 * own secondary interface packets 353 * own secondary interface packets
354 * (= secondary interface packets in general) 354 * (= secondary interface packets in general)
355 */ 355 */
356 (batman_ogm_packet->flags & BATADV_DIRECTLINK || 356 (batadv_ogm_packet->flags & BATADV_DIRECTLINK ||
357 (forw_packet->own && 357 (forw_packet->own &&
358 forw_packet->if_incoming != primary_if))) { 358 forw_packet->if_incoming != primary_if))) {
359 res = true; 359 res = true;
@@ -475,12 +475,12 @@ static void batadv_iv_ogm_queue_add(struct bat_priv *bat_priv,
475 */ 475 */
476 struct forw_packet *forw_packet_aggr = NULL, *forw_packet_pos = NULL; 476 struct forw_packet *forw_packet_aggr = NULL, *forw_packet_pos = NULL;
477 struct hlist_node *tmp_node; 477 struct hlist_node *tmp_node;
478 struct batman_ogm_packet *batman_ogm_packet; 478 struct batadv_ogm_packet *batadv_ogm_packet;
479 bool direct_link; 479 bool direct_link;
480 unsigned long max_aggregation_jiffies; 480 unsigned long max_aggregation_jiffies;
481 481
482 batman_ogm_packet = (struct batman_ogm_packet *)packet_buff; 482 batadv_ogm_packet = (struct batadv_ogm_packet *)packet_buff;
483 direct_link = batman_ogm_packet->flags & BATADV_DIRECTLINK ? 1 : 0; 483 direct_link = batadv_ogm_packet->flags & BATADV_DIRECTLINK ? 1 : 0;
484 max_aggregation_jiffies = msecs_to_jiffies(BATADV_MAX_AGGREGATION_MS); 484 max_aggregation_jiffies = msecs_to_jiffies(BATADV_MAX_AGGREGATION_MS);
485 485
486 /* find position for the packet in the forward queue */ 486 /* find position for the packet in the forward queue */
@@ -489,7 +489,7 @@ static void batadv_iv_ogm_queue_add(struct bat_priv *bat_priv,
489 if ((atomic_read(&bat_priv->aggregated_ogms)) && (!own_packet)) { 489 if ((atomic_read(&bat_priv->aggregated_ogms)) && (!own_packet)) {
490 hlist_for_each_entry(forw_packet_pos, tmp_node, 490 hlist_for_each_entry(forw_packet_pos, tmp_node,
491 &bat_priv->forw_bat_list, list) { 491 &bat_priv->forw_bat_list, list) {
492 if (batadv_iv_ogm_can_aggregate(batman_ogm_packet, 492 if (batadv_iv_ogm_can_aggregate(batadv_ogm_packet,
493 bat_priv, packet_len, 493 bat_priv, packet_len,
494 send_time, direct_link, 494 send_time, direct_link,
495 if_incoming, 495 if_incoming,
@@ -526,7 +526,7 @@ static void batadv_iv_ogm_queue_add(struct bat_priv *bat_priv,
526 526
527static void batadv_iv_ogm_forward(struct orig_node *orig_node, 527static void batadv_iv_ogm_forward(struct orig_node *orig_node,
528 const struct ethhdr *ethhdr, 528 const struct ethhdr *ethhdr,
529 struct batman_ogm_packet *batman_ogm_packet, 529 struct batadv_ogm_packet *batadv_ogm_packet,
530 bool is_single_hop_neigh, 530 bool is_single_hop_neigh,
531 bool is_from_best_next_hop, 531 bool is_from_best_next_hop,
532 struct hard_iface *if_incoming) 532 struct hard_iface *if_incoming)
@@ -534,7 +534,7 @@ static void batadv_iv_ogm_forward(struct orig_node *orig_node,
534 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 534 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
535 uint8_t tt_num_changes; 535 uint8_t tt_num_changes;
536 536
537 if (batman_ogm_packet->header.ttl <= 1) { 537 if (batadv_ogm_packet->header.ttl <= 1) {
538 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "ttl exceeded\n"); 538 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "ttl exceeded\n");
539 return; 539 return;
540 } 540 }
@@ -547,32 +547,32 @@ static void batadv_iv_ogm_forward(struct orig_node *orig_node,
547 * simply drop the ogm. 547 * simply drop the ogm.
548 */ 548 */
549 if (is_single_hop_neigh) 549 if (is_single_hop_neigh)
550 batman_ogm_packet->flags |= BATADV_NOT_BEST_NEXT_HOP; 550 batadv_ogm_packet->flags |= BATADV_NOT_BEST_NEXT_HOP;
551 else 551 else
552 return; 552 return;
553 } 553 }
554 554
555 tt_num_changes = batman_ogm_packet->tt_num_changes; 555 tt_num_changes = batadv_ogm_packet->tt_num_changes;
556 556
557 batman_ogm_packet->header.ttl--; 557 batadv_ogm_packet->header.ttl--;
558 memcpy(batman_ogm_packet->prev_sender, ethhdr->h_source, ETH_ALEN); 558 memcpy(batadv_ogm_packet->prev_sender, ethhdr->h_source, ETH_ALEN);
559 559
560 /* apply hop penalty */ 560 /* apply hop penalty */
561 batman_ogm_packet->tq = batadv_hop_penalty(batman_ogm_packet->tq, 561 batadv_ogm_packet->tq = batadv_hop_penalty(batadv_ogm_packet->tq,
562 bat_priv); 562 bat_priv);
563 563
564 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 564 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
565 "Forwarding packet: tq: %i, ttl: %i\n", 565 "Forwarding packet: tq: %i, ttl: %i\n",
566 batman_ogm_packet->tq, batman_ogm_packet->header.ttl); 566 batadv_ogm_packet->tq, batadv_ogm_packet->header.ttl);
567 567
568 /* switch of primaries first hop flag when forwarding */ 568 /* switch of primaries first hop flag when forwarding */
569 batman_ogm_packet->flags &= ~BATADV_PRIMARIES_FIRST_HOP; 569 batadv_ogm_packet->flags &= ~BATADV_PRIMARIES_FIRST_HOP;
570 if (is_single_hop_neigh) 570 if (is_single_hop_neigh)
571 batman_ogm_packet->flags |= BATADV_DIRECTLINK; 571 batadv_ogm_packet->flags |= BATADV_DIRECTLINK;
572 else 572 else
573 batman_ogm_packet->flags &= ~BATADV_DIRECTLINK; 573 batadv_ogm_packet->flags &= ~BATADV_DIRECTLINK;
574 574
575 batadv_iv_ogm_queue_add(bat_priv, (unsigned char *)batman_ogm_packet, 575 batadv_iv_ogm_queue_add(bat_priv, (unsigned char *)batadv_ogm_packet,
576 BATADV_OGM_HLEN + batadv_tt_len(tt_num_changes), 576 BATADV_OGM_HLEN + batadv_tt_len(tt_num_changes),
577 if_incoming, 0, batadv_iv_ogm_fwd_send_time()); 577 if_incoming, 0, batadv_iv_ogm_fwd_send_time());
578} 578}
@@ -580,7 +580,7 @@ static void batadv_iv_ogm_forward(struct orig_node *orig_node,
580static void batadv_iv_ogm_schedule(struct hard_iface *hard_iface) 580static void batadv_iv_ogm_schedule(struct hard_iface *hard_iface)
581{ 581{
582 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 582 struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
583 struct batman_ogm_packet *batman_ogm_packet; 583 struct batadv_ogm_packet *batadv_ogm_packet;
584 struct hard_iface *primary_if; 584 struct hard_iface *primary_if;
585 int vis_server, tt_num_changes = 0; 585 int vis_server, tt_num_changes = 0;
586 586
@@ -593,29 +593,29 @@ static void batadv_iv_ogm_schedule(struct hard_iface *hard_iface)
593 &hard_iface->packet_len, 593 &hard_iface->packet_len,
594 BATADV_OGM_HLEN); 594 BATADV_OGM_HLEN);
595 595
596 batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; 596 batadv_ogm_packet = (struct batadv_ogm_packet *)hard_iface->packet_buff;
597 597
598 /* change sequence number to network order */ 598 /* change sequence number to network order */
599 batman_ogm_packet->seqno = 599 batadv_ogm_packet->seqno =
600 htonl((uint32_t)atomic_read(&hard_iface->seqno)); 600 htonl((uint32_t)atomic_read(&hard_iface->seqno));
601 atomic_inc(&hard_iface->seqno); 601 atomic_inc(&hard_iface->seqno);
602 602
603 batman_ogm_packet->ttvn = atomic_read(&bat_priv->ttvn); 603 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->ttvn);
604 batman_ogm_packet->tt_crc = htons(bat_priv->tt_crc); 604 batadv_ogm_packet->tt_crc = htons(bat_priv->tt_crc);
605 if (tt_num_changes >= 0) 605 if (tt_num_changes >= 0)
606 batman_ogm_packet->tt_num_changes = tt_num_changes; 606 batadv_ogm_packet->tt_num_changes = tt_num_changes;
607 607
608 if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC) 608 if (vis_server == BATADV_VIS_TYPE_SERVER_SYNC)
609 batman_ogm_packet->flags |= BATADV_VIS_SERVER; 609 batadv_ogm_packet->flags |= BATADV_VIS_SERVER;
610 else 610 else
611 batman_ogm_packet->flags &= ~BATADV_VIS_SERVER; 611 batadv_ogm_packet->flags &= ~BATADV_VIS_SERVER;
612 612
613 if ((hard_iface == primary_if) && 613 if ((hard_iface == primary_if) &&
614 (atomic_read(&bat_priv->gw_mode) == BATADV_GW_MODE_SERVER)) 614 (atomic_read(&bat_priv->gw_mode) == BATADV_GW_MODE_SERVER))
615 batman_ogm_packet->gw_flags = 615 batadv_ogm_packet->gw_flags =
616 (uint8_t)atomic_read(&bat_priv->gw_bandwidth); 616 (uint8_t)atomic_read(&bat_priv->gw_bandwidth);
617 else 617 else
618 batman_ogm_packet->gw_flags = BATADV_NO_FLAGS; 618 batadv_ogm_packet->gw_flags = BATADV_NO_FLAGS;
619 619
620 batadv_slide_own_bcast_window(hard_iface); 620 batadv_slide_own_bcast_window(hard_iface);
621 batadv_iv_ogm_queue_add(bat_priv, hard_iface->packet_buff, 621 batadv_iv_ogm_queue_add(bat_priv, hard_iface->packet_buff,
@@ -630,7 +630,7 @@ static void
630batadv_iv_ogm_orig_update(struct bat_priv *bat_priv, 630batadv_iv_ogm_orig_update(struct bat_priv *bat_priv,
631 struct orig_node *orig_node, 631 struct orig_node *orig_node,
632 const struct ethhdr *ethhdr, 632 const struct ethhdr *ethhdr,
633 const struct batman_ogm_packet *batman_ogm_packet, 633 const struct batadv_ogm_packet *batadv_ogm_packet,
634 struct hard_iface *if_incoming, 634 struct hard_iface *if_incoming,
635 const unsigned char *tt_buff, 635 const unsigned char *tt_buff,
636 int is_duplicate) 636 int is_duplicate)
@@ -679,7 +679,7 @@ batadv_iv_ogm_orig_update(struct bat_priv *bat_priv,
679 neigh_node = batadv_iv_ogm_neigh_new(if_incoming, 679 neigh_node = batadv_iv_ogm_neigh_new(if_incoming,
680 ethhdr->h_source, 680 ethhdr->h_source,
681 orig_node, orig_tmp, 681 orig_node, orig_tmp,
682 batman_ogm_packet->seqno); 682 batadv_ogm_packet->seqno);
683 683
684 batadv_orig_node_free_ref(orig_tmp); 684 batadv_orig_node_free_ref(orig_tmp);
685 if (!neigh_node) 685 if (!neigh_node)
@@ -690,19 +690,19 @@ batadv_iv_ogm_orig_update(struct bat_priv *bat_priv,
690 690
691 rcu_read_unlock(); 691 rcu_read_unlock();
692 692
693 orig_node->flags = batman_ogm_packet->flags; 693 orig_node->flags = batadv_ogm_packet->flags;
694 neigh_node->last_seen = jiffies; 694 neigh_node->last_seen = jiffies;
695 695
696 spin_lock_bh(&neigh_node->lq_update_lock); 696 spin_lock_bh(&neigh_node->lq_update_lock);
697 batadv_ring_buffer_set(neigh_node->tq_recv, 697 batadv_ring_buffer_set(neigh_node->tq_recv,
698 &neigh_node->tq_index, 698 &neigh_node->tq_index,
699 batman_ogm_packet->tq); 699 batadv_ogm_packet->tq);
700 neigh_node->tq_avg = batadv_ring_buffer_avg(neigh_node->tq_recv); 700 neigh_node->tq_avg = batadv_ring_buffer_avg(neigh_node->tq_recv);
701 spin_unlock_bh(&neigh_node->lq_update_lock); 701 spin_unlock_bh(&neigh_node->lq_update_lock);
702 702
703 if (!is_duplicate) { 703 if (!is_duplicate) {
704 orig_node->last_ttl = batman_ogm_packet->header.ttl; 704 orig_node->last_ttl = batadv_ogm_packet->header.ttl;
705 neigh_node->last_ttl = batman_ogm_packet->header.ttl; 705 neigh_node->last_ttl = batadv_ogm_packet->header.ttl;
706 } 706 }
707 707
708 batadv_bonding_candidate_add(orig_node, neigh_node); 708 batadv_bonding_candidate_add(orig_node, neigh_node);
@@ -744,19 +744,19 @@ update_tt:
744 /* I have to check for transtable changes only if the OGM has been 744 /* I have to check for transtable changes only if the OGM has been
745 * sent through a primary interface 745 * sent through a primary interface
746 */ 746 */
747 if (((batman_ogm_packet->orig != ethhdr->h_source) && 747 if (((batadv_ogm_packet->orig != ethhdr->h_source) &&
748 (batman_ogm_packet->header.ttl > 2)) || 748 (batadv_ogm_packet->header.ttl > 2)) ||
749 (batman_ogm_packet->flags & BATADV_PRIMARIES_FIRST_HOP)) 749 (batadv_ogm_packet->flags & BATADV_PRIMARIES_FIRST_HOP))
750 batadv_tt_update_orig(bat_priv, orig_node, tt_buff, 750 batadv_tt_update_orig(bat_priv, orig_node, tt_buff,
751 batman_ogm_packet->tt_num_changes, 751 batadv_ogm_packet->tt_num_changes,
752 batman_ogm_packet->ttvn, 752 batadv_ogm_packet->ttvn,
753 ntohs(batman_ogm_packet->tt_crc)); 753 ntohs(batadv_ogm_packet->tt_crc));
754 754
755 if (orig_node->gw_flags != batman_ogm_packet->gw_flags) 755 if (orig_node->gw_flags != batadv_ogm_packet->gw_flags)
756 batadv_gw_node_update(bat_priv, orig_node, 756 batadv_gw_node_update(bat_priv, orig_node,
757 batman_ogm_packet->gw_flags); 757 batadv_ogm_packet->gw_flags);
758 758
759 orig_node->gw_flags = batman_ogm_packet->gw_flags; 759 orig_node->gw_flags = batadv_ogm_packet->gw_flags;
760 760
761 /* restart gateway selection if fast or late switching was enabled */ 761 /* restart gateway selection if fast or late switching was enabled */
762 if ((orig_node->gw_flags) && 762 if ((orig_node->gw_flags) &&
@@ -777,7 +777,7 @@ out:
777 777
778static int batadv_iv_ogm_calc_tq(struct orig_node *orig_node, 778static int batadv_iv_ogm_calc_tq(struct orig_node *orig_node,
779 struct orig_node *orig_neigh_node, 779 struct orig_node *orig_neigh_node,
780 struct batman_ogm_packet *batman_ogm_packet, 780 struct batadv_ogm_packet *batadv_ogm_packet,
781 struct hard_iface *if_incoming) 781 struct hard_iface *if_incoming)
782{ 782{
783 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 783 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
@@ -814,7 +814,7 @@ static int batadv_iv_ogm_calc_tq(struct orig_node *orig_node,
814 orig_neigh_node->orig, 814 orig_neigh_node->orig,
815 orig_neigh_node, 815 orig_neigh_node,
816 orig_neigh_node, 816 orig_neigh_node,
817 batman_ogm_packet->seqno); 817 batadv_ogm_packet->seqno);
818 818
819 if (!neigh_node) 819 if (!neigh_node)
820 goto out; 820 goto out;
@@ -862,20 +862,20 @@ static int batadv_iv_ogm_calc_tq(struct orig_node *orig_node,
862 inv_asym_penalty /= neigh_rq_max_cube; 862 inv_asym_penalty /= neigh_rq_max_cube;
863 tq_asym_penalty = BATADV_TQ_MAX_VALUE - inv_asym_penalty; 863 tq_asym_penalty = BATADV_TQ_MAX_VALUE - inv_asym_penalty;
864 864
865 combined_tq = batman_ogm_packet->tq * tq_own * tq_asym_penalty; 865 combined_tq = batadv_ogm_packet->tq * tq_own * tq_asym_penalty;
866 combined_tq /= BATADV_TQ_MAX_VALUE * BATADV_TQ_MAX_VALUE; 866 combined_tq /= BATADV_TQ_MAX_VALUE * BATADV_TQ_MAX_VALUE;
867 batman_ogm_packet->tq = combined_tq; 867 batadv_ogm_packet->tq = combined_tq;
868 868
869 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 869 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
870 "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i\n", 870 "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, total tq: %3i\n",
871 orig_node->orig, orig_neigh_node->orig, total_count, 871 orig_node->orig, orig_neigh_node->orig, total_count,
872 neigh_rq_count, tq_own, 872 neigh_rq_count, tq_own,
873 tq_asym_penalty, batman_ogm_packet->tq); 873 tq_asym_penalty, batadv_ogm_packet->tq);
874 874
875 /* if link has the minimum required transmission quality 875 /* if link has the minimum required transmission quality
876 * consider it bidirectional 876 * consider it bidirectional
877 */ 877 */
878 if (batman_ogm_packet->tq >= BATADV_TQ_TOTAL_BIDRECT_LIMIT) 878 if (batadv_ogm_packet->tq >= BATADV_TQ_TOTAL_BIDRECT_LIMIT)
879 ret = 1; 879 ret = 1;
880 880
881out: 881out:
@@ -894,7 +894,7 @@ out:
894 */ 894 */
895static int 895static int
896batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, 896batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
897 const struct batman_ogm_packet *batman_ogm_packet, 897 const struct batadv_ogm_packet *batadv_ogm_packet,
898 const struct hard_iface *if_incoming) 898 const struct hard_iface *if_incoming)
899{ 899{
900 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 900 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
@@ -905,10 +905,10 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
905 int32_t seq_diff; 905 int32_t seq_diff;
906 int need_update = 0; 906 int need_update = 0;
907 int set_mark, ret = -1; 907 int set_mark, ret = -1;
908 uint32_t seqno = ntohl(batman_ogm_packet->seqno); 908 uint32_t seqno = ntohl(batadv_ogm_packet->seqno);
909 uint8_t *neigh_addr; 909 uint8_t *neigh_addr;
910 910
911 orig_node = batadv_get_orig_node(bat_priv, batman_ogm_packet->orig); 911 orig_node = batadv_get_orig_node(bat_priv, batadv_ogm_packet->orig);
912 if (!orig_node) 912 if (!orig_node)
913 return 0; 913 return 0;
914 914
@@ -963,7 +963,7 @@ out:
963} 963}
964 964
965static void batadv_iv_ogm_process(const struct ethhdr *ethhdr, 965static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
966 struct batman_ogm_packet *batman_ogm_packet, 966 struct batadv_ogm_packet *batadv_ogm_packet,
967 const unsigned char *tt_buff, 967 const unsigned char *tt_buff,
968 struct hard_iface *if_incoming) 968 struct hard_iface *if_incoming)
969{ 969{
@@ -989,34 +989,34 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
989 * it as an additional length. 989 * it as an additional length.
990 * 990 *
991 * TODO: A more sane solution would be to have a bit in the 991 * TODO: A more sane solution would be to have a bit in the
992 * batman_ogm_packet to detect whether the packet is the last 992 * batadv_ogm_packet to detect whether the packet is the last
993 * packet in an aggregation. Here we expect that the padding 993 * packet in an aggregation. Here we expect that the padding
994 * is always zero (or not 0x01) 994 * is always zero (or not 0x01)
995 */ 995 */
996 if (batman_ogm_packet->header.packet_type != BATADV_IV_OGM) 996 if (batadv_ogm_packet->header.packet_type != BATADV_IV_OGM)
997 return; 997 return;
998 998
999 /* could be changed by schedule_own_packet() */ 999 /* could be changed by schedule_own_packet() */
1000 if_incoming_seqno = atomic_read(&if_incoming->seqno); 1000 if_incoming_seqno = atomic_read(&if_incoming->seqno);
1001 1001
1002 if (batman_ogm_packet->flags & BATADV_DIRECTLINK) 1002 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
1003 has_directlink_flag = 1; 1003 has_directlink_flag = 1;
1004 else 1004 else
1005 has_directlink_flag = 0; 1005 has_directlink_flag = 0;
1006 1006
1007 if (batadv_compare_eth(ethhdr->h_source, batman_ogm_packet->orig)) 1007 if (batadv_compare_eth(ethhdr->h_source, batadv_ogm_packet->orig))
1008 is_single_hop_neigh = true; 1008 is_single_hop_neigh = true;
1009 1009
1010 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1010 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1011 "Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n", 1011 "Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n",
1012 ethhdr->h_source, if_incoming->net_dev->name, 1012 ethhdr->h_source, if_incoming->net_dev->name,
1013 if_incoming->net_dev->dev_addr, batman_ogm_packet->orig, 1013 if_incoming->net_dev->dev_addr, batadv_ogm_packet->orig,
1014 batman_ogm_packet->prev_sender, 1014 batadv_ogm_packet->prev_sender,
1015 ntohl(batman_ogm_packet->seqno), batman_ogm_packet->ttvn, 1015 ntohl(batadv_ogm_packet->seqno), batadv_ogm_packet->ttvn,
1016 ntohs(batman_ogm_packet->tt_crc), 1016 ntohs(batadv_ogm_packet->tt_crc),
1017 batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq, 1017 batadv_ogm_packet->tt_num_changes, batadv_ogm_packet->tq,
1018 batman_ogm_packet->header.ttl, 1018 batadv_ogm_packet->header.ttl,
1019 batman_ogm_packet->header.version, has_directlink_flag); 1019 batadv_ogm_packet->header.version, has_directlink_flag);
1020 1020
1021 rcu_read_lock(); 1021 rcu_read_lock();
1022 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { 1022 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
@@ -1030,11 +1030,11 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1030 hard_iface->net_dev->dev_addr)) 1030 hard_iface->net_dev->dev_addr))
1031 is_my_addr = 1; 1031 is_my_addr = 1;
1032 1032
1033 if (batadv_compare_eth(batman_ogm_packet->orig, 1033 if (batadv_compare_eth(batadv_ogm_packet->orig,
1034 hard_iface->net_dev->dev_addr)) 1034 hard_iface->net_dev->dev_addr))
1035 is_my_orig = 1; 1035 is_my_orig = 1;
1036 1036
1037 if (batadv_compare_eth(batman_ogm_packet->prev_sender, 1037 if (batadv_compare_eth(batadv_ogm_packet->prev_sender,
1038 hard_iface->net_dev->dev_addr)) 1038 hard_iface->net_dev->dev_addr))
1039 is_my_oldorig = 1; 1039 is_my_oldorig = 1;
1040 1040
@@ -1043,10 +1043,10 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1043 } 1043 }
1044 rcu_read_unlock(); 1044 rcu_read_unlock();
1045 1045
1046 if (batman_ogm_packet->header.version != BATADV_COMPAT_VERSION) { 1046 if (batadv_ogm_packet->header.version != BATADV_COMPAT_VERSION) {
1047 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1047 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1048 "Drop packet: incompatible batman version (%i)\n", 1048 "Drop packet: incompatible batman version (%i)\n",
1049 batman_ogm_packet->header.version); 1049 batadv_ogm_packet->header.version);
1050 return; 1050 return;
1051 } 1051 }
1052 1052
@@ -1082,14 +1082,14 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1082 */ 1082 */
1083 if (has_directlink_flag && 1083 if (has_directlink_flag &&
1084 batadv_compare_eth(if_incoming->net_dev->dev_addr, 1084 batadv_compare_eth(if_incoming->net_dev->dev_addr,
1085 batman_ogm_packet->orig)) { 1085 batadv_ogm_packet->orig)) {
1086 if_num = if_incoming->if_num; 1086 if_num = if_incoming->if_num;
1087 offset = if_num * BATADV_NUM_WORDS; 1087 offset = if_num * BATADV_NUM_WORDS;
1088 1088
1089 spin_lock_bh(&orig_neigh_node->ogm_cnt_lock); 1089 spin_lock_bh(&orig_neigh_node->ogm_cnt_lock);
1090 word = &(orig_neigh_node->bcast_own[offset]); 1090 word = &(orig_neigh_node->bcast_own[offset]);
1091 bit_pos = if_incoming_seqno - 2; 1091 bit_pos = if_incoming_seqno - 2;
1092 bit_pos -= ntohl(batman_ogm_packet->seqno); 1092 bit_pos -= ntohl(batadv_ogm_packet->seqno);
1093 batadv_set_bit(word, bit_pos); 1093 batadv_set_bit(word, bit_pos);
1094 weight = &orig_neigh_node->bcast_own_sum[if_num]; 1094 weight = &orig_neigh_node->bcast_own_sum[if_num];
1095 *weight = bitmap_weight(word, 1095 *weight = bitmap_weight(word,
@@ -1110,18 +1110,18 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1110 return; 1110 return;
1111 } 1111 }
1112 1112
1113 if (batman_ogm_packet->flags & BATADV_NOT_BEST_NEXT_HOP) { 1113 if (batadv_ogm_packet->flags & BATADV_NOT_BEST_NEXT_HOP) {
1114 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1114 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1115 "Drop packet: ignoring all packets not forwarded from the best next hop (sender: %pM)\n", 1115 "Drop packet: ignoring all packets not forwarded from the best next hop (sender: %pM)\n",
1116 ethhdr->h_source); 1116 ethhdr->h_source);
1117 return; 1117 return;
1118 } 1118 }
1119 1119
1120 orig_node = batadv_get_orig_node(bat_priv, batman_ogm_packet->orig); 1120 orig_node = batadv_get_orig_node(bat_priv, batadv_ogm_packet->orig);
1121 if (!orig_node) 1121 if (!orig_node)
1122 return; 1122 return;
1123 1123
1124 is_duplicate = batadv_iv_ogm_update_seqnos(ethhdr, batman_ogm_packet, 1124 is_duplicate = batadv_iv_ogm_update_seqnos(ethhdr, batadv_ogm_packet,
1125 if_incoming); 1125 if_incoming);
1126 1126
1127 if (is_duplicate == -1) { 1127 if (is_duplicate == -1) {
@@ -1131,7 +1131,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1131 goto out; 1131 goto out;
1132 } 1132 }
1133 1133
1134 if (batman_ogm_packet->tq == 0) { 1134 if (batadv_ogm_packet->tq == 0) {
1135 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1135 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1136 "Drop packet: originator packet with tq equal 0\n"); 1136 "Drop packet: originator packet with tq equal 0\n");
1137 goto out; 1137 goto out;
@@ -1145,11 +1145,11 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1145 (batadv_compare_eth(router->addr, ethhdr->h_source))) 1145 (batadv_compare_eth(router->addr, ethhdr->h_source)))
1146 is_from_best_next_hop = true; 1146 is_from_best_next_hop = true;
1147 1147
1148 prev_sender = batman_ogm_packet->prev_sender; 1148 prev_sender = batadv_ogm_packet->prev_sender;
1149 /* avoid temporary routing loops */ 1149 /* avoid temporary routing loops */
1150 if (router && router_router && 1150 if (router && router_router &&
1151 (batadv_compare_eth(router->addr, prev_sender)) && 1151 (batadv_compare_eth(router->addr, prev_sender)) &&
1152 !(batadv_compare_eth(batman_ogm_packet->orig, prev_sender)) && 1152 !(batadv_compare_eth(batadv_ogm_packet->orig, prev_sender)) &&
1153 (batadv_compare_eth(router->addr, router_router->addr))) { 1153 (batadv_compare_eth(router->addr, router_router->addr))) {
1154 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1154 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1155 "Drop packet: ignoring all rebroadcast packets that may make me loop (sender: %pM)\n", 1155 "Drop packet: ignoring all rebroadcast packets that may make me loop (sender: %pM)\n",
@@ -1178,26 +1178,26 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1178 } 1178 }
1179 1179
1180 is_bidirect = batadv_iv_ogm_calc_tq(orig_node, orig_neigh_node, 1180 is_bidirect = batadv_iv_ogm_calc_tq(orig_node, orig_neigh_node,
1181 batman_ogm_packet, if_incoming); 1181 batadv_ogm_packet, if_incoming);
1182 1182
1183 batadv_bonding_save_primary(orig_node, orig_neigh_node, 1183 batadv_bonding_save_primary(orig_node, orig_neigh_node,
1184 batman_ogm_packet); 1184 batadv_ogm_packet);
1185 1185
1186 /* update ranking if it is not a duplicate or has the same 1186 /* update ranking if it is not a duplicate or has the same
1187 * seqno and similar ttl as the non-duplicate 1187 * seqno and similar ttl as the non-duplicate
1188 */ 1188 */
1189 sameseq = orig_node->last_real_seqno == ntohl(batman_ogm_packet->seqno); 1189 sameseq = orig_node->last_real_seqno == ntohl(batadv_ogm_packet->seqno);
1190 simlar_ttl = orig_node->last_ttl - 3 <= batman_ogm_packet->header.ttl; 1190 simlar_ttl = orig_node->last_ttl - 3 <= batadv_ogm_packet->header.ttl;
1191 if (is_bidirect && (!is_duplicate || (sameseq && simlar_ttl))) 1191 if (is_bidirect && (!is_duplicate || (sameseq && simlar_ttl)))
1192 batadv_iv_ogm_orig_update(bat_priv, orig_node, ethhdr, 1192 batadv_iv_ogm_orig_update(bat_priv, orig_node, ethhdr,
1193 batman_ogm_packet, if_incoming, 1193 batadv_ogm_packet, if_incoming,
1194 tt_buff, is_duplicate); 1194 tt_buff, is_duplicate);
1195 1195
1196 /* is single hop (direct) neighbor */ 1196 /* is single hop (direct) neighbor */
1197 if (is_single_hop_neigh) { 1197 if (is_single_hop_neigh) {
1198 1198
1199 /* mark direct link on incoming interface */ 1199 /* mark direct link on incoming interface */
1200 batadv_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet, 1200 batadv_iv_ogm_forward(orig_node, ethhdr, batadv_ogm_packet,
1201 is_single_hop_neigh, 1201 is_single_hop_neigh,
1202 is_from_best_next_hop, if_incoming); 1202 is_from_best_next_hop, if_incoming);
1203 1203
@@ -1221,7 +1221,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1221 1221
1222 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 1222 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
1223 "Forwarding packet: rebroadcast originator packet\n"); 1223 "Forwarding packet: rebroadcast originator packet\n");
1224 batadv_iv_ogm_forward(orig_node, ethhdr, batman_ogm_packet, 1224 batadv_iv_ogm_forward(orig_node, ethhdr, batadv_ogm_packet,
1225 is_single_hop_neigh, is_from_best_next_hop, 1225 is_single_hop_neigh, is_from_best_next_hop,
1226 if_incoming); 1226 if_incoming);
1227 1227
@@ -1243,7 +1243,7 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,
1243 struct hard_iface *if_incoming) 1243 struct hard_iface *if_incoming)
1244{ 1244{
1245 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 1245 struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
1246 struct batman_ogm_packet *batman_ogm_packet; 1246 struct batadv_ogm_packet *batadv_ogm_packet;
1247 struct ethhdr *ethhdr; 1247 struct ethhdr *ethhdr;
1248 int buff_pos = 0, packet_len; 1248 int buff_pos = 0, packet_len;
1249 unsigned char *tt_buff, *packet_buff; 1249 unsigned char *tt_buff, *packet_buff;
@@ -1266,22 +1266,22 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,
1266 packet_len = skb_headlen(skb); 1266 packet_len = skb_headlen(skb);
1267 ethhdr = (struct ethhdr *)skb_mac_header(skb); 1267 ethhdr = (struct ethhdr *)skb_mac_header(skb);
1268 packet_buff = skb->data; 1268 packet_buff = skb->data;
1269 batman_ogm_packet = (struct batman_ogm_packet *)packet_buff; 1269 batadv_ogm_packet = (struct batadv_ogm_packet *)packet_buff;
1270 1270
1271 /* unpack the aggregated packets and process them one by one */ 1271 /* unpack the aggregated packets and process them one by one */
1272 do { 1272 do {
1273 tt_buff = packet_buff + buff_pos + BATADV_OGM_HLEN; 1273 tt_buff = packet_buff + buff_pos + BATADV_OGM_HLEN;
1274 1274
1275 batadv_iv_ogm_process(ethhdr, batman_ogm_packet, tt_buff, 1275 batadv_iv_ogm_process(ethhdr, batadv_ogm_packet, tt_buff,
1276 if_incoming); 1276 if_incoming);
1277 1277
1278 buff_pos += BATADV_OGM_HLEN; 1278 buff_pos += BATADV_OGM_HLEN;
1279 buff_pos += batadv_tt_len(batman_ogm_packet->tt_num_changes); 1279 buff_pos += batadv_tt_len(batadv_ogm_packet->tt_num_changes);
1280 1280
1281 batman_ogm_packet = (struct batman_ogm_packet *) 1281 batadv_ogm_packet = (struct batadv_ogm_packet *)
1282 (packet_buff + buff_pos); 1282 (packet_buff + buff_pos);
1283 } while (batadv_iv_ogm_aggr_packet(buff_pos, packet_len, 1283 } while (batadv_iv_ogm_aggr_packet(buff_pos, packet_len,
1284 batman_ogm_packet->tt_num_changes)); 1284 batadv_ogm_packet->tt_num_changes));
1285 1285
1286 kfree_skb(skb); 1286 kfree_skb(skb);
1287 return NET_RX_SUCCESS; 1287 return NET_RX_SUCCESS;
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 8bd70501b1e0..fdda2c8d48fe 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -255,7 +255,7 @@ static void batadv_bla_send_claim(struct bat_priv *bat_priv, uint8_t *mac,
255 struct hard_iface *primary_if; 255 struct hard_iface *primary_if;
256 struct net_device *soft_iface; 256 struct net_device *soft_iface;
257 uint8_t *hw_src; 257 uint8_t *hw_src;
258 struct bla_claim_dst local_claim_dest; 258 struct batadv_bla_claim_dst local_claim_dest;
259 __be32 zeroip = 0; 259 __be32 zeroip = 0;
260 260
261 primary_if = batadv_primary_if_get_selected(bat_priv); 261 primary_if = batadv_primary_if_get_selected(bat_priv);
@@ -759,9 +759,9 @@ static int batadv_check_claim_group(struct bat_priv *bat_priv,
759{ 759{
760 uint8_t *backbone_addr; 760 uint8_t *backbone_addr;
761 struct orig_node *orig_node; 761 struct orig_node *orig_node;
762 struct bla_claim_dst *bla_dst, *bla_dst_own; 762 struct batadv_bla_claim_dst *bla_dst, *bla_dst_own;
763 763
764 bla_dst = (struct bla_claim_dst *)hw_dst; 764 bla_dst = (struct batadv_bla_claim_dst *)hw_dst;
765 bla_dst_own = &bat_priv->claim_dest; 765 bla_dst_own = &bat_priv->claim_dest;
766 766
767 /* check if it is a claim packet in general */ 767 /* check if it is a claim packet in general */
@@ -832,7 +832,7 @@ static int batadv_bla_process_claim(struct bat_priv *bat_priv,
832 struct vlan_ethhdr *vhdr; 832 struct vlan_ethhdr *vhdr;
833 struct arphdr *arphdr; 833 struct arphdr *arphdr;
834 uint8_t *hw_src, *hw_dst; 834 uint8_t *hw_src, *hw_dst;
835 struct bla_claim_dst *bla_dst; 835 struct batadv_bla_claim_dst *bla_dst;
836 uint16_t proto; 836 uint16_t proto;
837 int headlen; 837 int headlen;
838 short vid = -1; 838 short vid = -1;
@@ -876,7 +876,7 @@ static int batadv_bla_process_claim(struct bat_priv *bat_priv,
876 876
877 hw_src = (uint8_t *)arphdr + sizeof(struct arphdr); 877 hw_src = (uint8_t *)arphdr + sizeof(struct arphdr);
878 hw_dst = hw_src + ETH_ALEN + 4; 878 hw_dst = hw_src + ETH_ALEN + 4;
879 bla_dst = (struct bla_claim_dst *)hw_dst; 879 bla_dst = (struct batadv_bla_claim_dst *)hw_dst;
880 880
881 /* check if it is a claim frame. */ 881 /* check if it is a claim frame. */
882 ret = batadv_check_claim_group(bat_priv, primary_if, hw_src, hw_dst, 882 ret = batadv_check_claim_group(bat_priv, primary_if, hw_src, hw_dst,
@@ -1201,7 +1201,7 @@ int batadv_bla_init(struct bat_priv *bat_priv)
1201 * the same host however as this might be intended. 1201 * the same host however as this might be intended.
1202 */ 1202 */
1203int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv, 1203int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
1204 struct bcast_packet *bcast_packet, 1204 struct batadv_bcast_packet *bcast_packet,
1205 int hdr_size) 1205 int hdr_size)
1206{ 1206{
1207 int i, length, curr; 1207 int i, length, curr;
diff --git a/net/batman-adv/bridge_loop_avoidance.h b/net/batman-adv/bridge_loop_avoidance.h
index 58563f0cf61d..d69f453d2b12 100644
--- a/net/batman-adv/bridge_loop_avoidance.h
+++ b/net/batman-adv/bridge_loop_avoidance.h
@@ -28,7 +28,7 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb,
28int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset); 28int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset);
29int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig); 29int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv, uint8_t *orig);
30int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv, 30int batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
31 struct bcast_packet *bcast_packet, 31 struct batadv_bcast_packet *bcast_packet,
32 int hdr_size); 32 int hdr_size);
33void batadv_bla_update_orig_address(struct bat_priv *bat_priv, 33void batadv_bla_update_orig_address(struct bat_priv *bat_priv,
34 struct hard_iface *primary_if, 34 struct hard_iface *primary_if,
@@ -72,7 +72,7 @@ static inline int batadv_bla_is_backbone_gw_orig(struct bat_priv *bat_priv,
72 72
73static inline int 73static inline int
74batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv, 74batadv_bla_check_bcast_duplist(struct bat_priv *bat_priv,
75 struct bcast_packet *bcast_packet, 75 struct batadv_bcast_packet *bcast_packet,
76 int hdr_size) 76 int hdr_size)
77{ 77{
78 return 0; 78 return 0;
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index e109d65c6803..0a14fdf9e877 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -100,14 +100,14 @@ out:
100static void batadv_primary_if_update_addr(struct bat_priv *bat_priv, 100static void batadv_primary_if_update_addr(struct bat_priv *bat_priv,
101 struct hard_iface *oldif) 101 struct hard_iface *oldif)
102{ 102{
103 struct vis_packet *vis_packet; 103 struct batadv_vis_packet *vis_packet;
104 struct hard_iface *primary_if; 104 struct hard_iface *primary_if;
105 105
106 primary_if = batadv_primary_if_get_selected(bat_priv); 106 primary_if = batadv_primary_if_get_selected(bat_priv);
107 if (!primary_if) 107 if (!primary_if)
108 goto out; 108 goto out;
109 109
110 vis_packet = (struct vis_packet *) 110 vis_packet = (struct batadv_vis_packet *)
111 bat_priv->my_vis_info->skb_packet->data; 111 bat_priv->my_vis_info->skb_packet->data;
112 memcpy(vis_packet->vis_orig, primary_if->net_dev->dev_addr, ETH_ALEN); 112 memcpy(vis_packet->vis_orig, primary_if->net_dev->dev_addr, ETH_ALEN);
113 memcpy(vis_packet->sender_orig, 113 memcpy(vis_packet->sender_orig,
diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c
index 61b52b379564..ca07580c1b44 100644
--- a/net/batman-adv/icmp_socket.c
+++ b/net/batman-adv/icmp_socket.c
@@ -29,7 +29,7 @@
29static struct socket_client *batadv_socket_client_hash[256]; 29static struct socket_client *batadv_socket_client_hash[256];
30 30
31static void batadv_socket_add_packet(struct socket_client *socket_client, 31static void batadv_socket_add_packet(struct socket_client *socket_client,
32 struct icmp_packet_rr *icmp_packet, 32 struct batadv_icmp_packet_rr *icmp_packet,
33 size_t icmp_len); 33 size_t icmp_len);
34 34
35void batadv_socket_init(void) 35void batadv_socket_init(void)
@@ -112,7 +112,7 @@ static ssize_t batadv_socket_read(struct file *file, char __user *buf,
112 if ((file->f_flags & O_NONBLOCK) && (socket_client->queue_len == 0)) 112 if ((file->f_flags & O_NONBLOCK) && (socket_client->queue_len == 0))
113 return -EAGAIN; 113 return -EAGAIN;
114 114
115 if ((!buf) || (count < sizeof(struct icmp_packet))) 115 if ((!buf) || (count < sizeof(struct batadv_icmp_packet)))
116 return -EINVAL; 116 return -EINVAL;
117 117
118 if (!access_ok(VERIFY_WRITE, buf, count)) 118 if (!access_ok(VERIFY_WRITE, buf, count))
@@ -151,13 +151,13 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
151 struct bat_priv *bat_priv = socket_client->bat_priv; 151 struct bat_priv *bat_priv = socket_client->bat_priv;
152 struct hard_iface *primary_if = NULL; 152 struct hard_iface *primary_if = NULL;
153 struct sk_buff *skb; 153 struct sk_buff *skb;
154 struct icmp_packet_rr *icmp_packet; 154 struct batadv_icmp_packet_rr *icmp_packet;
155 155
156 struct orig_node *orig_node = NULL; 156 struct orig_node *orig_node = NULL;
157 struct neigh_node *neigh_node = NULL; 157 struct neigh_node *neigh_node = NULL;
158 size_t packet_len = sizeof(struct icmp_packet); 158 size_t packet_len = sizeof(struct batadv_icmp_packet);
159 159
160 if (len < sizeof(struct icmp_packet)) { 160 if (len < sizeof(struct batadv_icmp_packet)) {
161 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 161 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
162 "Error - can't send packet from char device: invalid packet size\n"); 162 "Error - can't send packet from char device: invalid packet size\n");
163 return -EINVAL; 163 return -EINVAL;
@@ -170,8 +170,8 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
170 goto out; 170 goto out;
171 } 171 }
172 172
173 if (len >= sizeof(struct icmp_packet_rr)) 173 if (len >= sizeof(struct batadv_icmp_packet_rr))
174 packet_len = sizeof(struct icmp_packet_rr); 174 packet_len = sizeof(struct batadv_icmp_packet_rr);
175 175
176 skb = dev_alloc_skb(packet_len + ETH_HLEN); 176 skb = dev_alloc_skb(packet_len + ETH_HLEN);
177 if (!skb) { 177 if (!skb) {
@@ -180,7 +180,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
180 } 180 }
181 181
182 skb_reserve(skb, ETH_HLEN); 182 skb_reserve(skb, ETH_HLEN);
183 icmp_packet = (struct icmp_packet_rr *)skb_put(skb, packet_len); 183 icmp_packet = (struct batadv_icmp_packet_rr *)skb_put(skb, packet_len);
184 184
185 if (copy_from_user(icmp_packet, buff, packet_len)) { 185 if (copy_from_user(icmp_packet, buff, packet_len)) {
186 len = -EFAULT; 186 len = -EFAULT;
@@ -231,7 +231,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
231 memcpy(icmp_packet->orig, 231 memcpy(icmp_packet->orig,
232 primary_if->net_dev->dev_addr, ETH_ALEN); 232 primary_if->net_dev->dev_addr, ETH_ALEN);
233 233
234 if (packet_len == sizeof(struct icmp_packet_rr)) 234 if (packet_len == sizeof(struct batadv_icmp_packet_rr))
235 memcpy(icmp_packet->rr, 235 memcpy(icmp_packet->rr,
236 neigh_node->if_incoming->net_dev->dev_addr, ETH_ALEN); 236 neigh_node->if_incoming->net_dev->dev_addr, ETH_ALEN);
237 237
@@ -294,7 +294,7 @@ err:
294} 294}
295 295
296static void batadv_socket_add_packet(struct socket_client *socket_client, 296static void batadv_socket_add_packet(struct socket_client *socket_client,
297 struct icmp_packet_rr *icmp_packet, 297 struct batadv_icmp_packet_rr *icmp_packet,
298 size_t icmp_len) 298 size_t icmp_len)
299{ 299{
300 struct socket_packet *socket_packet; 300 struct socket_packet *socket_packet;
@@ -336,7 +336,7 @@ static void batadv_socket_add_packet(struct socket_client *socket_client,
336 wake_up(&socket_client->queue_wait); 336 wake_up(&socket_client->queue_wait);
337} 337}
338 338
339void batadv_socket_receive_packet(struct icmp_packet_rr *icmp_packet, 339void batadv_socket_receive_packet(struct batadv_icmp_packet_rr *icmp_packet,
340 size_t icmp_len) 340 size_t icmp_len)
341{ 341{
342 struct socket_client *hash; 342 struct socket_client *hash;
diff --git a/net/batman-adv/icmp_socket.h b/net/batman-adv/icmp_socket.h
index f88f9f0fe7a7..7b8ad529b09c 100644
--- a/net/batman-adv/icmp_socket.h
+++ b/net/batman-adv/icmp_socket.h
@@ -24,7 +24,7 @@
24 24
25void batadv_socket_init(void); 25void batadv_socket_init(void);
26int batadv_socket_setup(struct bat_priv *bat_priv); 26int batadv_socket_setup(struct bat_priv *bat_priv);
27void batadv_socket_receive_packet(struct icmp_packet_rr *icmp_packet, 27void batadv_socket_receive_packet(struct batadv_icmp_packet_rr *icmp_packet,
28 size_t icmp_len); 28 size_t icmp_len);
29 29
30#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */ 30#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 24d651da6fd7..97144a98c66f 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -205,7 +205,7 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
205 struct net_device *orig_dev) 205 struct net_device *orig_dev)
206{ 206{
207 struct bat_priv *bat_priv; 207 struct bat_priv *bat_priv;
208 struct batman_ogm_packet *batman_ogm_packet; 208 struct batadv_ogm_packet *batadv_ogm_packet;
209 struct hard_iface *hard_iface; 209 struct hard_iface *hard_iface;
210 uint8_t idx; 210 uint8_t idx;
211 int ret; 211 int ret;
@@ -237,19 +237,19 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
237 if (hard_iface->if_status != BATADV_IF_ACTIVE) 237 if (hard_iface->if_status != BATADV_IF_ACTIVE)
238 goto err_free; 238 goto err_free;
239 239
240 batman_ogm_packet = (struct batman_ogm_packet *)skb->data; 240 batadv_ogm_packet = (struct batadv_ogm_packet *)skb->data;
241 241
242 if (batman_ogm_packet->header.version != BATADV_COMPAT_VERSION) { 242 if (batadv_ogm_packet->header.version != BATADV_COMPAT_VERSION) {
243 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 243 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
244 "Drop packet: incompatible batman version (%i)\n", 244 "Drop packet: incompatible batman version (%i)\n",
245 batman_ogm_packet->header.version); 245 batadv_ogm_packet->header.version);
246 goto err_free; 246 goto err_free;
247 } 247 }
248 248
249 /* all receive handlers return whether they received or reused 249 /* all receive handlers return whether they received or reused
250 * the supplied skb. if not, we have to free the skb. 250 * the supplied skb. if not, we have to free the skb.
251 */ 251 */
252 idx = batman_ogm_packet->header.packet_type; 252 idx = batadv_ogm_packet->header.packet_type;
253 ret = (*batadv_rx_handler[idx])(skb, hard_iface); 253 ret = (*batadv_rx_handler[idx])(skb, hard_iface);
254 254
255 if (ret == NET_RX_DROP) 255 if (ret == NET_RX_DROP)
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index 59e328a22fb9..8d3e55a96adc 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -101,20 +101,20 @@ enum batadv_bla_claimframe {
101/* the destination hardware field in the ARP frame is used to 101/* the destination hardware field in the ARP frame is used to
102 * transport the claim type and the group id 102 * transport the claim type and the group id
103 */ 103 */
104struct bla_claim_dst { 104struct batadv_bla_claim_dst {
105 uint8_t magic[3]; /* FF:43:05 */ 105 uint8_t magic[3]; /* FF:43:05 */
106 uint8_t type; /* bla_claimframe */ 106 uint8_t type; /* bla_claimframe */
107 __be16 group; /* group id */ 107 __be16 group; /* group id */
108} __packed; 108} __packed;
109 109
110struct batman_header { 110struct batadv_header {
111 uint8_t packet_type; 111 uint8_t packet_type;
112 uint8_t version; /* batman version field */ 112 uint8_t version; /* batman version field */
113 uint8_t ttl; 113 uint8_t ttl;
114} __packed; 114} __packed;
115 115
116struct batman_ogm_packet { 116struct batadv_ogm_packet {
117 struct batman_header header; 117 struct batadv_header header;
118 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */ 118 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
119 __be32 seqno; 119 __be32 seqno;
120 uint8_t orig[ETH_ALEN]; 120 uint8_t orig[ETH_ALEN];
@@ -126,10 +126,10 @@ struct batman_ogm_packet {
126 __be16 tt_crc; 126 __be16 tt_crc;
127} __packed; 127} __packed;
128 128
129#define BATADV_OGM_HLEN sizeof(struct batman_ogm_packet) 129#define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet)
130 130
131struct icmp_packet { 131struct batadv_icmp_packet {
132 struct batman_header header; 132 struct batadv_header header;
133 uint8_t msg_type; /* see ICMP message types above */ 133 uint8_t msg_type; /* see ICMP message types above */
134 uint8_t dst[ETH_ALEN]; 134 uint8_t dst[ETH_ALEN];
135 uint8_t orig[ETH_ALEN]; 135 uint8_t orig[ETH_ALEN];
@@ -143,8 +143,8 @@ struct icmp_packet {
143/* icmp_packet_rr must start with all fields from imcp_packet 143/* icmp_packet_rr must start with all fields from imcp_packet
144 * as this is assumed by code that handles ICMP packets 144 * as this is assumed by code that handles ICMP packets
145 */ 145 */
146struct icmp_packet_rr { 146struct batadv_icmp_packet_rr {
147 struct batman_header header; 147 struct batadv_header header;
148 uint8_t msg_type; /* see ICMP message types above */ 148 uint8_t msg_type; /* see ICMP message types above */
149 uint8_t dst[ETH_ALEN]; 149 uint8_t dst[ETH_ALEN];
150 uint8_t orig[ETH_ALEN]; 150 uint8_t orig[ETH_ALEN];
@@ -154,14 +154,14 @@ struct icmp_packet_rr {
154 uint8_t rr[BATADV_RR_LEN][ETH_ALEN]; 154 uint8_t rr[BATADV_RR_LEN][ETH_ALEN];
155} __packed; 155} __packed;
156 156
157struct unicast_packet { 157struct batadv_unicast_packet {
158 struct batman_header header; 158 struct batadv_header header;
159 uint8_t ttvn; /* destination translation table version number */ 159 uint8_t ttvn; /* destination translation table version number */
160 uint8_t dest[ETH_ALEN]; 160 uint8_t dest[ETH_ALEN];
161} __packed; 161} __packed;
162 162
163struct unicast_frag_packet { 163struct batadv_unicast_frag_packet {
164 struct batman_header header; 164 struct batadv_header header;
165 uint8_t ttvn; /* destination translation table version number */ 165 uint8_t ttvn; /* destination translation table version number */
166 uint8_t dest[ETH_ALEN]; 166 uint8_t dest[ETH_ALEN];
167 uint8_t flags; 167 uint8_t flags;
@@ -170,15 +170,15 @@ struct unicast_frag_packet {
170 __be16 seqno; 170 __be16 seqno;
171} __packed; 171} __packed;
172 172
173struct bcast_packet { 173struct batadv_bcast_packet {
174 struct batman_header header; 174 struct batadv_header header;
175 uint8_t reserved; 175 uint8_t reserved;
176 __be32 seqno; 176 __be32 seqno;
177 uint8_t orig[ETH_ALEN]; 177 uint8_t orig[ETH_ALEN];
178} __packed; 178} __packed;
179 179
180struct vis_packet { 180struct batadv_vis_packet {
181 struct batman_header header; 181 struct batadv_header header;
182 uint8_t vis_type; /* which type of vis-participant sent this? */ 182 uint8_t vis_type; /* which type of vis-participant sent this? */
183 __be32 seqno; /* sequence number */ 183 __be32 seqno; /* sequence number */
184 uint8_t entries; /* number of entries behind this struct */ 184 uint8_t entries; /* number of entries behind this struct */
@@ -188,8 +188,8 @@ struct vis_packet {
188 uint8_t sender_orig[ETH_ALEN]; /* who sent or forwarded this packet */ 188 uint8_t sender_orig[ETH_ALEN]; /* who sent or forwarded this packet */
189} __packed; 189} __packed;
190 190
191struct tt_query_packet { 191struct batadv_tt_query_packet {
192 struct batman_header header; 192 struct batadv_header header;
193 /* the flag field is a combination of: 193 /* the flag field is a combination of:
194 * - TT_REQUEST or TT_RESPONSE 194 * - TT_REQUEST or TT_RESPONSE
195 * - TT_FULL_TABLE 195 * - TT_FULL_TABLE
@@ -212,15 +212,15 @@ struct tt_query_packet {
212 __be16 tt_data; 212 __be16 tt_data;
213} __packed; 213} __packed;
214 214
215struct roam_adv_packet { 215struct batadv_roam_adv_packet {
216 struct batman_header header; 216 struct batadv_header header;
217 uint8_t reserved; 217 uint8_t reserved;
218 uint8_t dst[ETH_ALEN]; 218 uint8_t dst[ETH_ALEN];
219 uint8_t src[ETH_ALEN]; 219 uint8_t src[ETH_ALEN];
220 uint8_t client[ETH_ALEN]; 220 uint8_t client[ETH_ALEN];
221} __packed; 221} __packed;
222 222
223struct tt_change { 223struct batadv_tt_change {
224 uint8_t flags; 224 uint8_t flags;
225 uint8_t addr[ETH_ALEN]; 225 uint8_t addr[ETH_ALEN];
226} __packed; 226} __packed;
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 86d444a87bde..e15790761105 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -217,7 +217,7 @@ out:
217void 217void
218batadv_bonding_save_primary(const struct orig_node *orig_node, 218batadv_bonding_save_primary(const struct orig_node *orig_node,
219 struct orig_node *orig_neigh_node, 219 struct orig_node *orig_neigh_node,
220 const struct batman_ogm_packet *batman_ogm_packet) 220 const struct batadv_ogm_packet *batman_ogm_packet)
221{ 221{
222 if (!(batman_ogm_packet->flags & BATADV_PRIMARIES_FIRST_HOP)) 222 if (!(batman_ogm_packet->flags & BATADV_PRIMARIES_FIRST_HOP))
223 return; 223 return;
@@ -284,10 +284,10 @@ static int batadv_recv_my_icmp_packet(struct bat_priv *bat_priv,
284 struct hard_iface *primary_if = NULL; 284 struct hard_iface *primary_if = NULL;
285 struct orig_node *orig_node = NULL; 285 struct orig_node *orig_node = NULL;
286 struct neigh_node *router = NULL; 286 struct neigh_node *router = NULL;
287 struct icmp_packet_rr *icmp_packet; 287 struct batadv_icmp_packet_rr *icmp_packet;
288 int ret = NET_RX_DROP; 288 int ret = NET_RX_DROP;
289 289
290 icmp_packet = (struct icmp_packet_rr *)skb->data; 290 icmp_packet = (struct batadv_icmp_packet_rr *)skb->data;
291 291
292 /* add data to device queue */ 292 /* add data to device queue */
293 if (icmp_packet->msg_type != BATADV_ECHO_REQUEST) { 293 if (icmp_packet->msg_type != BATADV_ECHO_REQUEST) {
@@ -313,7 +313,7 @@ static int batadv_recv_my_icmp_packet(struct bat_priv *bat_priv,
313 if (skb_cow(skb, ETH_HLEN) < 0) 313 if (skb_cow(skb, ETH_HLEN) < 0)
314 goto out; 314 goto out;
315 315
316 icmp_packet = (struct icmp_packet_rr *)skb->data; 316 icmp_packet = (struct batadv_icmp_packet_rr *)skb->data;
317 317
318 memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); 318 memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
319 memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); 319 memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN);
@@ -339,10 +339,10 @@ static int batadv_recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
339 struct hard_iface *primary_if = NULL; 339 struct hard_iface *primary_if = NULL;
340 struct orig_node *orig_node = NULL; 340 struct orig_node *orig_node = NULL;
341 struct neigh_node *router = NULL; 341 struct neigh_node *router = NULL;
342 struct icmp_packet *icmp_packet; 342 struct batadv_icmp_packet *icmp_packet;
343 int ret = NET_RX_DROP; 343 int ret = NET_RX_DROP;
344 344
345 icmp_packet = (struct icmp_packet *)skb->data; 345 icmp_packet = (struct batadv_icmp_packet *)skb->data;
346 346
347 /* send TTL exceeded if packet is an echo request (traceroute) */ 347 /* send TTL exceeded if packet is an echo request (traceroute) */
348 if (icmp_packet->msg_type != BATADV_ECHO_REQUEST) { 348 if (icmp_packet->msg_type != BATADV_ECHO_REQUEST) {
@@ -368,7 +368,7 @@ static int batadv_recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
368 if (skb_cow(skb, ETH_HLEN) < 0) 368 if (skb_cow(skb, ETH_HLEN) < 0)
369 goto out; 369 goto out;
370 370
371 icmp_packet = (struct icmp_packet *)skb->data; 371 icmp_packet = (struct batadv_icmp_packet *)skb->data;
372 372
373 memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); 373 memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
374 memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); 374 memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN);
@@ -392,16 +392,16 @@ out:
392int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if) 392int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
393{ 393{
394 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 394 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface);
395 struct icmp_packet_rr *icmp_packet; 395 struct batadv_icmp_packet_rr *icmp_packet;
396 struct ethhdr *ethhdr; 396 struct ethhdr *ethhdr;
397 struct orig_node *orig_node = NULL; 397 struct orig_node *orig_node = NULL;
398 struct neigh_node *router = NULL; 398 struct neigh_node *router = NULL;
399 int hdr_size = sizeof(struct icmp_packet); 399 int hdr_size = sizeof(struct batadv_icmp_packet);
400 int ret = NET_RX_DROP; 400 int ret = NET_RX_DROP;
401 401
402 /* we truncate all incoming icmp packets if they don't match our size */ 402 /* we truncate all incoming icmp packets if they don't match our size */
403 if (skb->len >= sizeof(struct icmp_packet_rr)) 403 if (skb->len >= sizeof(struct batadv_icmp_packet_rr))
404 hdr_size = sizeof(struct icmp_packet_rr); 404 hdr_size = sizeof(struct batadv_icmp_packet_rr);
405 405
406 /* drop packet if it has not necessary minimum size */ 406 /* drop packet if it has not necessary minimum size */
407 if (unlikely(!pskb_may_pull(skb, hdr_size))) 407 if (unlikely(!pskb_may_pull(skb, hdr_size)))
@@ -421,10 +421,10 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
421 if (!batadv_is_my_mac(ethhdr->h_dest)) 421 if (!batadv_is_my_mac(ethhdr->h_dest))
422 goto out; 422 goto out;
423 423
424 icmp_packet = (struct icmp_packet_rr *)skb->data; 424 icmp_packet = (struct batadv_icmp_packet_rr *)skb->data;
425 425
426 /* add record route information if not full */ 426 /* add record route information if not full */
427 if ((hdr_size == sizeof(struct icmp_packet_rr)) && 427 if ((hdr_size == sizeof(struct batadv_icmp_packet_rr)) &&
428 (icmp_packet->rr_cur < BATADV_RR_LEN)) { 428 (icmp_packet->rr_cur < BATADV_RR_LEN)) {
429 memcpy(&(icmp_packet->rr[icmp_packet->rr_cur]), 429 memcpy(&(icmp_packet->rr[icmp_packet->rr_cur]),
430 ethhdr->h_dest, ETH_ALEN); 430 ethhdr->h_dest, ETH_ALEN);
@@ -452,7 +452,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
452 if (skb_cow(skb, ETH_HLEN) < 0) 452 if (skb_cow(skb, ETH_HLEN) < 0)
453 goto out; 453 goto out;
454 454
455 icmp_packet = (struct icmp_packet_rr *)skb->data; 455 icmp_packet = (struct batadv_icmp_packet_rr *)skb->data;
456 456
457 /* decrement ttl */ 457 /* decrement ttl */
458 icmp_packet->header.ttl--; 458 icmp_packet->header.ttl--;
@@ -580,17 +580,19 @@ batadv_find_ifalter_router(struct orig_node *primary_orig,
580int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) 580int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
581{ 581{
582 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 582 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface);
583 struct tt_query_packet *tt_query; 583 struct batadv_tt_query_packet *tt_query;
584 uint16_t tt_size; 584 uint16_t tt_size;
585 struct ethhdr *ethhdr; 585 struct ethhdr *ethhdr;
586 char tt_flag; 586 char tt_flag;
587 size_t packet_size;
587 588
588 /* drop packet if it has not necessary minimum size */ 589 /* drop packet if it has not necessary minimum size */
589 if (unlikely(!pskb_may_pull(skb, sizeof(struct tt_query_packet)))) 590 if (unlikely(!pskb_may_pull(skb,
591 sizeof(struct batadv_tt_query_packet))))
590 goto out; 592 goto out;
591 593
592 /* I could need to modify it */ 594 /* I could need to modify it */
593 if (skb_cow(skb, sizeof(struct tt_query_packet)) < 0) 595 if (skb_cow(skb, sizeof(struct batadv_tt_query_packet)) < 0)
594 goto out; 596 goto out;
595 597
596 ethhdr = (struct ethhdr *)skb_mac_header(skb); 598 ethhdr = (struct ethhdr *)skb_mac_header(skb);
@@ -603,7 +605,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
603 if (is_broadcast_ether_addr(ethhdr->h_source)) 605 if (is_broadcast_ether_addr(ethhdr->h_source))
604 goto out; 606 goto out;
605 607
606 tt_query = (struct tt_query_packet *)skb->data; 608 tt_query = (struct batadv_tt_query_packet *)skb->data;
607 609
608 switch (tt_query->flags & BATADV_TT_QUERY_TYPE_MASK) { 610 switch (tt_query->flags & BATADV_TT_QUERY_TYPE_MASK) {
609 case BATADV_TT_REQUEST: 611 case BATADV_TT_REQUEST:
@@ -635,13 +637,14 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
635 if (skb_linearize(skb) < 0) 637 if (skb_linearize(skb) < 0)
636 goto out; 638 goto out;
637 /* skb_linearize() possibly changed skb->data */ 639 /* skb_linearize() possibly changed skb->data */
638 tt_query = (struct tt_query_packet *)skb->data; 640 tt_query = (struct batadv_tt_query_packet *)skb->data;
639 641
640 tt_size = batadv_tt_len(ntohs(tt_query->tt_data)); 642 tt_size = batadv_tt_len(ntohs(tt_query->tt_data));
641 643
642 /* Ensure we have all the claimed data */ 644 /* Ensure we have all the claimed data */
643 if (unlikely(skb_headlen(skb) < 645 packet_size = sizeof(struct batadv_tt_query_packet);
644 sizeof(struct tt_query_packet) + tt_size)) 646 packet_size += tt_size;
647 if (unlikely(skb_headlen(skb) < packet_size))
645 goto out; 648 goto out;
646 649
647 batadv_handle_tt_response(bat_priv, tt_query); 650 batadv_handle_tt_response(bat_priv, tt_query);
@@ -667,12 +670,13 @@ out:
667int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if) 670int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if)
668{ 671{
669 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 672 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface);
670 struct roam_adv_packet *roam_adv_packet; 673 struct batadv_roam_adv_packet *roam_adv_packet;
671 struct orig_node *orig_node; 674 struct orig_node *orig_node;
672 struct ethhdr *ethhdr; 675 struct ethhdr *ethhdr;
673 676
674 /* drop packet if it has not necessary minimum size */ 677 /* drop packet if it has not necessary minimum size */
675 if (unlikely(!pskb_may_pull(skb, sizeof(struct roam_adv_packet)))) 678 if (unlikely(!pskb_may_pull(skb,
679 sizeof(struct batadv_roam_adv_packet))))
676 goto out; 680 goto out;
677 681
678 ethhdr = (struct ethhdr *)skb_mac_header(skb); 682 ethhdr = (struct ethhdr *)skb_mac_header(skb);
@@ -687,7 +691,7 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if)
687 691
688 batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_RX); 692 batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_RX);
689 693
690 roam_adv_packet = (struct roam_adv_packet *)skb->data; 694 roam_adv_packet = (struct batadv_roam_adv_packet *)skb->data;
691 695
692 if (!batadv_is_my_mac(roam_adv_packet->dst)) 696 if (!batadv_is_my_mac(roam_adv_packet->dst))
693 return batadv_route_unicast_packet(skb, recv_if); 697 return batadv_route_unicast_packet(skb, recv_if);
@@ -843,12 +847,12 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
843 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 847 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface);
844 struct orig_node *orig_node = NULL; 848 struct orig_node *orig_node = NULL;
845 struct neigh_node *neigh_node = NULL; 849 struct neigh_node *neigh_node = NULL;
846 struct unicast_packet *unicast_packet; 850 struct batadv_unicast_packet *unicast_packet;
847 struct ethhdr *ethhdr = (struct ethhdr *)skb_mac_header(skb); 851 struct ethhdr *ethhdr = (struct ethhdr *)skb_mac_header(skb);
848 int ret = NET_RX_DROP; 852 int ret = NET_RX_DROP;
849 struct sk_buff *new_skb; 853 struct sk_buff *new_skb;
850 854
851 unicast_packet = (struct unicast_packet *)skb->data; 855 unicast_packet = (struct batadv_unicast_packet *)skb->data;
852 856
853 /* TTL exceeded */ 857 /* TTL exceeded */
854 if (unicast_packet->header.ttl < 2) { 858 if (unicast_packet->header.ttl < 2) {
@@ -873,7 +877,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
873 if (skb_cow(skb, ETH_HLEN) < 0) 877 if (skb_cow(skb, ETH_HLEN) < 0)
874 goto out; 878 goto out;
875 879
876 unicast_packet = (struct unicast_packet *)skb->data; 880 unicast_packet = (struct batadv_unicast_packet *)skb->data;
877 881
878 if (unicast_packet->header.packet_type == BATADV_UNICAST && 882 if (unicast_packet->header.packet_type == BATADV_UNICAST &&
879 atomic_read(&bat_priv->fragmentation) && 883 atomic_read(&bat_priv->fragmentation) &&
@@ -900,7 +904,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
900 } 904 }
901 905
902 skb = new_skb; 906 skb = new_skb;
903 unicast_packet = (struct unicast_packet *)skb->data; 907 unicast_packet = (struct batadv_unicast_packet *)skb->data;
904 } 908 }
905 909
906 /* decrement ttl */ 910 /* decrement ttl */
@@ -929,15 +933,15 @@ static int batadv_check_unicast_ttvn(struct bat_priv *bat_priv,
929 struct orig_node *orig_node; 933 struct orig_node *orig_node;
930 struct ethhdr *ethhdr; 934 struct ethhdr *ethhdr;
931 struct hard_iface *primary_if; 935 struct hard_iface *primary_if;
932 struct unicast_packet *unicast_packet; 936 struct batadv_unicast_packet *unicast_packet;
933 bool tt_poss_change; 937 bool tt_poss_change;
934 int is_old_ttvn; 938 int is_old_ttvn;
935 939
936 /* I could need to modify it */ 940 /* I could need to modify it */
937 if (skb_cow(skb, sizeof(struct unicast_packet)) < 0) 941 if (skb_cow(skb, sizeof(struct batadv_unicast_packet)) < 0)
938 return 0; 942 return 0;
939 943
940 unicast_packet = (struct unicast_packet *)skb->data; 944 unicast_packet = (struct batadv_unicast_packet *)skb->data;
941 945
942 if (batadv_is_my_mac(unicast_packet->dest)) { 946 if (batadv_is_my_mac(unicast_packet->dest)) {
943 tt_poss_change = bat_priv->tt_poss_change; 947 tt_poss_change = bat_priv->tt_poss_change;
@@ -958,12 +962,12 @@ static int batadv_check_unicast_ttvn(struct bat_priv *bat_priv,
958 is_old_ttvn = batadv_seq_before(unicast_packet->ttvn, curr_ttvn); 962 is_old_ttvn = batadv_seq_before(unicast_packet->ttvn, curr_ttvn);
959 if (is_old_ttvn || tt_poss_change) { 963 if (is_old_ttvn || tt_poss_change) {
960 /* check if there is enough data before accessing it */ 964 /* check if there is enough data before accessing it */
961 if (pskb_may_pull(skb, sizeof(struct unicast_packet) + 965 if (pskb_may_pull(skb, sizeof(struct batadv_unicast_packet) +
962 ETH_HLEN) < 0) 966 ETH_HLEN) < 0)
963 return 0; 967 return 0;
964 968
965 ethhdr = (struct ethhdr *)(skb->data + 969 ethhdr = (struct ethhdr *)(skb->data +
966 sizeof(struct unicast_packet)); 970 sizeof(struct batadv_unicast_packet));
967 971
968 /* we don't have an updated route for this client, so we should 972 /* we don't have an updated route for this client, so we should
969 * not try to reroute the packet!! 973 * not try to reroute the packet!!
@@ -1005,7 +1009,7 @@ static int batadv_check_unicast_ttvn(struct bat_priv *bat_priv,
1005int batadv_recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if) 1009int batadv_recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1006{ 1010{
1007 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 1011 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface);
1008 struct unicast_packet *unicast_packet; 1012 struct batadv_unicast_packet *unicast_packet;
1009 int hdr_size = sizeof(*unicast_packet); 1013 int hdr_size = sizeof(*unicast_packet);
1010 1014
1011 if (batadv_check_unicast_packet(skb, hdr_size) < 0) 1015 if (batadv_check_unicast_packet(skb, hdr_size) < 0)
@@ -1014,7 +1018,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1014 if (!batadv_check_unicast_ttvn(bat_priv, skb)) 1018 if (!batadv_check_unicast_ttvn(bat_priv, skb))
1015 return NET_RX_DROP; 1019 return NET_RX_DROP;
1016 1020
1017 unicast_packet = (struct unicast_packet *)skb->data; 1021 unicast_packet = (struct batadv_unicast_packet *)skb->data;
1018 1022
1019 /* packet for me */ 1023 /* packet for me */
1020 if (batadv_is_my_mac(unicast_packet->dest)) { 1024 if (batadv_is_my_mac(unicast_packet->dest)) {
@@ -1030,7 +1034,7 @@ int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
1030 struct hard_iface *recv_if) 1034 struct hard_iface *recv_if)
1031{ 1035{
1032 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 1036 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface);
1033 struct unicast_frag_packet *unicast_packet; 1037 struct batadv_unicast_frag_packet *unicast_packet;
1034 int hdr_size = sizeof(*unicast_packet); 1038 int hdr_size = sizeof(*unicast_packet);
1035 struct sk_buff *new_skb = NULL; 1039 struct sk_buff *new_skb = NULL;
1036 int ret; 1040 int ret;
@@ -1041,7 +1045,7 @@ int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
1041 if (!batadv_check_unicast_ttvn(bat_priv, skb)) 1045 if (!batadv_check_unicast_ttvn(bat_priv, skb))
1042 return NET_RX_DROP; 1046 return NET_RX_DROP;
1043 1047
1044 unicast_packet = (struct unicast_frag_packet *)skb->data; 1048 unicast_packet = (struct batadv_unicast_frag_packet *)skb->data;
1045 1049
1046 /* packet for me */ 1050 /* packet for me */
1047 if (batadv_is_my_mac(unicast_packet->dest)) { 1051 if (batadv_is_my_mac(unicast_packet->dest)) {
@@ -1056,7 +1060,7 @@ int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
1056 return NET_RX_SUCCESS; 1060 return NET_RX_SUCCESS;
1057 1061
1058 batadv_interface_rx(recv_if->soft_iface, new_skb, recv_if, 1062 batadv_interface_rx(recv_if->soft_iface, new_skb, recv_if,
1059 sizeof(struct unicast_packet)); 1063 sizeof(struct batadv_unicast_packet));
1060 return NET_RX_SUCCESS; 1064 return NET_RX_SUCCESS;
1061 } 1065 }
1062 1066
@@ -1068,7 +1072,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1068{ 1072{
1069 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 1073 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface);
1070 struct orig_node *orig_node = NULL; 1074 struct orig_node *orig_node = NULL;
1071 struct bcast_packet *bcast_packet; 1075 struct batadv_bcast_packet *bcast_packet;
1072 struct ethhdr *ethhdr; 1076 struct ethhdr *ethhdr;
1073 int hdr_size = sizeof(*bcast_packet); 1077 int hdr_size = sizeof(*bcast_packet);
1074 int ret = NET_RX_DROP; 1078 int ret = NET_RX_DROP;
@@ -1092,7 +1096,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1092 if (batadv_is_my_mac(ethhdr->h_source)) 1096 if (batadv_is_my_mac(ethhdr->h_source))
1093 goto out; 1097 goto out;
1094 1098
1095 bcast_packet = (struct bcast_packet *)skb->data; 1099 bcast_packet = (struct batadv_bcast_packet *)skb->data;
1096 1100
1097 /* ignore broadcasts originated by myself */ 1101 /* ignore broadcasts originated by myself */
1098 if (batadv_is_my_mac(bcast_packet->orig)) 1102 if (batadv_is_my_mac(bcast_packet->orig))
@@ -1156,7 +1160,7 @@ out:
1156 1160
1157int batadv_recv_vis_packet(struct sk_buff *skb, struct hard_iface *recv_if) 1161int batadv_recv_vis_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1158{ 1162{
1159 struct vis_packet *vis_packet; 1163 struct batadv_vis_packet *vis_packet;
1160 struct ethhdr *ethhdr; 1164 struct ethhdr *ethhdr;
1161 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 1165 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface);
1162 int hdr_size = sizeof(*vis_packet); 1166 int hdr_size = sizeof(*vis_packet);
@@ -1168,7 +1172,7 @@ int batadv_recv_vis_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1168 if (unlikely(!pskb_may_pull(skb, hdr_size))) 1172 if (unlikely(!pskb_may_pull(skb, hdr_size)))
1169 return NET_RX_DROP; 1173 return NET_RX_DROP;
1170 1174
1171 vis_packet = (struct vis_packet *)skb->data; 1175 vis_packet = (struct batadv_vis_packet *)skb->data;
1172 ethhdr = (struct ethhdr *)skb_mac_header(skb); 1176 ethhdr = (struct ethhdr *)skb_mac_header(skb);
1173 1177
1174 /* not for me */ 1178 /* not for me */
diff --git a/net/batman-adv/routing.h b/net/batman-adv/routing.h
index c3fd219e8e53..ead4ae055776 100644
--- a/net/batman-adv/routing.h
+++ b/net/batman-adv/routing.h
@@ -43,7 +43,7 @@ void batadv_bonding_candidate_add(struct orig_node *orig_node,
43 struct neigh_node *neigh_node); 43 struct neigh_node *neigh_node);
44void batadv_bonding_save_primary(const struct orig_node *orig_node, 44void batadv_bonding_save_primary(const struct orig_node *orig_node,
45 struct orig_node *orig_neigh_node, 45 struct orig_node *orig_neigh_node,
46 const struct batman_ogm_packet 46 const struct batadv_ogm_packet
47 *batman_ogm_packet); 47 *batman_ogm_packet);
48int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, 48int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff,
49 unsigned long *last_reset); 49 unsigned long *last_reset);
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index aad981859688..67c1c6c22f3b 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -138,7 +138,7 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv,
138{ 138{
139 struct hard_iface *primary_if = NULL; 139 struct hard_iface *primary_if = NULL;
140 struct forw_packet *forw_packet; 140 struct forw_packet *forw_packet;
141 struct bcast_packet *bcast_packet; 141 struct batadv_bcast_packet *bcast_packet;
142 struct sk_buff *newskb; 142 struct sk_buff *newskb;
143 143
144 if (!batadv_atomic_dec_not_zero(&bat_priv->bcast_queue_left)) { 144 if (!batadv_atomic_dec_not_zero(&bat_priv->bcast_queue_left)) {
@@ -161,7 +161,7 @@ int batadv_add_bcast_packet_to_list(struct bat_priv *bat_priv,
161 goto packet_free; 161 goto packet_free;
162 162
163 /* as we have a copy now, it is safe to decrease the TTL */ 163 /* as we have a copy now, it is safe to decrease the TTL */
164 bcast_packet = (struct bcast_packet *)newskb->data; 164 bcast_packet = (struct batadv_bcast_packet *)newskb->data;
165 bcast_packet->header.ttl--; 165 bcast_packet->header.ttl--;
166 166
167 skb_reset_mac_header(newskb); 167 skb_reset_mac_header(newskb);
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 0a00324e67e3..0a5d73a549f6 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -133,7 +133,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
133 struct ethhdr *ethhdr = (struct ethhdr *)skb->data; 133 struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
134 struct bat_priv *bat_priv = netdev_priv(soft_iface); 134 struct bat_priv *bat_priv = netdev_priv(soft_iface);
135 struct hard_iface *primary_if = NULL; 135 struct hard_iface *primary_if = NULL;
136 struct bcast_packet *bcast_packet; 136 struct batadv_bcast_packet *bcast_packet;
137 struct vlan_ethhdr *vhdr; 137 struct vlan_ethhdr *vhdr;
138 __be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN); 138 __be16 ethertype = __constant_htons(BATADV_ETH_P_BATMAN);
139 static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, 0x00, 139 static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, 0x00,
@@ -208,7 +208,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
208 if (batadv_skb_head_push(skb, sizeof(*bcast_packet)) < 0) 208 if (batadv_skb_head_push(skb, sizeof(*bcast_packet)) < 0)
209 goto dropped; 209 goto dropped;
210 210
211 bcast_packet = (struct bcast_packet *)skb->data; 211 bcast_packet = (struct batadv_bcast_packet *)skb->data;
212 bcast_packet->header.version = BATADV_COMPAT_VERSION; 212 bcast_packet->header.version = BATADV_COMPAT_VERSION;
213 bcast_packet->header.ttl = BATADV_TTL; 213 bcast_packet->header.ttl = BATADV_TTL;
214 214
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 9b35d1f59a11..48217cc6729d 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -212,7 +212,7 @@ unlock:
212 212
213int batadv_tt_len(int changes_num) 213int batadv_tt_len(int changes_num)
214{ 214{
215 return changes_num * sizeof(struct tt_change); 215 return changes_num * sizeof(struct batadv_tt_change);
216} 216}
217 217
218static int batadv_tt_local_init(struct bat_priv *bat_priv) 218static int batadv_tt_local_init(struct bat_priv *bat_priv)
@@ -384,7 +384,7 @@ static int batadv_tt_changes_fill_buff(struct bat_priv *bat_priv,
384 list) { 384 list) {
385 if (count < tot_changes) { 385 if (count < tot_changes) {
386 memcpy(tt_buff + batadv_tt_len(count), 386 memcpy(tt_buff + batadv_tt_len(count),
387 &entry->change, sizeof(struct tt_change)); 387 &entry->change, sizeof(struct batadv_tt_change));
388 count++; 388 count++;
389 } 389 }
390 list_del(&entry->list); 390 list_del(&entry->list);
@@ -1366,31 +1366,32 @@ batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn,
1366 void *cb_data) 1366 void *cb_data)
1367{ 1367{
1368 struct tt_common_entry *tt_common_entry; 1368 struct tt_common_entry *tt_common_entry;
1369 struct tt_query_packet *tt_response; 1369 struct batadv_tt_query_packet *tt_response;
1370 struct tt_change *tt_change; 1370 struct batadv_tt_change *tt_change;
1371 struct hlist_node *node; 1371 struct hlist_node *node;
1372 struct hlist_head *head; 1372 struct hlist_head *head;
1373 struct sk_buff *skb = NULL; 1373 struct sk_buff *skb = NULL;
1374 uint16_t tt_tot, tt_count; 1374 uint16_t tt_tot, tt_count;
1375 ssize_t tt_query_size = sizeof(struct tt_query_packet); 1375 ssize_t tt_query_size = sizeof(struct batadv_tt_query_packet);
1376 uint32_t i; 1376 uint32_t i;
1377 size_t len;
1377 1378
1378 if (tt_query_size + tt_len > primary_if->soft_iface->mtu) { 1379 if (tt_query_size + tt_len > primary_if->soft_iface->mtu) {
1379 tt_len = primary_if->soft_iface->mtu - tt_query_size; 1380 tt_len = primary_if->soft_iface->mtu - tt_query_size;
1380 tt_len -= tt_len % sizeof(struct tt_change); 1381 tt_len -= tt_len % sizeof(struct batadv_tt_change);
1381 } 1382 }
1382 tt_tot = tt_len / sizeof(struct tt_change); 1383 tt_tot = tt_len / sizeof(struct batadv_tt_change);
1383 1384
1384 skb = dev_alloc_skb(tt_query_size + tt_len + ETH_HLEN); 1385 len = tt_query_size + tt_len;
1386 skb = dev_alloc_skb(len + ETH_HLEN);
1385 if (!skb) 1387 if (!skb)
1386 goto out; 1388 goto out;
1387 1389
1388 skb_reserve(skb, ETH_HLEN); 1390 skb_reserve(skb, ETH_HLEN);
1389 tt_response = (struct tt_query_packet *)skb_put(skb, 1391 tt_response = (struct batadv_tt_query_packet *)skb_put(skb, len);
1390 tt_query_size + tt_len);
1391 tt_response->ttvn = ttvn; 1392 tt_response->ttvn = ttvn;
1392 1393
1393 tt_change = (struct tt_change *)(skb->data + tt_query_size); 1394 tt_change = (struct batadv_tt_change *)(skb->data + tt_query_size);
1394 tt_count = 0; 1395 tt_count = 0;
1395 1396
1396 rcu_read_lock(); 1397 rcu_read_lock();
@@ -1430,11 +1431,12 @@ static int batadv_send_tt_request(struct bat_priv *bat_priv,
1430 bool full_table) 1431 bool full_table)
1431{ 1432{
1432 struct sk_buff *skb = NULL; 1433 struct sk_buff *skb = NULL;
1433 struct tt_query_packet *tt_request; 1434 struct batadv_tt_query_packet *tt_request;
1434 struct neigh_node *neigh_node = NULL; 1435 struct neigh_node *neigh_node = NULL;
1435 struct hard_iface *primary_if; 1436 struct hard_iface *primary_if;
1436 struct tt_req_node *tt_req_node = NULL; 1437 struct tt_req_node *tt_req_node = NULL;
1437 int ret = 1; 1438 int ret = 1;
1439 size_t tt_req_len;
1438 1440
1439 primary_if = batadv_primary_if_get_selected(bat_priv); 1441 primary_if = batadv_primary_if_get_selected(bat_priv);
1440 if (!primary_if) 1442 if (!primary_if)
@@ -1447,14 +1449,14 @@ static int batadv_send_tt_request(struct bat_priv *bat_priv,
1447 if (!tt_req_node) 1449 if (!tt_req_node)
1448 goto out; 1450 goto out;
1449 1451
1450 skb = dev_alloc_skb(sizeof(struct tt_query_packet) + ETH_HLEN); 1452 skb = dev_alloc_skb(sizeof(*tt_request) + ETH_HLEN);
1451 if (!skb) 1453 if (!skb)
1452 goto out; 1454 goto out;
1453 1455
1454 skb_reserve(skb, ETH_HLEN); 1456 skb_reserve(skb, ETH_HLEN);
1455 1457
1456 tt_request = (struct tt_query_packet *)skb_put(skb, 1458 tt_req_len = sizeof(*tt_request);
1457 sizeof(struct tt_query_packet)); 1459 tt_request = (struct batadv_tt_query_packet *)skb_put(skb, tt_req_len);
1458 1460
1459 tt_request->header.packet_type = BATADV_TT_QUERY; 1461 tt_request->header.packet_type = BATADV_TT_QUERY;
1460 tt_request->header.version = BATADV_COMPAT_VERSION; 1462 tt_request->header.version = BATADV_COMPAT_VERSION;
@@ -1498,8 +1500,9 @@ out:
1498 return ret; 1500 return ret;
1499} 1501}
1500 1502
1501static bool batadv_send_other_tt_response(struct bat_priv *bat_priv, 1503static bool
1502 struct tt_query_packet *tt_request) 1504batadv_send_other_tt_response(struct bat_priv *bat_priv,
1505 struct batadv_tt_query_packet *tt_request)
1503{ 1506{
1504 struct orig_node *req_dst_orig_node = NULL, *res_dst_orig_node = NULL; 1507 struct orig_node *req_dst_orig_node = NULL, *res_dst_orig_node = NULL;
1505 struct neigh_node *neigh_node = NULL; 1508 struct neigh_node *neigh_node = NULL;
@@ -1510,7 +1513,8 @@ static bool batadv_send_other_tt_response(struct bat_priv *bat_priv,
1510 bool full_table; 1513 bool full_table;
1511 uint16_t tt_len, tt_tot; 1514 uint16_t tt_len, tt_tot;
1512 struct sk_buff *skb = NULL; 1515 struct sk_buff *skb = NULL;
1513 struct tt_query_packet *tt_response; 1516 struct batadv_tt_query_packet *tt_response;
1517 size_t len;
1514 1518
1515 batadv_dbg(BATADV_DBG_TT, bat_priv, 1519 batadv_dbg(BATADV_DBG_TT, bat_priv,
1516 "Received TT_REQUEST from %pM for ttvn: %u (%pM) [%c]\n", 1520 "Received TT_REQUEST from %pM for ttvn: %u (%pM) [%c]\n",
@@ -1555,28 +1559,28 @@ static bool batadv_send_other_tt_response(struct bat_priv *bat_priv,
1555 if (!full_table) { 1559 if (!full_table) {
1556 spin_lock_bh(&req_dst_orig_node->tt_buff_lock); 1560 spin_lock_bh(&req_dst_orig_node->tt_buff_lock);
1557 tt_len = req_dst_orig_node->tt_buff_len; 1561 tt_len = req_dst_orig_node->tt_buff_len;
1558 tt_tot = tt_len / sizeof(struct tt_change); 1562 tt_tot = tt_len / sizeof(struct batadv_tt_change);
1559 1563
1560 skb = dev_alloc_skb(sizeof(struct tt_query_packet) + 1564 len = sizeof(*tt_response) + tt_len;
1561 tt_len + ETH_HLEN); 1565 skb = dev_alloc_skb(len + ETH_HLEN);
1562 if (!skb) 1566 if (!skb)
1563 goto unlock; 1567 goto unlock;
1564 1568
1565 skb_reserve(skb, ETH_HLEN); 1569 skb_reserve(skb, ETH_HLEN);
1566 tt_response = (struct tt_query_packet *)skb_put(skb, 1570 tt_response = (struct batadv_tt_query_packet *)skb_put(skb,
1567 sizeof(struct tt_query_packet) + tt_len); 1571 len);
1568 tt_response->ttvn = req_ttvn; 1572 tt_response->ttvn = req_ttvn;
1569 tt_response->tt_data = htons(tt_tot); 1573 tt_response->tt_data = htons(tt_tot);
1570 1574
1571 tt_buff = skb->data + sizeof(struct tt_query_packet); 1575 tt_buff = skb->data + sizeof(*tt_response);
1572 /* Copy the last orig_node's OGM buffer */ 1576 /* Copy the last orig_node's OGM buffer */
1573 memcpy(tt_buff, req_dst_orig_node->tt_buff, 1577 memcpy(tt_buff, req_dst_orig_node->tt_buff,
1574 req_dst_orig_node->tt_buff_len); 1578 req_dst_orig_node->tt_buff_len);
1575 1579
1576 spin_unlock_bh(&req_dst_orig_node->tt_buff_lock); 1580 spin_unlock_bh(&req_dst_orig_node->tt_buff_lock);
1577 } else { 1581 } else {
1578 tt_len = (uint16_t)atomic_read(&req_dst_orig_node->tt_size) * 1582 tt_len = (uint16_t)atomic_read(&req_dst_orig_node->tt_size);
1579 sizeof(struct tt_change); 1583 tt_len *= sizeof(struct batadv_tt_change);
1580 ttvn = (uint8_t)atomic_read(&req_dst_orig_node->last_ttvn); 1584 ttvn = (uint8_t)atomic_read(&req_dst_orig_node->last_ttvn);
1581 1585
1582 skb = batadv_tt_response_fill_table(tt_len, ttvn, 1586 skb = batadv_tt_response_fill_table(tt_len, ttvn,
@@ -1587,7 +1591,7 @@ static bool batadv_send_other_tt_response(struct bat_priv *bat_priv,
1587 if (!skb) 1591 if (!skb)
1588 goto out; 1592 goto out;
1589 1593
1590 tt_response = (struct tt_query_packet *)skb->data; 1594 tt_response = (struct batadv_tt_query_packet *)skb->data;
1591 } 1595 }
1592 1596
1593 tt_response->header.packet_type = BATADV_TT_QUERY; 1597 tt_response->header.packet_type = BATADV_TT_QUERY;
@@ -1628,8 +1632,10 @@ out:
1628 return ret; 1632 return ret;
1629 1633
1630} 1634}
1631static bool batadv_send_my_tt_response(struct bat_priv *bat_priv, 1635
1632 struct tt_query_packet *tt_request) 1636static bool
1637batadv_send_my_tt_response(struct bat_priv *bat_priv,
1638 struct batadv_tt_query_packet *tt_request)
1633{ 1639{
1634 struct orig_node *orig_node = NULL; 1640 struct orig_node *orig_node = NULL;
1635 struct neigh_node *neigh_node = NULL; 1641 struct neigh_node *neigh_node = NULL;
@@ -1640,7 +1646,8 @@ static bool batadv_send_my_tt_response(struct bat_priv *bat_priv,
1640 bool full_table; 1646 bool full_table;
1641 uint16_t tt_len, tt_tot; 1647 uint16_t tt_len, tt_tot;
1642 struct sk_buff *skb = NULL; 1648 struct sk_buff *skb = NULL;
1643 struct tt_query_packet *tt_response; 1649 struct batadv_tt_query_packet *tt_response;
1650 size_t len;
1644 1651
1645 batadv_dbg(BATADV_DBG_TT, bat_priv, 1652 batadv_dbg(BATADV_DBG_TT, bat_priv,
1646 "Received TT_REQUEST from %pM for ttvn: %u (me) [%c]\n", 1653 "Received TT_REQUEST from %pM for ttvn: %u (me) [%c]\n",
@@ -1678,26 +1685,26 @@ static bool batadv_send_my_tt_response(struct bat_priv *bat_priv,
1678 if (!full_table) { 1685 if (!full_table) {
1679 spin_lock_bh(&bat_priv->tt_buff_lock); 1686 spin_lock_bh(&bat_priv->tt_buff_lock);
1680 tt_len = bat_priv->tt_buff_len; 1687 tt_len = bat_priv->tt_buff_len;
1681 tt_tot = tt_len / sizeof(struct tt_change); 1688 tt_tot = tt_len / sizeof(struct batadv_tt_change);
1682 1689
1683 skb = dev_alloc_skb(sizeof(struct tt_query_packet) + 1690 len = sizeof(*tt_response) + tt_len;
1684 tt_len + ETH_HLEN); 1691 skb = dev_alloc_skb(len + ETH_HLEN);
1685 if (!skb) 1692 if (!skb)
1686 goto unlock; 1693 goto unlock;
1687 1694
1688 skb_reserve(skb, ETH_HLEN); 1695 skb_reserve(skb, ETH_HLEN);
1689 tt_response = (struct tt_query_packet *)skb_put(skb, 1696 tt_response = (struct batadv_tt_query_packet *)skb_put(skb,
1690 sizeof(struct tt_query_packet) + tt_len); 1697 len);
1691 tt_response->ttvn = req_ttvn; 1698 tt_response->ttvn = req_ttvn;
1692 tt_response->tt_data = htons(tt_tot); 1699 tt_response->tt_data = htons(tt_tot);
1693 1700
1694 tt_buff = skb->data + sizeof(struct tt_query_packet); 1701 tt_buff = skb->data + sizeof(*tt_response);
1695 memcpy(tt_buff, bat_priv->tt_buff, 1702 memcpy(tt_buff, bat_priv->tt_buff,
1696 bat_priv->tt_buff_len); 1703 bat_priv->tt_buff_len);
1697 spin_unlock_bh(&bat_priv->tt_buff_lock); 1704 spin_unlock_bh(&bat_priv->tt_buff_lock);
1698 } else { 1705 } else {
1699 tt_len = (uint16_t)atomic_read(&bat_priv->num_local_tt) * 1706 tt_len = (uint16_t)atomic_read(&bat_priv->num_local_tt);
1700 sizeof(struct tt_change); 1707 tt_len *= sizeof(struct batadv_tt_change);
1701 ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); 1708 ttvn = (uint8_t)atomic_read(&bat_priv->ttvn);
1702 1709
1703 skb = batadv_tt_response_fill_table(tt_len, ttvn, 1710 skb = batadv_tt_response_fill_table(tt_len, ttvn,
@@ -1708,7 +1715,7 @@ static bool batadv_send_my_tt_response(struct bat_priv *bat_priv,
1708 if (!skb) 1715 if (!skb)
1709 goto out; 1716 goto out;
1710 1717
1711 tt_response = (struct tt_query_packet *)skb->data; 1718 tt_response = (struct batadv_tt_query_packet *)skb->data;
1712 } 1719 }
1713 1720
1714 tt_response->header.packet_type = BATADV_TT_QUERY; 1721 tt_response->header.packet_type = BATADV_TT_QUERY;
@@ -1748,7 +1755,7 @@ out:
1748} 1755}
1749 1756
1750bool batadv_send_tt_response(struct bat_priv *bat_priv, 1757bool batadv_send_tt_response(struct bat_priv *bat_priv,
1751 struct tt_query_packet *tt_request) 1758 struct batadv_tt_query_packet *tt_request)
1752{ 1759{
1753 if (batadv_is_my_mac(tt_request->dst)) { 1760 if (batadv_is_my_mac(tt_request->dst)) {
1754 /* don't answer backbone gws! */ 1761 /* don't answer backbone gws! */
@@ -1763,7 +1770,7 @@ bool batadv_send_tt_response(struct bat_priv *bat_priv,
1763 1770
1764static void _batadv_tt_update_changes(struct bat_priv *bat_priv, 1771static void _batadv_tt_update_changes(struct bat_priv *bat_priv,
1765 struct orig_node *orig_node, 1772 struct orig_node *orig_node,
1766 struct tt_change *tt_change, 1773 struct batadv_tt_change *tt_change,
1767 uint16_t tt_num_changes, uint8_t ttvn) 1774 uint16_t tt_num_changes, uint8_t ttvn)
1768{ 1775{
1769 int i; 1776 int i;
@@ -1793,7 +1800,7 @@ static void _batadv_tt_update_changes(struct bat_priv *bat_priv,
1793} 1800}
1794 1801
1795static void batadv_tt_fill_gtable(struct bat_priv *bat_priv, 1802static void batadv_tt_fill_gtable(struct bat_priv *bat_priv,
1796 struct tt_query_packet *tt_response) 1803 struct batadv_tt_query_packet *tt_response)
1797{ 1804{
1798 struct orig_node *orig_node = NULL; 1805 struct orig_node *orig_node = NULL;
1799 1806
@@ -1805,7 +1812,7 @@ static void batadv_tt_fill_gtable(struct bat_priv *bat_priv,
1805 batadv_tt_global_del_orig(bat_priv, orig_node, "Received full table"); 1812 batadv_tt_global_del_orig(bat_priv, orig_node, "Received full table");
1806 1813
1807 _batadv_tt_update_changes(bat_priv, orig_node, 1814 _batadv_tt_update_changes(bat_priv, orig_node,
1808 (struct tt_change *)(tt_response + 1), 1815 (struct batadv_tt_change *)(tt_response + 1),
1809 ntohs(tt_response->tt_data), 1816 ntohs(tt_response->tt_data),
1810 tt_response->ttvn); 1817 tt_response->ttvn);
1811 1818
@@ -1825,7 +1832,7 @@ out:
1825static void batadv_tt_update_changes(struct bat_priv *bat_priv, 1832static void batadv_tt_update_changes(struct bat_priv *bat_priv,
1826 struct orig_node *orig_node, 1833 struct orig_node *orig_node,
1827 uint16_t tt_num_changes, uint8_t ttvn, 1834 uint16_t tt_num_changes, uint8_t ttvn,
1828 struct tt_change *tt_change) 1835 struct batadv_tt_change *tt_change)
1829{ 1836{
1830 _batadv_tt_update_changes(bat_priv, orig_node, tt_change, 1837 _batadv_tt_update_changes(bat_priv, orig_node, tt_change,
1831 tt_num_changes, ttvn); 1838 tt_num_changes, ttvn);
@@ -1856,10 +1863,11 @@ out:
1856} 1863}
1857 1864
1858void batadv_handle_tt_response(struct bat_priv *bat_priv, 1865void batadv_handle_tt_response(struct bat_priv *bat_priv,
1859 struct tt_query_packet *tt_response) 1866 struct batadv_tt_query_packet *tt_response)
1860{ 1867{
1861 struct tt_req_node *node, *safe; 1868 struct tt_req_node *node, *safe;
1862 struct orig_node *orig_node = NULL; 1869 struct orig_node *orig_node = NULL;
1870 struct batadv_tt_change *tt_change;
1863 1871
1864 batadv_dbg(BATADV_DBG_TT, bat_priv, 1872 batadv_dbg(BATADV_DBG_TT, bat_priv,
1865 "Received TT_RESPONSE from %pM for ttvn %d t_size: %d [%c]\n", 1873 "Received TT_RESPONSE from %pM for ttvn %d t_size: %d [%c]\n",
@@ -1875,13 +1883,14 @@ void batadv_handle_tt_response(struct bat_priv *bat_priv,
1875 if (!orig_node) 1883 if (!orig_node)
1876 goto out; 1884 goto out;
1877 1885
1878 if (tt_response->flags & BATADV_TT_FULL_TABLE) 1886 if (tt_response->flags & BATADV_TT_FULL_TABLE) {
1879 batadv_tt_fill_gtable(bat_priv, tt_response); 1887 batadv_tt_fill_gtable(bat_priv, tt_response);
1880 else 1888 } else {
1889 tt_change = (struct batadv_tt_change *)(tt_response + 1);
1881 batadv_tt_update_changes(bat_priv, orig_node, 1890 batadv_tt_update_changes(bat_priv, orig_node,
1882 ntohs(tt_response->tt_data), 1891 ntohs(tt_response->tt_data),
1883 tt_response->ttvn, 1892 tt_response->ttvn, tt_change);
1884 (struct tt_change *)(tt_response + 1)); 1893 }
1885 1894
1886 /* Delete the tt_req_node from pending tt_requests list */ 1895 /* Delete the tt_req_node from pending tt_requests list */
1887 spin_lock_bh(&bat_priv->tt_req_list_lock); 1896 spin_lock_bh(&bat_priv->tt_req_list_lock);
@@ -2006,9 +2015,10 @@ static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
2006{ 2015{
2007 struct neigh_node *neigh_node = NULL; 2016 struct neigh_node *neigh_node = NULL;
2008 struct sk_buff *skb = NULL; 2017 struct sk_buff *skb = NULL;
2009 struct roam_adv_packet *roam_adv_packet; 2018 struct batadv_roam_adv_packet *roam_adv_packet;
2010 int ret = 1; 2019 int ret = 1;
2011 struct hard_iface *primary_if; 2020 struct hard_iface *primary_if;
2021 size_t len = sizeof(*roam_adv_packet);
2012 2022
2013 /* before going on we have to check whether the client has 2023 /* before going on we have to check whether the client has
2014 * already roamed to us too many times 2024 * already roamed to us too many times
@@ -2016,14 +2026,13 @@ static void batadv_send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
2016 if (!batadv_tt_check_roam_count(bat_priv, client)) 2026 if (!batadv_tt_check_roam_count(bat_priv, client))
2017 goto out; 2027 goto out;
2018 2028
2019 skb = dev_alloc_skb(sizeof(struct roam_adv_packet) + ETH_HLEN); 2029 skb = dev_alloc_skb(sizeof(*roam_adv_packet) + ETH_HLEN);
2020 if (!skb) 2030 if (!skb)
2021 goto out; 2031 goto out;
2022 2032
2023 skb_reserve(skb, ETH_HLEN); 2033 skb_reserve(skb, ETH_HLEN);
2024 2034
2025 roam_adv_packet = (struct roam_adv_packet *)skb_put(skb, 2035 roam_adv_packet = (struct batadv_roam_adv_packet *)skb_put(skb, len);
2026 sizeof(struct roam_adv_packet));
2027 2036
2028 roam_adv_packet->header.packet_type = BATADV_ROAM_ADV; 2037 roam_adv_packet->header.packet_type = BATADV_ROAM_ADV;
2029 roam_adv_packet->header.version = BATADV_COMPAT_VERSION; 2038 roam_adv_packet->header.version = BATADV_COMPAT_VERSION;
@@ -2255,6 +2264,7 @@ void batadv_tt_update_orig(struct bat_priv *bat_priv,
2255{ 2264{
2256 uint8_t orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn); 2265 uint8_t orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn);
2257 bool full_table = true; 2266 bool full_table = true;
2267 struct batadv_tt_change *tt_change;
2258 2268
2259 /* don't care about a backbone gateways updates. */ 2269 /* don't care about a backbone gateways updates. */
2260 if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig)) 2270 if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig))
@@ -2275,8 +2285,9 @@ void batadv_tt_update_orig(struct bat_priv *bat_priv,
2275 goto request_table; 2285 goto request_table;
2276 } 2286 }
2277 2287
2288 tt_change = (struct batadv_tt_change *)tt_buff;
2278 batadv_tt_update_changes(bat_priv, orig_node, tt_num_changes, 2289 batadv_tt_update_changes(bat_priv, orig_node, tt_num_changes,
2279 ttvn, (struct tt_change *)tt_buff); 2290 ttvn, tt_change);
2280 2291
2281 /* Even if we received the precomputed crc with the OGM, we 2292 /* Even if we received the precomputed crc with the OGM, we
2282 * prefer to recompute it to spot any possible inconsistency 2293 * prefer to recompute it to spot any possible inconsistency
diff --git a/net/batman-adv/translation-table.h b/net/batman-adv/translation-table.h
index 46b60bd822fe..4e83b293992b 100644
--- a/net/batman-adv/translation-table.h
+++ b/net/batman-adv/translation-table.h
@@ -43,10 +43,10 @@ struct orig_node *batadv_transtable_search(struct bat_priv *bat_priv,
43 const uint8_t *addr); 43 const uint8_t *addr);
44void batadv_tt_free(struct bat_priv *bat_priv); 44void batadv_tt_free(struct bat_priv *bat_priv);
45bool batadv_send_tt_response(struct bat_priv *bat_priv, 45bool batadv_send_tt_response(struct bat_priv *bat_priv,
46 struct tt_query_packet *tt_request); 46 struct batadv_tt_query_packet *tt_request);
47bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr); 47bool batadv_is_my_client(struct bat_priv *bat_priv, const uint8_t *addr);
48void batadv_handle_tt_response(struct bat_priv *bat_priv, 48void batadv_handle_tt_response(struct bat_priv *bat_priv,
49 struct tt_query_packet *tt_response); 49 struct batadv_tt_query_packet *tt_response);
50bool batadv_is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, 50bool batadv_is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src,
51 uint8_t *dst); 51 uint8_t *dst);
52void batadv_tt_update_orig(struct bat_priv *bat_priv, 52void batadv_tt_update_orig(struct bat_priv *bat_priv,
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 9dddaf1c1ca0..fb61d9cd912f 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -25,8 +25,8 @@
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26 26
27#define BATADV_HEADER_LEN \ 27#define BATADV_HEADER_LEN \
28 (ETH_HLEN + max(sizeof(struct unicast_packet), \ 28 (ETH_HLEN + max(sizeof(struct batadv_unicast_packet), \
29 sizeof(struct bcast_packet))) 29 sizeof(struct batadv_bcast_packet)))
30 30
31struct hard_iface { 31struct hard_iface {
32 struct list_head list; 32 struct list_head list;
@@ -211,7 +211,7 @@ struct bat_priv {
211#ifdef CONFIG_BATMAN_ADV_BLA 211#ifdef CONFIG_BATMAN_ADV_BLA
212 struct bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE]; 212 struct bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE];
213 int bcast_duplist_curr; 213 int bcast_duplist_curr;
214 struct bla_claim_dst claim_dest; 214 struct batadv_bla_claim_dst claim_dest;
215#endif 215#endif
216 spinlock_t forw_bat_list_lock; /* protects forw_bat_list */ 216 spinlock_t forw_bat_list_lock; /* protects forw_bat_list */
217 spinlock_t forw_bcast_list_lock; /* protects */ 217 spinlock_t forw_bcast_list_lock; /* protects */
@@ -250,7 +250,7 @@ struct socket_client {
250struct socket_packet { 250struct socket_packet {
251 struct list_head list; 251 struct list_head list;
252 size_t icmp_len; 252 size_t icmp_len;
253 struct icmp_packet_rr icmp_packet; 253 struct batadv_icmp_packet_rr icmp_packet;
254}; 254};
255 255
256struct tt_common_entry { 256struct tt_common_entry {
@@ -306,7 +306,7 @@ struct claim {
306 306
307struct tt_change_node { 307struct tt_change_node {
308 struct list_head list; 308 struct list_head list;
309 struct tt_change change; 309 struct batadv_tt_change change;
310}; 310};
311 311
312struct tt_req_node { 312struct tt_req_node {
diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
index c4603552f9d8..8a2a3df17fff 100644
--- a/net/batman-adv/unicast.c
+++ b/net/batman-adv/unicast.c
@@ -34,13 +34,13 @@ batadv_frag_merge_packet(struct list_head *head,
34 struct frag_packet_list_entry *tfp, 34 struct frag_packet_list_entry *tfp,
35 struct sk_buff *skb) 35 struct sk_buff *skb)
36{ 36{
37 struct unicast_frag_packet *up = 37 struct batadv_unicast_frag_packet *up;
38 (struct unicast_frag_packet *)skb->data;
39 struct sk_buff *tmp_skb; 38 struct sk_buff *tmp_skb;
40 struct unicast_packet *unicast_packet; 39 struct batadv_unicast_packet *unicast_packet;
41 int hdr_len = sizeof(*unicast_packet); 40 int hdr_len = sizeof(*unicast_packet);
42 int uni_diff = sizeof(*up) - hdr_len; 41 int uni_diff = sizeof(*up) - hdr_len;
43 42
43 up = (struct batadv_unicast_frag_packet *)skb->data;
44 /* set skb to the first part and tmp_skb to the second part */ 44 /* set skb to the first part and tmp_skb to the second part */
45 if (up->flags & BATADV_UNI_FRAG_HEAD) { 45 if (up->flags & BATADV_UNI_FRAG_HEAD) {
46 tmp_skb = tfp->skb; 46 tmp_skb = tfp->skb;
@@ -65,7 +65,8 @@ batadv_frag_merge_packet(struct list_head *head,
65 kfree_skb(tmp_skb); 65 kfree_skb(tmp_skb);
66 66
67 memmove(skb->data + uni_diff, skb->data, hdr_len); 67 memmove(skb->data + uni_diff, skb->data, hdr_len);
68 unicast_packet = (struct unicast_packet *)skb_pull(skb, uni_diff); 68 unicast_packet = (struct batadv_unicast_packet *)skb_pull(skb,
69 uni_diff);
69 unicast_packet->header.packet_type = BATADV_UNICAST; 70 unicast_packet->header.packet_type = BATADV_UNICAST;
70 71
71 return skb; 72 return skb;
@@ -80,8 +81,9 @@ static void batadv_frag_create_entry(struct list_head *head,
80 struct sk_buff *skb) 81 struct sk_buff *skb)
81{ 82{
82 struct frag_packet_list_entry *tfp; 83 struct frag_packet_list_entry *tfp;
83 struct unicast_frag_packet *up = 84 struct batadv_unicast_frag_packet *up;
84 (struct unicast_frag_packet *)skb->data; 85
86 up = (struct batadv_unicast_frag_packet *)skb->data;
85 87
86 /* free and oldest packets stand at the end */ 88 /* free and oldest packets stand at the end */
87 tfp = list_entry((head)->prev, typeof(*tfp), list); 89 tfp = list_entry((head)->prev, typeof(*tfp), list);
@@ -115,10 +117,10 @@ static int batadv_frag_create_buffer(struct list_head *head)
115 117
116static struct frag_packet_list_entry * 118static struct frag_packet_list_entry *
117batadv_frag_search_packet(struct list_head *head, 119batadv_frag_search_packet(struct list_head *head,
118 const struct unicast_frag_packet *up) 120 const struct batadv_unicast_frag_packet *up)
119{ 121{
120 struct frag_packet_list_entry *tfp; 122 struct frag_packet_list_entry *tfp;
121 struct unicast_frag_packet *tmp_up = NULL; 123 struct batadv_unicast_frag_packet *tmp_up = NULL;
122 uint16_t search_seqno; 124 uint16_t search_seqno;
123 125
124 if (up->flags & BATADV_UNI_FRAG_HEAD) 126 if (up->flags & BATADV_UNI_FRAG_HEAD)
@@ -134,7 +136,7 @@ batadv_frag_search_packet(struct list_head *head,
134 if (tfp->seqno == ntohs(up->seqno)) 136 if (tfp->seqno == ntohs(up->seqno))
135 goto mov_tail; 137 goto mov_tail;
136 138
137 tmp_up = (struct unicast_frag_packet *)tfp->skb->data; 139 tmp_up = (struct batadv_unicast_frag_packet *)tfp->skb->data;
138 140
139 if (tfp->seqno == search_seqno) { 141 if (tfp->seqno == search_seqno) {
140 142
@@ -179,9 +181,9 @@ int batadv_frag_reassemble_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
179 struct orig_node *orig_node; 181 struct orig_node *orig_node;
180 struct frag_packet_list_entry *tmp_frag_entry; 182 struct frag_packet_list_entry *tmp_frag_entry;
181 int ret = NET_RX_DROP; 183 int ret = NET_RX_DROP;
182 struct unicast_frag_packet *unicast_packet = 184 struct batadv_unicast_frag_packet *unicast_packet;
183 (struct unicast_frag_packet *)skb->data;
184 185
186 unicast_packet = (struct batadv_unicast_frag_packet *)skb->data;
185 *new_skb = NULL; 187 *new_skb = NULL;
186 188
187 orig_node = batadv_orig_hash_find(bat_priv, unicast_packet->orig); 189 orig_node = batadv_orig_hash_find(bat_priv, unicast_packet->orig);
@@ -220,10 +222,10 @@ out:
220int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, 222int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
221 struct hard_iface *hard_iface, const uint8_t dstaddr[]) 223 struct hard_iface *hard_iface, const uint8_t dstaddr[])
222{ 224{
223 struct unicast_packet tmp_uc, *unicast_packet; 225 struct batadv_unicast_packet tmp_uc, *unicast_packet;
224 struct hard_iface *primary_if; 226 struct hard_iface *primary_if;
225 struct sk_buff *frag_skb; 227 struct sk_buff *frag_skb;
226 struct unicast_frag_packet *frag1, *frag2; 228 struct batadv_unicast_frag_packet *frag1, *frag2;
227 int uc_hdr_len = sizeof(*unicast_packet); 229 int uc_hdr_len = sizeof(*unicast_packet);
228 int ucf_hdr_len = sizeof(*frag1); 230 int ucf_hdr_len = sizeof(*frag1);
229 int data_len = skb->len - uc_hdr_len; 231 int data_len = skb->len - uc_hdr_len;
@@ -239,7 +241,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
239 goto dropped; 241 goto dropped;
240 skb_reserve(frag_skb, ucf_hdr_len); 242 skb_reserve(frag_skb, ucf_hdr_len);
241 243
242 unicast_packet = (struct unicast_packet *)skb->data; 244 unicast_packet = (struct batadv_unicast_packet *)skb->data;
243 memcpy(&tmp_uc, unicast_packet, uc_hdr_len); 245 memcpy(&tmp_uc, unicast_packet, uc_hdr_len);
244 skb_split(skb, frag_skb, data_len / 2 + uc_hdr_len); 246 skb_split(skb, frag_skb, data_len / 2 + uc_hdr_len);
245 247
@@ -247,8 +249,8 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
247 batadv_skb_head_push(frag_skb, ucf_hdr_len) < 0) 249 batadv_skb_head_push(frag_skb, ucf_hdr_len) < 0)
248 goto drop_frag; 250 goto drop_frag;
249 251
250 frag1 = (struct unicast_frag_packet *)skb->data; 252 frag1 = (struct batadv_unicast_frag_packet *)skb->data;
251 frag2 = (struct unicast_frag_packet *)frag_skb->data; 253 frag2 = (struct batadv_unicast_frag_packet *)frag_skb->data;
252 254
253 memcpy(frag1, &tmp_uc, sizeof(tmp_uc)); 255 memcpy(frag1, &tmp_uc, sizeof(tmp_uc));
254 256
@@ -287,7 +289,7 @@ out:
287int batadv_unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv) 289int batadv_unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
288{ 290{
289 struct ethhdr *ethhdr = (struct ethhdr *)skb->data; 291 struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
290 struct unicast_packet *unicast_packet; 292 struct batadv_unicast_packet *unicast_packet;
291 struct orig_node *orig_node; 293 struct orig_node *orig_node;
292 struct neigh_node *neigh_node; 294 struct neigh_node *neigh_node;
293 int data_len = skb->len; 295 int data_len = skb->len;
@@ -317,7 +319,7 @@ find_router:
317 if (batadv_skb_head_push(skb, sizeof(*unicast_packet)) < 0) 319 if (batadv_skb_head_push(skb, sizeof(*unicast_packet)) < 0)
318 goto out; 320 goto out;
319 321
320 unicast_packet = (struct unicast_packet *)skb->data; 322 unicast_packet = (struct batadv_unicast_packet *)skb->data;
321 323
322 unicast_packet->header.version = BATADV_COMPAT_VERSION; 324 unicast_packet->header.version = BATADV_COMPAT_VERSION;
323 /* batman packet type: unicast */ 325 /* batman packet type: unicast */
diff --git a/net/batman-adv/unicast.h b/net/batman-adv/unicast.h
index 510e23f4179d..e0b6e335797e 100644
--- a/net/batman-adv/unicast.h
+++ b/net/batman-adv/unicast.h
@@ -35,11 +35,11 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
35 35
36static inline int batadv_frag_can_reassemble(const struct sk_buff *skb, int mtu) 36static inline int batadv_frag_can_reassemble(const struct sk_buff *skb, int mtu)
37{ 37{
38 const struct unicast_frag_packet *unicast_packet; 38 const struct batadv_unicast_frag_packet *unicast_packet;
39 int uneven_correction = 0; 39 int uneven_correction = 0;
40 unsigned int merged_size; 40 unsigned int merged_size;
41 41
42 unicast_packet = (struct unicast_frag_packet *)skb->data; 42 unicast_packet = (struct batadv_unicast_frag_packet *)skb->data;
43 43
44 if (unicast_packet->flags & BATADV_UNI_FRAG_LARGETAIL) { 44 if (unicast_packet->flags & BATADV_UNI_FRAG_LARGETAIL) {
45 if (unicast_packet->flags & BATADV_UNI_FRAG_HEAD) 45 if (unicast_packet->flags & BATADV_UNI_FRAG_HEAD)
@@ -49,7 +49,7 @@ static inline int batadv_frag_can_reassemble(const struct sk_buff *skb, int mtu)
49 } 49 }
50 50
51 merged_size = (skb->len - sizeof(*unicast_packet)) * 2; 51 merged_size = (skb->len - sizeof(*unicast_packet)) * 2;
52 merged_size += sizeof(struct unicast_packet) + uneven_correction; 52 merged_size += sizeof(struct batadv_unicast_packet) + uneven_correction;
53 53
54 return merged_size <= mtu; 54 return merged_size <= mtu;
55} 55}
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c
index c1fafa3b172f..309493d9128a 100644
--- a/net/batman-adv/vis.c
+++ b/net/batman-adv/vis.c
@@ -53,12 +53,12 @@ static void batadv_free_info(struct kref *ref)
53static int batadv_vis_info_cmp(const struct hlist_node *node, const void *data2) 53static int batadv_vis_info_cmp(const struct hlist_node *node, const void *data2)
54{ 54{
55 const struct vis_info *d1, *d2; 55 const struct vis_info *d1, *d2;
56 const struct vis_packet *p1, *p2; 56 const struct batadv_vis_packet *p1, *p2;
57 57
58 d1 = container_of(node, struct vis_info, hash_entry); 58 d1 = container_of(node, struct vis_info, hash_entry);
59 d2 = data2; 59 d2 = data2;
60 p1 = (struct vis_packet *)d1->skb_packet->data; 60 p1 = (struct batadv_vis_packet *)d1->skb_packet->data;
61 p2 = (struct vis_packet *)d2->skb_packet->data; 61 p2 = (struct batadv_vis_packet *)d2->skb_packet->data;
62 return batadv_compare_eth(p1->vis_orig, p2->vis_orig); 62 return batadv_compare_eth(p1->vis_orig, p2->vis_orig);
63} 63}
64 64
@@ -68,12 +68,12 @@ static int batadv_vis_info_cmp(const struct hlist_node *node, const void *data2)
68static uint32_t batadv_vis_info_choose(const void *data, uint32_t size) 68static uint32_t batadv_vis_info_choose(const void *data, uint32_t size)
69{ 69{
70 const struct vis_info *vis_info = data; 70 const struct vis_info *vis_info = data;
71 const struct vis_packet *packet; 71 const struct batadv_vis_packet *packet;
72 const unsigned char *key; 72 const unsigned char *key;
73 uint32_t hash = 0; 73 uint32_t hash = 0;
74 size_t i; 74 size_t i;
75 75
76 packet = (struct vis_packet *)vis_info->skb_packet->data; 76 packet = (struct batadv_vis_packet *)vis_info->skb_packet->data;
77 key = packet->vis_orig; 77 key = packet->vis_orig;
78 for (i = 0; i < ETH_ALEN; i++) { 78 for (i = 0; i < ETH_ALEN; i++) {
79 hash += key[i]; 79 hash += key[i];
@@ -169,7 +169,7 @@ static ssize_t batadv_vis_data_read_entry(struct seq_file *seq,
169} 169}
170 170
171static void batadv_vis_data_insert_interfaces(struct hlist_head *list, 171static void batadv_vis_data_insert_interfaces(struct hlist_head *list,
172 struct vis_packet *packet, 172 struct batadv_vis_packet *packet,
173 struct vis_info_entry *entries) 173 struct vis_info_entry *entries)
174{ 174{
175 int i; 175 int i;
@@ -187,7 +187,7 @@ static void batadv_vis_data_insert_interfaces(struct hlist_head *list,
187 187
188static void batadv_vis_data_read_entries(struct seq_file *seq, 188static void batadv_vis_data_read_entries(struct seq_file *seq,
189 struct hlist_head *list, 189 struct hlist_head *list,
190 struct vis_packet *packet, 190 struct batadv_vis_packet *packet,
191 struct vis_info_entry *entries) 191 struct vis_info_entry *entries)
192{ 192{
193 int i; 193 int i;
@@ -214,7 +214,7 @@ static void batadv_vis_seq_print_text_bucket(struct seq_file *seq,
214{ 214{
215 struct hlist_node *node; 215 struct hlist_node *node;
216 struct vis_info *info; 216 struct vis_info *info;
217 struct vis_packet *packet; 217 struct batadv_vis_packet *packet;
218 uint8_t *entries_pos; 218 uint8_t *entries_pos;
219 struct vis_info_entry *entries; 219 struct vis_info_entry *entries;
220 struct if_list_entry *entry; 220 struct if_list_entry *entry;
@@ -223,7 +223,7 @@ static void batadv_vis_seq_print_text_bucket(struct seq_file *seq,
223 HLIST_HEAD(vis_if_list); 223 HLIST_HEAD(vis_if_list);
224 224
225 hlist_for_each_entry_rcu(info, node, head, hash_entry) { 225 hlist_for_each_entry_rcu(info, node, head, hash_entry) {
226 packet = (struct vis_packet *)info->skb_packet->data; 226 packet = (struct batadv_vis_packet *)info->skb_packet->data;
227 entries_pos = (uint8_t *)packet + sizeof(*packet); 227 entries_pos = (uint8_t *)packet + sizeof(*packet);
228 entries = (struct vis_info_entry *)entries_pos; 228 entries = (struct vis_info_entry *)entries_pos;
229 229
@@ -334,15 +334,17 @@ static int batadv_recv_list_is_in(struct bat_priv *bat_priv,
334 * is newer than old entries in the hash. 334 * is newer than old entries in the hash.
335 */ 335 */
336static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv, 336static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv,
337 struct vis_packet *vis_packet, 337 struct batadv_vis_packet *vis_packet,
338 int vis_info_len, int *is_new, 338 int vis_info_len, int *is_new,
339 int make_broadcast) 339 int make_broadcast)
340{ 340{
341 struct vis_info *info, *old_info; 341 struct vis_info *info, *old_info;
342 struct vis_packet *search_packet, *old_packet; 342 struct batadv_vis_packet *search_packet, *old_packet;
343 struct vis_info search_elem; 343 struct vis_info search_elem;
344 struct vis_packet *packet; 344 struct batadv_vis_packet *packet;
345 struct sk_buff *tmp_skb;
345 int hash_added; 346 int hash_added;
347 size_t len;
346 348
347 *is_new = 0; 349 *is_new = 0;
348 /* sanity check */ 350 /* sanity check */
@@ -353,15 +355,17 @@ static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv,
353 search_elem.skb_packet = dev_alloc_skb(sizeof(*search_packet)); 355 search_elem.skb_packet = dev_alloc_skb(sizeof(*search_packet));
354 if (!search_elem.skb_packet) 356 if (!search_elem.skb_packet)
355 return NULL; 357 return NULL;
356 search_packet = (struct vis_packet *)skb_put(search_elem.skb_packet, 358 len = sizeof(*search_packet);
357 sizeof(*search_packet)); 359 tmp_skb = search_elem.skb_packet;
360 search_packet = (struct batadv_vis_packet *)skb_put(tmp_skb, len);
358 361
359 memcpy(search_packet->vis_orig, vis_packet->vis_orig, ETH_ALEN); 362 memcpy(search_packet->vis_orig, vis_packet->vis_orig, ETH_ALEN);
360 old_info = batadv_vis_hash_find(bat_priv, &search_elem); 363 old_info = batadv_vis_hash_find(bat_priv, &search_elem);
361 kfree_skb(search_elem.skb_packet); 364 kfree_skb(search_elem.skb_packet);
362 365
363 if (old_info) { 366 if (old_info) {
364 old_packet = (struct vis_packet *)old_info->skb_packet->data; 367 tmp_skb = old_info->skb_packet;
368 old_packet = (struct batadv_vis_packet *)tmp_skb->data;
365 if (!batadv_seq_after(ntohl(vis_packet->seqno), 369 if (!batadv_seq_after(ntohl(vis_packet->seqno),
366 ntohl(old_packet->seqno))) { 370 ntohl(old_packet->seqno))) {
367 if (old_packet->seqno == vis_packet->seqno) { 371 if (old_packet->seqno == vis_packet->seqno) {
@@ -385,22 +389,21 @@ static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv,
385 if (!info) 389 if (!info)
386 return NULL; 390 return NULL;
387 391
388 info->skb_packet = dev_alloc_skb(sizeof(*packet) + vis_info_len + 392 len = sizeof(*packet) + vis_info_len;
389 ETH_HLEN); 393 info->skb_packet = dev_alloc_skb(len + ETH_HLEN);
390 if (!info->skb_packet) { 394 if (!info->skb_packet) {
391 kfree(info); 395 kfree(info);
392 return NULL; 396 return NULL;
393 } 397 }
394 skb_reserve(info->skb_packet, ETH_HLEN); 398 skb_reserve(info->skb_packet, ETH_HLEN);
395 packet = (struct vis_packet *)skb_put(info->skb_packet, sizeof(*packet) 399 packet = (struct batadv_vis_packet *)skb_put(info->skb_packet, len);
396 + vis_info_len);
397 400
398 kref_init(&info->refcount); 401 kref_init(&info->refcount);
399 INIT_LIST_HEAD(&info->send_list); 402 INIT_LIST_HEAD(&info->send_list);
400 INIT_LIST_HEAD(&info->recv_list); 403 INIT_LIST_HEAD(&info->recv_list);
401 info->first_seen = jiffies; 404 info->first_seen = jiffies;
402 info->bat_priv = bat_priv; 405 info->bat_priv = bat_priv;
403 memcpy(packet, vis_packet, sizeof(*packet) + vis_info_len); 406 memcpy(packet, vis_packet, len);
404 407
405 /* initialize and add new packet. */ 408 /* initialize and add new packet. */
406 *is_new = 1; 409 *is_new = 1;
@@ -430,7 +433,7 @@ static struct vis_info *batadv_add_packet(struct bat_priv *bat_priv,
430 433
431/* handle the server sync packet, forward if needed. */ 434/* handle the server sync packet, forward if needed. */
432void batadv_receive_server_sync_packet(struct bat_priv *bat_priv, 435void batadv_receive_server_sync_packet(struct bat_priv *bat_priv,
433 struct vis_packet *vis_packet, 436 struct batadv_vis_packet *vis_packet,
434 int vis_info_len) 437 int vis_info_len)
435{ 438{
436 struct vis_info *info; 439 struct vis_info *info;
@@ -456,11 +459,11 @@ end:
456 459
457/* handle an incoming client update packet and schedule forward if needed. */ 460/* handle an incoming client update packet and schedule forward if needed. */
458void batadv_receive_client_update_packet(struct bat_priv *bat_priv, 461void batadv_receive_client_update_packet(struct bat_priv *bat_priv,
459 struct vis_packet *vis_packet, 462 struct batadv_vis_packet *vis_packet,
460 int vis_info_len) 463 int vis_info_len)
461{ 464{
462 struct vis_info *info; 465 struct vis_info *info;
463 struct vis_packet *packet; 466 struct batadv_vis_packet *packet;
464 int is_new; 467 int is_new;
465 int vis_server = atomic_read(&bat_priv->vis_mode); 468 int vis_server = atomic_read(&bat_priv->vis_mode);
466 int are_target = 0; 469 int are_target = 0;
@@ -482,7 +485,7 @@ void batadv_receive_client_update_packet(struct bat_priv *bat_priv,
482 goto end; 485 goto end;
483 /* note that outdated packets will be dropped at this point. */ 486 /* note that outdated packets will be dropped at this point. */
484 487
485 packet = (struct vis_packet *)info->skb_packet->data; 488 packet = (struct batadv_vis_packet *)info->skb_packet->data;
486 489
487 /* send only if we're the target server or ... */ 490 /* send only if we're the target server or ... */
488 if (are_target && is_new) { 491 if (are_target && is_new) {
@@ -511,11 +514,11 @@ static int batadv_find_best_vis_server(struct bat_priv *bat_priv,
511 struct hlist_node *node; 514 struct hlist_node *node;
512 struct hlist_head *head; 515 struct hlist_head *head;
513 struct orig_node *orig_node; 516 struct orig_node *orig_node;
514 struct vis_packet *packet; 517 struct batadv_vis_packet *packet;
515 int best_tq = -1; 518 int best_tq = -1;
516 uint32_t i; 519 uint32_t i;
517 520
518 packet = (struct vis_packet *)info->skb_packet->data; 521 packet = (struct batadv_vis_packet *)info->skb_packet->data;
519 522
520 for (i = 0; i < hash->size; i++) { 523 for (i = 0; i < hash->size; i++) {
521 head = &hash->table[i]; 524 head = &hash->table[i];
@@ -543,10 +546,10 @@ static int batadv_find_best_vis_server(struct bat_priv *bat_priv,
543/* Return true if the vis packet is full. */ 546/* Return true if the vis packet is full. */
544static bool batadv_vis_packet_full(const struct vis_info *info) 547static bool batadv_vis_packet_full(const struct vis_info *info)
545{ 548{
546 const struct vis_packet *packet; 549 const struct batadv_vis_packet *packet;
547 size_t num_items; 550 size_t num_items;
548 551
549 packet = (struct vis_packet *)info->skb_packet->data; 552 packet = (struct batadv_vis_packet *)info->skb_packet->data;
550 num_items = BATADV_MAX_VIS_PACKET_SIZE / sizeof(struct vis_info_entry); 553 num_items = BATADV_MAX_VIS_PACKET_SIZE / sizeof(struct vis_info_entry);
551 554
552 if (num_items < packet->entries + 1) 555 if (num_items < packet->entries + 1)
@@ -565,13 +568,14 @@ static int batadv_generate_vis_packet(struct bat_priv *bat_priv)
565 struct orig_node *orig_node; 568 struct orig_node *orig_node;
566 struct neigh_node *router; 569 struct neigh_node *router;
567 struct vis_info *info = bat_priv->my_vis_info; 570 struct vis_info *info = bat_priv->my_vis_info;
568 struct vis_packet *packet = (struct vis_packet *)info->skb_packet->data; 571 struct batadv_vis_packet *packet;
569 struct vis_info_entry *entry; 572 struct vis_info_entry *entry;
570 struct tt_common_entry *tt_common_entry; 573 struct tt_common_entry *tt_common_entry;
571 int best_tq = -1; 574 int best_tq = -1;
572 uint32_t i; 575 uint32_t i;
573 576
574 info->first_seen = jiffies; 577 info->first_seen = jiffies;
578 packet = (struct batadv_vis_packet *)info->skb_packet->data;
575 packet->vis_type = atomic_read(&bat_priv->vis_mode); 579 packet->vis_type = atomic_read(&bat_priv->vis_mode);
576 580
577 memcpy(packet->target_orig, batadv_broadcast_addr, ETH_ALEN); 581 memcpy(packet->target_orig, batadv_broadcast_addr, ETH_ALEN);
@@ -691,14 +695,14 @@ static void batadv_broadcast_vis_packet(struct bat_priv *bat_priv,
691 struct hlist_node *node; 695 struct hlist_node *node;
692 struct hlist_head *head; 696 struct hlist_head *head;
693 struct orig_node *orig_node; 697 struct orig_node *orig_node;
694 struct vis_packet *packet; 698 struct batadv_vis_packet *packet;
695 struct sk_buff *skb; 699 struct sk_buff *skb;
696 struct hard_iface *hard_iface; 700 struct hard_iface *hard_iface;
697 uint8_t dstaddr[ETH_ALEN]; 701 uint8_t dstaddr[ETH_ALEN];
698 uint32_t i; 702 uint32_t i;
699 703
700 704
701 packet = (struct vis_packet *)info->skb_packet->data; 705 packet = (struct batadv_vis_packet *)info->skb_packet->data;
702 706
703 /* send to all routers in range. */ 707 /* send to all routers in range. */
704 for (i = 0; i < hash->size; i++) { 708 for (i = 0; i < hash->size; i++) {
@@ -745,9 +749,9 @@ static void batadv_unicast_vis_packet(struct bat_priv *bat_priv,
745 struct orig_node *orig_node; 749 struct orig_node *orig_node;
746 struct neigh_node *router = NULL; 750 struct neigh_node *router = NULL;
747 struct sk_buff *skb; 751 struct sk_buff *skb;
748 struct vis_packet *packet; 752 struct batadv_vis_packet *packet;
749 753
750 packet = (struct vis_packet *)info->skb_packet->data; 754 packet = (struct batadv_vis_packet *)info->skb_packet->data;
751 755
752 orig_node = batadv_orig_hash_find(bat_priv, packet->target_orig); 756 orig_node = batadv_orig_hash_find(bat_priv, packet->target_orig);
753 if (!orig_node) 757 if (!orig_node)
@@ -773,13 +777,13 @@ static void batadv_send_vis_packet(struct bat_priv *bat_priv,
773 struct vis_info *info) 777 struct vis_info *info)
774{ 778{
775 struct hard_iface *primary_if; 779 struct hard_iface *primary_if;
776 struct vis_packet *packet; 780 struct batadv_vis_packet *packet;
777 781
778 primary_if = batadv_primary_if_get_selected(bat_priv); 782 primary_if = batadv_primary_if_get_selected(bat_priv);
779 if (!primary_if) 783 if (!primary_if)
780 goto out; 784 goto out;
781 785
782 packet = (struct vis_packet *)info->skb_packet->data; 786 packet = (struct batadv_vis_packet *)info->skb_packet->data;
783 if (packet->header.ttl < 2) { 787 if (packet->header.ttl < 2) {
784 pr_debug("Error - can't send vis packet: ttl exceeded\n"); 788 pr_debug("Error - can't send vis packet: ttl exceeded\n");
785 goto out; 789 goto out;
@@ -838,10 +842,11 @@ static void batadv_send_vis_packets(struct work_struct *work)
838 */ 842 */
839int batadv_vis_init(struct bat_priv *bat_priv) 843int batadv_vis_init(struct bat_priv *bat_priv)
840{ 844{
841 struct vis_packet *packet; 845 struct batadv_vis_packet *packet;
842 int hash_added; 846 int hash_added;
843 unsigned int len; 847 unsigned int len;
844 unsigned long first_seen; 848 unsigned long first_seen;
849 struct sk_buff *tmp_skb;
845 850
846 if (bat_priv->vis_hash) 851 if (bat_priv->vis_hash)
847 return 0; 852 return 0;
@@ -864,8 +869,8 @@ int batadv_vis_init(struct bat_priv *bat_priv)
864 goto free_info; 869 goto free_info;
865 870
866 skb_reserve(bat_priv->my_vis_info->skb_packet, ETH_HLEN); 871 skb_reserve(bat_priv->my_vis_info->skb_packet, ETH_HLEN);
867 packet = (struct vis_packet *)skb_put(bat_priv->my_vis_info->skb_packet, 872 tmp_skb = bat_priv->my_vis_info->skb_packet;
868 sizeof(*packet)); 873 packet = (struct batadv_vis_packet *)skb_put(tmp_skb, sizeof(*packet));
869 874
870 /* prefill the vis info */ 875 /* prefill the vis info */
871 first_seen = jiffies - msecs_to_jiffies(BATADV_VIS_INTERVAL); 876 first_seen = jiffies - msecs_to_jiffies(BATADV_VIS_INTERVAL);
diff --git a/net/batman-adv/vis.h b/net/batman-adv/vis.h
index 16a1a6b7e2c3..d6bfcc7b6ac7 100644
--- a/net/batman-adv/vis.h
+++ b/net/batman-adv/vis.h
@@ -25,10 +25,10 @@
25 25
26int batadv_vis_seq_print_text(struct seq_file *seq, void *offset); 26int batadv_vis_seq_print_text(struct seq_file *seq, void *offset);
27void batadv_receive_server_sync_packet(struct bat_priv *bat_priv, 27void batadv_receive_server_sync_packet(struct bat_priv *bat_priv,
28 struct vis_packet *vis_packet, 28 struct batadv_vis_packet *vis_packet,
29 int vis_info_len); 29 int vis_info_len);
30void batadv_receive_client_update_packet(struct bat_priv *bat_priv, 30void batadv_receive_client_update_packet(struct bat_priv *bat_priv,
31 struct vis_packet *vis_packet, 31 struct batadv_vis_packet *vis_packet,
32 int vis_info_len); 32 int vis_info_len);
33int batadv_vis_init(struct bat_priv *bat_priv); 33int batadv_vis_init(struct bat_priv *bat_priv);
34void batadv_vis_quit(struct bat_priv *bat_priv); 34void batadv_vis_quit(struct bat_priv *bat_priv);