From: Al Viro <viro@ZenIV.linux.org.uk>
To: Antonio Quartulli <ordex@autistici.org>
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
davem@davemloft.net
Subject: [B.A.T.M.A.N.] batman: keep batman_ogm_packet ->seqno net-endian all along
Date: Wed, 18 Apr 2012 19:11:50 +0100 [thread overview]
Message-ID: <20120418181150.GE6589@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20120418180837.GB6589@ZenIV.linux.org.uk>
Ditto for its ->seqno...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
net/batman-adv/bat_iv_ogm.c | 25 ++++++++++---------------
net/batman-adv/packet.h | 2 +-
2 files changed, 11 insertions(+), 16 deletions(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 5aa8861..cc6d4c3 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -34,11 +34,11 @@ static struct neigh_node *bat_iv_ogm_neigh_new(struct hard_iface *hard_iface,
const uint8_t *neigh_addr,
struct orig_node *orig_node,
struct orig_node *orig_neigh,
- uint32_t seqno)
+ __be32 seqno)
{
struct neigh_node *neigh_node;
- neigh_node = neigh_node_new(hard_iface, neigh_addr, seqno);
+ neigh_node = neigh_node_new(hard_iface, neigh_addr, ntohl(seqno));
if (!neigh_node)
goto out;
@@ -543,8 +543,6 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node,
"Forwarding packet: tq: %i, ttl: %i\n",
batman_ogm_packet->tq, batman_ogm_packet->header.ttl);
- batman_ogm_packet->seqno = htonl(batman_ogm_packet->seqno);
-
/* switch of primaries first hop flag when forwarding */
batman_ogm_packet->flags &= ~PRIMARIES_FIRST_HOP;
if (is_single_hop_neigh)
@@ -868,13 +866,14 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
int32_t seq_diff;
int need_update = 0;
int set_mark, ret = -1;
+ uint32_t seqno = ntohl(batman_ogm_packet->seqno);
orig_node = get_orig_node(bat_priv, batman_ogm_packet->orig);
if (!orig_node)
return 0;
spin_lock_bh(&orig_node->ogm_cnt_lock);
- seq_diff = batman_ogm_packet->seqno - orig_node->last_real_seqno;
+ seq_diff = seqno - orig_node->last_real_seqno;
/* signalize caller that the packet is to be dropped. */
if (!hlist_empty(&orig_node->neigh_list) &&
@@ -888,7 +887,7 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
is_duplicate |= bat_test_bit(tmp_neigh_node->real_bits,
orig_node->last_real_seqno,
- batman_ogm_packet->seqno);
+ seqno);
if (compare_eth(tmp_neigh_node->addr, ethhdr->h_source) &&
(tmp_neigh_node->if_incoming == if_incoming))
@@ -910,8 +909,8 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
if (need_update) {
bat_dbg(DBG_BATMAN, bat_priv,
"updating last_seqno: old %u, new %u\n",
- orig_node->last_real_seqno, batman_ogm_packet->seqno);
- orig_node->last_real_seqno = batman_ogm_packet->seqno;
+ orig_node->last_real_seqno, seqno);
+ orig_node->last_real_seqno = seqno;
}
ret = is_duplicate;
@@ -967,7 +966,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
"Received BATMAN packet via NB: %pM, IF: %s [%pM] (from OG: %pM, via prev OG: %pM, seqno %u, ttvn %u, crc %u, changes %u, td %d, TTL %d, V %d, IDF %d)\n",
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->prev_sender, ntohl(batman_ogm_packet->seqno),
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,
@@ -1039,7 +1038,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
word = &(orig_neigh_node->bcast_own[offset]);
bat_set_bit(word,
if_incoming_seqno -
- batman_ogm_packet->seqno - 2);
+ ntohl(batman_ogm_packet->seqno) - 2);
orig_neigh_node->bcast_own_sum[if_incoming->if_num] =
bitmap_weight(word, TQ_LOCAL_WINDOW_SIZE);
spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock);
@@ -1132,7 +1131,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr,
* seqno and similar ttl as the non-duplicate */
if (is_bidirectional &&
(!is_duplicate ||
- ((orig_node->last_real_seqno == batman_ogm_packet->seqno) &&
+ ((orig_node->last_real_seqno == ntohl(batman_ogm_packet->seqno)) &&
(orig_node->last_ttl - 3 <= batman_ogm_packet->header.ttl))))
bat_iv_ogm_orig_update(bat_priv, orig_node, ethhdr,
batman_ogm_packet, if_incoming,
@@ -1210,10 +1209,6 @@ static int bat_iv_ogm_receive(struct sk_buff *skb,
/* unpack the aggregated packets and process them one by one */
do {
- /* network to host order for our 32bit seqno and the
- orig_interval */
- batman_ogm_packet->seqno = ntohl(batman_ogm_packet->seqno);
-
tt_buff = packet_buff + buff_pos + BATMAN_OGM_HLEN;
bat_iv_ogm_process(ethhdr, batman_ogm_packet,
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index 61a7fe0..ad39938 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -125,7 +125,7 @@ struct batman_header {
struct batman_ogm_packet {
struct batman_header header;
uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
- uint32_t seqno;
+ __be32 seqno;
uint8_t orig[ETH_ALEN];
uint8_t prev_sender[ETH_ALEN];
uint8_t gw_flags; /* flags related to gateway class */
--
1.7.2.5
next prev parent reply other threads:[~2012-04-18 18:11 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-18 9:59 [B.A.T.M.A.N.] pull request: batman-adv 2012-04-18 Antonio Quartulli
2012-04-18 9:59 ` [B.A.T.M.A.N.] [PATCH 01/13] batman-adv: convert the tt_crc to network order Antonio Quartulli
2012-04-18 9:59 ` [B.A.T.M.A.N.] [PATCH 02/13] batman-adv: remove duplicated line in comment Antonio Quartulli
2012-04-18 10:00 ` [B.A.T.M.A.N.] [PATCH 03/13] batman-adv: move ogm initialization into the proper function Antonio Quartulli
2012-04-18 10:00 ` [B.A.T.M.A.N.] [PATCH 04/13] batman-adv: refactoring API: find generalized name for bat_ogm_init callback Antonio Quartulli
2012-04-18 10:00 ` [B.A.T.M.A.N.] [PATCH 05/13] batman-adv: randomize initial seqno to avoid collision Antonio Quartulli
2012-04-18 10:00 ` [B.A.T.M.A.N.] [PATCH 06/13] batman-adv: add iface_disable() callback to routing API Antonio Quartulli
2012-04-18 10:00 ` [B.A.T.M.A.N.] [PATCH 07/13] batman-adv: handle routing code initialization properly Antonio Quartulli
2012-04-18 10:00 ` [B.A.T.M.A.N.] [PATCH 08/13] batman-adv: refactoring API: find generalized name for bat_ogm_init_primary callback Antonio Quartulli
2012-04-18 10:00 ` [B.A.T.M.A.N.] [PATCH 09/13] batman-adv: rename BATMAN_OGM_LEN to BATMAN_OGM_HLEN Antonio Quartulli
2012-04-18 10:00 ` [B.A.T.M.A.N.] [PATCH 10/13] batman-adv: mark existing ogm variables as batman iv Antonio Quartulli
2012-04-18 10:00 ` [B.A.T.M.A.N.] [PATCH 11/13] batman-adv: use ETH_HLEN instead of sizeof(struct ethhdr) Antonio Quartulli
2012-04-18 10:00 ` [B.A.T.M.A.N.] [PATCH 12/13] batman-adv: print OGM seq numbers as unsigned int Antonio Quartulli
2012-04-18 10:00 ` [B.A.T.M.A.N.] [PATCH 13/13] batman-adv: skip the window protection test when the originator has no neighbours Antonio Quartulli
2012-04-18 17:22 ` [B.A.T.M.A.N.] pull request: batman-adv 2012-04-18 David Miller
2012-04-18 18:08 ` Al Viro
2012-04-18 18:09 ` [B.A.T.M.A.N.] [PATCH 1/4] batman: don't bother flipping ->tt_data Al Viro
2012-04-18 18:10 ` [B.A.T.M.A.N.] [PATCH 2/4] batman: don't bother flipping ->tt_crc Al Viro
2012-04-19 5:41 ` Antonio Quartulli
2012-04-19 5:49 ` Antonio Quartulli
2012-04-18 18:11 ` Al Viro [this message]
2012-04-18 18:15 ` [B.A.T.M.A.N.] batman: keep batman_ogm_packet ->seqno net-endian all along Al Viro
2012-04-18 18:14 ` [B.A.T.M.A.N.] batman: trivial endianness annotations Al Viro
[not found] ` <20120419061026.GC8658@ritirata.org>
[not found] ` <20120419134854.GA6871@ZenIV.linux.org.uk>
2012-04-19 14:09 ` [B.A.T.M.A.N.] pull request: batman-adv 2012-04-18 Antonio Quartulli
2012-04-23 5:18 ` Marek Lindner
2012-04-23 6:43 ` Al Viro
2012-04-23 7:17 ` Marek Lindner
[not found] ` <20120422064426.GU6871@ZenIV.linux.org.uk>
2012-04-25 12:11 ` [B.A.T.M.A.N.] [PATCH 1/5] batman-adv: don't bother flipping ->tt_data Marek Lindner
[not found] ` <20120422065029.GY6871@ZenIV.linux.org.uk>
2012-04-25 12:14 ` [B.A.T.M.A.N.] [PATCH 5/5] batman-adv: get rid of pointless cast in memcpy() Marek Lindner
[not found] ` <20120422064750.GX6871@ZenIV.linux.org.uk>
2012-04-25 12:18 ` [B.A.T.M.A.N.] [PATCH 4/5] batman-adv: trivial endianness annotations Marek Lindner
[not found] ` <20120422064629.GW6871@ZenIV.linux.org.uk>
2012-04-25 12:25 ` [B.A.T.M.A.N.] [PATCH 3/5] batman-adv: keep batman_ogm_packet ->seqno net-endian all along Marek Lindner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120418181150.GE6589@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=ordex@autistici.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).