[PKTGEN]: TCI endianness fixes

open-coded variant there works only for little-endian

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Al Viro and committed by David S. Miller 0f37c605 36da4d86

+18 -12
+18 -12
net/core/pktgen.c
··· 2304 2304 *mpls |= MPLS_STACK_BOTTOM; 2305 2305 } 2306 2306 2307 + static inline __be16 build_tci(unsigned int id, unsigned int cfi, 2308 + unsigned int prio) 2309 + { 2310 + return htons(id | (cfi << 12) | (prio << 13)); 2311 + } 2312 + 2307 2313 static struct sk_buff *fill_packet_ipv4(struct net_device *odev, 2308 2314 struct pktgen_dev *pkt_dev) 2309 2315 { ··· 2359 2353 if (pkt_dev->vlan_id != 0xffff) { 2360 2354 if(pkt_dev->svlan_id != 0xffff) { 2361 2355 svlan_tci = (__be16 *)skb_put(skb, sizeof(__be16)); 2362 - *svlan_tci = htons(pkt_dev->svlan_id); 2363 - *svlan_tci |= pkt_dev->svlan_p << 5; 2364 - *svlan_tci |= pkt_dev->svlan_cfi << 4; 2356 + *svlan_tci = build_tci(pkt_dev->svlan_id, 2357 + pkt_dev->svlan_cfi, 2358 + pkt_dev->svlan_p); 2365 2359 svlan_encapsulated_proto = (__be16 *)skb_put(skb, sizeof(__be16)); 2366 2360 *svlan_encapsulated_proto = __constant_htons(ETH_P_8021Q); 2367 2361 } 2368 2362 vlan_tci = (__be16 *)skb_put(skb, sizeof(__be16)); 2369 - *vlan_tci = htons(pkt_dev->vlan_id); 2370 - *vlan_tci |= pkt_dev->vlan_p << 5; 2371 - *vlan_tci |= pkt_dev->vlan_cfi << 4; 2363 + *vlan_tci = build_tci(pkt_dev->vlan_id, 2364 + pkt_dev->vlan_cfi, 2365 + pkt_dev->vlan_p); 2372 2366 vlan_encapsulated_proto = (__be16 *)skb_put(skb, sizeof(__be16)); 2373 2367 *vlan_encapsulated_proto = __constant_htons(ETH_P_IP); 2374 2368 } ··· 2695 2689 if (pkt_dev->vlan_id != 0xffff) { 2696 2690 if(pkt_dev->svlan_id != 0xffff) { 2697 2691 svlan_tci = (__be16 *)skb_put(skb, sizeof(__be16)); 2698 - *svlan_tci = htons(pkt_dev->svlan_id); 2699 - *svlan_tci |= pkt_dev->svlan_p << 5; 2700 - *svlan_tci |= pkt_dev->svlan_cfi << 4; 2692 + *svlan_tci = build_tci(pkt_dev->svlan_id, 2693 + pkt_dev->svlan_cfi, 2694 + pkt_dev->svlan_p); 2701 2695 svlan_encapsulated_proto = (__be16 *)skb_put(skb, sizeof(__be16)); 2702 2696 *svlan_encapsulated_proto = __constant_htons(ETH_P_8021Q); 2703 2697 } 2704 2698 vlan_tci = (__be16 *)skb_put(skb, sizeof(__be16)); 2705 - *vlan_tci = htons(pkt_dev->vlan_id); 2706 - *vlan_tci |= pkt_dev->vlan_p << 5; 2707 - *vlan_tci |= pkt_dev->vlan_cfi << 4; 2699 + *vlan_tci = build_tci(pkt_dev->vlan_id, 2700 + pkt_dev->vlan_cfi, 2701 + pkt_dev->vlan_p); 2708 2702 vlan_encapsulated_proto = (__be16 *)skb_put(skb, sizeof(__be16)); 2709 2703 *vlan_encapsulated_proto = __constant_htons(ETH_P_IPV6); 2710 2704 }