diff options
Diffstat (limited to 'examples/l4fwd')
-rw-r--r-- | examples/l4fwd/Makefile | 1 | ||||
-rw-r--r-- | examples/l4fwd/README | 1 | ||||
-rw-r--r-- | examples/l4fwd/common.h | 38 | ||||
-rw-r--r-- | examples/l4fwd/main.c | 8 | ||||
-rw-r--r-- | examples/l4fwd/netbe.h | 5 | ||||
-rw-r--r-- | examples/l4fwd/parse.c | 21 | ||||
-rw-r--r-- | examples/l4fwd/parse.h | 2 | ||||
-rw-r--r-- | examples/l4fwd/pkt.c | 168 | ||||
-rw-r--r-- | examples/l4fwd/port.h | 19 | ||||
-rw-r--r-- | examples/l4fwd/test/config.sh | 347 | ||||
-rw-r--r-- | examples/l4fwd/test/example_env_vars | 15 | ||||
-rw-r--r-- | examples/l4fwd/test/nctxrx.sh | 110 | ||||
-rw-r--r-- | examples/l4fwd/test/run_test.sh | 21 | ||||
-rw-r--r-- | examples/l4fwd/udp.h | 12 |
14 files changed, 470 insertions, 298 deletions
diff --git a/examples/l4fwd/Makefile b/examples/l4fwd/Makefile index f18b622..a6e0de3 100644 --- a/examples/l4fwd/Makefile +++ b/examples/l4fwd/Makefile @@ -38,6 +38,7 @@ CFLAGS += -I$(RTE_OUTPUT)/include LDLIBS += -L$(RTE_OUTPUT)/lib LDLIBS += -ltle_l4p +LDLIBS += -ltle_memtank LDLIBS += -ltle_timer EXTRA_CFLAGS += -O3 diff --git a/examples/l4fwd/README b/examples/l4fwd/README index dc3dc67..328f7ef 100644 --- a/examples/l4fwd/README +++ b/examples/l4fwd/README @@ -139,6 +139,7 @@ -K | --seckey <string> /* 16 character long secret key used by */ \ /* hash algorithms to generate the */ \ /* sequence number. */ \ + -M | --mbuf-num <num> /* other than default number of mbufs per pool. */ \ <port0_params> <port1_params> ... <portN_params> Note that: options -U and -T cannot be used together. diff --git a/examples/l4fwd/common.h b/examples/l4fwd/common.h index b7750d7..a2cd5f6 100644 --- a/examples/l4fwd/common.h +++ b/examples/l4fwd/common.h @@ -357,31 +357,31 @@ fill_dst(struct tle_dest *dst, struct netbe_dev *bed, const struct netbe_dest *bdp, uint16_t l3_type, int32_t sid, uint8_t proto_id) { - struct ether_hdr *eth; - struct ipv4_hdr *ip4h; - struct ipv6_hdr *ip6h; + struct rte_ether_hdr *eth; + struct rte_ipv4_hdr *ip4h; + struct rte_ipv6_hdr *ip6h; dst->dev = bed->dev; dst->head_mp = frag_mpool[sid + 1]; dst->mtu = RTE_MIN(bdp->mtu, bed->port.mtu); dst->l2_len = sizeof(*eth); - eth = (struct ether_hdr *)dst->hdr; + eth = (struct rte_ether_hdr *)dst->hdr; - ether_addr_copy(&bed->port.mac, ð->s_addr); - ether_addr_copy(&bdp->mac, ð->d_addr); + rte_ether_addr_copy(&bed->port.mac, ð->s_addr); + rte_ether_addr_copy(&bdp->mac, ð->d_addr); eth->ether_type = rte_cpu_to_be_16(l3_type); - if (l3_type == ETHER_TYPE_IPv4) { + if (l3_type == RTE_ETHER_TYPE_IPV4) { dst->l3_len = sizeof(*ip4h); - ip4h = (struct ipv4_hdr *)(eth + 1); + ip4h = (struct rte_ipv4_hdr *)(eth + 1); ip4h->version_ihl = 4 << 4 | - sizeof(*ip4h) / IPV4_IHL_MULTIPLIER; + sizeof(*ip4h) / RTE_IPV4_IHL_MULTIPLIER; ip4h->time_to_live = 64; ip4h->next_proto_id = proto_id; - } else if (l3_type == ETHER_TYPE_IPv6) { + } else if (l3_type == RTE_ETHER_TYPE_IPV6) { dst->l3_len = sizeof(*ip6h); - ip6h = (struct ipv6_hdr *)(eth + 1); + ip6h = (struct rte_ipv6_hdr *)(eth + 1); ip6h->vtc_flow = 6 << 4; ip6h->proto = proto_id; ip6h->hop_limits = 64; @@ -402,12 +402,12 @@ netbe_add_dest(struct netbe_lcore *lc, uint32_t dev_idx, uint16_t family, n = lc->dst4_num; dp = lc->dst4 + n; m = RTE_DIM(lc->dst4); - l3_type = ETHER_TYPE_IPv4; + l3_type = RTE_ETHER_TYPE_IPV4; } else { n = lc->dst6_num; dp = lc->dst6 + n; m = RTE_DIM(lc->dst6); - l3_type = ETHER_TYPE_IPv6; + l3_type = RTE_ETHER_TYPE_IPV6; } if (n + dnum >= m) { @@ -441,21 +441,21 @@ netbe_add_dest(struct netbe_lcore *lc, uint32_t dev_idx, uint16_t family, static inline void fill_arp_reply(struct netbe_dev *dev, struct rte_mbuf *m) { - struct ether_hdr *eth; - struct arp_hdr *ahdr; - struct arp_ipv4 *adata; + struct rte_ether_hdr *eth; + struct rte_arp_hdr *ahdr; + struct rte_arp_ipv4 *adata; uint32_t tip; /* set up the ethernet data */ - eth = rte_pktmbuf_mtod(m, struct ether_hdr *); + eth = rte_pktmbuf_mtod(m, struct rte_ether_hdr *); eth->d_addr = eth->s_addr; eth->s_addr = dev->port.mac; /* set up the arp data */ - ahdr = rte_pktmbuf_mtod_offset(m, struct arp_hdr *, m->l2_len); + ahdr = rte_pktmbuf_mtod_offset(m, struct rte_arp_hdr *, m->l2_len); adata = &ahdr->arp_data; - ahdr->arp_op = rte_cpu_to_be_16(ARP_OP_REPLY); + ahdr->arp_opcode = rte_cpu_to_be_16(RTE_ARP_OP_REPLY); tip = adata->arp_tip; adata->arp_tip = adata->arp_sip; diff --git a/examples/l4fwd/main.c b/examples/l4fwd/main.c index 9396403..57e9cfd 100644 --- a/examples/l4fwd/main.c +++ b/examples/l4fwd/main.c @@ -61,16 +61,12 @@ RTE_DEFINE_PER_LCORE(struct netfe_lcore *, _fe); static volatile int force_quit; -static struct netbe_cfg becfg; +static struct netbe_cfg becfg = {.mpool_buf_num=MPOOL_NB_BUF}; static struct rte_mempool *mpool[RTE_MAX_NUMA_NODES + 1]; static struct rte_mempool *frag_mpool[RTE_MAX_NUMA_NODES + 1]; static char proto_name[3][10] = {"udp", "tcp", ""}; -static const struct rte_eth_conf port_conf_default = { - .rxmode = { - .offloads = DEV_RX_OFFLOAD_VLAN_STRIP, - }, -}; +static const struct rte_eth_conf port_conf_default; struct tx_content tx_content = { .sz = 0, diff --git a/examples/l4fwd/netbe.h b/examples/l4fwd/netbe.h index 6d9aa35..430bc28 100644 --- a/examples/l4fwd/netbe.h +++ b/examples/l4fwd/netbe.h @@ -75,7 +75,7 @@ struct netbe_port { uint64_t tx_offload; uint32_t ipv4; struct in6_addr ipv6; - struct ether_addr mac; + struct rte_ether_addr mac; uint32_t hash_key_size; uint8_t hash_key[RSS_HASH_KEY_LENGTH]; }; @@ -90,7 +90,7 @@ struct netbe_dest { struct in_addr ipv4; struct in6_addr ipv6; }; - struct ether_addr mac; + struct rte_ether_addr mac; }; struct netbe_dest_prm { @@ -151,6 +151,7 @@ struct netbe_cfg { uint32_t arp; uint32_t prt_num; uint32_t cpu_num; + uint32_t mpool_buf_num; struct netbe_port *prt; struct netbe_lcore *cpu; }; diff --git a/examples/l4fwd/parse.c b/examples/l4fwd/parse.c index 40adee4..b936bab 100644 --- a/examples/l4fwd/parse.c +++ b/examples/l4fwd/parse.c @@ -45,6 +45,9 @@ static const struct { #define OPT_SHORT_PROMISC 'P' #define OPT_LONG_PROMISC "promisc" +#define OPT_SHORT_MBUFNUM 'M' +#define OPT_LONG_MBUFNUM "mbuf-num" + #define OPT_SHORT_RBUFS 'R' #define OPT_LONG_RBUFS "rbufs" @@ -95,6 +98,7 @@ static const struct option long_opt[] = { {OPT_LONG_SBULK, 1, 0, OPT_SHORT_SBULK}, {OPT_LONG_CTXFLAGS, 1, 0, OPT_SHORT_CTXFLAGS}, {OPT_LONG_PROMISC, 0, 0, OPT_SHORT_PROMISC}, + {OPT_LONG_MBUFNUM, 1, 0, OPT_SHORT_MBUFNUM}, {OPT_LONG_RBUFS, 1, 0, OPT_SHORT_RBUFS}, {OPT_LONG_SBUFS, 1, 0, OPT_SHORT_SBUFS}, {OPT_LONG_BECFG, 1, 0, OPT_SHORT_BECFG}, @@ -330,7 +334,7 @@ parse_netbe_arg(struct netbe_port *prt, const char *arg, rte_cpuset_t *pcpu) union parse_val val[RTE_DIM(hndl)]; memset(val, 0, sizeof(val)); - val[2].u64 = ETHER_MAX_LEN - ETHER_CRC_LEN; + val[2].u64 = RTE_ETHER_MAX_LEN - RTE_ETHER_CRC_LEN; rc = parse_kvargs(arg, keys_man, RTE_DIM(keys_man), keys_opt, RTE_DIM(keys_opt), hndl, val); @@ -373,7 +377,8 @@ check_netbe_dest(const struct netbe_dest *dst) RTE_LOG(ERR, USER1, "%s(line=%u) invalid masklen=%u", __func__, dst->line, dst->prfx); return -EINVAL; - } else if (dst->mtu > ETHER_MAX_JUMBO_FRAME_LEN - ETHER_CRC_LEN) { + } else if (dst->mtu > + RTE_ETHER_MAX_JUMBO_FRAME_LEN - RTE_ETHER_CRC_LEN) { RTE_LOG(ERR, USER1, "%s(line=%u) invalid mtu=%u", __func__, dst->line, dst->mtu); return -EINVAL; @@ -409,7 +414,7 @@ parse_netbe_dest(struct netbe_dest *dst, const char *arg) /* set default values. */ memset(val, 0, sizeof(val)); - val[4].u64 = ETHER_MAX_JUMBO_FRAME_LEN - ETHER_CRC_LEN; + val[4].u64 = RTE_ETHER_MAX_JUMBO_FRAME_LEN - RTE_ETHER_CRC_LEN; rc = parse_kvargs(arg, keys_man, RTE_DIM(keys_man), keys_opt, RTE_DIM(keys_opt), hndl, val); @@ -816,7 +821,7 @@ parse_app_options(int argc, char **argv, struct netbe_cfg *cfg, optind = 0; optarg = NULL; - while ((opt = getopt_long(argc, argv, "aB:C:c:LPR:S:TUb:f:s:v:H:K:W:w:", + while ((opt = getopt_long(argc, argv, "aB:C:c:LPR:S:M:TUb:f:s:v:H:K:W:w:", long_opt, &opt_idx)) != EOF) { if (opt == OPT_SHORT_ARP) { cfg->arp = 1; @@ -834,7 +839,13 @@ parse_app_options(int argc, char **argv, struct netbe_cfg *cfg, "for option: \'%c\'\n", __func__, optarg, opt); ctx_prm->flags = v; - } else if (opt == OPT_SHORT_PROMISC) { + } else if (opt == OPT_SHORT_MBUFNUM) { + rc = parse_uint_val(NULL, optarg, &v); + if (rc < 0) + rte_exit(EXIT_FAILURE, "%s: invalid value: %s " + "for option: \'%c\'\n", + __func__, optarg, opt); + cfg->mpool_buf_num = v; } else if (opt == OPT_SHORT_PROMISC) { cfg->promisc = 1; } else if (opt == OPT_SHORT_RBUFS) { diff --git a/examples/l4fwd/parse.h b/examples/l4fwd/parse.h index 4303623..4634d60 100644 --- a/examples/l4fwd/parse.h +++ b/examples/l4fwd/parse.h @@ -29,7 +29,7 @@ union parse_val { struct in6_addr addr6; }; } in; - struct ether_addr mac; + struct rte_ether_addr mac; rte_cpuset_t cpuset; }; diff --git a/examples/l4fwd/pkt.c b/examples/l4fwd/pkt.c index 43aa9c8..6694e81 100644 --- a/examples/l4fwd/pkt.c +++ b/examples/l4fwd/pkt.c @@ -49,9 +49,9 @@ fill_pkt_hdr_len(struct rte_mbuf *m, uint32_t l2, uint32_t l3, uint32_t l4) } static inline int -is_ipv4_frag(const struct ipv4_hdr *iph) +is_ipv4_frag(const struct rte_ipv4_hdr *iph) { - const uint16_t mask = rte_cpu_to_be_16(~IPV4_HDR_DF_FLAG); + const uint16_t mask = rte_cpu_to_be_16(~RTE_IPV4_HDR_DF_FLAG); return ((mask & iph->fragment_offset) != 0); } @@ -59,9 +59,9 @@ is_ipv4_frag(const struct ipv4_hdr *iph) static inline uint32_t get_tcp_header_size(struct rte_mbuf *m, uint32_t l2_len, uint32_t l3_len) { - const struct tcp_hdr *tcp; + const struct rte_tcp_hdr *tcp; - tcp = rte_pktmbuf_mtod_offset(m, struct tcp_hdr *, l2_len + l3_len); + tcp = rte_pktmbuf_mtod_offset(m, struct rte_tcp_hdr *, l2_len + l3_len); return (tcp->data_off >> 4) * 4; } @@ -69,9 +69,9 @@ static inline void adjust_ipv4_pktlen(struct rte_mbuf *m, uint32_t l2_len) { uint32_t plen, trim; - const struct ipv4_hdr *iph; + const struct rte_ipv4_hdr *iph; - iph = rte_pktmbuf_mtod_offset(m, const struct ipv4_hdr *, l2_len); + iph = rte_pktmbuf_mtod_offset(m, const struct rte_ipv4_hdr *, l2_len); plen = rte_be_to_cpu_16(iph->total_length) + l2_len; if (plen < m->pkt_len) { trim = m->pkt_len - plen; @@ -83,9 +83,9 @@ static inline void adjust_ipv6_pktlen(struct rte_mbuf *m, uint32_t l2_len) { uint32_t plen, trim; - const struct ipv6_hdr *iph; + const struct rte_ipv6_hdr *iph; - iph = rte_pktmbuf_mtod_offset(m, const struct ipv6_hdr *, l2_len); + iph = rte_pktmbuf_mtod_offset(m, const struct rte_ipv6_hdr *, l2_len); plen = rte_be_to_cpu_16(iph->payload_len) + sizeof(*iph) + l2_len; if (plen < m->pkt_len) { trim = m->pkt_len - plen; @@ -97,23 +97,24 @@ static inline void tcp_stat_update(struct netbe_lcore *lc, const struct rte_mbuf *m, uint32_t l2_len, uint32_t l3_len) { - const struct tcp_hdr *th; + const struct rte_tcp_hdr *th; - th = rte_pktmbuf_mtod_offset(m, struct tcp_hdr *, l2_len + l3_len); + th = rte_pktmbuf_mtod_offset(m, struct rte_tcp_hdr *, l2_len + l3_len); lc->tcp_stat.flags[th->tcp_flags]++; } static inline uint32_t get_ipv4_hdr_len(struct rte_mbuf *m, uint32_t l2, uint32_t proto, uint32_t frag) { - const struct ipv4_hdr *iph; + const struct rte_ipv4_hdr *iph; int32_t dlen, len; dlen = rte_pktmbuf_data_len(m); dlen -= l2; - iph = rte_pktmbuf_mtod_offset(m, const struct ipv4_hdr *, l2); - len = (iph->version_ihl & IPV4_HDR_IHL_MASK) * IPV4_IHL_MULTIPLIER; + iph = rte_pktmbuf_mtod_offset(m, const struct rte_ipv4_hdr *, l2); + len = (iph->version_ihl & RTE_IPV4_HDR_IHL_MASK) * + RTE_IPV4_IHL_MULTIPLIER; if (frag != 0 && is_ipv4_frag(iph)) { m->packet_type &= ~RTE_PTYPE_L4_MASK; @@ -155,7 +156,7 @@ get_ipv6x_hdr_len(struct rte_mbuf *m, uint32_t l2, uint32_t nproto, const struct ip6_ext *ipx; int32_t dlen, len, ofs; - len = sizeof(struct ipv6_hdr); + len = sizeof(struct rte_ipv6_hdr); dlen = rte_pktmbuf_data_len(m); dlen -= l2; @@ -205,13 +206,13 @@ get_ipv6x_hdr_len(struct rte_mbuf *m, uint32_t l2, uint32_t nproto, static inline uint32_t get_ipv6_hdr_len(struct rte_mbuf *m, uint32_t l2, uint32_t fproto) { - const struct ipv6_hdr *iph; + const struct rte_ipv6_hdr *iph; - iph = rte_pktmbuf_mtod_offset(m, const struct ipv6_hdr *, - sizeof(struct ether_hdr)); + iph = rte_pktmbuf_mtod_offset(m, const struct rte_ipv6_hdr *, + sizeof(struct rte_ether_hdr)); if (iph->proto == fproto) - return sizeof(struct ipv6_hdr); + return sizeof(struct rte_ipv6_hdr); else if (ipv6x_hdr(iph->proto) != 0) return get_ipv6x_hdr_len(m, l2, iph->proto, fproto); @@ -234,14 +235,14 @@ static inline struct rte_mbuf * handle_arp(struct rte_mbuf *m, struct netbe_lcore *lc, dpdk_port_t port, uint32_t l2len) { - const struct arp_hdr *ahdr; + const struct rte_arp_hdr *ahdr; struct pkt_buf *abuf; - ahdr = rte_pktmbuf_mtod_offset(m, const struct arp_hdr *, l2len); + ahdr = rte_pktmbuf_mtod_offset(m, const struct rte_arp_hdr *, l2len); - if (ahdr->arp_hrd != rte_be_to_cpu_16(ARP_HRD_ETHER) || - ahdr->arp_pro != rte_be_to_cpu_16(ETHER_TYPE_IPv4) || - ahdr->arp_op != rte_be_to_cpu_16(ARP_OP_REQUEST)) { + if (ahdr->arp_hardware != rte_be_to_cpu_16(RTE_ARP_HRD_ETHER) || + ahdr->arp_protocol != rte_be_to_cpu_16(RTE_ETHER_TYPE_IPV4) || + ahdr->arp_opcode != rte_be_to_cpu_16(RTE_ARP_OP_REQUEST)) { m->packet_type = RTE_PTYPE_UNKNOWN; return m; @@ -263,28 +264,28 @@ fill_eth_tcp_arp_hdr_len(struct rte_mbuf *m, struct netbe_lcore *lc, { uint32_t dlen, l2_len, l3_len, l4_len; uint16_t etp; - const struct ether_hdr *eth; + const struct rte_ether_hdr *eth; dlen = rte_pktmbuf_data_len(m); /* check that first segment is at least 54B long. */ - if (dlen < sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr) + - sizeof(struct tcp_hdr)) { + if (dlen < sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr) + + sizeof(struct rte_tcp_hdr)) { m->packet_type = RTE_PTYPE_UNKNOWN; return m; } l2_len = sizeof(*eth); - eth = rte_pktmbuf_mtod(m, const struct ether_hdr *); + eth = rte_pktmbuf_mtod(m, const struct rte_ether_hdr *); etp = eth->ether_type; - if (etp == rte_be_to_cpu_16(ETHER_TYPE_VLAN)) - l2_len += sizeof(struct vlan_hdr); + if (etp == rte_be_to_cpu_16(RTE_ETHER_TYPE_VLAN)) + l2_len += sizeof(struct rte_vlan_hdr); - if (etp == rte_be_to_cpu_16(ETHER_TYPE_ARP)) + if (etp == rte_be_to_cpu_16(RTE_ETHER_TYPE_ARP)) return handle_arp(m, lc, port, l2_len); - if (etp == rte_be_to_cpu_16(ETHER_TYPE_IPv4)) { + if (etp == rte_be_to_cpu_16(RTE_ETHER_TYPE_IPV4)) { m->packet_type = RTE_PTYPE_L4_TCP | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L2_ETHER; @@ -292,9 +293,9 @@ fill_eth_tcp_arp_hdr_len(struct rte_mbuf *m, struct netbe_lcore *lc, l4_len = get_tcp_header_size(m, l2_len, l3_len); fill_pkt_hdr_len(m, l2_len, l3_len, l4_len); adjust_ipv4_pktlen(m, l2_len); - } else if (etp == rte_be_to_cpu_16(ETHER_TYPE_IPv6) && - dlen >= l2_len + sizeof(struct ipv6_hdr) + - sizeof(struct tcp_hdr)) { + } else if (etp == rte_be_to_cpu_16(RTE_ETHER_TYPE_IPV6) && + dlen >= l2_len + sizeof(struct rte_ipv6_hdr) + + sizeof(struct rte_tcp_hdr)) { m->packet_type = RTE_PTYPE_L4_TCP | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L2_ETHER; @@ -313,25 +314,25 @@ fill_eth_tcp_hdr_len(struct rte_mbuf *m) { uint32_t dlen, l2_len, l3_len, l4_len; uint16_t etp; - const struct ether_hdr *eth; + const struct rte_ether_hdr *eth; dlen = rte_pktmbuf_data_len(m); /* check that first segment is at least 54B long. */ - if (dlen < sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr) + - sizeof(struct tcp_hdr)) { + if (dlen < sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr) + + sizeof(struct rte_tcp_hdr)) { m->packet_type = RTE_PTYPE_UNKNOWN; return; } l2_len = sizeof(*eth); - eth = rte_pktmbuf_mtod(m, const struct ether_hdr *); + eth = rte_pktmbuf_mtod(m, const struct rte_ether_hdr *); etp = eth->ether_type; - if (etp == rte_be_to_cpu_16(ETHER_TYPE_VLAN)) - l2_len += sizeof(struct vlan_hdr); + if (etp == rte_be_to_cpu_16(RTE_ETHER_TYPE_VLAN)) + l2_len += sizeof(struct rte_vlan_hdr); - if (etp == rte_be_to_cpu_16(ETHER_TYPE_IPv4)) { + if (etp == rte_be_to_cpu_16(RTE_ETHER_TYPE_IPV4)) { m->packet_type = RTE_PTYPE_L4_TCP | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L2_ETHER; @@ -339,9 +340,9 @@ fill_eth_tcp_hdr_len(struct rte_mbuf *m) l4_len = get_tcp_header_size(m, l2_len, l3_len); fill_pkt_hdr_len(m, l2_len, l3_len, l4_len); adjust_ipv4_pktlen(m, l2_len); - } else if (etp == rte_be_to_cpu_16(ETHER_TYPE_IPv6) && - dlen >= l2_len + sizeof(struct ipv6_hdr) + - sizeof(struct tcp_hdr)) { + } else if (etp == rte_be_to_cpu_16(RTE_ETHER_TYPE_IPV6) && + dlen >= l2_len + sizeof(struct rte_ipv6_hdr) + + sizeof(struct rte_tcp_hdr)) { m->packet_type = RTE_PTYPE_L4_TCP | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L2_ETHER; @@ -358,38 +359,38 @@ fill_eth_udp_hdr_len(struct rte_mbuf *m) { uint32_t dlen, l2_len; uint16_t etp; - const struct ether_hdr *eth; + const struct rte_ether_hdr *eth; dlen = rte_pktmbuf_data_len(m); /* check that first segment is at least 42B long. */ - if (dlen < sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr) + - sizeof(struct udp_hdr)) { + if (dlen < sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr) + + sizeof(struct rte_udp_hdr)) { m->packet_type = RTE_PTYPE_UNKNOWN; return; } l2_len = sizeof(*eth); - eth = rte_pktmbuf_mtod(m, const struct ether_hdr *); + eth = rte_pktmbuf_mtod(m, const struct rte_ether_hdr *); etp = eth->ether_type; - if (etp == rte_be_to_cpu_16(ETHER_TYPE_VLAN)) - l2_len += sizeof(struct vlan_hdr); + if (etp == rte_be_to_cpu_16(RTE_ETHER_TYPE_VLAN)) + l2_len += sizeof(struct rte_vlan_hdr); - if (etp == rte_be_to_cpu_16(ETHER_TYPE_IPv4)) { + if (etp == rte_be_to_cpu_16(RTE_ETHER_TYPE_IPV4)) { m->packet_type = RTE_PTYPE_L4_UDP | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L2_ETHER; fill_ipv4_hdr_len(m, l2_len, IPPROTO_UDP, 1, - sizeof(struct udp_hdr)); - } else if (etp == rte_be_to_cpu_16(ETHER_TYPE_IPv6) && - dlen >= l2_len + sizeof(struct ipv6_hdr) + - sizeof(struct udp_hdr)) { + sizeof(struct rte_udp_hdr)); + } else if (etp == rte_be_to_cpu_16(RTE_ETHER_TYPE_IPV6) && + dlen >= l2_len + sizeof(struct rte_ipv6_hdr) + + sizeof(struct rte_udp_hdr)) { m->packet_type = RTE_PTYPE_L4_UDP | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L2_ETHER; fill_ipv6_hdr_len(m, l2_len, IPPROTO_UDP, - sizeof(struct udp_hdr)); + sizeof(struct rte_udp_hdr)); } else m->packet_type = RTE_PTYPE_UNKNOWN; } @@ -406,7 +407,7 @@ ipv4x_cksum(const void *iph, size_t len) static inline void fix_reassembled(struct rte_mbuf *m, int32_t hwcsum, uint32_t proto) { - struct ipv4_hdr *iph; + struct rte_ipv4_hdr *iph; /* update packet type. */ m->packet_type &= ~RTE_PTYPE_L4_MASK; @@ -425,7 +426,8 @@ fix_reassembled(struct rte_mbuf *m, int32_t hwcsum, uint32_t proto) /* recalculate ipv4 cksum after reassemble. */ else if (hwcsum == 0 && RTE_ETH_IS_IPV4_HDR(m->packet_type)) { - iph = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *, m->l2_len); + iph = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, + m->l2_len); iph->hdr_checksum = ipv4x_cksum(iph, m->l3_len); } } @@ -444,19 +446,21 @@ reassemble(struct rte_mbuf *m, struct netbe_lcore *lc, uint64_t tms, if (RTE_ETH_IS_IPV4_HDR(m->packet_type)) { - struct ipv4_hdr *iph; + struct rte_ipv4_hdr *iph; - iph = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *, m->l2_len); + iph = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, + m->l2_len); /* process this fragment. */ m = rte_ipv4_frag_reassemble_packet(tbl, dr, m, tms, iph); } else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) { - struct ipv6_hdr *iph; + struct rte_ipv6_hdr *iph; struct ipv6_extension_fragment *fhdr; - iph = rte_pktmbuf_mtod_offset(m, struct ipv6_hdr *, m->l2_len); + iph = rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *, + m->l2_len); /* * we store fragment header offset in tso_segsz before @@ -535,7 +539,7 @@ type0_tcp_rx_callback(__rte_unused dpdk_port_t port, uint32_t j, tp; struct netbe_lcore *lc; uint32_t l4_len, l3_len, l2_len; - const struct ether_hdr *eth; + const struct rte_ether_hdr *eth; lc = user_param; l2_len = sizeof(*eth); @@ -554,17 +558,17 @@ type0_tcp_rx_callback(__rte_unused dpdk_port_t port, case (RTE_PTYPE_L4_TCP | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L2_ETHER): l4_len = get_tcp_header_size(pkt[j], l2_len, - sizeof(struct ipv4_hdr)); + sizeof(struct rte_ipv4_hdr)); fill_pkt_hdr_len(pkt[j], l2_len, - sizeof(struct ipv4_hdr), l4_len); + sizeof(struct rte_ipv4_hdr), l4_len); adjust_ipv4_pktlen(pkt[j], l2_len); break; case (RTE_PTYPE_L4_TCP | RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L2_ETHER): l4_len = get_tcp_header_size(pkt[j], l2_len, - sizeof(struct ipv6_hdr)); + sizeof(struct rte_ipv6_hdr)); fill_pkt_hdr_len(pkt[j], l2_len, - sizeof(struct ipv6_hdr), l4_len); + sizeof(struct rte_ipv6_hdr), l4_len); adjust_ipv6_pktlen(pkt[j], l2_len); break; case (RTE_PTYPE_L4_TCP | RTE_PTYPE_L3_IPV4_EXT | @@ -604,7 +608,7 @@ type0_udp_rx_callback(dpdk_port_t port, __rte_unused uint16_t queue, uint64_t cts; struct netbe_lcore *lc; uint32_t l2_len; - const struct ether_hdr *eth; + const struct rte_ether_hdr *eth; lc = user_param; cts = 0; @@ -623,37 +627,37 @@ type0_udp_rx_callback(dpdk_port_t port, __rte_unused uint16_t queue, case (RTE_PTYPE_L4_UDP | RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L2_ETHER): fill_pkt_hdr_len(pkt[j], l2_len, - sizeof(struct ipv4_hdr), - sizeof(struct udp_hdr)); + sizeof(struct rte_ipv4_hdr), + sizeof(struct rte_udp_hdr)); adjust_ipv4_pktlen(pkt[j], l2_len); break; case (RTE_PTYPE_L4_UDP | RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L2_ETHER): fill_pkt_hdr_len(pkt[j], l2_len, - sizeof(struct ipv6_hdr), - sizeof(struct udp_hdr)); + sizeof(struct rte_ipv6_hdr), + sizeof(struct rte_udp_hdr)); adjust_ipv6_pktlen(pkt[j], l2_len); break; case (RTE_PTYPE_L4_UDP | RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L2_ETHER): fill_ipv4_hdr_len(pkt[j], l2_len, - UINT32_MAX, 0, sizeof(struct udp_hdr)); + UINT32_MAX, 0, sizeof(struct rte_udp_hdr)); break; case (RTE_PTYPE_L4_UDP | RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_L2_ETHER): fill_ipv6_hdr_len(pkt[j], l2_len, - IPPROTO_UDP, sizeof(struct udp_hdr)); + IPPROTO_UDP, sizeof(struct rte_udp_hdr)); break; /* possibly fragmented udp packets. */ case (RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L2_ETHER): case (RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L2_ETHER): fill_ipv4_hdr_len(pkt[j], l2_len, - IPPROTO_UDP, 1, sizeof(struct udp_hdr)); + IPPROTO_UDP, 1, sizeof(struct rte_udp_hdr)); break; case (RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L2_ETHER): case (RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_L2_ETHER): fill_ipv6_hdr_len(pkt[j], l2_len, - IPPROTO_UDP, sizeof(struct udp_hdr)); + IPPROTO_UDP, sizeof(struct rte_udp_hdr)); break; default: /* treat packet types as invalid. */ @@ -690,7 +694,7 @@ type1_tcp_rx_callback(__rte_unused dpdk_port_t port, uint32_t j, tp; struct netbe_lcore *lc; uint32_t l4_len, l3_len, l2_len; - const struct ether_hdr *eth; + const struct rte_ether_hdr *eth; lc = user_param; l2_len = sizeof(*eth); @@ -745,7 +749,7 @@ type1_udp_rx_callback(dpdk_port_t port, __rte_unused uint16_t queue, uint64_t cts; struct netbe_lcore *lc; uint32_t l2_len; - const struct ether_hdr *eth; + const struct rte_ether_hdr *eth; lc = user_param; cts = 0; @@ -763,22 +767,22 @@ type1_udp_rx_callback(dpdk_port_t port, __rte_unused uint16_t queue, case (RTE_PTYPE_L4_UDP | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L2_ETHER): fill_ipv4_hdr_len(pkt[j], l2_len, - UINT32_MAX, 0, sizeof(struct udp_hdr)); + UINT32_MAX, 0, sizeof(struct rte_udp_hdr)); break; case (RTE_PTYPE_L4_UDP | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L2_ETHER): fill_ipv6_hdr_len(pkt[j], l2_len, - IPPROTO_UDP, sizeof(struct udp_hdr)); + IPPROTO_UDP, sizeof(struct rte_udp_hdr)); break; case (RTE_PTYPE_L4_FRAG | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L2_ETHER): fill_ipv4_hdr_len(pkt[j], l2_len, - IPPROTO_UDP, 0, sizeof(struct udp_hdr)); + IPPROTO_UDP, 0, sizeof(struct rte_udp_hdr)); break; case (RTE_PTYPE_L4_FRAG | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L2_ETHER): fill_ipv6_hdr_len(pkt[j], l2_len, - IPPROTO_UDP, sizeof(struct udp_hdr)); + IPPROTO_UDP, sizeof(struct rte_udp_hdr)); break; default: /* treat packet types as invalid. */ diff --git a/examples/l4fwd/port.h b/examples/l4fwd/port.h index a154844..ce730dd 100644 --- a/examples/l4fwd/port.h +++ b/examples/l4fwd/port.h @@ -182,8 +182,8 @@ port_init(struct netbe_port *uprt, uint32_t proto) __func__, uprt->id); port_conf.rxmode.offloads |= uprt->rx_offload & RX_CSUM_OFFLOAD; } - port_conf.rxmode.max_rx_pkt_len = uprt->mtu + ETHER_CRC_LEN; - if (port_conf.rxmode.max_rx_pkt_len > ETHER_MAX_LEN) + port_conf.rxmode.max_rx_pkt_len = uprt->mtu + RTE_ETHER_CRC_LEN; + if (port_conf.rxmode.max_rx_pkt_len > RTE_ETHER_MAX_LEN) port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; rc = update_rss_conf(uprt, &dev_info, &port_conf, proto); @@ -258,8 +258,7 @@ check_lcore(uint32_t lc) return -EINVAL; } if (rte_eal_get_lcore_state(lc) == RUNNING) { - RTE_LOG(ERR, USER1, "lcore %u already running %p\n", - lc, lcore_config[lc].f); + RTE_LOG(ERR, USER1, "lcore %u already in use\n", lc); return -EINVAL; } return 0; @@ -316,14 +315,14 @@ log_netbe_cfg(const struct netbe_cfg *ucfg) } static int -pool_init(uint32_t sid) +pool_init(uint32_t sid, uint32_t mpool_buf_num) { int32_t rc; struct rte_mempool *mp; char name[RTE_MEMPOOL_NAMESIZE]; snprintf(name, sizeof(name), "MP%u", sid); - mp = rte_pktmbuf_pool_create(name, MPOOL_NB_BUF, MPOOL_CACHE_SIZE, 0, + mp = rte_pktmbuf_pool_create(name, mpool_buf_num, MPOOL_CACHE_SIZE, 0, RTE_MBUF_DEFAULT_BUF_SIZE, sid - 1); if (mp == NULL) { rc = -rte_errno; @@ -337,14 +336,14 @@ pool_init(uint32_t sid) } static int -frag_pool_init(uint32_t sid) +frag_pool_init(uint32_t sid, uint32_t mpool_buf_num) { int32_t rc; struct rte_mempool *frag_mp; char frag_name[RTE_MEMPOOL_NAMESIZE]; snprintf(frag_name, sizeof(frag_name), "frag_MP%u", sid); - frag_mp = rte_pktmbuf_pool_create(frag_name, MPOOL_NB_BUF, + frag_mp = rte_pktmbuf_pool_create(frag_name, mpool_buf_num, MPOOL_CACHE_SIZE, 0, FRAG_MBUF_BUF_SIZE, sid - 1); if (frag_mp == NULL) { rc = -rte_errno; @@ -406,13 +405,13 @@ netbe_port_init(struct netbe_cfg *cfg) assert(sid < RTE_DIM(mpool)); if (mpool[sid] == NULL) { - rc = pool_init(sid); + rc = pool_init(sid, cfg->mpool_buf_num); if (rc != 0) return rc; } if (frag_mpool[sid] == NULL) { - rc = frag_pool_init(sid); + rc = frag_pool_init(sid, cfg->mpool_buf_num); if (rc != 0) return rc; } diff --git a/examples/l4fwd/test/config.sh b/examples/l4fwd/test/config.sh index fef8fda..ca62e3d 100644 --- a/examples/l4fwd/test/config.sh +++ b/examples/l4fwd/test/config.sh @@ -9,17 +9,28 @@ DPDK_PORT=0 TCP_PORT=6000 # local interface addresses to set -LOCAL_IPV4=192.168.1.60 -LOCAL_IPV6=fd12:3456:789a:0001:0000:0000:0000:0060 +L4FWD_IPV4=192.168.2.60 +L4FWD_IPV6=fd12:3456:789a:0002:0000:0000:0000:0060 # remote interface addresses to set -REMOTE_IPV4=192.168.1.64 -REMOTE_IPV6=fd12:3456:789a:0001:0000:0000:0000:0064 +LINUX_IPV4=192.168.2.64 +LINUX_IPV6=fd12:3456:789a:0002:0000:0000:0000:0064 # mask length for addresses of each IP version MASK_IPV4=24 MASK_IPV6=64 +# Interface tap/remote +IFACE="" + +# should tap mode be used (1 - use tap interface, 0 - use real NIC) +USE_TAP=0 + +# MAC address for tap interface - filled when tap is created +LINUX_MAC="00:64:74:61:70:30" +# fake MAC address to provide in neighbours +FAKE_MAC="00:64:74:61:70:33" + # name of the config files for backend and frontend of l4fwd app L4FWD_BE_CFG_FILE=$(mktemp) L4FWD_FE_CFG_FILE=$(mktemp) @@ -40,6 +51,15 @@ then exit 127 fi +# set interface based on mode used +if [[ "${ETH_DEV}" == "tap" ]] +then + IFACE=l4fwd_tap0 + USE_TAP=1 +else + IFACE=${REMOTE_IFACE} +fi + # check if L4FWD_PATH points to an executable if [[ ! -x ${L4FWD_PATH} ]] then @@ -47,23 +67,27 @@ then exit 127 fi -# check if REMOTE_HOST is reachable -ssh ${REMOTE_HOST} echo -st=$? -if [[ $st -ne 0 ]] +# neccesary check for real NIC mode +if [[ ${USE_TAP} -eq 0 ]] then - echo "host ${REMOTE_HOST} is not reachable" - exit $st -fi + # check if REMOTE_HOST is reachable + ssh ${REMOTE_HOST} echo + st=$? + if [[ $st -ne 0 ]] + then + echo "host ${REMOTE_HOST} is not reachable" + exit $st + fi -# get ethernet address of REMOTE_HOST -REMOTE_MAC=$(ssh ${REMOTE_HOST} ip addr show dev ${REMOTE_IFACE}) -st=$? -REMOTE_MAC=$(echo ${REMOTE_MAC} | sed -e 's/^.*ether //' -e 's/ brd.*$//') -if [[ $st -ne 0 || -z "${REMOTE_MAC}" ]] -then - echo "could not retrive ethernet address from ${REMOTE_IFACE}" - exit 127 + # get ethernet address of REMOTE_HOST + LINUX_MAC=$(ssh ${REMOTE_HOST} ip addr show dev ${IFACE}) + st=$? + LINUX_MAC=$(echo ${LINUX_MAC} | sed -e 's/^.*ether //' -e 's/ brd.*$//') + if [[ $st -ne 0 || -z "${LINUX_MAC}" ]] + then + echo "could not retrive ethernet address from ${IFACE}" + exit 127 + fi fi # check if FECORE is set - default 0 @@ -77,7 +101,7 @@ L4FWD_BECORE=${L4FWD_BECORE:-${L4FWD_FECORE}} # set file for l4fwd app output L4FWD_OUT_FILE=./l4fwd.out # set rbufs/sbufs/streams to open for l4fwd -L4FWD_STREAMS='--rbufs 0x100 --sbufs 0x100 --streams 0x100' +L4FWD_STREAMS='--mbuf-num 0x2000 --rbufs 0x100 --sbufs 0x100 --streams 0x100' # set lcores for DPDK to start if [[ ${L4FWD_FECORE} -ne ${L4FWD_BECORE} ]] @@ -87,8 +111,22 @@ else L4FWD_LCORE="${L4FWD_FECORE}" fi +L4FWD_TAP="" + +# set eal parameters specific for mode used +if [[ ${USE_TAP} -eq 0 ]] +then + L4FWD_DEV="${ETH_DEV}" +else + L4FWD_DEV="--no-pci --vdev=\"net_tap0,iface=${IFACE},\ +mac=\"${LINUX_MAC}\"\"" +fi + # set EAL parameters -L4FWD_CMD_EAL_PRM="--lcores='${L4FWD_LCORE}' -n 4 ${ETH_DEV}" +L4FWD_CMD_EAL_PRM="--lcores='${L4FWD_LCORE}' -n 4 ${L4FWD_DEV}" + +# interface to wait for until it is set up properly +L4FWD_WAIT_VDEV="${IFACE}" # l4fwd parameters (listen, TCP only, enable arp, promiscuous) L4FWD_CMD_PRM="--listen --tcp --enable-arp --promisc ${L4FWD_STREAMS}" @@ -100,21 +138,31 @@ L4FWD_CONFIG="--fecfg ${L4FWD_FE_CFG_FILE} --becfg ${L4FWD_BE_CFG_FILE}" if [[ ${ipv4} -eq 1 ]] then L4FWD_PORT_PRM="port=${DPDK_PORT},lcore=${L4FWD_BECORE},rx_offload=0x0\ -,tx_offload=0x0,ipv4=${LOCAL_IPV4}" +,tx_offload=0x0,ipv4=${L4FWD_IPV4}" elif [[ ${ipv6} -eq 1 ]] then L4FWD_PORT_PRM="port=${DPDK_PORT},lcore=${L4FWD_BECORE},rx_offload=0x0\ -,tx_offload=0x0,ipv6=${LOCAL_IPV6}" +,tx_offload=0x0,ipv6=${L4FWD_IPV6}" fi # other variables-------------------------------------------------------------- +# function to run command with ssh <remote> if needed +use_ssh() +{ + if [[ ${USE_TAP} -eq 1 ]] + then + "$@" + else + ssh ${REMOTE_HOST} "$*" + fi +} + # check if directories on remote are set, if not make one -ssh ${REMOTE_HOST} mkdir -p {${REMOTE_OUTDIR},${REMOTE_RESDIR}} +use_ssh mkdir -p {${REMOTE_OUTDIR},${REMOTE_RESDIR}} # <tc qdisc ... netem ...> instruction to set -netem="ssh ${REMOTE_HOST} tc qdisc add dev ${REMOTE_IFACE} \ -root netem limit 100000" +netem="tc qdisc add dev ${IFACE} root netem limit 100000" # setting for scp which suppresses output of scp when not in verbose mode if [[ ${verbose} -eq 1 ]] @@ -135,12 +183,13 @@ fi # set address to use by netcat if [[ ${ipv4} -eq 1 ]] then - nc_addr=${LOCAL_IPV4} + nc_addr=${L4FWD_IPV4} elif [[ ${ipv6} -eq 1 ]] then - nc_addr=${LOCAL_IPV6} + nc_addr=${L4FWD_IPV6} fi +# calculate network address let "ipv4_elem=(${MASK_IPV4}/8)" let "ipv6_elem=(${MASK_IPV6}/16)" let "ipv4_elem_rev=4-${ipv4_elem}" @@ -151,9 +200,18 @@ while [[ ${ipv4_elem_rev} -ne 0 ]]; do let "ipv4_elem_rev=${ipv4_elem_rev}-1" done -ipv4_network=$(echo ${REMOTE_IPV4} | cut -d. -f-${ipv4_elem} | \ +ipv4_network=$(echo ${LINUX_IPV4} | cut -d. -f-${ipv4_elem} | \ sed 's#.*#&'"${ipv4_append}"'#') -ipv6_network=$(echo ${REMOTE_IPV6} | cut -d: -f-${ipv6_elem} | sed 's#.*#&::#') +ipv6_network=$(echo ${LINUX_IPV6} | cut -d: -f-${ipv6_elem} | sed 's#.*#&::#') + +# create temporary result file for tap mode, and/or set common file name +if [[ ${USE_TAP} -eq 0 ]] +then + common_result_file="${REMOTE_RESDIR}/results.out" +else + > ${local_result_file} + common_result_file=${local_result_file} +fi # helper functions------------------------------------------------------------- @@ -174,18 +232,33 @@ update_results() it=$3 # get only 'real' time in results file - $(ssh ${REMOTE_HOST} "awk '/real/{print \$2}' \ - ${REMOTE_RESDIR}/${file}.result.${it} \ - >> ${REMOTE_RESDIR}/results.out") + if [[ ${USE_TAP} -eq 0 ]] + then + $(ssh ${REMOTE_HOST} "awk '/real/{print \$2}' \ +${REMOTE_RESDIR}/${file}.result.${it} >> ${common_result_file}") + else + awk '/real/{print $2}' ${REMOTE_RESDIR}/${file}.result.${it} \ + >> ${common_result_file} + fi # add file and status of test to results if [[ ${status} -ne 0 ]] then - $(ssh ${REMOTE_HOST} "sed -i '$ s_.*_[FAIL]\t&_' \ - ${REMOTE_RESDIR}/results.out") + if [[ ${USE_TAP} -eq 0 ]] + then + $(ssh ${REMOTE_HOST} "sed -i '$ s_.*_[FAIL]\t&_' \ +${common_result_file}") + else + sed -i '$ s_.*_[FAIL]\t&_' ${common_result_file} + fi else - $(ssh ${REMOTE_HOST} "sed -i '$ s_.*_[OK]\t&_' \ - ${REMOTE_RESDIR}/results.out") + if [[ ${USE_TAP} -eq 0 ]] + then + $(ssh ${REMOTE_HOST} "sed -i '$ s_.*_[OK]\t&_' \ +${common_result_file}") + else + sed -i '$ s_.*_[OK]\t&_' ${common_result_file} + fi fi length=$(expr length "${file}") @@ -196,13 +269,21 @@ update_results() tab="\t" fi - $(ssh ${REMOTE_HOST} "sed -i '$ s_.*_${file}${tab}&_' \ - ${REMOTE_RESDIR}/results.out") + if [[ ${USE_TAP} -eq 0 ]] + then + $(ssh ${REMOTE_HOST} "sed -i '$ s_.*_${file}${tab}&_' \ +${common_result_file}") + else + sed -i "$ s_.*_${file}${tab}&_" ${common_result_file} + fi } # start l4fwd app l4fwd_start() { + # make configuration files for be/fe + configure_be_fe + # create temporary file for command running l4fwd L4FWD_EXEC_FILE=$(mktemp) @@ -229,6 +310,20 @@ EOF rm -f ${L4FWD_EXEC_FILE} exit 127 fi + + if [[ ${USE_TAP} -eq 1 ]] + then + # check if tap interface is up + i=0 + st=1 + while [[ ${i} -ne 5 && ${st} -ne 0 ]] + do + sleep 1 + ip link show dev ${L4FWD_WAIT_VDEV} > /dev/null 2>&1 + st=$? + let i++ + done + fi } # stop l4fwd app @@ -236,7 +331,7 @@ l4fwd_stop() { # kill runnning l4fwd app kill -s SIGINT ${L4FWD_PID} - + sleep 1 # remove temporary files rm -f ${L4FWD_EXEC_FILE} rm -f ${L4FWD_FE_CFG_FILE} @@ -246,13 +341,8 @@ l4fwd_stop() # helper function to set netem on remote setup_netem() { - # remove netem settings from remote interface if any - check_netem=$(ssh ${REMOTE_HOST} "tc qdisc show dev \ - ${REMOTE_IFACE} | grep netem") - if [[ -n ${check_netem} ]] - then - ssh ${REMOTE_HOST} tc qdisc del dev ${REMOTE_IFACE} root - fi + # remove netem settings from interface + use_ssh tc qdisc del dev ${IFACE} root # set default delay for reorder if [[ ${reorder} -ne 0 && ${delay} -eq 0 ]] @@ -284,35 +374,42 @@ setup_netem() netem="${netem} reorder 100% gap ${reorder}" fi - # set netem on remote - ${netem} + # set netem + use_ssh ${netem} # visual break of the output if_verbose echo -e "\nNetwork rules on remote set to:" # print current netem settings - if_verbose ssh ${REMOTE_HOST} tc qdisc show dev ${REMOTE_IFACE} + if_verbose use_ssh tc qdisc show dev ${IFACE} } -# configure IPv4 remote machine -configure_ip4_remote() +# configure IPv4 interface +configure_l4fwd_ip4() { # visual break of the output - if_verbose echo "Setting interface on remote" + if_verbose echo "Setting IPv4 interface" # set remote interface with correct IP address - ssh ${REMOTE_HOST} ip link set ${REMOTE_IFACE} down - ssh ${REMOTE_HOST} ip addr flush dev ${REMOTE_IFACE} - ssh ${REMOTE_HOST} ip addr add ${REMOTE_IPV4}/${MASK_IPV4} \ - dev ${REMOTE_IFACE} - ssh ${REMOTE_HOST} ip link set ${REMOTE_IFACE} up - if_verbose ssh ${REMOTE_HOST} ip addr show dev ${REMOTE_IFACE} - - ssh ${REMOTE_HOST} ip neigh flush dev ${REMOTE_IFACE} - ssh ${REMOTE_HOST} iptables --flush + if [[ ${USE_TAP} -eq 0 ]] + then + ssh ${REMOTE_HOST} ip link set ${IFACE} down + ssh ${REMOTE_HOST} ip addr flush dev ${IFACE} + ssh ${REMOTE_HOST} ip addr add ${LINUX_IPV4}/${MASK_IPV4} \ +dev ${IFACE} + ssh ${REMOTE_HOST} ip link set ${IFACE} up + ssh ${REMOTE_HOST} ip neigh flush dev ${IFACE} + else + ip addr add ${LINUX_IPV4}/${MASK_IPV4} dev ${IFACE} + ip link set ${IFACE} up + ip neigh flush dev ${IFACE} + ip neigh add ${L4FWD_IPV4} dev ${IFACE} lladdr ${FAKE_MAC} + fi - ssh ${REMOTE_HOST} ip route change ${ipv4_network}/${MASK_IPV4} dev \ - ${REMOTE_IFACE} rto_min 30ms + use_ssh iptables --flush + use_ssh ip route change ${ipv4_network}/${MASK_IPV4} dev ${IFACE} \ +rto_min 30ms + if_verbose use_ssh ip addr show dev ${IFACE} # construct <tc qdisc ... nete ...> instruction if [[ set_netem -eq 1 ]] @@ -324,32 +421,40 @@ configure_ip4_remote() sleep 1 } -# configure IPv6 remote machine -configure_ip6_remote() +# configure IPv6 interface +configure_l4fwd_ip6() { # visual break of the output - if_verbose echo "Setting interface on remote" + if_verbose echo "Setting IPv6 interface" # set remote interface with correct IP address - ssh ${REMOTE_HOST} ip link set ${REMOTE_IFACE} down - ssh ${REMOTE_HOST} sysctl -q -w \ - net.ipv6.conf.${REMOTE_IFACE}.disable_ipv6=0 - ssh ${REMOTE_HOST} ip addr flush dev ${REMOTE_IFACE} - ssh ${REMOTE_HOST} ip -6 addr add ${REMOTE_IPV6}/${MASK_IPV6} \ - dev ${REMOTE_IFACE} - ssh ${REMOTE_HOST} ip -6 link set ${REMOTE_IFACE} up - if_verbose ssh ${REMOTE_HOST} ip addr show dev ${REMOTE_IFACE} - - ssh ${REMOTE_HOST} ip neigh flush dev ${REMOTE_IFACE} - ssh ${REMOTE_HOST} ip -6 neigh add ${LOCAL_IPV6} dev ${REMOTE_IFACE} \ - lladdr ${LOCAL_MAC} - ssh ${REMOTE_HOST} iptables --flush - ssh ${REMOTE_HOST} ip6tables --flush - - ssh ${REMOTE_HOST} ip route change ${ipv6_network}/${MASK_IPV6} dev \ - ${REMOTE_IFACE} proto kernel metric 256 rto_min 30ms - - ssh ${REMOTE_HOST} ip -6 route show + if [[ ${USE_TAP} -eq 0 ]] + then + ssh ${REMOTE_HOST} ip link set ${IFACE} down + ssh ${REMOTE_HOST} sysctl -q -w \ +net.ipv6.conf.${IFACE}.disable_ipv6=0 + ssh ${REMOTE_HOST} ip addr flush dev ${IFACE} + ssh ${REMOTE_HOST} ip -6 addr add ${LINUX_IPV6}/${MASK_IPV6} \ +dev ${IFACE} + ssh ${REMOTE_HOST} ip -6 link set ${IFACE} up + ssh ${REMOTE_HOST} ip neigh flush dev ${IFACE} + ssh ${REMOTE_HOST} ip -6 neigh add ${L4FWD_IPV6} dev ${IFACE} \ +lladdr ${LOCAL_MAC} + else + sysctl -q -w net.ipv6.conf.${IFACE}.disable_ipv6=0 + ip addr flush dev ${IFACE} + ip -6 addr add ${LINUX_IPV6}/${MASK_IPV6} dev ${IFACE} + ip -6 link set ${IFACE} up + ip neigh flush dev ${IFACE} + ip -6 neigh add ${L4FWD_IPV6} dev ${IFACE} lladdr ${FAKE_MAC} + fi + + use_ssh iptables --flush + use_ssh ip6tables --flush + + use_ssh ip route change ${ipv6_network}/${MASK_IPV6} dev \ +${IFACE} proto kernel metric 256 rto_min 30ms + if_verbose use_ssh ip addr show dev ${IFACE} # construct <tc qdisc ... nete ...> instruction if [[ set_netem -eq 1 ]] @@ -357,36 +462,28 @@ configure_ip6_remote() setup_netem fi - # give linux 1 sec to handle all network settings - sleep 1 + # give linux 3 sec to handle all network settings + sleep 3 } -# configure remote -configure_remote() + +# configure tap interfaces +configure_interfaces() { # call proper configuration if [[ ${ipv4} -eq 1 ]] then - configure_ip4_remote - - if_verbose echo -e "\nBE configuration:" - config4_be - - if_verbose echo -e "\nFE configuration:" - config4_fe + configure_l4fwd_ip4 elif [[ ${ipv6} -eq 1 ]] then - configure_ip6_remote - - if_verbose echo -e "\nBE configuration:" - config6_be - - if_verbose echo -e "\nFE configuration:" - config6_fe + configure_l4fwd_ip6 fi # create empty results file on remote - $(ssh ${REMOTE_HOST} "> ${REMOTE_RESDIR}/results.out") + if [[ ${USE_TAP} -eq 0 ]] + then + $(ssh ${REMOTE_HOST} "> ${common_result_file}") + fi } # restore netem settings to default @@ -394,21 +491,41 @@ restore_netem() { if [[ ${set_netem} -eq 1 ]] then - ssh ${REMOTE_HOST} tc qdisc del dev ${REMOTE_IFACE} root + use_ssh tc qdisc del dev ${IFACE} root fi } # remove created directories after test is done remove_directories() { - ssh ${REMOTE_HOST} rm -fr ${REMOTE_DIR} + use_ssh rm -fr ${REMOTE_DIR} } # configuration of be/fe config------------------------------------------------ +configure_be_fe() +{ + # call proper configuration + if [[ ${ipv4} -eq 1 ]] + then + if_verbose echo -e "\nBE configuration:" + config4_be + + if_verbose echo -e "\nFE configuration:" + config4_fe + elif [[ ${ipv6} -eq 1 ]] + then + if_verbose echo -e "\nBE configuration:" + config6_be + + if_verbose echo -e "\nFE configuration:" + config6_fe + fi +} + config4_be() { - cat <<EOF > ${L4FWD_BE_CFG_FILE} -port=${DPDK_PORT},masklen=${MASK_IPV4},addr=${REMOTE_IPV4},mac=${REMOTE_MAC} + cat <<EOF > ${L4FWD_BE_CFG_FILE} +port=${DPDK_PORT},masklen=${MASK_IPV4},addr=${LINUX_IPV4},mac=${LINUX_MAC} EOF if_verbose cat ${L4FWD_BE_CFG_FILE} @@ -416,8 +533,8 @@ EOF config6_be() { - cat <<EOF > ${L4FWD_BE_CFG_FILE} -port=${DPDK_PORT},masklen=${MASK_IPV6},addr=${REMOTE_IPV6},mac=${REMOTE_MAC} + cat <<EOF > ${L4FWD_BE_CFG_FILE} +port=${DPDK_PORT},masklen=${MASK_IPV6},addr=${LINUX_IPV6},mac=${LINUX_MAC} EOF if_verbose cat ${L4FWD_BE_CFG_FILE} @@ -426,8 +543,8 @@ EOF config4_fe() { cat <<EOF > ${L4FWD_FE_CFG_FILE} -lcore=${L4FWD_FECORE},belcore=${L4FWD_BECORE},op=echo,laddr=${LOCAL_IPV4}\ -,lport=${TCP_PORT},raddr=${REMOTE_IPV4},rport=0 +lcore=${L4FWD_FECORE},belcore=${L4FWD_BECORE},op=echo,laddr=${L4FWD_IPV4}\ +,lport=${TCP_PORT},raddr=${LINUX_IPV4},rport=0 EOF if_verbose cat ${L4FWD_FE_CFG_FILE} @@ -436,8 +553,8 @@ EOF config6_fe() { cat <<EOF > ${L4FWD_FE_CFG_FILE} -lcore=${L4FWD_FECORE},belcore=${L4FWD_BECORE},op=echo,laddr=${LOCAL_IPV6}\ -,lport=${TCP_PORT},raddr=${REMOTE_IPV6},rport=0 +lcore=${L4FWD_FECORE},belcore=${L4FWD_BECORE},op=echo,laddr=${L4FWD_IPV6}\ +,lport=${TCP_PORT},raddr=${LINUX_IPV6},rport=0 EOF if_verbose cat ${L4FWD_FE_CFG_FILE} diff --git a/examples/l4fwd/test/example_env_vars b/examples/l4fwd/test/example_env_vars index 9877db8..82e0e85 100644 --- a/examples/l4fwd/test/example_env_vars +++ b/examples/l4fwd/test/example_env_vars @@ -2,12 +2,19 @@ # ENV VARIABLES -export REMOTE_HOST=root@10.237.214.104 -export REMOTE_IFACE=enp138s0f0 -export LOCAL_MAC="68:05:ca:04:47:02" +# configuration for tap interface +export ETH_DEV="tap" export L4FWD_PATH=/opt/home/md/Projects/tldk/BuildForTLDK/app/l4fwd export L4FWD_FECORE=5 #optional export L4FWD_BECORE=6 #optional -export ETH_DEV="-w 8a:00.0" + +# configuration for real NIC +#export ETH_DEV="-w 8a:00.0" +#export L4FWD_PATH=/opt/home/md/Projects/tldk/BuildForTLDK/app/l4fwd +#export REMOTE_HOST=root@10.237.214.104 #required for real NIC only +#export REMOTE_IFACE=enp138s0f0 #required for real NIC only +#export LOCAL_MAC="68:05:ca:04:47:02" #required for real NIC only +#export L4FWD_FECORE=5 #optional +#export L4FWD_BECORE=6 #optional # ENV VARIABLES end diff --git a/examples/l4fwd/test/nctxrx.sh b/examples/l4fwd/test/nctxrx.sh index 6a016e0..98f84c2 100644 --- a/examples/l4fwd/test/nctxrx.sh +++ b/examples/l4fwd/test/nctxrx.sh @@ -8,41 +8,54 @@ # script with -h (help) # # User needs to specify following environment variables: -# ETH_DEV - ethernet device to be used on SUT by DPDK +# L4FWD_PATH - path to l4fwd app binary +# ETH_DEV - for real NIC usage - ethernet device to be used on SUT by DPDK +# - for tap interface - tap +# +# User needs to set following enviroment variables in case of real NIC usage: # REMOTE_HOST - ip/hostname of DUT # REMOTE_IFACE - interface name for the test-port on DUT # LOCAL_MAC - MAC address used by DPDK -# L4FWD_PATH - path to l4fwd app binary +# # Optional envirenment variables: # L4FWD_FECORE - core on which l4fwd frontend should run # L4FWD_BECORE - core on which l4fwd backend should run # -# The purpose of the script is to automate validation tests for l4fwd app -# where packets are out of order/lost. It expects l4fwd application being -# run on local linux system (SUT). Script is operating on remote linux -# machine (DUT) with use of ssh. SUT and DUT are connected via NIC. On SUT -# network traffic is managed by DPDK and on DUT by linux. On DUT netcat is -# used to send test data via TCP to TLDK on SUT, which is set to echo mode +# The purpose of the script is to automate validation tests for l4fwd app where +# packets are out of order/lost. Script is operating on local linux machine only +# or on local and remote machine (depending on enviroment variables). +# +# For local machine only, l4fwd application is being run by the script, which +# sets up the tap interface. Created interface is serving a connection for l4fwd +# and netcat within the same OS. +# +# For local/remote linux machine mode, script uses real NIC specified in +# enviroment variable. Connection with remote machine is made via ssh. L4fwd app +# is being run on local machine, while interface and netcat are being set on +# remote side (operated by linux). +# +# Netcat is used to send test data via TCP to l4fwd, which is set to echo mode # (sends back the same data). Depending on test specified, TCP segments are -# artificially changed in sending buffer of DUT, so they are lost in some -# percentage or sent out of order. If specified, report is sent from DUT -# to SUT after all tests were performed. +# artificially changed inside sending buffer, so they are lost in some +# percentage or sent out of order. Report is printed after all tests were +# performed. # -# Example traffic visualisation: -# DUT --(TCP out of order)--> SUT --(TCP with correct order)--> DUT(validation) +# Example of traffic visualisation +# Netcat(TAP/NIC) --(TCP out of order)--> (TAP/NIC)L4FWD(TAP/NIC) -- +# --(TCP with correct order)--> (TAP/NIC)Netcat(validation) # options which can be changed by the user if needed--------------------------- # timeout in [s] for calling nc (in case traffic stuck) timeout=600 -# delay for netem (50 [ms] is default value when reorder option used) +# delay for netem (20 [ms] is default value when reorder option used) delay=0 # default loss of packets [%] value loss=0 -# default probability [%] of not losing burst of packets +# default probability [%] of not loosing burst of packets loss_burst=80 # variables used by script----------------------------------------------------- @@ -55,7 +68,7 @@ rmresults="" set_netem=0 # flag to check if default files should to be used (default 1) -# default files are generated with urandom (couple of sizes) +# default files are generated with urandom default_file=1 # IP protocol version @@ -160,7 +173,7 @@ done # load configuration . $(dirname $0)/config.sh -# send file with results to local machine +# send file with results to local machine when in real NIC mode send_results() { if_verbose echo -e "Sending result file to local" @@ -185,7 +198,7 @@ run_test() # -q 0 -> wait 0 seconds after EOF and quit # timeout to deal with hanging connection when sth went wrong # feed netcat with {of} file to send - # receiving end is redirected to out/...out files + # receiving end is redirected to out/...out file # 'exec' for redirecting nc err output to not mess result cmd="exec 4>&2 \$({ time timeout ${timeout} nc ${nc_ipv6} -q 0 ${nc_addr} ${TCP_PORT} \ @@ -195,13 +208,18 @@ run_test() exec 4>&-" # create temporary file for nc command to execute - xf=$(ssh ${REMOTE_HOST} mktemp -p ${REMOTE_DIR}) + xf=$(use_ssh mktemp -p ${REMOTE_DIR}) # store command from {cmd} into temporaty file - echo "${cmd}" | ssh ${REMOTE_HOST} "cat > ${xf}" + if [[ ${USE_TAP} -eq 0 ]] + then + echo "${cmd}" | ssh ${REMOTE_HOST} "cat > ${xf}" + else + echo "${cmd}" | cat > ${xf} + fi # execute nc command in the background - ssh ${REMOTE_HOST} /bin/bash ${xf} & + use_ssh /bin/bash ${xf} & pids="${pids} $!" @@ -219,7 +237,7 @@ exec 4>&-" wait ${pids} # remove temporary files - ssh ${REMOTE_HOST} rm -f ${rmxf} + use_ssh rm -f ${rmxf} # visual break if_verbose echo -e "\nNetstat:" @@ -227,13 +245,13 @@ exec 4>&-" # prints network information for given {TCP_PORT} number # -n -> show numeric addresses # -a -> show all (both listening and non-listening sockets) - if_verbose ssh ${REMOTE_HOST} netstat -na | grep ${TCP_PORT} + if_verbose use_ssh netstat -na | grep ${TCP_PORT} # visual break if_verbose echo -e "\nJobs:" # display status of jobs in the current session (this bash script) - if_verbose ssh ${REMOTE_HOST} jobs -l + if_verbose use_ssh jobs -l # visual break if_verbose echo -e "\nNetcat processes:" @@ -242,7 +260,7 @@ exec 4>&-" # -e -> show all processes # -f -> do full format listing (more info) # grep -v -> get rid of the following word match from grep output - if_verbose ssh ${REMOTE_HOST} ps -ef | grep "nc " | grep -v grep + if_verbose use_ssh ps -ef | grep "nc " | grep -v grep # visual break if_verbose echo -e "\nRunning validation" @@ -252,13 +270,12 @@ exec 4>&-" while [[ ${i} -lt ${num} ]] do # prints checksum of sent and received file - if_verbose ssh ${REMOTE_HOST} cksum ${REMOTE_DIR}/${of} \ + if_verbose use_ssh cksum ${REMOTE_DIR}/${of} \ ${REMOTE_OUTDIR}/${of}.out.${i} # compares sent and received files if they match # compare {of} and {out/of.out.i} line by line - ssh ${REMOTE_HOST} diff ${REMOTE_DIR}/${of} \ - ${REMOTE_OUTDIR}/${of}.out.${i} + use_ssh diff ${REMOTE_DIR}/${of} ${REMOTE_OUTDIR}/${of}.out.${i} # capture the result of diff command above rc=$? @@ -280,15 +297,15 @@ exec 4>&-" fi # remove received file from out/ directory - ssh ${REMOTE_HOST} rm -f ${REMOTE_OUTDIR}/${of}.out.${i} + use_ssh rm -f ${REMOTE_OUTDIR}/${of}.out.${i} i=$(expr $i + 1) done # remove temporary results - ssh ${REMOTE_HOST} rm -f ${rmresults} + use_ssh rm -f ${rmresults} - if [[ flag_error -eq 1 ]] + if [[ flag_error -ne 0 ]] then return ${flag_error} fi @@ -296,13 +313,17 @@ exec 4>&-" if_verbose echo "" echo -e "TEST SUCCESSFUL - ${of}" if_verbose echo "" + return 0 } # clean up after error or end of tests cleanup() { - send_results + if [[ ${USE_TAP} -eq 0 ]] + then + send_results + fi restore_netem l4fwd_stop remove_directories @@ -310,17 +331,20 @@ cleanup() # script start----------------------------------------------------------------- -#configure remote machine -configure_remote - # start l4fwd app l4fwd_start +#configure configure tap interfaces +configure_interfaces + # check if default files should be used if [[ ${default_file} -eq 0 ]] then if_verbose echo -e "Sending test file to remote" - scp ${scp_suppress} ${file} ${REMOTE_HOST}:${REMOTE_DIR} + if [[ ${USE_TAP} -eq 0 ]] + then + scp ${scp_suppress} ${file} ${REMOTE_HOST}:${REMOTE_DIR} + fi run_test ${file} # check test outcome @@ -330,17 +354,17 @@ then cleanup exit ${ret} fi - ssh ${REMOTE_HOST} rm -f ${REMOTE_DIR}/${file} + use_ssh rm -f ${REMOTE_DIR}/${file} else - # use default files with size 16MB - for size in 16 + # use default files with size 8MB + for size in 8 do # generate file - if_verbose echo -e "Generating ${size}MB file for test" - x=$(ssh ${REMOTE_HOST} mktemp $(basename $0).${size}MB.XXX \ + if_verbose echo -e "\nGenerating ${size}MB file for test" + x=$(use_ssh mktemp $(basename $0).${size}MB.XXX \ -p ${REMOTE_DIR}) - ssh ${REMOTE_HOST} dd if=/dev/urandom of=${x} bs=1M \ + use_ssh dd if=/dev/urandom of=${x} bs=1M \ count=${size} ${dd_suppress} # run test over generated file @@ -355,7 +379,7 @@ else fi # remove generated file only if test successful - ssh ${REMOTE_HOST} rm -f ${x} + use_ssh rm -f ${x} done fi diff --git a/examples/l4fwd/test/run_test.sh b/examples/l4fwd/test/run_test.sh index 690651a..7e892e6 100644 --- a/examples/l4fwd/test/run_test.sh +++ b/examples/l4fwd/test/run_test.sh @@ -2,18 +2,22 @@ # readme section--------------------------------------------------------------- -# usage: /bin/bash run_test.sh [-46lrh] +# usage: /bin/bash run_test.sh [-46alrh] # # Run all tests using nctxrx.sh. Report stored and printed # after tests were done. For details about options run # script with -h (help) # # User needs to specify following environment variables: -# ETH_DEV - ethernet device to be used on SUT by DPDK +# L4FWD_PATH - path to l4fwd app binary +# ETH_DEV - for real NIC usage - ethernet device to be used on SUT by DPDK +# - for tap interface - tap +# +# User needs to set following enviroment variables in case of real NIC usage: # REMOTE_HOST - ip/hostname of DUT # REMOTE_IFACE - interface name for the test-port on DUT # LOCAL_MAC - MAC address used by DPDK -# L4FWD_PATH - path to l4fwd app binary +# # Optional envirenment variables: # L4FWD_FECORE - core on which l4fwd frontend should run # L4FWD_BECORE - core on which l4fwd backend should run @@ -203,7 +207,7 @@ do then echo -e "\nTest for reorder: ${reorder}\t[OK]" else - echo -e "\nTest for reorder: $reorder}\t[FAIL]" + echo -e "\nTest for reorder: ${reorder}\t[FAIL]" error_count=$(expr ${error_count} + 1) fi @@ -274,5 +278,12 @@ else fi # print report after all tests were done -echo -e "Report\n" +echo -e "Report:\n" cat ${result} + +if [[ ${error_count} -eq 0 ]] +then + exit 0 +else + exit 1 +fi diff --git a/examples/l4fwd/udp.h b/examples/l4fwd/udp.h index c079e9c..2465f08 100644 --- a/examples/l4fwd/udp.h +++ b/examples/l4fwd/udp.h @@ -252,25 +252,25 @@ static inline void netfe_pkt_addr(const struct rte_mbuf *m, struct sockaddr_storage *ps, uint16_t family) { - const struct ipv4_hdr *ip4h; - const struct ipv6_hdr *ip6h; - const struct udp_hdr *udph; + const struct rte_ipv4_hdr *ip4h; + const struct rte_ipv6_hdr *ip6h; + const struct rte_udp_hdr *udph; struct sockaddr_in *in4; struct sockaddr_in6 *in6; NETFE_PKT_DUMP(m); - udph = rte_pktmbuf_mtod_offset(m, struct udp_hdr *, -m->l4_len); + udph = rte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *, -m->l4_len); if (family == AF_INET) { in4 = (struct sockaddr_in *)ps; - ip4h = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *, + ip4h = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, -(m->l4_len + m->l3_len)); in4->sin_port = udph->src_port; in4->sin_addr.s_addr = ip4h->src_addr; } else { in6 = (struct sockaddr_in6 *)ps; - ip6h = rte_pktmbuf_mtod_offset(m, struct ipv6_hdr *, + ip6h = rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *, -(m->l4_len + m->l3_len)); in6->sin6_port = udph->src_port; rte_memcpy(&in6->sin6_addr, ip6h->src_addr, |