aboutgitcodebugslistschat
path: root/udp_internal.h
diff options
context:
space:
mode:
authorLaurent Vivier <lvivier@redhat.com>2024-11-22 17:43:31 +0100
committerStefano Brivio <sbrivio@redhat.com>2024-11-27 16:12:21 +0100
commit5a8b33c667d4468e82c4d50e81da06c0e681761e (patch)
tree9c1af635ea6a5f1d29b45458088098d66f1fac86 /udp_internal.h
parent31117b27c6c905a6bf5fb2567f30fa2f9e0fb3cd (diff)
downloadpasst-5a8b33c667d4468e82c4d50e81da06c0e681761e.tar
passt-5a8b33c667d4468e82c4d50e81da06c0e681761e.tar.gz
passt-5a8b33c667d4468e82c4d50e81da06c0e681761e.tar.bz2
passt-5a8b33c667d4468e82c4d50e81da06c0e681761e.tar.lz
passt-5a8b33c667d4468e82c4d50e81da06c0e681761e.tar.xz
passt-5a8b33c667d4468e82c4d50e81da06c0e681761e.tar.zst
passt-5a8b33c667d4468e82c4d50e81da06c0e681761e.zip
udp: Prepare udp.c to be shared with vhost-user
Export udp_payload_t, udp_update_hdr4(), udp_update_hdr6() and udp_sock_errs(). Rename udp_listen_sock_handler() to udp_buf_listen_sock_handler() and udp_reply_sock_handler to udp_buf_reply_sock_handler(). Signed-off-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'udp_internal.h')
-rw-r--r--udp_internal.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/udp_internal.h b/udp_internal.h
new file mode 100644
index 0000000..cc80e30
--- /dev/null
+++ b/udp_internal.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright (c) 2021 Red Hat GmbH
+ * Author: Stefano Brivio <sbrivio@redhat.com>
+ */
+
+#ifndef UDP_INTERNAL_H
+#define UDP_INTERNAL_H
+
+#include "tap.h" /* needed by udp_meta_t */
+
+#define UDP_MAX_FRAMES 32 /* max # of frames to receive at once */
+
+/**
+ * struct udp_payload_t - UDP header and data for inbound messages
+ * @uh: UDP header
+ * @data: UDP data
+ */
+struct udp_payload_t {
+ struct udphdr uh;
+ char data[USHRT_MAX - sizeof(struct udphdr)];
+#ifdef __AVX2__
+} __attribute__ ((packed, aligned(32)));
+#else
+} __attribute__ ((packed, aligned(__alignof__(unsigned int))));
+#endif
+
+size_t udp_update_hdr4(struct iphdr *ip4h, struct udp_payload_t *bp,
+ const struct flowside *toside, size_t dlen,
+ bool no_udp_csum);
+size_t udp_update_hdr6(struct ipv6hdr *ip6h, struct udp_payload_t *bp,
+ const struct flowside *toside, size_t dlen,
+ bool no_udp_csum);
+int udp_sock_errs(const struct ctx *c, int s, uint32_t events);
+#endif /* UDP_INTERNAL_H */