vhost: Fix packet length issue
PATCH 1/1 vhost: Fix packet length issue
As HW vlan strip will reduce the packet length by minus length of vlan tag, so it need restore the packet length by plus it.
--- examples/vhost/main.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
examples/vhost/main.c +14 -3
@@ -1067,6 +1067,7 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag) {struct mbuf_table *tx_q;struct rte_mbuf **m_table; +struct rte_mbuf *last_seg = m;unsigned len, ret, offset =0 ;const uint16_t lcore_id =rte_lcore_id ();struct virtio_net_data_ll *dev_ll = ll_root_used;
@@ -1097,7 +1098,13 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag)rte_pktmbuf_free (m);return ; } - offset =4 ; + +/* +* HW vlan strip will reduce the packet length +* by minus length of vlan tag, so need restore +* the packet length by plus it. +*/ + offset =VLAN_HLEN ; vlan_tag = (uint16_t ) vlan_tags[(uint16_t )dev_ll->vdev->dev->device_fh];
@@ -1121,8 +1128,12 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag) len = tx_q->len; m->ol_flags =PKT_TX_VLAN_PKT ; -/*FIXME: offset*/ - m->data_len += offset; + +while (last_seg->next) + last_seg = last_seg->next; + last_seg->data_len += offset; + m->pkt_len += offset; + m->vlan_tci = vlan_tag; tx_q->m_table[len] = m;
Signature · 1 line
1.8.4.2
A message that is not in the archive (sent off-list or not yet received): 1414659602-10115-1-git-send-email-changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
PATCH v2 1/1 vhost: Fix packet length issue
As HW vlan strip will reduce the packet length by minus length of vlan tag, so it need restore the packet length by plus it.
---
v2 change:
Update data length by plus offset in first segment instead of last segment.
v1 change:
Update the packet length by plus offset.
Use macro to replace constant;
examples/vhost/main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
examples/vhost/main.c +10 -2
@@ -1097,7 +1097,13 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag)rte_pktmbuf_free (m);return ; } - offset =4 ; + +/* +* HW vlan strip will reduce the packet length +* by minus length of vlan tag, so need restore +* the packet length by plus it. +*/ + offset =VLAN_HLEN ; vlan_tag = (uint16_t ) vlan_tags[(uint16_t )dev_ll->vdev->dev->device_fh];
@@ -1121,8 +1127,10 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag) len = tx_q->len; m->ol_flags =PKT_TX_VLAN_PKT ; -/*FIXME: offset*/ + m->data_len += offset; + m->pkt_len += offset; + m->vlan_tci = vlan_tag; tx_q->m_table[len] = m;
Signature · 1 line
1.8.4.2
A message that is not in the archive (sent off-list or not yet received): 1414681176-13965-1-git-send-email-changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
v3 cover Fix packet length issue
This patch set fix packet length issue in vhost app, and enhance code by extracting a function to replace duplicated codes in one copy and zero copy TX function.
-v3 change:
Extract a function to replace duplicated codes in one copy and zero copy TX function
-v2 change:
Update data length by plus offset in first segment instead of last segment.
-v1 change:
Update the packet length by plus offset;
Use macro to replace constant.
Changchun Ouyang (2):
Fix packet length issue in vhost.
Extract a function to replace duplicated codes in vhost.
examples/vhost/main.c | 137 ++++++++++++++++++++++---------------------------- 1 file changed, 61 insertions(+), 76 deletions(-)
Signature · 1 line
1.8.4.2
A message that is not in the archive (sent off-list or not yet received): 1415084708-8192-1-git-send-email-changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
PATCH v3 1/2 vhost: Fix packet length issue
As HW vlan strip will reduce the packet length by minus length of vlan tag, so it need restore the packet length by plus it.
--- examples/vhost/main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
examples/vhost/main.c +10 -2
@@ -1078,7 +1078,13 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag)rte_pktmbuf_free (m);return ; } - offset =4 ; + +/* +* HW vlan strip will reduce the packet length +* by minus length of vlan tag, so need restore +* the packet length by plus it. +*/ + offset =VLAN_HLEN ; vlan_tag = (uint16_t ) vlan_tags[(uint16_t )dev_ll->vdev->dev->device_fh];
@@ -1102,8 +1108,10 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag) len = tx_q->len; m->ol_flags =PKT_TX_VLAN_PKT ; -/*FIXME: offset*/ + m->data_len += offset; + m->pkt_len += offset; + m->vlan_tci = vlan_tag; tx_q->m_table[len] = m;
Signature · 1 line
1.8.4.2
PATCH v3 2/2 vhost: Remove duplicated codes
In reply to a message not in the archiveExtract a function to replace duplicated codes in one copy and zero copy TX function.
--- examples/vhost/main.c | 139 +++++++++++++++++++++----------------------------- 1 file changed, 58 insertions(+), 81 deletions(-)
examples/vhost/main.c +58 -81
@@ -1040,6 +1040,57 @@ virtio_tx_local(struct vhost_dev *vdev, struct rte_mbuf *m) }/* +* Check if the destination MAC of a packet is one local VM, +* and get its vlan tag, and offset if it is. +*/ +static inline int __attribute__((always_inline)) +find_local_dest (struct virtio_net *dev,struct rte_mbuf *m, +uint32_t *offset,uint16_t *vlan_tag) +{ +struct virtio_net_data_ll *dev_ll = ll_root_used; + struct ether_hdr *pkt_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *); + +while (dev_ll !=NULL ) { +if ((dev_ll->vdev->ready ==DEVICE_RX ) + &ðer_addr_cmp (&(pkt_hdr->d_addr), + &dev_ll->vdev->mac_address)) { +/* +* Drop the packet if the TX packet is +* destined for the TX device. +*/ +if (dev_ll->vdev->dev->device_fh == dev->device_fh) { +LOG_DEBUG (VHOST_DATA , +"(%" PRIu64") TX: Source and destination" +" MAC addresses are the same. Dropping " +"packet.\n" , + dev_ll->vdev->dev->device_fh); +return -1 ; + } + +/* +* HW vlan strip will reduce the packet length +* by minus length of vlan tag, so need restore +* the packet length by plus it. +*/ + *offset =VLAN_HLEN ; + *vlan_tag = + (uint16_t ) + vlan_tags[(uint16_t )dev_ll->vdev->dev->device_fh]; + +LOG_DEBUG (VHOST_DATA , +"(%" PRIu64") TX: pkt to local VM device id:" +"(%" PRIu64") vlan tag: %d.\n" , + dev->device_fh, dev_ll->vdev->dev->device_fh, + vlan_tag); + +break ; + } + dev_ll = dev_ll->next; + } +return 0 ; +} + +/* * This function routes the TX packet to the correct interface. This may be a local device * or the physical port. */
@@ -1050,8 +1101,6 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag)struct rte_mbuf **m_table;unsigned len, ret, offset =0 ;const uint16_t lcore_id =rte_lcore_id (); -struct virtio_net_data_ll *dev_ll = ll_root_used; - struct ether_hdr *pkt_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);struct virtio_net *dev = vdev->dev;/*check if destination is local VM*/
@@ -1061,43 +1110,9 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag) }if (vm2vm_mode ==VM2VM_HARDWARE ) { -while (dev_ll !=NULL ) { -if ((dev_ll->vdev->ready ==DEVICE_RX ) - &ðer_addr_cmp (&(pkt_hdr->d_addr), - &dev_ll->vdev->mac_address)) { -/* -* Drop the packet if the TX packet is -* destined for the TX device. -*/ -if (dev_ll->vdev->dev->device_fh == dev->device_fh) { -LOG_DEBUG (VHOST_DATA , -"(%" PRIu64") TX: Source and destination" -" MAC addresses are the same. Dropping " -"packet.\n" , - dev_ll->vdev->dev->device_fh); -rte_pktmbuf_free (m); -return ; - } - -/* -* HW vlan strip will reduce the packet length -* by minus length of vlan tag, so need restore -* the packet length by plus it. -*/ - offset =VLAN_HLEN ; - vlan_tag = - (uint16_t ) - vlan_tags[(uint16_t )dev_ll->vdev->dev->device_fh]; - -LOG_DEBUG (VHOST_DATA , -"(%" PRIu64") TX: pkt to local VM device id:" -"(%" PRIu64") vlan tag: %d.\n" , - dev->device_fh, dev_ll->vdev->dev->device_fh, - vlan_tag); - -break ; - } - dev_ll = dev_ll->next; +if (find_local_dest (dev, m, &offset, &vlan_tag) !=0 ) { +rte_pktmbuf_free (m); +return ; } }
@@ -1726,8 +1741,6 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m,struct rte_mbuf *mbuf =NULL ;unsigned len, ret, offset =0 ;struct vpool *vpool; -struct virtio_net_data_ll *dev_ll = ll_root_used; - struct ether_hdr *pkt_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);uint16_t vlan_tag = (uint16_t )vlan_tags[(uint16_t )dev->device_fh];uint16_t vmdq_rx_q = ((struct vhost_dev *)dev->priv)->vmdq_rx_q;
@@ -1756,46 +1769,10 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m,* such a ambiguous situation, so pkt will lost. */ vlan_tag = external_pkt_default_vlan_tag; -while (dev_ll !=NULL ) { -if (likely (dev_ll->vdev->ready ==DEVICE_RX ) && -ether_addr_cmp (&(pkt_hdr->d_addr), - &dev_ll->vdev->mac_address)) { - -/* -* Drop the packet if the TX packet is destined -* for the TX device. -*/ -if (unlikely (dev_ll->vdev->dev->device_fh - == dev->device_fh)) { -LOG_DEBUG (VHOST_DATA , -"(%" PRIu64") TX: Source and destination" -"MAC addresses are the same. Dropping " -"packet.\n" , - dev_ll->vdev->dev->device_fh); -MBUF_HEADROOM_UINT32 (mbuf) - = (uint32_t )desc_idx; -__rte_mbuf_raw_free (mbuf); -return ; - } - -/* -* Packet length offset 4 bytes for HW vlan -* strip when L2 switch back. -*/ - offset =4 ; - vlan_tag = - (uint16_t ) - vlan_tags[(uint16_t )dev_ll->vdev->dev->device_fh]; - -LOG_DEBUG (VHOST_DATA , -"(%" PRIu64") TX: pkt to local VM device id:" -"(%" PRIu64") vlan tag: %d.\n" , - dev->device_fh, dev_ll->vdev->dev->device_fh, - vlan_tag); - -break ; - } - dev_ll = dev_ll->next; +if (find_local_dest (dev, m, &offset, &vlan_tag) !=0 ) { +MBUF_HEADROOM_UINT32 (mbuf) = (uint32_t )desc_idx; +__rte_mbuf_raw_free (mbuf); +return ; } }
Signature · 1 line
1.8.4.2
v4 cover Fix packet length issue
In reply to a message not in the archiveThis patch set fix packet length issue in vhost app, and enhance code by extracting a function to replace duplicated codes in one copy and zero copy TX function.
-v4 chang:
Check offset value and extra bytes inside packet buffer cross page boundary.
-v3 change:
Extract a function to replace duplicated codes in one copy and zero copy TX function.
-v2 change:
Update data length by plus offset in first segment instead of last segment.
-v1 change:
Update the packet length by plus offset;
Use macro to replace constant.
Changchun Ouyang (3):
Fix packet length issue in vhost.
Extract a function to replace duplicated codes in vhost. Check offset value in vhost
examples/vhost/main.c | 142 +++++++++++++++++++++++--------------------------- 1 file changed, 65 insertions(+), 77 deletions(-)
Signature · 1 line
1.8.4.2
A message that is not in the archive (sent off-list or not yet received): 1415171435-24252-1-git-send-email-changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
PATCH v4 1/3 vhost: Fix packet length issue
As HW vlan strip will reduce the packet length by minus length of vlan tag, so it need restore the packet length by plus it.
--- examples/vhost/main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
examples/vhost/main.c +10 -2
@@ -1078,7 +1078,13 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag)rte_pktmbuf_free (m);return ; } - offset =4 ; + +/* +* HW vlan strip will reduce the packet length +* by minus length of vlan tag, so need restore +* the packet length by plus it. +*/ + offset =VLAN_HLEN ; vlan_tag = (uint16_t ) vlan_tags[(uint16_t )dev_ll->vdev->dev->device_fh];
@@ -1102,8 +1108,10 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag) len = tx_q->len; m->ol_flags =PKT_TX_VLAN_PKT ; -/*FIXME: offset*/ + m->data_len += offset; + m->pkt_len += offset; + m->vlan_tci = vlan_tag; tx_q->m_table[len] = m;
Signature · 1 line
1.8.4.2
A message that is not in the archive (sent off-list or not yet received): 1415171435-24252-2-git-send-email-changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Xie, Huawei
Acked-byQuoted 48 lines
-----Original Message-----
From: Ouyang, Changchun
Sent: Wednesday, November 05, 2014 12:11 AM
To: [email protected]
Cc: Xie, Huawei; Ananyev, Konstantin; Cao, Waterman; Ouyang, Changchun
Subject: [PATCH v4 1/3] vhost: Fix packet length issueAs HW vlan strip will reduce the packet length by minus length of vlan tag, so it need restore the packet length by plus it.
Signed-off-by Changchun Ouyang <[email protected]>--- examples/vhost/main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)examples/vhost/main.c +7
-1@@ -1078,7 +1078,13 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag)rte_pktmbuf_free (m );return ; } - offset =4 ; + +/* +* HW vlan strip will reduce the packet length +* by minus length of vlan tag, so need restore +* the packet length by plus it. +*/ + offset =VLAN_HLEN ; vlan_tag = (uint16_t)vlan_tags[(uint16_t)dev_ll->vdev->dev-
Quoted 1 line
device_fh];examples/vhost/main.c +3
-1@@ -1102,8 +1108,10 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag) len = tx_q->len; m->ol_flags =PKT_TX_VLAN_PKT ; -/*FIXME: offset*/ + m->data_len += offset; + m->pkt_len += offset; + m->vlan_tci = vlan_tag;
Quoted 3 lines
tx_q->m_table[len] = m;
--
1.8.4.2
Only one thing, I feel "by minus/plus" has grammar problem. :).
PATCH v4 2/3 vhost: Remove duplicated codes
In reply to a message not in the archiveExtract a function to replace duplicated codes in one copy and zero copy TX function.
--- examples/vhost/main.c | 139 +++++++++++++++++++++----------------------------- 1 file changed, 58 insertions(+), 81 deletions(-)
examples/vhost/main.c +58 -81
@@ -1040,6 +1040,57 @@ virtio_tx_local(struct vhost_dev *vdev, struct rte_mbuf *m) }/* +* Check if the destination MAC of a packet is one local VM, +* and get its vlan tag, and offset if it is. +*/ +static inline int __attribute__((always_inline)) +find_local_dest (struct virtio_net *dev,struct rte_mbuf *m, +uint32_t *offset,uint16_t *vlan_tag) +{ +struct virtio_net_data_ll *dev_ll = ll_root_used; + struct ether_hdr *pkt_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *); + +while (dev_ll !=NULL ) { +if ((dev_ll->vdev->ready ==DEVICE_RX ) + &ðer_addr_cmp (&(pkt_hdr->d_addr), + &dev_ll->vdev->mac_address)) { +/* +* Drop the packet if the TX packet is +* destined for the TX device. +*/ +if (dev_ll->vdev->dev->device_fh == dev->device_fh) { +LOG_DEBUG (VHOST_DATA , +"(%" PRIu64") TX: Source and destination" +" MAC addresses are the same. Dropping " +"packet.\n" , + dev_ll->vdev->dev->device_fh); +return -1 ; + } + +/* +* HW vlan strip will reduce the packet length +* by minus length of vlan tag, so need restore +* the packet length by plus it. +*/ + *offset =VLAN_HLEN ; + *vlan_tag = + (uint16_t ) + vlan_tags[(uint16_t )dev_ll->vdev->dev->device_fh]; + +LOG_DEBUG (VHOST_DATA , +"(%" PRIu64") TX: pkt to local VM device id:" +"(%" PRIu64") vlan tag: %d.\n" , + dev->device_fh, dev_ll->vdev->dev->device_fh, + vlan_tag); + +break ; + } + dev_ll = dev_ll->next; + } +return 0 ; +} + +/* * This function routes the TX packet to the correct interface. This may be a local device * or the physical port. */
@@ -1050,8 +1101,6 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag)struct rte_mbuf **m_table;unsigned len, ret, offset =0 ;const uint16_t lcore_id =rte_lcore_id (); -struct virtio_net_data_ll *dev_ll = ll_root_used; - struct ether_hdr *pkt_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);struct virtio_net *dev = vdev->dev;/*check if destination is local VM*/
@@ -1061,43 +1110,9 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag) }if (vm2vm_mode ==VM2VM_HARDWARE ) { -while (dev_ll !=NULL ) { -if ((dev_ll->vdev->ready ==DEVICE_RX ) - &ðer_addr_cmp (&(pkt_hdr->d_addr), - &dev_ll->vdev->mac_address)) { -/* -* Drop the packet if the TX packet is -* destined for the TX device. -*/ -if (dev_ll->vdev->dev->device_fh == dev->device_fh) { -LOG_DEBUG (VHOST_DATA , -"(%" PRIu64") TX: Source and destination" -" MAC addresses are the same. Dropping " -"packet.\n" , - dev_ll->vdev->dev->device_fh); -rte_pktmbuf_free (m); -return ; - } - -/* -* HW vlan strip will reduce the packet length -* by minus length of vlan tag, so need restore -* the packet length by plus it. -*/ - offset =VLAN_HLEN ; - vlan_tag = - (uint16_t ) - vlan_tags[(uint16_t )dev_ll->vdev->dev->device_fh]; - -LOG_DEBUG (VHOST_DATA , -"(%" PRIu64") TX: pkt to local VM device id:" -"(%" PRIu64") vlan tag: %d.\n" , - dev->device_fh, dev_ll->vdev->dev->device_fh, - vlan_tag); - -break ; - } - dev_ll = dev_ll->next; +if (find_local_dest (dev, m, &offset, &vlan_tag) !=0 ) { +rte_pktmbuf_free (m); +return ; } }
@@ -1726,8 +1741,6 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m,struct rte_mbuf *mbuf =NULL ;unsigned len, ret, offset =0 ;struct vpool *vpool; -struct virtio_net_data_ll *dev_ll = ll_root_used; - struct ether_hdr *pkt_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);uint16_t vlan_tag = (uint16_t )vlan_tags[(uint16_t )dev->device_fh];uint16_t vmdq_rx_q = ((struct vhost_dev *)dev->priv)->vmdq_rx_q;
@@ -1756,46 +1769,10 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m,* such a ambiguous situation, so pkt will lost. */ vlan_tag = external_pkt_default_vlan_tag; -while (dev_ll !=NULL ) { -if (likely (dev_ll->vdev->ready ==DEVICE_RX ) && -ether_addr_cmp (&(pkt_hdr->d_addr), - &dev_ll->vdev->mac_address)) { - -/* -* Drop the packet if the TX packet is destined -* for the TX device. -*/ -if (unlikely (dev_ll->vdev->dev->device_fh - == dev->device_fh)) { -LOG_DEBUG (VHOST_DATA , -"(%" PRIu64") TX: Source and destination" -"MAC addresses are the same. Dropping " -"packet.\n" , - dev_ll->vdev->dev->device_fh); -MBUF_HEADROOM_UINT32 (mbuf) - = (uint32_t )desc_idx; -__rte_mbuf_raw_free (mbuf); -return ; - } - -/* -* Packet length offset 4 bytes for HW vlan -* strip when L2 switch back. -*/ - offset =4 ; - vlan_tag = - (uint16_t ) - vlan_tags[(uint16_t )dev_ll->vdev->dev->device_fh]; - -LOG_DEBUG (VHOST_DATA , -"(%" PRIu64") TX: pkt to local VM device id:" -"(%" PRIu64") vlan tag: %d.\n" , - dev->device_fh, dev_ll->vdev->dev->device_fh, - vlan_tag); - -break ; - } - dev_ll = dev_ll->next; +if (find_local_dest (dev, m, &offset, &vlan_tag) !=0 ) { +MBUF_HEADROOM_UINT32 (mbuf) = (uint32_t )desc_idx; +__rte_mbuf_raw_free (mbuf); +return ; } }
Signature · 1 line
1.8.4.2
PATCH v4 3/3 vhost: Check offset value
In reply to a message not in the archiveThis patch checks the packet length offset value, and checks if the extra bytes inside buffer cross page boundary.
--- examples/vhost/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
examples/vhost/main.c +5 -2
@@ -1110,7 +1110,8 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag) }if (vm2vm_mode ==VM2VM_HARDWARE ) { -if (find_local_dest (dev, m, &offset, &vlan_tag) !=0 ) { +if (find_local_dest (dev, m, &offset, &vlan_tag) !=0 || + offset >rte_pktmbuf_tailroom (m)) {rte_pktmbuf_free (m);return ; }
@@ -1896,7 +1897,9 @@ virtio_dev_tx_zcp(struct virtio_net *dev)/* Buffer address translation. */ buff_addr =gpa_to_vva (dev, desc->addr); - phys_addr =gpa_to_hpa (vdev, desc->addr, desc->len, &addr_type); +/* Need check extra VLAN_HLEN size for inserting VLAN tag */ + phys_addr =gpa_to_hpa (vdev, desc->addr, desc->len +VLAN_HLEN , + &addr_type);if (likely (packet_success < (free_entries -1 )))/* Prefetch descriptor index. */
Signature · 1 line
1.8.4.2
A message that is not in the archive (sent off-list or not yet received): 1415171435-24252-4-git-send-email-changchun.ouyang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Re: [PATCH v4 3/3] vhost: Check offset value
Quoted 47 lines
-----Original Message-----
From: Ouyang, Changchun
Sent: Wednesday, November 05, 2014 12:11 AM
To: [email protected]
Cc: Xie, Huawei; Ananyev, Konstantin; Cao, Waterman; Ouyang, Changchun
Subject: [PATCH v4 3/3] vhost: Check offset valueThis patch checks the packet length offset value, and checks if the extra bytes inside buffer
cross page boundary.Signed-off-by Changchun Ouyang <[email protected]>--- examples/vhost/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)examples/vhost/main.c +2
-1@@ -1110,7 +1110,8 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag) }if (vm2vm_mode ==VM2VM_HARDWARE ) { -if (find_local_dest (dev, m, &offset, &vlan_tag) !=0 ) { +if (find_local_dest (dev, m, &offset, &vlan_tag) !=0 || + offset >rte_pktmbuf_tailroom (m)) {rte_pktmbuf_free (m);return ;examples/vhost/main.c +3
-1}@@ -1896,7 +1897,9 @@ virtio_dev_tx_zcp(struct virtio_net *dev)/* Buffer address translation. */ buff_addr =gpa_to_vva (dev, desc->addr); - phys_addr =gpa_to_hpa (vdev, desc->addr, desc->len, &addr_type); +/* Need check extra VLAN_HLEN size for inserting VLAN tag */ + phys_addr =gpa_to_hpa (vdev, desc->addr, desc->len +VLAN_HLEN , + &addr_type);examples/vhost/main.c +0
-1if (likely (packet_success < (free_entries -1 )))/* Prefetch descriptor index. */ --
Quoted 1 line
1.8.4.2
Why don't we merge 1,2,3 patches?
A message that is not in the archive (sent off-list or not yet received): C37D651A908B024F974696C65296B57B0F2E2149-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org
Re: [PATCH v4 3/3] vhost: Check offset value
2014-11-05 16:52, Xie, Huawei:
Quoted 1 line
Why don't we merge 1,2,3 patches?
Because it's simpler to understand small patches with a dedicated explanation in the commit log of each patch.
Why do you want to merge them?
Signature · 1 line
Thomas
Re: [PATCH v4 3/3] vhost: Check offset value
Quoted 10 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, November 05, 2014 10:01 AM
To: Xie, Huawei
Cc: [email protected]; Ouyang, Changchun
Subject: Re: [dpdk-dev] [PATCH v4 3/3] vhost: Check offset value2014-11-05 16:52, Xie, Huawei:
Quoted 8 lines
Quoted 1 line
Why don't we merge 1,2,3 patches?
Because it's simpler to understand small patches with a dedicated explanation in the commit log of each patch.
Why do you want to merge them?--
Thomas
Got it, so we prefer each patch fixes one dedicated thing.
Re: [PATCH v4 3/3] vhost: Check offset value
In reply to Thomas MonjalonAgree with Thomas! using small patches is for easily understanding. Merging and mixing things together is not a good thing.
Changchun
Quoted 16 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Thursday, November 6, 2014 1:01 AM
To: Xie, Huawei
Cc: [email protected]; Ouyang, Changchun
Subject: Re: [dpdk-dev] [PATCH v4 3/3] vhost: Check offset value2014-11-05 16:52, Xie, Huawei:
Quoted 1 line
Why don't we merge 1,2,3 patches?
Because it's simpler to understand small patches with a dedicated explanation in the commit log of each patch.
Why do you want to merge them?--
Thomas
Ananyev, Konstantin
Acked-byRe: [PATCH v4 0/3] Fix packet length issue
In reply to a message not in the archiveQuoted 28 lines
From: Ouyang, Changchun
Sent: Wednesday, November 05, 2014 7:11 AM
To: [email protected]
Cc: Xie, Huawei; Ananyev, Konstantin; Cao, Waterman; Ouyang, Changchun
Subject: [PATCH v4 0/3] Fix packet length issueThis patch set fix packet length issue in vhost app, and enhance code by extracting a function to replace duplicated codes in one copy and zero copy TX function.
(quoted diff) +0
-4-v4 chang: Check offset value and extra bytes inside packet buffer cross page boundary. -v3 change: Extract a function to replace duplicated codes in one copy and zero copy TX function. -v2 change: Update data length by plus offset in first segment instead of last segment. -v1 change: Update the packet length by plus offset; Use macro to replace constant.Changchun Ouyang (3):
Fix packet length issue in vhost.
Extract a function to replace duplicated codes in vhost. Check offset value in vhost
Quoted 5 lines
examples/vhost/main.c | 142 +++++++++++++++++++++++--------------------------- 1 file changed, 65 insertions(+), 77 deletions(-)--
1.8.4.2
A message that is not in the archive (sent off-list or not yet received): 2601191342CEEE43887BDE71AB977258213A27BD-kPTMFJFq+rEu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org
Thomas Monjalon
AppliedRe: [PATCH v4 0/3] Fix packet length issue
Quoted 22 lines
Quoted 22 lines
This patch set fix packet length issue in vhost app, and enhance code by extracting a function to replace duplicated codes in one copy and zero copy TX function.
(quoted diff) +0
-4-v4 chang: Check offset value and extra bytes inside packet buffer cross page boundary. -v3 change: Extract a function to replace duplicated codes in one copy and zero copy TX function. -v2 change: Update data length by plus offset in first segment instead of last segment. -v1 change: Update the packet length by plus offset; Use macro to replace constant.Changchun Ouyang (3):
Fix packet length issue in vhost.
Extract a function to replace duplicated codes in vhost. Check offset value in vhost
Quoted 7 lines
Quoted 5 lines
examples/vhost/main.c | 142 +++++++++++++++++++++++--------------------------- 1 file changed, 65 insertions(+), 77 deletions(-)--
1.8.4.2
Applied
Thanks
Signature · 1 line
Thomas