public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
blob 12ca8dbc44eb99127dfdc529a90fd85227f90d89 1473 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
 
/* SPDX-License-Identifier: GPL-2.0-or-later
 * Copyright Red Hat
 * Author: David Gibson <david@gibson.dropbear.id.au>
 *
 * Tracking for logical "flows" of packets.
 */

#include <unistd.h>
#include <string.h>

#include "util.h"
#include "passt.h"
#include "inany.h"
#include "flow.h"
#include "tcp_conn.h"
#include "flow_table.h"

const char *flow_type_str[] = {
	[FLOW_NONE]		= "<none>",
	[FLOW_TCP]		= "TCP connection",
	[FLOW_TCP_SPLICE]	= "TCP connection (spliced)",
};

/* Global Flow Table */
union flow flowtab[FLOW_MAX];

/**
 * flow_table_compact() - Perform compaction on flow table
 * @c:		Execution context
 * @hole:	Pointer to recently closed flow
 */
void flow_table_compact(struct ctx *c, union flow *hole)
{
	union flow *from;

	if (FLOW_IDX(hole) == --c->flow_count) {
		debug("flow: table compaction: maximum index was %li (%p)",
		      FLOW_IDX(hole), hole);
		memset(hole, 0, sizeof(*hole));
		return;
	}

	from = flowtab + c->flow_count;
	memcpy(hole, from, sizeof(*hole));

	switch (from->f.type) {
	case FLOW_TCP:
		tcp_tap_conn_update(c, &from->tcp, &hole->tcp);
		break;
	case FLOW_TCP_SPLICE:
		tcp_splice_conn_update(c, &hole->tcp_splice);
		break;
	default:
		die("Unexpected %s in tcp_table_compact()",
		    FLOW_TYPE(&from->f));
	}

	debug("flow: table compaction (%s): old index %li, new index %li, "
	      "from: %p, to: %p",
	      FLOW_TYPE(&from->f), FLOW_IDX(from), FLOW_IDX(hole), from, hole);

	memset(from, 0, sizeof(*from));
}

debug log:

solving 12ca8db ...
found 12ca8db in https://archives.passt.top/passt-dev/20230828054146.48673-5-david@gibson.dropbear.id.au/
found 864158a in https://archives.passt.top/passt-dev/20230828054146.48673-3-david@gibson.dropbear.id.au/
found c3802ce in https://archives.passt.top/passt-dev/20230828054146.48673-2-david@gibson.dropbear.id.au/

applying [1/3] https://archives.passt.top/passt-dev/20230828054146.48673-2-david@gibson.dropbear.id.au/
diff --git a/flow.c b/flow.c
new file mode 100644
index 0000000..c3802ce


applying [2/3] https://archives.passt.top/passt-dev/20230828054146.48673-3-david@gibson.dropbear.id.au/
diff --git a/flow.c b/flow.c
index c3802ce..864158a 100644


applying [3/3] https://archives.passt.top/passt-dev/20230828054146.48673-5-david@gibson.dropbear.id.au/
diff --git a/flow.c b/flow.c
index 864158a..12ca8db 100644

Checking patch flow.c...
Applied patch flow.c cleanly.
Checking patch flow.c...
Applied patch flow.c cleanly.
Checking patch flow.c...
Applied patch flow.c cleanly.

index at:
100644 12ca8dbc44eb99127dfdc529a90fd85227f90d89	flow.c

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