public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH 1/9] epoll: Generalize epoll_ref to cover things other than sockets
Date: Thu, 10 Aug 2023 10:23:14 +1000	[thread overview]
Message-ID: <ZNQt8lrDsnZjoESh@zatzit> (raw)
In-Reply-To: <20230809215743.22102e88@elisabeth>

[-- Attachment #1: Type: text/plain, Size: 2959 bytes --]

On Wed, Aug 09, 2023 at 09:59:10PM +0200, Stefano Brivio wrote:
> On Mon,  7 Aug 2023 23:46:23 +1000
> David Gibson <david@gibson.dropbear.id.au> wrote:
> 
> > The epoll_ref type includes fields for the IP protocol of a socket, and the
> > socket fd.  However, we already have a few things in the epoll which aren't
> > protocol sockets, and we may have more in future.  Rename these fields to
> > an abstract "fd type" and file descriptor for more generality.
> > 
> > Similarly, rather than using existing IP protocol numbers for the type,
> > introduce our own number space.  For now these just correspond to the
> > supported protocols, but we'll expand on that in future.
> > 
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
> >  icmp.c       |  6 +++---
> >  passt.c      | 25 ++++++++++++-------------
> >  passt.h      | 40 +++++++++++++++++++++++++++++-----------
> >  tcp.c        | 22 +++++++++++-----------
> >  tcp_conn.h   |  4 ++--
> >  tcp_splice.c |  4 ++--
> >  udp.c        | 14 +++++++-------
> >  util.c       | 27 ++++++++++++++++++++-------
> >  8 files changed, 86 insertions(+), 56 deletions(-)
> > 
> > diff --git a/icmp.c b/icmp.c
> > index 676fa64..a4b6a47 100644
> > --- a/icmp.c
> > +++ b/icmp.c
> > @@ -79,7 +79,7 @@ void icmp_sock_handler(const struct ctx *c, union epoll_ref ref,
> >  	(void)events;
> >  	(void)now;
> >  
> > -	n = recvfrom(ref.s, buf, sizeof(buf), 0, (struct sockaddr *)&sr, &sl);
> > +	n = recvfrom(ref.fd, buf, sizeof(buf), 0, (struct sockaddr *)&sr, &sl);
> >  	if (n < 0)
> >  		return;
> >  
> > @@ -182,7 +182,7 @@ int icmp_tap_handler(const struct ctx *c, int af, const void *addr,
> >  				    bind_if, id, iref.u32);
> >  			if (s < 0)
> >  				goto fail_sock;
> > -			if (s > SOCKET_MAX) {
> > +			if (s > FD_REF_MAX) {
> >  				close(s);
> >  				return 1;
> >  			}
> > @@ -236,7 +236,7 @@ int icmp_tap_handler(const struct ctx *c, int af, const void *addr,
> >  				    bind_if, id, iref.u32);
> >  			if (s < 0)
> >  				goto fail_sock;
> > -			if (s > SOCKET_MAX) {
> > +			if (s > FD_REF_MAX) {
> >  				close(s);
> >  				return 1;
> >  			}
> > diff --git a/passt.c b/passt.c
> > index 9123868..b42f42d 100644
> > --- a/passt.c
> > +++ b/passt.c
> > @@ -55,12 +55,11 @@
> >  
> >  char pkt_buf[PKT_BUF_BYTES]	__attribute__ ((aligned(PAGE_SIZE)));
> >  
> > -char *ip_proto_str[IPPROTO_SCTP + 1] = {
> > -	[IPPROTO_ICMP]		= "ICMP",
> > -	[IPPROTO_TCP]		= "TCP",
> > -	[IPPROTO_UDP]		= "UDP",
> > -	[IPPROTO_ICMPV6]	= "ICMPV6",
> > -	[IPPROTO_SCTP]		= "SCTP",
> > +char *epoll_type_str[EPOLL_TYPE_MAX+1] = {
> 
> For consistency, given you're respinning anyway: [EPOLL_TYPE_MAX + 1]

Done, thanks.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2023-08-10  2:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-07 13:46 [PATCH 0/9] Clean up to epoll dispatch David Gibson
2023-08-07 13:46 ` [PATCH 1/9] epoll: Generalize epoll_ref to cover things other than sockets David Gibson
2023-08-09 19:59   ` Stefano Brivio
2023-08-10  0:23     ` David Gibson [this message]
2023-08-07 13:46 ` [PATCH 2/9] epoll: Always use epoll_ref for the epoll data variable David Gibson
2023-08-07 13:46 ` [PATCH 3/9] epoll: Fold sock_handler into general switch on epoll event fd David Gibson
2023-08-07 13:46 ` [PATCH 4/9] epoll: Split handling of ICMP and ICMPv6 sockets David Gibson
2023-08-07 13:46 ` [PATCH 5/9] epoll: Tiny cleanup to udp_sock_handler() David Gibson
2023-08-07 13:46 ` [PATCH 6/9] epoll: Split handling of TCP timerfds into its own handler function David Gibson
2023-08-07 13:46 ` [PATCH 7/9] epoll: Split handling of listening TCP sockets into their own handler David Gibson
2023-08-09  6:29   ` David Gibson
2023-08-07 13:46 ` [PATCH 8/9] epoll: Split listening Unix domain socket into its own type David Gibson
2023-08-09 19:59   ` Stefano Brivio
2023-08-10  1:08     ` David Gibson
2023-08-10  7:50       ` Stefano Brivio
2023-08-11  3:17         ` David Gibson
2023-08-07 13:46 ` [PATCH 9/9] epoll: Use different epoll types for passt and pasta tap fds David Gibson

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=ZNQt8lrDsnZjoESh@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@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.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

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 IMAP folder(s).