Skip to content

Commit

Permalink
net/netvsc: fix VLAN metadata parsing
Browse files Browse the repository at this point in the history
[ upstream commit f7654c8c13f46ab537e8220ea4d6b4911f9f0fd5 ]

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: 4e9c73e ("net/netvsc: add Hyper-V network device")

Signed-off-by: Alan Elder <alan.elder@microsoft.com>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
  • Loading branch information
Alan Elder authored and bluca committed Mar 7, 2024
1 parent 6ccc096 commit a254412
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/net/netvsc/hn_rxtx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit a254412

Please sign in to comment.