Shashikanth VH
Committed by Gerrit Code Review

[ONOS-3845] BGP support flow specification capability on peer basis.

Change-Id: Iae0f617f72213a4f1664dcf6e904b01ac7460816
......@@ -73,20 +73,6 @@ public interface BgpCfg {
void setLsCapability(boolean lscapability);
/**
* Get the status of the flow specification support for this BGP speaker.
*
* @return true if the flow specification is supported otherwise false
*/
boolean flowSpecCapability();
/**
* Set the flow specification support to this BGP speaker.
*
* @param flowSpecCapability BGP flow specification capability support
*/
void setFlowSpecCapability(boolean flowSpecCapability);
/**
* Get the status of the 32 bit AS support for this BGP speaker.
*
* @return true if the 32 bit AS number is supported else false
......
......@@ -58,6 +58,24 @@ 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.
*
......@@ -177,4 +195,18 @@ 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,11 +665,23 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler {
*/
private void sendHandshakeOpenMessage() throws IOException, BgpParseException {
int bgpId;
boolean flowSpecStatus = false;
boolean vpnFlowSpecStatus = false;
bgpId = Ip4Address.valueOf(bgpconfig.getRouterId()).toInt();
BgpPeerConfig peerConfig = (BgpPeerConfig) bgpconfig.displayPeers(peerAddr);
if (peerConfig.flowSpecStatus() == BgpPeerCfg.FlowSpec.IPV4) {
flowSpecStatus = true;
} else if (peerConfig.flowSpecStatus() == BgpPeerCfg.FlowSpec.VPNV4) {
vpnFlowSpecStatus = true;
}
BgpMessage msg = factory4.openMessageBuilder().setAsNumber((short) bgpconfig.getAsNumber())
.setHoldTime(bgpconfig.getHoldTime()).setBgpId(bgpId).setLsCapabilityTlv(bgpconfig.getLsCapability())
.setLargeAsCapabilityTlv(bgpconfig.getLargeASCapability()).build();
.setHoldTime(bgpconfig.getHoldTime()).setBgpId(bgpId)
.setLsCapabilityTlv(bgpconfig.getLsCapability())
.setLargeAsCapabilityTlv(bgpconfig.getLargeASCapability())
.setFlowSpecCapabilityTlv(flowSpecStatus)
.setVpnFlowSpecCapabilityTlv(vpnFlowSpecStatus).build();
log.debug("Sending open message to {}", channel.getRemoteAddress());
channel.write(Collections.singletonList(msg));
......@@ -775,12 +787,17 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler {
BgpValueType tempTlv;
boolean isLargeAsCapabilityCfg = h.bgpconfig.getLargeASCapability();
boolean isLsCapabilityCfg = h.bgpconfig.getLsCapability();
boolean isFlowSpecCapabilityCfg = h.bgpconfig.flowSpecCapability();
boolean isFlowSpecCapabilityCfg = false;
MultiProtocolExtnCapabilityTlv tempCapability;
boolean isMultiProtocolLsCapability = false;
boolean isMultiProtocolFlowSpecCapability = false;
boolean isMultiProtocolVpnFlowSpecCapability = false;
BgpPeerConfig peerConfig = (BgpPeerConfig) h.bgpconfig.displayPeers(peerAddr);
if (peerConfig.flowSpecStatus() != BgpPeerCfg.FlowSpec.NONE) {
isFlowSpecCapabilityCfg = true;
}
while (listIterator.hasNext()) {
BgpValueType tlv = listIterator.next();
if (tlv.getType() == MULTI_PROTOCOL_EXTN_CAPA_TYPE) {
......
......@@ -47,7 +47,6 @@ public class BgpConfig implements BgpCfg {
private int localAs;
private int maxSession;
private boolean lsCapability;
private boolean flowSpecCapability;
private short holdTime;
private boolean largeAs = false;
private int maxConnRetryTime;
......@@ -120,16 +119,6 @@ public class BgpConfig implements BgpCfg {
}
@Override
public boolean flowSpecCapability() {
return this.flowSpecCapability;
}
@Override
public void setFlowSpecCapability(boolean vpnFlowSpecCapability) {
this.flowSpecCapability = flowSpecCapability;
}
@Override
public String getRouterId() {
if (this.routerId != null) {
return this.routerId.toString();
......
......@@ -30,6 +30,7 @@ public class BgpPeerConfig implements BgpPeerCfg {
private State state;
private boolean selfInitiated;
private BgpConnectPeer connectPeer;
private FlowSpec flowSpecStatus = FlowSpec.NONE;
/**
* Constructor to initialize the values.
......@@ -118,4 +119,14 @@ 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;
}
}
......