aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv
diff options
context:
space:
mode:
authorAl Viro <viro@ZenIV.linux.org.uk>2012-04-22 02:44:27 -0400
committerAntonio Quartulli <ordex@autistici.org>2012-06-18 12:01:03 -0400
commitf25bd58a9d95481e81a09a3a88c4a3f3ab38609f (patch)
tree659d34ff5de3fe316534a47e82e2f0765b83ffc1 /net/batman-adv
parent5346c35ebfbdb1727e60079456dd8071cb888059 (diff)
batman-adv: don't bother flipping ->tt_data
just keep it net-endian all along Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> [lindner_marek@yahoo.de: fix checkpatch warnings] Signed-off-by: Marek Lindner <lindner_marek@yahoo.de> Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/packet.h2
-rw-r--r--net/batman-adv/routing.c10
-rw-r--r--net/batman-adv/translation-table.c10
3 files changed, 10 insertions, 12 deletions
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index 5bf567b52534..372fc889832a 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -206,7 +206,7 @@ struct tt_query_packet {
206 * if TT_REQUEST: crc associated with the 206 * if TT_REQUEST: crc associated with the
207 * ttvn 207 * ttvn
208 * if TT_RESPONSE: table_size */ 208 * if TT_RESPONSE: table_size */
209 uint16_t tt_data; 209 __be16 tt_data;
210} __packed; 210} __packed;
211 211
212struct roam_adv_packet { 212struct roam_adv_packet {
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 369604c99a46..9cfd23c6d64a 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -573,7 +573,7 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
573{ 573{
574 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); 574 struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface);
575 struct tt_query_packet *tt_query; 575 struct tt_query_packet *tt_query;
576 uint16_t tt_len; 576 uint16_t tt_size;
577 struct ethhdr *ethhdr; 577 struct ethhdr *ethhdr;
578 578
579 /* drop packet if it has not necessary minimum size */ 579 /* drop packet if it has not necessary minimum size */
@@ -596,8 +596,6 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
596 596
597 tt_query = (struct tt_query_packet *)skb->data; 597 tt_query = (struct tt_query_packet *)skb->data;
598 598
599 tt_query->tt_data = ntohs(tt_query->tt_data);
600
601 switch (tt_query->flags & TT_QUERY_TYPE_MASK) { 599 switch (tt_query->flags & TT_QUERY_TYPE_MASK) {
602 case TT_REQUEST: 600 case TT_REQUEST:
603 batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_RX); 601 batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_RX);
@@ -609,7 +607,6 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
609 "Routing TT_REQUEST to %pM [%c]\n", 607 "Routing TT_REQUEST to %pM [%c]\n",
610 tt_query->dst, 608 tt_query->dst,
611 (tt_query->flags & TT_FULL_TABLE ? 'F' : '.')); 609 (tt_query->flags & TT_FULL_TABLE ? 'F' : '.'));
612 tt_query->tt_data = htons(tt_query->tt_data);
613 return route_unicast_packet(skb, recv_if); 610 return route_unicast_packet(skb, recv_if);
614 } 611 }
615 break; 612 break;
@@ -624,11 +621,11 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
624 /* skb_linearize() possibly changed skb->data */ 621 /* skb_linearize() possibly changed skb->data */
625 tt_query = (struct tt_query_packet *)skb->data; 622 tt_query = (struct tt_query_packet *)skb->data;
626 623
627 tt_len = tt_query->tt_data * sizeof(struct tt_change); 624 tt_size = tt_len(ntohs(tt_query->tt_data));
628 625
629 /* Ensure we have all the claimed data */ 626 /* Ensure we have all the claimed data */
630 if (unlikely(skb_headlen(skb) < 627 if (unlikely(skb_headlen(skb) <
631 sizeof(struct tt_query_packet) + tt_len)) 628 sizeof(struct tt_query_packet) + tt_size))
632 goto out; 629 goto out;
633 630
634 handle_tt_response(bat_priv, tt_query); 631 handle_tt_response(bat_priv, tt_query);
@@ -637,7 +634,6 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
637 "Routing TT_RESPONSE to %pM [%c]\n", 634 "Routing TT_RESPONSE to %pM [%c]\n",
638 tt_query->dst, 635 tt_query->dst,
639 (tt_query->flags & TT_FULL_TABLE ? 'F' : '.')); 636 (tt_query->flags & TT_FULL_TABLE ? 'F' : '.'));
640 tt_query->tt_data = htons(tt_query->tt_data);
641 return route_unicast_packet(skb, recv_if); 637 return route_unicast_packet(skb, recv_if);
642 } 638 }
643 break; 639 break;
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 24e691d7275c..88cfe2a8ea4f 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1418,7 +1418,7 @@ static bool send_other_tt_response(struct bat_priv *bat_priv,
1418 1418
1419 /* I don't have the requested data */ 1419 /* I don't have the requested data */
1420 if (orig_ttvn != req_ttvn || 1420 if (orig_ttvn != req_ttvn ||
1421 tt_request->tt_data != req_dst_orig_node->tt_crc) 1421 tt_request->tt_data != htons(req_dst_orig_node->tt_crc))
1422 goto out; 1422 goto out;
1423 1423
1424 /* If the full table has been explicitly requested */ 1424 /* If the full table has been explicitly requested */
@@ -1678,7 +1678,7 @@ static void tt_fill_gtable(struct bat_priv *bat_priv,
1678 1678
1679 _tt_update_changes(bat_priv, orig_node, 1679 _tt_update_changes(bat_priv, orig_node,
1680 (struct tt_change *)(tt_response + 1), 1680 (struct tt_change *)(tt_response + 1),
1681 tt_response->tt_data, tt_response->ttvn); 1681 ntohs(tt_response->tt_data), tt_response->ttvn);
1682 1682
1683 spin_lock_bh(&orig_node->tt_buff_lock); 1683 spin_lock_bh(&orig_node->tt_buff_lock);
1684 kfree(orig_node->tt_buff); 1684 kfree(orig_node->tt_buff);
@@ -1733,7 +1733,8 @@ void handle_tt_response(struct bat_priv *bat_priv,
1733 1733
1734 bat_dbg(DBG_TT, bat_priv, 1734 bat_dbg(DBG_TT, bat_priv,
1735 "Received TT_RESPONSE from %pM for ttvn %d t_size: %d [%c]\n", 1735 "Received TT_RESPONSE from %pM for ttvn %d t_size: %d [%c]\n",
1736 tt_response->src, tt_response->ttvn, tt_response->tt_data, 1736 tt_response->src, tt_response->ttvn,
1737 ntohs(tt_response->tt_data),
1737 (tt_response->flags & TT_FULL_TABLE ? 'F' : '.')); 1738 (tt_response->flags & TT_FULL_TABLE ? 'F' : '.'));
1738 1739
1739 /* we should have never asked a backbone gw */ 1740 /* we should have never asked a backbone gw */
@@ -1747,7 +1748,8 @@ void handle_tt_response(struct bat_priv *bat_priv,
1747 if (tt_response->flags & TT_FULL_TABLE) 1748 if (tt_response->flags & TT_FULL_TABLE)
1748 tt_fill_gtable(bat_priv, tt_response); 1749 tt_fill_gtable(bat_priv, tt_response);
1749 else 1750 else
1750 tt_update_changes(bat_priv, orig_node, tt_response->tt_data, 1751 tt_update_changes(bat_priv, orig_node,
1752 ntohs(tt_response->tt_data),
1751 tt_response->ttvn, 1753 tt_response->ttvn,
1752 (struct tt_change *)(tt_response + 1)); 1754 (struct tt_change *)(tt_response + 1));
1753 1755