Bgp and Pcep maintaiability
Change-Id: I2c14cc29d4900ef2f0fbffd4761b0d78e282910f
diff --git a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpConnectPeer.java b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpConnectPeer.java
index 03310a6..d42d32c 100644
--- a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpConnectPeer.java
+++ b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpConnectPeer.java
@@ -17,12 +17,28 @@
*/
public interface BgpConnectPeer {
/**
- * Initiate bgp peer connection.
- */
+ * Initiate bgp peer connection.
+ */
void connectPeer();
/**
- * End bgp peer connection.
- */
+ * End bgp peer connection.
+ */
void disconnectPeer();
+
+ /**
+ * Returns the peer port.
+ *
+ * @return PeerPort
+ */
+ int getPeerPort();
+
+ /**
+ * Returns the connect retry counter.
+ *
+ * @return connectRetryCounter
+ */
+ int getConnectRetryCounter();
+
+
}
diff --git a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java
index 90a8eed..e562b94 100644
--- a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java
+++ b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpController.java
@@ -19,6 +19,7 @@
import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.protocol.BgpMessage;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -61,7 +62,7 @@
* Send a message to a particular bgp peer.
*
* @param bgpId the id of the peer to send message.
- * @param msg the message to send
+ * @param msg the message to send
*/
void writeMsg(BgpId bgpId, BgpMessage msg);
@@ -69,14 +70,13 @@
* Process a message and notify the appropriate listeners.
*
* @param bgpId id of the peer the message arrived on
- * @param msg the message to process.
+ * @param msg the message to process.
* @throws BgpParseException on data processing error
*/
void processBgpPacket(BgpId bgpId, BgpMessage msg) throws BgpParseException;
/**
* Close all connected BGP peers.
- *
*/
void closeConnectedPeers();
@@ -149,4 +149,35 @@
* @return link listener
*/
Set<BgpLinkListener> linkListener();
+
+ /**
+ * Stores the exceptions occured during an active session.
+ *
+ * @param peerId BGP peer id
+ * @param exception exceptions based on the peer id.
+ */
+ void activeSessionExceptionAdd(String peerId, String exception);
+
+ /**
+ * Stores the exceptions occured during an closed session.
+ *
+ * @param peerId BGP peer id
+ * @param exception exceptions based on the peer id
+ */
+ void closedSessionExceptionAdd(String peerId, String exception);
+
+ /**
+ * Return active session exceptions.
+ *
+ * @return activeSessionMap
+ */
+ Map<String, List<String>> activeSessionMap();
+
+ /**
+ * Return closed session exceptions.
+ *
+ * @return closedSessionMap
+ */
+ Map<String, List<String>> closedSessionMap();
+
}
diff --git a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java
index a0f5952..fb9ca1d 100644
--- a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java
+++ b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpDpid.java
@@ -61,8 +61,10 @@
this.stringBuilder.append(":ROUTINGUNIVERSE=").append(((BgpLinkLsNlriVer4) linkNlri).getIdentifier());
if (nodeDescriptorType == NODE_DESCRIPTOR_LOCAL) {
+ log.debug("Local node descriptor added");
add(linkNlri.localNodeDescriptors());
} else if (nodeDescriptorType == NODE_DESCRIPTOR_REMOTE) {
+ log.debug("Remote node descriptor added");
add(linkNlri.remoteNodeDescriptors());
}
}
@@ -93,7 +95,7 @@
this.stringBuilder.append(":ROUTINGUNIVERSE=").append(((BgpNodeLSNlriVer4) nlri).getIdentifier());
add(((BgpNodeLSNlriVer4) nlri).getLocalNodeDescriptors().getNodedescriptors());
- log.info("BgpDpid :: add");
+ log.debug("BgpDpid :: add");
}
/**
@@ -103,7 +105,7 @@
* @return instance of this class
*/
public BgpDpid add(final NodeDescriptors value) {
- log.info("BgpDpid :: add function");
+ log.debug("BgpDpid :: add function");
if (value != null) {
List<BgpValueType> subTlvs = value.getSubTlvs();
ListIterator<BgpValueType> listIterator = subTlvs.listIterator();
@@ -148,7 +150,7 @@
try {
return new URI(SCHEME, value, null);
} catch (URISyntaxException e) {
- log.info("Exception BgpId URI: " + e.toString());
+ log.debug("Exception BgpId URI: " + e.toString());
}
return null;
}
diff --git a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java
index 456ecd2..a10fafc 100644
--- a/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java
+++ b/protocols/bgp/api/src/main/java/org/onosproject/bgp/controller/BgpLocalRib.java
@@ -16,8 +16,14 @@
import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.protocol.BgpLSNlri;
import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails;
+import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib;
+import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier;
+import org.onosproject.bgpio.protocol.linkstate.BgpLinkLSIdentifier;
+import org.onosproject.bgpio.protocol.linkstate.BgpPrefixLSIdentifier;
import org.onosproject.bgpio.types.RouteDistinguisher;
+import java.util.Map;
+
/**
* Abstraction of BGP local RIB.
*/
@@ -62,4 +68,46 @@
* @throws BgpParseException while deleting NLRI from local rib
*/
void delete(BgpLSNlri nlri, RouteDistinguisher routeDistinguisher) throws BgpParseException;
+
+ /**
+ * Returns node NLRI tree.
+ *
+ * @return node tree
+ */
+ Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib> nodeTree();
+
+ /**
+ * Returns link NLRI tree.
+ *
+ * @return link tree
+ */
+ Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib> linkTree();
+
+ /**
+ * Returns prefix NLRI tree.
+ *
+ * @return prefix tree
+ */
+ Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib> prefixTree();
+
+ /**
+ * Returns VPN node NLRI tree.
+ *
+ * @return vpn node NLRI tree
+ */
+ Map<RouteDistinguisher, Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnNodeTree();
+
+ /**
+ * Returns VPN link NLRI tree.
+ *
+ * @return vpn link NLRI Tree
+ */
+ Map<RouteDistinguisher, Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnLinkTree();
+
+ /**
+ * Returns VPN prefix NLRI tree.
+ *
+ * @return vpn prefix NLRI Tree
+ */
+ Map<RouteDistinguisher, Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnPrefixTree();
}
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java
index 0294c9c..e80fd13 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpLinkLSIdentifier.java
@@ -83,15 +83,15 @@
* @throws BgpParseException while parsing link identifier
*/
public static BgpLinkLSIdentifier parseLinkIdendifier(ChannelBuffer cb, byte protocolId) throws BgpParseException {
- //Parse local node descriptor
+ log.debug("Parse local node descriptor");
NodeDescriptors localNodeDescriptors = new NodeDescriptors();
localNodeDescriptors = parseNodeDescriptors(cb, NodeDescriptors.LOCAL_NODE_DES_TYPE, protocolId);
- //Parse remote node descriptor
+ log.debug("Parse remote node descriptor");
NodeDescriptors remoteNodeDescriptors = new NodeDescriptors();
remoteNodeDescriptors = parseNodeDescriptors(cb, NodeDescriptors.REMOTE_NODE_DES_TYPE, protocolId);
- //Parse link descriptor
+ log.debug("Parse link descriptor");
LinkedList<BgpValueType> linkDescriptor = new LinkedList<>();
linkDescriptor = parseLinkDescriptors(cb);
return new BgpLinkLSIdentifier(localNodeDescriptors, remoteNodeDescriptors, linkDescriptor);
@@ -108,7 +108,7 @@
*/
public static NodeDescriptors parseNodeDescriptors(ChannelBuffer cb, short desType, byte protocolId)
throws BgpParseException {
- log.debug("parse Node descriptors");
+ log.debug("Parse node descriptors");
ChannelBuffer tempBuf = cb.copy();
short type = cb.readShort();
short length = cb.readShort();
@@ -166,8 +166,8 @@
break;
case BgpAttrNodeMultiTopologyId.ATTRNODE_MULTITOPOLOGY:
tlv = BgpAttrNodeMultiTopologyId.read(tempCb);
- count++;
- //MultiTopologyId TLV cannot repeat more than once
+ count = count++;
+ log.debug("MultiTopologyId TLV cannot repeat more than once");
if (count > 1) {
//length + 4 implies data contains type, length and value
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java
index 2cecf0c..a1035e2 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpNodeLSNlriVer4.java
@@ -135,7 +135,7 @@
byte protocolId = cb.readByte();
long identifier = cb.readLong();
- // Parse Local Node Descriptors
+ log.debug("Parse local node descriptors");
BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier();
localNodeDescriptors = BgpNodeLSIdentifier.parseLocalNodeDescriptors(cb, protocolId);
return new BgpNodeLSNlriVer4(identifier, protocolId, localNodeDescriptors, isVpn, routeDistinguisher);
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java
index fbfc781..eb795b4 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/BgpPrefixLSIdentifier.java
@@ -51,6 +51,7 @@
public BgpPrefixLSIdentifier() {
this.localNodeDescriptors = null;
this.prefixDescriptor = null;
+ log.debug("Parameters are reset");
}
/**
@@ -74,11 +75,11 @@
*/
public static BgpPrefixLSIdentifier parsePrefixIdendifier(ChannelBuffer cb, byte protocolId)
throws BgpParseException {
- //Parse Local Node descriptor
+ log.debug("Parse local node descriptor");
NodeDescriptors localNodeDescriptors = new NodeDescriptors();
localNodeDescriptors = parseLocalNodeDescriptors(cb, protocolId);
- //Parse Prefix descriptor
+ log.debug("MultiTopologyId TLV cannot repeat more than once");
List<BgpValueType> prefixDescriptor = new LinkedList<>();
prefixDescriptor = parsePrefixDescriptors(cb);
return new BgpPrefixLSIdentifier(localNodeDescriptors, prefixDescriptor);
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java
index ac44c54..7cb13aa 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpKeepaliveMsgVer4.java
@@ -124,13 +124,13 @@
@Override
public void write(ChannelBuffer cb, BgpKeepaliveMsgVer4 message) {
- // write marker
+ log.debug("Write marker");
cb.writeBytes(marker, 0, MARKER_LENGTH);
- // write length of header
+ log.debug("Write length of header");
cb.writeShort(PACKET_MINIMUM_LENGTH);
- // write the type of message
+ log.debug("Write the type of message");
cb.writeByte(MSG_TYPE.getType());
}
}
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java
index b252de8..382f123 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpNotificationMsgVer4.java
@@ -198,7 +198,7 @@
cb.writeBytes(message.data);
}
- //Update message length field in notification message
+ log.debug("Update message length field in notification message");
int length = cb.writerIndex() - msgStartIndex;
cb.setShort(headerLenIndex, (short) length);
message.bgpHeader.setLength((short) length);
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java
index 5ab79fe..d8900ad 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpOpenMsgVer4.java
@@ -193,14 +193,19 @@
// Read AS number
asNumber = cb.getUnsignedShort(cb.readerIndex());
cb.readShort();
+ log.debug("AS number read");
+
// Read Hold timer
holdTime = cb.readShort();
+ log.debug("Holding time read");
// Read BGP Identifier
bgpId = cb.readInt();
+ log.debug("BGP identifier read");
// Read optional parameter length
optParaLen = cb.readByte();
+ log.debug("OPtional parameter length read");
// Read Capabilities if optional parameter length is greater than 0
if (optParaLen != 0) {
@@ -263,7 +268,7 @@
throw new BgpParseException("Invalid length received for RpdCapability.");
}
if (length > cb.readableBytes()) {
- throw new BgpParseException("Four octet as num tlv length"
+ throw new BgpParseException("Four octet as num TLV length"
+ " is more than readableBytes.");
}
short rpdAfi = cb.readShort();
@@ -559,7 +564,7 @@
while (listIterator.hasNext()) {
BgpValueType tlv = listIterator.next();
if (tlv == null) {
- log.debug("Warning: tlv is null from CapabilityTlv list");
+ log.debug("Warning: TLV is null from CapabilityTlv list");
continue;
}
tlv.write(cb);
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java
index 9f8ec82..6847dd6 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpPathAttributes.java
@@ -154,7 +154,7 @@
pathAttribute = WideCommunity.read(cb);
break;
default:
- //skip bytes for unsupported attribute types
+ log.debug("Skip bytes for unsupported attribute types");
UnSupportedAttribute.read(cb);
}
pathAttributeList.add(pathAttribute);
@@ -263,19 +263,19 @@
}
if (!isOrigin) {
- log.debug("Mandatory Attributes not Present");
+ log.debug("Mandatory attributes not Present");
Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
Origin.ORIGIN_TYPE);
}
if (!isAsPath) {
- log.debug("Mandatory Attributes not Present");
+ log.debug("Mandatory attributes not Present");
Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
AsPath.ASPATH_TYPE);
}
if (!isMpUnReach && !isMpReach && !isNextHop) {
- log.debug("Mandatory Attributes not Present");
+ log.debug("Mandatory attributes not Present");
Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
NextHop.NEXTHOP_TYPE);
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java
index 7062a7d..b6576a3 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BgpUpdateMsgVer4.java
@@ -130,7 +130,7 @@
LinkedList<IpPrefix> withDrwRoutes = new LinkedList<>();
LinkedList<IpPrefix> nlri = new LinkedList<>();
BgpPathAttributes bgpPathAttributes = new BgpPathAttributes();
- // Reading Withdrawn Routes Length
+
Short withDrwLen = cb.readShort();
if (cb.readableBytes() < withDrwLen) {
@@ -138,13 +138,15 @@
BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
cb.readableBytes());
}
+ log.debug("Reading withdrawn routes length");
ChannelBuffer tempCb = cb.readBytes(withDrwLen);
if (withDrwLen != 0) {
// Parsing WithdrawnRoutes
withDrwRoutes = parseWithdrawnRoutes(tempCb);
+ log.debug("Withdrawn routes parsed");
}
if (cb.readableBytes() < MIN_LEN_AFTER_WITHDRW_ROUTES) {
- log.debug("Bgp Path Attribute len field not present");
+ log.debug("Bgp path attribute len field not present");
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
}
@@ -156,6 +158,7 @@
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
}
+ log.debug("Total path attribute length read");
if (totPathAttrLen != 0) {
// Parsing BGPPathAttributes
if (cb.readableBytes() < totPathAttrLen) {
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsSourcePrefix.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsSourcePrefix.java
index e205246..9587cc5 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsSourcePrefix.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsSourcePrefix.java
@@ -15,17 +15,16 @@
*/
package org.onosproject.bgpio.types;
-import java.nio.ByteBuffer;
-import java.util.Objects;
-
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Preconditions;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onlab.packet.IpPrefix;
import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.util.Constants;
import org.onosproject.bgpio.util.Validation;
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
+import java.nio.ByteBuffer;
+import java.util.Objects;
/**
* Provides implementation of IPv4AddressTlv.
@@ -33,13 +32,14 @@
public class BgpFsSourcePrefix implements BgpValueType {
public static final byte FLOW_SPEC_TYPE = Constants.BGP_FLOWSPEC_SRC_PREFIX;
+ public static final int BYTE_IN_BITS = 8;
private byte length;
private IpPrefix ipPrefix;
- public static final int BYTE_IN_BITS = 8;
+
/**
* Constructor to initialize parameters.
*
- * @param length length of the prefix
+ * @param length length of the prefix
* @param ipPrefix ip prefix
*/
public BgpFsSourcePrefix(byte length, IpPrefix ipPrefix) {
@@ -48,6 +48,50 @@
}
/**
+ * Reads the channel buffer and returns object of IPv4AddressTlv.
+ *
+ * @param cb channelBuffer
+ * @return object of flow spec source prefix
+ * @throws BgpParseException while parsing BgpFsSourcePrefix
+ */
+ public static BgpFsSourcePrefix read(ChannelBuffer cb) throws BgpParseException {
+ IpPrefix ipPrefix;
+
+ int length = cb.readByte();
+ if (length == 0) {
+ byte[] prefix = new byte[]{0};
+ ipPrefix = Validation.bytesToPrefix(prefix, length);
+ return new BgpFsSourcePrefix((byte) ipPrefix.prefixLength(), ipPrefix);
+ }
+
+ int len = length / BYTE_IN_BITS;
+ int reminder = length % BYTE_IN_BITS;
+ if (reminder > 0) {
+ len = len + 1;
+ }
+ if (cb.readableBytes() < len) {
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.MALFORMED_ATTRIBUTE_LIST, cb.readableBytes());
+ }
+ byte[] prefix = new byte[len];
+ cb.readBytes(prefix, 0, len);
+ ipPrefix = Validation.bytesToPrefix(prefix, length);
+
+ return new BgpFsSourcePrefix((byte) ipPrefix.prefixLength(), ipPrefix);
+ }
+
+ /**
+ * Returns object of this class with specified values.
+ *
+ * @param ipPrefix ip prefix
+ * @param length length of ip prefix
+ * @return object of this class
+ */
+ public static BgpFsSourcePrefix of(final IpPrefix ipPrefix, final byte length) {
+ return new BgpFsSourcePrefix(length, ipPrefix);
+ }
+
+ /**
* Returns ip prefix.
*
* @return ipPrefix ip prefix
@@ -87,50 +131,6 @@
return cb.writerIndex() - iLenStartIndex;
}
- /**
- * Reads the channel buffer and returns object of IPv4AddressTlv.
- *
- * @param cb channelBuffer
- * @return object of flow spec source prefix
- * @throws BgpParseException while parsing BgpFsSourcePrefix
- */
- public static BgpFsSourcePrefix read(ChannelBuffer cb) throws BgpParseException {
- IpPrefix ipPrefix;
-
- int length = cb.readByte();
- if (length == 0) {
- byte[] prefix = new byte[] {0};
- ipPrefix = Validation.bytesToPrefix(prefix, length);
- return new BgpFsSourcePrefix((byte) ipPrefix.prefixLength(), ipPrefix);
- }
-
- int len = length / BYTE_IN_BITS;
- int reminder = length % BYTE_IN_BITS;
- if (reminder > 0) {
- len = len + 1;
- }
- if (cb.readableBytes() < len) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.MALFORMED_ATTRIBUTE_LIST, cb.readableBytes());
- }
- byte[] prefix = new byte[len];
- cb.readBytes(prefix, 0, len);
- ipPrefix = Validation.bytesToPrefix(prefix, length);
-
- return new BgpFsSourcePrefix((byte) ipPrefix.prefixLength(), ipPrefix);
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param ipPrefix ip prefix
- * @param length length of ip prefix
- * @return object of this class
- */
- public static BgpFsSourcePrefix of(final IpPrefix ipPrefix, final byte length) {
- return new BgpFsSourcePrefix(length, ipPrefix);
- }
-
@Override
public int compareTo(Object o) {
if (this.equals(o)) {
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java
index 3fb8d3b..32aaa71 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java
@@ -44,4 +44,4 @@
* @return result after comparing two objects
*/
int compareTo(Object o);
-}
\ No newline at end of file
+}
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java
index 605e7e3..f7f783e 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java
@@ -80,6 +80,7 @@
nodeName = new byte[lsAttrLength];
cb.readBytes(nodeName);
+ log.debug("LS attribute node name read");
return BgpAttrNodeName.of(nodeName);
}
diff --git a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpChannelHandler.java b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpChannelHandler.java
index 92236a4..1f6e5bc 100644
--- a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpChannelHandler.java
+++ b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpChannelHandler.java
@@ -499,6 +499,7 @@
if (e.getCause() instanceof ReadTimeoutException) {
// device timeout
+ bgpController.closedSessionExceptionAdd(peerAddr, e.getCause().toString());
log.error("Disconnecting device {} due to read timeout", getPeerInfoString());
sendNotification(BgpErrorType.HOLD_TIMER_EXPIRED, (byte) 0, null);
state = ChannelState.IDLE;
@@ -506,9 +507,11 @@
ctx.getChannel().close();
return;
} else if (e.getCause() instanceof ClosedChannelException) {
+ bgpController.activeSessionExceptionAdd(peerAddr, e.getCause().toString());
log.debug("Channel for bgp {} already closed", getPeerInfoString());
} else if (e.getCause() instanceof IOException) {
log.error("Disconnecting peer {} due to IO Error: {}", getPeerInfoString(), e.getCause().getMessage());
+ bgpController.closedSessionExceptionAdd(peerAddr, e.getCause().toString());
if (log.isDebugEnabled()) {
// still print stack trace if debug is enabled
log.debug("StackTrace for previous Exception: ", e.getCause());
@@ -520,6 +523,7 @@
BgpParseException errMsg = (BgpParseException) e.getCause();
byte errorCode = errMsg.getErrorCode();
byte errorSubCode = errMsg.getErrorSubCode();
+ bgpController.activeSessionExceptionAdd(peerAddr, e.getCause().toString());
ChannelBuffer tempCb = errMsg.getData();
if (tempCb != null) {
int dataLength = tempCb.readableBytes();
@@ -529,9 +533,11 @@
sendNotification(errorCode, errorSubCode, data);
} else if (e.getCause() instanceof RejectedExecutionException) {
log.warn("Could not process message: queue full");
+ bgpController.activeSessionExceptionAdd(peerAddr, e.getCause().toString());
} else {
stopKeepAliveTimer();
log.error("Error while processing message from peer " + getPeerInfoString() + "state " + this.state);
+ bgpController.closedSessionExceptionAdd(peerAddr, e.getCause().toString());
ctx.getChannel().close();
}
}
@@ -733,7 +739,7 @@
* @throws IOException while processing error message
*/
public void processUnknownMsg(byte errorCode, byte errorSubCode, byte data) throws BgpParseException, IOException {
- log.debug("UNKNOWN message received");
+ log.debug("Unknown message received");
byte[] byteArray = new byte[1];
byteArray[0] = data;
sendNotification(errorCode, errorSubCode, byteArray);
@@ -782,7 +788,7 @@
* @throws BgpParseException
*/
private boolean capabilityValidation(BgpChannelHandler h, BgpOpenMsg openmsg) throws BgpParseException {
- log.debug("capabilityValidation");
+ log.debug("capability validation");
boolean isFourOctetCapabilityExits = false;
boolean isRpdCapabilityExits = false;
@@ -916,7 +922,7 @@
* @return true or false
*/
private boolean asNumberValidation(BgpChannelHandler h, BgpOpenMsg openMsg) {
- log.debug("AS Num validation");
+ log.debug("AS number validation");
int capAsNum = 0;
boolean isFourOctetCapabilityExits = false;
diff --git a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConfig.java b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConfig.java
index a0bac3e..867f6a6 100644
--- a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConfig.java
+++ b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConfig.java
@@ -19,6 +19,8 @@
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
+import java.util.List;
+import java.util.ArrayList;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.IpAddress;
@@ -42,7 +44,7 @@
private static final short DEFAULT_HOLD_TIMER = 120;
private static final short DEFAULT_CONN_RETRY_TIME = 120;
private static final short DEFAULT_CONN_RETRY_COUNT = 5;
-
+ private List<BgpConnectPeerImpl> peerList = new ArrayList();
private State state = State.INIT;
private int localAs;
private int maxSession;
@@ -189,10 +191,10 @@
}
this.bgpPeerTree.put(routerid, lspeer);
- log.debug("added successfully");
+ log.debug("Added successfully");
return true;
} else {
- log.debug("already exists");
+ log.debug("Already exists");
return false;
}
}
@@ -208,6 +210,8 @@
connectPeer = new BgpConnectPeerImpl(bgpController, routerid, Controller.BGP_PORT_NUM);
lspeer.setConnectPeer(connectPeer);
connectPeer.connectPeer();
+ peerList.add((BgpConnectPeerImpl) connectPeer);
+
}
return true;
}
diff --git a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConnectPeerImpl.java b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConnectPeerImpl.java
index 494718b..a53bf23 100644
--- a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConnectPeerImpl.java
+++ b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpConnectPeerImpl.java
@@ -42,6 +42,38 @@
private int connectRetryTime;
private ChannelPipelineFactory pfact;
private ClientBootstrap peerBootstrap;
+ public String getPeerHost() {
+ return peerHost;
+ }
+ public static int getRetryInterval() {
+ return RETRY_INTERVAL;
+ }
+
+ @Override
+ public int getPeerPort() {
+ return peerPort;
+ }
+ @Override
+ public int getConnectRetryCounter() {
+ return connectRetryCounter;
+ }
+
+ public void setConnectRetryCounter(int connectRetryCounter) {
+ this.connectRetryCounter = connectRetryCounter;
+ }
+
+ public void setConnectRetryTime(int connectRetryTime) {
+ this.connectRetryTime = connectRetryTime;
+ }
+
+ public BgpCfg getBgpconfig() {
+ return bgpconfig;
+ }
+
+ public void setBgpconfig(BgpCfg bgpconfig) {
+ this.bgpconfig = bgpconfig;
+ }
+
private BgpCfg bgpconfig;
/**
@@ -118,14 +150,14 @@
} else {
connectRetryCounter++;
- log.info("Connected to remote host {}, Connect Counter {}", peerHost, connectRetryCounter);
+ log.debug("Connected to remote host {}, Connect Counter {}", peerHost, connectRetryCounter);
disconnectPeer();
return;
}
}
});
} catch (Exception e) {
- log.info("Connect peer exception : " + e.toString());
+ log.debug("Connect peer exception : " + e.toString());
disconnectPeer();
}
}
diff --git a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpControllerImpl.java b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpControllerImpl.java
index 83c0648..15a5b58 100644
--- a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpControllerImpl.java
+++ b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpControllerImpl.java
@@ -38,6 +38,9 @@
import org.slf4j.LoggerFactory;
import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.TreeMap;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -50,7 +53,7 @@
public class BgpControllerImpl implements BgpController {
private static final Logger log = LoggerFactory.getLogger(BgpControllerImpl.class);
-
+ final Controller ctrl = new Controller(this);
protected ConcurrentHashMap<BgpId, BgpPeer> connectedPeers = new ConcurrentHashMap<BgpId, BgpPeer>();
protected BgpPeerManagerImpl peerManager = new BgpPeerManagerImpl();
@@ -60,10 +63,53 @@
protected Set<BgpNodeListener> bgpNodeListener = new CopyOnWriteArraySet<>();
protected Set<BgpLinkListener> bgpLinkListener = new CopyOnWriteArraySet<>();
-
- final Controller ctrl = new Controller(this);
-
+ protected BgpController bgpController;
private BgpConfig bgpconfig = new BgpConfig(this);
+ private List<String> activeExceptionList = new LinkedList();
+ private LinkedList<String> closedExceptionList = new LinkedList<String>();
+ private Map<String, List<String>> activeSessionExceptionMap = new TreeMap<>();
+ private Map<String, List<String>> closedSessionExceptionMap = new TreeMap<>();
+
+ @Override
+ public void activeSessionExceptionAdd(String peerId, String exception) {
+ if (peerId != null) {
+ activeExceptionList.add(exception);
+ activeSessionExceptionMap.put(peerId, activeExceptionList);
+ } else {
+ log.debug("Peer Id is null");
+ }
+ if (activeExceptionList.size() > 10) {
+ activeExceptionList.clear();
+ activeExceptionList.add(exception);
+ activeSessionExceptionMap.put(peerId, activeExceptionList);
+ }
+ }
+
+
+ @Override
+ public void closedSessionExceptionAdd(String peerId, String exception) {
+ if (peerId != null) {
+ closedExceptionList.add(exception);
+ closedSessionExceptionMap.put(peerId, closedExceptionList);
+ } else {
+ log.debug("Peer Id is null");
+ }
+ if (closedExceptionList.size() > 10) {
+ closedExceptionList.clear();
+ closedExceptionList.add(exception);
+ closedSessionExceptionMap.put(peerId, closedExceptionList);
+ }
+ }
+
+ @Override
+ public Map<String, List<String>> activeSessionMap() {
+ return activeSessionExceptionMap;
+ }
+
+ @Override
+ public Map<String, List<String>> closedSessionMap() {
+ return closedSessionExceptionMap;
+ }
@Activate
public void activate() {
@@ -73,6 +119,8 @@
@Deactivate
public void deactivate() {
+ activeSessionExceptionMap.clear();
+ closedSessionExceptionMap.clear();
// Close all connected peers
closeConnectedPeers();
this.ctrl.stop();
diff --git a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpLocalRibImpl.java b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpLocalRibImpl.java
index aef8055..9bf2ee3 100644
--- a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpLocalRibImpl.java
+++ b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpLocalRibImpl.java
@@ -69,6 +69,7 @@
*
* @return node tree
*/
+ @Override
public Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib> nodeTree() {
return nodeTree;
}
@@ -78,6 +79,7 @@
*
* @return link tree
*/
+ @Override
public Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib> linkTree() {
return linkTree;
}
@@ -87,6 +89,7 @@
*
* @return prefix tree
*/
+ @Override
public Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib> prefixTree() {
return prefixTree;
}
@@ -96,6 +99,7 @@
*
* @return vpn node NLRI tree
*/
+ @Override
public Map<RouteDistinguisher, Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnNodeTree() {
return vpnNodeTree;
}
@@ -105,6 +109,7 @@
*
* @return vpn link NLRI Tree
*/
+ @Override
public Map<RouteDistinguisher, Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnLinkTree() {
return vpnLinkTree;
}
@@ -114,6 +119,7 @@
*
* @return vpn prefix NLRI Tree
*/
+ @Override
public Map<RouteDistinguisher, Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnPrefixTree() {
return vpnPrefixTree;
}
@@ -421,7 +427,7 @@
decisionResult = selectionAlgo.compare(prefixTree.get(prefixIdentifier), detailsLocRib);
if (decisionResult < 0) {
prefixTree.replace(prefixIdentifier, detailsLocRib);
- log.debug("local RIB prefix updated: {}", detailsLocRib.toString());
+ log.debug("Local RIB prefix updated: {}", detailsLocRib.toString());
}
} else {
if (!isVpnRib) {
diff --git a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPeerImpl.java b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPeerImpl.java
index 02a4321..40048bc 100644
--- a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPeerImpl.java
+++ b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpPeerImpl.java
@@ -142,16 +142,20 @@
if (tlv.getType() == MultiProtocolExtnCapabilityTlv.TYPE) {
MultiProtocolExtnCapabilityTlv temp = (MultiProtocolExtnCapabilityTlv) tlv;
if ((temp.getAfi() == afi) && (temp.getSafi() == sAfi)) {
+ log.debug("Multi prorotcol extension capabality TLV is true");
return true;
+
}
} else if (tlv.getType() == RpdCapabilityTlv.TYPE) {
RpdCapabilityTlv temp = (RpdCapabilityTlv) tlv;
if ((temp.getAfi() == afi) && (temp.getSafi() == sAfi)) {
+ log.debug("RPD capabality TLV is true");
return true;
}
}
}
}
+ log.debug("IS capabality is not supported ");
return false;
}
@@ -236,7 +240,7 @@
BgpMessage msg = Controller.getBgpMessageFactory4().updateMessageBuilder()
.setBgpPathAttributes(attributesList).build();
- log.debug("Sending Flow spec Update message to {}", channel.getRemoteAddress());
+ log.debug("Sending flow spec update message to {}", channel.getRemoteAddress());
channel.write(Collections.singletonList(msg));
}