netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Johnston <matt@codeconstruct.com.au>
To: Paolo Abeni <pabeni@redhat.com>,
	Jeremy Kerr <jk@codeconstruct.com.au>,
	 "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Simon Horman <horms@kernel.org>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net-next v4 5/8] net: mctp: Use hashtable for binds
Date: Tue, 15 Jul 2025 19:08:03 +0800	[thread overview]
Message-ID: <cd1d3ba89ef2c038b82968dff3c9c3de9843c0e2.camel@codeconstruct.com.au> (raw)
In-Reply-To: <151b85fe-72a2-4eb4-9aef-4e3b13b1c8ff@redhat.com>

Hi Paolo,

Thanks for the review.

On Tue, 2025-07-15 at 12:05 +0200, Paolo Abeni wrote:
...
> >  	struct mutex bind_lock;
> > -	struct hlist_head binds;
> > +	DECLARE_HASHTABLE(binds, MCTP_BINDS_BITS);
> 
> Note that I comment on patch 2/8 before actually looking at this patch.

I guess even with a hash table there's theoretical scope for someone
to fill a hash bucket (via clever timing measurement perhaps). Currently MCTP
requires CAP_NET_BIND_SERVICE for any binds, so the risk there is limited.

> As a possible follow-up I suggest a dynamically allocating the hash
> table at first bind time.

*nod* I'll take a look at that.


> > ...
> > +	/* Look for binds in order of widening scope. A given destination or
> > +	 * source address also implies matching on a particular network.
> > +	 *
> > +	 * - Matching destination and source
> > +	 * - Matching destination
> > +	 * - Matching source
> > +	 * - Matching network, any address
> > +	 * - Any network or address
> > +	 */
> 
> Note for a possible follow-up: a more idiomatic approach uses a
> compute_score() function that respect the above priority and require a
> single hash traversal, see, i.e. net/ipv4/udp.c

Thanks for the pointer, I'll see if something like that would work.

Cheers,
Matt

  reply	other threads:[~2025-07-15 11:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-10  8:55 [PATCH net-next v4 0/8] net: mctp: Improved bind handling Matt Johnston
2025-07-10  8:55 ` [PATCH net-next v4 1/8] net: mctp: mctp_test_route_extaddr_input cleanup Matt Johnston
2025-07-10  8:55 ` [PATCH net-next v4 2/8] net: mctp: Prevent duplicate binds Matt Johnston
2025-07-15  9:50   ` Paolo Abeni
2025-07-10  8:55 ` [PATCH net-next v4 3/8] net: mctp: Treat MCTP_NET_ANY specially in bind() Matt Johnston
2025-07-10  8:55 ` [PATCH net-next v4 4/8] net: mctp: Add test for conflicting bind()s Matt Johnston
2025-07-10  8:55 ` [PATCH net-next v4 5/8] net: mctp: Use hashtable for binds Matt Johnston
2025-07-15 10:05   ` Paolo Abeni
2025-07-15 11:08     ` Matt Johnston [this message]
2025-07-10  8:55 ` [PATCH net-next v4 6/8] net: mctp: Allow limiting binds to a peer address Matt Johnston
2025-07-10  8:56 ` [PATCH net-next v4 7/8] net: mctp: Test conflicts of connect() with bind() Matt Johnston
2025-07-10  8:56 ` [PATCH net-next v4 8/8] net: mctp: Add bind lookup test Matt Johnston
2025-07-15 10:20 ` [PATCH net-next v4 0/8] net: mctp: Improved bind handling patchwork-bot+netdevbpf

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=cd1d3ba89ef2c038b82968dff3c9c3de9843c0e2.camel@codeconstruct.com.au \
    --to=matt@codeconstruct.com.au \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jk@codeconstruct.com.au \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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;
as well as URLs for NNTP newsgroup(s).