Hi,
When looking at packet dump with wireshark, I found LLDP packets that
were made and sent by FlowVisor were marked as "malformed packet."
Although I'm not sure whether this is a bug, the following patch just
eliminates the "malformed" mark. The malformed reason is because an
LLDP packet made by FlowVisor doesn't have "the end of LLDPDU" nor a
TLV header, but followed by padding(0xcafebabe) that is recognized as
"type = 101, length = 254" (shown by wireshark). I don't know whether
a TLV header is needed even after "the end of LLDPDU", but the patch
tries to insert both. In addition, it modifies some other things
regarding LLDP packet, which are not big deals, though.
A few notes about the patch.
The first modification is for reflecting the comment into the
implementation (120 = 0x78). I just found this during the debug.
The second one is to insert "end of LLDPDU" (0x00, 0x00) and TLV
header before the padding.
The last one is for adjusting the length value in TLV header of
FlowVisor's LLDP trailer. In the definition of TLV, length value
doesn't contain the length of "type" and "length" header.
Thanks,
Masahiko.
--- a/src/org/flowvisor/ofswitch/TopologyConnection.java
+++ b/src/org/flowvisor/ofswitch/TopologyConnection.java
@@ -482,13 +482,23 @@ public class TopologyConnection implements
FVEventHandler, FVSendMsg {
bb.putShort(portNumber);
// TTL TLV
- byte ttl[] = { 0x06, 0x02, 0x00, 0x70 };
+ byte ttl[] = { 0x06, 0x02, 0x00, 0x78 };
bb.put(ttl); // type 3, length 2, 120 seconds
// SysD TLV
bb.put(lldpSysD);
bb.putLong(this.featuresReply.getDatapathId());
+ // End of LLDPDU
+ byte endoflldp[] = { 0x00, 0x00 };
+ bb.put(endoflldp); // type 0, length 0
+
+ // padding
+ if (bb.position() > (size - 4))
+ return buf;
+ int tlv = ((size - bb.position() - 2) & 0x1ff) | ((1 & 0x007f) << 9);
// LLDP_CHASSIS_ID << 9
+ bb.putShort((short) tlv);
+ bb.put((byte) 0x07); // subtype = LLDP_CHASSIS_ID_LOCAL
while (bb.position() <= (size - 4))
bb.putInt(0xcafebabe); // fill with well known padding
return buf;
--- a/src/org/flowvisor/message/lldp/LLDPTrailer.java
+++ b/src/org/flowvisor/message/lldp/LLDPTrailer.java
@@ -87,7 +87,7 @@ public class LLDPTrailer {
ByteBuffer newPacket = ByteBuffer.allocate(embedded.length +
len);
newPacket.put(embedded);
- int tlv = (len & 0x1ff) | ((LLDP_CHASSIS_ID & 0x007f) << 9);
+ int tlv = ((len - TLV_LEN) & 0x1ff) | ((LLDP_CHASSIS_ID & 0x007f)
<< 9);
newPacket.putShort((short) tlv);
newPacket.put(LLDP_CHASSIS_ID_LOCAL);
_______________________________________________
openflow-discuss mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/openflow-discuss