Committed by
Gerrit Code Review
[ONOS-2606] Bgp local RIB implementation.
Change-Id: I39eadec95fa1e1328c73efabb2a50bb438075809
Showing
7 changed files
with
152 additions
and
8 deletions
| ... | @@ -95,6 +95,20 @@ public interface BgpController { | ... | @@ -95,6 +95,20 @@ public interface BgpController { |
| 95 | int connectedPeerCount(); | 95 | int connectedPeerCount(); |
| 96 | 96 | ||
| 97 | /** | 97 | /** |
| 98 | + * Return BGP local RIB instance with VPN. | ||
| 99 | + * | ||
| 100 | + * @return BGPLocalRibImpl local RIB with VPN | ||
| 101 | + */ | ||
| 102 | + BgpLocalRib bgpLocalRibVpn(); | ||
| 103 | + | ||
| 104 | + /** | ||
| 105 | + * Return BGP local RIB instance. | ||
| 106 | + * | ||
| 107 | + * @return BGPLocalRibImpl local RIB | ||
| 108 | + */ | ||
| 109 | + BgpLocalRib bgpLocalRib(); | ||
| 110 | + | ||
| 111 | + /** | ||
| 98 | * Return BGP peer manager. | 112 | * Return BGP peer manager. |
| 99 | * | 113 | * |
| 100 | * @return BGPPeerManager peer manager instance | 114 | * @return BGPPeerManager peer manager instance | ... | ... |
| ... | @@ -440,7 +440,9 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -440,7 +440,9 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler { |
| 440 | // which we obviously don't want. | 440 | // which we obviously don't want. |
| 441 | log.debug("{}:removal called", getPeerInfoString()); | 441 | log.debug("{}:removal called", getPeerInfoString()); |
| 442 | if (bgpPeer != null) { | 442 | if (bgpPeer != null) { |
| 443 | + BgpPeerImpl peer = (BgpPeerImpl) bgpPeer; | ||
| 443 | peerManager.removeConnectedPeer(thisbgpId); | 444 | peerManager.removeConnectedPeer(thisbgpId); |
| 445 | + peer.updateLocalRIBOnPeerDisconnect(); | ||
| 444 | } | 446 | } |
| 445 | 447 | ||
| 446 | // Retry connection if connection is lost to bgp speaker/peer | 448 | // Retry connection if connection is lost to bgp speaker/peer | ... | ... |
| ... | @@ -21,8 +21,14 @@ import java.util.Set; | ... | @@ -21,8 +21,14 @@ import java.util.Set; |
| 21 | import java.util.TreeMap; | 21 | import java.util.TreeMap; |
| 22 | 22 | ||
| 23 | import org.onlab.packet.Ip4Address; | 23 | import org.onlab.packet.Ip4Address; |
| 24 | +import org.onlab.packet.IpAddress; | ||
| 24 | import org.onosproject.bgp.controller.BgpCfg; | 25 | import org.onosproject.bgp.controller.BgpCfg; |
| 26 | +import org.onosproject.bgp.controller.BgpConnectPeer; | ||
| 27 | +import org.onosproject.bgp.controller.BgpController; | ||
| 28 | +import org.onosproject.bgp.controller.BgpId; | ||
| 29 | +import org.onosproject.bgp.controller.BgpPeer; | ||
| 25 | import org.onosproject.bgp.controller.BgpPeerCfg; | 30 | import org.onosproject.bgp.controller.BgpPeerCfg; |
| 31 | +import org.onosproject.bgp.controller.impl.BgpControllerImpl.BgpPeerManagerImpl; | ||
| 26 | import org.slf4j.Logger; | 32 | import org.slf4j.Logger; |
| 27 | import org.slf4j.LoggerFactory; | 33 | import org.slf4j.LoggerFactory; |
| 28 | 34 | ||
| ... | @@ -48,12 +54,16 @@ public class BgpConfig implements BgpCfg { | ... | @@ -48,12 +54,16 @@ public class BgpConfig implements BgpCfg { |
| 48 | 54 | ||
| 49 | private Ip4Address routerId = null; | 55 | private Ip4Address routerId = null; |
| 50 | private TreeMap<String, BgpPeerCfg> bgpPeerTree = new TreeMap<>(); | 56 | private TreeMap<String, BgpPeerCfg> bgpPeerTree = new TreeMap<>(); |
| 57 | + private BgpConnectPeer connectPeer; | ||
| 58 | + private BgpPeerManagerImpl peerManager; | ||
| 59 | + private BgpController bgpController; | ||
| 51 | 60 | ||
| 52 | - /** | 61 | + /* |
| 53 | * Constructor to initialize the values. | 62 | * Constructor to initialize the values. |
| 54 | */ | 63 | */ |
| 55 | - public BgpConfig() { | 64 | + public BgpConfig(BgpController bgpController) { |
| 56 | - | 65 | + this.bgpController = bgpController; |
| 66 | + this.peerManager = (BgpPeerManagerImpl) bgpController.peerManager(); | ||
| 57 | this.holdTime = DEFAULT_HOLD_TIMER; | 67 | this.holdTime = DEFAULT_HOLD_TIMER; |
| 58 | this.maxConnRetryTime = DEFAULT_CONN_RETRY_TIME; | 68 | this.maxConnRetryTime = DEFAULT_CONN_RETRY_TIME; |
| 59 | this.maxConnRetryCount = DEFAULT_CONN_RETRY_COUNT; | 69 | this.maxConnRetryCount = DEFAULT_CONN_RETRY_COUNT; |
| ... | @@ -172,7 +182,12 @@ public class BgpConfig implements BgpCfg { | ... | @@ -172,7 +182,12 @@ public class BgpConfig implements BgpCfg { |
| 172 | 182 | ||
| 173 | if (lspeer != null) { | 183 | if (lspeer != null) { |
| 174 | lspeer.setSelfInnitConnection(true); | 184 | lspeer.setSelfInnitConnection(true); |
| 175 | - // TODO: initiate peer connection | 185 | + |
| 186 | + if (lspeer.connectPeer() == null) { | ||
| 187 | + connectPeer = new BgpConnectPeerImpl(bgpController, routerid, Controller.getBgpPortNum()); | ||
| 188 | + lspeer.setConnectPeer(connectPeer); | ||
| 189 | + connectPeer.connectPeer(); | ||
| 190 | + } | ||
| 176 | return true; | 191 | return true; |
| 177 | } | 192 | } |
| 178 | 193 | ||
| ... | @@ -185,7 +200,6 @@ public class BgpConfig implements BgpCfg { | ... | @@ -185,7 +200,6 @@ public class BgpConfig implements BgpCfg { |
| 185 | 200 | ||
| 186 | if (lspeer != null) { | 201 | if (lspeer != null) { |
| 187 | 202 | ||
| 188 | - //TODO DISCONNECT PEER | ||
| 189 | disconnectPeer(routerid); | 203 | disconnectPeer(routerid); |
| 190 | lspeer.setSelfInnitConnection(false); | 204 | lspeer.setSelfInnitConnection(false); |
| 191 | lspeer = this.bgpPeerTree.remove(routerid); | 205 | lspeer = this.bgpPeerTree.remove(routerid); |
| ... | @@ -204,7 +218,12 @@ public class BgpConfig implements BgpCfg { | ... | @@ -204,7 +218,12 @@ public class BgpConfig implements BgpCfg { |
| 204 | 218 | ||
| 205 | if (lspeer != null) { | 219 | if (lspeer != null) { |
| 206 | 220 | ||
| 207 | - //TODO DISCONNECT PEER | 221 | + BgpPeer disconnPeer = peerManager.getPeer(BgpId.bgpId(IpAddress.valueOf(routerid))); |
| 222 | + if (disconnPeer != null) { | ||
| 223 | + // TODO: send notification peer deconfigured | ||
| 224 | + disconnPeer.disconnectPeer(); | ||
| 225 | + } | ||
| 226 | + lspeer.connectPeer().disconnectPeer(); | ||
| 208 | lspeer.setState(BgpPeerCfg.State.IDLE); | 227 | lspeer.setState(BgpPeerCfg.State.IDLE); |
| 209 | lspeer.setSelfInnitConnection(false); | 228 | lspeer.setSelfInnitConnection(false); |
| 210 | log.debug("Disconnected : " + routerid + " successfully"); | 229 | log.debug("Disconnected : " + routerid + " successfully"); | ... | ... |
| ... | @@ -16,6 +16,8 @@ | ... | @@ -16,6 +16,8 @@ |
| 16 | 16 | ||
| 17 | package org.onosproject.bgp.controller.impl; | 17 | package org.onosproject.bgp.controller.impl; |
| 18 | 18 | ||
| 19 | +import java.util.Iterator; | ||
| 20 | +import java.util.List; | ||
| 19 | import java.util.Set; | 21 | import java.util.Set; |
| 20 | import java.util.concurrent.ConcurrentHashMap; | 22 | import java.util.concurrent.ConcurrentHashMap; |
| 21 | import java.util.concurrent.CopyOnWriteArraySet; | 23 | import java.util.concurrent.CopyOnWriteArraySet; |
| ... | @@ -29,11 +31,16 @@ import org.apache.felix.scr.annotations.Service; | ... | @@ -29,11 +31,16 @@ import org.apache.felix.scr.annotations.Service; |
| 29 | import org.onosproject.bgp.controller.BgpCfg; | 31 | import org.onosproject.bgp.controller.BgpCfg; |
| 30 | import org.onosproject.bgp.controller.BgpController; | 32 | import org.onosproject.bgp.controller.BgpController; |
| 31 | import org.onosproject.bgp.controller.BgpId; | 33 | import org.onosproject.bgp.controller.BgpId; |
| 34 | +import org.onosproject.bgp.controller.BgpLocalRib; | ||
| 32 | import org.onosproject.bgp.controller.BgpPeer; | 35 | import org.onosproject.bgp.controller.BgpPeer; |
| 33 | import org.onosproject.bgp.controller.BgpNodeListener; | 36 | import org.onosproject.bgp.controller.BgpNodeListener; |
| 34 | import org.onosproject.bgp.controller.BgpPeerManager; | 37 | import org.onosproject.bgp.controller.BgpPeerManager; |
| 35 | import org.onosproject.bgpio.exceptions.BgpParseException; | 38 | import org.onosproject.bgpio.exceptions.BgpParseException; |
| 36 | import org.onosproject.bgpio.protocol.BgpMessage; | 39 | import org.onosproject.bgpio.protocol.BgpMessage; |
| 40 | +import org.onosproject.bgpio.protocol.BgpUpdateMsg; | ||
| 41 | +import org.onosproject.bgpio.types.BgpValueType; | ||
| 42 | +import org.onosproject.bgpio.types.MpReachNlri; | ||
| 43 | +import org.onosproject.bgpio.types.MpUnReachNlri; | ||
| 37 | import org.slf4j.Logger; | 44 | import org.slf4j.Logger; |
| 38 | import org.slf4j.LoggerFactory; | 45 | import org.slf4j.LoggerFactory; |
| 39 | 46 | ||
| ... | @@ -47,11 +54,14 @@ public class BgpControllerImpl implements BgpController { | ... | @@ -47,11 +54,14 @@ public class BgpControllerImpl implements BgpController { |
| 47 | 54 | ||
| 48 | protected BgpPeerManagerImpl peerManager = new BgpPeerManagerImpl(); | 55 | protected BgpPeerManagerImpl peerManager = new BgpPeerManagerImpl(); |
| 49 | 56 | ||
| 57 | + private BgpLocalRib bgplocalRIB = new BgpLocalRibImpl(this); | ||
| 58 | + private BgpLocalRib bgplocalRIBVpn = new BgpLocalRibImpl(this); | ||
| 59 | + | ||
| 50 | protected Set<BgpNodeListener> bgpNodeListener = new CopyOnWriteArraySet<>(); | 60 | protected Set<BgpNodeListener> bgpNodeListener = new CopyOnWriteArraySet<>(); |
| 51 | 61 | ||
| 52 | final Controller ctrl = new Controller(this); | 62 | final Controller ctrl = new Controller(this); |
| 53 | 63 | ||
| 54 | - private BgpConfig bgpconfig = new BgpConfig(); | 64 | + private BgpConfig bgpconfig = new BgpConfig(this); |
| 55 | 65 | ||
| 56 | @Activate | 66 | @Activate |
| 57 | public void activate() { | 67 | public void activate() { |
| ... | @@ -100,6 +110,8 @@ public class BgpControllerImpl implements BgpController { | ... | @@ -100,6 +110,8 @@ public class BgpControllerImpl implements BgpController { |
| 100 | @Override | 110 | @Override |
| 101 | public void processBGPPacket(BgpId bgpId, BgpMessage msg) throws BgpParseException { | 111 | public void processBGPPacket(BgpId bgpId, BgpMessage msg) throws BgpParseException { |
| 102 | 112 | ||
| 113 | + BgpPeer peer = getPeer(bgpId); | ||
| 114 | + | ||
| 103 | switch (msg.getType()) { | 115 | switch (msg.getType()) { |
| 104 | case OPEN: | 116 | case OPEN: |
| 105 | // TODO: Process Open message | 117 | // TODO: Process Open message |
| ... | @@ -111,7 +123,23 @@ public class BgpControllerImpl implements BgpController { | ... | @@ -111,7 +123,23 @@ public class BgpControllerImpl implements BgpController { |
| 111 | // TODO: Process notificatoin message | 123 | // TODO: Process notificatoin message |
| 112 | break; | 124 | break; |
| 113 | case UPDATE: | 125 | case UPDATE: |
| 114 | - // TODO: Process update message | 126 | + BgpUpdateMsg updateMsg = (BgpUpdateMsg) msg; |
| 127 | + List<BgpValueType> pathAttr = updateMsg.bgpPathAttributes().pathAttributes(); | ||
| 128 | + if (pathAttr == null) { | ||
| 129 | + log.debug("llPathAttr is null, cannot process update message"); | ||
| 130 | + break; | ||
| 131 | + } | ||
| 132 | + Iterator<BgpValueType> listIterator = pathAttr.iterator(); | ||
| 133 | + boolean isLinkstate = false; | ||
| 134 | + while (listIterator.hasNext()) { | ||
| 135 | + BgpValueType attr = listIterator.next(); | ||
| 136 | + if ((attr instanceof MpReachNlri) || (attr instanceof MpUnReachNlri)) { | ||
| 137 | + isLinkstate = true; | ||
| 138 | + } | ||
| 139 | + } | ||
| 140 | + if (isLinkstate) { | ||
| 141 | + peer.buildAdjRibIn(pathAttr); | ||
| 142 | + } | ||
| 115 | break; | 143 | break; |
| 116 | default: | 144 | default: |
| 117 | // TODO: Process other message | 145 | // TODO: Process other message |
| ... | @@ -215,4 +243,24 @@ public class BgpControllerImpl implements BgpController { | ... | @@ -215,4 +243,24 @@ public class BgpControllerImpl implements BgpController { |
| 215 | public int connectedPeerCount() { | 243 | public int connectedPeerCount() { |
| 216 | return connectedPeers.size(); | 244 | return connectedPeers.size(); |
| 217 | } | 245 | } |
| 246 | + | ||
| 247 | + /** | ||
| 248 | + * Gets the BGP local RIB. | ||
| 249 | + * | ||
| 250 | + * @return bgplocalRIB BGP local RIB. | ||
| 251 | + */ | ||
| 252 | + @Override | ||
| 253 | + public BgpLocalRib bgpLocalRib() { | ||
| 254 | + return bgplocalRIB; | ||
| 255 | + } | ||
| 256 | + | ||
| 257 | + /** | ||
| 258 | + * Gets the BGP local RIB with VPN. | ||
| 259 | + * | ||
| 260 | + * @return bgplocalRIBVpn BGP VPN local RIB . | ||
| 261 | + */ | ||
| 262 | + @Override | ||
| 263 | + public BgpLocalRib bgpLocalRibVpn() { | ||
| 264 | + return bgplocalRIBVpn; | ||
| 265 | + } | ||
| 218 | } | 266 | } | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -28,6 +28,7 @@ import org.onlab.packet.IpAddress; | ... | @@ -28,6 +28,7 @@ import org.onlab.packet.IpAddress; |
| 28 | import org.onosproject.bgp.controller.BgpController; | 28 | import org.onosproject.bgp.controller.BgpController; |
| 29 | import org.onosproject.bgp.controller.BgpPeer; | 29 | import org.onosproject.bgp.controller.BgpPeer; |
| 30 | import org.onosproject.bgp.controller.BgpSessionInfo; | 30 | import org.onosproject.bgp.controller.BgpSessionInfo; |
| 31 | +import org.onosproject.bgp.controller.BgpLocalRib; | ||
| 31 | import org.onosproject.bgpio.exceptions.BgpParseException; | 32 | import org.onosproject.bgpio.exceptions.BgpParseException; |
| 32 | import org.onosproject.bgpio.protocol.BgpFactories; | 33 | import org.onosproject.bgpio.protocol.BgpFactories; |
| 33 | import org.onosproject.bgpio.protocol.BgpFactory; | 34 | import org.onosproject.bgpio.protocol.BgpFactory; |
| ... | @@ -61,9 +62,28 @@ public class BgpPeerImpl implements BgpPeer { | ... | @@ -61,9 +62,28 @@ public class BgpPeerImpl implements BgpPeer { |
| 61 | protected boolean isHandShakeComplete = false; | 62 | protected boolean isHandShakeComplete = false; |
| 62 | private BgpSessionInfo sessionInfo; | 63 | private BgpSessionInfo sessionInfo; |
| 63 | private BgpPacketStatsImpl pktStats; | 64 | private BgpPacketStatsImpl pktStats; |
| 65 | + private BgpLocalRib bgplocalRIB; | ||
| 66 | + private BgpLocalRib bgplocalRIBVpn; | ||
| 64 | private AdjRibIn adjRib; | 67 | private AdjRibIn adjRib; |
| 65 | private VpnAdjRibIn vpnAdjRib; | 68 | private VpnAdjRibIn vpnAdjRib; |
| 66 | 69 | ||
| 70 | + /** | ||
| 71 | + * Return the adjacency RIB-IN. | ||
| 72 | + * | ||
| 73 | + * @return adjRib the adjacency RIB-IN | ||
| 74 | + */ | ||
| 75 | + public AdjRibIn adjacencyRib() { | ||
| 76 | + return adjRib; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + /** | ||
| 80 | + * Return the adjacency RIB-IN with VPN. | ||
| 81 | + * | ||
| 82 | + * @return vpnAdjRib the adjacency RIB-IN with VPN | ||
| 83 | + */ | ||
| 84 | + public VpnAdjRibIn vpnAdjacencyRib() { | ||
| 85 | + return vpnAdjRib; | ||
| 86 | + } | ||
| 67 | 87 | ||
| 68 | @Override | 88 | @Override |
| 69 | public BgpSessionInfo sessionInfo() { | 89 | public BgpSessionInfo sessionInfo() { |
| ... | @@ -81,6 +101,8 @@ public class BgpPeerImpl implements BgpPeer { | ... | @@ -81,6 +101,8 @@ public class BgpPeerImpl implements BgpPeer { |
| 81 | this.bgpController = bgpController; | 101 | this.bgpController = bgpController; |
| 82 | this.sessionInfo = sessionInfo; | 102 | this.sessionInfo = sessionInfo; |
| 83 | this.pktStats = pktStats; | 103 | this.pktStats = pktStats; |
| 104 | + this.bgplocalRIB = bgpController.bgpLocalRib(); | ||
| 105 | + this.bgplocalRIBVpn = bgpController.bgpLocalRibVpn(); | ||
| 84 | this.adjRib = new AdjRibIn(); | 106 | this.adjRib = new AdjRibIn(); |
| 85 | this.vpnAdjRib = new VpnAdjRibIn(); | 107 | this.vpnAdjRib = new VpnAdjRibIn(); |
| 86 | } | 108 | } |
| ... | @@ -119,22 +141,31 @@ public class BgpPeerImpl implements BgpPeer { | ... | @@ -119,22 +141,31 @@ public class BgpPeerImpl implements BgpPeer { |
| 119 | PathAttrNlriDetails details = setPathAttrDetails(nlriInfo, pathAttr); | 141 | PathAttrNlriDetails details = setPathAttrDetails(nlriInfo, pathAttr); |
| 120 | if (!((BgpNodeLSNlriVer4) nlriInfo).isVpnPresent()) { | 142 | if (!((BgpNodeLSNlriVer4) nlriInfo).isVpnPresent()) { |
| 121 | adjRib.add(nlriInfo, details); | 143 | adjRib.add(nlriInfo, details); |
| 144 | + bgplocalRIB.add(sessionInfo(), nlriInfo, details); | ||
| 122 | } else { | 145 | } else { |
| 123 | vpnAdjRib.addVpn(nlriInfo, details, ((BgpNodeLSNlriVer4) nlriInfo).getRouteDistinguisher()); | 146 | vpnAdjRib.addVpn(nlriInfo, details, ((BgpNodeLSNlriVer4) nlriInfo).getRouteDistinguisher()); |
| 147 | + bgplocalRIBVpn.add(sessionInfo(), nlriInfo, details, | ||
| 148 | + ((BgpNodeLSNlriVer4) nlriInfo).getRouteDistinguisher()); | ||
| 124 | } | 149 | } |
| 125 | } else if (nlriInfo instanceof BgpLinkLsNlriVer4) { | 150 | } else if (nlriInfo instanceof BgpLinkLsNlriVer4) { |
| 126 | PathAttrNlriDetails details = setPathAttrDetails(nlriInfo, pathAttr); | 151 | PathAttrNlriDetails details = setPathAttrDetails(nlriInfo, pathAttr); |
| 127 | if (!((BgpLinkLsNlriVer4) nlriInfo).isVpnPresent()) { | 152 | if (!((BgpLinkLsNlriVer4) nlriInfo).isVpnPresent()) { |
| 128 | adjRib.add(nlriInfo, details); | 153 | adjRib.add(nlriInfo, details); |
| 154 | + bgplocalRIB.add(sessionInfo(), nlriInfo, details); | ||
| 129 | } else { | 155 | } else { |
| 130 | vpnAdjRib.addVpn(nlriInfo, details, ((BgpLinkLsNlriVer4) nlriInfo).getRouteDistinguisher()); | 156 | vpnAdjRib.addVpn(nlriInfo, details, ((BgpLinkLsNlriVer4) nlriInfo).getRouteDistinguisher()); |
| 157 | + bgplocalRIBVpn.add(sessionInfo(), nlriInfo, details, | ||
| 158 | + ((BgpLinkLsNlriVer4) nlriInfo).getRouteDistinguisher()); | ||
| 131 | } | 159 | } |
| 132 | } else if (nlriInfo instanceof BgpPrefixIPv4LSNlriVer4) { | 160 | } else if (nlriInfo instanceof BgpPrefixIPv4LSNlriVer4) { |
| 133 | PathAttrNlriDetails details = setPathAttrDetails(nlriInfo, pathAttr); | 161 | PathAttrNlriDetails details = setPathAttrDetails(nlriInfo, pathAttr); |
| 134 | if (!((BgpPrefixIPv4LSNlriVer4) nlriInfo).isVpnPresent()) { | 162 | if (!((BgpPrefixIPv4LSNlriVer4) nlriInfo).isVpnPresent()) { |
| 135 | adjRib.add(nlriInfo, details); | 163 | adjRib.add(nlriInfo, details); |
| 164 | + bgplocalRIB.add(sessionInfo(), nlriInfo, details); | ||
| 136 | } else { | 165 | } else { |
| 137 | vpnAdjRib.addVpn(nlriInfo, details, ((BgpPrefixIPv4LSNlriVer4) nlriInfo).getRouteDistinguisher()); | 166 | vpnAdjRib.addVpn(nlriInfo, details, ((BgpPrefixIPv4LSNlriVer4) nlriInfo).getRouteDistinguisher()); |
| 167 | + bgplocalRIBVpn.add(sessionInfo(), nlriInfo, details, | ||
| 168 | + ((BgpPrefixIPv4LSNlriVer4) nlriInfo).getRouteDistinguisher()); | ||
| 138 | } | 169 | } |
| 139 | } | 170 | } |
| 140 | } | 171 | } |
| ... | @@ -170,20 +201,26 @@ public class BgpPeerImpl implements BgpPeer { | ... | @@ -170,20 +201,26 @@ public class BgpPeerImpl implements BgpPeer { |
| 170 | if (nlriInfo instanceof BgpNodeLSNlriVer4) { | 201 | if (nlriInfo instanceof BgpNodeLSNlriVer4) { |
| 171 | if (!((BgpNodeLSNlriVer4) nlriInfo).isVpnPresent()) { | 202 | if (!((BgpNodeLSNlriVer4) nlriInfo).isVpnPresent()) { |
| 172 | adjRib.remove(nlriInfo); | 203 | adjRib.remove(nlriInfo); |
| 204 | + bgplocalRIB.delete(nlriInfo); | ||
| 173 | } else { | 205 | } else { |
| 174 | vpnAdjRib.removeVpn(nlriInfo, ((BgpNodeLSNlriVer4) nlriInfo).getRouteDistinguisher()); | 206 | vpnAdjRib.removeVpn(nlriInfo, ((BgpNodeLSNlriVer4) nlriInfo).getRouteDistinguisher()); |
| 207 | + bgplocalRIBVpn.delete(nlriInfo, ((BgpNodeLSNlriVer4) nlriInfo).getRouteDistinguisher()); | ||
| 175 | } | 208 | } |
| 176 | } else if (nlriInfo instanceof BgpLinkLsNlriVer4) { | 209 | } else if (nlriInfo instanceof BgpLinkLsNlriVer4) { |
| 177 | if (!((BgpLinkLsNlriVer4) nlriInfo).isVpnPresent()) { | 210 | if (!((BgpLinkLsNlriVer4) nlriInfo).isVpnPresent()) { |
| 178 | adjRib.remove(nlriInfo); | 211 | adjRib.remove(nlriInfo); |
| 212 | + bgplocalRIB.delete(nlriInfo); | ||
| 179 | } else { | 213 | } else { |
| 180 | vpnAdjRib.removeVpn(nlriInfo, ((BgpLinkLsNlriVer4) nlriInfo).getRouteDistinguisher()); | 214 | vpnAdjRib.removeVpn(nlriInfo, ((BgpLinkLsNlriVer4) nlriInfo).getRouteDistinguisher()); |
| 215 | + bgplocalRIBVpn.delete(nlriInfo, ((BgpLinkLsNlriVer4) nlriInfo).getRouteDistinguisher()); | ||
| 181 | } | 216 | } |
| 182 | } else if (nlriInfo instanceof BgpPrefixIPv4LSNlriVer4) { | 217 | } else if (nlriInfo instanceof BgpPrefixIPv4LSNlriVer4) { |
| 183 | if (!((BgpPrefixIPv4LSNlriVer4) nlriInfo).isVpnPresent()) { | 218 | if (!((BgpPrefixIPv4LSNlriVer4) nlriInfo).isVpnPresent()) { |
| 184 | adjRib.remove(nlriInfo); | 219 | adjRib.remove(nlriInfo); |
| 220 | + bgplocalRIB.delete(nlriInfo); | ||
| 185 | } else { | 221 | } else { |
| 186 | vpnAdjRib.removeVpn(nlriInfo, ((BgpPrefixIPv4LSNlriVer4) nlriInfo).getRouteDistinguisher()); | 222 | vpnAdjRib.removeVpn(nlriInfo, ((BgpPrefixIPv4LSNlriVer4) nlriInfo).getRouteDistinguisher()); |
| 223 | + bgplocalRIBVpn.delete(nlriInfo, ((BgpPrefixIPv4LSNlriVer4) nlriInfo).getRouteDistinguisher()); | ||
| 187 | } | 224 | } |
| 188 | } | 225 | } |
| 189 | } | 226 | } |
| ... | @@ -207,6 +244,18 @@ public class BgpPeerImpl implements BgpPeer { | ... | @@ -207,6 +244,18 @@ public class BgpPeerImpl implements BgpPeer { |
| 207 | return vpnAdjRib; | 244 | return vpnAdjRib; |
| 208 | } | 245 | } |
| 209 | 246 | ||
| 247 | + /** | ||
| 248 | + * Update localRIB on peer disconnect. | ||
| 249 | + * | ||
| 250 | + */ | ||
| 251 | + public void updateLocalRIBOnPeerDisconnect() { | ||
| 252 | + BgpLocalRibImpl localRib = (BgpLocalRibImpl) bgplocalRIB; | ||
| 253 | + BgpLocalRibImpl localRibVpn = (BgpLocalRibImpl) bgplocalRIBVpn; | ||
| 254 | + | ||
| 255 | + localRib.localRIBUpdate(adjacencyRib()); | ||
| 256 | + localRibVpn.localRIBUpdate(vpnAdjacencyRib()); | ||
| 257 | + } | ||
| 258 | + | ||
| 210 | // ************************ | 259 | // ************************ |
| 211 | // Channel related | 260 | // Channel related |
| 212 | // ************************ | 261 | // ************************ | ... | ... |
| ... | @@ -31,6 +31,7 @@ import org.onosproject.bgp.controller.BgpCfg; | ... | @@ -31,6 +31,7 @@ import org.onosproject.bgp.controller.BgpCfg; |
| 31 | import org.onosproject.bgp.controller.BgpController; | 31 | import org.onosproject.bgp.controller.BgpController; |
| 32 | import org.onosproject.bgp.controller.BgpId; | 32 | import org.onosproject.bgp.controller.BgpId; |
| 33 | import org.onosproject.bgp.controller.BgpPeer; | 33 | import org.onosproject.bgp.controller.BgpPeer; |
| 34 | +import org.onosproject.bgp.controller.BgpLocalRib; | ||
| 34 | import org.onosproject.bgp.controller.BgpNodeListener; | 35 | import org.onosproject.bgp.controller.BgpNodeListener; |
| 35 | import org.onosproject.bgp.controller.BgpPeerManager; | 36 | import org.onosproject.bgp.controller.BgpPeerManager; |
| 36 | import org.onosproject.bgpio.exceptions.BgpParseException; | 37 | import org.onosproject.bgpio.exceptions.BgpParseException; |
| ... | @@ -208,6 +209,17 @@ public class BgpTopologyProviderTest { | ... | @@ -208,6 +209,17 @@ public class BgpTopologyProviderTest { |
| 208 | return 0; | 209 | return 0; |
| 209 | } | 210 | } |
| 210 | 211 | ||
| 212 | + @Override | ||
| 213 | + public BgpLocalRib bgpLocalRibVpn() { | ||
| 214 | + // TODO Auto-generated method stub | ||
| 215 | + return null; | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + @Override | ||
| 219 | + public BgpLocalRib bgpLocalRib() { | ||
| 220 | + // TODO Auto-generated method stub | ||
| 221 | + return null; | ||
| 222 | + } | ||
| 211 | 223 | ||
| 212 | @Override | 224 | @Override |
| 213 | public BgpPeerManager peerManager() { | 225 | public BgpPeerManager peerManager() { | ... | ... |
-
Please register or login to post a comment