public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
blob cb2cf62e3f754d3c710bb804d4fc63337e35bc52 2089 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
 
/* 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 <stdint.h>
#include <unistd.h>
#include <string.h>

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

const char *flow_type_str[] = {
	[FLOW_TYPE_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 %u (%p)",
		      FLOW_IDX(hole), (void *)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 %u, new index %u, "
	      "from: %p, to: %p",
	      FLOW_TYPE(&from->f), FLOW_IDX(from), FLOW_IDX(hole),
	      (void *)from, (void *)hole);

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

/** flow_log_ - Log flow-related message
 * @f:		flow the message is related to
 * @pri:	Log priority
 * @fmt:	Format string
 * @...:	printf-arguments
 *
 * @fmt must include an initial "%s" to expand to the prefix we generate
 * (typically added by the flow_log() macro).
 */
void flow_log_(const struct flow_common *f, int pri, const char *fmt, ...)
{
	char msg[BUFSIZ];
	va_list args;

	va_start(args, fmt);
	(void)vsnprintf(msg, sizeof(msg), fmt, args);
	va_end(args);

	logmsg(pri, "Flow %u (%s): %s", flow_idx(f), FLOW_TYPE(f), msg);
}

debug log:

solving cb2cf62 ...
found cb2cf62 in https://archives.passt.top/passt-dev/20231123023629.2024938-7-david@gibson.dropbear.id.au/
found 0fff119 in https://archives.passt.top/passt-dev/20231123023629.2024938-6-david@gibson.dropbear.id.au/ ||
	https://archives.passt.top/passt-dev/20231126233348.1599864-6-david@gibson.dropbear.id.au/
found a9bb8f5 in https://archives.passt.top/passt-dev/20231123023629.2024938-4-david@gibson.dropbear.id.au/ ||
	https://archives.passt.top/passt-dev/20231126233348.1599864-3-david@gibson.dropbear.id.au/
found 7c3603c in https://archives.passt.top/passt-dev/20231123023629.2024938-3-david@gibson.dropbear.id.au/ ||
	https://archives.passt.top/passt-dev/20231126233348.1599864-2-david@gibson.dropbear.id.au/

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

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

skipping https://archives.passt.top/passt-dev/20231126233348.1599864-2-david@gibson.dropbear.id.au/ for 7c3603c
index at:
100644 7c3603c435f874446739746f4252fc8d2d8c9d92	flow.c

applying [2/4] https://archives.passt.top/passt-dev/20231123023629.2024938-4-david@gibson.dropbear.id.au/
diff --git a/flow.c b/flow.c
index 7c3603c..a9bb8f5 100644

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

skipping https://archives.passt.top/passt-dev/20231126233348.1599864-3-david@gibson.dropbear.id.au/ for a9bb8f5
index at:
100644 a9bb8f52816fb13f4337916f9ed8b112a7f99170	flow.c

applying [3/4] https://archives.passt.top/passt-dev/20231123023629.2024938-6-david@gibson.dropbear.id.au/
diff --git a/flow.c b/flow.c
index a9bb8f5..0fff119 100644

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

skipping https://archives.passt.top/passt-dev/20231126233348.1599864-6-david@gibson.dropbear.id.au/ for 0fff119
index at:
100644 0fff119f28fc2ee8f1752208e8554a31a4ca6684	flow.c

applying [4/4] https://archives.passt.top/passt-dev/20231123023629.2024938-7-david@gibson.dropbear.id.au/
diff --git a/flow.c b/flow.c
index 0fff119..cb2cf62 100644

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

index at:
100644 cb2cf62e3f754d3c710bb804d4fc63337e35bc52	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).