[v7,2/2] net/netvsc: fix parsing of VLAN metadata
Checks
Commit Message
The previous code incorrectly parsed the VLAN ID and priority.
If the 16-bits of VLAN ID and priority/CFI on the wire was
0123456789ABCDEF the code parsed it as 456789ABCDEF3012. There
were macros defined to handle this conversion but they were not
used.
Fixes: 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
Cc: sthemmin@microsoft.com
Cc: stable@dpdk.org
Signed-off-by: Alan Elder <alan.elder@microsoft.com>
---
v7:
* Split into two patches, one for lib and one for driver
v6:
* Line length can be 100 - un-split lines
v5:
* Move the VLAN parsing macros to rte_ether.h
v4:
* Make consistent with FreeBSD code
---
drivers/net/netvsc/hn_rxtx.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
--
2.25.1
Comments
On 2/19/2024 9:31 AM, Alan Elder wrote:
> The previous code incorrectly parsed the VLAN ID and priority.
> If the 16-bits of VLAN ID and priority/CFI on the wire was
> 0123456789ABCDEF the code parsed it as 456789ABCDEF3012. There
> were macros defined to handle this conversion but they were not
> used.
>
> Fixes: 4e9c73e96e83 ("net/netvsc: add Hyper-V network device")
> Cc: stable@dpdk.org
>
> Signed-off-by: Alan Elder <alan.elder@microsoft.com>
>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
@@ -612,7 +612,9 @@ static void hn_rxpkt(struct hn_rx_queue *rxq, struct hn_rx_bufinfo *rxb,
RTE_PTYPE_L4_MASK);
if (info->vlan_info != HN_NDIS_VLAN_INFO_INVALID) {
- m->vlan_tci = info->vlan_info;
+ m->vlan_tci = RTE_VLAN_TCI_MAKE(NDIS_VLAN_INFO_ID(info->vlan_info),
+ NDIS_VLAN_INFO_PRI(info->vlan_info),
+ NDIS_VLAN_INFO_CFI(info->vlan_info));
m->ol_flags |= RTE_MBUF_F_RX_VLAN_STRIPPED | RTE_MBUF_F_RX_VLAN;
/* NDIS always strips tag, put it back if necessary */
@@ -1332,7 +1334,9 @@ static void hn_encap(struct rndis_packet_msg *pkt,
if (m->ol_flags & RTE_MBUF_F_TX_VLAN) {
pi_data = hn_rndis_pktinfo_append(pkt, NDIS_VLAN_INFO_SIZE,
NDIS_PKTINFO_TYPE_VLAN);
- *pi_data = m->vlan_tci;
+ *pi_data = NDIS_VLAN_INFO_MAKE(RTE_VLAN_TCI_ID(m->vlan_tci),
+ RTE_VLAN_TCI_PRI(m->vlan_tci),
+ RTE_VLAN_TCI_DEI(m->vlan_tci));
}
if (m->ol_flags & RTE_MBUF_F_TX_TCP_SEG) {