| 684 | } |
| 685 | |
| 686 | static inline void |
| 687 | l3fwd_simple_forward(struct rte_mbuf *m, uint16_t portid, |
| 688 | struct lcore_conf *qconf) |
| 689 | { |
| 690 | struct rte_ether_hdr *eth_hdr; |
| 691 | struct rte_ipv4_hdr *ipv4_hdr; |
| 692 | void *d_addr_bytes; |
| 693 | uint16_t dst_port; |
| 694 | |
| 695 | eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *); |
| 696 | |
| 697 | if (RTE_ETH_IS_IPV4_HDR(m->packet_type)) { |
| 698 | /* Handle IPv4 headers.*/ |
| 699 | ipv4_hdr = |
| 700 | rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, |
| 701 | sizeof(struct rte_ether_hdr)); |
| 702 | |
| 703 | #ifdef DO_RFC_1812_CHECKS |
| 704 | /* Check to make sure the packet is valid (RFC1812) */ |
| 705 | if (is_valid_ipv4_pkt(ipv4_hdr, m->pkt_len) < 0) { |
| 706 | rte_pktmbuf_free(m); |
| 707 | return; |
| 708 | } |
| 709 | #endif |
| 710 | |
| 711 | dst_port = get_ipv4_dst_port(ipv4_hdr, portid, |
| 712 | qconf->ipv4_lookup_struct); |
| 713 | if (dst_port >= RTE_MAX_ETHPORTS || |
| 714 | (enabled_port_mask & 1 << dst_port) == 0) |
| 715 | dst_port = portid; |
| 716 | |
| 717 | /* 02:00:00:00:00:xx */ |
| 718 | d_addr_bytes = ð_hdr->dst_addr.addr_bytes[0]; |
| 719 | *((uint64_t *)d_addr_bytes) = |
| 720 | 0x000000000002 + ((uint64_t)dst_port << 40); |
| 721 | |
| 722 | #ifdef DO_RFC_1812_CHECKS |
| 723 | /* Update time to live and header checksum */ |
| 724 | --(ipv4_hdr->time_to_live); |
| 725 | ++(ipv4_hdr->hdr_checksum); |
| 726 | #endif |
| 727 | |
| 728 | /* src addr */ |
| 729 | rte_ether_addr_copy(&ports_eth_addr[dst_port], |
| 730 | ð_hdr->src_addr); |
| 731 | |
| 732 | send_single_packet(m, dst_port); |
| 733 | } else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) { |
| 734 | /* Handle IPv6 headers.*/ |
| 735 | #if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH) |
| 736 | struct rte_ipv6_hdr *ipv6_hdr; |
| 737 | |
| 738 | ipv6_hdr = |
| 739 | rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *, |
| 740 | sizeof(struct rte_ether_hdr)); |
| 741 | |
| 742 | dst_port = get_ipv6_dst_port(ipv6_hdr, portid, |
| 743 | qconf->ipv6_lookup_struct); |
no test coverage detected