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