BGP flow spec configuration system test issue fix.

Change-Id: Ia912fdb15f584b477ead748aed87e3c4fa003d29
This commit is contained in:
Shashikanth VH 2016-02-19 17:26:03 +05:30 committed by Gerrit Code Review
parent 86b3b1aa2e
commit 580bdeb64f
7 changed files with 110 additions and 52 deletions

View File

@ -44,6 +44,29 @@ public interface BgpCfg {
IP_AS_CONFIGURED 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. * 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 * @return state information
*/ */
BgpPeerCfg.State getPeerConnState(String routerid); 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);
} }

View File

@ -58,24 +58,6 @@ public interface BgpPeerCfg {
INVALID 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. * Returns the connection State information of the peer.
* *
@ -195,18 +177,4 @@ public interface BgpPeerCfg {
* @return peer connect instance * @return peer connect instance
*/ */
BgpConnectPeer connectPeer(); 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);
} }

View File

@ -665,14 +665,18 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler {
*/ */
private void sendHandshakeOpenMessage() throws IOException, BgpParseException { private void sendHandshakeOpenMessage() throws IOException, BgpParseException {
int bgpId; int bgpId;
BgpCfg.FlowSpec flowSpec = bgpconfig.flowSpecCapability();
boolean flowSpecStatus = false; boolean flowSpecStatus = false;
boolean vpnFlowSpecStatus = false; boolean vpnFlowSpecStatus = false;
bgpId = Ip4Address.valueOf(bgpconfig.getRouterId()).toInt(); 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; flowSpecStatus = true;
} else if (peerConfig.flowSpecStatus() == BgpPeerCfg.FlowSpec.VPNV4) {
vpnFlowSpecStatus = true; vpnFlowSpecStatus = true;
} }
@ -792,9 +796,9 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler {
boolean isMultiProtocolLsCapability = false; boolean isMultiProtocolLsCapability = false;
boolean isMultiProtocolFlowSpecCapability = false; boolean isMultiProtocolFlowSpecCapability = false;
boolean isMultiProtocolVpnFlowSpecCapability = false; boolean isMultiProtocolVpnFlowSpecCapability = false;
BgpCfg.FlowSpec flowSpec = h.bgpconfig.flowSpecCapability();
BgpPeerConfig peerConfig = (BgpPeerConfig) h.bgpconfig.displayPeers(peerAddr); if (flowSpec != BgpCfg.FlowSpec.NONE) {
if (peerConfig.flowSpecStatus() != BgpPeerCfg.FlowSpec.NONE) {
isFlowSpecCapabilityCfg = true; isFlowSpecCapabilityCfg = true;
} }

View File

@ -51,7 +51,7 @@ public class BgpConfig implements BgpCfg {
private boolean largeAs = false; private boolean largeAs = false;
private int maxConnRetryTime; private int maxConnRetryTime;
private int maxConnRetryCount; private int maxConnRetryCount;
private FlowSpec flowSpec = FlowSpec.NONE;
private Ip4Address routerId = null; private Ip4Address routerId = null;
private TreeMap<String, BgpPeerCfg> bgpPeerTree = new TreeMap<>(); private TreeMap<String, BgpPeerCfg> bgpPeerTree = new TreeMap<>();
private BgpConnectPeer connectPeer; private BgpConnectPeer connectPeer;
@ -118,6 +118,16 @@ public class BgpConfig implements BgpCfg {
this.lsCapability = lsCapability; this.lsCapability = lsCapability;
} }
@Override
public FlowSpec flowSpecCapability() {
return this.flowSpec;
}
@Override
public void setFlowSpecCapability(FlowSpec flowSpec) {
this.flowSpec = flowSpec;
}
@Override @Override
public String getRouterId() { public String getRouterId() {
if (this.routerId != null) { if (this.routerId != null) {
@ -222,7 +232,7 @@ public class BgpConfig implements BgpCfg {
if (disconnPeer != null) { if (disconnPeer != null) {
// TODO: send notification peer deconfigured // TODO: send notification peer deconfigured
disconnPeer.disconnectPeer(); disconnPeer.disconnectPeer();
} else { } else if (lspeer.connectPeer() != null) {
lspeer.connectPeer().disconnectPeer(); lspeer.connectPeer().disconnectPeer();
} }
lspeer.setState(BgpPeerCfg.State.IDLE); lspeer.setState(BgpPeerCfg.State.IDLE);

View File

@ -30,7 +30,6 @@ public class BgpPeerConfig implements BgpPeerCfg {
private State state; private State state;
private boolean selfInitiated; private boolean selfInitiated;
private BgpConnectPeer connectPeer; private BgpConnectPeer connectPeer;
private FlowSpec flowSpecStatus = FlowSpec.NONE;
/** /**
* Constructor to initialize the values. * Constructor to initialize the values.
@ -119,14 +118,4 @@ public class BgpPeerConfig implements BgpPeerCfg {
public void setConnectPeer(BgpConnectPeer connectPeer) { public void setConnectPeer(BgpConnectPeer connectPeer) {
this.connectPeer = connectPeer; this.connectPeer = connectPeer;
} }
@Override
public FlowSpec flowSpecStatus() {
return flowSpecStatus;
}
@Override
public void setFlowSpecStatus(FlowSpec flowSpecStatus) {
this.flowSpecStatus = flowSpecStatus;
}
} }

View File

@ -47,6 +47,7 @@ public class BgpAppConfig extends Config<ApplicationId> {
public static final String LS_CAPABILITY = "lsCapability"; public static final String LS_CAPABILITY = "lsCapability";
public static final String HOLD_TIME = "holdTime"; public static final String HOLD_TIME = "holdTime";
public static final String LARGE_AS_CAPABILITY = "largeAsCapability"; 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 BGP_PEER = "bgpPeer";
public static final String PEER_IP = "peerIp"; public static final String PEER_IP = "peerIp";
@ -67,10 +68,11 @@ public class BgpAppConfig extends Config<ApplicationId> {
bgpConfig = bgpController.getConfig(); bgpConfig = bgpController.getConfig();
fields = hasOnlyFields(ROUTER_ID, LOCAL_AS, MAX_SESSION, LS_CAPABILITY, 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) && isIpAddress(ROUTER_ID, MANDATORY) && isNumber(LOCAL_AS, MANDATORY) &&
isNumber(MAX_SESSION, OPTIONAL, 20) && isNumber(HOLD_TIME, OPTIONAL, 180) && 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) { if (!fields) {
return fields; return fields;
@ -124,6 +126,15 @@ public class BgpAppConfig extends Config<ApplicationId> {
return Boolean.parseBoolean(get(LARGE_AS_CAPABILITY, null)); 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. * 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)); 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. * Validates the Bgp local and peer configuration.
* *
@ -152,6 +179,9 @@ public class BgpAppConfig extends Config<ApplicationId> {
return false; return false;
} }
if (!validateFlowSpec()) {
return false;
}
return true; return true;
} }

View File

@ -128,6 +128,16 @@ public class BgpCfgProvider extends AbstractProvider {
bgpConfig.setMaxSession(config.maxSession()); bgpConfig.setMaxSession(config.maxSession());
bgpConfig.setLargeASCapability(config.largeAsCapability()); 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(); nodes = config.bgpPeer();
for (int i = 0; i < nodes.size(); i++) { for (int i = 0; i < nodes.size(); i++) {
String connectMode = nodes.get(i).connectMode(); String connectMode = nodes.get(i).connectMode();
@ -163,6 +173,16 @@ public class BgpCfgProvider extends AbstractProvider {
bgpConfig.setHoldTime(config.holdTime()); bgpConfig.setHoldTime(config.holdTime());
bgpConfig.setMaxSession(config.maxSession()); bgpConfig.setMaxSession(config.maxSession());
bgpConfig.setLargeASCapability(config.largeAsCapability()); 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 { } else {
log.info(" Self configuration cannot be modified as there is existing connections "); log.info(" Self configuration cannot be modified as there is existing connections ");
} }