Make LinkManager aware of unidirectional links.
Change-Id: I8a1a9b1909bf47dcca65fd2440dd54599916e193
diff --git a/core/net/src/main/java/org/onosproject/net/link/impl/LinkManager.java b/core/net/src/main/java/org/onosproject/net/link/impl/LinkManager.java
index cfed826..3027334 100644
--- a/core/net/src/main/java/org/onosproject/net/link/impl/LinkManager.java
+++ b/core/net/src/main/java/org/onosproject/net/link/impl/LinkManager.java
@@ -346,25 +346,28 @@
removeLink(lk.dst(), lk.src());
return;
}
- Link link = getLink(lk.src(), lk.dst());
- LinkDescription fldesc;
- LinkDescription rldesc;
+
+ doUpdate(lk.src(), lk.dst(), cfg);
+ if (cfg.isBidirectional()) {
+ doUpdate(lk.dst(), lk.src(), cfg);
+ }
+ }
+
+ private void doUpdate(ConnectPoint src, ConnectPoint dst, BasicLinkConfig cfg) {
+ Link link = getLink(src, dst);
+ LinkDescription desc;
+
if (link == null) {
- fldesc = BasicLinkOperator.descriptionOf(lk.src(), lk.dst(), cfg);
- rldesc = BasicLinkOperator.descriptionOf(lk.dst(), lk.src(), cfg);
+ desc = BasicLinkOperator.descriptionOf(src, dst, cfg);
} else {
- fldesc = BasicLinkOperator.combine(cfg,
- BasicLinkOperator.descriptionOf(lk.src(), lk.dst(), link));
- rldesc = BasicLinkOperator.combine(cfg,
- BasicLinkOperator.descriptionOf(lk.dst(), lk.src(), link));
+ desc = BasicLinkOperator.combine(cfg,
+ BasicLinkOperator.descriptionOf(src, dst, link));
}
ProviderId pid = Optional.ofNullable(link)
- .map(Link::providerId)
- .orElse(ProviderId.NONE);
- store.createOrUpdateLink(pid, fldesc);
- store.createOrUpdateLink(pid, rldesc);
+ .map(Link::providerId)
+ .orElse(ProviderId.NONE);
+ store.createOrUpdateLink(pid, desc);
}
-
}
}