aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/routing.c
diff options
context:
space:
mode:
authorSimon Wunderlich <sw@simonwunderlich.de>2013-12-02 14:38:31 -0500
committerAntonio Quartulli <antonio@meshcoding.com>2013-12-28 06:51:16 -0500
commita40d9b075c21f06872de3f05cc2eb3d06665e2ff (patch)
tree85aefae654246aa4f89e046bb0bca6b5b85b76f6 /net/batman-adv/routing.c
parent46b76e0b8b5e21fa5a2387d6f72b193514e7f722 (diff)
batman-adv: fix header alignment by unrolling batadv_header
The size of the batadv_header of 3 is problematic on some architectures which automatically pad all structures to a 32 bit boundary. To not lose performance by packing this struct, better embed it into the various host structures. Reported-by: Russell King <linux@arm.linux.org.uk> Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de> Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch> Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Diffstat (limited to 'net/batman-adv/routing.c')
-rw-r--r--net/batman-adv/routing.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index d4114d775ad6..5b52d718a6eb 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)
@@ -363,7 +363,7 @@ static int batadv_recv_icmp_ttl_exceeded(struct batadv_priv *bat_priv,
363 memcpy(icmp_packet->icmph.orig, primary_if->net_dev->dev_addr, 363 memcpy(icmp_packet->icmph.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->icmph.msg_type = BATADV_TTL_EXCEEDED;
366 icmp_packet->icmph.header.ttl = BATADV_TTL; 366 icmp_packet->icmph.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);