Skip to content
Snippets Groups Projects
Commit 29aa25c8 authored by Srinivasan Ramasubramanian's avatar Srinivasan Ramasubramanian
Browse files

Add isOutgoingDiscoveryAllowed(), isIncomingDiscoveryAllowed(), and...

Add isOutgoingDiscoveryAllowed(), isIncomingDiscoveryAllowed(), and getDiscoveryActions() as methods to facilitate changes to discovery procedures easily.
parent 7ec0996d
No related branches found
No related tags found
No related merge requests found
......@@ -518,6 +518,94 @@ public class LinkDiscoveryManager implements IOFMessageListener,
sendDiscoveryMessage(sw, port, true, false);
}
/**
* Check if incoming discovery messages are enabled or not.
* @param sw
* @param port
* @param isStandard
* @return
*/
protected boolean isIncomingDiscoveryAllowed(long sw, short port,
boolean isStandard) {
if (isLinkDiscoverySuppressed(sw, port)) {
/* Do not process LLDPs from this port as suppressLLDP is set */
return false;
}
IOFSwitch iofSwitch = floodlightProvider.getSwitches().get(sw);
if (iofSwitch == null) {
return false;
}
if (port == OFPort.OFPP_LOCAL.getValue()) return false;
OFPhysicalPort ofpPort = iofSwitch.getPort(port);
if (ofpPort == null) {
if (log.isTraceEnabled()) {
log.trace("Null physical port. sw={}, port={}",
HexString.toHexString(sw), port);
}
return false;
}
return true;
}
/**
* Check if outgoing discovery messages are enabled or not.
* @param sw
* @param port
* @param isStandard
* @param isReverse
* @return
*/
protected boolean isOutgoingDiscoveryAllowed(long sw, short port,
boolean isStandard,
boolean isReverse) {
if (isLinkDiscoverySuppressed(sw, port)) {
/* Dont send LLDPs out of this port as suppressLLDP is set */
return false;
}
IOFSwitch iofSwitch = floodlightProvider.getSwitches().get(sw);
if (iofSwitch == null) {
return false;
}
if (port == OFPort.OFPP_LOCAL.getValue()) return false;
OFPhysicalPort ofpPort = iofSwitch.getPort(port);
if (ofpPort == null) {
if (log.isTraceEnabled()) {
log.trace("Null physical port. sw={}, port={}",
HexString.toHexString(sw), port);
}
return false;
}
// For fast ports, do not send forward LLDPs or BDDPs.
if (!isReverse && autoPortFastFeature && iofSwitch.isFastPort(port))
return false;
return true;
}
/**
* Get the actions for packet-out corresponding to a specific port.
* This is a placeholder for adding actions if any port-specific
* actions are desired. The default action is simply to output to
* the given port.
* @param port
* @return
*/
protected List<OFAction> getDiscoveryActions (short port){
// set actions
List<OFAction> actions = new ArrayList<OFAction>();
actions.add(new OFActionOutput(port, (short) 0));
return actions;
}
/**
* Send link discovery message out of a given switch port. The discovery
* message may be a standard LLDP or a modified LLDP, where the dst mac
......@@ -540,34 +628,13 @@ public class LinkDiscoveryManager implements IOFMessageListener,
void sendDiscoveryMessage(long sw, short port,
boolean isStandard, boolean isReverse) {
IOFSwitch iofSwitch = floodlightProvider.getSwitches().get(sw);
if (iofSwitch == null) {
// Takes care of all checks including null pointer checks.
if (!isOutgoingDiscoveryAllowed(sw, port, isStandard, isReverse))
return;
}
if (port == OFPort.OFPP_LOCAL.getValue()) return;
IOFSwitch iofSwitch = floodlightProvider.getSwitches().get(sw);
OFPhysicalPort ofpPort = iofSwitch.getPort(port);
if (ofpPort == null) {
if (log.isTraceEnabled()) {
log.trace("Null physical port. sw={}, port={}",
HexString.toHexString(sw), port);
}
return;
}
if (isLinkDiscoverySuppressed(sw, port)) {
/* Dont send LLDPs out of this port as suppressLLDPs set
*
*/
return;
}
// For fast ports, do not send forward LLDPs or BDDPs.
if (!isReverse && autoPortFastFeature && iofSwitch.isFastPort(port))
return;
if (log.isTraceEnabled()) {
log.trace("Sending LLDP packet out of swich: {}, port: {}",
HexString.toHexString(sw), port);
......@@ -664,9 +731,7 @@ public class LinkDiscoveryManager implements IOFMessageListener,
po.setBufferId(OFPacketOut.BUFFER_ID_NONE);
po.setInPort(OFPort.OFPP_NONE);
// set actions
List<OFAction> actions = new ArrayList<OFAction>();
actions.add(new OFActionOutput(port, (short) 0));
List<OFAction> actions = getDiscoveryActions(port);
po.setActions(actions);
po.setActionsLength((short) OFActionOutput.MINIMUM_LENGTH);
......@@ -787,17 +852,9 @@ public class LinkDiscoveryManager implements IOFMessageListener,
boolean isStandard, FloodlightContext cntx) {
// If LLDP is suppressed on this port, ignore received packet as well
IOFSwitch iofSwitch = floodlightProvider.getSwitches().get(sw);
if (iofSwitch == null) {
return Command.STOP;
}
if (isLinkDiscoverySuppressed(sw, pi.getInPort())) {
if (log.isTraceEnabled()) {
log.trace("Got a LLDP=[{}] from a supressed switchport sw = {}, port = {}. Not fowarding it.",
new Object[] {lldp.toString(), HexString.toHexString(sw), pi.getInPort()});
}
if (!isIncomingDiscoveryAllowed(sw, pi.getInPort(), isStandard))
return Command.STOP;
}
// If this is a malformed LLDP, or not from us, exit
if (lldp.getPortId() == null || lldp.getPortId().getLength() != 3) {
......@@ -2227,4 +2284,4 @@ public class LinkDiscoveryManager implements IOFMessageListener,
else
log.info("Setting autoportfast feature to OFF");
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment