* 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.
| 1304 | * The flow that needs its handle set. |
| 1305 | */ |
| 1306 | static void |
| 1307 | tap_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 |
no test coverage detected