History

net: psample: allow using rate as probability

Although not explicitly documented in the psample module itself, the definition of PSAMPLE_ATTR_SAMPLE_RATE seems inherited from act_sample. Quoting tc-sample(8): "RATE of 100 will lead to an average of one sampled packet out of every 100 observed." With this semantics, the rates that we can express with an unsigned 32-bits number are very unevenly distributed and concentrated towards "sampling few packets". For example, we can express a probability of 2.32E-8% but we cannot express anything between 100% and 50%. For sampling applications that are capable of sampling a decent amount of packets, this sampling rate semantics is not very useful. Add a new flag to the uAPI that indicates that the sampling rate is expressed in scaled probability, this is: - 0 is 0% probability, no packets get sampled. - U32_MAX is 100% probability, all packets get sampled.

Adrian Moreno committed 2 years ago

Commit 7b1b2b61 parent c35d86a3 files · +14 −2Browse files

Showing the changes to include/uapi (1 of 3 files). Show all

Unified · Split

include/uapi/linux/psample.h+9−1
@@ -8,7 +8,11 @@ enum { · 7 unmodified lines
88 PSAMPLE_ATTR_ORIGSIZE,
99 PSAMPLE_ATTR_SAMPLE_GROUP,
1010 PSAMPLE_ATTR_GROUP_SEQ,
11− PSAMPLE_ATTR_SAMPLE_RATE,
11+ PSAMPLE_ATTR_SAMPLE_RATE, /* u32, ratio between observed and
12+ * sampled packets or scaled probability
13+ * if PSAMPLE_ATTR_SAMPLE_PROBABILITY
14+ * is set.
15+ */
1216 PSAMPLE_ATTR_DATA,
1317 PSAMPLE_ATTR_GROUP_REFCOUNT,
1418 PSAMPLE_ATTR_TUNNEL,
@@ -20,6 +24,10 @@ enum { · 5 unmodified lines
2024 PSAMPLE_ATTR_TIMESTAMP, /* u64, nanoseconds */
2125 PSAMPLE_ATTR_PROTO, /* u16 */
2226 PSAMPLE_ATTR_USER_COOKIE, /* binary, user provided data */
27+ PSAMPLE_ATTR_SAMPLE_PROBABILITY,/* no argument, interpret rate in
28+ * PSAMPLE_ATTR_SAMPLE_RATE as a
29+ * probability scaled 0 - U32_MAX.
30+ */
2331
2432 __PSAMPLE_ATTR_MAX
2533 };

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t