diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java index 4afb0a007bd4888aa12dc7eea6539def9d473fda..bcb8b35f846dca2ff29a951fca08e818f1c71e7e 100644 --- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java +++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java @@ -64,7 +64,7 @@ import net.floodlightcontroller.linkdiscovery.web.LinkDiscoveryWebRoutable; import net.floodlightcontroller.linkdiscovery.ILinkDiscoveryListener; import net.floodlightcontroller.linkdiscovery.ILinkDiscoveryService; import net.floodlightcontroller.linkdiscovery.LinkInfo; -import net.floodlightcontroller.packet.BDDP; +import net.floodlightcontroller.packet.BSN; import net.floodlightcontroller.packet.Ethernet; import net.floodlightcontroller.packet.IPv4; import net.floodlightcontroller.packet.LLDP; @@ -529,6 +529,10 @@ IFloodlightModule, IInfoProvider, IHAListener { if (iofSwitch == null) { return; } + + if (port == OFPort.OFPP_LOCAL.getValue()) + return; + OFPhysicalPort ofpPort = iofSwitch.getPort(port); if (ofpPort == null) { @@ -553,64 +557,30 @@ IFloodlightModule, IInfoProvider, IHAListener { log.trace("Sending LLDP packet out of swich: {}, port: {}", sw, port); } - LLDP lldp; - Ethernet ethernet; - if (isStandard) { - ethernet = new Ethernet() - .setSourceMACAddress(ofpPort.getHardwareAddress()) - .setDestinationMACAddress(LLDP_STANDARD_DST_MAC_STRING) - .setEtherType(Ethernet.TYPE_LLDP); - lldp = new LLDP(); - } else { - ethernet = new Ethernet() - .setSourceMACAddress(ofpPort.getHardwareAddress()) - .setDestinationMACAddress(LLDP_BSN_DST_MAC_STRING) - .setEtherType(Ethernet.TYPE_BDDP); - lldp = new BDDP(); - } // using "nearest customer bridge" MAC address for broadest possible propagation // through provider and TPMR bridges (see IEEE 802.1AB-2009 and 802.1Q-2011), // in particular the Linux bridge which behaves mostly like a provider bridge - - ethernet.setPayload(lldp); byte[] chassisId = new byte[] {4, 0, 0, 0, 0, 0, 0}; // filled in later byte[] portId = new byte[] {2, 0, 0}; // filled in later byte[] ttlValue = new byte[] {0, 0x78}; - lldp.setChassisId(new LLDPTLV().setType((byte) 1).setLength((short) chassisId.length).setValue(chassisId)); - lldp.setPortId(new LLDPTLV().setType((byte) 2).setLength((short) portId.length).setValue(portId)); - lldp.setTtl(new LLDPTLV().setType((byte) 3).setLength((short) ttlValue.length).setValue(ttlValue)); - // OpenFlow OUI - 00-26-E1 byte[] dpidTLVValue = new byte[] {0x0, 0x26, (byte) 0xe1, 0, 0, 0, 0, 0, 0, 0, 0, 0}; LLDPTLV dpidTLV = new LLDPTLV().setType((byte) 127).setLength((short) dpidTLVValue.length).setValue(dpidTLVValue); - lldp.getOptionalTLVList().add(dpidTLV); - - // Add the controller identifier to the TLV value. - lldp.getOptionalTLVList().add(controllerTLV); - if (isReverse) { - lldp.getOptionalTLVList().add(reverseTLV); - }else { - lldp.getOptionalTLVList().add(forwardTLV); - } byte[] dpidArray = new byte[8]; ByteBuffer dpidBB = ByteBuffer.wrap(dpidArray); ByteBuffer portBB = ByteBuffer.wrap(portId, 1, 2); - Long dpid = sw; dpidBB.putLong(dpid); - // set the ethernet source mac to last 6 bytes of dpid - System.arraycopy(dpidArray, 2, ethernet.getSourceMACAddress(), 0, 6); + System.arraycopy(dpidArray, 2, ofpPort.getHardwareAddress(), 0, 6); // set the chassis id's value to last 6 bytes of dpid System.arraycopy(dpidArray, 2, chassisId, 1, 6); // set the optional tlv to the full dpid System.arraycopy(dpidArray, 0, dpidTLVValue, 4, 8); - if (port == OFPort.OFPP_LOCAL.getValue()) - return; // set the portId to the outgoing port portBB.putShort(port); @@ -619,6 +589,39 @@ IFloodlightModule, IInfoProvider, IHAListener { HexString.toHexString(sw), port); } + LLDP lldp = new LLDP(); + lldp.setChassisId(new LLDPTLV().setType((byte) 1).setLength((short) chassisId.length).setValue(chassisId)); + lldp.setPortId(new LLDPTLV().setType((byte) 2).setLength((short) portId.length).setValue(portId)); + lldp.setTtl(new LLDPTLV().setType((byte) 3).setLength((short) ttlValue.length).setValue(ttlValue)); + lldp.getOptionalTLVList().add(dpidTLV); + + // Add the controller identifier to the TLV value. + lldp.getOptionalTLVList().add(controllerTLV); + if (isReverse) { + lldp.getOptionalTLVList().add(reverseTLV); + }else { + lldp.getOptionalTLVList().add(forwardTLV); + } + + Ethernet ethernet; + if (isStandard) { + ethernet = new Ethernet() + .setSourceMACAddress(ofpPort.getHardwareAddress()) + .setDestinationMACAddress(LLDP_STANDARD_DST_MAC_STRING) + .setEtherType(Ethernet.TYPE_LLDP); + ethernet.setPayload(lldp); + } else { + BSN bsn = new BSN(BSN.BSN_TYPE_BDDP); + bsn.setPayload(lldp); + + ethernet = new Ethernet() + .setSourceMACAddress(ofpPort.getHardwareAddress()) + .setDestinationMACAddress(LLDP_BSN_DST_MAC_STRING) + .setEtherType(Ethernet.TYPE_BSN); + ethernet.setPayload(bsn); + } + + // serialize and wrap in a packet out byte[] data = ethernet.serialize(); OFPacketOut po = (OFPacketOut) floodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_OUT); @@ -900,8 +903,15 @@ IFloodlightModule, IInfoProvider, IHAListener { IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD); - if(eth.getEtherType() == Ethernet.TYPE_BDDP) { - return handleLldp((LLDP) eth.getPayload(), sw, pi, false, cntx); + if(eth.getEtherType() == Ethernet.TYPE_BSN) { + BSN bsn = (BSN) eth.getPayload(); + if (bsn == null) return Command.STOP; + if (bsn.getPayload() == null) return Command.STOP; + // It could be a packet other than BSN LLDP, therefore + // continue with the regular processing. + if (bsn.getPayload() instanceof LLDP == false) + return Command.CONTINUE; + return handleLldp((LLDP) bsn.getPayload(), sw, pi, false, cntx); } else if (eth.getEtherType() == Ethernet.TYPE_LLDP) { return handleLldp((LLDP) eth.getPayload(), sw, pi, true, cntx); } else if (eth.getEtherType() < 1500) { diff --git a/src/main/java/net/floodlightcontroller/packet/BDDP.java b/src/main/java/net/floodlightcontroller/packet/BDDP.java deleted file mode 100644 index 086ef2963d949cd86731bc9f8c3718450ffc8b14..0000000000000000000000000000000000000000 --- a/src/main/java/net/floodlightcontroller/packet/BDDP.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.floodlightcontroller.packet; - -import java.util.ArrayList; - -/** - * This class defines the packet structure for broadcast domain discovery. - * This class is an extended version of the LLDP class. The only difference - * is that the eth-type is different from the standard LLDP. - * - * @author srini - * - */ -public class BDDP extends LLDP { - public BDDP() { - this.optionalTLVList = new ArrayList<LLDPTLV>(); - this.ethType = Ethernet.TYPE_BDDP; - } -} diff --git a/src/main/java/net/floodlightcontroller/packet/Ethernet.java b/src/main/java/net/floodlightcontroller/packet/Ethernet.java index 6f16a03a45b3a640a194692d257618dae0146715..6bd627b0ef419ed02b51acededa6c0efa012c3ff 100644 --- a/src/main/java/net/floodlightcontroller/packet/Ethernet.java +++ b/src/main/java/net/floodlightcontroller/packet/Ethernet.java @@ -37,7 +37,6 @@ public class Ethernet extends BasePacket { public static final short TYPE_LLDP = (short) 0x88cc; public static final short TYPE_BSN = (short) 0x8942; public static final short VLAN_UNTAGGED = (short)0xffff; - public static final short TYPE_BDDP = (short) 0x8999; public static final short DATALAYER_ADDRESS_LENGTH = 6; // bytes public static Map<Short, Class<? extends IPacket>> etherTypeClassMap; @@ -47,7 +46,6 @@ public class Ethernet extends BasePacket { etherTypeClassMap.put(TYPE_RARP, ARP.class); etherTypeClassMap.put(TYPE_IPv4, IPv4.class); etherTypeClassMap.put(TYPE_LLDP, LLDP.class); - etherTypeClassMap.put(TYPE_BDDP, BDDP.class); etherTypeClassMap.put(TYPE_BSN, BSN.class); } diff --git a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java index 51bbd017ee3afc218fa8bff233c68cf1c604b5fc..ba17483ab0c0101d1ac36f9c75c30aacf20021b8 100644 --- a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java +++ b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java @@ -30,7 +30,9 @@ import net.floodlightcontroller.core.util.SingletonTask; import net.floodlightcontroller.counter.ICounterStoreService; import net.floodlightcontroller.linkdiscovery.ILinkDiscoveryListener; import net.floodlightcontroller.linkdiscovery.ILinkDiscoveryService; +import net.floodlightcontroller.packet.BSN; import net.floodlightcontroller.packet.Ethernet; +import net.floodlightcontroller.packet.LLDP; import net.floodlightcontroller.restserver.IRestApiService; import net.floodlightcontroller.routing.IRoutingService; import net.floodlightcontroller.routing.Link; @@ -829,7 +831,16 @@ public class TopologyManager implements IFloodlightProviderService.bcStore. get(cntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD); - if (eth.getEtherType() == Ethernet.TYPE_BDDP) { + if (eth.getEtherType() == Ethernet.TYPE_BSN) { + BSN bsn = (BSN) eth.getPayload(); + if (bsn == null) return Command.STOP; + if (bsn.getPayload() == null) return Command.STOP; + + // It could be a packet other than BSN LLDP, therefore + // continue with the regular processing. + if (bsn.getPayload() instanceof LLDP == false) + return Command.CONTINUE; + doFloodBDDP(sw.getId(), pi, cntx); } else { return dropFilter(sw.getId(), pi, cntx);