[ONOS-4424] use fingerprinted Ethernet source
Fix to ecord.co app to work with fingerprinted Ethernet source, not
an additional TLV.
This patch relies on the related patch in ONOS.
Change-Id: Ie1085c167efddbd125f186c1b1ba3b2544f01353
diff --git a/ecord/co/src/main/java/org/onosproject/ecord/co/BigSwitchDeviceProvider.java b/ecord/co/src/main/java/org/onosproject/ecord/co/BigSwitchDeviceProvider.java
index d75f59e..5e96c6f 100644
--- a/ecord/co/src/main/java/org/onosproject/ecord/co/BigSwitchDeviceProvider.java
+++ b/ecord/co/src/main/java/org/onosproject/ecord/co/BigSwitchDeviceProvider.java
@@ -29,11 +29,9 @@
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.onlab.packet.Ethernet;
-import org.onlab.packet.LLDPOrganizationalTLV;
import org.onlab.packet.ONOSLLDP;
import org.onlab.util.Tools;
import org.onosproject.cfg.ComponentConfigService;
-import org.onosproject.cluster.ClusterMetadata;
import org.onosproject.cluster.ClusterMetadataService;
import org.onosproject.cluster.ClusterService;
import org.onosproject.incubator.rpc.RemoteServiceContext;
@@ -55,7 +53,7 @@
import org.onosproject.net.device.DeviceProviderService;
import org.onosproject.net.device.PortDescription;
import org.onosproject.net.link.DefaultLinkDescription;
-import org.onosproject.net.link.LinkProvider;
+import org.onosproject.net.link.ProbedLinkProvider;
import org.onosproject.net.link.LinkProviderRegistry;
import org.onosproject.net.link.LinkProviderService;
import org.onosproject.net.packet.DefaultOutboundPacket;
@@ -83,7 +81,6 @@
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
import static org.onlab.util.Tools.groupedThreads;
-import static org.onosproject.cluster.ClusterMetadata.NO_NAME;
import static org.onosproject.ecord.co.BigSwitchManager.REALIZED_BY;
import static org.onosproject.net.config.basics.SubjectFactories.CONNECT_POINT_SUBJECT_FACTORY;
import static org.onosproject.net.flow.DefaultTrafficTreatment.builder;
@@ -108,7 +105,7 @@
* Device provider which exposes a big switch abstraction of the underlying data path.
*/
@Component(immediate = true)
-public class BigSwitchDeviceProvider implements DeviceProvider, LinkProvider {
+public class BigSwitchDeviceProvider implements DeviceProvider, ProbedLinkProvider {
private static final Logger LOG = getLogger(BigSwitchDeviceProvider.class);
@@ -121,9 +118,6 @@
private static final String PROP_METRO_IP = "metroIp";
private static final String DEFAULT_METRO_IP = "localhost";
- // make this an ONOSLLDP utility value?
- private static final String SRC_MAC = "DE:AD:BE:EF:BA:11";
-
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected BigSwitchService bigSwitchService;
@@ -154,7 +148,6 @@
private LinkProviderService linkProviderService;
private ScheduledExecutorService executor;
private ScheduledFuture<?> future;
- private String fingerPrint;
private BigSwitchListener listener = new InternalListener();
@@ -437,10 +430,13 @@
private void prepareProbe() {
ethPacket.setEtherType(Ethernet.TYPE_LLDP)
.setDestinationMACAddress(ONOSLLDP.LLDP_NICIRA)
- .setSourceMACAddress(SRC_MAC)
.setPad(true);
}
+ private String buildMac() {
+ return ProbedLinkProvider.fingerprintMac(metadataService.getClusterMetadata());
+ }
+
private class InternalListener implements BigSwitchListener {
@Override
public void event(BigSwitchEvent event) {
@@ -511,18 +507,12 @@
@Override
public void run() {
- // fingerprint shouldn't change so if we get it once, it can be stashed
- if (fingerPrint == null || NO_NAME.equals(fingerPrint)) {
- ClusterMetadata mData = metadataService.getClusterMetadata();
- fingerPrint = mData == null ? NO_NAME : mData.getName();
- }
bigSwitchService.getPorts().forEach(p -> {
// ID of big switch contains schema, so we're good
- ONOSLLDP lldp = ONOSLLDP.fingerprintedLLDP(bigSwitch.id().toString(),
+ ONOSLLDP lldp = ONOSLLDP.onosLLDP(bigSwitch.id().toString(),
bigSwitch.chassisId(),
- (int) p.portNumber().toLong(),
- fingerPrint);
- ethPacket.setPayload(lldp);
+ (int) p.portNumber().toLong());
+ ethPacket.setSourceMACAddress(buildMac()).setPayload(lldp);
// recover physical connect point
ConnectPoint real = ConnectPoint.deviceConnectPoint(
@@ -548,7 +538,7 @@
if (probe == null) {
return;
}
- if (isValidProbe(probe)) {
+ if (isValidProbe(eth.getSourceMAC().toString(), probe)) {
/*
* build and pass a linkDesription to the metro domain, which
* will map out a virtual link between the two big switches.
@@ -569,33 +559,16 @@
}
/*
- * true for probes from other controller clusters, that are
- * fingerprinted. Possibly also check that the other end's connect
- * point is that of a big switch.
+ * true for probes from other controller clusters, that are from big switches.
*/
- private boolean isValidProbe(ONOSLLDP probe) {
- LLDPOrganizationalTLV tlv = probe.getDomainTLV();
- if (tlv == null) {
+ private boolean isValidProbe(String mac, ONOSLLDP probe) {
+ // don't consider ourselves valid if we're using DEFAULT_MAC
+ String ourMac = buildMac();
+ if (mac.equalsIgnoreCase(ourMac) || ProbedLinkProvider.defaultMac().equalsIgnoreCase(ourMac)) {
return false;
}
- ClusterMetadata mdata = metadataService.getClusterMetadata();
- if (mdata == null) {
- LOG.warn("In transient state, ignoring probes until I'm sane");
- return false;
- }
- String us = mdata.getName();
- String them = probe.getDomainString();
- if (NO_NAME.equals(them)) {
- LOG.warn("Cluster for {} in transient state; ignoring", probe.getDeviceString());
- return false;
- }
- if (us.equals(them)) {
- LOG.debug("Got LLDP from myself (name={})", us);
- return false;
- } else {
- // only want probes from a virtualized domain edge, i.e. a bigswitch
- return probe.getDeviceString().contains("bigswitch") ? true : false;
- }
+ // TODO Come up with more rubust way to identify bigswitch probe?
+ return probe.getDeviceString().contains("bigswitch");
}
}
}