Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.bgp.controller.impl; |
| 18 | |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 19 | import org.onosproject.bgp.controller.BgpCfg; |
| 20 | import org.onosproject.bgp.controller.BgpController; |
| 21 | import org.onosproject.bgp.controller.BgpId; |
Priyanka B | fc51c95 | 2016-03-26 14:30:33 +0530 | [diff] [blame] | 22 | import org.onosproject.bgp.controller.BgpLinkListener; |
Shashikanth VH | 3fe3798 | 2015-11-30 11:50:07 +0530 | [diff] [blame] | 23 | import org.onosproject.bgp.controller.BgpLocalRib; |
Shashikanth VH | f62b5c0 | 2015-11-20 22:23:08 +0530 | [diff] [blame] | 24 | import org.onosproject.bgp.controller.BgpNodeListener; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 25 | import org.onosproject.bgp.controller.BgpPeer; |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 26 | import org.onosproject.bgp.controller.BgpPeerManager; |
Mohammad Shahid | 30fedc5 | 2017-08-09 11:49:40 +0530 | [diff] [blame] | 27 | import org.onosproject.bgp.controller.BgpRouteListener; |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 28 | import org.onosproject.bgpio.exceptions.BgpParseException; |
| 29 | import org.onosproject.bgpio.protocol.BgpMessage; |
Shashikanth VH | 3fe3798 | 2015-11-30 11:50:07 +0530 | [diff] [blame] | 30 | import org.onosproject.bgpio.protocol.BgpUpdateMsg; |
| 31 | import org.onosproject.bgpio.types.BgpValueType; |
| 32 | import org.onosproject.bgpio.types.MpReachNlri; |
| 33 | import org.onosproject.bgpio.types.MpUnReachNlri; |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 34 | import org.osgi.service.component.annotations.Activate; |
| 35 | import org.osgi.service.component.annotations.Component; |
| 36 | import org.osgi.service.component.annotations.Deactivate; |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 37 | import org.slf4j.Logger; |
| 38 | import org.slf4j.LoggerFactory; |
| 39 | |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 40 | import java.util.Iterator; |
mohamedrahil | 00f6f26 | 2016-11-24 20:20:41 +0530 | [diff] [blame] | 41 | import java.util.LinkedList; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 42 | import java.util.List; |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 43 | import java.util.Map; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 44 | import java.util.Set; |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 45 | import java.util.TreeMap; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 46 | import java.util.concurrent.ConcurrentHashMap; |
| 47 | import java.util.concurrent.CopyOnWriteArraySet; |
| 48 | import java.util.concurrent.locks.Lock; |
| 49 | import java.util.concurrent.locks.ReentrantLock; |
| 50 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 51 | @Component(immediate = true, service = BgpController.class) |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 52 | public class BgpControllerImpl implements BgpController { |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 53 | |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 54 | private static final Logger log = LoggerFactory.getLogger(BgpControllerImpl.class); |
mohamedrahil | 00f6f26 | 2016-11-24 20:20:41 +0530 | [diff] [blame] | 55 | final Controller ctrl = new Controller(this); |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 56 | protected ConcurrentHashMap<BgpId, BgpPeer> connectedPeers = new ConcurrentHashMap<BgpId, BgpPeer>(); |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 57 | |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 58 | protected BgpPeerManagerImpl peerManager = new BgpPeerManagerImpl(); |
Shashikanth VH | f62b5c0 | 2015-11-20 22:23:08 +0530 | [diff] [blame] | 59 | |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 60 | private BgpLocalRib bgplocalRib = new BgpLocalRibImpl(this); |
| 61 | private BgpLocalRib bgplocalRibVpn = new BgpLocalRibImpl(this); |
Shashikanth VH | 3fe3798 | 2015-11-30 11:50:07 +0530 | [diff] [blame] | 62 | |
Shashikanth VH | f62b5c0 | 2015-11-20 22:23:08 +0530 | [diff] [blame] | 63 | protected Set<BgpNodeListener> bgpNodeListener = new CopyOnWriteArraySet<>(); |
Priyanka B | fc51c95 | 2016-03-26 14:30:33 +0530 | [diff] [blame] | 64 | protected Set<BgpLinkListener> bgpLinkListener = new CopyOnWriteArraySet<>(); |
mohamedrahil | 00f6f26 | 2016-11-24 20:20:41 +0530 | [diff] [blame] | 65 | protected BgpController bgpController; |
Shashikanth VH | 3fe3798 | 2015-11-30 11:50:07 +0530 | [diff] [blame] | 66 | private BgpConfig bgpconfig = new BgpConfig(this); |
mohamedrahil | 00f6f26 | 2016-11-24 20:20:41 +0530 | [diff] [blame] | 67 | private List<String> activeExceptionList = new LinkedList(); |
| 68 | private LinkedList<String> closedExceptionList = new LinkedList<String>(); |
| 69 | private Map<String, List<String>> activeSessionExceptionMap = new TreeMap<>(); |
| 70 | private Map<String, List<String>> closedSessionExceptionMap = new TreeMap<>(); |
Mohammad Shahid | 30fedc5 | 2017-08-09 11:49:40 +0530 | [diff] [blame] | 71 | protected Set<BgpRouteListener> bgpRouteListener = new CopyOnWriteArraySet<>(); |
mohamedrahil | 00f6f26 | 2016-11-24 20:20:41 +0530 | [diff] [blame] | 72 | |
| 73 | @Override |
| 74 | public void activeSessionExceptionAdd(String peerId, String exception) { |
| 75 | if (peerId != null) { |
| 76 | activeExceptionList.add(exception); |
| 77 | activeSessionExceptionMap.put(peerId, activeExceptionList); |
| 78 | } else { |
| 79 | log.debug("Peer Id is null"); |
| 80 | } |
| 81 | if (activeExceptionList.size() > 10) { |
| 82 | activeExceptionList.clear(); |
| 83 | activeExceptionList.add(exception); |
| 84 | activeSessionExceptionMap.put(peerId, activeExceptionList); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | |
| 89 | @Override |
| 90 | public void closedSessionExceptionAdd(String peerId, String exception) { |
| 91 | if (peerId != null) { |
| 92 | closedExceptionList.add(exception); |
| 93 | closedSessionExceptionMap.put(peerId, closedExceptionList); |
| 94 | } else { |
| 95 | log.debug("Peer Id is null"); |
| 96 | } |
| 97 | if (closedExceptionList.size() > 10) { |
| 98 | closedExceptionList.clear(); |
| 99 | closedExceptionList.add(exception); |
| 100 | closedSessionExceptionMap.put(peerId, closedExceptionList); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | @Override |
| 105 | public Map<String, List<String>> activeSessionMap() { |
| 106 | return activeSessionExceptionMap; |
| 107 | } |
| 108 | |
| 109 | @Override |
| 110 | public Map<String, List<String>> closedSessionMap() { |
| 111 | return closedSessionExceptionMap; |
| 112 | } |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 113 | |
Mohammad Shahid | 30fedc5 | 2017-08-09 11:49:40 +0530 | [diff] [blame] | 114 | @Override |
| 115 | public void addRouteListener(BgpRouteListener listener) { |
| 116 | this.bgpRouteListener.add(listener); |
| 117 | } |
| 118 | |
| 119 | @Override |
| 120 | public void removeRouteListener(BgpRouteListener listener) { |
| 121 | this.bgpRouteListener.remove(listener); |
| 122 | } |
| 123 | |
| 124 | @Override |
| 125 | public Set<BgpRouteListener> routeListener() { |
| 126 | return bgpRouteListener; |
| 127 | } |
| 128 | |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 129 | @Activate |
| 130 | public void activate() { |
| 131 | this.ctrl.start(); |
| 132 | log.info("Started"); |
| 133 | } |
| 134 | |
| 135 | @Deactivate |
| 136 | public void deactivate() { |
mohamedrahil | 00f6f26 | 2016-11-24 20:20:41 +0530 | [diff] [blame] | 137 | activeSessionExceptionMap.clear(); |
| 138 | closedSessionExceptionMap.clear(); |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 139 | // Close all connected peers |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 140 | closeConnectedPeers(); |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 141 | this.ctrl.stop(); |
| 142 | log.info("Stopped"); |
| 143 | } |
| 144 | |
| 145 | @Override |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 146 | public Iterable<BgpPeer> getPeers() { |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 147 | return this.connectedPeers.values(); |
| 148 | } |
| 149 | |
| 150 | @Override |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 151 | public BgpPeer getPeer(BgpId bgpId) { |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 152 | return this.connectedPeers.get(bgpId); |
| 153 | } |
| 154 | |
| 155 | @Override |
Shashikanth VH | f62b5c0 | 2015-11-20 22:23:08 +0530 | [diff] [blame] | 156 | public void addListener(BgpNodeListener listener) { |
| 157 | this.bgpNodeListener.add(listener); |
| 158 | } |
| 159 | |
| 160 | @Override |
| 161 | public void removeListener(BgpNodeListener listener) { |
| 162 | this.bgpNodeListener.remove(listener); |
| 163 | } |
| 164 | |
| 165 | @Override |
| 166 | public Set<BgpNodeListener> listener() { |
| 167 | return bgpNodeListener; |
| 168 | } |
| 169 | |
| 170 | @Override |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 171 | public void writeMsg(BgpId bgpId, BgpMessage msg) { |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 172 | this.getPeer(bgpId).sendMessage(msg); |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | @Override |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 176 | public void processBgpPacket(BgpId bgpId, BgpMessage msg) throws BgpParseException { |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 177 | |
Shashikanth VH | 3fe3798 | 2015-11-30 11:50:07 +0530 | [diff] [blame] | 178 | BgpPeer peer = getPeer(bgpId); |
| 179 | |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 180 | switch (msg.getType()) { |
Mohammad Shahid | 30fedc5 | 2017-08-09 11:49:40 +0530 | [diff] [blame] | 181 | case OPEN: |
| 182 | // TODO: Process Open message |
| 183 | break; |
| 184 | case KEEP_ALIVE: |
| 185 | // TODO: Process keepalive message |
| 186 | break; |
| 187 | case NOTIFICATION: |
| 188 | // TODO: Process notificatoin message |
| 189 | break; |
| 190 | case UPDATE: |
| 191 | BgpUpdateMsg updateMsg = (BgpUpdateMsg) msg; |
| 192 | List<BgpValueType> pathAttr = updateMsg.bgpPathAttributes().pathAttributes(); |
| 193 | if (pathAttr == null) { |
| 194 | log.debug("llPathAttr is null, cannot process update message"); |
| 195 | break; |
| 196 | } |
| 197 | Iterator<BgpValueType> listIterator = pathAttr.iterator(); |
| 198 | boolean isLinkstate = false; |
| 199 | boolean isEvpn = false; |
Shashikanth VH | 26fd38a | 2016-04-26 18:11:37 +0530 | [diff] [blame] | 200 | |
Mohammad Shahid | 30fedc5 | 2017-08-09 11:49:40 +0530 | [diff] [blame] | 201 | while (listIterator.hasNext()) { |
| 202 | BgpValueType attr = listIterator.next(); |
| 203 | if (attr instanceof MpReachNlri) { |
| 204 | MpReachNlri mpReach = (MpReachNlri) attr; |
| 205 | if (mpReach.bgpFlowSpecNlri() == null |
| 206 | && mpReach.bgpEvpnNlri() == null) { |
| 207 | isLinkstate = true; |
| 208 | } |
| 209 | if (mpReach.bgpEvpnNlri() != null) { |
| 210 | isEvpn = true; |
| 211 | } |
| 212 | } else if (attr instanceof MpUnReachNlri) { |
| 213 | MpUnReachNlri mpUnReach = (MpUnReachNlri) attr; |
| 214 | if (mpUnReach.bgpFlowSpecNlri() == null |
| 215 | && mpUnReach.bgpEvpnNlri() == null) { |
| 216 | isLinkstate = true; |
| 217 | } |
| 218 | if (mpUnReach.bgpEvpnNlri() != null) { |
| 219 | isEvpn = true; |
| 220 | } |
Shashikanth VH | afb2e00 | 2016-02-12 14:48:29 +0530 | [diff] [blame] | 221 | } |
Shashikanth VH | 3fe3798 | 2015-11-30 11:50:07 +0530 | [diff] [blame] | 222 | } |
Mohammad Shahid | 30fedc5 | 2017-08-09 11:49:40 +0530 | [diff] [blame] | 223 | if (isLinkstate) { |
| 224 | peer.buildAdjRibIn(pathAttr); |
| 225 | } |
| 226 | if (isEvpn) { |
| 227 | for (BgpRouteListener listener : bgpRouteListener) { |
| 228 | listener.processRoute(bgpId, updateMsg); |
| 229 | } |
| 230 | } |
| 231 | break; |
| 232 | default: |
| 233 | // TODO: Process other message |
| 234 | break; |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 235 | } |
| 236 | } |
| 237 | |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 238 | @Override |
| 239 | public void closeConnectedPeers() { |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 240 | BgpPeer bgpPeer; |
| 241 | for (BgpId id : this.connectedPeers.keySet()) { |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 242 | bgpPeer = getPeer(id); |
| 243 | bgpPeer.disconnectPeer(); |
| 244 | } |
| 245 | } |
| 246 | |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 247 | /** |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 248 | * Implementation of an BGP Peer which is responsible for keeping track of connected peers and the state in which |
| 249 | * they are. |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 250 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 251 | public class BgpPeerManagerImpl implements BgpPeerManager { |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 252 | |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 253 | private final Logger log = LoggerFactory.getLogger(BgpPeerManagerImpl.class); |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 254 | private final Lock peerLock = new ReentrantLock(); |
| 255 | |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 256 | @Override |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 257 | public boolean addConnectedPeer(BgpId bgpId, BgpPeer bgpPeer) { |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 258 | |
| 259 | if (connectedPeers.get(bgpId) != null) { |
| 260 | this.log.error("Trying to add connectedPeer but found previous " + "value for bgp ip: {}", |
| 261 | bgpId.toString()); |
| 262 | return false; |
| 263 | } else { |
| 264 | this.log.debug("Added Peer {}", bgpId.toString()); |
| 265 | connectedPeers.put(bgpId, bgpPeer); |
| 266 | return true; |
| 267 | } |
| 268 | } |
| 269 | |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 270 | @Override |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 271 | public boolean isPeerConnected(BgpId bgpId) { |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 272 | if (connectedPeers.get(bgpId) == null) { |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 273 | this.log.error("Is peer connected: bgpIp {}.", bgpId.toString()); |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 274 | return false; |
| 275 | } |
| 276 | |
| 277 | return true; |
| 278 | } |
| 279 | |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 280 | @Override |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 281 | public void removeConnectedPeer(BgpId bgpId) { |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 282 | connectedPeers.remove(bgpId); |
| 283 | } |
| 284 | |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 285 | @Override |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 286 | public BgpPeer getPeer(BgpId bgpId) { |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 287 | return connectedPeers.get(bgpId); |
| 288 | } |
| 289 | |
| 290 | /** |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 291 | * Gets bgp peer instance. |
| 292 | * |
| 293 | * @param bgpController controller instance. |
| 294 | * @param sessionInfo bgp session info. |
| 295 | * @param pktStats packet statistics. |
| 296 | * @return BGPPeer peer instance. |
| 297 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 298 | public BgpPeer getBgpPeerInstance(BgpController bgpController, BgpSessionInfoImpl sessionInfo, |
| 299 | BgpPacketStatsImpl pktStats) { |
| 300 | BgpPeer bgpPeer = new BgpPeerImpl(bgpController, sessionInfo, pktStats); |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 301 | return bgpPeer; |
| 302 | } |
| 303 | |
| 304 | } |
| 305 | |
Vidyashree Rama | 7bd3d78 | 2015-11-23 08:46:33 +0530 | [diff] [blame] | 306 | /** |
| 307 | * Returns controller. |
| 308 | * |
| 309 | * @return controller |
| 310 | */ |
| 311 | public Controller controller() { |
| 312 | return this.ctrl; |
| 313 | } |
| 314 | |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 315 | @Override |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 316 | public ConcurrentHashMap<BgpId, BgpPeer> connectedPeers() { |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 317 | return connectedPeers; |
| 318 | } |
| 319 | |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 320 | @Override |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 321 | public BgpPeerManagerImpl peerManager() { |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 322 | return peerManager; |
| 323 | } |
| 324 | |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 325 | @Override |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 326 | public BgpCfg getConfig() { |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 327 | return this.bgpconfig; |
| 328 | } |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 329 | |
| 330 | @Override |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 331 | public int connectedPeerCount() { |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 332 | return connectedPeers.size(); |
| 333 | } |
Shashikanth VH | 3fe3798 | 2015-11-30 11:50:07 +0530 | [diff] [blame] | 334 | |
| 335 | /** |
| 336 | * Gets the BGP local RIB. |
| 337 | * |
| 338 | * @return bgplocalRIB BGP local RIB. |
| 339 | */ |
| 340 | @Override |
| 341 | public BgpLocalRib bgpLocalRib() { |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 342 | return bgplocalRib; |
Shashikanth VH | 3fe3798 | 2015-11-30 11:50:07 +0530 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | /** |
| 346 | * Gets the BGP local RIB with VPN. |
| 347 | * |
| 348 | * @return bgplocalRIBVpn BGP VPN local RIB . |
| 349 | */ |
| 350 | @Override |
| 351 | public BgpLocalRib bgpLocalRibVpn() { |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 352 | return bgplocalRibVpn; |
Shashikanth VH | 3fe3798 | 2015-11-30 11:50:07 +0530 | [diff] [blame] | 353 | } |
Priyanka B | fc51c95 | 2016-03-26 14:30:33 +0530 | [diff] [blame] | 354 | |
| 355 | @Override |
| 356 | public void addLinkListener(BgpLinkListener listener) { |
| 357 | this.bgpLinkListener.add(listener); |
| 358 | } |
| 359 | |
| 360 | @Override |
| 361 | public void removeLinkListener(BgpLinkListener listener) { |
| 362 | this.bgpLinkListener.remove(listener); |
| 363 | } |
| 364 | |
| 365 | @Override |
| 366 | public Set<BgpLinkListener> linkListener() { |
| 367 | return bgpLinkListener; |
| 368 | } |
Shashikanth VH | 9f8afb4 | 2015-11-04 18:00:30 +0530 | [diff] [blame] | 369 | } |