WHY only covert dport to host short in inet_lookup_listener?

ZZZZZHB

New Member
Joined
Nov 20, 2019
Messages
4
Reaction score
0
Credits
0
While reading how to find a tcp listener in linux kervel, version 5.3.6
I found that only dest port was converted to host short to do hash
why don't convert saddr, sport, daddr to host long or host short either ?


code as follows, in linux-5.3.6/include/net/inet_hashtables.h:
static inline struct sock *inet_lookup_listener(struct net *net,
struct inet_hashinfo *hashinfo,
struct sk_buff *skb, int doff,
__be32 saddr, __be16 sport,
__be32 daddr, __be16 dport, int dif, int sdif)
{
return __inet_lookup_listener(net, hashinfo, skb, doff, saddr, sport,
daddr, ntohs(dport), dif, sdif);
}

any help will be appreciated:D
 


Probably because most operations during the hashing process acts on a byte level, which makes the byte order not important for computation. However the dport is used as a math operator in a whole, which means the result of the computation will be different depending on the byte order.

Now why would it be useful to have consistents hash values across different endianess... Maybe its a legacy from systems that can work with multiple endianess ? Or usefull for testing purpose ?
 
Probably because most operations during the hashing process acts on a byte level, which makes the byte order not important for computation. However the dport is used as a math operator in a whole, which means the result of the computation will be different depending on the byte order.

Now why would it be useful to have consistents hash values across different endianess... Maybe its a legacy from systems that can work with multiple endianess ? Or usefull for testing purpose ?

thx JulienCC
 
thx JulienCC
thanks JulienCC
but saddr,sport,daddr also have byte order problem, didn't see where coverting them to host byte order. since saddr and daddr come from ip header, sport and dport come from tcp header. and use the m to do hash process soon.
 

Members online


Top