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>, passt-dev@passt.top
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 2/4] pif: Introduce notion of passt/pasta interface
Date: Mon,  9 Oct 2023 19:30:11 +1100	[thread overview]
Message-ID: <20231009083013.2837178-3-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20231009083013.2837178-1-david@gibson.dropbear.id.au>

We have several possible ways of communicating with other entities.  We use
sockets to communicate with the host and other network sites, but also in
a different context to communicate "spliced" channels to a namespace.  We
also use a tuntap device or a qemu socket to communicate with the namespace
or guest.

For the time being these are just defined implicitly by how we structure
things.  However, there are other communication channels we want to use in
future (e.g. virtio-user), and we want to allow more flexible forwarding
between those.  To accomplish that we're going to want a specific way of
referring to those channels.

Introduce the concept of a "passt/pasta interface" or "pif" representing a
specific channel to communicate network data.  Each pif is assumed to be
associated with a specific network namespace in the broad sense (that is
as a place where IP addresses have a consistent meaning - not the Linux
specific sense).  But there could be multiple pifs communicating with the
same namespace (e.g. the spliced and tap interfaces in pasta).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 Makefile |  2 +-
 pif.h    | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 pif.h

diff --git a/Makefile b/Makefile
index 0324fdd..55972b1 100644
--- a/Makefile
+++ b/Makefile
@@ -53,7 +53,7 @@ MANPAGES = passt.1 pasta.1 qrap.1
 
 PASST_HEADERS = arch.h arp.h checksum.h conf.h dhcp.h dhcpv6.h icmp.h \
 	inany.h isolation.h lineread.h log.h ndp.h netlink.h packet.h passt.h \
-	pasta.h pcap.h port_fwd.h siphash.h tap.h tcp.h tcp_conn.h \
+	pasta.h pcap.h pif.h port_fwd.h siphash.h tap.h tcp.h tcp_conn.h \
 	tcp_splice.h udp.h util.h
 HEADERS = $(PASST_HEADERS) seccomp.h
 
diff --git a/pif.h b/pif.h
new file mode 100644
index 0000000..edd4fee
--- /dev/null
+++ b/pif.h
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright Red Hat
+ * Author: David Gibson <david@gibson.dropbear.id.au>
+ *
+ * Passt/pasta interface types and IDs
+ */
+#ifndef PIF_H
+#define PIF_H
+
+/**
+ * enum pif_type - Type of passt/pasta interface ("pif")
+ *
+ * Pifs can be an L4 level channel (sockets) or an L2 level channel (tap device
+ * or qemu socket).
+ */
+enum pif_type {
+	/* Invalid or not present pif */
+	PIF_NONE = 0,
+	/* Host socket interface */
+	PIF_HOST,
+	/* Qemu socket or namespace tuntap interface */
+	PIF_TAP,
+	/* Namespace socket interface for splicing */
+	PIF_SPLICE,
+};
+	
+/**
+ * pif_id - Index for passt/pasta interface ("pif")
+ *
+ * This represents a specific instance of an interface.  For now, we don't have
+ * multiple instances of the same type, so we use the same values as for
+ * pif_type here.  That might change in future.
+ */
+typedef uint8_t pif_id;
+
+#endif /* PIF_H */
-- 
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright Red Hat
+ * Author: David Gibson <david@gibson.dropbear.id.au>
+ *
+ * Passt/pasta interface types and IDs
+ */
+#ifndef PIF_H
+#define PIF_H
+
+/**
+ * enum pif_type - Type of passt/pasta interface ("pif")
+ *
+ * Pifs can be an L4 level channel (sockets) or an L2 level channel (tap device
+ * or qemu socket).
+ */
+enum pif_type {
+	/* Invalid or not present pif */
+	PIF_NONE = 0,
+	/* Host socket interface */
+	PIF_HOST,
+	/* Qemu socket or namespace tuntap interface */
+	PIF_TAP,
+	/* Namespace socket interface for splicing */
+	PIF_SPLICE,
+};
+	
+/**
+ * pif_id - Index for passt/pasta interface ("pif")
+ *
+ * This represents a specific instance of an interface.  For now, we don't have
+ * multiple instances of the same type, so we use the same values as for
+ * pif_type here.  That might change in future.
+ */
+typedef uint8_t pif_id;
+
+#endif /* PIF_H */
-- 
2.41.0


  parent reply	other threads:[~2023-10-09  8:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-09  8:30 [PATCH 0/4] Passt Interface Identifiers David Gibson
2023-10-09  8:30 ` [PATCH 1/4] udp: Clean up ref initialisation in udp_sock_init() David Gibson
2023-10-09  8:30 ` David Gibson [this message]
2023-10-09  8:30 ` [PATCH 3/4] pif: Record originating pif in listening socket refs David Gibson
2023-11-03  9:47   ` Stefano Brivio
2023-11-04  2:03     ` David Gibson
2023-10-09  8:30 ` [PATCH 4/4] pif: Pass originating pif to tap handler functions 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=20231009083013.2837178-3-david@gibson.dropbear.id.au \
    --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).