| 272 | } |
| 273 | |
| 274 | static inline uint16_t |
| 275 | route4_pkt(struct rte_mbuf *pkt, struct rt_ctx *rt_ctx) |
| 276 | { |
| 277 | uint32_t dst_ip; |
| 278 | uint16_t offset; |
| 279 | uint32_t hop; |
| 280 | int ret; |
| 281 | |
| 282 | offset = RTE_ETHER_HDR_LEN + offsetof(struct ip, ip_dst); |
| 283 | dst_ip = *rte_pktmbuf_mtod_offset(pkt, uint32_t *, offset); |
| 284 | dst_ip = rte_be_to_cpu_32(dst_ip); |
| 285 | |
| 286 | ret = rte_lpm_lookup((struct rte_lpm *)rt_ctx, dst_ip, &hop); |
| 287 | |
| 288 | if (ret == 0) { |
| 289 | /* We have a hit */ |
| 290 | return hop; |
| 291 | } |
| 292 | |
| 293 | /* else */ |
| 294 | return RTE_MAX_ETHPORTS; |
| 295 | } |
| 296 | |
| 297 | /* TODO: To be tested */ |
| 298 | static inline uint16_t |
no test coverage detected