All of lore.kernel.org
 help / color / mirror / Atom feed
* nfqueue hashing on TCP/UDP port
@ 2021-06-15  0:42 Jake Owen
  2021-06-15 13:06 ` Florian Westphal
  0 siblings, 1 reply; 3+ messages in thread
From: Jake Owen @ 2021-06-15  0:42 UTC (permalink / raw)
  To: netfilter-devel

Hello!

tl;dr Is there a technical reason why nfqueue balance as implemented
does not use TCP/UDP ports as well as source/destination IP addresses?

We've been having trouble with the queue hashing algorithm used by
iptable's `--queue-balance` for traffic generated on-box (e.g. by a
squid proxy) where a large percentage of traffic would be TCP, source
IP of the proxy, and one google/microsoft/apple destination IP. This
is made worse if the random seed causes two or more of these high
traffic services to hash to the same queue. We are working on
preserving the original client IP as the source IP to provide
sufficient randomness to balance accurately, but in the meantime have
wondered if balancing by port was not implemented because it was
deemed unnecessary, or because of some technical reason which escapes
me.

I've been able to write a kernel patch which hashes based on protocol,
IP and port for the CentOS 7 kernel we have in production which
_appears_ to be stable. Is there an existing test harness I can use to
validate this implementation? I'm willing to propose a solution for
the latest 5.x kernel if other people think that this is a valid
solution/use case.

Kind Regards,
Jake Owen

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: nfqueue hashing on TCP/UDP port
  2021-06-15  0:42 nfqueue hashing on TCP/UDP port Jake Owen
@ 2021-06-15 13:06 ` Florian Westphal
  2021-06-15 22:58   ` Jake Owen
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Westphal @ 2021-06-15 13:06 UTC (permalink / raw)
  To: Jake Owen; +Cc: netfilter-devel

Jake Owen <jake.owen@superloop.com> wrote:
> Hello!
> 
> tl;dr Is there a technical reason why nfqueue balance as implemented
> does not use TCP/UDP ports as well as source/destination IP addresses?

To keep host-to-host comunication on the same queue, for ftp, sip and
other highlevel protocols where a logical connection consists of
multiple tcp/udp flows.

> We've been having trouble with the queue hashing algorithm used by
> iptable's `--queue-balance` for traffic generated on-box (e.g. by a
> squid proxy) where a large percentage of traffic would be TCP, source
> IP of the proxy, and one google/microsoft/apple destination IP. This
> is made worse if the random seed causes two or more of these high
> traffic services to hash to the same queue. We are working on
> preserving the original client IP as the source IP to provide
> sufficient randomness to balance accurately, but in the meantime have
> wondered if balancing by port was not implemented because it was
> deemed unnecessary, or because of some technical reason which escapes
> me.

The latter.  I will add arbitrary hash keying to nft, its currently
only missing from the frontend.

Will put you in CC when its done.

> I'm willing to propose a solution for
> the latest 5.x kernel if other people think that this is a valid
> solution/use case.

With nft this will soon be possible:

queue num jhash ip daddr . tcp sport . tcp dport mod 16

... which will queue to 0-15.

I don't think we need code changes to the xtables backend.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: nfqueue hashing on TCP/UDP port
  2021-06-15 13:06 ` Florian Westphal
@ 2021-06-15 22:58   ` Jake Owen
  0 siblings, 0 replies; 3+ messages in thread
From: Jake Owen @ 2021-06-15 22:58 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netfilter-devel

Thank you Florian. I appreciate your thoughtful reply.

> To keep host-to-host comunication on the same queue, for ftp, sip and
> other highlevel protocols where a logical connection consists of
> multiple tcp/udp flows.

That does make a lot of sense.

> I will add arbitrary hash keying to nft, its currently
> only missing from the frontend.
>
> Will put you in CC when its done.

Thank you!

> With nft this will soon be possible:
>
> queue num jhash ip daddr . tcp sport . tcp dport mod 16
>
> ... which will queue to 0-15.
>
> I don't think we need code changes to the xtables backend.

That amount of flexibility looks wonderful.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-15 22:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-15  0:42 nfqueue hashing on TCP/UDP port Jake Owen
2021-06-15 13:06 ` Florian Westphal
2021-06-15 22:58   ` Jake Owen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.