VOL-1834 Report when tagging is not as expected
Change-Id: I863fb1786f9355314088dcfc9f0fe697a6932403
diff --git a/core/core_server.go b/core/core_server.go
index af699e1..c03545a 100644
--- a/core/core_server.go
+++ b/core/core_server.go
@@ -646,14 +646,25 @@
"payload": layerDHCP.LayerPayload(),
"type": layerDHCP.LayerType().String(),
}).Info("Received downstream packet is DHCP.")
- rawpkt, _, _ = PopVLAN(rawpkt)
- rawpkt, _, _ = PopVLAN(rawpkt)
- logger.Debug("%s", rawpkt.Dump())
- dhcpPkt := byteMsg{IntfId: intfid, OnuId: onuid, Byte: rawpkt.Data()}
+ poppkt, _, err := PopVLAN(rawpkt)
+ if err != nil {
+ logger.Error("Received untagged packet when expecting single-tagged packet. Dropped.")
+ return nil
+ } else {
+ // check to see if the packet was double-tagged
+ _, _, err := PopVLAN(poppkt)
+ if err == nil {
+ logger.Error("Received double-tagged packet when expecting single-tagged packet. Dropped.")
+ return nil
+ }
+ }
+ logger.Debug("%s", poppkt.Dump())
+ dhcpPkt := byteMsg{IntfId: intfid, OnuId: onuid, Byte: poppkt.Data()}
s.dhcpOut <- &dhcpPkt
return nil
} else {
device.LoggerWithOnu(onu).Warn("WARNING: Received packet is not EAPOL or DHCP")
+ // TODO(smbaker): Clarify if this return is correct. There is SendUni() dead code that follows.
return nil
}
ioinfo, err := s.identifyUniIoinfo("inside", intfid, onuid)
@@ -670,10 +681,18 @@
func (s *Server) uplinkPacketOut(rawpkt gopacket.Packet) error {
poppkt, _, err := PopVLAN(rawpkt)
- poppkt, _, err = PopVLAN(poppkt)
if err != nil {
- logger.Error("%s", err)
- return err
+ logger.Error("Received untagged packet when expecting single-tagged packet. Dropped")
+ return nil
+ } else {
+ // check to see if the packet was double-tagged
+ poppktAgain, _, err := PopVLAN(poppkt)
+ if err == nil {
+ poppkt = poppktAgain
+ } else {
+ logger.Error("Received single-tagged packet when expecting double-tagged packet. Dropped.")
+ return nil
+ }
}
ioinfo, err := s.IdentifyNniIoinfo("inside")
if err != nil {
diff --git a/core/io_worker.go b/core/io_worker.go
index 00ecda3..e0ffd10 100644
--- a/core/io_worker.go
+++ b/core/io_worker.go
@@ -85,8 +85,7 @@
return retpkt, vid, nil
}
}
- return pkt, 0, nil
- // return nil, 0, errors.New("failed to pop vlan")
+ return nil, 0, errors.New("failed to pop vlan")
}
// PushVLAN pushes the vlan header to the packet and returns tha packet