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

Function rte_node_ip6_rewrite_add

dpdk/lib/node/ip6_rewrite.c:279–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277}
278
279int
280rte_node_ip6_rewrite_add(uint16_t next_hop, uint8_t *rewrite_data,
281 uint8_t rewrite_len, uint16_t dst_port)
282{
283 struct ip6_rewrite_nh_header *nh;
284
285 if (next_hop >= RTE_GRAPH_IP6_REWRITE_MAX_NH)
286 return -EINVAL;
287
288 if (rewrite_len > RTE_GRAPH_IP6_REWRITE_MAX_LEN)
289 return -EINVAL;
290
291 if (ip6_rewrite_nm == NULL) {
292 ip6_rewrite_nm = rte_zmalloc(
293 "ip6_rewrite", sizeof(struct ip6_rewrite_node_main),
294 RTE_CACHE_LINE_SIZE);
295 if (ip6_rewrite_nm == NULL)
296 return -ENOMEM;
297 }
298
299 /* Check if dst port doesn't exist as edge */
300 if (!ip6_rewrite_nm->next_index[dst_port])
301 return -EINVAL;
302
303 /* Update next hop */
304 nh = &ip6_rewrite_nm->nh[next_hop];
305
306 memcpy(nh->rewrite_data, rewrite_data, rewrite_len);
307 nh->tx_node = ip6_rewrite_nm->next_index[dst_port];
308 nh->rewrite_len = rewrite_len;
309 nh->enabled = true;
310
311 return 0;
312}
313
314static struct rte_node_register ip6_rewrite_node = {
315 .process = ip6_rewrite_node_process,

Callers 2

ip6_rewrite_node_addFunction · 0.85
mainFunction · 0.85

Calls 2

rte_zmallocFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected