- @Override
- protected void add(InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> identifier,
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface add) {
- LOG.trace("Operational Interface add event - {}", add);
- String interfaceName = add.getName();
- Interface intf = getInterface(interfaceName);
- if (intf != null && intf.getType().equals(Tunnel.class)) {
- BigInteger dpnId = interfaceManager.getDpnForInterface(interfaceName);
- if(add.getOperStatus().equals(OperStatus.Up)) {
- //Create ingress to LFIB
- LOG.debug("Installing Ingress for tunnel interface {}", interfaceName);
- makeTunnelIngressFlow(dpnId, interfaceName, NwConstants.ADD_FLOW);
- }
- } else {
- VpnInterface vpnInterface = getVpnInterface(interfaceName);
- if(vpnInterface != null) {
- if(add.getOperStatus().equals(OperStatus.Up)) {
- LOG.debug("Installing VPN related rules for interface {}", interfaceName);
- addInterface(VpnUtil.getVpnInterfaceIdentifier(vpnInterface.getName()), vpnInterface);
+ }
+
+ protected void addExtraRoute(String destination, String nextHop, String rd, String routerID, int label) {
+ if (rd != null) {
+ addPrefixToBGP(rd, destination, nextHop, label);
+ } else {
+ // ### add FIB route directly
+ addFibEntryToDS(routerID, destination, nextHop, label);
+ }
+ }
+
+ protected void delExtraRoute(String destination, String rd, String routerID) {
+ if (rd != null) {
+ removePrefixFromBGP(rd, destination);
+ } else {
+ // ### add FIB route directly
+ removeFibEntryFromDS(routerID, destination);
+ }
+ }
+
+ protected void updatePrefixesForDPN(BigInteger dpnId, UpdateRouteAction action) {
+
+ InstanceIdentifierBuilder<VpnInstances> idBuilder = InstanceIdentifier.builder(VpnInstances.class);
+ InstanceIdentifier<VpnInstances> vpnInstancesId = idBuilder.build();
+ Optional<VpnInstances> vpnInstances = VpnUtil.read(broker, LogicalDatastoreType.CONFIGURATION, vpnInstancesId);
+
+ if (vpnInstances.isPresent()) {
+ List<VpnInstance> vpnInstanceList = vpnInstances.get().getVpnInstance();
+ Iterator<VpnInstance> vpnInstIter = vpnInstanceList.iterator();
+ while (vpnInstIter.hasNext()) {
+ VpnInstance vpnInstance = vpnInstIter.next();
+ VpnAfConfig vpnConfig = vpnInstance.getIpv4Family();
+ String rd = vpnConfig.getRouteDistinguisher();
+
+ InstanceIdentifier<VpnToDpnList> id = VpnUtil.getVpnToDpnListIdentifier(rd, dpnId);
+ Optional<VpnToDpnList> dpnInVpn = VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL, id);
+ if (dpnInVpn.isPresent()) {
+ if (action == UpdateRouteAction.ADVERTISE_ROUTE) {
+ fibManager.populateFibOnNewDpn(dpnId, VpnUtil
+ .getVpnId(broker, vpnInstance.getVpnInstanceName()), rd);
+ }
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.vpn.instance.op.data
+ .vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces> vpnInterfaces = dpnInVpn.get().getVpnInterfaces();
+ for(org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.vpn.instance.op.data
+ .vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces vpnInterface : vpnInterfaces) {
+ InstanceIdentifier<VpnInterface> vpnIntfId = VpnUtil.getVpnInterfaceIdentifier(vpnInterface.getInterfaceName());
+ InstanceIdentifier<Adjacencies> path = vpnIntfId.augmentation(Adjacencies.class);
+ Optional<Adjacencies> adjacencies = VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL, path);
+
+ if (adjacencies.isPresent()) {
+ List<Adjacency> adjacencyList = adjacencies.get().getAdjacency();
+ Iterator<Adjacency> adjacencyIterator = adjacencyList.iterator();
+
+ while (adjacencyIterator.hasNext()) {
+ Adjacency adjacency = adjacencyIterator.next();
+ try {
+ if(action == UpdateRouteAction.ADVERTISE_ROUTE)
+ bgpManager.addPrefix(rd, adjacency.getIpAddress(), adjacency.getNextHopIp(), adjacency.getLabel().intValue());
+ else if(action == UpdateRouteAction.WITHDRAW_ROUTE)
+ bgpManager.deletePrefix(rd, adjacency.getIpAddress());
+ } catch (Exception e) {
+ LOG.error("Exception when updating prefix {} in vrf {} to BGP", adjacency.getIpAddress(), rd);
+ }
+ }
+ }
+
+ }
+ if (action == UpdateRouteAction.WITHDRAW_ROUTE) {
+ fibManager.cleanUpDpnForVpn(dpnId, VpnUtil
+ .getVpnId(broker, vpnInstance.getVpnInstanceName()), rd);