Redo fix for incorrect vlan parsing of rx emuldev frames

The previous fix in 6977278654 was incorrect and incomplete since it
won't handle the case when emulated devices have PRIO and/or CFI/DEI
set.

This is the correct fix where Prio and CFI/DEI are no longer part of the
device key.
This commit is contained in:
Srivats P 2020-01-26 19:01:37 +05:30
parent f0dd0c307b
commit 176fc7dd15
2 changed files with 8 additions and 5 deletions

View File

@ -33,7 +33,8 @@ const int kIp6HdrLen = 40;
/*
* NOTE:
* 1. Device Key is (VLANS + MAC) - is assumed to be unique for a device
* 1. Device Key is (VLANS [without prio/cfi] + MAC)
* - is assumed to be unique for a device
* 2. Device clients/users (viz. DeviceManager) should take care when
* setting params that change the key, if the key is used elsewhere
* (e.g. in a hash)
@ -67,7 +68,7 @@ void Device::setVlan(int index, quint16 vlan, quint16 tpid)
vlan_[index] = (tpid << 16) | vlan;
ofs = index * sizeof(quint16);
key_[ofs] = vlan >> 8;
key_[ofs] = (vlan >> 8) & 0x0f; // Vlan prio/cfi should not be part of key
key_[ofs+1] = vlan & 0xff;
if (index >= numVlanTags_)

View File

@ -265,10 +265,11 @@ _eth_type:
if (tpidList_.contains(ethType)) {
offset += 2;
vlan = qFromBigEndian<quint16>(pktData + offset) & 0x0FFF;
vlan = qFromBigEndian<quint16>(pktData + offset);
dk.setVlan(idx++, vlan);
offset += 2;
qDebug("%s: idx: %d vlan %d", __FUNCTION__, idx, vlan);
qDebug("%s: idx: %d vlan: 0x%04x/%d", __FUNCTION__,
idx, vlan, vlan & 0x0fff);
goto _eth_type;
}
@ -383,7 +384,8 @@ _eth_type:
vlan = qFromBigEndian<quint16>(pktData + offset);
dk.setVlan(idx++, vlan);
offset += 2;
qDebug("%s: idx: %d vlan %d", __FUNCTION__, idx, vlan);
qDebug("%s: idx: %d vlan: 0x%04x/%d", __FUNCTION__,
idx, vlan, vlan & 0x0fff);
goto _eth_type;
}