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

Function create_default_flow

dpdk/app/test/test_security_inline_macsec.c:310–365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308}
309
310static int
311create_default_flow(const struct mcs_test_vector *td, uint16_t portid,
312 enum rte_security_macsec_direction dir, void *sess)
313{
314 struct rte_flow_action action[2];
315 struct rte_flow_item pattern[2];
316 struct rte_flow_attr attr = {0};
317 struct rte_flow_error err;
318 struct rte_flow *flow;
319 struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
320 static const struct rte_flow_item_eth eth_mask = {
321 .hdr.dst_addr.addr_bytes = "\x00\x00\x00\x00\x00\x00",
322 .hdr.src_addr.addr_bytes = "\x00\x00\x00\x00\x00\x00",
323 .hdr.ether_type = RTE_BE16(0x0000),
324 };
325
326 int ret;
327
328 eth.has_vlan = 0;
329 if (dir == RTE_SECURITY_MACSEC_DIR_TX)
330 memcpy(&eth.hdr, td->plain_pkt.data, RTE_ETHER_HDR_LEN);
331 else
332 memcpy(&eth.hdr, td->secure_pkt.data, RTE_ETHER_HDR_LEN);
333
334 pattern[0].type = RTE_FLOW_ITEM_TYPE_ETH;
335 pattern[0].spec = ð
336 pattern[0].mask = &eth_mask;
337 pattern[0].last = NULL;
338 pattern[1].type = RTE_FLOW_ITEM_TYPE_END;
339
340 action[0].type = RTE_FLOW_ACTION_TYPE_SECURITY;
341 action[0].conf = sess;
342 action[1].type = RTE_FLOW_ACTION_TYPE_END;
343 action[1].conf = NULL;
344
345 attr.ingress = (dir == RTE_SECURITY_MACSEC_DIR_RX) ? 1 : 0;
346 attr.egress = (dir == RTE_SECURITY_MACSEC_DIR_TX) ? 1 : 0;
347
348 ret = rte_flow_validate(portid, &attr, pattern, action, &err);
349 if (ret) {
350 printf("\nValidate flow failed, ret = %d\n", ret);
351 return -1;
352 }
353 flow = rte_flow_create(portid, &attr, pattern, action, &err);
354 if (flow == NULL) {
355 printf("\nDefault flow rule create failed\n");
356 return -1;
357 }
358
359 if (dir == RTE_SECURITY_MACSEC_DIR_TX)
360 default_tx_flow[portid] = flow;
361 else
362 default_rx_flow[portid] = flow;
363
364 return 0;
365}
366
367static void

Callers 1

test_macsecFunction · 0.70

Calls 4

rte_flow_validateFunction · 0.85
rte_flow_createFunction · 0.85
memcpyFunction · 0.50
printfFunction · 0.50

Tested by

no test coverage detected