diff options
author | Al Viro <viro@ZenIV.linux.org.uk> | 2012-04-22 02:46:29 -0400 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2012-06-18 12:01:02 -0400 |
commit | e0f5211f9bbfaa66d27cda6b0dc86466c7dcb206 (patch) | |
tree | 09499c9f74a541eb5ff6e4b3ebe9a22886c71588 /net/batman-adv/bat_iv_ogm.c | |
parent | 3e2f1a1bb528df14065a9287f37378ca453c52f9 (diff) |
batman-adv: keep batman_ogm_packet ->seqno net-endian all along
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv/bat_iv_ogm.c')
-rw-r--r-- | net/batman-adv/bat_iv_ogm.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index e94ac0b99c65..56b6d78bfbfd 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c | |||
@@ -34,11 +34,12 @@ static struct neigh_node *bat_iv_ogm_neigh_new(struct hard_iface *hard_iface, | |||
34 | const uint8_t *neigh_addr, | 34 | const uint8_t *neigh_addr, |
35 | struct orig_node *orig_node, | 35 | struct orig_node *orig_node, |
36 | struct orig_node *orig_neigh, | 36 | struct orig_node *orig_neigh, |
37 | uint32_t seqno) | 37 | __be32 seqno) |
38 | { | 38 | { |
39 | struct neigh_node *neigh_node; | 39 | struct neigh_node *neigh_node; |
40 | 40 | ||
41 | neigh_node = batadv_neigh_node_new(hard_iface, neigh_addr, seqno); | 41 | neigh_node = batadv_neigh_node_new(hard_iface, neigh_addr, |
42 | ntohl(seqno)); | ||
42 | if (!neigh_node) | 43 | if (!neigh_node) |
43 | goto out; | 44 | goto out; |
44 | 45 | ||
@@ -546,7 +547,6 @@ static void bat_iv_ogm_forward(struct orig_node *orig_node, | |||
546 | "Forwarding packet: tq: %i, ttl: %i\n", | 547 | "Forwarding packet: tq: %i, ttl: %i\n", |
547 | batman_ogm_packet->tq, batman_ogm_packet->header.ttl); | 548 | batman_ogm_packet->tq, batman_ogm_packet->header.ttl); |
548 | 549 | ||
549 | batman_ogm_packet->seqno = htonl(batman_ogm_packet->seqno); | ||
550 | batman_ogm_packet->tt_crc = htons(batman_ogm_packet->tt_crc); | 550 | batman_ogm_packet->tt_crc = htons(batman_ogm_packet->tt_crc); |
551 | 551 | ||
552 | /* switch of primaries first hop flag when forwarding */ | 552 | /* switch of primaries first hop flag when forwarding */ |
@@ -871,13 +871,14 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, | |||
871 | int32_t seq_diff; | 871 | int32_t seq_diff; |
872 | int need_update = 0; | 872 | int need_update = 0; |
873 | int set_mark, ret = -1; | 873 | int set_mark, ret = -1; |
874 | uint32_t seqno = ntohl(batman_ogm_packet->seqno); | ||
874 | 875 | ||
875 | orig_node = get_orig_node(bat_priv, batman_ogm_packet->orig); | 876 | orig_node = get_orig_node(bat_priv, batman_ogm_packet->orig); |
876 | if (!orig_node) | 877 | if (!orig_node) |
877 | return 0; | 878 | return 0; |
878 | 879 | ||
879 | spin_lock_bh(&orig_node->ogm_cnt_lock); | 880 | spin_lock_bh(&orig_node->ogm_cnt_lock); |
880 | seq_diff = batman_ogm_packet->seqno - orig_node->last_real_seqno; | 881 | seq_diff = seqno - orig_node->last_real_seqno; |
881 | 882 | ||
882 | /* signalize caller that the packet is to be dropped. */ | 883 | /* signalize caller that the packet is to be dropped. */ |
883 | if (!hlist_empty(&orig_node->neigh_list) && | 884 | if (!hlist_empty(&orig_node->neigh_list) && |
@@ -891,7 +892,7 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, | |||
891 | 892 | ||
892 | is_duplicate |= bat_test_bit(tmp_neigh_node->real_bits, | 893 | is_duplicate |= bat_test_bit(tmp_neigh_node->real_bits, |
893 | orig_node->last_real_seqno, | 894 | orig_node->last_real_seqno, |
894 | batman_ogm_packet->seqno); | 895 | seqno); |
895 | 896 | ||
896 | if (compare_eth(tmp_neigh_node->addr, ethhdr->h_source) && | 897 | if (compare_eth(tmp_neigh_node->addr, ethhdr->h_source) && |
897 | (tmp_neigh_node->if_incoming == if_incoming)) | 898 | (tmp_neigh_node->if_incoming == if_incoming)) |
@@ -913,8 +914,8 @@ static int bat_iv_ogm_update_seqnos(const struct ethhdr *ethhdr, | |||
913 | if (need_update) { | 914 | if (need_update) { |
914 | bat_dbg(DBG_BATMAN, bat_priv, | 915 | bat_dbg(DBG_BATMAN, bat_priv, |
915 | "updating last_seqno: old %u, new %u\n", | 916 | "updating last_seqno: old %u, new %u\n", |
916 | orig_node->last_real_seqno, batman_ogm_packet->seqno); | 917 | orig_node->last_real_seqno, seqno); |
917 | orig_node->last_real_seqno = batman_ogm_packet->seqno; | 918 | orig_node->last_real_seqno = seqno; |
918 | } | 919 | } |
919 | 920 | ||
920 | ret = is_duplicate; | 921 | ret = is_duplicate; |
@@ -970,7 +971,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, | |||
970 | "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", | 971 | "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", |
971 | ethhdr->h_source, if_incoming->net_dev->name, | 972 | ethhdr->h_source, if_incoming->net_dev->name, |
972 | if_incoming->net_dev->dev_addr, batman_ogm_packet->orig, | 973 | if_incoming->net_dev->dev_addr, batman_ogm_packet->orig, |
973 | batman_ogm_packet->prev_sender, batman_ogm_packet->seqno, | 974 | batman_ogm_packet->prev_sender, ntohl(batman_ogm_packet->seqno), |
974 | batman_ogm_packet->ttvn, batman_ogm_packet->tt_crc, | 975 | batman_ogm_packet->ttvn, batman_ogm_packet->tt_crc, |
975 | batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq, | 976 | batman_ogm_packet->tt_num_changes, batman_ogm_packet->tq, |
976 | batman_ogm_packet->header.ttl, | 977 | batman_ogm_packet->header.ttl, |
@@ -1042,7 +1043,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, | |||
1042 | word = &(orig_neigh_node->bcast_own[offset]); | 1043 | word = &(orig_neigh_node->bcast_own[offset]); |
1043 | bat_set_bit(word, | 1044 | bat_set_bit(word, |
1044 | if_incoming_seqno - | 1045 | if_incoming_seqno - |
1045 | batman_ogm_packet->seqno - 2); | 1046 | ntohl(batman_ogm_packet->seqno) - 2); |
1046 | orig_neigh_node->bcast_own_sum[if_incoming->if_num] = | 1047 | orig_neigh_node->bcast_own_sum[if_incoming->if_num] = |
1047 | bitmap_weight(word, TQ_LOCAL_WINDOW_SIZE); | 1048 | bitmap_weight(word, TQ_LOCAL_WINDOW_SIZE); |
1048 | spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock); | 1049 | spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock); |
@@ -1135,7 +1136,7 @@ static void bat_iv_ogm_process(const struct ethhdr *ethhdr, | |||
1135 | * seqno and similar ttl as the non-duplicate */ | 1136 | * seqno and similar ttl as the non-duplicate */ |
1136 | if (is_bidirectional && | 1137 | if (is_bidirectional && |
1137 | (!is_duplicate || | 1138 | (!is_duplicate || |
1138 | ((orig_node->last_real_seqno == batman_ogm_packet->seqno) && | 1139 | ((orig_node->last_real_seqno == ntohl(batman_ogm_packet->seqno)) && |
1139 | (orig_node->last_ttl - 3 <= batman_ogm_packet->header.ttl)))) | 1140 | (orig_node->last_ttl - 3 <= batman_ogm_packet->header.ttl)))) |
1140 | bat_iv_ogm_orig_update(bat_priv, orig_node, ethhdr, | 1141 | bat_iv_ogm_orig_update(bat_priv, orig_node, ethhdr, |
1141 | batman_ogm_packet, if_incoming, | 1142 | batman_ogm_packet, if_incoming, |
@@ -1220,7 +1221,6 @@ static int bat_iv_ogm_receive(struct sk_buff *skb, | |||
1220 | do { | 1221 | do { |
1221 | /* network to host order for our 32bit seqno and the | 1222 | /* network to host order for our 32bit seqno and the |
1222 | orig_interval */ | 1223 | orig_interval */ |
1223 | batman_ogm_packet->seqno = ntohl(batman_ogm_packet->seqno); | ||
1224 | batman_ogm_packet->tt_crc = ntohs(batman_ogm_packet->tt_crc); | 1224 | batman_ogm_packet->tt_crc = ntohs(batman_ogm_packet->tt_crc); |
1225 | 1225 | ||
1226 | tt_buff = packet_buff + buff_pos + BATMAN_OGM_HLEN; | 1226 | tt_buff = packet_buff + buff_pos + BATMAN_OGM_HLEN; |