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 { ...@@ -73,20 +73,6 @@ public interface BgpCfg {
73 void setLsCapability(boolean lscapability); 73 void setLsCapability(boolean lscapability);
74 74
75 /** 75 /**
76 - * Get the status of the flow specification support for this BGP speaker.
77 - *
78 - * @return true if the flow specification is supported otherwise false
79 - */
80 - boolean flowSpecCapability();
81 -
82 - /**
83 - * Set the flow specification support to this BGP speaker.
84 - *
85 - * @param flowSpecCapability BGP flow specification capability support
86 - */
87 - void setFlowSpecCapability(boolean flowSpecCapability);
88 -
89 - /**
90 * Get the status of the 32 bit AS support for this BGP speaker. 76 * Get the status of the 32 bit AS support for this BGP speaker.
91 * 77 *
92 * @return true if the 32 bit AS number is supported else false 78 * @return true if the 32 bit AS number is supported else false
......
...@@ -58,6 +58,24 @@ public interface BgpPeerCfg { ...@@ -58,6 +58,24 @@ public interface BgpPeerCfg {
58 INVALID 58 INVALID
59 } 59 }
60 60
61 + enum FlowSpec {
62 +
63 + /**
64 + * Signifies that peer support IPV4 flow specification.
65 + */
66 + IPV4,
67 +
68 + /**
69 + * Signifies that peer support VPNV4 flow specification.
70 + */
71 + VPNV4,
72 +
73 + /**
74 + * Signifies that peer flow specification support disabled.
75 + */
76 + NONE
77 + }
78 +
61 /** 79 /**
62 * Returns the connection State information of the peer. 80 * Returns the connection State information of the peer.
63 * 81 *
...@@ -177,4 +195,18 @@ public interface BgpPeerCfg { ...@@ -177,4 +195,18 @@ public interface BgpPeerCfg {
177 * @return peer connect instance 195 * @return peer connect instance
178 */ 196 */
179 BgpConnectPeer connectPeer(); 197 BgpConnectPeer connectPeer();
198 +
199 + /**
200 + * Gets the flow specification capability.
201 + *
202 + * @return flow specification status
203 + */
204 + public FlowSpec flowSpecStatus();
205 +
206 + /**
207 + * sets the flow specification capability.
208 + *
209 + * @param flowSpecStatus flow specification status
210 + */
211 + public void setFlowSpecStatus(FlowSpec flowSpecStatus);
180 } 212 }
......
...@@ -665,11 +665,23 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler { ...@@ -665,11 +665,23 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler {
665 */ 665 */
666 private void sendHandshakeOpenMessage() throws IOException, BgpParseException { 666 private void sendHandshakeOpenMessage() throws IOException, BgpParseException {
667 int bgpId; 667 int bgpId;
668 + boolean flowSpecStatus = false;
669 + boolean vpnFlowSpecStatus = false;
668 670
669 bgpId = Ip4Address.valueOf(bgpconfig.getRouterId()).toInt(); 671 bgpId = Ip4Address.valueOf(bgpconfig.getRouterId()).toInt();
672 + BgpPeerConfig peerConfig = (BgpPeerConfig) bgpconfig.displayPeers(peerAddr);
673 + if (peerConfig.flowSpecStatus() == BgpPeerCfg.FlowSpec.IPV4) {
674 + flowSpecStatus = true;
675 + } else if (peerConfig.flowSpecStatus() == BgpPeerCfg.FlowSpec.VPNV4) {
676 + vpnFlowSpecStatus = true;
677 + }
678 +
670 BgpMessage msg = factory4.openMessageBuilder().setAsNumber((short) bgpconfig.getAsNumber()) 679 BgpMessage msg = factory4.openMessageBuilder().setAsNumber((short) bgpconfig.getAsNumber())
671 - .setHoldTime(bgpconfig.getHoldTime()).setBgpId(bgpId).setLsCapabilityTlv(bgpconfig.getLsCapability()) 680 + .setHoldTime(bgpconfig.getHoldTime()).setBgpId(bgpId)
672 - .setLargeAsCapabilityTlv(bgpconfig.getLargeASCapability()).build(); 681 + .setLsCapabilityTlv(bgpconfig.getLsCapability())
682 + .setLargeAsCapabilityTlv(bgpconfig.getLargeASCapability())
683 + .setFlowSpecCapabilityTlv(flowSpecStatus)
684 + .setVpnFlowSpecCapabilityTlv(vpnFlowSpecStatus).build();
673 log.debug("Sending open message to {}", channel.getRemoteAddress()); 685 log.debug("Sending open message to {}", channel.getRemoteAddress());
674 channel.write(Collections.singletonList(msg)); 686 channel.write(Collections.singletonList(msg));
675 687
...@@ -775,12 +787,17 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler { ...@@ -775,12 +787,17 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler {
775 BgpValueType tempTlv; 787 BgpValueType tempTlv;
776 boolean isLargeAsCapabilityCfg = h.bgpconfig.getLargeASCapability(); 788 boolean isLargeAsCapabilityCfg = h.bgpconfig.getLargeASCapability();
777 boolean isLsCapabilityCfg = h.bgpconfig.getLsCapability(); 789 boolean isLsCapabilityCfg = h.bgpconfig.getLsCapability();
778 - boolean isFlowSpecCapabilityCfg = h.bgpconfig.flowSpecCapability(); 790 + boolean isFlowSpecCapabilityCfg = false;
779 MultiProtocolExtnCapabilityTlv tempCapability; 791 MultiProtocolExtnCapabilityTlv tempCapability;
780 boolean isMultiProtocolLsCapability = false; 792 boolean isMultiProtocolLsCapability = false;
781 boolean isMultiProtocolFlowSpecCapability = false; 793 boolean isMultiProtocolFlowSpecCapability = false;
782 boolean isMultiProtocolVpnFlowSpecCapability = false; 794 boolean isMultiProtocolVpnFlowSpecCapability = false;
783 795
796 + BgpPeerConfig peerConfig = (BgpPeerConfig) h.bgpconfig.displayPeers(peerAddr);
797 + if (peerConfig.flowSpecStatus() != BgpPeerCfg.FlowSpec.NONE) {
798 + isFlowSpecCapabilityCfg = true;
799 + }
800 +
784 while (listIterator.hasNext()) { 801 while (listIterator.hasNext()) {
785 BgpValueType tlv = listIterator.next(); 802 BgpValueType tlv = listIterator.next();
786 if (tlv.getType() == MULTI_PROTOCOL_EXTN_CAPA_TYPE) { 803 if (tlv.getType() == MULTI_PROTOCOL_EXTN_CAPA_TYPE) {
......
...@@ -47,7 +47,6 @@ public class BgpConfig implements BgpCfg { ...@@ -47,7 +47,6 @@ public class BgpConfig implements BgpCfg {
47 private int localAs; 47 private int localAs;
48 private int maxSession; 48 private int maxSession;
49 private boolean lsCapability; 49 private boolean lsCapability;
50 - private boolean flowSpecCapability;
51 private short holdTime; 50 private short holdTime;
52 private boolean largeAs = false; 51 private boolean largeAs = false;
53 private int maxConnRetryTime; 52 private int maxConnRetryTime;
...@@ -120,16 +119,6 @@ public class BgpConfig implements BgpCfg { ...@@ -120,16 +119,6 @@ public class BgpConfig implements BgpCfg {
120 } 119 }
121 120
122 @Override 121 @Override
123 - public boolean flowSpecCapability() {
124 - return this.flowSpecCapability;
125 - }
126 -
127 - @Override
128 - public void setFlowSpecCapability(boolean vpnFlowSpecCapability) {
129 - this.flowSpecCapability = flowSpecCapability;
130 - }
131 -
132 - @Override
133 public String getRouterId() { 122 public String getRouterId() {
134 if (this.routerId != null) { 123 if (this.routerId != null) {
135 return this.routerId.toString(); 124 return this.routerId.toString();
......
...@@ -30,6 +30,7 @@ public class BgpPeerConfig implements BgpPeerCfg { ...@@ -30,6 +30,7 @@ public class BgpPeerConfig implements BgpPeerCfg {
30 private State state; 30 private State state;
31 private boolean selfInitiated; 31 private boolean selfInitiated;
32 private BgpConnectPeer connectPeer; 32 private BgpConnectPeer connectPeer;
33 + private FlowSpec flowSpecStatus = FlowSpec.NONE;
33 34
34 /** 35 /**
35 * Constructor to initialize the values. 36 * Constructor to initialize the values.
...@@ -118,4 +119,14 @@ public class BgpPeerConfig implements BgpPeerCfg { ...@@ -118,4 +119,14 @@ public class BgpPeerConfig implements BgpPeerCfg {
118 public void setConnectPeer(BgpConnectPeer connectPeer) { 119 public void setConnectPeer(BgpConnectPeer connectPeer) {
119 this.connectPeer = connectPeer; 120 this.connectPeer = connectPeer;
120 } 121 }
122 +
123 + @Override
124 + public FlowSpec flowSpecStatus() {
125 + return flowSpecStatus;
126 + }
127 +
128 + @Override
129 + public void setFlowSpecStatus(FlowSpec flowSpecStatus) {
130 + this.flowSpecStatus = flowSpecStatus;
131 + }
121 } 132 }
......