Patchwork [2/4] batman: don't bother flipping ->tt_crc

login
register
mail settings
Submitter Al Viro
Date April 18, 2012, 6:10 p.m.
Message ID <20120418181058.GD6589@ZenIV.linux.org.uk>
Download mbox | patch
Permalink /patch/153554/
State Awaiting Upstream
Delegated to: David Miller
Headers show

Comments

Al Viro - April 18, 2012, 6:10 p.m.
Again, keep ->tt_crc in batman_ogv_packet net-endian

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 net/batman-adv/bat_iv_ogm.c |    6 ++----
 net/batman-adv/packet.h     |    2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)
Antonio Quartulli - April 19, 2012, 5:41 a.m.
On Wed, Apr 18, 2012 at 07:10:58 +0100, Al Viro wrote:
> @@ -722,7 +721,7 @@ update_tt:
>  		tt_update_orig(bat_priv, orig_node, tt_buff,
>  			       batman_ogm_packet->tt_num_changes,
>  			       batman_ogm_packet->ttvn,
> -			       batman_ogm_packet->tt_crc);
> +			       ntohs(batman_ogm_packet->tt_crc));

If we don't need to flip tt_crc, wy are you introducing ntohs here? Am I
overlooking something?

> @@ -969,7 +968,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
>  		ethhdr->h_source, if_incoming->net_dev->name,
>  		if_incoming->net_dev->dev_addr, batman_ogm_packet->orig,
>  		batman_ogm_packet->prev_sender, batman_ogm_packet->seqno,
> -		batman_ogm_packet->ttvn, batman_ogm_packet->tt_crc,
> +		batman_ogm_packet->ttvn, ntohs(batman_ogm_packet->tt_crc),
>  		batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq,

The same here..I am not understanding..

Thank you for your patches!

Cheers,
Antonio Quartulli - April 19, 2012, 5:49 a.m.
On Thu, Apr 19, 2012 at 07:41:14AM +0200, Antonio Quartulli wrote:
> On Wed, Apr 18, 2012 at 07:10:58 +0100, Al Viro wrote:
> > @@ -722,7 +721,7 @@ update_tt:
> >  		tt_update_orig(bat_priv, orig_node, tt_buff,
> >  			       batman_ogm_packet->tt_num_changes,
> >  			       batman_ogm_packet->ttvn,
> > -			       batman_ogm_packet->tt_crc);
> > +			       ntohs(batman_ogm_packet->tt_crc));
> 
> If we don't need to flip tt_crc, wy are you introducing ntohs here? Am I
> overlooking something?

Ok. I was missing the correct meaning of __be16. Now everything is clear.


Cheers,

Patch

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index ab2085c..5aa8861 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -544,7 +544,6 @@  static void bat_iv_ogm_forward(struct orig_node *orig_node,
 		batman_ogm_packet->tq, batman_ogm_packet->header.ttl);
 
 	batman_ogm_packet->seqno = htonl(batman_ogm_packet->seqno);
-	batman_ogm_packet->tt_crc = htons(batman_ogm_packet->tt_crc);
 
 	/* switch of primaries first hop flag when forwarding */
 	batman_ogm_packet->flags &= ~PRIMARIES_FIRST_HOP;
@@ -722,7 +721,7 @@  update_tt:
 		tt_update_orig(bat_priv, orig_node, tt_buff,
 			       batman_ogm_packet->tt_num_changes,
 			       batman_ogm_packet->ttvn,
-			       batman_ogm_packet->tt_crc);
+			       ntohs(batman_ogm_packet->tt_crc));
 
 	if (orig_node->gw_flags != batman_ogm_packet->gw_flags)
 		gw_node_update(bat_priv, orig_node,
@@ -969,7 +968,7 @@  static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
 		ethhdr->h_source, if_incoming->net_dev->name,
 		if_incoming->net_dev->dev_addr, batman_ogm_packet->orig,
 		batman_ogm_packet->prev_sender, batman_ogm_packet->seqno,
-		batman_ogm_packet->ttvn, batman_ogm_packet->tt_crc,
+		batman_ogm_packet->ttvn, ntohs(batman_ogm_packet->tt_crc),
 		batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq,
 		batman_ogm_packet->header.ttl,
 		batman_ogm_packet->header.version, has_directlink_flag);
@@ -1214,7 +1213,6 @@  static int bat_iv_ogm_receive(struct sk_buff *skb,
 		/* network to host order for our 32bit seqno and the
 		   orig_interval */
 		batman_ogm_packet->seqno = ntohl(batman_ogm_packet->seqno);
-		batman_ogm_packet->tt_crc = ntohs(batman_ogm_packet->tt_crc);
 
 		tt_buff = packet_buff + buff_pos + BATMAN_OGM_HLEN;
 
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index 9157f7c..61a7fe0 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -132,7 +132,7 @@  struct batman_ogm_packet {
 	uint8_t  tq;
 	uint8_t  tt_num_changes;
 	uint8_t  ttvn; /* translation table version number */
-	uint16_t tt_crc;
+	__be16   tt_crc;
 } __packed;
 
 #define BATMAN_OGM_HLEN sizeof(struct batman_ogm_packet)