MCPcopy Create free account
hub / github.com/F-Stack/f-stack / tap_flow_set_handle

Function tap_flow_set_handle

dpdk/drivers/net/tap/tap_flow.c:1306–1327  ·  view source on GitHub ↗

* Set a unique handle in a flow. * * The kernel supports TC rules with equal priority, as long as they use the * same matching fields (e.g.: dst mac and ipv4) with different values (and * full mask to ensure no collision is possible). * In those rules, the handle (uint32_t) is the part that would identify * specifically each rule. * * Use jhash of the flow pointer to make a unique handle.

Source from the content-addressed store, hash-verified

1304 * The flow that needs its handle set.
1305 */
1306static void
1307tap_flow_set_handle(struct rte_flow *flow)
1308{
1309 union {
1310 struct rte_flow *flow;
1311 uint32_t words[sizeof(flow) / sizeof(uint32_t)];
1312 } tmp = {
1313 .flow = flow,
1314 };
1315 uint32_t handle;
1316 static uint64_t hash_seed;
1317
1318 if (hash_seed == 0)
1319 hash_seed = rte_rand();
1320
1321 handle = rte_jhash_32b(tmp.words, sizeof(flow) / sizeof(uint32_t), hash_seed);
1322
1323 /* must be at least 1 to avoid letting the kernel choose one for us */
1324 if (!handle)
1325 handle = 1;
1326 flow->msg.t.tcm_handle = handle;
1327}
1328
1329/**
1330 * Free the flow opened file descriptors and allocated memory

Callers 3

tap_flow_createFunction · 0.85
tap_flow_implicit_createFunction · 0.85
rss_enableFunction · 0.85

Calls 2

rte_randFunction · 0.85
rte_jhash_32bFunction · 0.50

Tested by

no test coverage detected