1 #ifndef __NET_UDP_WRAPPER_H
2 #define __NET_UDP_WRAPPER_H 1
4 #include_next <net/udp.h>
6 #ifndef HAVE_UDP_FLOW_SRC_PORT
7 static inline __be16 udp_flow_src_port(struct net *net, struct sk_buff *skb,
8 int min, int max, bool use_eth)
13 /* Use default range */
14 inet_get_local_port_range(net, &min, &max);
17 hash = skb_get_hash(skb);
18 if (unlikely(!hash) && use_eth) {
19 /* Can't find a normal hash, caller has indicated an Ethernet
20 * packet so use that to compute a hash.
22 hash = jhash(skb->data, 2 * ETH_ALEN,
23 (__force u32) skb->protocol);
26 /* Since this is being sent on the wire obfuscate hash a bit
27 * to minimize possbility that any useful information to an
28 * attacker is leaked. Only upper 16 bits are relevant in the
29 * computation for 16 bit port value.
33 return htons((((u64) hash * (max - min)) >> 32) + min);