The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Philo Lu <lulie@linux.alibaba.com>
To: Gur Stavi <gur.stavi@huawei.com>
Cc: antony.antony@secunet.com, davem@davemloft.net,
	dsahern@kernel.org, dust.li@linux.alibaba.com,
	edumazet@google.com, fred.cc@alibaba-inc.com,
	jakub@cloudflare.com, kuba@kernel.org,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	pabeni@redhat.com, steffen.klassert@secunet.com,
	willemdebruijn.kernel@gmail.com,
	yubing.qiuyubing@alibaba-inc.com
Subject: Re: [RFC PATCHv2 net-next 1/3] net/udp: Add a new struct for hash2 slot
Date: Wed, 25 Sep 2024 10:57:25 +0800	[thread overview]
Message-ID: <7fdfc76d-cf7d-47f3-afcf-c963c44f01b7@linux.alibaba.com> (raw)
In-Reply-To: <20240924125101.1688823-1-gur.stavi@huawei.com>


On 2024/9/24 20:51, Gur Stavi wrote:
>> @@ -224,13 +224,12 @@ struct sock *__udp6_lib_lookup(const struct net *net,
>>   			       struct sk_buff *skb)
>>   {
>>   	unsigned short hnum = ntohs(dport);
>> -	unsigned int hash2, slot2;
>>   	struct udp_hslot *hslot2;
>>   	struct sock *result, *sk;
>> +	unsigned int hash2;
>>
>>   	hash2 = ipv6_portaddr_hash(net, daddr, hnum);
>> -	slot2 = hash2 & udptable->mask;
>> -	hslot2 = &udptable->hash2[slot2];
>> +	hslot2 = udp_hashslot2(udptable, hash2);
>>
> 
> Why not minimize the code change by using udptable->hash2[slot2].hslot?
> Especially since later you do it in __udp6_lib_mcast_deliver.
> I think that many developers would find usage of C primitives more
> readable.

Yes I can use udptable->hash2[slot2].hslot. But I prefer the 
udp_hashslot2() helper, because I found I have to add ".hslot" at many 
places, while most of them look exactly what udp_hashslot2() does. I 
think replacing them may get the codes simpler and benefit future coding.

Some places like __udp6_lib_mcast_deliver() get hslot2 differently from 
udp_hashslot2(), so just appending ".hslot" to avoid functionality change.

Thanks.
-- 
Philo


  reply	other threads:[~2024-09-25  2:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-24 11:04 [RFC PATCHv2 net-next 0/3] udp: Add 4-tuple hash for connected sockets Philo Lu
2024-09-24 11:04 ` [RFC PATCHv2 net-next 1/3] net/udp: Add a new struct for hash2 slot Philo Lu
2024-09-24 12:30   ` Gur Stavi
2024-09-25  2:43     ` Philo Lu
2024-09-24 12:51   ` Gur Stavi
2024-09-25  2:57     ` Philo Lu [this message]
2024-09-24 11:04 ` [RFC PATCHv2 net-next 2/3] net/udp: Add 4-tuple hash list basis Philo Lu
2024-09-24 11:04 ` [RFC PATCHv2 net-next 3/3] ipv4/udp: Add 4-tuple hash for connected socket Philo Lu
2024-09-24 12:31   ` Gur Stavi
2024-09-25  3:16     ` Philo Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7fdfc76d-cf7d-47f3-afcf-c963c44f01b7@linux.alibaba.com \
    --to=lulie@linux.alibaba.com \
    --cc=antony.antony@secunet.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=dust.li@linux.alibaba.com \
    --cc=edumazet@google.com \
    --cc=fred.cc@alibaba-inc.com \
    --cc=gur.stavi@huawei.com \
    --cc=jakub@cloudflare.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=steffen.klassert@secunet.com \
    --cc=willemdebruijn.kernel@gmail.com \
    --cc=yubing.qiuyubing@alibaba-inc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox