diff options
Diffstat (limited to 'net/batman-adv/unicast.c')
-rw-r--r-- | net/batman-adv/unicast.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c index 19c3daf34ac..32b125fb3d3 100644 --- a/net/batman-adv/unicast.c +++ b/net/batman-adv/unicast.c | |||
@@ -39,8 +39,8 @@ static struct sk_buff *frag_merge_packet(struct list_head *head, | |||
39 | (struct unicast_frag_packet *)skb->data; | 39 | (struct unicast_frag_packet *)skb->data; |
40 | struct sk_buff *tmp_skb; | 40 | struct sk_buff *tmp_skb; |
41 | struct unicast_packet *unicast_packet; | 41 | struct unicast_packet *unicast_packet; |
42 | int hdr_len = sizeof(struct unicast_packet); | 42 | int hdr_len = sizeof(*unicast_packet); |
43 | int uni_diff = sizeof(struct unicast_frag_packet) - hdr_len; | 43 | int uni_diff = sizeof(*up) - hdr_len; |
44 | 44 | ||
45 | /* set skb to the first part and tmp_skb to the second part */ | 45 | /* set skb to the first part and tmp_skb to the second part */ |
46 | if (up->flags & UNI_FRAG_HEAD) { | 46 | if (up->flags & UNI_FRAG_HEAD) { |
@@ -53,7 +53,7 @@ static struct sk_buff *frag_merge_packet(struct list_head *head, | |||
53 | if (skb_linearize(skb) < 0 || skb_linearize(tmp_skb) < 0) | 53 | if (skb_linearize(skb) < 0 || skb_linearize(tmp_skb) < 0) |
54 | goto err; | 54 | goto err; |
55 | 55 | ||
56 | skb_pull(tmp_skb, sizeof(struct unicast_frag_packet)); | 56 | skb_pull(tmp_skb, sizeof(*up)); |
57 | if (pskb_expand_head(skb, 0, tmp_skb->len, GFP_ATOMIC) < 0) | 57 | if (pskb_expand_head(skb, 0, tmp_skb->len, GFP_ATOMIC) < 0) |
58 | goto err; | 58 | goto err; |
59 | 59 | ||
@@ -99,8 +99,7 @@ static int frag_create_buffer(struct list_head *head) | |||
99 | struct frag_packet_list_entry *tfp; | 99 | struct frag_packet_list_entry *tfp; |
100 | 100 | ||
101 | for (i = 0; i < FRAG_BUFFER_SIZE; i++) { | 101 | for (i = 0; i < FRAG_BUFFER_SIZE; i++) { |
102 | tfp = kmalloc(sizeof(struct frag_packet_list_entry), | 102 | tfp = kmalloc(sizeof(*tfp), GFP_ATOMIC); |
103 | GFP_ATOMIC); | ||
104 | if (!tfp) { | 103 | if (!tfp) { |
105 | frag_list_free(head); | 104 | frag_list_free(head); |
106 | return -ENOMEM; | 105 | return -ENOMEM; |
@@ -115,7 +114,7 @@ static int frag_create_buffer(struct list_head *head) | |||
115 | } | 114 | } |
116 | 115 | ||
117 | static struct frag_packet_list_entry *frag_search_packet(struct list_head *head, | 116 | static struct frag_packet_list_entry *frag_search_packet(struct list_head *head, |
118 | struct unicast_frag_packet *up) | 117 | const struct unicast_frag_packet *up) |
119 | { | 118 | { |
120 | struct frag_packet_list_entry *tfp; | 119 | struct frag_packet_list_entry *tfp; |
121 | struct unicast_frag_packet *tmp_up = NULL; | 120 | struct unicast_frag_packet *tmp_up = NULL; |
@@ -218,14 +217,14 @@ out: | |||
218 | } | 217 | } |
219 | 218 | ||
220 | int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, | 219 | int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, |
221 | struct hard_iface *hard_iface, uint8_t dstaddr[]) | 220 | struct hard_iface *hard_iface, const uint8_t dstaddr[]) |
222 | { | 221 | { |
223 | struct unicast_packet tmp_uc, *unicast_packet; | 222 | struct unicast_packet tmp_uc, *unicast_packet; |
224 | struct hard_iface *primary_if; | 223 | struct hard_iface *primary_if; |
225 | struct sk_buff *frag_skb; | 224 | struct sk_buff *frag_skb; |
226 | struct unicast_frag_packet *frag1, *frag2; | 225 | struct unicast_frag_packet *frag1, *frag2; |
227 | int uc_hdr_len = sizeof(struct unicast_packet); | 226 | int uc_hdr_len = sizeof(*unicast_packet); |
228 | int ucf_hdr_len = sizeof(struct unicast_frag_packet); | 227 | int ucf_hdr_len = sizeof(*frag1); |
229 | int data_len = skb->len - uc_hdr_len; | 228 | int data_len = skb->len - uc_hdr_len; |
230 | int large_tail = 0, ret = NET_RX_DROP; | 229 | int large_tail = 0, ret = NET_RX_DROP; |
231 | uint16_t seqno; | 230 | uint16_t seqno; |
@@ -250,14 +249,14 @@ int frag_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv, | |||
250 | frag1 = (struct unicast_frag_packet *)skb->data; | 249 | frag1 = (struct unicast_frag_packet *)skb->data; |
251 | frag2 = (struct unicast_frag_packet *)frag_skb->data; | 250 | frag2 = (struct unicast_frag_packet *)frag_skb->data; |
252 | 251 | ||
253 | memcpy(frag1, &tmp_uc, sizeof(struct unicast_packet)); | 252 | memcpy(frag1, &tmp_uc, sizeof(tmp_uc)); |
254 | 253 | ||
255 | frag1->ttl--; | 254 | frag1->ttl--; |
256 | frag1->version = COMPAT_VERSION; | 255 | frag1->version = COMPAT_VERSION; |
257 | frag1->packet_type = BAT_UNICAST_FRAG; | 256 | frag1->packet_type = BAT_UNICAST_FRAG; |
258 | 257 | ||
259 | memcpy(frag1->orig, primary_if->net_dev->dev_addr, ETH_ALEN); | 258 | memcpy(frag1->orig, primary_if->net_dev->dev_addr, ETH_ALEN); |
260 | memcpy(frag2, frag1, sizeof(struct unicast_frag_packet)); | 259 | memcpy(frag2, frag1, sizeof(*frag2)); |
261 | 260 | ||
262 | if (data_len & 1) | 261 | if (data_len & 1) |
263 | large_tail = UNI_FRAG_LARGETAIL; | 262 | large_tail = UNI_FRAG_LARGETAIL; |
@@ -295,7 +294,7 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv) | |||
295 | 294 | ||
296 | /* get routing information */ | 295 | /* get routing information */ |
297 | if (is_multicast_ether_addr(ethhdr->h_dest)) { | 296 | if (is_multicast_ether_addr(ethhdr->h_dest)) { |
298 | orig_node = (struct orig_node *)gw_get_selected_orig(bat_priv); | 297 | orig_node = gw_get_selected_orig(bat_priv); |
299 | if (orig_node) | 298 | if (orig_node) |
300 | goto find_router; | 299 | goto find_router; |
301 | } | 300 | } |
@@ -314,10 +313,7 @@ find_router: | |||
314 | if (!neigh_node) | 313 | if (!neigh_node) |
315 | goto out; | 314 | goto out; |
316 | 315 | ||
317 | if (neigh_node->if_incoming->if_status != IF_ACTIVE) | 316 | if (my_skb_head_push(skb, sizeof(*unicast_packet)) < 0) |
318 | goto out; | ||
319 | |||
320 | if (my_skb_head_push(skb, sizeof(struct unicast_packet)) < 0) | ||
321 | goto out; | 317 | goto out; |
322 | 318 | ||
323 | unicast_packet = (struct unicast_packet *)skb->data; | 319 | unicast_packet = (struct unicast_packet *)skb->data; |
@@ -329,9 +325,12 @@ find_router: | |||
329 | unicast_packet->ttl = TTL; | 325 | unicast_packet->ttl = TTL; |
330 | /* copy the destination for faster routing */ | 326 | /* copy the destination for faster routing */ |
331 | memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN); | 327 | memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN); |
328 | /* set the destination tt version number */ | ||
329 | unicast_packet->ttvn = | ||
330 | (uint8_t)atomic_read(&orig_node->last_ttvn); | ||
332 | 331 | ||
333 | if (atomic_read(&bat_priv->fragmentation) && | 332 | if (atomic_read(&bat_priv->fragmentation) && |
334 | data_len + sizeof(struct unicast_packet) > | 333 | data_len + sizeof(*unicast_packet) > |
335 | neigh_node->if_incoming->net_dev->mtu) { | 334 | neigh_node->if_incoming->net_dev->mtu) { |
336 | /* send frag skb decreases ttl */ | 335 | /* send frag skb decreases ttl */ |
337 | unicast_packet->ttl++; | 336 | unicast_packet->ttl++; |