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

Function rte_node_ip4_rewrite_add

dpdk/lib/node/ip4_rewrite.c:295–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293}
294
295int
296rte_node_ip4_rewrite_add(uint16_t next_hop, uint8_t *rewrite_data,
297 uint8_t rewrite_len, uint16_t dst_port)
298{
299 struct ip4_rewrite_nh_header *nh;
300
301 if (next_hop >= RTE_GRAPH_IP4_REWRITE_MAX_NH)
302 return -EINVAL;
303
304 if (rewrite_len > RTE_GRAPH_IP4_REWRITE_MAX_LEN)
305 return -EINVAL;
306
307 if (ip4_rewrite_nm == NULL) {
308 ip4_rewrite_nm = rte_zmalloc(
309 "ip4_rewrite", sizeof(struct ip4_rewrite_node_main),
310 RTE_CACHE_LINE_SIZE);
311 if (ip4_rewrite_nm == NULL)
312 return -ENOMEM;
313 }
314
315 /* Check if dst port doesn't exist as edge */
316 if (!ip4_rewrite_nm->next_index[dst_port])
317 return -EINVAL;
318
319 /* Update next hop */
320 nh = &ip4_rewrite_nm->nh[next_hop];
321
322 memcpy(nh->rewrite_data, rewrite_data, rewrite_len);
323 nh->tx_node = ip4_rewrite_nm->next_index[dst_port];
324 nh->rewrite_len = rewrite_len;
325 nh->enabled = true;
326
327 return 0;
328}
329
330static struct rte_node_register ip4_rewrite_node = {
331 .process = ip4_rewrite_node_process,

Callers 2

ip4_rewrite_node_addFunction · 0.85
mainFunction · 0.85

Calls 2

rte_zmallocFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected