public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
3464b74df85884a4112c992951c2e92ee23f12a6 blob 2552 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
 
/* SPDX-License-Identifier: GPL-2.0-or-later
 * Copyright (c) 2021 Red Hat GmbH
 * Author: Stefano Brivio <sbrivio@redhat.com>
 */

#ifndef UDP_H
#define UDP_H

#include <stdint.h>
#include <netinet/in.h>
#include <netinet/udp.h>
#include <linux/virtio_net.h>

#include "tap_hdr.h"
#include "fwd.h"

/**
 * 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

#define UDP_MAX_FRAMES		32  /* max # of frames to receive at once */

/* UDP header and data for inbound messages */
extern struct udp_payload_t udp_payload[UDP_MAX_FRAMES];

/* Ethernet headers for IPv4 and IPv6 frames */
extern struct ethhdr udp_eth_hdr[UDP_MAX_FRAMES];

/* IOVs and msghdr arrays for receiving datagrams from sockets */
extern struct iovec	udp_iov_recv		[UDP_MAX_FRAMES];
extern struct mmsghdr	udp_mh_recv		[UDP_MAX_FRAMES];


/**
 * struct udp_meta_t - Pre-cooked headers for UDP packets
 * @ip6h:	Pre-filled IPv6 header (except for payload_len and addresses)
 * @ip4h:	Pre-filled IPv4 header (except for tot_len and saddr)
 * @taph:	Tap backend specific header
 */
struct udp_meta_t {
	struct ipv6hdr ip6h;
	struct iphdr ip4h;
	union {
		struct virtio_net_hdr_mrg_rxbuf vnet_hdr;
		struct tap_hdr taph;
};
#ifdef __AVX2__
} __attribute__((aligned(32)));
#else
};
#endif

/* Pre-cooked headers for UDP packets */
extern struct udp_meta_t udp_meta[UDP_MAX_FRAMES];


void udp_listen_sock_handler(const struct ctx *c, union epoll_ref ref,
			     uint32_t events, const struct timespec *now);
void udp_sock_handler(const struct ctx *c, union epoll_ref ref,
		      uint32_t events, const struct timespec *now);
int udp_tap_handler(const struct ctx *c, uint8_t pif,
		    sa_family_t af, const void *saddr, const void *daddr,
		    uint8_t ttl, const struct pool *p, int idx,
		    const struct timespec *now);
int udp_init(struct ctx *c);
void udp_update_l2_buf(const unsigned char *eth_d);

/**
 * struct udp_ctx - Execution context for UDP
 * @scan_in:		Port scanning state for inbound packets
 * @scan_out:		Port scanning state for outbound packets
 * @timeout:		Timeout for unidirectional flows (in s)
 * @stream_timeout:	Timeout for stream-like flows (in s)
 */
struct udp_ctx {
	struct fwd_scan scan_in;
	struct fwd_scan scan_out;
	int timeout;
	int stream_timeout;
};

#endif /* UDP_H */
debug log:

solving 3464b74 ...
found 3464b74 in https://archives.passt.top/passt-dev/20260802132155.870796-8-aerosound161@gmail.com/
found b7a367c in https://archives.passt.top/passt-dev/20260802132155.870796-3-aerosound161@gmail.com/
found b50283e in https://passt.top/passt
preparing index
index prepared:
100644 b50283eab1989fa76bd3cd66bd42aeac59b48e02	udp.h

applying [1/2] https://archives.passt.top/passt-dev/20260802132155.870796-3-aerosound161@gmail.com/
diff --git a/udp.h b/udp.h
index b50283e..b7a367c 100644


applying [2/2] https://archives.passt.top/passt-dev/20260802132155.870796-8-aerosound161@gmail.com/
diff --git a/udp.h b/udp.h
index b7a367c..3464b74 100644

Checking patch udp.h...
Applied patch udp.h cleanly.
Checking patch udp.h...
Applied patch udp.h cleanly.

index at:
100644 3464b74df85884a4112c992951c2e92ee23f12a6	udp.h

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).