Committed by
Gerrit Code Review
BGP flow spec configuration system test issue fix.
Change-Id: Ia912fdb15f584b477ead748aed87e3c4fa003d29
Showing
7 changed files
with
110 additions
and
52 deletions
... | @@ -44,6 +44,29 @@ public interface BgpCfg { | ... | @@ -44,6 +44,29 @@ public interface BgpCfg { |
44 | IP_AS_CONFIGURED | 44 | IP_AS_CONFIGURED |
45 | } | 45 | } |
46 | 46 | ||
47 | + enum FlowSpec { | ||
48 | + | ||
49 | + /** | ||
50 | + * Signifies that peer support IPV4 flow specification. | ||
51 | + */ | ||
52 | + IPV4, | ||
53 | + | ||
54 | + /** | ||
55 | + * Signifies that peer support VPNV4 flow specification. | ||
56 | + */ | ||
57 | + VPNV4, | ||
58 | + | ||
59 | + /** | ||
60 | + * Signifies that peer support IPV4 and VPNV4 flow specification. | ||
61 | + */ | ||
62 | + IPV4_VPNV4, | ||
63 | + | ||
64 | + /** | ||
65 | + * Signifies that peer flow specification capability disabled. | ||
66 | + */ | ||
67 | + NONE | ||
68 | + } | ||
69 | + | ||
47 | /** | 70 | /** |
48 | * Returns the status of the configuration based on this state certain operations like connection is handled. | 71 | * Returns the status of the configuration based on this state certain operations like connection is handled. |
49 | * | 72 | * |
... | @@ -294,4 +317,18 @@ public interface BgpCfg { | ... | @@ -294,4 +317,18 @@ public interface BgpCfg { |
294 | * @return state information | 317 | * @return state information |
295 | */ | 318 | */ |
296 | BgpPeerCfg.State getPeerConnState(String routerid); | 319 | BgpPeerCfg.State getPeerConnState(String routerid); |
320 | + | ||
321 | + /** | ||
322 | + * Gets the flow specification capability. | ||
323 | + * | ||
324 | + * @return flow specification capability | ||
325 | + */ | ||
326 | + FlowSpec flowSpecCapability(); | ||
327 | + | ||
328 | + /** | ||
329 | + * Sets the flow specification capability. | ||
330 | + * | ||
331 | + * @param flowSpec flow specification capability | ||
332 | + */ | ||
333 | + void setFlowSpecCapability(FlowSpec flowSpec); | ||
297 | } | 334 | } | ... | ... |
... | @@ -58,24 +58,6 @@ public interface BgpPeerCfg { | ... | @@ -58,24 +58,6 @@ 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 | - | ||
79 | /** | 61 | /** |
80 | * Returns the connection State information of the peer. | 62 | * Returns the connection State information of the peer. |
81 | * | 63 | * |
... | @@ -195,18 +177,4 @@ public interface BgpPeerCfg { | ... | @@ -195,18 +177,4 @@ public interface BgpPeerCfg { |
195 | * @return peer connect instance | 177 | * @return peer connect instance |
196 | */ | 178 | */ |
197 | BgpConnectPeer connectPeer(); | 179 | 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); | ||
212 | } | 180 | } | ... | ... |
... | @@ -665,14 +665,18 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -665,14 +665,18 @@ 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 | + BgpCfg.FlowSpec flowSpec = bgpconfig.flowSpecCapability(); | ||
668 | boolean flowSpecStatus = false; | 669 | boolean flowSpecStatus = false; |
669 | boolean vpnFlowSpecStatus = false; | 670 | boolean vpnFlowSpecStatus = false; |
670 | 671 | ||
671 | bgpId = Ip4Address.valueOf(bgpconfig.getRouterId()).toInt(); | 672 | bgpId = Ip4Address.valueOf(bgpconfig.getRouterId()).toInt(); |
672 | - BgpPeerConfig peerConfig = (BgpPeerConfig) bgpconfig.displayPeers(peerAddr); | 673 | + |
673 | - if (peerConfig.flowSpecStatus() == BgpPeerCfg.FlowSpec.IPV4) { | 674 | + if (flowSpec == BgpCfg.FlowSpec.IPV4) { |
675 | + flowSpecStatus = true; | ||
676 | + } else if (flowSpec == BgpCfg.FlowSpec.VPNV4) { | ||
677 | + vpnFlowSpecStatus = true; | ||
678 | + } else if (flowSpec == BgpCfg.FlowSpec.IPV4_VPNV4) { | ||
674 | flowSpecStatus = true; | 679 | flowSpecStatus = true; |
675 | - } else if (peerConfig.flowSpecStatus() == BgpPeerCfg.FlowSpec.VPNV4) { | ||
676 | vpnFlowSpecStatus = true; | 680 | vpnFlowSpecStatus = true; |
677 | } | 681 | } |
678 | 682 | ||
... | @@ -792,9 +796,9 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -792,9 +796,9 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler { |
792 | boolean isMultiProtocolLsCapability = false; | 796 | boolean isMultiProtocolLsCapability = false; |
793 | boolean isMultiProtocolFlowSpecCapability = false; | 797 | boolean isMultiProtocolFlowSpecCapability = false; |
794 | boolean isMultiProtocolVpnFlowSpecCapability = false; | 798 | boolean isMultiProtocolVpnFlowSpecCapability = false; |
799 | + BgpCfg.FlowSpec flowSpec = h.bgpconfig.flowSpecCapability(); | ||
795 | 800 | ||
796 | - BgpPeerConfig peerConfig = (BgpPeerConfig) h.bgpconfig.displayPeers(peerAddr); | 801 | + if (flowSpec != BgpCfg.FlowSpec.NONE) { |
797 | - if (peerConfig.flowSpecStatus() != BgpPeerCfg.FlowSpec.NONE) { | ||
798 | isFlowSpecCapabilityCfg = true; | 802 | isFlowSpecCapabilityCfg = true; |
799 | } | 803 | } |
800 | 804 | ... | ... |
... | @@ -51,7 +51,7 @@ public class BgpConfig implements BgpCfg { | ... | @@ -51,7 +51,7 @@ public class BgpConfig implements BgpCfg { |
51 | private boolean largeAs = false; | 51 | private boolean largeAs = false; |
52 | private int maxConnRetryTime; | 52 | private int maxConnRetryTime; |
53 | private int maxConnRetryCount; | 53 | private int maxConnRetryCount; |
54 | - | 54 | + private FlowSpec flowSpec = FlowSpec.NONE; |
55 | private Ip4Address routerId = null; | 55 | private Ip4Address routerId = null; |
56 | private TreeMap<String, BgpPeerCfg> bgpPeerTree = new TreeMap<>(); | 56 | private TreeMap<String, BgpPeerCfg> bgpPeerTree = new TreeMap<>(); |
57 | private BgpConnectPeer connectPeer; | 57 | private BgpConnectPeer connectPeer; |
... | @@ -119,6 +119,16 @@ public class BgpConfig implements BgpCfg { | ... | @@ -119,6 +119,16 @@ public class BgpConfig implements BgpCfg { |
119 | } | 119 | } |
120 | 120 | ||
121 | @Override | 121 | @Override |
122 | + public FlowSpec flowSpecCapability() { | ||
123 | + return this.flowSpec; | ||
124 | + } | ||
125 | + | ||
126 | + @Override | ||
127 | + public void setFlowSpecCapability(FlowSpec flowSpec) { | ||
128 | + this.flowSpec = flowSpec; | ||
129 | + } | ||
130 | + | ||
131 | + @Override | ||
122 | public String getRouterId() { | 132 | public String getRouterId() { |
123 | if (this.routerId != null) { | 133 | if (this.routerId != null) { |
124 | return this.routerId.toString(); | 134 | return this.routerId.toString(); |
... | @@ -222,7 +232,7 @@ public class BgpConfig implements BgpCfg { | ... | @@ -222,7 +232,7 @@ public class BgpConfig implements BgpCfg { |
222 | if (disconnPeer != null) { | 232 | if (disconnPeer != null) { |
223 | // TODO: send notification peer deconfigured | 233 | // TODO: send notification peer deconfigured |
224 | disconnPeer.disconnectPeer(); | 234 | disconnPeer.disconnectPeer(); |
225 | - } else { | 235 | + } else if (lspeer.connectPeer() != null) { |
226 | lspeer.connectPeer().disconnectPeer(); | 236 | lspeer.connectPeer().disconnectPeer(); |
227 | } | 237 | } |
228 | lspeer.setState(BgpPeerCfg.State.IDLE); | 238 | lspeer.setState(BgpPeerCfg.State.IDLE); | ... | ... |
... | @@ -30,7 +30,6 @@ public class BgpPeerConfig implements BgpPeerCfg { | ... | @@ -30,7 +30,6 @@ 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; | ||
34 | 33 | ||
35 | /** | 34 | /** |
36 | * Constructor to initialize the values. | 35 | * Constructor to initialize the values. |
... | @@ -119,14 +118,4 @@ public class BgpPeerConfig implements BgpPeerCfg { | ... | @@ -119,14 +118,4 @@ public class BgpPeerConfig implements BgpPeerCfg { |
119 | public void setConnectPeer(BgpConnectPeer connectPeer) { | 118 | public void setConnectPeer(BgpConnectPeer connectPeer) { |
120 | this.connectPeer = connectPeer; | 119 | this.connectPeer = connectPeer; |
121 | } | 120 | } |
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 | - } | ||
132 | } | 121 | } | ... | ... |
... | @@ -47,6 +47,7 @@ public class BgpAppConfig extends Config<ApplicationId> { | ... | @@ -47,6 +47,7 @@ public class BgpAppConfig extends Config<ApplicationId> { |
47 | public static final String LS_CAPABILITY = "lsCapability"; | 47 | public static final String LS_CAPABILITY = "lsCapability"; |
48 | public static final String HOLD_TIME = "holdTime"; | 48 | public static final String HOLD_TIME = "holdTime"; |
49 | public static final String LARGE_AS_CAPABILITY = "largeAsCapability"; | 49 | public static final String LARGE_AS_CAPABILITY = "largeAsCapability"; |
50 | + public static final String FLOW_SPEC_CAPABILITY = "flowSpecCapability"; | ||
50 | 51 | ||
51 | public static final String BGP_PEER = "bgpPeer"; | 52 | public static final String BGP_PEER = "bgpPeer"; |
52 | public static final String PEER_IP = "peerIp"; | 53 | public static final String PEER_IP = "peerIp"; |
... | @@ -67,10 +68,11 @@ public class BgpAppConfig extends Config<ApplicationId> { | ... | @@ -67,10 +68,11 @@ public class BgpAppConfig extends Config<ApplicationId> { |
67 | bgpConfig = bgpController.getConfig(); | 68 | bgpConfig = bgpController.getConfig(); |
68 | 69 | ||
69 | fields = hasOnlyFields(ROUTER_ID, LOCAL_AS, MAX_SESSION, LS_CAPABILITY, | 70 | fields = hasOnlyFields(ROUTER_ID, LOCAL_AS, MAX_SESSION, LS_CAPABILITY, |
70 | - HOLD_TIME, LARGE_AS_CAPABILITY, BGP_PEER) && | 71 | + HOLD_TIME, LARGE_AS_CAPABILITY, FLOW_SPEC_CAPABILITY, BGP_PEER) && |
71 | isIpAddress(ROUTER_ID, MANDATORY) && isNumber(LOCAL_AS, MANDATORY) && | 72 | isIpAddress(ROUTER_ID, MANDATORY) && isNumber(LOCAL_AS, MANDATORY) && |
72 | isNumber(MAX_SESSION, OPTIONAL, 20) && isNumber(HOLD_TIME, OPTIONAL, 180) && | 73 | isNumber(MAX_SESSION, OPTIONAL, 20) && isNumber(HOLD_TIME, OPTIONAL, 180) && |
73 | - isBoolean(LS_CAPABILITY, OPTIONAL) && isBoolean(LARGE_AS_CAPABILITY, OPTIONAL); | 74 | + isBoolean(LS_CAPABILITY, OPTIONAL) && isBoolean(LARGE_AS_CAPABILITY, OPTIONAL) && |
75 | + isString(FLOW_SPEC_CAPABILITY, OPTIONAL); | ||
74 | 76 | ||
75 | if (!fields) { | 77 | if (!fields) { |
76 | return fields; | 78 | return fields; |
... | @@ -125,6 +127,15 @@ public class BgpAppConfig extends Config<ApplicationId> { | ... | @@ -125,6 +127,15 @@ public class BgpAppConfig extends Config<ApplicationId> { |
125 | } | 127 | } |
126 | 128 | ||
127 | /** | 129 | /** |
130 | + * Returns flow specification capability support from the configuration. | ||
131 | + * | ||
132 | + * @return flow specification capability | ||
133 | + */ | ||
134 | + public String flowSpecCapability() { | ||
135 | + return get(FLOW_SPEC_CAPABILITY, null); | ||
136 | + } | ||
137 | + | ||
138 | + /** | ||
128 | * Returns holdTime of the local node from the configuration. | 139 | * Returns holdTime of the local node from the configuration. |
129 | * | 140 | * |
130 | * @return holdTime | 141 | * @return holdTime |
... | @@ -134,6 +145,22 @@ public class BgpAppConfig extends Config<ApplicationId> { | ... | @@ -134,6 +145,22 @@ public class BgpAppConfig extends Config<ApplicationId> { |
134 | } | 145 | } |
135 | 146 | ||
136 | /** | 147 | /** |
148 | + * Validates the flow specification capability. | ||
149 | + * | ||
150 | + * @return true if valid else false | ||
151 | + */ | ||
152 | + public boolean validateFlowSpec() { | ||
153 | + if (flowSpecCapability() != null) { | ||
154 | + String flowSpec = flowSpecCapability(); | ||
155 | + if ((flowSpec.equals("IPV4")) || (flowSpec.equals("VPNV4")) || (flowSpec.equals("IPV4_VPNV4"))) { | ||
156 | + return true; | ||
157 | + } | ||
158 | + } | ||
159 | + | ||
160 | + return false; | ||
161 | + } | ||
162 | + | ||
163 | + /** | ||
137 | * Validates the Bgp local and peer configuration. | 164 | * Validates the Bgp local and peer configuration. |
138 | * | 165 | * |
139 | * @return true if valid else false | 166 | * @return true if valid else false |
... | @@ -152,6 +179,9 @@ public class BgpAppConfig extends Config<ApplicationId> { | ... | @@ -152,6 +179,9 @@ public class BgpAppConfig extends Config<ApplicationId> { |
152 | return false; | 179 | return false; |
153 | } | 180 | } |
154 | 181 | ||
182 | + if (!validateFlowSpec()) { | ||
183 | + return false; | ||
184 | + } | ||
155 | return true; | 185 | return true; |
156 | } | 186 | } |
157 | 187 | ... | ... |
... | @@ -128,6 +128,16 @@ public class BgpCfgProvider extends AbstractProvider { | ... | @@ -128,6 +128,16 @@ public class BgpCfgProvider extends AbstractProvider { |
128 | bgpConfig.setMaxSession(config.maxSession()); | 128 | bgpConfig.setMaxSession(config.maxSession()); |
129 | bgpConfig.setLargeASCapability(config.largeAsCapability()); | 129 | bgpConfig.setLargeASCapability(config.largeAsCapability()); |
130 | 130 | ||
131 | + if (config.flowSpecCapability().equals("IPV4")) { | ||
132 | + bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.IPV4); | ||
133 | + } else if (config.flowSpecCapability().equals("VPNV4")) { | ||
134 | + bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.VPNV4); | ||
135 | + } else if (config.flowSpecCapability().equals("IPV4_VPNV4")) { | ||
136 | + bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.IPV4_VPNV4); | ||
137 | + } else { | ||
138 | + bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.NONE); | ||
139 | + } | ||
140 | + | ||
131 | nodes = config.bgpPeer(); | 141 | nodes = config.bgpPeer(); |
132 | for (int i = 0; i < nodes.size(); i++) { | 142 | for (int i = 0; i < nodes.size(); i++) { |
133 | String connectMode = nodes.get(i).connectMode(); | 143 | String connectMode = nodes.get(i).connectMode(); |
... | @@ -163,6 +173,16 @@ public class BgpCfgProvider extends AbstractProvider { | ... | @@ -163,6 +173,16 @@ public class BgpCfgProvider extends AbstractProvider { |
163 | bgpConfig.setHoldTime(config.holdTime()); | 173 | bgpConfig.setHoldTime(config.holdTime()); |
164 | bgpConfig.setMaxSession(config.maxSession()); | 174 | bgpConfig.setMaxSession(config.maxSession()); |
165 | bgpConfig.setLargeASCapability(config.largeAsCapability()); | 175 | bgpConfig.setLargeASCapability(config.largeAsCapability()); |
176 | + | ||
177 | + if (config.flowSpecCapability().equals("IPV4")) { | ||
178 | + bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.IPV4); | ||
179 | + } else if (config.flowSpecCapability().equals("VPNV4")) { | ||
180 | + bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.VPNV4); | ||
181 | + } else if (config.flowSpecCapability().equals("IPV4_VPNV4")) { | ||
182 | + bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.IPV4_VPNV4); | ||
183 | + } else { | ||
184 | + bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.NONE); | ||
185 | + } | ||
166 | } else { | 186 | } else { |
167 | log.info(" Self configuration cannot be modified as there is existing connections "); | 187 | log.info(" Self configuration cannot be modified as there is existing connections "); |
168 | } | 188 | } | ... | ... |
-
Please register or login to post a comment