[ONOS-8036] BGP-LS has only partial support for IPv6
- Removed hard-coded Ipv4Address and replaced with the generic
IpAddress wherever necessary
- Added support of AFI = 2 (IPv6) in MPReachNlri and MPUnreachNlri
- Added a new config parameter for IPv6 in BGP Config. This allows
AFI = 2 to be sent in BGP Open messages
- Skipped TLV 1170 and 1173, which were causing exceptions
Change-Id: I76e69021b1d2687754bbf700681070051e347942
diff --git a/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpAppConfig.java b/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpAppConfig.java
index 9f1710a..f76c401 100644
--- a/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpAppConfig.java
+++ b/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpAppConfig.java
@@ -62,6 +62,11 @@
public static final String PEER_CONNECT_PASSIVE = "passive";
public static final String PEER_CONNECT_ACTIVE = "active";
+ public static final String CONNECTION_TYPE = "connectionType";
+ public static final String CONNECTION_TYPE_IPV4 = "IPV4";
+ public static final String CONNECTION_TYPE_IPV6 = "IPV6";
+ public static final String CONNECTION_TYPE_IPV4_AND_IPV6 = "IPV4_IPV6";
+
static final int MAX_SHORT_AS_NUMBER = 65535;
static final long MAX_LONG_AS_NUMBER = 4294967295L;
@@ -80,13 +85,13 @@
fields = hasOnlyFields(ROUTER_ID, LOCAL_AS, MAX_SESSION, LS_CAPABILITY,
HOLD_TIME, LARGE_AS_CAPABILITY, FLOW_SPEC_CAPABILITY,
- FLOW_SPEC_RPD_CAPABILITY, BGP_PEER, EVPN_CAPABILITY) &&
+ FLOW_SPEC_RPD_CAPABILITY, BGP_PEER, EVPN_CAPABILITY, CONNECTION_TYPE) &&
isIpAddress(ROUTER_ID, MANDATORY) && isNumber(LOCAL_AS, MANDATORY) &&
isNumber(MAX_SESSION, OPTIONAL, MIN_SESSION_NUMBER, MAX_SESSION_NUMBER)
&& isNumber(HOLD_TIME, OPTIONAL, MIN_HOLDTIME, MAX_HOLDTIME) &&
isBoolean(LS_CAPABILITY, OPTIONAL) && isBoolean(LARGE_AS_CAPABILITY, OPTIONAL) &&
isString(FLOW_SPEC_CAPABILITY, OPTIONAL) && isBoolean(FLOW_SPEC_RPD_CAPABILITY, OPTIONAL)
- && isBoolean(EVPN_CAPABILITY, OPTIONAL);
+ && isBoolean(EVPN_CAPABILITY, OPTIONAL) && isString(CONNECTION_TYPE, OPTIONAL);
if (!fields) {
return fields;
@@ -168,6 +173,33 @@
}
/**
+ * Returns BGP connection type from the configuration.
+ *
+ * @return BGP connection type
+ */
+ public String connectionType() {
+ return get(CONNECTION_TYPE, null);
+ }
+
+ /**
+ * Validates the BGP connection type.
+ *
+ * @return true if valid else false
+ */
+ public boolean validateConnectionType() {
+ if (connectionType() != null) {
+ String connectionType = connectionType();
+ if (!connectionType.equals(CONNECTION_TYPE_IPV4) && !connectionType.equals(CONNECTION_TYPE_IPV6)
+ && !connectionType.equals(CONNECTION_TYPE_IPV4_AND_IPV6)) {
+ log.error("Connection Type is invalid");
+ return false;
+ }
+ }
+ log.debug("Connection Type is valid");
+ return true;
+ }
+
+ /**
* Validates the flow specification capability.
*
* @return true if valid else false
@@ -234,6 +266,10 @@
if (!validateHoldTime()) {
return false;
}
+
+ if (!validateConnectionType()) {
+ return false;
+ }
return true;
}
diff --git a/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpCfgProvider.java b/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpCfgProvider.java
index c35f4f0..d9268d8 100644
--- a/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpCfgProvider.java
+++ b/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpCfgProvider.java
@@ -152,6 +152,8 @@
bgpConfig.connectPeer(nodes.get(i).hostname());
}
}
+
+ bgpConfig.setConnectionType(getBgpConnectionTypeFromConfig(config));
}
/**
@@ -259,6 +261,30 @@
}
}
+ bgpConfig.setConnectionType(getBgpConnectionTypeFromConfig(config));
+ }
+
+ /**
+ * Function to get Bgp Connection type from config.
+ * @param config The BgpAppConfig from which connection type is to be fetched
+ * @return Bgp connection type
+ */
+ private BgpCfg.ConnectionType getBgpConnectionTypeFromConfig(BgpAppConfig config) {
+ //config cannot be null here, because of the function call sequence
+
+ //But, let's put a sanity check for connectionType
+ if (null == config.connectionType()) {
+ //IPv4 is the default connection type
+ return BgpCfg.ConnectionType.IPV4;
+ }
+
+ if (config.connectionType().equals(BgpAppConfig.CONNECTION_TYPE_IPV4)) {
+ return BgpCfg.ConnectionType.IPV6;
+ } else if (config.connectionType().equals(BgpAppConfig.CONNECTION_TYPE_IPV4_AND_IPV6)) {
+ return BgpCfg.ConnectionType.IPV4_IPV6;
+ } else {
+ return BgpCfg.ConnectionType.IPV4;
+ }
}
/**