diff options
author | Antonio Quartulli <antonio@open-mesh.com> | 2013-10-12 20:50:17 -0400 |
---|---|---|
committer | Antonio Quartulli <antonio@meshcoding.com> | 2014-01-08 14:49:39 -0500 |
commit | 3fba7325bb057977ec180b5f462084c50ca7940e (patch) | |
tree | ffa321077c017256351bf2c8342e80267382244b /net/batman-adv | |
parent | a48bcacdb3b31816500d5732111241b705c4bc61 (diff) |
batman-adv: don't switch byte order too often if not needed
If possible, operations like ntohs/ntohl should not be
performed too often. Use a variable to locally store the
converted value and then use it.
Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/routing.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 46278bfb8fdb..a89e812963e5 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
@@ -1135,6 +1135,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, | |||
1135 | int hdr_size = sizeof(*bcast_packet); | 1135 | int hdr_size = sizeof(*bcast_packet); |
1136 | int ret = NET_RX_DROP; | 1136 | int ret = NET_RX_DROP; |
1137 | int32_t seq_diff; | 1137 | int32_t seq_diff; |
1138 | uint32_t seqno; | ||
1138 | 1139 | ||
1139 | /* drop packet if it has not necessary minimum size */ | 1140 | /* drop packet if it has not necessary minimum size */ |
1140 | if (unlikely(!pskb_may_pull(skb, hdr_size))) | 1141 | if (unlikely(!pskb_may_pull(skb, hdr_size))) |
@@ -1170,12 +1171,13 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, | |||
1170 | 1171 | ||
1171 | spin_lock_bh(&orig_node->bcast_seqno_lock); | 1172 | spin_lock_bh(&orig_node->bcast_seqno_lock); |
1172 | 1173 | ||
1174 | seqno = ntohl(bcast_packet->seqno); | ||
1173 | /* check whether the packet is a duplicate */ | 1175 | /* check whether the packet is a duplicate */ |
1174 | if (batadv_test_bit(orig_node->bcast_bits, orig_node->last_bcast_seqno, | 1176 | if (batadv_test_bit(orig_node->bcast_bits, orig_node->last_bcast_seqno, |
1175 | ntohl(bcast_packet->seqno))) | 1177 | seqno)) |
1176 | goto spin_unlock; | 1178 | goto spin_unlock; |
1177 | 1179 | ||
1178 | seq_diff = ntohl(bcast_packet->seqno) - orig_node->last_bcast_seqno; | 1180 | seq_diff = seqno - orig_node->last_bcast_seqno; |
1179 | 1181 | ||
1180 | /* check whether the packet is old and the host just restarted. */ | 1182 | /* check whether the packet is old and the host just restarted. */ |
1181 | if (batadv_window_protected(bat_priv, seq_diff, | 1183 | if (batadv_window_protected(bat_priv, seq_diff, |
@@ -1186,7 +1188,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, | |||
1186 | * if required. | 1188 | * if required. |
1187 | */ | 1189 | */ |
1188 | if (batadv_bit_get_packet(bat_priv, orig_node->bcast_bits, seq_diff, 1)) | 1190 | if (batadv_bit_get_packet(bat_priv, orig_node->bcast_bits, seq_diff, 1)) |
1189 | orig_node->last_bcast_seqno = ntohl(bcast_packet->seqno); | 1191 | orig_node->last_bcast_seqno = seqno; |
1190 | 1192 | ||
1191 | spin_unlock_bh(&orig_node->bcast_seqno_lock); | 1193 | spin_unlock_bh(&orig_node->bcast_seqno_lock); |
1192 | 1194 | ||