diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2024-06-14 11:51:07 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2024-06-14 12:11:42 +0200 |
commit | ff57f8ddc6e5cfbc5d82e7d3f401bed8f30cd608 (patch) | |
tree | e24046db6b74ded6bc6004959d6e7fb0e0272b7b /tap.c | |
parent | 63db7dcdbf4f8d528a6c04f73c338a686ad8a5fe (diff) | |
download | passt-ff57f8ddc6e5cfbc5d82e7d3f401bed8f30cd608.tar passt-ff57f8ddc6e5cfbc5d82e7d3f401bed8f30cd608.tar.gz passt-ff57f8ddc6e5cfbc5d82e7d3f401bed8f30cd608.tar.bz2 passt-ff57f8ddc6e5cfbc5d82e7d3f401bed8f30cd608.tar.lz passt-ff57f8ddc6e5cfbc5d82e7d3f401bed8f30cd608.tar.xz passt-ff57f8ddc6e5cfbc5d82e7d3f401bed8f30cd608.tar.zst passt-ff57f8ddc6e5cfbc5d82e7d3f401bed8f30cd608.zip |
udp: Rework how we divide queued datagrams between sending methods
udp_sock_handler() takes a number of datagrams from sockets that depending
on their addresses could be forwarded either to the L2 interface ("tap")
or to another socket ("spliced"). In the latter case we can also only
send packets together if they have the same source port, and therefore
are sent via the same socket.
To reduce the total number of system calls we gather contiguous batches of
datagrams with the same destination interface and socket where applicable.
The determination of what the target is is made by udp_mmh_splice_port().
It returns the source port for splice packets and -1 for "tap" packets.
We find batches by looking ahead in our queue until we find a datagram
whose "splicefrom" port doesn't match the first in our current batch.
udp_mmh_splice_port() is moderately expensive, and unfortunately we
can call it twice on the same datagram: once as the (last + 1) entry
in one batch (to check it's not in that batch), then again as the
first entry in the next batch.
Avoid this by keeping track of the "splice port" in the metadata structure,
and filling it in one entry ahead of the one we're currently considering.
This is a bit subtle, but not that hard. It will also generalise better
when we have more complex possibilities based on the flow table.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tap.c')
0 files changed, 0 insertions, 0 deletions