Merge branch 'master' of ssh://gerrit.onlab.us:29418/onos-next
diff --git a/providers/host/pom.xml b/providers/host/pom.xml
index e0f9cef..1cd580f 100644
--- a/providers/host/pom.xml
+++ b/providers/host/pom.xml
@@ -16,5 +16,15 @@
<packaging>bundle</packaging>
<description>ONOS host tracking provider</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.onlab.onos</groupId>
+ <artifactId>onos-api</artifactId>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+
</project>
diff --git a/providers/lldp/src/main/java/org/onlab/onos/provider/lldp/impl/LLDPLinkProvider.java b/providers/lldp/src/main/java/org/onlab/onos/provider/lldp/impl/LLDPLinkProvider.java
index f4ab71d..acffe54 100644
--- a/providers/lldp/src/main/java/org/onlab/onos/provider/lldp/impl/LLDPLinkProvider.java
+++ b/providers/lldp/src/main/java/org/onlab/onos/provider/lldp/impl/LLDPLinkProvider.java
@@ -5,6 +5,7 @@
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onlab.onos.mastership.MastershipService;
import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.Device;
import org.onlab.onos.net.DeviceId;
@@ -46,6 +47,9 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected PacketService packetSevice;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected MastershipService masterService;
+
private LinkProviderService providerService;
private final boolean useBDDP = true;
@@ -95,7 +99,7 @@
switch (event.type()) {
case DEVICE_ADDED:
discoverers.put(device.id(),
- new LinkDiscovery(device, packetSevice,
+ new LinkDiscovery(device, packetSevice, masterService,
providerService, useBDDP));
break;
case PORT_ADDED:
diff --git a/providers/lldp/src/main/java/org/onlab/onos/provider/lldp/impl/LinkDiscovery.java b/providers/lldp/src/main/java/org/onlab/onos/provider/lldp/impl/LinkDiscovery.java
index 6ad6124..4282199 100644
--- a/providers/lldp/src/main/java/org/onlab/onos/provider/lldp/impl/LinkDiscovery.java
+++ b/providers/lldp/src/main/java/org/onlab/onos/provider/lldp/impl/LinkDiscovery.java
@@ -30,10 +30,12 @@
import org.jboss.netty.util.Timeout;
import org.jboss.netty.util.TimerTask;
+import org.onlab.onos.mastership.MastershipService;
import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.Device;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.Link.Type;
+import org.onlab.onos.net.MastershipRole;
import org.onlab.onos.net.Port;
import org.onlab.onos.net.PortNumber;
import org.onlab.onos.net.flow.DefaultTrafficTreatment;
@@ -79,22 +81,24 @@
private final boolean useBDDP;
private final LinkProviderService linkProvider;
private final PacketService pktService;
+ private final MastershipService mastershipService;
private Timeout timeout;
/**
* Instantiates discovery manager for the given physical switch. Creates a
* generic LLDP packet that will be customized for the port it is sent out on.
* Starts the the timer for the discovery process.
- *
- * @param device the physical switch
+ * @param device the physical switch
+ * @param masterService
* @param useBDDP flag to also use BDDP for discovery
*/
public LinkDiscovery(Device device, PacketService pktService,
- LinkProviderService providerService, Boolean... useBDDP) {
+ MastershipService masterService, LinkProviderService providerService, Boolean... useBDDP) {
this.device = device;
this.probeRate = 3000;
this.linkProvider = providerService;
this.pktService = pktService;
+ this.mastershipService = masterService;
this.slowPorts = Collections.synchronizedSet(new HashSet<Long>());
this.fastPorts = Collections.synchronizedSet(new HashSet<Long>());
this.portProbeCount = new HashMap<>();
@@ -337,12 +341,15 @@
}
private void sendProbes(Long portNumber) {
- OutboundPacket pkt = this.createOutBoundLLDP(portNumber);
- pktService.emit(pkt);
- if (useBDDP) {
- OutboundPacket bpkt = this.createOutBoundBDDP(portNumber);
- pktService.emit(bpkt);
- }
+ if (mastershipService.getLocalRole(this.device.id()) ==
+ MastershipRole.MASTER) {
+ OutboundPacket pkt = this.createOutBoundLLDP(portNumber);
+ pktService.emit(pkt);
+ if (useBDDP) {
+ OutboundPacket bpkt = this.createOutBoundBDDP(portNumber);
+ pktService.emit(bpkt);
+ }
+ }
}
}