mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-12-16 14:52:15 +01:00
BGP flow spec configuration system test issue fix.
Change-Id: Ia912fdb15f584b477ead748aed87e3c4fa003d29
This commit is contained in:
parent
86b3b1aa2e
commit
580bdeb64f
@ -44,6 +44,29 @@ public interface BgpCfg {
|
||||
IP_AS_CONFIGURED
|
||||
}
|
||||
|
||||
enum FlowSpec {
|
||||
|
||||
/**
|
||||
* Signifies that peer support IPV4 flow specification.
|
||||
*/
|
||||
IPV4,
|
||||
|
||||
/**
|
||||
* Signifies that peer support VPNV4 flow specification.
|
||||
*/
|
||||
VPNV4,
|
||||
|
||||
/**
|
||||
* Signifies that peer support IPV4 and VPNV4 flow specification.
|
||||
*/
|
||||
IPV4_VPNV4,
|
||||
|
||||
/**
|
||||
* Signifies that peer flow specification capability disabled.
|
||||
*/
|
||||
NONE
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the status of the configuration based on this state certain operations like connection is handled.
|
||||
*
|
||||
@ -294,4 +317,18 @@ public interface BgpCfg {
|
||||
* @return state information
|
||||
*/
|
||||
BgpPeerCfg.State getPeerConnState(String routerid);
|
||||
|
||||
/**
|
||||
* Gets the flow specification capability.
|
||||
*
|
||||
* @return flow specification capability
|
||||
*/
|
||||
FlowSpec flowSpecCapability();
|
||||
|
||||
/**
|
||||
* Sets the flow specification capability.
|
||||
*
|
||||
* @param flowSpec flow specification capability
|
||||
*/
|
||||
void setFlowSpecCapability(FlowSpec flowSpec);
|
||||
}
|
||||
|
||||
@ -58,24 +58,6 @@ public interface BgpPeerCfg {
|
||||
INVALID
|
||||
}
|
||||
|
||||
enum FlowSpec {
|
||||
|
||||
/**
|
||||
* Signifies that peer support IPV4 flow specification.
|
||||
*/
|
||||
IPV4,
|
||||
|
||||
/**
|
||||
* Signifies that peer support VPNV4 flow specification.
|
||||
*/
|
||||
VPNV4,
|
||||
|
||||
/**
|
||||
* Signifies that peer flow specification support disabled.
|
||||
*/
|
||||
NONE
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the connection State information of the peer.
|
||||
*
|
||||
@ -195,18 +177,4 @@ public interface BgpPeerCfg {
|
||||
* @return peer connect instance
|
||||
*/
|
||||
BgpConnectPeer connectPeer();
|
||||
|
||||
/**
|
||||
* Gets the flow specification capability.
|
||||
*
|
||||
* @return flow specification status
|
||||
*/
|
||||
public FlowSpec flowSpecStatus();
|
||||
|
||||
/**
|
||||
* sets the flow specification capability.
|
||||
*
|
||||
* @param flowSpecStatus flow specification status
|
||||
*/
|
||||
public void setFlowSpecStatus(FlowSpec flowSpecStatus);
|
||||
}
|
||||
|
||||
@ -665,14 +665,18 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler {
|
||||
*/
|
||||
private void sendHandshakeOpenMessage() throws IOException, BgpParseException {
|
||||
int bgpId;
|
||||
BgpCfg.FlowSpec flowSpec = bgpconfig.flowSpecCapability();
|
||||
boolean flowSpecStatus = false;
|
||||
boolean vpnFlowSpecStatus = false;
|
||||
|
||||
bgpId = Ip4Address.valueOf(bgpconfig.getRouterId()).toInt();
|
||||
BgpPeerConfig peerConfig = (BgpPeerConfig) bgpconfig.displayPeers(peerAddr);
|
||||
if (peerConfig.flowSpecStatus() == BgpPeerCfg.FlowSpec.IPV4) {
|
||||
|
||||
if (flowSpec == BgpCfg.FlowSpec.IPV4) {
|
||||
flowSpecStatus = true;
|
||||
} else if (flowSpec == BgpCfg.FlowSpec.VPNV4) {
|
||||
vpnFlowSpecStatus = true;
|
||||
} else if (flowSpec == BgpCfg.FlowSpec.IPV4_VPNV4) {
|
||||
flowSpecStatus = true;
|
||||
} else if (peerConfig.flowSpecStatus() == BgpPeerCfg.FlowSpec.VPNV4) {
|
||||
vpnFlowSpecStatus = true;
|
||||
}
|
||||
|
||||
@ -792,9 +796,9 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler {
|
||||
boolean isMultiProtocolLsCapability = false;
|
||||
boolean isMultiProtocolFlowSpecCapability = false;
|
||||
boolean isMultiProtocolVpnFlowSpecCapability = false;
|
||||
BgpCfg.FlowSpec flowSpec = h.bgpconfig.flowSpecCapability();
|
||||
|
||||
BgpPeerConfig peerConfig = (BgpPeerConfig) h.bgpconfig.displayPeers(peerAddr);
|
||||
if (peerConfig.flowSpecStatus() != BgpPeerCfg.FlowSpec.NONE) {
|
||||
if (flowSpec != BgpCfg.FlowSpec.NONE) {
|
||||
isFlowSpecCapabilityCfg = true;
|
||||
}
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ public class BgpConfig implements BgpCfg {
|
||||
private boolean largeAs = false;
|
||||
private int maxConnRetryTime;
|
||||
private int maxConnRetryCount;
|
||||
|
||||
private FlowSpec flowSpec = FlowSpec.NONE;
|
||||
private Ip4Address routerId = null;
|
||||
private TreeMap<String, BgpPeerCfg> bgpPeerTree = new TreeMap<>();
|
||||
private BgpConnectPeer connectPeer;
|
||||
@ -118,6 +118,16 @@ public class BgpConfig implements BgpCfg {
|
||||
this.lsCapability = lsCapability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlowSpec flowSpecCapability() {
|
||||
return this.flowSpec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlowSpecCapability(FlowSpec flowSpec) {
|
||||
this.flowSpec = flowSpec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRouterId() {
|
||||
if (this.routerId != null) {
|
||||
@ -222,7 +232,7 @@ public class BgpConfig implements BgpCfg {
|
||||
if (disconnPeer != null) {
|
||||
// TODO: send notification peer deconfigured
|
||||
disconnPeer.disconnectPeer();
|
||||
} else {
|
||||
} else if (lspeer.connectPeer() != null) {
|
||||
lspeer.connectPeer().disconnectPeer();
|
||||
}
|
||||
lspeer.setState(BgpPeerCfg.State.IDLE);
|
||||
|
||||
@ -30,7 +30,6 @@ public class BgpPeerConfig implements BgpPeerCfg {
|
||||
private State state;
|
||||
private boolean selfInitiated;
|
||||
private BgpConnectPeer connectPeer;
|
||||
private FlowSpec flowSpecStatus = FlowSpec.NONE;
|
||||
|
||||
/**
|
||||
* Constructor to initialize the values.
|
||||
@ -119,14 +118,4 @@ public class BgpPeerConfig implements BgpPeerCfg {
|
||||
public void setConnectPeer(BgpConnectPeer connectPeer) {
|
||||
this.connectPeer = connectPeer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlowSpec flowSpecStatus() {
|
||||
return flowSpecStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlowSpecStatus(FlowSpec flowSpecStatus) {
|
||||
this.flowSpecStatus = flowSpecStatus;
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,6 +47,7 @@ public class BgpAppConfig extends Config<ApplicationId> {
|
||||
public static final String LS_CAPABILITY = "lsCapability";
|
||||
public static final String HOLD_TIME = "holdTime";
|
||||
public static final String LARGE_AS_CAPABILITY = "largeAsCapability";
|
||||
public static final String FLOW_SPEC_CAPABILITY = "flowSpecCapability";
|
||||
|
||||
public static final String BGP_PEER = "bgpPeer";
|
||||
public static final String PEER_IP = "peerIp";
|
||||
@ -67,10 +68,11 @@ public class BgpAppConfig extends Config<ApplicationId> {
|
||||
bgpConfig = bgpController.getConfig();
|
||||
|
||||
fields = hasOnlyFields(ROUTER_ID, LOCAL_AS, MAX_SESSION, LS_CAPABILITY,
|
||||
HOLD_TIME, LARGE_AS_CAPABILITY, BGP_PEER) &&
|
||||
HOLD_TIME, LARGE_AS_CAPABILITY, FLOW_SPEC_CAPABILITY, BGP_PEER) &&
|
||||
isIpAddress(ROUTER_ID, MANDATORY) && isNumber(LOCAL_AS, MANDATORY) &&
|
||||
isNumber(MAX_SESSION, OPTIONAL, 20) && isNumber(HOLD_TIME, OPTIONAL, 180) &&
|
||||
isBoolean(LS_CAPABILITY, OPTIONAL) && isBoolean(LARGE_AS_CAPABILITY, OPTIONAL);
|
||||
isBoolean(LS_CAPABILITY, OPTIONAL) && isBoolean(LARGE_AS_CAPABILITY, OPTIONAL) &&
|
||||
isString(FLOW_SPEC_CAPABILITY, OPTIONAL);
|
||||
|
||||
if (!fields) {
|
||||
return fields;
|
||||
@ -124,6 +126,15 @@ public class BgpAppConfig extends Config<ApplicationId> {
|
||||
return Boolean.parseBoolean(get(LARGE_AS_CAPABILITY, null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns flow specification capability support from the configuration.
|
||||
*
|
||||
* @return flow specification capability
|
||||
*/
|
||||
public String flowSpecCapability() {
|
||||
return get(FLOW_SPEC_CAPABILITY, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns holdTime of the local node from the configuration.
|
||||
*
|
||||
@ -133,6 +144,22 @@ public class BgpAppConfig extends Config<ApplicationId> {
|
||||
return Short.parseShort(get(HOLD_TIME, null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the flow specification capability.
|
||||
*
|
||||
* @return true if valid else false
|
||||
*/
|
||||
public boolean validateFlowSpec() {
|
||||
if (flowSpecCapability() != null) {
|
||||
String flowSpec = flowSpecCapability();
|
||||
if ((flowSpec.equals("IPV4")) || (flowSpec.equals("VPNV4")) || (flowSpec.equals("IPV4_VPNV4"))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the Bgp local and peer configuration.
|
||||
*
|
||||
@ -152,6 +179,9 @@ public class BgpAppConfig extends Config<ApplicationId> {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!validateFlowSpec()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -128,6 +128,16 @@ public class BgpCfgProvider extends AbstractProvider {
|
||||
bgpConfig.setMaxSession(config.maxSession());
|
||||
bgpConfig.setLargeASCapability(config.largeAsCapability());
|
||||
|
||||
if (config.flowSpecCapability().equals("IPV4")) {
|
||||
bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.IPV4);
|
||||
} else if (config.flowSpecCapability().equals("VPNV4")) {
|
||||
bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.VPNV4);
|
||||
} else if (config.flowSpecCapability().equals("IPV4_VPNV4")) {
|
||||
bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.IPV4_VPNV4);
|
||||
} else {
|
||||
bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.NONE);
|
||||
}
|
||||
|
||||
nodes = config.bgpPeer();
|
||||
for (int i = 0; i < nodes.size(); i++) {
|
||||
String connectMode = nodes.get(i).connectMode();
|
||||
@ -163,6 +173,16 @@ public class BgpCfgProvider extends AbstractProvider {
|
||||
bgpConfig.setHoldTime(config.holdTime());
|
||||
bgpConfig.setMaxSession(config.maxSession());
|
||||
bgpConfig.setLargeASCapability(config.largeAsCapability());
|
||||
|
||||
if (config.flowSpecCapability().equals("IPV4")) {
|
||||
bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.IPV4);
|
||||
} else if (config.flowSpecCapability().equals("VPNV4")) {
|
||||
bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.VPNV4);
|
||||
} else if (config.flowSpecCapability().equals("IPV4_VPNV4")) {
|
||||
bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.IPV4_VPNV4);
|
||||
} else {
|
||||
bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.NONE);
|
||||
}
|
||||
} else {
|
||||
log.info(" Self configuration cannot be modified as there is existing connections ");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user