int actionKey = 0;
listAction.add((new ActionInfo(ActionType.set_field_tunnel_id, new BigInteger[] {BigInteger.valueOf(interfaceInfo.getInterfaceTag())}, actionKey)).buildAction());
actionKey++;
- listAction.add((new ActionInfo(ActionType.nx_resubmit, new BigInteger[] {BigInteger.valueOf(55)}, actionKey)).buildAction());
+ listAction.add((new ActionInfo(ActionType.nx_resubmit, new String[] {Short.toString((short)55)}, actionKey)).buildAction());
return listAction;
}
import org.opendaylight.vpnservice.mdsalutil.MetaDataUtil;
import org.opendaylight.vpnservice.mdsalutil.NwConstants;
import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.OpState;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.PrefixToInterface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.VpnInstanceOpData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.VpnToExtraroute;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetTunnelTypeOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.OdlInterfaceRpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.l3nexthop.rev150409.l3nexthop.vpnnexthops.VpnNexthop;
-import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.Adjacencies;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.adjacency.list.Adjacency;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
if(localNextHopInfo != null) {
localDpnId = localNextHopInfo.getDpnId();
Prefixes prefix = getPrefixToInterface(vpnId, isExtraRoute ? localNextHopIP : vrfEntry.getDestPrefix());
- Optional<OpState> opStateData = FibUtil.read(broker, LogicalDatastoreType.OPERATIONAL,
- FibUtil.getVpnInterfaceOpStateIdentifier(prefix.getVpnInterfaceName()));
- if(opStateData.isPresent() && !opStateData.get().isStateUp())
- {
makeConnectedRoute(localDpnId, vpnId, vrfEntry, rd, null /* invalid */,
NwConstants.DEL_FLOW);
makeLFibTableEntry(localDpnId, vrfEntry.getLabel(), 0 /* invalid */,
vrfEntry.getNextHopAddress(), NwConstants.DEL_FLOW);
removeTunnelTableEntry(localDpnId, vrfEntry.getLabel());
deleteLocalAdjacency(localDpnId, vpnId, localNextHopIP);
- }
}
return localDpnId;
}
if (vpnInterfaces.remove(currVpnInterface)) {
if (vpnInterfaces.isEmpty()) {
- //FibUtil.delete(broker, LogicalDatastoreType.OPERATIONAL, id);
- LOG.trace("cleanUpOpDataForFib: cleanUpDpnForVpn: {}, {}", dpnId, vpnId);
- cleanUpDpnForVpn(dpnId, vpnId, rd);
+ LOG.trace("Last vpn interface {} on dpn {} for vpn {}. Clean up fib in dpn", intfName, dpnId, rd);
+ FibUtil.delete(broker, LogicalDatastoreType.OPERATIONAL, id);
+ cleanUpDpnForVpn(dpnId, vpnId, rd);
} else {
- LOG.trace("cleanUpOpDataForFib: delete interface: {} on {}", intfName, dpnId);
+ LOG.trace("Delete vpn interface {} from dpn {} to vpn {} list.", intfName, dpnId, rd);
FibUtil.delete(broker, LogicalDatastoreType.OPERATIONAL, id.child(
org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.vpn.instance.op.data
.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces.class,
if (prefixInfo == null)
return; //Don't have any info for this prefix (shouldn't happen); need to return
String ifName = prefixInfo.getVpnInterfaceName();
- Optional<OpState> opStateData = FibUtil.read(broker, LogicalDatastoreType.OPERATIONAL,
- FibUtil.getVpnInterfaceOpStateIdentifier(ifName));
- if(opStateData.isPresent() && !opStateData.get().isStateUp()) {
- Optional<Adjacencies>
- optAdjacencies =
- FibUtil.read(broker, LogicalDatastoreType.OPERATIONAL, FibUtil.getAdjListPath(ifName));
- int numAdj = 0;
- if (optAdjacencies.isPresent()) {
+ Optional<Adjacencies> optAdjacencies = FibUtil.read(broker, LogicalDatastoreType.OPERATIONAL, FibUtil.getAdjListPath(ifName));
+ int numAdj = 0;
+ if (optAdjacencies.isPresent()) {
numAdj = optAdjacencies.get().getAdjacency().size();
- }
- LOG.trace("cleanUpOpDataForFib: remove adjacency for prefix: {} {}", vpnId,
- vrfEntry.getDestPrefix());
- //remove adjacency corr to prefix
+ }
+ LOG.trace("cleanUpOpDataForFib: remove adjacency for prefix: {} {}", vpnId, vrfEntry.getDestPrefix());
+ //remove adjacency corr to prefix
+ if (numAdj > 1) {
FibUtil.delete(broker, LogicalDatastoreType.OPERATIONAL,
- FibUtil.getAdjacencyIdentifier(ifName, vrfEntry.getDestPrefix()));
+ FibUtil.getAdjacencyIdentifier(ifName, vrfEntry.getDestPrefix()));
+ }
- if ((numAdj - 1) == 0) { //there are no adjacencies left for this vpn interface, clean up
+ if ((numAdj - 1) == 0) { //there are no adjacencies left for this vpn interface, clean up
//clean up the vpn interface from DpnToVpn list
- delIntfFromDpnToVpnList(vpnId, prefixInfo.getDpnId(), ifName, rd);
- LOG.trace("cleanUpOpDataForFib: Delete prefix to interface and vpnInterface ");
- FibUtil.delete(broker, LogicalDatastoreType.OPERATIONAL,
- FibUtil.getPrefixToInterfaceIdentifier(
- vpnId,
- (extra_route) ? vrfEntry.getNextHopAddress() + "/32"
- : vrfEntry.getDestPrefix()));
+ LOG.trace("Clean up vpn interface {} from dpn {} to vpn {} list.", ifName, prefixInfo.getDpnId(), rd);
FibUtil.delete(broker, LogicalDatastoreType.OPERATIONAL,
FibUtil.getVpnInterfaceIdentifier(ifName));
- }
- }
+ }
}
private void deleteFibEntries(final InstanceIdentifier<VrfEntry> identifier,
localNextHopInfo = nextHopManager.getVpnNexthop(vpnId, extra_route.getNexthopIp());
}
}
- isRemoteRoute = ((localNextHopInfo != null) && (!remoteDpnId.equals(localNextHopInfo.getDpnId())));
+ if (localNextHopInfo != null) {
+ isRemoteRoute = (!remoteDpnId.equals(localNextHopInfo.getDpnId()));
+ }
}
if (isRemoteRoute) {
makeConnectedRoute(remoteDpnId, vpnId, vrfEntry, rd, null, NwConstants.DEL_FLOW);
public void populateFibOnNewDpn(BigInteger dpnId, long vpnId, String rd) {
LOG.trace("New dpn {} for vpn {} : populateFibOnNewDpn", dpnId, rd);
InstanceIdentifier<VrfTables> id = buildVrfId(rd);
- Optional<VrfTables> vrfTable = FibUtil.read(broker, LogicalDatastoreType.CONFIGURATION, id);
- if(vrfTable.isPresent()) {
- for(VrfEntry vrfEntry : vrfTable.get().getVrfEntry()) {
- // Passing null as we don't know the dpn
- // to which prefix is attached at this point
- createRemoteFibEntry(null, dpnId, vpnId, vrfTable.get().getKey(), vrfEntry);
+ String lockOnDpnVpn = new String(dpnId.toString()+ vpnId);
+ synchronized (lockOnDpnVpn.intern()) {
+ Optional<VrfTables> vrfTable = FibUtil.read(broker, LogicalDatastoreType.CONFIGURATION, id);
+ if (vrfTable.isPresent()) {
+ for (VrfEntry vrfEntry : vrfTable.get().getVrfEntry()) {
+ // Passing null as we don't know the dpn
+ // to which prefix is attached at this point
+ createRemoteFibEntry(null, dpnId, vpnId, vrfTable.get().getKey(), vrfEntry);
+ }
+ }
+ }
+ }
+
+ public void populateFibOnDpn(BigInteger dpnId, long vpnId, String rd, String nexthopIp) {
+ LOG.trace("dpn {} for vpn {}, nexthopIp {} : populateFibOnDpn", dpnId, rd, nexthopIp);
+ InstanceIdentifier<VrfTables> id = buildVrfId(rd);
+ String lockOnDpnVpn = new String(dpnId.toString()+ vpnId);
+ synchronized (lockOnDpnVpn.intern()) {
+ Optional<VrfTables> vrfTable = FibUtil.read(broker, LogicalDatastoreType.CONFIGURATION, id);
+ if (vrfTable.isPresent()) {
+ for (VrfEntry vrfEntry : vrfTable.get().getVrfEntry()) {
+ // Passing null as we don't know the dpn
+ // to which prefix is attached at this point
+ if (nexthopIp == vrfEntry.getNextHopAddress()) {
+ createRemoteFibEntry(null, dpnId, vpnId, vrfTable.get().getKey(), vrfEntry);
+ }
+ }
}
}
}
public void cleanUpDpnForVpn(BigInteger dpnId, long vpnId, String rd) {
LOG.trace("Remove dpn {} for vpn {} : cleanUpDpnForVpn", dpnId, rd);
InstanceIdentifier<VrfTables> id = buildVrfId(rd);
- Optional<VrfTables> vrfTable = FibUtil.read(broker, LogicalDatastoreType.CONFIGURATION, id);
- if(vrfTable.isPresent()) {
- for(VrfEntry vrfEntry : vrfTable.get().getVrfEntry()) {
- // Passing null as we don't know the dpn
- // to which prefix is attached at this point
- deleteRemoteRoute(null, dpnId, vpnId, vrfTable.get().getKey(), vrfEntry);
+ String lockOnDpnVpn = new String(dpnId.toString()+ vpnId);
+ synchronized (lockOnDpnVpn.intern()) {
+ Optional<VrfTables> vrfTable = FibUtil.read(broker, LogicalDatastoreType.CONFIGURATION, id);
+ if (vrfTable.isPresent()) {
+ for (VrfEntry vrfEntry : vrfTable.get().getVrfEntry()) {
+ // Passing null as we don't know the dpn
+ // to which prefix is attached at this point
+ deleteRemoteRoute(null, dpnId, vpnId, vrfTable.get().getKey(), vrfEntry);
+ }
+ }
+ }
+ }
+
+ public void cleanUpDpnForVpn(BigInteger dpnId, long vpnId, String rd, String nexthopIp) {
+ LOG.trace("dpn {} for vpn {}, nexthopIp {} : cleanUpDpnForVpn", dpnId, rd, nexthopIp);
+ InstanceIdentifier<VrfTables> id = buildVrfId(rd);
+ String lockOnDpnVpn = new String(dpnId.toString()+ vpnId);
+ synchronized (lockOnDpnVpn.intern()) {
+ Optional<VrfTables> vrfTable = FibUtil.read(broker, LogicalDatastoreType.CONFIGURATION, id);
+ if (vrfTable.isPresent()) {
+ for (VrfEntry vrfEntry : vrfTable.get().getVrfEntry()) {
+ // Passing null as we don't know the dpn
+ // to which prefix is attached at this point
+ if (nexthopIp == vrfEntry.getNextHopAddress()) {
+ deleteRemoteRoute(null, dpnId, vpnId, vrfTable.get().getKey(), vrfEntry);
+ }
+ }
}
}
}
instructions.add(new InstructionInfo(InstructionType.clear_actions));
// Instruction to goto L3 InterfaceTable
- instructions.add(new InstructionInfo(InstructionType.goto_table, new long[] { NwConstants.LPORT_DISPATCHER_TABLE }));
+ List <ActionInfo> actionsInfos = new ArrayList <ActionInfo> ();
+ actionsInfos.add(new ActionInfo(ActionType.nx_resubmit, new String[]{
+ Short.toString(NwConstants.LPORT_DISPATCHER_TABLE)}));
+ instructions.add(new InstructionInfo(InstructionType.apply_actions, actionsInfos));
+ //instructions.add(new InstructionInfo(InstructionType.goto_table, new long[] { NwConstants.LPORT_DISPATCHER_TABLE }));
FlowEntity flowEntityL3Intf = MDSALUtil.buildFlowEntity(dpnId, NwConstants.L3_INTERFACE_TABLE,
getFlowRef(dpnId, NwConstants.L3_INTERFACE_TABLE, NwConstants.TABLE_MISS_FLOW),
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.Adjacencies;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.OpState;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.adjacency.list.Adjacency;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList;
.child(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface.class, new org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceKey(vpnInterfaceName)).build();
}
- static InstanceIdentifier<OpState> getVpnInterfaceOpStateIdentifier(String vpnInterfaceName) {
- return InstanceIdentifier.builder(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.VpnInterfaces.class)
- .child(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface.class,
- new org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceKey(vpnInterfaceName))
- .augmentation(OpState.class).build();
- }
-
static InstanceIdentifier<VpnToDpnList> getVpnToDpnListIdentifier(String rd, BigInteger dpnId) {
return InstanceIdentifier.builder(org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.VpnInstanceOpData.class)
.child(org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey(rd))
@Override
public Action buildAction(ActionInfo actionInfo) {
+ String[] actionValues = actionInfo.getActionValues();
NxResubmitBuilder nxarsb = new NxResubmitBuilder();
- nxarsb.setTable((short) 55);
+ nxarsb.setTable(Short.parseShort(actionValues[0]));
ActionBuilder ab = new ActionBuilder();
ab.setAction(new NxActionResubmitRpcAddGroupCaseBuilder().setNxResubmit(nxarsb.build()).build());
ab.setKey(new ActionKey(actionInfo.getActionKey()));
if (configInterface != null && configInterface.getType().equals(Tunnel.class)) {
if(intrf.getOperStatus().equals(Interface.OperStatus.Up)) {
//advertise all prefixes in all vpns for this dpn to bgp
- vpnInterfaceManager.updatePrefixesForDPN(dpnId, VpnInterfaceManager.UpdateRouteAction.ADVERTISE_ROUTE);
+ // FIXME: Blocked until tunnel event[vxlan/gre] support is available
+ // vpnInterfaceManager.updatePrefixesForDPN(dpnId, VpnInterfaceManager.UpdateRouteAction.ADVERTISE_ROUTE);
}
} else {
vpnInterfaceManager.processVpnInterfaceUp(dpnId, interfaceName, intrf.getIfIndex());
BigInteger dpId = InterfaceUtils.getDpIdFromInterface(intrf);
if (intrf != null && intrf.getType() != null && intrf.getType().equals(Tunnel.class)) {
//withdraw all prefixes in all vpns for this dpn from bgp
- vpnInterfaceManager.updatePrefixesForDPN(dpId, VpnInterfaceManager.UpdateRouteAction.WITHDRAW_ROUTE);
+ // FIXME: Blocked until tunnel event[vxlan/gre] support is available
+ // vpnInterfaceManager.updatePrefixesForDPN(dpId, VpnInterfaceManager.UpdateRouteAction.WITHDRAW_ROUTE);
} else {
if (VpnUtil.isVpnInterfaceConfigured(broker, interfaceName)) {
vpnInterfaceManager.processVpnInterfaceDown(dpId, interfaceName, intrf.getIfIndex(), true);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface
intf = InterfaceUtils.getInterface(broker, interfaceName);
if (intf != null && intf.getType().equals(Tunnel.class)) {
+ /*
+ // FIXME: Blocked until tunnel event[vxlan/gre] support is available
BigInteger dpnId = InterfaceUtils.getDpIdFromInterface(update);
if(update.getOperStatus().equals(Interface.OperStatus.Up)) {
//advertise all prefixes in all vpns for this dpn to bgp
- vpnInterfaceManager.updatePrefixesForDPN(dpnId, VpnInterfaceManager.UpdateRouteAction.ADVERTISE_ROUTE);
+ // vpnInterfaceManager.updatePrefixesForDPN(dpnId, VpnInterfaceManager.UpdateRouteAction.ADVERTISE_ROUTE);
} else if(update.getOperStatus().equals(Interface.OperStatus.Down)) {
//withdraw all prefixes in all vpns for this dpn from bgp
- vpnInterfaceManager.updatePrefixesForDPN(dpnId, VpnInterfaceManager.UpdateRouteAction.WITHDRAW_ROUTE);
- }
+ // vpnInterfaceManager.updatePrefixesForDPN(dpnId, VpnInterfaceManager.UpdateRouteAction.WITHDRAW_ROUTE);
+ }*/
}
}
import org.opendaylight.vpnservice.mdsalutil.*;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.OpState;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.OpStateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.PrefixToInterface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.adjacency.list.AdjacencyKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListBuilder;
return;
}
bindService(dpId, vpnName, interfaceName, lPortTag);
- updateDpnDbs(vpnName, interfaceName, true);
- processVpnInterfaceAdjacencies(VpnUtil.getVpnInterfaceIdentifier(vpnInterface.getName()), vpnInterface, true);
+ updateDpnDbs(dpId, vpnName, interfaceName, true);
+ processVpnInterfaceAdjacencies(dpId, VpnUtil.getVpnInterfaceIdentifier(vpnInterface.getName()), vpnInterface);
}
}
- private void updateDpnDbs(String vpnName, String interfaceName, boolean add) {
+ private void updateDpnDbs(BigInteger dpId, String vpnName, String interfaceName, boolean add) {
long vpnId = VpnUtil.getVpnId(broker, vpnName);
- BigInteger dpId = InterfaceUtils.getDpnForInterface(interfaceManager, interfaceName);
+ if (dpId == null) {
+ dpId = InterfaceUtils.getDpnForInterface(interfaceManager, interfaceName);
+ }
if(!dpId.equals(BigInteger.ZERO)) {
if(add)
updateMappingDbs(vpnId, dpId, interfaceName, vpnName);
}
- private void processVpnInterfaceAdjacencies(final InstanceIdentifier<VpnInterface> identifier, VpnInterface intf,
- boolean vpnInterfaceState) {
+ private void processVpnInterfaceAdjacencies(BigInteger dpnId, final InstanceIdentifier<VpnInterface> identifier, VpnInterface intf) {
String intfName = intf.getName();
synchronized (intfName) {
// Get the rd of the vpn instance
String rd = getRouteDistinguisher(intf.getVpnInstanceName());
- BigInteger dpnId = InterfaceUtils.getDpnForInterface(interfaceManager, intfName);
String nextHopIp = InterfaceUtils.getEndpointIpAddressForDPN(broker, dpnId);
if (nextHopIp == null){
LOG.error("NextHop for interface {} is null", intfName);
}
Adjacencies aug = VpnUtil.getVpnInterfaceAugmentation(value);
- VpnInterface opInterface = VpnUtil.getVpnInterface(intfName, intf.getVpnInstanceName(),
- aug, vpnInterfaceState);
+ VpnInterface opInterface = VpnUtil.getVpnInterface(intfName, intf.getVpnInstanceName(), aug);
InstanceIdentifier<VpnInterface> interfaceId = VpnUtil.getVpnInterfaceIdentifier(intfName);
VpnUtil.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, interfaceId, opInterface);
for (Adjacency nextHop : aug.getAdjacency()) {
String rd = VpnUtil.getVpnRd(broker, intf.getVpnInstanceName());
if (adjacencies.isPresent()) {
- VpnUtil.syncUpdate(broker, LogicalDatastoreType.OPERATIONAL, identifier.augmentation(OpState.class),
- new OpStateBuilder().setStateUp(false).build());
List<Adjacency> nextHops = adjacencies.get().getAdjacency();
if (!nextHops.isEmpty()) {
.setIpAddress(prefix).setKey(new AdjacencyKey(prefix)).build());
Adjacencies aug = VpnUtil.getVpnInterfaceAugmentation(adjacencies);
- VpnInterface newVpnIntf = VpnUtil.getVpnInterface(currVpnIntf.getName(), currVpnIntf.getVpnInstanceName(),
- aug, currVpnIntf.getAugmentation(OpState.class).isStateUp());
+ VpnInterface newVpnIntf = VpnUtil.getVpnInterface(currVpnIntf.getName(), currVpnIntf.getVpnInstanceName(), aug);
VpnUtil.syncUpdate(broker, LogicalDatastoreType.OPERATIONAL, identifier, newVpnIntf);
addExtraRoute(adj.getIpAddress(), adj.getNextHopIp(), rd, currVpnIntf.getVpnInstanceName(), (int) label, currVpnIntf.getName());
Adjacencies aug = VpnUtil.getVpnInterfaceAugmentation(adjacencies);
VpnInterface newVpnIntf = VpnUtil.getVpnInterface(currVpnIntf.getName(),
currVpnIntf.getVpnInstanceName(),
- aug,
- currVpnIntf.getAugmentation(OpState.class).isStateUp());
+ aug);
VpnUtil.syncUpdate(broker, LogicalDatastoreType.OPERATIONAL, identifier, newVpnIntf);
//increment the vpn interface count in Vpn Instance Op Data
Long ifCnt = 0L;
String rd = getRouteDistinguisher(del.getVpnInstanceName());
- if(rd.isEmpty()) rd = del.getVpnInstanceName();
+ if(rd == null || rd.isEmpty()) rd = del.getVpnInstanceName();
VpnInstanceOpDataEntry vpnInstOp = VpnUtil.getVpnInstanceOpData(broker, rd);
if(vpnInstOp != null && vpnInstOp.getVpnInterfaceCount() != null) {
ifCnt = vpnInstOp.getVpnInterfaceCount();
LOG.trace("VpnInterfaceOpListener remove: interface name {} rd {} interface count in Vpn Op Instance {}", interfaceName, rd, ifCnt);
- VpnUtil.asyncUpdate(broker, LogicalDatastoreType.OPERATIONAL,
- VpnUtil.getVpnInstanceOpDataIdentifier(rd),
- VpnUtil.updateIntfCntInVpnInstOpData(ifCnt - 1, rd), VpnUtil.DEFAULT_CALLBACK);
-
- //TODO: Clean up the DPN List in Vpn Instance Op if ifCnt is zero
+ if(ifCnt != 0) {
+ VpnUtil.asyncUpdate(broker, LogicalDatastoreType.OPERATIONAL,
+ VpnUtil.getVpnInstanceOpDataIdentifier(rd),
+ VpnUtil.updateIntfCntInVpnInstOpData(ifCnt - 1, rd), VpnUtil.DEFAULT_CALLBACK);
+ }
+ // Vpn Interface removed => No more adjacencies from it.
+ // Hence clean up interface from vpn-dpn-interface list.
+ Adjacency adjacency = del.getAugmentation(Adjacencies.class).getAdjacency().get(0);
+ Optional<Prefixes> prefixToInterface = Optional.absent();
+ prefixToInterface = VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL,
+ VpnUtil.getPrefixToInterfaceIdentifier(vpnInstOp.getVpnId(),
+ VpnUtil.getIpPrefix(adjacency.getIpAddress())));
+ if (!prefixToInterface.isPresent()) {
+ prefixToInterface = VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL,
+ VpnUtil.getPrefixToInterfaceIdentifier(vpnInstOp.getVpnId(),
+ VpnUtil.getIpPrefix(adjacency.getNextHopIp())));
+ }
+ if (prefixToInterface.isPresent()) {
+ VpnUtil.delete(broker, LogicalDatastoreType.OPERATIONAL,
+ VpnUtil.getPrefixToInterfaceIdentifier(vpnInstOp.getVpnId(),
+ prefixToInterface.get().getIpAddress()),
+ VpnUtil.DEFAULT_CALLBACK);
+ updateDpnDbs(prefixToInterface.get().getDpnId(), del.getVpnInstanceName(), interfaceName, false);
+ }
notifyTaskIfRequired(interfaceName);
}
//increment the vpn interface count in Vpn Instance Op Data
Long ifCnt = 0L;
String rd = getRouteDistinguisher(add.getVpnInstanceName());
- if(rd.isEmpty()) rd = add.getVpnInstanceName();
+ if(rd == null || rd.isEmpty()) rd = add.getVpnInstanceName();
VpnInstanceOpDataEntry vpnInstOp = VpnUtil.getVpnInstanceOpData(broker, rd);
if(vpnInstOp != null && vpnInstOp.getVpnInterfaceCount() != null) {
ifCnt = vpnInstOp.getVpnInterfaceCount();
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);
+ try {
+ VpnAfConfig vpnConfig = vpnInstance.getIpv4Family();
+ String rd = vpnConfig.getRouteDistinguisher();
+ if (rd == null || rd.isEmpty()) {
+ rd = vpnInstance.getVpnInstanceName();
}
- 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);
+ 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);
+ // }
}
- if (action == UpdateRouteAction.WITHDRAW_ROUTE) {
- fibManager.cleanUpDpnForVpn(dpnId, VpnUtil
- .getVpnId(broker, vpnInstance.getVpnInstanceName()), rd);
- }
+ } catch (Exception e) {
+ LOG.error("updatePrefixesForDPN {} in vpn {} failed", dpnId, vpnInstance.getVpnInstanceName(), e);
}
}
}
.child(VpnInstance.class, new VpnInstanceKey(vpnName)).build();
}
- static VpnInterface getVpnInterface(String intfName, String vpnName, Adjacencies aug, boolean opState) {
+ static VpnInterface getVpnInterface(String intfName, String vpnName, Adjacencies aug) {
return new VpnInterfaceBuilder().setKey(new VpnInterfaceKey(intfName)).setVpnInstanceName(vpnName)
.addAugmentation(Adjacencies.class, aug)
- .addAugmentation(OpState.class, new OpStateBuilder().setStateUp(opState).build())
.build();
}