From patchwork Wed Apr 18 18:09:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 153553 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4BCCAB703E for ; Thu, 19 Apr 2012 04:10:06 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753550Ab2DRSJw (ORCPT ); Wed, 18 Apr 2012 14:09:52 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:49254 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753276Ab2DRSJu (ORCPT ); Wed, 18 Apr 2012 14:09:50 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.76 #1 (Red Hat Linux)) id 1SKZK7-0006S2-SM; Wed, 18 Apr 2012 18:09:47 +0000 Date: Wed, 18 Apr 2012 19:09:47 +0100 From: Al Viro To: Antonio Quartulli Cc: davem@davemloft.net, netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org Subject: [PATCH 1/4] batman: don't bother flipping ->tt_data Message-ID: <20120418180947.GC6589@ZenIV.linux.org.uk> References: <1334743210-12338-1-git-send-email-ordex@autistici.org> <20120418180837.GB6589@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120418180837.GB6589@ZenIV.linux.org.uk> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org just keep it net-endian all along Signed-off-by: Al Viro --- net/batman-adv/packet.h | 2 +- net/batman-adv/routing.c | 6 +----- net/batman-adv/translation-table.c | 8 ++++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h index 307dbb3..9157f7c 100644 --- a/net/batman-adv/packet.h +++ b/net/batman-adv/packet.h @@ -220,7 +220,7 @@ struct tt_query_packet { * if TT_REQUEST: crc associated with the * ttvn * if TT_RESPONSE: table_size */ - uint16_t tt_data; + __be16 tt_data; } __packed; struct roam_adv_packet { diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 2181a91..4310cfe 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -596,8 +596,6 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) tt_query = (struct tt_query_packet *)skb->data; - tt_query->tt_data = ntohs(tt_query->tt_data); - switch (tt_query->flags & TT_QUERY_TYPE_MASK) { case TT_REQUEST: /* If we cannot provide an answer the tt_request is @@ -607,7 +605,6 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) "Routing TT_REQUEST to %pM [%c]\n", tt_query->dst, (tt_query->flags & TT_FULL_TABLE ? 'F' : '.')); - tt_query->tt_data = htons(tt_query->tt_data); return route_unicast_packet(skb, recv_if); } break; @@ -618,7 +615,7 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) if (skb_linearize(skb) < 0) goto out; - tt_len = tt_query->tt_data * sizeof(struct tt_change); + tt_len = ntohs(tt_query->tt_data) * sizeof(struct tt_change); /* Ensure we have all the claimed data */ if (unlikely(skb_headlen(skb) < @@ -631,7 +628,6 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) "Routing TT_RESPONSE to %pM [%c]\n", tt_query->dst, (tt_query->flags & TT_FULL_TABLE ? 'F' : '.')); - tt_query->tt_data = htons(tt_query->tt_data); return route_unicast_packet(skb, recv_if); } break; diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 88e4c8e..a9c2b59 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -1416,7 +1416,7 @@ static bool send_other_tt_response(struct bat_priv *bat_priv, /* I don't have the requested data */ if (orig_ttvn != req_ttvn || - tt_request->tt_data != req_dst_orig_node->tt_crc) + tt_request->tt_data != htons(req_dst_orig_node->tt_crc)) goto out; /* If the full table has been explicitly requested */ @@ -1672,7 +1672,7 @@ static void tt_fill_gtable(struct bat_priv *bat_priv, _tt_update_changes(bat_priv, orig_node, (struct tt_change *)(tt_response + 1), - tt_response->tt_data, tt_response->ttvn); + ntohs(tt_response->tt_data), tt_response->ttvn); spin_lock_bh(&orig_node->tt_buff_lock); kfree(orig_node->tt_buff); @@ -1727,7 +1727,7 @@ void handle_tt_response(struct bat_priv *bat_priv, bat_dbg(DBG_TT, bat_priv, "Received TT_RESPONSE from %pM for ttvn %d t_size: %d [%c]\n", - tt_response->src, tt_response->ttvn, tt_response->tt_data, + tt_response->src, tt_response->ttvn, ntohs(tt_response->tt_data), (tt_response->flags & TT_FULL_TABLE ? 'F' : '.')); /* we should have never asked a backbone gw */ @@ -1741,7 +1741,7 @@ void handle_tt_response(struct bat_priv *bat_priv, if (tt_response->flags & TT_FULL_TABLE) tt_fill_gtable(bat_priv, tt_response); else - tt_update_changes(bat_priv, orig_node, tt_response->tt_data, + tt_update_changes(bat_priv, orig_node, ntohs(tt_response->tt_data), tt_response->ttvn, (struct tt_change *)(tt_response + 1));