examples/ip_fragmentation: fix check of packet type
PATCH 1/1 examples/ip_fragmentation: fix check of packet type
The packet_type in mbuf is not correctly filled by ixgbe 82599 NIC. To use the ether_type in ethernet header to check packet type is more reliaber.
--- examples/ip_fragmentation/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
examples/ip_fragmentation/main.c +6 -4
@@ -268,6 +268,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf,uint32_t i, len, next_hop_ipv4;uint8_t next_hop_ipv6, port_out, ipv6;int32_t len2; +struct ether_hdr *eth_hdr; ipv6 =0 ; rxq = &qconf->rx_queue_list[queueid];
@@ -276,13 +277,14 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf, port_out = port_in;/* Remove the Ethernet header and trailer from the input packet */ + eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);rte_pktmbuf_adj (m, (uint16_t )sizeof (struct ether_hdr ));/* Build transmission burst */ len = qconf->tx_mbufs[port_out].len;/* if this is an IPv4 packet */ -if (RTE_ETH_IS_IPV4_HDR (m->packet_type)) { +if (eth_hdr->ether_type ==rte_cpu_to_be_16 (ETHER_TYPE_IPv4)) {struct ipv4_hdr *ip_hdr;uint32_t ip_dst;/* Read the lookup key (i.e. ip_dst) from the input packet */
@@ -316,7 +318,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf,if (unlikely (len2 <0 ))return ; } - }else if (RTE_ETH_IS_IPV6_HDR (m->packet_type)) { + }else if (eth_hdr->ether_type ==rte_be_to_cpu_16 (ETHER_TYPE_IPv6)) {/* if this is an IPv6 packet */ struct ipv6_hdr *ip_hdr;
@@ -363,8 +365,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf,void *d_addr_bytes; m = qconf->tx_mbufs[port_out].m_table[i]; -struct ether_hdr *eth_hdr = (struct ether_hdr *) -rte_pktmbuf_prepend (m, (uint16_t )sizeof (struct ether_hdr )); + eth_hdr = (struct ether_hdr *)rte_pktmbuf_prepend (m, + (uint16_t )sizeof (struct ether_hdr ));if (eth_hdr ==NULL ) {rte_panic ("No headroom in mbuf.\n" ); }
Signature · 1 line
2.7.4
Sorry, correct the name of Tester
Quoted 10 lines
-----Original Message-----
From: Dai, Wei
Sent: Friday, March 10, 2017 11:28 AM
To: [email protected]; Ananyev, Konstantin <[email protected]>
Cc: Dai, Wei <[email protected]>; [email protected]
Subject: [PATCH] examples/ip_fragmentation: fix check of packet typeThe
packet_typein mbuf is not correctly filled by ixgbe 82599 NIC. To use theether_typein ethernet header to check packet type is more reliaber.
Quoted 7 lines
Fixes 3c0184cc0c60 ("examples: replace some offload flags with packet type")Fixes ab351fe1c95c ("mbuf: remove packet type from offload flags")Reported-by Fangfang Wei <[email protected]>Signed-off-by Wei Dai <[email protected]>
Quoted 59 lines
--- examples/ip_fragmentation/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)examples/ip_fragmentation/main.c +1
-0@@ -268,6 +268,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, structlcore_queue_conf *qconf, uint32_t i, len, next_hop_ipv4;uint8_t next_hop_ipv6, port_out, ipv6;int32_t len2; +struct ether_hdr *eth_hdr; ipv6 =0 ;examples/ip_fragmentation/main.c +2
-1rxq = &qconf->rx_queue_list[queueid];@@ -276,13 +277,14 @@ l3fwd_simple_forward(struct rte_mbuf *m, structlcore_queue_conf *qconf, port_out = port_in;/* Remove the Ethernet header and trailer from the input packet */ + eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);rte_pktmbuf_adj (m, (uint16_t )sizeof (struct ether_hdr ));/* Build transmission burst */ len = qconf->tx_mbufs[port_out].len;/* if this is an IPv4 packet */ -if (RTE_ETH_IS_IPV4_HDR (m->packet_type)) { +if (eth_hdr->ether_type ==rte_cpu_to_be_16 (ETHER_TYPE_IPv4)) {struct ipv4_hdr *ip_hdr;uint32_t ip_dst;/* Read the lookup key (i.e.
ip_dst) from the input packet */ @@
-316,7 +318,7 @@ l3fwd_simple_forward(structrte_mbuf*m, structlcore_queue_conf*qconf,examples/ip_fragmentation/main.c +3
-3if (unlikely (len2 <0 ))return ; } - }else if (RTE_ETH_IS_IPV6_HDR (m->packet_type)) { + }else if (eth_hdr->ether_type ==rte_be_to_cpu_16 (ETHER_TYPE_IPv6)) {/* if this is an IPv6 packet */ struct ipv6_hdr *ip_hdr;@@ -363,8 +365,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf, void *d_addr_bytes; m = qconf->tx_mbufs[port_out].m_table[i]; -struct ether_hdr *eth_hdr = (struct ether_hdr *) -rte_pktmbuf_prepend (m, (uint16_t )sizeof (struct ether_hdr )); + eth_hdr = (struct ether_hdr *)rte_pktmbuf_prepend (m, + (uint16_t )sizeof (struct ether_hdr ));if (eth_hdr ==NULL ) {rte_panic ("No headroom in mbuf.\n" );}
--
2.7.4
Hi Wei,
Quoted 61 lines
-----Original Message-----
From: Dai, Wei
Sent: Friday, March 10, 2017 3:28 AM
To: [email protected]; Ananyev, Konstantin <[email protected]>
Cc: Dai, Wei <[email protected]>; [email protected]
Subject: [PATCH] examples/ip_fragmentation: fix check of packet typeThe
packet_typein mbuf is not correctly filled by ixgbe 82599 NIC. To use theether_typein ethernet header to check packet type is more reliaber.Fixes 3c0184cc0c60 ("examples: replace some offload flags with packet type")Fixes ab351fe1c95c ("mbuf: remove packet type from offload flags")Reported-by Fangfang Wei <[email protected]>Signed-off-by Wei Dai <[email protected]>Tested-by Fagnfang Wei <[email protected]>--- examples/ip_fragmentation/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)examples/ip_fragmentation/main.c +4
-2@@ -268,6 +268,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf,uint32_t i, len, next_hop_ipv4;uint8_t next_hop_ipv6, port_out, ipv6;int32_t len2; +struct ether_hdr *eth_hdr; ipv6 =0 ; rxq = &qconf->rx_queue_list[queueid];@@ -276,13 +277,14 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf, port_out = port_in;/* Remove the Ethernet header and trailer from the input packet */ + eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);rte_pktmbuf_adj (m, (uint16_t )sizeof (struct ether_hdr ));/* Build transmission burst */ len = qconf->tx_mbufs[port_out].len;/* if this is an IPv4 packet */ -if (RTE_ETH_IS_IPV4_HDR (m->packet_type)) { +if (eth_hdr->ether_type ==rte_cpu_to_be_16 (ETHER_TYPE_IPv4)) {struct ipv4_hdr *ip_hdr;uint32_t ip_dst;/* Read the lookup key (i.e. ip_dst) from the input packet */ @@ -316,7 +318,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf,if (unlikely (len2 <0 ))return ; } - }else if (RTE_ETH_IS_IPV6_HDR (m->packet_type)) { + }else if (eth_hdr->ether_type ==rte_be_to_cpu_16 (ETHER_TYPE_IPv6)) {/* if this is an IPv6 packet */ struct ipv6_hdr *ip_hdr;
examples/ip_fragmentation/main.c l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf, · line 372
Quoted 10 lines
examples/ip_fragmentation/main.c +2
-2@@ -363,8 +365,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf,void *d_addr_bytes; m = qconf->tx_mbufs[port_out].m_table[i]; -struct ether_hdr *eth_hdr = (struct ether_hdr *) -rte_pktmbuf_prepend (m, (uint16_t )sizeof (struct ether_hdr )); + eth_hdr = (struct ether_hdr *)rte_pktmbuf_prepend (m, + (uint16_t )sizeof (struct ether_hdr ));if (eth_hdr ==NULL ) {rte_panic ("No headroom in mbuf.\n" ); }
Thanks for the fix.
Would it be more convenient to do what l3fwd does:
Check what ptype capabilities are provided by HW, if no ptype support detected, then install an RX callback?
Konstantin
Quoted 2 lines
--
2.7.4
Hi, Konstantin
I see your point.
I think your method can work.
But I think your method is a bit complex. As you method need to add more codes. Anyway this is a simple bug.
How do you think now ?
Quoted 95 lines
-----Original Message-----
From: Ananyev, Konstantin
Sent: Friday, March 10, 2017 8:21 PM
To: Dai, Wei <[email protected]>; [email protected]
Cc: [email protected]
Subject: RE: [PATCH] examples/ip_fragmentation: fix check of packet typeHi Wei,
examples/ip_fragmentation/main.c l3fwd_simple_forward(struct rte_mbuf *m, struct
Quoted 30 lines
-----Original Message-----
From: Dai, Wei
Sent: Friday, March 10, 2017 3:28 AM
To: [email protected]; Ananyev, Konstantin <[email protected]>
Cc: Dai, Wei <[email protected]>; [email protected]
Subject: [PATCH] examples/ip_fragmentation: fix check of packet typeThe
packet_typein mbuf is not correctly filled by ixgbe 82599 NIC. To use theether_typein ethernet header to check packet type is more reliaber.Fixes 3c0184cc0c60 ("examples: replace some offload flags with packettype")
Fixes ab351fe1c95c ("mbuf: remove packet type from offload flags")Reported-by Fangfang Wei <[email protected]>Signed-off-by Wei Dai <[email protected]>Tested-by Fagnfang Wei <[email protected]>--- examples/ip_fragmentation/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)examples/ip_fragmentation/main.c +0
-0@@ -268,6 +268,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct
lcore_queue_conf*qconf,Quoted 14 lines
examples/ip_fragmentation/main.c +1
-0uint32_t i, len, next_hop_ipv4;uint8_t next_hop_ipv6, port_out, ipv6;int32_t len2; +struct ether_hdr *eth_hdr; ipv6 =0 ; rxq = &qconf->rx_queue_list[queueid]; @@ -276,13 +277,14 @@l3fwd_simple_forward(struct
rte_mbuf*m, structlcore_queue_conf*qconf,examples/ip_fragmentation/main.c +1
-0port_out = port_in;/* Remove the Ethernet header and trailer from the input packet */ + eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);rte_pktmbuf_adj (m, (uint16_t )sizeof (struct ether_hdr ));examples/ip_fragmentation/main.c l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf,
Quoted 10 lines
examples/ip_fragmentation/main.c +1
-2/* Build transmission burst */ len = qconf->tx_mbufs[port_out].len;/* if this is an IPv4 packet */ -if (RTE_ETH_IS_IPV4_HDR (m->packet_type)) { +if (eth_hdr->ether_type ==rte_cpu_to_be_16 (ETHER_TYPE_IPv4)) {struct ipv4_hdr *ip_hdr;uint32_t ip_dst; /* Read the lookup key (i.e. ip_dst) from the input packet */ @@ -316,7 +318,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct
lcore_queue_conf*qconf,examples/ip_fragmentation/main.c l3fwd_simple_forward(struct rte_mbuf *m, struct
Quoted 10 lines
examples/ip_fragmentation/main.c +2
-1if (unlikely (len2 <0 ))return ; } - }else if (RTE_ETH_IS_IPV6_HDR (m->packet_type)) { + }else if (eth_hdr->ether_type ==rte_be_to_cpu_16 (ETHER_TYPE_IPv6)) +{/* if this is an IPv6 packet */ struct ipv6_hdr *ip_hdr;@@ -363,8 +365,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct
lcore_queue_conf*qconf,examples/ip_fragmentation/main.c l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf, · line 372
Quoted 10 lines
examples/ip_fragmentation/main.c +2
-2void *d_addr_bytes; m = qconf->tx_mbufs[port_out].m_table[i]; -struct ether_hdr *eth_hdr = (struct ether_hdr *) -rte_pktmbuf_prepend (m, (uint16_t )sizeof (struct ether_hdr )); + eth_hdr = (struct ether_hdr *)rte_pktmbuf_prepend (m, + (uint16_t )sizeof (struct ether_hdr ));if (eth_hdr ==NULL ) {rte_panic ("No headroom in mbuf.\n" ); }Thanks for the fix.
Would it be more convenient to do what l3fwd does:
Check what ptype capabilities are provided by HW, if no ptype support detected, then install an RX callback?
KonstantinQuoted 2 lines
--
2.7.4
Hi Wei,
Quoted 7 lines
Hi, Konstantin
I see your point.
I think your method can work.
But I think your method is a bit complex. As you method need to add more codes. Anyway this is a simple bug.
How do you think now ?
I still think it is better for all apps to handle this issue in a uniform way. Again in that case for NICs that do support PTYPE offloads the performance should be unaffected. Konstantin
Quoted 96 lines
Quoted 96 lines
-----Original Message-----
From: Ananyev, Konstantin
Sent: Friday, March 10, 2017 8:21 PM
To: Dai, Wei <[email protected]>; [email protected]
Cc: [email protected]
Subject: RE: [PATCH] examples/ip_fragmentation: fix check of packet typeHi Wei,
examples/ip_fragmentation/main.c l3fwd_simple_forward(struct rte_mbuf *m, struct
Quoted 30 lines
-----Original Message-----
From: Dai, Wei
Sent: Friday, March 10, 2017 3:28 AM
To: [email protected]; Ananyev, Konstantin <[email protected]>
Cc: Dai, Wei <[email protected]>; [email protected]
Subject: [PATCH] examples/ip_fragmentation: fix check of packet typeThe
packet_typein mbuf is not correctly filled by ixgbe 82599 NIC. To use theether_typein ethernet header to check packet type is more reliaber.Fixes 3c0184cc0c60 ("examples: replace some offload flags with packettype")
Fixes ab351fe1c95c ("mbuf: remove packet type from offload flags")Reported-by Fangfang Wei <[email protected]>Signed-off-by Wei Dai <[email protected]>Tested-by Fagnfang Wei <[email protected]>--- examples/ip_fragmentation/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)examples/ip_fragmentation/main.c +0
-0@@ -268,6 +268,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct
lcore_queue_conf*qconf,Quoted 14 lines
examples/ip_fragmentation/main.c +1
-0uint32_t i, len, next_hop_ipv4;uint8_t next_hop_ipv6, port_out, ipv6;int32_t len2; +struct ether_hdr *eth_hdr; ipv6 =0 ; rxq = &qconf->rx_queue_list[queueid]; @@ -276,13 +277,14 @@l3fwd_simple_forward(struct
rte_mbuf*m, structlcore_queue_conf*qconf,examples/ip_fragmentation/main.c +1
-0port_out = port_in;/* Remove the Ethernet header and trailer from the input packet */ + eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);rte_pktmbuf_adj (m, (uint16_t )sizeof (struct ether_hdr ));examples/ip_fragmentation/main.c l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf,
Quoted 10 lines
examples/ip_fragmentation/main.c +1
-2/* Build transmission burst */ len = qconf->tx_mbufs[port_out].len;/* if this is an IPv4 packet */ -if (RTE_ETH_IS_IPV4_HDR (m->packet_type)) { +if (eth_hdr->ether_type ==rte_cpu_to_be_16 (ETHER_TYPE_IPv4)) {struct ipv4_hdr *ip_hdr;uint32_t ip_dst; /* Read the lookup key (i.e. ip_dst) from the input packet */ @@ -316,7 +318,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct
lcore_queue_conf*qconf,examples/ip_fragmentation/main.c l3fwd_simple_forward(struct rte_mbuf *m, struct
Quoted 10 lines
examples/ip_fragmentation/main.c +2
-1if (unlikely (len2 <0 ))return ; } - }else if (RTE_ETH_IS_IPV6_HDR (m->packet_type)) { + }else if (eth_hdr->ether_type ==rte_be_to_cpu_16 (ETHER_TYPE_IPv6)) +{/* if this is an IPv6 packet */ struct ipv6_hdr *ip_hdr;@@ -363,8 +365,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct
lcore_queue_conf*qconf,examples/ip_fragmentation/main.c l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf, · line 372
Quoted 10 lines
examples/ip_fragmentation/main.c +2
-2void *d_addr_bytes; m = qconf->tx_mbufs[port_out].m_table[i]; -struct ether_hdr *eth_hdr = (struct ether_hdr *) -rte_pktmbuf_prepend (m, (uint16_t )sizeof (struct ether_hdr )); + eth_hdr = (struct ether_hdr *)rte_pktmbuf_prepend (m, + (uint16_t )sizeof (struct ether_hdr ));if (eth_hdr ==NULL ) {rte_panic ("No headroom in mbuf.\n" ); }Thanks for the fix.
Would it be more convenient to do what l3fwd does:
Check what ptype capabilities are provided by HW, if no ptype support detected, then install an RX callback?
KonstantinQuoted 2 lines
--
2.7.4
Quoted 14 lines
-----Original Message-----
From: Ananyev, Konstantin
Sent: Monday, March 13, 2017 3:02 PM
To: Dai, Wei <[email protected]>; [email protected]
Cc: [email protected]
Subject: RE: [PATCH] examples/ip_fragmentation: fix check of packet typeHi Wei,
Quoted 5 lines
Hi, Konstantin
I see your point.
I think your method can work.
But I think your method is a bit complex. As you method need to add more
Quoted 9 lines
codes.
Quoted 2 lines
Anyway this is a simple bug.
How do you think now ?I still think it is better for all apps to handle this issue in a uniform way. Again in that case for NICs that do support PTYPE offloads the performance should be unaffected.
Konstantin
I have just had a quick look through the l3fwd and didn't find any codes to check what ptypes capabilities ae provided by stuff below DPDK PMD & its base driver. L3fwd only check an input argument "--parse-ptype" to enable ptype check implemented in a Rx callback function.
In this l3fwd rx callback function, it has done the same thing as my code. Anyway, I'd like to provide a v2 patch to deal with this issue in a uniform way.
Thanks & Best Regards
-Wei
Quoted 19 lines
Quoted 9 lines
Hi Wei,
Quoted 5 lines
Hi, Konstantin
I see your point.
I think your method can work.
But I think your method is a bit complex. As you method need to add moreQuoted 9 lines
codes.
Quoted 2 lines
Anyway this is a simple bug.
How do you think now ?I still think it is better for all apps to handle this issue in a uniform way. Again in that case for NICs that do support PTYPE offloads the performance should be unaffected.
Konstantin
Quoted 4 lines
I have just had a quick look through the l3fwd and didn't find any codes to check what ptypes capabilities ae provided by stuff below DPDK PMD & its base driver. L3fwd only check an input argument "--parse-ptype" to enable ptype check implemented in a Rx callback function.
As an example for lpm:
http://dpdk.org/browse/dpdk/tree/examples/l3fwd/l3fwd_lpm.c#n279
Konstantin
Quoted 5 lines
In this l3fwd rx callback function, it has done the same thing as my code. Anyway, I'd like to provide a v2 patch to deal with this issue in a uniform way.
Thanks & Best Regards
-Wei
Quoted 29 lines
-----Original Message-----
From: Ananyev, Konstantin
Sent: Tuesday, March 14, 2017 6:13 AM
To: Dai, Wei <[email protected]>; [email protected]
Cc: [email protected]
Subject: RE: [PATCH] examples/ip_fragmentation: fix check of packet typeQuoted 12 lines
Quoted 12 lines
Hi Wei,
Quoted 6 lines
Hi, Konstantin
I see your point.
I think your method can work.
But I think your method is a bit complex. As you method need to add morecodes.
Quoted 2 lines
Anyway this is a simple bug.
How do you think now ?Quoted 8 lines
Quoted 5 lines
I still think it is better for all apps to handle this issue in a uniform way. Again in that case for NICs that do support PTYPE offloads the performance should be unaffected.
KonstantinI have just had a quick look through the l3fwd and didn't find any codes to check what ptypes capabilities ae provided by stuff below DPDK
Quoted 7 lines
PMD & its base driver.
Quoted 2 lines
L3fwd only check an input argument "--parse-ptype" to enable ptype check implemented in a Rx callback function.
As an example for lpm:
http://dpdk.org/browse/dpdk/tree/examples/l3fwd/l3fwd_lpm.c#n279
Konstantin
Thanks for your guide.
I will use rte_eth_dev_get_supported_ptypes( ) in my v2 patch.
Quoted 7 lines
Quoted 7 lines
In this l3fwd rx callback function, it has done the same thing as my code. Anyway, I'd like to provide a v2 patch to deal with this issue in a uniform way.
Thanks & Best Regards
-Wei