Javadoc cleanups and some additional error checking
Change-Id: I0f36b1a875c0f43891e65dcc35f6023000476091
diff --git a/mfwd/src/main/java/org/onosproject/mfwd/impl/McastForwarding.java b/mfwd/src/main/java/org/onosproject/mfwd/impl/McastForwarding.java
index 7377605..1b730fa 100644
--- a/mfwd/src/main/java/org/onosproject/mfwd/impl/McastForwarding.java
+++ b/mfwd/src/main/java/org/onosproject/mfwd/impl/McastForwarding.java
@@ -94,6 +94,7 @@
/**
* Get the application ID, used by the McastIntentManager.
+ *
* @return the application ID
*/
public static ApplicationId getAppId() {
@@ -106,7 +107,8 @@
private class ReactivePacketProcessor implements PacketProcessor {
/**
- * process incoming packets.
+ * Process incoming packets.
+ *
* @param context packet processing context
*/
@Override
@@ -138,19 +140,19 @@
IpAddress gaddr = IpAddress.valueOf(ip.getDestinationAddress());
IpAddress saddr = Ip4Address.valueOf(ip.getSourceAddress());
- log.debug("Packet (" + saddr.toString() + ", " + gaddr.toString() +
- "\tingress port: " + context.inPacket().receivedFrom().toString());
+ log.debug("Packet ({}, {}) has been punted\n" +
+ "\tingress port: {}\n",
+ saddr.toString(),
+ gaddr.toString(),
+ context.inPacket().receivedFrom().toString());
- IpPrefix mcast = IpPrefix.valueOf("224.0.0.0/4");
if (!mcast.contains(gaddr)) {
-
- // The IP destination is not a multicast address
+ // Yikes, this is a bad group address
return;
}
if (mcast.contains(saddr)) {
-
- // The IP source is a multicast address.
+ // Yikes, the source address is multicast
return;
}
@@ -166,7 +168,7 @@
* ingress port would be a specific device.
*/
McastRoute entry = mrib.findBestMatch(spfx, gpfx);
- if (entry == null) {
+ if (entry == null || entry.getSaddr().equals(IPv4.fromIPv4Address(0))) {
/*
* Create an entry that we can fast drop.
@@ -190,7 +192,11 @@
/*
* This is odd, we should not have received a punted packet if an
* intent was installed unless the intent was not installed
- * correctly.
+ * correctly. However, we are seeing packets get punted after
+ * the intent has been installed.
+ *
+ * Therefore we are going to forward the packets even if they
+ * should have already been forwarded by the intent fabric.
*/
if (entry.getIntentKey() != null) {
return;
@@ -209,6 +215,7 @@
/**
* Forward the packet to it's multicast destinations.
+ *
* @param context The packet context
* @param entry The multicast route entry matching this packet
*/
diff --git a/mfwd/src/main/java/org/onosproject/mfwd/impl/McastIntentManager.java b/mfwd/src/main/java/org/onosproject/mfwd/impl/McastIntentManager.java
index 67a6045..c3709e6 100644
--- a/mfwd/src/main/java/org/onosproject/mfwd/impl/McastIntentManager.java
+++ b/mfwd/src/main/java/org/onosproject/mfwd/impl/McastIntentManager.java
@@ -59,6 +59,7 @@
/**
* Get instance of this intentManager.
+ *
* @return the instance of this intent manager.
*/
public static McastIntentManager getInstance() {
@@ -70,6 +71,7 @@
/**
* Install the PointToMultipoint forwarding intent.
+ *
* @param mroute multicast route entry
* @return the intent that has been set or null otherwise
*/
@@ -109,6 +111,7 @@
/**
* Withdraw the intent represented by this route.
+ *
* @param mroute the mcast route whose intent we want to remove
*/
public void withdrawIntent(McastRouteBase mroute) {
diff --git a/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRoute.java b/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRoute.java
index 06073a3..d56488e 100644
--- a/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRoute.java
+++ b/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRoute.java
@@ -29,26 +29,30 @@
interface McastRoute {
/**
- * get the group addresses.
+ * Gets the group addresses.
+ *
* @return group address
*/
public IpPrefix getGaddr();
/**
- * get the source address.
+ * Gets the source address.
+ *
* @return the source address
*/
public IpPrefix getSaddr();
/**
- * Is this an IPv4 multicast route.
+ * Determines if this is an IPv4 multicast route.
+ *
* @return true if it is an IPv4 route
*/
public boolean isIp4();
/**
- * Is this an IPv4 multicast route.
- * @return true if it is an IPv4 route
+ * Determines if this is an IPv6 multicast route.
+ *
+ * @return true if it is an IPv6 route
*/
public boolean isIp6();
@@ -61,6 +65,7 @@
/**
* Add the ingress Connect Point using. ..
+ *
* @param deviceId device ID
* @param portNum port number
*/
@@ -68,18 +73,21 @@
/**
* Get the ingress connect point.
+ *
* @return the ingress connect point
*/
public ConnectPoint getIngressPoint();
/**
* Add an egress connect point.
+ *
* @param member the egress ConnectPoint to be added
*/
public void addEgressPoint(ConnectPoint member);
/**
* Add an egress connect point.
+ *
* @param deviceId the device ID of the connect point
* @param portNum the port number of the connect point
*/
@@ -87,6 +95,7 @@
/**
* Get the egress connect points.
+ *
* @return a set of egress connect points
*/
public Set<ConnectPoint> getEgressPoints();
@@ -98,9 +107,10 @@
/**
* Get the punt count.
+ *
* @return the punt count
*/
- public Integer getPuntCount();
+ public int getPuntCount();
/**
* Have the McastIntentManager create an intent, attempt to
@@ -110,6 +120,7 @@
/**
* Set the Intent key.
+ *
* @param intent intent
*/
public void setIntent(SinglePointToMultiPointIntent intent);
@@ -121,12 +132,14 @@
/**
* Get the intent key.
+ *
* @return the intentKey
*/
public Key getIntentKey();
/**
* Pretty print the the route.
+ *
* @return a pretty string
*/
public String toString();
diff --git a/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteBase.java b/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteBase.java
index cbe9904..36582ad 100644
--- a/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteBase.java
+++ b/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteBase.java
@@ -77,6 +77,7 @@
/**
* Set the source and group address value of a (*, G) group.
+ *
* @param gpfx the group prefix address
*/
public McastRouteBase(IpPrefix gpfx) {
@@ -85,6 +86,7 @@
/**
* Create a multicast route constructor.
+ *
* @param saddr source address
* @param gaddr group address
*/
@@ -103,6 +105,7 @@
/**
* Get the multicast group address.
+ *
* @return the multicast group address
*/
@Override
@@ -112,6 +115,7 @@
/**
* Get the multicast source address.
+ *
* @return the multicast source address
*/
@Override
@@ -121,6 +125,7 @@
/**
* Is this an IPv4 multicast route.
+ *
* @return true if it is an IPv4 route
*/
@Override
@@ -130,6 +135,7 @@
/**
* Is this an IPv6 multicast route.
+ *
* @return true if it is an IPv6 route
*/
@Override
@@ -139,6 +145,7 @@
/**
* Is this a multicast group route?
+ *
* @return true if it is a multicast group route.
*/
public boolean isGroup() {
@@ -164,6 +171,7 @@
/**
* Add or modify the ingress connect point.
+ *
* @param deviceId the switch device Id
* @param portNum the ingress port number
*/
@@ -176,6 +184,7 @@
/**
* Get the ingress ConnectPoint.
+ *
* @return the ingress ConnectPoint
*/
@Override
@@ -207,6 +216,7 @@
/**
* Get egress connect points for the route.
+ *
* @return Set of egress connect points
*/
@Override
@@ -216,10 +226,11 @@
/**
* Get the number of times the packet has been punted.
+ *
* @return the punt count
*/
@Override
- public Integer getPuntCount() {
+ public int getPuntCount() {
return puntCount;
}
@@ -252,6 +263,7 @@
/**
* Set the Intent key.
+ *
* @param intent intent
*/
@Override
@@ -261,6 +273,7 @@
/**
* Get the intent key represented by this route.
+ *
* @return intentKey
*/
@Override
@@ -285,6 +298,7 @@
/**
* Pretty Print this Multicast Route. Works for McastRouteSource and McastRouteGroup.
+ *
* @return pretty string of the multicast route
*/
@Override
diff --git a/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteGroup.java b/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteGroup.java
index 2159093..4a58e1b 100644
--- a/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteGroup.java
+++ b/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteGroup.java
@@ -40,6 +40,7 @@
/**
* Create a multicast group.
+ *
* @param gpfx - Group address
*/
public McastRouteGroup(IpPrefix gpfx) {
@@ -57,6 +58,7 @@
/**
* Find a specific multicast source address for this group.
+ *
* @param saddr the source address
* @return the multicast source route or null if it does not exist
*/
@@ -66,6 +68,7 @@
/**
* Return the entire set of multicast sources for this group.
+ *
* @return the set of multicast sources
*/
public HashMap<IpPrefix, McastRouteSource> getSources() {
@@ -84,6 +87,7 @@
/**
* Remove the source with this specific IpPrefix from this group entry.
+ *
* @param spfx IP Prefix of the source to be removed
* @return the source route that was just removed
*/
diff --git a/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteSource.java b/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteSource.java
index 9dd9a3c..68edc2e 100644
--- a/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteSource.java
+++ b/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteSource.java
@@ -39,6 +39,7 @@
/**
* Set our parent multicast group.
+ *
* @param group the group this source belongs to
*/
public void setGroup(McastRouteGroup group) {
diff --git a/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteTable.java b/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteTable.java
index b15cd4b..ff7a026 100644
--- a/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteTable.java
+++ b/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteTable.java
@@ -59,6 +59,7 @@
/**
* Get the single instance of this multicast group address.
+ *
* @return the multicast route table
*/
public static McastRouteTable getInstance() {
@@ -70,7 +71,8 @@
/**
* Get the IPv4 MRIB.
- * @return the IPv4 MRIB.
+ *
+ * @return the IPv4 MRIB
*/
public Map<IpPrefix, McastRouteGroup> getMrib4() {
return mrib4;
@@ -78,8 +80,7 @@
/**
* Get the IPv6 MRIB.
- * XXX: should we throw an exception if somebody requests the ipv6 address when
- * it has not been enabled, or just return null as we do now.
+ *
* @return Return the set of prefix keyed McastGroups
*/
public Map<IpPrefix, McastRouteGroup> getMrib6() {
@@ -94,22 +95,21 @@
private void storeGroup(McastRouteGroup group) {
if (group.isIp4()) {
mrib4.put(group.getGaddr(), group);
- } else {
- if (ipv6Enabled) {
- mrib6.put(group.getGaddr(), group);
- }
+ } else if (group.isIp6() && ipv6Enabled) {
+ mrib6.put(group.getGaddr(), group);
}
}
/**
- * remove the group.
+ * Remove the group.
+ *
* @param group the group to be removed
*/
private void removeGroup(McastRouteGroup group) {
IpPrefix gpfx = group.getGaddr();
if (gpfx.isIp4()) {
mrib4.remove(gpfx);
- } else if (ipv6Enabled) {
+ } else if (gpfx.isIp6() && ipv6Enabled) {
mrib6.remove(gpfx);
}
}
@@ -156,11 +156,8 @@
// Save it for later
if (gpfx.isIp4()) {
this.mrib4.put(gpfx, group);
- } else {
-
- if (ipv6Enabled) {
+ } else if (gpfx.isIp6() && ipv6Enabled) {
this.mrib6.put(gpfx, group);
- }
}
}
@@ -253,6 +250,7 @@
/**
* Find the specific multicast group entry.
+ *
* @param group the group address
* @return McastRouteGroup the multicast (*, G) group route
*/
@@ -260,21 +258,20 @@
McastRouteGroup g = null;
if (group.isIp4()) {
g = mrib4.get(group);
- } else {
- if (ipv6Enabled) {
+ } else if (group.isIp6() && ipv6Enabled) {
g = mrib6.get(group);
- }
}
return g;
}
/**
* Find the multicast (S, G) entry if it exists.
- * @param gaddr the group address
+ *
* @param saddr the source address
+ * @param gaddr the group address
* @return The multicast source route entry if it exists, null if it does not.
*/
- public McastRouteSource findMcastSource(IpPrefix gaddr, IpPrefix saddr) {
+ public McastRouteSource findMcastSource(IpPrefix saddr, IpPrefix gaddr) {
McastRouteGroup grp = findMcastGroup(checkNotNull(gaddr));
if (grp == null) {
return null;