aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2011-11-20 09:47:38 -0500
committerMarek Lindner <lindner_marek@yahoo.de>2012-02-16 13:50:19 -0500
commit76543d14aec6ce5cb3fc7be9b39c50fcebd2043b (patch)
tree4f739cfadaee8ec9a06d7855956f3accc1dcc2be /net/batman-adv
parent17071578888c7c18709e48e74fae228c04581b9a (diff)
batman-adv: Explicitly mark the common header structure
All batman-adv packets have a common 3 byte header. It can be used to share some code between different code paths, but it was never explicit stated that this header has to be always the same for all packets. Therefore, new code changes always have the problem that they may accidently introduce regressions by moving some elements around. A new structure is introduced that contains the common header and makes it easier visible that these 3 bytes have to be the same for all on-wire packets. Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/bat_iv_ogm.c47
-rw-r--r--net/batman-adv/hard-interface.c6
-rw-r--r--net/batman-adv/icmp_socket.c6
-rw-r--r--net/batman-adv/packet.h38
-rw-r--r--net/batman-adv/routing.c18
-rw-r--r--net/batman-adv/send.c2
-rw-r--r--net/batman-adv/soft-interface.c14
-rw-r--r--net/batman-adv/translation-table.c24
-rw-r--r--net/batman-adv/unicast.c16
-rw-r--r--net/batman-adv/vis.c14
10 files changed, 87 insertions, 98 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 3512e251545b..d60e1ba0bc15 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -38,10 +38,10 @@ void bat_ogm_init(struct hard_iface *hard_iface)
38 hard_iface->packet_buff = kmalloc(hard_iface->packet_len, GFP_ATOMIC); 38 hard_iface->packet_buff = kmalloc(hard_iface->packet_len, GFP_ATOMIC);
39 39
40 batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; 40 batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff;
41 batman_ogm_packet->packet_type = BAT_OGM; 41 batman_ogm_packet->header.packet_type = BAT_OGM;
42 batman_ogm_packet->version = COMPAT_VERSION; 42 batman_ogm_packet->header.version = COMPAT_VERSION;
43 batman_ogm_packet->header.ttl = 2;
43 batman_ogm_packet->flags = NO_FLAGS; 44 batman_ogm_packet->flags = NO_FLAGS;
44 batman_ogm_packet->ttl = 2;
45 batman_ogm_packet->tq = TQ_MAX_VALUE; 45 batman_ogm_packet->tq = TQ_MAX_VALUE;
46 batman_ogm_packet->tt_num_changes = 0; 46 batman_ogm_packet->tt_num_changes = 0;
47 batman_ogm_packet->ttvn = 0; 47 batman_ogm_packet->ttvn = 0;
@@ -53,7 +53,7 @@ void bat_ogm_init_primary(struct hard_iface *hard_iface)
53 53
54 batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff; 54 batman_ogm_packet = (struct batman_ogm_packet *)hard_iface->packet_buff;
55 batman_ogm_packet->flags = PRIMARIES_FIRST_HOP; 55 batman_ogm_packet->flags = PRIMARIES_FIRST_HOP;
56 batman_ogm_packet->ttl = TTL; 56 batman_ogm_packet->header.ttl = TTL;
57} 57}
58 58
59void bat_ogm_update_mac(struct hard_iface *hard_iface) 59void bat_ogm_update_mac(struct hard_iface *hard_iface)
@@ -137,7 +137,7 @@ static void bat_ogm_send_to_if(struct forw_packet *forw_packet,
137 fwd_str, (packet_num > 0 ? "aggregated " : ""), 137 fwd_str, (packet_num > 0 ? "aggregated " : ""),
138 batman_ogm_packet->orig, 138 batman_ogm_packet->orig,
139 ntohl(batman_ogm_packet->seqno), 139 ntohl(batman_ogm_packet->seqno),
140 batman_ogm_packet->tq, batman_ogm_packet->ttl, 140 batman_ogm_packet->tq, batman_ogm_packet->header.ttl,
141 (batman_ogm_packet->flags & DIRECTLINK ? 141 (batman_ogm_packet->flags & DIRECTLINK ?
142 "on" : "off"), 142 "on" : "off"),
143 batman_ogm_packet->ttvn, hard_iface->net_dev->name, 143 batman_ogm_packet->ttvn, hard_iface->net_dev->name,
@@ -188,7 +188,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet)
188 188
189 /* multihomed peer assumed */ 189 /* multihomed peer assumed */
190 /* non-primary OGMs are only broadcasted on their interface */ 190 /* non-primary OGMs are only broadcasted on their interface */
191 if ((directlink && (batman_ogm_packet->ttl == 1)) || 191 if ((directlink && (batman_ogm_packet->header.ttl == 1)) ||
192 (forw_packet->own && (forw_packet->if_incoming != primary_if))) { 192 (forw_packet->own && (forw_packet->if_incoming != primary_if))) {
193 193
194 /* FIXME: what about aggregated packets ? */ 194 /* FIXME: what about aggregated packets ? */
@@ -198,7 +198,7 @@ void bat_ogm_emit(struct forw_packet *forw_packet)
198 (forw_packet->own ? "Sending own" : "Forwarding"), 198 (forw_packet->own ? "Sending own" : "Forwarding"),
199 batman_ogm_packet->orig, 199 batman_ogm_packet->orig,
200 ntohl(batman_ogm_packet->seqno), 200 ntohl(batman_ogm_packet->seqno),
201 batman_ogm_packet->ttl, 201 batman_ogm_packet->header.ttl,
202 forw_packet->if_incoming->net_dev->name, 202 forw_packet->if_incoming->net_dev->name,
203 forw_packet->if_incoming->net_dev->dev_addr); 203 forw_packet->if_incoming->net_dev->dev_addr);
204 204
@@ -272,7 +272,7 @@ static bool bat_ogm_can_aggregate(const struct batman_ogm_packet
272 * are flooded through the net */ 272 * are flooded through the net */
273 if ((!directlink) && 273 if ((!directlink) &&
274 (!(batman_ogm_packet->flags & DIRECTLINK)) && 274 (!(batman_ogm_packet->flags & DIRECTLINK)) &&
275 (batman_ogm_packet->ttl != 1) && 275 (batman_ogm_packet->header.ttl != 1) &&
276 276
277 /* own packets originating non-primary 277 /* own packets originating non-primary
278 * interfaces leave only that interface */ 278 * interfaces leave only that interface */
@@ -285,7 +285,7 @@ static bool bat_ogm_can_aggregate(const struct batman_ogm_packet
285 /* if the incoming packet is sent via this one 285 /* if the incoming packet is sent via this one
286 * interface only - we still can aggregate */ 286 * interface only - we still can aggregate */
287 if ((directlink) && 287 if ((directlink) &&
288 (new_batman_ogm_packet->ttl == 1) && 288 (new_batman_ogm_packet->header.ttl == 1) &&
289 (forw_packet->if_incoming == if_incoming) && 289 (forw_packet->if_incoming == if_incoming) &&
290 290
291 /* packets from direct neighbors or 291 /* packets from direct neighbors or
@@ -471,7 +471,7 @@ static void bat_ogm_forward(struct orig_node *orig_node,
471 uint8_t in_tq, in_ttl, tq_avg = 0; 471 uint8_t in_tq, in_ttl, tq_avg = 0;
472 uint8_t tt_num_changes; 472 uint8_t tt_num_changes;
473 473
474 if (batman_ogm_packet->ttl <= 1) { 474 if (batman_ogm_packet->header.ttl <= 1) {
475 bat_dbg(DBG_BATMAN, bat_priv, "ttl exceeded\n"); 475 bat_dbg(DBG_BATMAN, bat_priv, "ttl exceeded\n");
476 return; 476 return;
477 } 477 }
@@ -479,10 +479,10 @@ static void bat_ogm_forward(struct orig_node *orig_node,
479 router = orig_node_get_router(orig_node); 479 router = orig_node_get_router(orig_node);
480 480
481 in_tq = batman_ogm_packet->tq; 481 in_tq = batman_ogm_packet->tq;
482 in_ttl = batman_ogm_packet->ttl; 482 in_ttl = batman_ogm_packet->header.ttl;
483 tt_num_changes = batman_ogm_packet->tt_num_changes; 483 tt_num_changes = batman_ogm_packet->tt_num_changes;
484 484
485 batman_ogm_packet->ttl--; 485 batman_ogm_packet->header.ttl--;
486 memcpy(batman_ogm_packet->prev_sender, ethhdr->h_source, ETH_ALEN); 486 memcpy(batman_ogm_packet->prev_sender, ethhdr->h_source, ETH_ALEN);
487 487
488 /* rebroadcast tq of our best ranking neighbor to ensure the rebroadcast 488 /* rebroadcast tq of our best ranking neighbor to ensure the rebroadcast
@@ -494,7 +494,8 @@ static void bat_ogm_forward(struct orig_node *orig_node,
494 batman_ogm_packet->tq = router->tq_avg; 494 batman_ogm_packet->tq = router->tq_avg;
495 495
496 if (router->last_ttl) 496 if (router->last_ttl)
497 batman_ogm_packet->ttl = router->last_ttl - 1; 497 batman_ogm_packet->header.ttl =
498 router->last_ttl - 1;
498 } 499 }
499 500
500 tq_avg = router->tq_avg; 501 tq_avg = router->tq_avg;
@@ -510,7 +511,7 @@ static void bat_ogm_forward(struct orig_node *orig_node,
510 "Forwarding packet: tq_orig: %i, tq_avg: %i, " 511 "Forwarding packet: tq_orig: %i, tq_avg: %i, "
511 "tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n", 512 "tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n",
512 in_tq, tq_avg, batman_ogm_packet->tq, in_ttl - 1, 513 in_tq, tq_avg, batman_ogm_packet->tq, in_ttl - 1,
513 batman_ogm_packet->ttl); 514 batman_ogm_packet->header.ttl);
514 515
515 batman_ogm_packet->seqno = htonl(batman_ogm_packet->seqno); 516 batman_ogm_packet->seqno = htonl(batman_ogm_packet->seqno);
516 batman_ogm_packet->tt_crc = htons(batman_ogm_packet->tt_crc); 517 batman_ogm_packet->tt_crc = htons(batman_ogm_packet->tt_crc);
@@ -642,8 +643,8 @@ static void bat_ogm_orig_update(struct bat_priv *bat_priv,
642 spin_unlock_bh(&neigh_node->tq_lock); 643 spin_unlock_bh(&neigh_node->tq_lock);
643 644
644 if (!is_duplicate) { 645 if (!is_duplicate) {
645 orig_node->last_ttl = batman_ogm_packet->ttl; 646 orig_node->last_ttl = batman_ogm_packet->header.ttl;
646 neigh_node->last_ttl = batman_ogm_packet->ttl; 647 neigh_node->last_ttl = batman_ogm_packet->header.ttl;
647 } 648 }
648 649
649 bonding_candidate_add(orig_node, neigh_node); 650 bonding_candidate_add(orig_node, neigh_node);
@@ -683,7 +684,7 @@ update_tt:
683 /* I have to check for transtable changes only if the OGM has been 684 /* I have to check for transtable changes only if the OGM has been
684 * sent through a primary interface */ 685 * sent through a primary interface */
685 if (((batman_ogm_packet->orig != ethhdr->h_source) && 686 if (((batman_ogm_packet->orig != ethhdr->h_source) &&
686 (batman_ogm_packet->ttl > 2)) || 687 (batman_ogm_packet->header.ttl > 2)) ||
687 (batman_ogm_packet->flags & PRIMARIES_FIRST_HOP)) 688 (batman_ogm_packet->flags & PRIMARIES_FIRST_HOP))
688 tt_update_orig(bat_priv, orig_node, tt_buff, 689 tt_update_orig(bat_priv, orig_node, tt_buff,
689 batman_ogm_packet->tt_num_changes, 690 batman_ogm_packet->tt_num_changes,
@@ -918,7 +919,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
918 * packet in an aggregation. Here we expect that the padding 919 * packet in an aggregation. Here we expect that the padding
919 * is always zero (or not 0x01) 920 * is always zero (or not 0x01)
920 */ 921 */
921 if (batman_ogm_packet->packet_type != BAT_OGM) 922 if (batman_ogm_packet->header.packet_type != BAT_OGM)
922 return; 923 return;
923 924
924 /* could be changed by schedule_own_packet() */ 925 /* could be changed by schedule_own_packet() */
@@ -938,8 +939,8 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
938 batman_ogm_packet->prev_sender, batman_ogm_packet->seqno, 939 batman_ogm_packet->prev_sender, batman_ogm_packet->seqno,
939 batman_ogm_packet->ttvn, batman_ogm_packet->tt_crc, 940 batman_ogm_packet->ttvn, batman_ogm_packet->tt_crc,
940 batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq, 941 batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq,
941 batman_ogm_packet->ttl, batman_ogm_packet->version, 942 batman_ogm_packet->header.ttl,
942 has_directlink_flag); 943 batman_ogm_packet->header.version, has_directlink_flag);
943 944
944 rcu_read_lock(); 945 rcu_read_lock();
945 list_for_each_entry_rcu(hard_iface, &hardif_list, list) { 946 list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
@@ -966,10 +967,10 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
966 } 967 }
967 rcu_read_unlock(); 968 rcu_read_unlock();
968 969
969 if (batman_ogm_packet->version != COMPAT_VERSION) { 970 if (batman_ogm_packet->header.version != COMPAT_VERSION) {
970 bat_dbg(DBG_BATMAN, bat_priv, 971 bat_dbg(DBG_BATMAN, bat_priv,
971 "Drop packet: incompatible batman version (%i)\n", 972 "Drop packet: incompatible batman version (%i)\n",
972 batman_ogm_packet->version); 973 batman_ogm_packet->header.version);
973 return; 974 return;
974 } 975 }
975 976
@@ -1091,7 +1092,7 @@ static void bat_ogm_process(const struct ethhdr *ethhdr,
1091 if (is_bidirectional && 1092 if (is_bidirectional &&
1092 (!is_duplicate || 1093 (!is_duplicate ||
1093 ((orig_node->last_real_seqno == batman_ogm_packet->seqno) && 1094 ((orig_node->last_real_seqno == batman_ogm_packet->seqno) &&
1094 (orig_node->last_ttl - 3 <= batman_ogm_packet->ttl)))) 1095 (orig_node->last_ttl - 3 <= batman_ogm_packet->header.ttl))))
1095 bat_ogm_orig_update(bat_priv, orig_node, ethhdr, 1096 bat_ogm_orig_update(bat_priv, orig_node, ethhdr,
1096 batman_ogm_packet, if_incoming, 1097 batman_ogm_packet, if_incoming,
1097 tt_buff, is_duplicate); 1098 tt_buff, is_duplicate);
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 7704df468e0b..d3e0e32e51c6 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -590,17 +590,17 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
590 590
591 batman_ogm_packet = (struct batman_ogm_packet *)skb->data; 591 batman_ogm_packet = (struct batman_ogm_packet *)skb->data;
592 592
593 if (batman_ogm_packet->version != COMPAT_VERSION) { 593 if (batman_ogm_packet->header.version != COMPAT_VERSION) {
594 bat_dbg(DBG_BATMAN, bat_priv, 594 bat_dbg(DBG_BATMAN, bat_priv,
595 "Drop packet: incompatible batman version (%i)\n", 595 "Drop packet: incompatible batman version (%i)\n",
596 batman_ogm_packet->version); 596 batman_ogm_packet->header.version);
597 goto err_free; 597 goto err_free;
598 } 598 }
599 599
600 /* all receive handlers return whether they received or reused 600 /* all receive handlers return whether they received or reused
601 * the supplied skb. if not, we have to free the skb. */ 601 * the supplied skb. if not, we have to free the skb. */
602 602
603 switch (batman_ogm_packet->packet_type) { 603 switch (batman_ogm_packet->header.packet_type) {
604 /* batman originator packet */ 604 /* batman originator packet */
605 case BAT_OGM: 605 case BAT_OGM:
606 ret = recv_bat_ogm_packet(skb, hard_iface); 606 ret = recv_bat_ogm_packet(skb, hard_iface);
diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c
index d9c1e7bb7fbf..5d69e103faa1 100644
--- a/net/batman-adv/icmp_socket.c
+++ b/net/batman-adv/icmp_socket.c
@@ -191,7 +191,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
191 goto free_skb; 191 goto free_skb;
192 } 192 }
193 193
194 if (icmp_packet->packet_type != BAT_ICMP) { 194 if (icmp_packet->header.packet_type != BAT_ICMP) {
195 bat_dbg(DBG_BATMAN, bat_priv, 195 bat_dbg(DBG_BATMAN, bat_priv,
196 "Error - can't send packet from char device: " 196 "Error - can't send packet from char device: "
197 "got bogus packet type (expected: BAT_ICMP)\n"); 197 "got bogus packet type (expected: BAT_ICMP)\n");
@@ -209,9 +209,9 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
209 209
210 icmp_packet->uid = socket_client->index; 210 icmp_packet->uid = socket_client->index;
211 211
212 if (icmp_packet->version != COMPAT_VERSION) { 212 if (icmp_packet->header.version != COMPAT_VERSION) {
213 icmp_packet->msg_type = PARAMETER_PROBLEM; 213 icmp_packet->msg_type = PARAMETER_PROBLEM;
214 icmp_packet->version = COMPAT_VERSION; 214 icmp_packet->header.version = COMPAT_VERSION;
215 bat_socket_add_packet(socket_client, icmp_packet, packet_len); 215 bat_socket_add_packet(socket_client, icmp_packet, packet_len);
216 goto free_skb; 216 goto free_skb;
217 } 217 }
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index 4d9e54c57a36..88c717b9344d 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -90,10 +90,14 @@ enum tt_client_flags {
90 TT_CLIENT_PENDING = 1 << 10 90 TT_CLIENT_PENDING = 1 << 10
91}; 91};
92 92
93struct batman_ogm_packet { 93struct batman_header {
94 uint8_t packet_type; 94 uint8_t packet_type;
95 uint8_t version; /* batman version field */ 95 uint8_t version; /* batman version field */
96 uint8_t ttl; 96 uint8_t ttl;
97} __packed;
98
99struct batman_ogm_packet {
100 struct batman_header header;
97 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */ 101 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
98 uint32_t seqno; 102 uint32_t seqno;
99 uint8_t orig[6]; 103 uint8_t orig[6];
@@ -108,9 +112,7 @@ struct batman_ogm_packet {
108#define BATMAN_OGM_LEN sizeof(struct batman_ogm_packet) 112#define BATMAN_OGM_LEN sizeof(struct batman_ogm_packet)
109 113
110struct icmp_packet { 114struct icmp_packet {
111 uint8_t packet_type; 115 struct batman_header header;
112 uint8_t version; /* batman version field */
113 uint8_t ttl;
114 uint8_t msg_type; /* see ICMP message types above */ 116 uint8_t msg_type; /* see ICMP message types above */
115 uint8_t dst[6]; 117 uint8_t dst[6];
116 uint8_t orig[6]; 118 uint8_t orig[6];
@@ -124,9 +126,7 @@ struct icmp_packet {
124/* icmp_packet_rr must start with all fields from imcp_packet 126/* icmp_packet_rr must start with all fields from imcp_packet
125 * as this is assumed by code that handles ICMP packets */ 127 * as this is assumed by code that handles ICMP packets */
126struct icmp_packet_rr { 128struct icmp_packet_rr {
127 uint8_t packet_type; 129 struct batman_header header;
128 uint8_t version; /* batman version field */
129 uint8_t ttl;
130 uint8_t msg_type; /* see ICMP message types above */ 130 uint8_t msg_type; /* see ICMP message types above */
131 uint8_t dst[6]; 131 uint8_t dst[6];
132 uint8_t orig[6]; 132 uint8_t orig[6];
@@ -137,17 +137,13 @@ struct icmp_packet_rr {
137} __packed; 137} __packed;
138 138
139struct unicast_packet { 139struct unicast_packet {
140 uint8_t packet_type; 140 struct batman_header header;
141 uint8_t version; /* batman version field */
142 uint8_t ttl;
143 uint8_t ttvn; /* destination translation table version number */ 141 uint8_t ttvn; /* destination translation table version number */
144 uint8_t dest[6]; 142 uint8_t dest[6];
145} __packed; 143} __packed;
146 144
147struct unicast_frag_packet { 145struct unicast_frag_packet {
148 uint8_t packet_type; 146 struct batman_header header;
149 uint8_t version; /* batman version field */
150 uint8_t ttl;
151 uint8_t ttvn; /* destination translation table version number */ 147 uint8_t ttvn; /* destination translation table version number */
152 uint8_t dest[6]; 148 uint8_t dest[6];
153 uint8_t flags; 149 uint8_t flags;
@@ -157,18 +153,14 @@ struct unicast_frag_packet {
157} __packed; 153} __packed;
158 154
159struct bcast_packet { 155struct bcast_packet {
160 uint8_t packet_type; 156 struct batman_header header;
161 uint8_t version; /* batman version field */
162 uint8_t ttl;
163 uint8_t reserved; 157 uint8_t reserved;
164 uint32_t seqno; 158 uint32_t seqno;
165 uint8_t orig[6]; 159 uint8_t orig[6];
166} __packed; 160} __packed;
167 161
168struct vis_packet { 162struct vis_packet {
169 uint8_t packet_type; 163 struct batman_header header;
170 uint8_t version; /* batman version field */
171 uint8_t ttl; /* TTL */
172 uint8_t vis_type; /* which type of vis-participant sent this? */ 164 uint8_t vis_type; /* which type of vis-participant sent this? */
173 uint32_t seqno; /* sequence number */ 165 uint32_t seqno; /* sequence number */
174 uint8_t entries; /* number of entries behind this struct */ 166 uint8_t entries; /* number of entries behind this struct */
@@ -179,9 +171,7 @@ struct vis_packet {
179} __packed; 171} __packed;
180 172
181struct tt_query_packet { 173struct tt_query_packet {
182 uint8_t packet_type; 174 struct batman_header header;
183 uint8_t version; /* batman version field */
184 uint8_t ttl;
185 /* the flag field is a combination of: 175 /* the flag field is a combination of:
186 * - TT_REQUEST or TT_RESPONSE 176 * - TT_REQUEST or TT_RESPONSE
187 * - TT_FULL_TABLE */ 177 * - TT_FULL_TABLE */
@@ -202,9 +192,7 @@ struct tt_query_packet {
202} __packed; 192} __packed;
203 193
204struct roam_adv_packet { 194struct roam_adv_packet {
205 uint8_t packet_type; 195 struct batman_header header;
206 uint8_t version;
207 uint8_t ttl;
208 uint8_t reserved; 196 uint8_t reserved;
209 uint8_t dst[ETH_ALEN]; 197 uint8_t dst[ETH_ALEN];
210 uint8_t src[ETH_ALEN]; 198 uint8_t src[ETH_ALEN];
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 773e606f9702..4363d197aebc 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -320,7 +320,7 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
320 memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); 320 memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
321 memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); 321 memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN);
322 icmp_packet->msg_type = ECHO_REPLY; 322 icmp_packet->msg_type = ECHO_REPLY;
323 icmp_packet->ttl = TTL; 323 icmp_packet->header.ttl = TTL;
324 324
325 send_skb_packet(skb, router->if_incoming, router->addr); 325 send_skb_packet(skb, router->if_incoming, router->addr);
326 ret = NET_RX_SUCCESS; 326 ret = NET_RX_SUCCESS;
@@ -376,7 +376,7 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
376 memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); 376 memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN);
377 memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); 377 memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN);
378 icmp_packet->msg_type = TTL_EXCEEDED; 378 icmp_packet->msg_type = TTL_EXCEEDED;
379 icmp_packet->ttl = TTL; 379 icmp_packet->header.ttl = TTL;
380 380
381 send_skb_packet(skb, router->if_incoming, router->addr); 381 send_skb_packet(skb, router->if_incoming, router->addr);
382 ret = NET_RX_SUCCESS; 382 ret = NET_RX_SUCCESS;
@@ -441,7 +441,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
441 return recv_my_icmp_packet(bat_priv, skb, hdr_size); 441 return recv_my_icmp_packet(bat_priv, skb, hdr_size);
442 442
443 /* TTL exceeded */ 443 /* TTL exceeded */
444 if (icmp_packet->ttl < 2) 444 if (icmp_packet->header.ttl < 2)
445 return recv_icmp_ttl_exceeded(bat_priv, skb); 445 return recv_icmp_ttl_exceeded(bat_priv, skb);
446 446
447 /* get routing information */ 447 /* get routing information */
@@ -460,7 +460,7 @@ int recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if)
460 icmp_packet = (struct icmp_packet_rr *)skb->data; 460 icmp_packet = (struct icmp_packet_rr *)skb->data;
461 461
462 /* decrement ttl */ 462 /* decrement ttl */
463 icmp_packet->ttl--; 463 icmp_packet->header.ttl--;
464 464
465 /* route it */ 465 /* route it */
466 send_skb_packet(skb, router->if_incoming, router->addr); 466 send_skb_packet(skb, router->if_incoming, router->addr);
@@ -815,7 +815,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
815 unicast_packet = (struct unicast_packet *)skb->data; 815 unicast_packet = (struct unicast_packet *)skb->data;
816 816
817 /* TTL exceeded */ 817 /* TTL exceeded */
818 if (unicast_packet->ttl < 2) { 818 if (unicast_packet->header.ttl < 2) {
819 pr_debug("Warning - can't forward unicast packet from %pM to " 819 pr_debug("Warning - can't forward unicast packet from %pM to "
820 "%pM: ttl exceeded\n", ethhdr->h_source, 820 "%pM: ttl exceeded\n", ethhdr->h_source,
821 unicast_packet->dest); 821 unicast_packet->dest);
@@ -840,7 +840,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
840 840
841 unicast_packet = (struct unicast_packet *)skb->data; 841 unicast_packet = (struct unicast_packet *)skb->data;
842 842
843 if (unicast_packet->packet_type == BAT_UNICAST && 843 if (unicast_packet->header.packet_type == BAT_UNICAST &&
844 atomic_read(&bat_priv->fragmentation) && 844 atomic_read(&bat_priv->fragmentation) &&
845 skb->len > neigh_node->if_incoming->net_dev->mtu) { 845 skb->len > neigh_node->if_incoming->net_dev->mtu) {
846 ret = frag_send_skb(skb, bat_priv, 846 ret = frag_send_skb(skb, bat_priv,
@@ -848,7 +848,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
848 goto out; 848 goto out;
849 } 849 }
850 850
851 if (unicast_packet->packet_type == BAT_UNICAST_FRAG && 851 if (unicast_packet->header.packet_type == BAT_UNICAST_FRAG &&
852 frag_can_reassemble(skb, neigh_node->if_incoming->net_dev->mtu)) { 852 frag_can_reassemble(skb, neigh_node->if_incoming->net_dev->mtu)) {
853 853
854 ret = frag_reassemble_skb(skb, bat_priv, &new_skb); 854 ret = frag_reassemble_skb(skb, bat_priv, &new_skb);
@@ -867,7 +867,7 @@ int route_unicast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
867 } 867 }
868 868
869 /* decrement ttl */ 869 /* decrement ttl */
870 unicast_packet->ttl--; 870 unicast_packet->header.ttl--;
871 871
872 /* route it */ 872 /* route it */
873 send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); 873 send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
@@ -1041,7 +1041,7 @@ int recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if)
1041 if (is_my_mac(bcast_packet->orig)) 1041 if (is_my_mac(bcast_packet->orig))
1042 goto out; 1042 goto out;
1043 1043
1044 if (bcast_packet->ttl < 2) 1044 if (bcast_packet->header.ttl < 2)
1045 goto out; 1045 goto out;
1046 1046
1047 orig_node = orig_hash_find(bat_priv, bcast_packet->orig); 1047 orig_node = orig_hash_find(bat_priv, bcast_packet->orig);
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index 8a684eb738ad..b00a0f537b4e 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -234,7 +234,7 @@ int add_bcast_packet_to_list(struct bat_priv *bat_priv,
234 234
235 /* as we have a copy now, it is safe to decrease the TTL */ 235 /* as we have a copy now, it is safe to decrease the TTL */
236 bcast_packet = (struct bcast_packet *)newskb->data; 236 bcast_packet = (struct bcast_packet *)newskb->data;
237 bcast_packet->ttl--; 237 bcast_packet->header.ttl--;
238 238
239 skb_reset_mac_header(newskb); 239 skb_reset_mac_header(newskb);
240 240
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 987c75a775f9..bd8c7cfaeacf 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -457,10 +457,10 @@ static void softif_batman_recv(struct sk_buff *skb, struct net_device *dev,
457 batman_ogm_packet = (struct batman_ogm_packet *) 457 batman_ogm_packet = (struct batman_ogm_packet *)
458 (skb->data + ETH_HLEN); 458 (skb->data + ETH_HLEN);
459 459
460 if (batman_ogm_packet->version != COMPAT_VERSION) 460 if (batman_ogm_packet->header.version != COMPAT_VERSION)
461 goto out; 461 goto out;
462 462
463 if (batman_ogm_packet->packet_type != BAT_OGM) 463 if (batman_ogm_packet->header.packet_type != BAT_OGM)
464 goto out; 464 goto out;
465 465
466 if (!(batman_ogm_packet->flags & PRIMARIES_FIRST_HOP)) 466 if (!(batman_ogm_packet->flags & PRIMARIES_FIRST_HOP))
@@ -632,11 +632,11 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface)
632 goto dropped; 632 goto dropped;
633 633
634 bcast_packet = (struct bcast_packet *)skb->data; 634 bcast_packet = (struct bcast_packet *)skb->data;
635 bcast_packet->version = COMPAT_VERSION; 635 bcast_packet->header.version = COMPAT_VERSION;
636 bcast_packet->ttl = TTL; 636 bcast_packet->header.ttl = TTL;
637 637
638 /* batman packet type: broadcast */ 638 /* batman packet type: broadcast */
639 bcast_packet->packet_type = BAT_BCAST; 639 bcast_packet->header.packet_type = BAT_BCAST;
640 640
641 /* hw address of first interface is the orig mac because only 641 /* hw address of first interface is the orig mac because only
642 * this mac is known throughout the mesh */ 642 * this mac is known throughout the mesh */
@@ -725,8 +725,8 @@ void interface_rx(struct net_device *soft_iface,
725 skb_push(skb, hdr_size); 725 skb_push(skb, hdr_size);
726 unicast_packet = (struct unicast_packet *)skb->data; 726 unicast_packet = (struct unicast_packet *)skb->data;
727 727
728 if ((unicast_packet->packet_type != BAT_UNICAST) && 728 if ((unicast_packet->header.packet_type != BAT_UNICAST) &&
729 (unicast_packet->packet_type != BAT_UNICAST_FRAG)) 729 (unicast_packet->header.packet_type != BAT_UNICAST_FRAG))
730 goto dropped; 730 goto dropped;
731 731
732 skb_reset_mac_header(skb); 732 skb_reset_mac_header(skb);
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index c632475df375..bc518fca0b69 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1135,11 +1135,11 @@ static int send_tt_request(struct bat_priv *bat_priv,
1135 tt_request = (struct tt_query_packet *)skb_put(skb, 1135 tt_request = (struct tt_query_packet *)skb_put(skb,
1136 sizeof(struct tt_query_packet)); 1136 sizeof(struct tt_query_packet));
1137 1137
1138 tt_request->packet_type = BAT_TT_QUERY; 1138 tt_request->header.packet_type = BAT_TT_QUERY;
1139 tt_request->version = COMPAT_VERSION; 1139 tt_request->header.version = COMPAT_VERSION;
1140 memcpy(tt_request->src, primary_if->net_dev->dev_addr, ETH_ALEN); 1140 memcpy(tt_request->src, primary_if->net_dev->dev_addr, ETH_ALEN);
1141 memcpy(tt_request->dst, dst_orig_node->orig, ETH_ALEN); 1141 memcpy(tt_request->dst, dst_orig_node->orig, ETH_ALEN);
1142 tt_request->ttl = TTL; 1142 tt_request->header.ttl = TTL;
1143 tt_request->ttvn = ttvn; 1143 tt_request->ttvn = ttvn;
1144 tt_request->tt_data = tt_crc; 1144 tt_request->tt_data = tt_crc;
1145 tt_request->flags = TT_REQUEST; 1145 tt_request->flags = TT_REQUEST;
@@ -1265,9 +1265,9 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
1265 tt_response = (struct tt_query_packet *)skb->data; 1265 tt_response = (struct tt_query_packet *)skb->data;
1266 } 1266 }
1267 1267
1268 tt_response->packet_type = BAT_TT_QUERY; 1268 tt_response->header.packet_type = BAT_TT_QUERY;
1269 tt_response->version = COMPAT_VERSION; 1269 tt_response->header.version = COMPAT_VERSION;
1270 tt_response->ttl = TTL; 1270 tt_response->header.ttl = TTL;
1271 memcpy(tt_response->src, req_dst_orig_node->orig, ETH_ALEN); 1271 memcpy(tt_response->src, req_dst_orig_node->orig, ETH_ALEN);
1272 memcpy(tt_response->dst, tt_request->src, ETH_ALEN); 1272 memcpy(tt_response->dst, tt_request->src, ETH_ALEN);
1273 tt_response->flags = TT_RESPONSE; 1273 tt_response->flags = TT_RESPONSE;
@@ -1382,9 +1382,9 @@ static bool send_my_tt_response(struct bat_priv *bat_priv,
1382 tt_response = (struct tt_query_packet *)skb->data; 1382 tt_response = (struct tt_query_packet *)skb->data;
1383 } 1383 }
1384 1384
1385 tt_response->packet_type = BAT_TT_QUERY; 1385 tt_response->header.packet_type = BAT_TT_QUERY;
1386 tt_response->version = COMPAT_VERSION; 1386 tt_response->header.version = COMPAT_VERSION;
1387 tt_response->ttl = TTL; 1387 tt_response->header.ttl = TTL;
1388 memcpy(tt_response->src, primary_if->net_dev->dev_addr, ETH_ALEN); 1388 memcpy(tt_response->src, primary_if->net_dev->dev_addr, ETH_ALEN);
1389 memcpy(tt_response->dst, tt_request->src, ETH_ALEN); 1389 memcpy(tt_response->dst, tt_request->src, ETH_ALEN);
1390 tt_response->flags = TT_RESPONSE; 1390 tt_response->flags = TT_RESPONSE;
@@ -1671,9 +1671,9 @@ void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client,
1671 roam_adv_packet = (struct roam_adv_packet *)skb_put(skb, 1671 roam_adv_packet = (struct roam_adv_packet *)skb_put(skb,
1672 sizeof(struct roam_adv_packet)); 1672 sizeof(struct roam_adv_packet));
1673 1673
1674 roam_adv_packet->packet_type = BAT_ROAM_ADV; 1674 roam_adv_packet->header.packet_type = BAT_ROAM_ADV;
1675 roam_adv_packet->version = COMPAT_VERSION; 1675 roam_adv_packet->header.version = COMPAT_VERSION;
1676 roam_adv_packet->ttl = TTL; 1676 roam_adv_packet->header.ttl = TTL;
1677 primary_if = primary_if_get_selected(bat_priv); 1677 primary_if = primary_if_get_selected(bat_priv);
1678 if (!primary_if) 1678 if (!primary_if)
1679 goto out; 1679 goto out;
diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
index 07d1c1da89dd..6f3c65952f53 100644
--- a/net/batman-adv/unicast.c
+++ b/net/batman-adv/unicast.c
@@ -67,7 +67,7 @@ static struct sk_buff *frag_merge_packet(struct list_head *head,
67 67
68 memmove(skb->data + uni_diff, skb->data, hdr_len); 68 memmove(skb->data + uni_diff, skb->data, hdr_len);
69 unicast_packet = (struct unicast_packet *) skb_pull(skb, uni_diff); 69 unicast_packet = (struct unicast_packet *) skb_pull(skb, uni_diff);
70 unicast_packet->packet_type = BAT_UNICAST; 70 unicast_packet->header.packet_type = BAT_UNICAST;
71 71
72 return skb; 72 return skb;
73 73
@@ -251,9 +251,9 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv,
251 251
252 memcpy(frag1, &tmp_uc, sizeof(tmp_uc)); 252 memcpy(frag1, &tmp_uc, sizeof(tmp_uc));
253 253
254 frag1->ttl--; 254 frag1->header.ttl--;
255 frag1->version = COMPAT_VERSION; 255 frag1->header.version = COMPAT_VERSION;
256 frag1->packet_type = BAT_UNICAST_FRAG; 256 frag1->header.packet_type = BAT_UNICAST_FRAG;
257 257
258 memcpy(frag1->orig, primary_if->net_dev->dev_addr, ETH_ALEN); 258 memcpy(frag1->orig, primary_if->net_dev->dev_addr, ETH_ALEN);
259 memcpy(frag2, frag1, sizeof(*frag2)); 259 memcpy(frag2, frag1, sizeof(*frag2));
@@ -320,11 +320,11 @@ find_router:
320 320
321 unicast_packet = (struct unicast_packet *)skb->data; 321 unicast_packet = (struct unicast_packet *)skb->data;
322 322
323 unicast_packet->version = COMPAT_VERSION; 323 unicast_packet->header.version = COMPAT_VERSION;
324 /* batman packet type: unicast */ 324 /* batman packet type: unicast */
325 unicast_packet->packet_type = BAT_UNICAST; 325 unicast_packet->header.packet_type = BAT_UNICAST;
326 /* set unicast ttl */ 326 /* set unicast ttl */
327 unicast_packet->ttl = TTL; 327 unicast_packet->header.ttl = TTL;
328 /* copy the destination for faster routing */ 328 /* copy the destination for faster routing */
329 memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN); 329 memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN);
330 /* set the destination tt version number */ 330 /* set the destination tt version number */
@@ -335,7 +335,7 @@ find_router:
335 data_len + sizeof(*unicast_packet) > 335 data_len + sizeof(*unicast_packet) >
336 neigh_node->if_incoming->net_dev->mtu) { 336 neigh_node->if_incoming->net_dev->mtu) {
337 /* send frag skb decreases ttl */ 337 /* send frag skb decreases ttl */
338 unicast_packet->ttl++; 338 unicast_packet->header.ttl++;
339 ret = frag_send_skb(skb, bat_priv, 339 ret = frag_send_skb(skb, bat_priv,
340 neigh_node->if_incoming, neigh_node->addr); 340 neigh_node->if_incoming, neigh_node->addr);
341 goto out; 341 goto out;
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c
index cc3b9f2f3b5d..ac7e66100590 100644
--- a/net/batman-adv/vis.c
+++ b/net/batman-adv/vis.c
@@ -617,7 +617,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
617 packet->vis_type = atomic_read(&bat_priv->vis_mode); 617 packet->vis_type = atomic_read(&bat_priv->vis_mode);
618 618
619 memcpy(packet->target_orig, broadcast_addr, ETH_ALEN); 619 memcpy(packet->target_orig, broadcast_addr, ETH_ALEN);
620 packet->ttl = TTL; 620 packet->header.ttl = TTL;
621 packet->seqno = htonl(ntohl(packet->seqno) + 1); 621 packet->seqno = htonl(ntohl(packet->seqno) + 1);
622 packet->entries = 0; 622 packet->entries = 0;
623 skb_trim(info->skb_packet, sizeof(*packet)); 623 skb_trim(info->skb_packet, sizeof(*packet));
@@ -818,19 +818,19 @@ static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info)
818 goto out; 818 goto out;
819 819
820 packet = (struct vis_packet *)info->skb_packet->data; 820 packet = (struct vis_packet *)info->skb_packet->data;
821 if (packet->ttl < 2) { 821 if (packet->header.ttl < 2) {
822 pr_debug("Error - can't send vis packet: ttl exceeded\n"); 822 pr_debug("Error - can't send vis packet: ttl exceeded\n");
823 goto out; 823 goto out;
824 } 824 }
825 825
826 memcpy(packet->sender_orig, primary_if->net_dev->dev_addr, ETH_ALEN); 826 memcpy(packet->sender_orig, primary_if->net_dev->dev_addr, ETH_ALEN);
827 packet->ttl--; 827 packet->header.ttl--;
828 828
829 if (is_broadcast_ether_addr(packet->target_orig)) 829 if (is_broadcast_ether_addr(packet->target_orig))
830 broadcast_vis_packet(bat_priv, info); 830 broadcast_vis_packet(bat_priv, info);
831 else 831 else
832 unicast_vis_packet(bat_priv, info); 832 unicast_vis_packet(bat_priv, info);
833 packet->ttl++; /* restore TTL */ 833 packet->header.ttl++; /* restore TTL */
834 834
835out: 835out:
836 if (primary_if) 836 if (primary_if)
@@ -910,9 +910,9 @@ int vis_init(struct bat_priv *bat_priv)
910 INIT_LIST_HEAD(&bat_priv->my_vis_info->send_list); 910 INIT_LIST_HEAD(&bat_priv->my_vis_info->send_list);
911 kref_init(&bat_priv->my_vis_info->refcount); 911 kref_init(&bat_priv->my_vis_info->refcount);
912 bat_priv->my_vis_info->bat_priv = bat_priv; 912 bat_priv->my_vis_info->bat_priv = bat_priv;
913 packet->version = COMPAT_VERSION; 913 packet->header.version = COMPAT_VERSION;
914 packet->packet_type = BAT_VIS; 914 packet->header.packet_type = BAT_VIS;
915 packet->ttl = TTL; 915 packet->header.ttl = TTL;
916 packet->seqno = 0; 916 packet->seqno = 0;
917 packet->entries = 0; 917 packet->entries = 0;
918 918