aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv
diff options
context:
space:
mode:
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/bat_iv_ogm.c36
-rw-r--r--net/batman-adv/distributed-arp-table.c6
-rw-r--r--net/batman-adv/fragmentation.c8
-rw-r--r--net/batman-adv/icmp_socket.c6
-rw-r--r--net/batman-adv/main.c16
-rw-r--r--net/batman-adv/network-coding.c22
-rw-r--r--net/batman-adv/packet.h124
-rw-r--r--net/batman-adv/routing.c30
-rw-r--r--net/batman-adv/send.c10
-rw-r--r--net/batman-adv/soft-interface.c18
-rw-r--r--net/batman-adv/translation-table.c6
11 files changed, 177 insertions, 105 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index a2b480a90872..b9c8a6eedf45 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -307,9 +307,9 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
307 hard_iface->bat_iv.ogm_buff = ogm_buff; 307 hard_iface->bat_iv.ogm_buff = ogm_buff;
308 308
309 batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff; 309 batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff;
310 batadv_ogm_packet->header.packet_type = BATADV_IV_OGM; 310 batadv_ogm_packet->packet_type = BATADV_IV_OGM;
311 batadv_ogm_packet->header.version = BATADV_COMPAT_VERSION; 311 batadv_ogm_packet->version = BATADV_COMPAT_VERSION;
312 batadv_ogm_packet->header.ttl = 2; 312 batadv_ogm_packet->ttl = 2;
313 batadv_ogm_packet->flags = BATADV_NO_FLAGS; 313 batadv_ogm_packet->flags = BATADV_NO_FLAGS;
314 batadv_ogm_packet->reserved = 0; 314 batadv_ogm_packet->reserved = 0;
315 batadv_ogm_packet->tq = BATADV_TQ_MAX_VALUE; 315 batadv_ogm_packet->tq = BATADV_TQ_MAX_VALUE;
@@ -346,7 +346,7 @@ batadv_iv_ogm_primary_iface_set(struct batadv_hard_iface *hard_iface)
346 346
347 batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff; 347 batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff;
348 batadv_ogm_packet->flags = BATADV_PRIMARIES_FIRST_HOP; 348 batadv_ogm_packet->flags = BATADV_PRIMARIES_FIRST_HOP;
349 batadv_ogm_packet->header.ttl = BATADV_TTL; 349 batadv_ogm_packet->ttl = BATADV_TTL;
350} 350}
351 351
352/* when do we schedule our own ogm to be sent */ 352/* when do we schedule our own ogm to be sent */
@@ -435,7 +435,7 @@ static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet,
435 fwd_str, (packet_num > 0 ? "aggregated " : ""), 435 fwd_str, (packet_num > 0 ? "aggregated " : ""),
436 batadv_ogm_packet->orig, 436 batadv_ogm_packet->orig,
437 ntohl(batadv_ogm_packet->seqno), 437 ntohl(batadv_ogm_packet->seqno),
438 batadv_ogm_packet->tq, batadv_ogm_packet->header.ttl, 438 batadv_ogm_packet->tq, batadv_ogm_packet->ttl,
439 (batadv_ogm_packet->flags & BATADV_DIRECTLINK ? 439 (batadv_ogm_packet->flags & BATADV_DIRECTLINK ?
440 "on" : "off"), 440 "on" : "off"),
441 hard_iface->net_dev->name, 441 hard_iface->net_dev->name,
@@ -491,7 +491,7 @@ static void batadv_iv_ogm_emit(struct batadv_forw_packet *forw_packet)
491 /* multihomed peer assumed 491 /* multihomed peer assumed
492 * non-primary OGMs are only broadcasted on their interface 492 * non-primary OGMs are only broadcasted on their interface
493 */ 493 */
494 if ((directlink && (batadv_ogm_packet->header.ttl == 1)) || 494 if ((directlink && (batadv_ogm_packet->ttl == 1)) ||
495 (forw_packet->own && (forw_packet->if_incoming != primary_if))) { 495 (forw_packet->own && (forw_packet->if_incoming != primary_if))) {
496 /* FIXME: what about aggregated packets ? */ 496 /* FIXME: what about aggregated packets ? */
497 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 497 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
@@ -499,7 +499,7 @@ static void batadv_iv_ogm_emit(struct batadv_forw_packet *forw_packet)
499 (forw_packet->own ? "Sending own" : "Forwarding"), 499 (forw_packet->own ? "Sending own" : "Forwarding"),
500 batadv_ogm_packet->orig, 500 batadv_ogm_packet->orig,
501 ntohl(batadv_ogm_packet->seqno), 501 ntohl(batadv_ogm_packet->seqno),
502 batadv_ogm_packet->header.ttl, 502 batadv_ogm_packet->ttl,
503 forw_packet->if_incoming->net_dev->name, 503 forw_packet->if_incoming->net_dev->name,
504 forw_packet->if_incoming->net_dev->dev_addr); 504 forw_packet->if_incoming->net_dev->dev_addr);
505 505
@@ -572,7 +572,7 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet,
572 */ 572 */
573 if ((!directlink) && 573 if ((!directlink) &&
574 (!(batadv_ogm_packet->flags & BATADV_DIRECTLINK)) && 574 (!(batadv_ogm_packet->flags & BATADV_DIRECTLINK)) &&
575 (batadv_ogm_packet->header.ttl != 1) && 575 (batadv_ogm_packet->ttl != 1) &&
576 576
577 /* own packets originating non-primary 577 /* own packets originating non-primary
578 * interfaces leave only that interface 578 * interfaces leave only that interface
@@ -587,7 +587,7 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet,
587 * interface only - we still can aggregate 587 * interface only - we still can aggregate
588 */ 588 */
589 if ((directlink) && 589 if ((directlink) &&
590 (new_bat_ogm_packet->header.ttl == 1) && 590 (new_bat_ogm_packet->ttl == 1) &&
591 (forw_packet->if_incoming == if_incoming) && 591 (forw_packet->if_incoming == if_incoming) &&
592 592
593 /* packets from direct neighbors or 593 /* packets from direct neighbors or
@@ -778,7 +778,7 @@ static void batadv_iv_ogm_forward(struct batadv_orig_node *orig_node,
778 struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface); 778 struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
779 uint16_t tvlv_len; 779 uint16_t tvlv_len;
780 780
781 if (batadv_ogm_packet->header.ttl <= 1) { 781 if (batadv_ogm_packet->ttl <= 1) {
782 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "ttl exceeded\n"); 782 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "ttl exceeded\n");
783 return; 783 return;
784 } 784 }
@@ -798,7 +798,7 @@ static void batadv_iv_ogm_forward(struct batadv_orig_node *orig_node,
798 798
799 tvlv_len = ntohs(batadv_ogm_packet->tvlv_len); 799 tvlv_len = ntohs(batadv_ogm_packet->tvlv_len);
800 800
801 batadv_ogm_packet->header.ttl--; 801 batadv_ogm_packet->ttl--;
802 memcpy(batadv_ogm_packet->prev_sender, ethhdr->h_source, ETH_ALEN); 802 memcpy(batadv_ogm_packet->prev_sender, ethhdr->h_source, ETH_ALEN);
803 803
804 /* apply hop penalty */ 804 /* apply hop penalty */
@@ -807,7 +807,7 @@ static void batadv_iv_ogm_forward(struct batadv_orig_node *orig_node,
807 807
808 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 808 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
809 "Forwarding packet: tq: %i, ttl: %i\n", 809 "Forwarding packet: tq: %i, ttl: %i\n",
810 batadv_ogm_packet->tq, batadv_ogm_packet->header.ttl); 810 batadv_ogm_packet->tq, batadv_ogm_packet->ttl);
811 811
812 /* switch of primaries first hop flag when forwarding */ 812 /* switch of primaries first hop flag when forwarding */
813 batadv_ogm_packet->flags &= ~BATADV_PRIMARIES_FIRST_HOP; 813 batadv_ogm_packet->flags &= ~BATADV_PRIMARIES_FIRST_HOP;
@@ -972,8 +972,8 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
972 spin_unlock_bh(&neigh_node->bat_iv.lq_update_lock); 972 spin_unlock_bh(&neigh_node->bat_iv.lq_update_lock);
973 973
974 if (dup_status == BATADV_NO_DUP) { 974 if (dup_status == BATADV_NO_DUP) {
975 orig_node->last_ttl = batadv_ogm_packet->header.ttl; 975 orig_node->last_ttl = batadv_ogm_packet->ttl;
976 neigh_node->last_ttl = batadv_ogm_packet->header.ttl; 976 neigh_node->last_ttl = batadv_ogm_packet->ttl;
977 } 977 }
978 978
979 batadv_bonding_candidate_add(bat_priv, orig_node, neigh_node); 979 batadv_bonding_candidate_add(bat_priv, orig_node, neigh_node);
@@ -1247,7 +1247,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1247 * packet in an aggregation. Here we expect that the padding 1247 * packet in an aggregation. Here we expect that the padding
1248 * is always zero (or not 0x01) 1248 * is always zero (or not 0x01)
1249 */ 1249 */
1250 if (batadv_ogm_packet->header.packet_type != BATADV_IV_OGM) 1250 if (batadv_ogm_packet->packet_type != BATADV_IV_OGM)
1251 return; 1251 return;
1252 1252
1253 /* could be changed by schedule_own_packet() */ 1253 /* could be changed by schedule_own_packet() */
@@ -1267,8 +1267,8 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1267 if_incoming->net_dev->dev_addr, batadv_ogm_packet->orig, 1267 if_incoming->net_dev->dev_addr, batadv_ogm_packet->orig,
1268 batadv_ogm_packet->prev_sender, 1268 batadv_ogm_packet->prev_sender,
1269 ntohl(batadv_ogm_packet->seqno), batadv_ogm_packet->tq, 1269 ntohl(batadv_ogm_packet->seqno), batadv_ogm_packet->tq,
1270 batadv_ogm_packet->header.ttl, 1270 batadv_ogm_packet->ttl,
1271 batadv_ogm_packet->header.version, has_directlink_flag); 1271 batadv_ogm_packet->version, has_directlink_flag);
1272 1272
1273 rcu_read_lock(); 1273 rcu_read_lock();
1274 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { 1274 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
@@ -1433,7 +1433,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
1433 * seqno and similar ttl as the non-duplicate 1433 * seqno and similar ttl as the non-duplicate
1434 */ 1434 */
1435 sameseq = orig_node->last_real_seqno == ntohl(batadv_ogm_packet->seqno); 1435 sameseq = orig_node->last_real_seqno == ntohl(batadv_ogm_packet->seqno);
1436 similar_ttl = orig_node->last_ttl - 3 <= batadv_ogm_packet->header.ttl; 1436 similar_ttl = orig_node->last_ttl - 3 <= batadv_ogm_packet->ttl;
1437 if (is_bidirect && ((dup_status == BATADV_NO_DUP) || 1437 if (is_bidirect && ((dup_status == BATADV_NO_DUP) ||
1438 (sameseq && similar_ttl))) 1438 (sameseq && similar_ttl)))
1439 batadv_iv_ogm_orig_update(bat_priv, orig_node, ethhdr, 1439 batadv_iv_ogm_orig_update(bat_priv, orig_node, ethhdr,
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index 6c8c3934bd7b..b316a4cb6f14 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -349,7 +349,7 @@ static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb,
349 349
350 unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data; 350 unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data;
351 351
352 switch (unicast_4addr_packet->u.header.packet_type) { 352 switch (unicast_4addr_packet->u.packet_type) {
353 case BATADV_UNICAST: 353 case BATADV_UNICAST:
354 batadv_dbg(BATADV_DBG_DAT, bat_priv, 354 batadv_dbg(BATADV_DBG_DAT, bat_priv,
355 "* encapsulated within a UNICAST packet\n"); 355 "* encapsulated within a UNICAST packet\n");
@@ -374,7 +374,7 @@ static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb,
374 break; 374 break;
375 default: 375 default:
376 batadv_dbg(BATADV_DBG_DAT, bat_priv, "* type: Unknown (%u)!\n", 376 batadv_dbg(BATADV_DBG_DAT, bat_priv, "* type: Unknown (%u)!\n",
377 unicast_4addr_packet->u.header.packet_type); 377 unicast_4addr_packet->u.packet_type);
378 } 378 }
379 break; 379 break;
380 case BATADV_BCAST: 380 case BATADV_BCAST:
@@ -387,7 +387,7 @@ static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb,
387 default: 387 default:
388 batadv_dbg(BATADV_DBG_DAT, bat_priv, 388 batadv_dbg(BATADV_DBG_DAT, bat_priv,
389 "* encapsulated within an unknown packet type (0x%x)\n", 389 "* encapsulated within an unknown packet type (0x%x)\n",
390 unicast_4addr_packet->u.header.packet_type); 390 unicast_4addr_packet->u.packet_type);
391 } 391 }
392} 392}
393 393
diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
index 271d321b3a04..6ddb6145ffb5 100644
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -355,7 +355,7 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb,
355 batadv_add_counter(bat_priv, BATADV_CNT_FRAG_FWD_BYTES, 355 batadv_add_counter(bat_priv, BATADV_CNT_FRAG_FWD_BYTES,
356 skb->len + ETH_HLEN); 356 skb->len + ETH_HLEN);
357 357
358 packet->header.ttl--; 358 packet->ttl--;
359 batadv_send_skb_packet(skb, neigh_node->if_incoming, 359 batadv_send_skb_packet(skb, neigh_node->if_incoming,
360 neigh_node->addr); 360 neigh_node->addr);
361 ret = true; 361 ret = true;
@@ -444,9 +444,9 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
444 goto out_err; 444 goto out_err;
445 445
446 /* Create one header to be copied to all fragments */ 446 /* Create one header to be copied to all fragments */
447 frag_header.header.packet_type = BATADV_UNICAST_FRAG; 447 frag_header.packet_type = BATADV_UNICAST_FRAG;
448 frag_header.header.version = BATADV_COMPAT_VERSION; 448 frag_header.version = BATADV_COMPAT_VERSION;
449 frag_header.header.ttl = BATADV_TTL; 449 frag_header.ttl = BATADV_TTL;
450 frag_header.seqno = htons(atomic_inc_return(&bat_priv->frag_seqno)); 450 frag_header.seqno = htons(atomic_inc_return(&bat_priv->frag_seqno));
451 frag_header.reserved = 0; 451 frag_header.reserved = 0;
452 frag_header.no = 0; 452 frag_header.no = 0;
diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c
index 29ae4efe3543..130cc3217e2b 100644
--- a/net/batman-adv/icmp_socket.c
+++ b/net/batman-adv/icmp_socket.c
@@ -194,7 +194,7 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
194 goto free_skb; 194 goto free_skb;
195 } 195 }
196 196
197 if (icmp_header->header.packet_type != BATADV_ICMP) { 197 if (icmp_header->packet_type != BATADV_ICMP) {
198 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 198 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
199 "Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n"); 199 "Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n");
200 len = -EINVAL; 200 len = -EINVAL;
@@ -243,9 +243,9 @@ static ssize_t batadv_socket_write(struct file *file, const char __user *buff,
243 243
244 icmp_header->uid = socket_client->index; 244 icmp_header->uid = socket_client->index;
245 245
246 if (icmp_header->header.version != BATADV_COMPAT_VERSION) { 246 if (icmp_header->version != BATADV_COMPAT_VERSION) {
247 icmp_header->msg_type = BATADV_PARAMETER_PROBLEM; 247 icmp_header->msg_type = BATADV_PARAMETER_PROBLEM;
248 icmp_header->header.version = BATADV_COMPAT_VERSION; 248 icmp_header->version = BATADV_COMPAT_VERSION;
249 batadv_socket_add_packet(socket_client, icmp_header, 249 batadv_socket_add_packet(socket_client, icmp_header,
250 packet_len); 250 packet_len);
251 goto free_skb; 251 goto free_skb;
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index c51a5e568f0a..1511f64a6cea 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -383,17 +383,17 @@ int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
383 383
384 batadv_ogm_packet = (struct batadv_ogm_packet *)skb->data; 384 batadv_ogm_packet = (struct batadv_ogm_packet *)skb->data;
385 385
386 if (batadv_ogm_packet->header.version != BATADV_COMPAT_VERSION) { 386 if (batadv_ogm_packet->version != BATADV_COMPAT_VERSION) {
387 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 387 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
388 "Drop packet: incompatible batman version (%i)\n", 388 "Drop packet: incompatible batman version (%i)\n",
389 batadv_ogm_packet->header.version); 389 batadv_ogm_packet->version);
390 goto err_free; 390 goto err_free;
391 } 391 }
392 392
393 /* all receive handlers return whether they received or reused 393 /* all receive handlers return whether they received or reused
394 * the supplied skb. if not, we have to free the skb. 394 * the supplied skb. if not, we have to free the skb.
395 */ 395 */
396 idx = batadv_ogm_packet->header.packet_type; 396 idx = batadv_ogm_packet->packet_type;
397 ret = (*batadv_rx_handler[idx])(skb, hard_iface); 397 ret = (*batadv_rx_handler[idx])(skb, hard_iface);
398 398
399 if (ret == NET_RX_DROP) 399 if (ret == NET_RX_DROP)
@@ -426,8 +426,8 @@ static void batadv_recv_handler_init(void)
426 BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, dest) != 4); 426 BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, dest) != 4);
427 BUILD_BUG_ON(offsetof(struct batadv_unicast_tvlv_packet, dst) != 4); 427 BUILD_BUG_ON(offsetof(struct batadv_unicast_tvlv_packet, dst) != 4);
428 BUILD_BUG_ON(offsetof(struct batadv_frag_packet, dest) != 4); 428 BUILD_BUG_ON(offsetof(struct batadv_frag_packet, dest) != 4);
429 BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, icmph.dst) != 4); 429 BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, dst) != 4);
430 BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, icmph.dst) != 4); 430 BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, dst) != 4);
431 431
432 /* broadcast packet */ 432 /* broadcast packet */
433 batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet; 433 batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet;
@@ -1119,9 +1119,9 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, uint8_t *src,
1119 skb_reserve(skb, ETH_HLEN); 1119 skb_reserve(skb, ETH_HLEN);
1120 tvlv_buff = skb_put(skb, sizeof(*unicast_tvlv_packet) + tvlv_len); 1120 tvlv_buff = skb_put(skb, sizeof(*unicast_tvlv_packet) + tvlv_len);
1121 unicast_tvlv_packet = (struct batadv_unicast_tvlv_packet *)tvlv_buff; 1121 unicast_tvlv_packet = (struct batadv_unicast_tvlv_packet *)tvlv_buff;
1122 unicast_tvlv_packet->header.packet_type = BATADV_UNICAST_TVLV; 1122 unicast_tvlv_packet->packet_type = BATADV_UNICAST_TVLV;
1123 unicast_tvlv_packet->header.version = BATADV_COMPAT_VERSION; 1123 unicast_tvlv_packet->version = BATADV_COMPAT_VERSION;
1124 unicast_tvlv_packet->header.ttl = BATADV_TTL; 1124 unicast_tvlv_packet->ttl = BATADV_TTL;
1125 unicast_tvlv_packet->reserved = 0; 1125 unicast_tvlv_packet->reserved = 0;
1126 unicast_tvlv_packet->tvlv_len = htons(tvlv_len); 1126 unicast_tvlv_packet->tvlv_len = htons(tvlv_len);
1127 unicast_tvlv_packet->align = 0; 1127 unicast_tvlv_packet->align = 0;
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c
index 351e199bc0af..511d7e1eea38 100644
--- a/net/batman-adv/network-coding.c
+++ b/net/batman-adv/network-coding.c
@@ -722,7 +722,7 @@ static bool batadv_can_nc_with_orig(struct batadv_priv *bat_priv,
722{ 722{
723 if (orig_node->last_real_seqno != ntohl(ogm_packet->seqno)) 723 if (orig_node->last_real_seqno != ntohl(ogm_packet->seqno))
724 return false; 724 return false;
725 if (orig_node->last_ttl != ogm_packet->header.ttl + 1) 725 if (orig_node->last_ttl != ogm_packet->ttl + 1)
726 return false; 726 return false;
727 if (!batadv_compare_eth(ogm_packet->orig, ogm_packet->prev_sender)) 727 if (!batadv_compare_eth(ogm_packet->orig, ogm_packet->prev_sender))
728 return false; 728 return false;
@@ -1082,9 +1082,9 @@ static bool batadv_nc_code_packets(struct batadv_priv *bat_priv,
1082 coded_packet = (struct batadv_coded_packet *)skb_dest->data; 1082 coded_packet = (struct batadv_coded_packet *)skb_dest->data;
1083 skb_reset_mac_header(skb_dest); 1083 skb_reset_mac_header(skb_dest);
1084 1084
1085 coded_packet->header.packet_type = BATADV_CODED; 1085 coded_packet->packet_type = BATADV_CODED;
1086 coded_packet->header.version = BATADV_COMPAT_VERSION; 1086 coded_packet->version = BATADV_COMPAT_VERSION;
1087 coded_packet->header.ttl = packet1->header.ttl; 1087 coded_packet->ttl = packet1->ttl;
1088 1088
1089 /* Info about first unicast packet */ 1089 /* Info about first unicast packet */
1090 memcpy(coded_packet->first_source, first_source, ETH_ALEN); 1090 memcpy(coded_packet->first_source, first_source, ETH_ALEN);
@@ -1097,7 +1097,7 @@ static bool batadv_nc_code_packets(struct batadv_priv *bat_priv,
1097 memcpy(coded_packet->second_source, second_source, ETH_ALEN); 1097 memcpy(coded_packet->second_source, second_source, ETH_ALEN);
1098 memcpy(coded_packet->second_orig_dest, packet2->dest, ETH_ALEN); 1098 memcpy(coded_packet->second_orig_dest, packet2->dest, ETH_ALEN);
1099 coded_packet->second_crc = packet_id2; 1099 coded_packet->second_crc = packet_id2;
1100 coded_packet->second_ttl = packet2->header.ttl; 1100 coded_packet->second_ttl = packet2->ttl;
1101 coded_packet->second_ttvn = packet2->ttvn; 1101 coded_packet->second_ttvn = packet2->ttvn;
1102 coded_packet->coded_len = htons(coding_len); 1102 coded_packet->coded_len = htons(coding_len);
1103 1103
@@ -1452,7 +1452,7 @@ bool batadv_nc_skb_forward(struct sk_buff *skb,
1452 /* We only handle unicast packets */ 1452 /* We only handle unicast packets */
1453 payload = skb_network_header(skb); 1453 payload = skb_network_header(skb);
1454 packet = (struct batadv_unicast_packet *)payload; 1454 packet = (struct batadv_unicast_packet *)payload;
1455 if (packet->header.packet_type != BATADV_UNICAST) 1455 if (packet->packet_type != BATADV_UNICAST)
1456 goto out; 1456 goto out;
1457 1457
1458 /* Try to find a coding opportunity and send the skb if one is found */ 1458 /* Try to find a coding opportunity and send the skb if one is found */
@@ -1505,7 +1505,7 @@ void batadv_nc_skb_store_for_decoding(struct batadv_priv *bat_priv,
1505 /* Check for supported packet type */ 1505 /* Check for supported packet type */
1506 payload = skb_network_header(skb); 1506 payload = skb_network_header(skb);
1507 packet = (struct batadv_unicast_packet *)payload; 1507 packet = (struct batadv_unicast_packet *)payload;
1508 if (packet->header.packet_type != BATADV_UNICAST) 1508 if (packet->packet_type != BATADV_UNICAST)
1509 goto out; 1509 goto out;
1510 1510
1511 /* Find existing nc_path or create a new */ 1511 /* Find existing nc_path or create a new */
@@ -1623,7 +1623,7 @@ batadv_nc_skb_decode_packet(struct batadv_priv *bat_priv, struct sk_buff *skb,
1623 ttvn = coded_packet_tmp.second_ttvn; 1623 ttvn = coded_packet_tmp.second_ttvn;
1624 } else { 1624 } else {
1625 orig_dest = coded_packet_tmp.first_orig_dest; 1625 orig_dest = coded_packet_tmp.first_orig_dest;
1626 ttl = coded_packet_tmp.header.ttl; 1626 ttl = coded_packet_tmp.ttl;
1627 ttvn = coded_packet_tmp.first_ttvn; 1627 ttvn = coded_packet_tmp.first_ttvn;
1628 } 1628 }
1629 1629
@@ -1648,9 +1648,9 @@ batadv_nc_skb_decode_packet(struct batadv_priv *bat_priv, struct sk_buff *skb,
1648 1648
1649 /* Create decoded unicast packet */ 1649 /* Create decoded unicast packet */
1650 unicast_packet = (struct batadv_unicast_packet *)skb->data; 1650 unicast_packet = (struct batadv_unicast_packet *)skb->data;
1651 unicast_packet->header.packet_type = BATADV_UNICAST; 1651 unicast_packet->packet_type = BATADV_UNICAST;
1652 unicast_packet->header.version = BATADV_COMPAT_VERSION; 1652 unicast_packet->version = BATADV_COMPAT_VERSION;
1653 unicast_packet->header.ttl = ttl; 1653 unicast_packet->ttl = ttl;
1654 memcpy(unicast_packet->dest, orig_dest, ETH_ALEN); 1654 memcpy(unicast_packet->dest, orig_dest, ETH_ALEN);
1655 unicast_packet->ttvn = ttvn; 1655 unicast_packet->ttvn = ttvn;
1656 1656
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index 207459b62966..2dd8f2422550 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -155,6 +155,7 @@ enum batadv_tvlv_type {
155 BATADV_TVLV_ROAM = 0x05, 155 BATADV_TVLV_ROAM = 0x05,
156}; 156};
157 157
158#pragma pack(2)
158/* the destination hardware field in the ARP frame is used to 159/* the destination hardware field in the ARP frame is used to
159 * transport the claim type and the group id 160 * transport the claim type and the group id
160 */ 161 */
@@ -163,24 +164,20 @@ struct batadv_bla_claim_dst {
163 uint8_t type; /* bla_claimframe */ 164 uint8_t type; /* bla_claimframe */
164 __be16 group; /* group id */ 165 __be16 group; /* group id */
165}; 166};
166 167#pragma pack()
167struct batadv_header {
168 uint8_t packet_type;
169 uint8_t version; /* batman version field */
170 uint8_t ttl;
171 /* the parent struct has to add a byte after the header to make
172 * everything 4 bytes aligned again
173 */
174};
175 168
176/** 169/**
177 * struct batadv_ogm_packet - ogm (routing protocol) packet 170 * struct batadv_ogm_packet - ogm (routing protocol) packet
178 * @header: common batman packet header 171 * @packet_type: batman-adv packet type, part of the general header
172 * @version: batman-adv protocol version, part of the genereal header
173 * @ttl: time to live for this packet, part of the genereal header
179 * @flags: contains routing relevant flags - see enum batadv_iv_flags 174 * @flags: contains routing relevant flags - see enum batadv_iv_flags
180 * @tvlv_len: length of tvlv data following the ogm header 175 * @tvlv_len: length of tvlv data following the ogm header
181 */ 176 */
182struct batadv_ogm_packet { 177struct batadv_ogm_packet {
183 struct batadv_header header; 178 uint8_t packet_type;
179 uint8_t version;
180 uint8_t ttl;
184 uint8_t flags; 181 uint8_t flags;
185 __be32 seqno; 182 __be32 seqno;
186 uint8_t orig[ETH_ALEN]; 183 uint8_t orig[ETH_ALEN];
@@ -196,29 +193,51 @@ struct batadv_ogm_packet {
196#define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet) 193#define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet)
197 194
198/** 195/**
199 * batadv_icmp_header - common ICMP header 196 * batadv_icmp_header - common members among all the ICMP packets
200 * @header: common batman header 197 * @packet_type: batman-adv packet type, part of the general header
198 * @version: batman-adv protocol version, part of the genereal header
199 * @ttl: time to live for this packet, part of the genereal header
201 * @msg_type: ICMP packet type 200 * @msg_type: ICMP packet type
202 * @dst: address of the destination node 201 * @dst: address of the destination node
203 * @orig: address of the source node 202 * @orig: address of the source node
204 * @uid: local ICMP socket identifier 203 * @uid: local ICMP socket identifier
204 * @align: not used - useful for alignment purposes only
205 *
206 * This structure is used for ICMP packets parsing only and it is never sent
207 * over the wire. The alignment field at the end is there to ensure that
208 * members are padded the same way as they are in real packets.
205 */ 209 */
206struct batadv_icmp_header { 210struct batadv_icmp_header {
207 struct batadv_header header; 211 uint8_t packet_type;
212 uint8_t version;
213 uint8_t ttl;
208 uint8_t msg_type; /* see ICMP message types above */ 214 uint8_t msg_type; /* see ICMP message types above */
209 uint8_t dst[ETH_ALEN]; 215 uint8_t dst[ETH_ALEN];
210 uint8_t orig[ETH_ALEN]; 216 uint8_t orig[ETH_ALEN];
211 uint8_t uid; 217 uint8_t uid;
218 uint8_t align[3];
212}; 219};
213 220
214/** 221/**
215 * batadv_icmp_packet - ICMP packet 222 * batadv_icmp_packet - ICMP packet
216 * @icmph: common ICMP header 223 * @packet_type: batman-adv packet type, part of the general header
224 * @version: batman-adv protocol version, part of the genereal header
225 * @ttl: time to live for this packet, part of the genereal header
226 * @msg_type: ICMP packet type
227 * @dst: address of the destination node
228 * @orig: address of the source node
229 * @uid: local ICMP socket identifier
217 * @reserved: not used - useful for alignment 230 * @reserved: not used - useful for alignment
218 * @seqno: ICMP sequence number 231 * @seqno: ICMP sequence number
219 */ 232 */
220struct batadv_icmp_packet { 233struct batadv_icmp_packet {
221 struct batadv_icmp_header icmph; 234 uint8_t packet_type;
235 uint8_t version;
236 uint8_t ttl;
237 uint8_t msg_type; /* see ICMP message types above */
238 uint8_t dst[ETH_ALEN];
239 uint8_t orig[ETH_ALEN];
240 uint8_t uid;
222 uint8_t reserved; 241 uint8_t reserved;
223 __be16 seqno; 242 __be16 seqno;
224}; 243};
@@ -227,13 +246,25 @@ struct batadv_icmp_packet {
227 246
228/** 247/**
229 * batadv_icmp_packet_rr - ICMP RouteRecord packet 248 * batadv_icmp_packet_rr - ICMP RouteRecord packet
230 * @icmph: common ICMP header 249 * @packet_type: batman-adv packet type, part of the general header
250 * @version: batman-adv protocol version, part of the genereal header
251 * @ttl: time to live for this packet, part of the genereal header
252 * @msg_type: ICMP packet type
253 * @dst: address of the destination node
254 * @orig: address of the source node
255 * @uid: local ICMP socket identifier
231 * @rr_cur: number of entries the rr array 256 * @rr_cur: number of entries the rr array
232 * @seqno: ICMP sequence number 257 * @seqno: ICMP sequence number
233 * @rr: route record array 258 * @rr: route record array
234 */ 259 */
235struct batadv_icmp_packet_rr { 260struct batadv_icmp_packet_rr {
236 struct batadv_icmp_header icmph; 261 uint8_t packet_type;
262 uint8_t version;
263 uint8_t ttl;
264 uint8_t msg_type; /* see ICMP message types above */
265 uint8_t dst[ETH_ALEN];
266 uint8_t orig[ETH_ALEN];
267 uint8_t uid;
237 uint8_t rr_cur; 268 uint8_t rr_cur;
238 __be16 seqno; 269 __be16 seqno;
239 uint8_t rr[BATADV_RR_LEN][ETH_ALEN]; 270 uint8_t rr[BATADV_RR_LEN][ETH_ALEN];
@@ -253,8 +284,18 @@ struct batadv_icmp_packet_rr {
253 */ 284 */
254#pragma pack(2) 285#pragma pack(2)
255 286
287/**
288 * struct batadv_unicast_packet - unicast packet for network payload
289 * @packet_type: batman-adv packet type, part of the general header
290 * @version: batman-adv protocol version, part of the genereal header
291 * @ttl: time to live for this packet, part of the genereal header
292 * @ttvn: translation table version number
293 * @dest: originator destination of the unicast packet
294 */
256struct batadv_unicast_packet { 295struct batadv_unicast_packet {
257 struct batadv_header header; 296 uint8_t packet_type;
297 uint8_t version;
298 uint8_t ttl;
258 uint8_t ttvn; /* destination translation table version number */ 299 uint8_t ttvn; /* destination translation table version number */
259 uint8_t dest[ETH_ALEN]; 300 uint8_t dest[ETH_ALEN];
260 /* "4 bytes boundary + 2 bytes" long to make the payload after the 301 /* "4 bytes boundary + 2 bytes" long to make the payload after the
@@ -280,7 +321,9 @@ struct batadv_unicast_4addr_packet {
280 321
281/** 322/**
282 * struct batadv_frag_packet - fragmented packet 323 * struct batadv_frag_packet - fragmented packet
283 * @header: common batman packet header with type, compatversion, and ttl 324 * @packet_type: batman-adv packet type, part of the general header
325 * @version: batman-adv protocol version, part of the genereal header
326 * @ttl: time to live for this packet, part of the genereal header
284 * @dest: final destination used when routing fragments 327 * @dest: final destination used when routing fragments
285 * @orig: originator of the fragment used when merging the packet 328 * @orig: originator of the fragment used when merging the packet
286 * @no: fragment number within this sequence 329 * @no: fragment number within this sequence
@@ -289,7 +332,9 @@ struct batadv_unicast_4addr_packet {
289 * @total_size: size of the merged packet 332 * @total_size: size of the merged packet
290 */ 333 */
291struct batadv_frag_packet { 334struct batadv_frag_packet {
292 struct batadv_header header; 335 uint8_t packet_type;
336 uint8_t version; /* batman version field */
337 uint8_t ttl;
293#if defined(__BIG_ENDIAN_BITFIELD) 338#if defined(__BIG_ENDIAN_BITFIELD)
294 uint8_t no:4; 339 uint8_t no:4;
295 uint8_t reserved:4; 340 uint8_t reserved:4;
@@ -305,8 +350,19 @@ struct batadv_frag_packet {
305 __be16 total_size; 350 __be16 total_size;
306}; 351};
307 352
353/**
354 * struct batadv_bcast_packet - broadcast packet for network payload
355 * @packet_type: batman-adv packet type, part of the general header
356 * @version: batman-adv protocol version, part of the genereal header
357 * @ttl: time to live for this packet, part of the genereal header
358 * @reserved: reserved byte for alignment
359 * @seqno: sequence identification
360 * @orig: originator of the broadcast packet
361 */
308struct batadv_bcast_packet { 362struct batadv_bcast_packet {
309 struct batadv_header header; 363 uint8_t packet_type;
364 uint8_t version; /* batman version field */
365 uint8_t ttl;
310 uint8_t reserved; 366 uint8_t reserved;
311 __be32 seqno; 367 __be32 seqno;
312 uint8_t orig[ETH_ALEN]; 368 uint8_t orig[ETH_ALEN];
@@ -315,11 +371,11 @@ struct batadv_bcast_packet {
315 */ 371 */
316}; 372};
317 373
318#pragma pack()
319
320/** 374/**
321 * struct batadv_coded_packet - network coded packet 375 * struct batadv_coded_packet - network coded packet
322 * @header: common batman packet header and ttl of first included packet 376 * @packet_type: batman-adv packet type, part of the general header
377 * @version: batman-adv protocol version, part of the genereal header
378 * @ttl: time to live for this packet, part of the genereal header
323 * @reserved: Align following fields to 2-byte boundaries 379 * @reserved: Align following fields to 2-byte boundaries
324 * @first_source: original source of first included packet 380 * @first_source: original source of first included packet
325 * @first_orig_dest: original destinal of first included packet 381 * @first_orig_dest: original destinal of first included packet
@@ -334,7 +390,9 @@ struct batadv_bcast_packet {
334 * @coded_len: length of network coded part of the payload 390 * @coded_len: length of network coded part of the payload
335 */ 391 */
336struct batadv_coded_packet { 392struct batadv_coded_packet {
337 struct batadv_header header; 393 uint8_t packet_type;
394 uint8_t version; /* batman version field */
395 uint8_t ttl;
338 uint8_t first_ttvn; 396 uint8_t first_ttvn;
339 /* uint8_t first_dest[ETH_ALEN]; - saved in mac header destination */ 397 /* uint8_t first_dest[ETH_ALEN]; - saved in mac header destination */
340 uint8_t first_source[ETH_ALEN]; 398 uint8_t first_source[ETH_ALEN];
@@ -349,9 +407,13 @@ struct batadv_coded_packet {
349 __be16 coded_len; 407 __be16 coded_len;
350}; 408};
351 409
410#pragma pack()
411
352/** 412/**
353 * struct batadv_unicast_tvlv - generic unicast packet with tvlv payload 413 * struct batadv_unicast_tvlv - generic unicast packet with tvlv payload
354 * @header: common batman packet header 414 * @packet_type: batman-adv packet type, part of the general header
415 * @version: batman-adv protocol version, part of the genereal header
416 * @ttl: time to live for this packet, part of the genereal header
355 * @reserved: reserved field (for packet alignment) 417 * @reserved: reserved field (for packet alignment)
356 * @src: address of the source 418 * @src: address of the source
357 * @dst: address of the destination 419 * @dst: address of the destination
@@ -359,7 +421,9 @@ struct batadv_coded_packet {
359 * @align: 2 bytes to align the header to a 4 byte boundry 421 * @align: 2 bytes to align the header to a 4 byte boundry
360 */ 422 */
361struct batadv_unicast_tvlv_packet { 423struct batadv_unicast_tvlv_packet {
362 struct batadv_header header; 424 uint8_t packet_type;
425 uint8_t version; /* batman version field */
426 uint8_t ttl;
363 uint8_t reserved; 427 uint8_t reserved;
364 uint8_t dst[ETH_ALEN]; 428 uint8_t dst[ETH_ALEN];
365 uint8_t src[ETH_ALEN]; 429 uint8_t src[ETH_ALEN];
@@ -420,13 +484,13 @@ struct batadv_tvlv_tt_vlan_data {
420 * struct batadv_tvlv_tt_change - translation table diff data 484 * struct batadv_tvlv_tt_change - translation table diff data
421 * @flags: status indicators concerning the non-mesh client (see 485 * @flags: status indicators concerning the non-mesh client (see
422 * batadv_tt_client_flags) 486 * batadv_tt_client_flags)
423 * @reserved: reserved field 487 * @reserved: reserved field - useful for alignment purposes only
424 * @addr: mac address of non-mesh client that triggered this tt change 488 * @addr: mac address of non-mesh client that triggered this tt change
425 * @vid: VLAN identifier 489 * @vid: VLAN identifier
426 */ 490 */
427struct batadv_tvlv_tt_change { 491struct batadv_tvlv_tt_change {
428 uint8_t flags; 492 uint8_t flags;
429 uint8_t reserved; 493 uint8_t reserved[3];
430 uint8_t addr[ETH_ALEN]; 494 uint8_t addr[ETH_ALEN];
431 __be16 vid; 495 __be16 vid;
432}; 496};
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index d4114d775ad6..46278bfb8fdb 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -308,7 +308,7 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv,
308 memcpy(icmph->dst, icmph->orig, ETH_ALEN); 308 memcpy(icmph->dst, icmph->orig, ETH_ALEN);
309 memcpy(icmph->orig, primary_if->net_dev->dev_addr, ETH_ALEN); 309 memcpy(icmph->orig, primary_if->net_dev->dev_addr, ETH_ALEN);
310 icmph->msg_type = BATADV_ECHO_REPLY; 310 icmph->msg_type = BATADV_ECHO_REPLY;
311 icmph->header.ttl = BATADV_TTL; 311 icmph->ttl = BATADV_TTL;
312 312
313 res = batadv_send_skb_to_orig(skb, orig_node, NULL); 313 res = batadv_send_skb_to_orig(skb, orig_node, NULL);
314 if (res != NET_XMIT_DROP) 314 if (res != NET_XMIT_DROP)
@@ -338,9 +338,9 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
338 icmp_packet = (struct batadv_icmp_packet *)skb->data; 338 icmp_packet = (struct batadv_icmp_packet *)skb->data;
339 339
340 /* send TTL exceeded if packet is an echo request (traceroute) */ 340 /* send TTL exceeded if packet is an echo request (traceroute) */
341 if (icmp_packet->icmph.msg_type != BATADV_ECHO_REQUEST) { 341 if (icmp_packet->msg_type != BATADV_ECHO_REQUEST) {
342 pr_debug("Warning - can't forward icmp packet from %pM to %pM: ttl exceeded\n", 342 pr_debug("Warning - can't forward icmp packet from %pM to %pM: ttl exceeded\n",
343 icmp_packet->icmph.orig, icmp_packet->icmph.dst); 343 icmp_packet->orig, icmp_packet->dst);
344 goto out; 344 goto out;
345 } 345 }
346 346
@@ -349,7 +349,7 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
349 goto out; 349 goto out;
350 350
351 /* get routing information */ 351 /* get routing information */
352 orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->icmph.orig); 352 orig_node = batadv_orig_hash_find(bat_priv, icmp_packet->orig);
353 if (!orig_node) 353 if (!orig_node)
354 goto out; 354 goto out;
355 355
@@ -359,11 +359,11 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
359 359
360 icmp_packet = (struct batadv_icmp_packet *)skb->data; 360 icmp_packet = (struct batadv_icmp_packet *)skb->data;
361 361
362 memcpy(icmp_packet->icmph.dst, icmp_packet->icmph.orig, ETH_ALEN); 362 memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
363 memcpy(icmp_packet->icmph.orig, primary_if->net_dev->dev_addr, 363 memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr,
364 ETH_ALEN); 364 ETH_ALEN);
365 icmp_packet->icmph.msg_type = BATADV_TTL_EXCEEDED; 365 icmp_packet->msg_type = BATADV_TTL_EXCEEDED;
366 icmp_packet->icmph.header.ttl = BATADV_TTL; 366 icmp_packet->ttl = BATADV_TTL;
367 367
368 if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP) 368 if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP)
369 ret = NET_RX_SUCCESS; 369 ret = NET_RX_SUCCESS;
@@ -434,7 +434,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
434 return batadv_recv_my_icmp_packet(bat_priv, skb); 434 return batadv_recv_my_icmp_packet(bat_priv, skb);
435 435
436 /* TTL exceeded */ 436 /* TTL exceeded */
437 if (icmph->header.ttl < 2) 437 if (icmph->ttl < 2)
438 return batadv_recv_icmp_ttl_exceeded(bat_priv, skb); 438 return batadv_recv_icmp_ttl_exceeded(bat_priv, skb);
439 439
440 /* get routing information */ 440 /* get routing information */
@@ -449,7 +449,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
449 icmph = (struct batadv_icmp_header *)skb->data; 449 icmph = (struct batadv_icmp_header *)skb->data;
450 450
451 /* decrement ttl */ 451 /* decrement ttl */
452 icmph->header.ttl--; 452 icmph->ttl--;
453 453
454 /* route it */ 454 /* route it */
455 if (batadv_send_skb_to_orig(skb, orig_node, recv_if) != NET_XMIT_DROP) 455 if (batadv_send_skb_to_orig(skb, orig_node, recv_if) != NET_XMIT_DROP)
@@ -709,7 +709,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
709 unicast_packet = (struct batadv_unicast_packet *)skb->data; 709 unicast_packet = (struct batadv_unicast_packet *)skb->data;
710 710
711 /* TTL exceeded */ 711 /* TTL exceeded */
712 if (unicast_packet->header.ttl < 2) { 712 if (unicast_packet->ttl < 2) {
713 pr_debug("Warning - can't forward unicast packet from %pM to %pM: ttl exceeded\n", 713 pr_debug("Warning - can't forward unicast packet from %pM to %pM: ttl exceeded\n",
714 ethhdr->h_source, unicast_packet->dest); 714 ethhdr->h_source, unicast_packet->dest);
715 goto out; 715 goto out;
@@ -727,9 +727,9 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
727 727
728 /* decrement ttl */ 728 /* decrement ttl */
729 unicast_packet = (struct batadv_unicast_packet *)skb->data; 729 unicast_packet = (struct batadv_unicast_packet *)skb->data;
730 unicast_packet->header.ttl--; 730 unicast_packet->ttl--;
731 731
732 switch (unicast_packet->header.packet_type) { 732 switch (unicast_packet->packet_type) {
733 case BATADV_UNICAST_4ADDR: 733 case BATADV_UNICAST_4ADDR:
734 hdr_len = sizeof(struct batadv_unicast_4addr_packet); 734 hdr_len = sizeof(struct batadv_unicast_4addr_packet);
735 break; 735 break;
@@ -970,7 +970,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
970 unicast_packet = (struct batadv_unicast_packet *)skb->data; 970 unicast_packet = (struct batadv_unicast_packet *)skb->data;
971 unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data; 971 unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data;
972 972
973 is4addr = unicast_packet->header.packet_type == BATADV_UNICAST_4ADDR; 973 is4addr = unicast_packet->packet_type == BATADV_UNICAST_4ADDR;
974 /* the caller function should have already pulled 2 bytes */ 974 /* the caller function should have already pulled 2 bytes */
975 if (is4addr) 975 if (is4addr)
976 hdr_size = sizeof(*unicast_4addr_packet); 976 hdr_size = sizeof(*unicast_4addr_packet);
@@ -1160,7 +1160,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb,
1160 if (batadv_is_my_mac(bat_priv, bcast_packet->orig)) 1160 if (batadv_is_my_mac(bat_priv, bcast_packet->orig))
1161 goto out; 1161 goto out;
1162 1162
1163 if (bcast_packet->header.ttl < 2) 1163 if (bcast_packet->ttl < 2)
1164 goto out; 1164 goto out;
1165 1165
1166 orig_node = batadv_orig_hash_find(bat_priv, bcast_packet->orig); 1166 orig_node = batadv_orig_hash_find(bat_priv, bcast_packet->orig);
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index c83be5ebaa28..fba4dcfcfac2 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -161,11 +161,11 @@ batadv_send_skb_push_fill_unicast(struct sk_buff *skb, int hdr_size,
161 return false; 161 return false;
162 162
163 unicast_packet = (struct batadv_unicast_packet *)skb->data; 163 unicast_packet = (struct batadv_unicast_packet *)skb->data;
164 unicast_packet->header.version = BATADV_COMPAT_VERSION; 164 unicast_packet->version = BATADV_COMPAT_VERSION;
165 /* batman packet type: unicast */ 165 /* batman packet type: unicast */
166 unicast_packet->header.packet_type = BATADV_UNICAST; 166 unicast_packet->packet_type = BATADV_UNICAST;
167 /* set unicast ttl */ 167 /* set unicast ttl */
168 unicast_packet->header.ttl = BATADV_TTL; 168 unicast_packet->ttl = BATADV_TTL;
169 /* copy the destination for faster routing */ 169 /* copy the destination for faster routing */
170 memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN); 170 memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN);
171 /* set the destination tt version number */ 171 /* set the destination tt version number */
@@ -221,7 +221,7 @@ bool batadv_send_skb_prepare_unicast_4addr(struct batadv_priv *bat_priv,
221 goto out; 221 goto out;
222 222
223 uc_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data; 223 uc_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data;
224 uc_4addr_packet->u.header.packet_type = BATADV_UNICAST_4ADDR; 224 uc_4addr_packet->u.packet_type = BATADV_UNICAST_4ADDR;
225 memcpy(uc_4addr_packet->src, primary_if->net_dev->dev_addr, ETH_ALEN); 225 memcpy(uc_4addr_packet->src, primary_if->net_dev->dev_addr, ETH_ALEN);
226 uc_4addr_packet->subtype = packet_subtype; 226 uc_4addr_packet->subtype = packet_subtype;
227 uc_4addr_packet->reserved = 0; 227 uc_4addr_packet->reserved = 0;
@@ -436,7 +436,7 @@ int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
436 436
437 /* as we have a copy now, it is safe to decrease the TTL */ 437 /* as we have a copy now, it is safe to decrease the TTL */
438 bcast_packet = (struct batadv_bcast_packet *)newskb->data; 438 bcast_packet = (struct batadv_bcast_packet *)newskb->data;
439 bcast_packet->header.ttl--; 439 bcast_packet->ttl--;
440 440
441 skb_reset_mac_header(newskb); 441 skb_reset_mac_header(newskb);
442 442
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 36f050876f82..a8f99d1486c0 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -264,11 +264,11 @@ static int batadv_interface_tx(struct sk_buff *skb,
264 goto dropped; 264 goto dropped;
265 265
266 bcast_packet = (struct batadv_bcast_packet *)skb->data; 266 bcast_packet = (struct batadv_bcast_packet *)skb->data;
267 bcast_packet->header.version = BATADV_COMPAT_VERSION; 267 bcast_packet->version = BATADV_COMPAT_VERSION;
268 bcast_packet->header.ttl = BATADV_TTL; 268 bcast_packet->ttl = BATADV_TTL;
269 269
270 /* batman packet type: broadcast */ 270 /* batman packet type: broadcast */
271 bcast_packet->header.packet_type = BATADV_BCAST; 271 bcast_packet->packet_type = BATADV_BCAST;
272 bcast_packet->reserved = 0; 272 bcast_packet->reserved = 0;
273 273
274 /* hw address of first interface is the orig mac because only 274 /* hw address of first interface is the orig mac because only
@@ -328,7 +328,7 @@ void batadv_interface_rx(struct net_device *soft_iface,
328 struct sk_buff *skb, struct batadv_hard_iface *recv_if, 328 struct sk_buff *skb, struct batadv_hard_iface *recv_if,
329 int hdr_size, struct batadv_orig_node *orig_node) 329 int hdr_size, struct batadv_orig_node *orig_node)
330{ 330{
331 struct batadv_header *batadv_header = (struct batadv_header *)skb->data; 331 struct batadv_bcast_packet *batadv_bcast_packet;
332 struct batadv_priv *bat_priv = netdev_priv(soft_iface); 332 struct batadv_priv *bat_priv = netdev_priv(soft_iface);
333 __be16 ethertype = htons(ETH_P_BATMAN); 333 __be16 ethertype = htons(ETH_P_BATMAN);
334 struct vlan_ethhdr *vhdr; 334 struct vlan_ethhdr *vhdr;
@@ -336,7 +336,8 @@ void batadv_interface_rx(struct net_device *soft_iface,
336 unsigned short vid; 336 unsigned short vid;
337 bool is_bcast; 337 bool is_bcast;
338 338
339 is_bcast = (batadv_header->packet_type == BATADV_BCAST); 339 batadv_bcast_packet = (struct batadv_bcast_packet *)skb->data;
340 is_bcast = (batadv_bcast_packet->packet_type == BATADV_BCAST);
340 341
341 /* check if enough space is available for pulling, and pull */ 342 /* check if enough space is available for pulling, and pull */
342 if (!pskb_may_pull(skb, hdr_size)) 343 if (!pskb_may_pull(skb, hdr_size))
@@ -345,7 +346,12 @@ void batadv_interface_rx(struct net_device *soft_iface,
345 skb_pull_rcsum(skb, hdr_size); 346 skb_pull_rcsum(skb, hdr_size);
346 skb_reset_mac_header(skb); 347 skb_reset_mac_header(skb);
347 348
348 vid = batadv_get_vid(skb, hdr_size); 349 /* clean the netfilter state now that the batman-adv header has been
350 * removed
351 */
352 nf_reset(skb);
353
354 vid = batadv_get_vid(skb, 0);
349 ethhdr = eth_hdr(skb); 355 ethhdr = eth_hdr(skb);
350 356
351 switch (ntohs(ethhdr->h_proto)) { 357 switch (ntohs(ethhdr->h_proto)) {
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 4add57d4857f..ff625fedbc5e 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -333,7 +333,8 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv,
333 return; 333 return;
334 334
335 tt_change_node->change.flags = flags; 335 tt_change_node->change.flags = flags;
336 tt_change_node->change.reserved = 0; 336 memset(tt_change_node->change.reserved, 0,
337 sizeof(tt_change_node->change.reserved));
337 memcpy(tt_change_node->change.addr, common->addr, ETH_ALEN); 338 memcpy(tt_change_node->change.addr, common->addr, ETH_ALEN);
338 tt_change_node->change.vid = htons(common->vid); 339 tt_change_node->change.vid = htons(common->vid);
339 340
@@ -2221,7 +2222,8 @@ static void batadv_tt_tvlv_generate(struct batadv_priv *bat_priv,
2221 ETH_ALEN); 2222 ETH_ALEN);
2222 tt_change->flags = tt_common_entry->flags; 2223 tt_change->flags = tt_common_entry->flags;
2223 tt_change->vid = htons(tt_common_entry->vid); 2224 tt_change->vid = htons(tt_common_entry->vid);
2224 tt_change->reserved = 0; 2225 memset(tt_change->reserved, 0,
2226 sizeof(tt_change->reserved));
2225 2227
2226 tt_num_entries++; 2228 tt_num_entries++;
2227 tt_change++; 2229 tt_change++;