aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/soft-interface.c
diff options
context:
space:
mode:
authorAntonio Quartulli <ordex@autistici.org>2013-05-19 06:55:16 -0400
committerAntonio Quartulli <antonio@meshcoding.com>2013-10-12 05:59:23 -0400
commit293e93385e024be71500c9480ef85d6199459d17 (patch)
treeda710c595953f0442c0a2b18dd2f7723d8a5ee7d /net/batman-adv/soft-interface.c
parentee75ed88879af88558818a5c6609d85f60ff0df4 (diff)
batman-adv: use htons when possible
When comparing a network ordered value with a constant, it is better to convert the constant at compile time by means of htons() instead of converting the value at runtime using ntohs(). This refactoring may slightly improve the code performance. Moreover substitute __constant_htons() with htons() since the latter increase readability and it is smart enough to be as efficient as the former Signed-off-by: Antonio Quartulli <ordex@autistici.org> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de> Acked-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Diffstat (limited to 'net/batman-adv/soft-interface.c')
-rw-r--r--net/batman-adv/soft-interface.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 18b1fd915d1f..87e7e4ed216d 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -145,7 +145,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
145 struct batadv_hard_iface *primary_if = NULL; 145 struct batadv_hard_iface *primary_if = NULL;
146 struct batadv_bcast_packet *bcast_packet; 146 struct batadv_bcast_packet *bcast_packet;
147 struct vlan_ethhdr *vhdr; 147 struct vlan_ethhdr *vhdr;
148 __be16 ethertype = __constant_htons(ETH_P_BATMAN); 148 __be16 ethertype = htons(ETH_P_BATMAN);
149 static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, 149 static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00,
150 0x00, 0x00}; 150 0x00, 0x00};
151 static const uint8_t ectp_addr[ETH_ALEN] = {0xCF, 0x00, 0x00, 0x00, 151 static const uint8_t ectp_addr[ETH_ALEN] = {0xCF, 0x00, 0x00, 0x00,
@@ -312,7 +312,7 @@ void batadv_interface_rx(struct net_device *soft_iface,
312 struct vlan_ethhdr *vhdr; 312 struct vlan_ethhdr *vhdr;
313 struct batadv_header *batadv_header = (struct batadv_header *)skb->data; 313 struct batadv_header *batadv_header = (struct batadv_header *)skb->data;
314 unsigned short vid __maybe_unused = BATADV_NO_FLAGS; 314 unsigned short vid __maybe_unused = BATADV_NO_FLAGS;
315 __be16 ethertype = __constant_htons(ETH_P_BATMAN); 315 __be16 ethertype = htons(ETH_P_BATMAN);
316 bool is_bcast; 316 bool is_bcast;
317 317
318 is_bcast = (batadv_header->packet_type == BATADV_BCAST); 318 is_bcast = (batadv_header->packet_type == BATADV_BCAST);