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

Function rte_node_ip4_route_add

dpdk/lib/node/ip4_lookup.c:121–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121int
122rte_node_ip4_route_add(uint32_t ip, uint8_t depth, uint16_t next_hop,
123 enum rte_node_ip4_lookup_next next_node)
124{
125 char abuf[INET6_ADDRSTRLEN];
126 struct in_addr in;
127 uint8_t socket;
128 uint32_t val;
129 int ret;
130
131 in.s_addr = htonl(ip);
132 inet_ntop(AF_INET, &in, abuf, sizeof(abuf));
133 /* Embedded next node id into 24 bit next hop */
134 val = ((next_node << 16) | next_hop) & ((1ull << 24) - 1);
135 node_dbg("ip4_lookup", "LPM: Adding route %s / %d nh (0x%x)", abuf,
136 depth, val);
137
138 for (socket = 0; socket < RTE_MAX_NUMA_NODES; socket++) {
139 if (!ip4_lookup_nm.lpm_tbl[socket])
140 continue;
141
142 ret = rte_lpm_add(ip4_lookup_nm.lpm_tbl[socket],
143 ip, depth, val);
144 if (ret < 0) {
145 node_err("ip4_lookup",
146 "Unable to add entry %s / %d nh (%x) to LPM table on sock %d, rc=%d",
147 abuf, depth, val, socket, ret);
148 return ret;
149 }
150 }
151
152 return 0;
153}
154
155static int
156setup_lpm(struct ip4_lookup_node_main *nm, int socket)

Callers 2

mainFunction · 0.85

Calls 2

inet_ntopFunction · 0.85
rte_lpm_addFunction · 0.50

Tested by

no test coverage detected