localDpnId, remoteDpnId, vpnId, prefixIp, nextHopIp);
LOG.trace("getRemoteNextHopPointer: Calling ITM with localDpnId {} ", localDpnId);
- try{
- // here use the config for tunnel type param
- tunnelIfName = getTunnelInterfaceName(remoteDpnId, IpAddressBuilder.getDefaultInstance(nextHopIp));
- }catch(Exception ex){
- LOG.error("Error while retrieving nexthop pointer for DC Gateway : ", ex.getMessage());
+ if (nextHopIp != null && !nextHopIp.isEmpty()) {
+ try{
+ // here use the config for tunnel type param
+ tunnelIfName = getTunnelInterfaceName(remoteDpnId, IpAddressBuilder.getDefaultInstance(nextHopIp));
+ }catch(Exception ex){
+ LOG.error("Error while retrieving nexthop pointer for nexthop {} : ", nextHopIp, ex.getMessage());
+ }
}
return tunnelIfName;
}
return;
}
String portname = NeutronvpnUtils.uuidToTapPortName(port.getUuid());
- String name = new StringBuilder(portname).append(":0").toString();
List<Adjacency> adjList = new ArrayList<Adjacency>();
InstanceIdentifier<VpnInterface> vpnIfIdentifier = InstanceIdentifier.builder(VpnInterfaces.class).
- child(VpnInterface.class, new VpnInterfaceKey(name)).build();
+ child(VpnInterface.class, new VpnInterfaceKey(portname)).build();
// find router associated to vpn
Uuid routerId = NeutronvpnUtils.getRouterforVpn(broker, vpnId);
Router rtr = null;
// create extra route adjacency
if (rtr != null && rtr.getRoutes() != null) {
List<String> routeList = rtr.getRoutes();
- List<Adjacency> erAdjList = addAdjacencyforExtraRoute(routeList, false, name);
+ List<Adjacency> erAdjList = addAdjacencyforExtraRoute(routeList, false, portname);
if (erAdjList != null) {
adjList.addAll(erAdjList);
}
}
// create vpn-interface on this neutron port
Adjacencies adjs = new AdjacenciesBuilder().setAdjacency(adjList).build();
- VpnInterfaceBuilder vpnb = new VpnInterfaceBuilder().setKey(new VpnInterfaceKey(name)).
- setName(name).setVpnInstanceName(vpnId.getValue()).addAugmentation(Adjacencies.class, adjs);
+ VpnInterfaceBuilder vpnb = new VpnInterfaceBuilder().setKey(new VpnInterfaceKey(portname)).
+ setName(portname).setVpnInstanceName(vpnId.getValue()).addAugmentation(Adjacencies.class, adjs);
VpnInterface vpnIf = vpnb.build();
- NeutronvpnUtils.lockVpnInterface(lockManager, name);
+ NeutronvpnUtils.lockVpnInterface(lockManager, portname);
try {
logger.debug("Creating vpn interface {}", vpnIf);
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIf);
} catch (Exception ex) {
- logger.error("Creation of vpninterface {} failed due to {}", name, ex);
+ logger.error("Creation of vpninterface {} failed due to {}", portname, ex);
} finally {
- NeutronvpnUtils.unlockVpnInterface(lockManager, name);
+ NeutronvpnUtils.unlockVpnInterface(lockManager, portname);
}
}
if (port != null) {
String pname = NeutronvpnUtils.uuidToTapPortName(port.getUuid());
- String name = new StringBuilder(pname).append(":0").toString();
InstanceIdentifier<VpnInterface> vpnIfIdentifier = InstanceIdentifier.builder(VpnInterfaces.class).
- child(VpnInterface.class, new VpnInterfaceKey(name)).build();
+ child(VpnInterface.class, new VpnInterfaceKey(pname)).build();
- NeutronvpnUtils.lockVpnInterface(lockManager, name);
+ NeutronvpnUtils.lockVpnInterface(lockManager, pname);
try {
- logger.debug("Deleting vpn interface {}", name);
+ logger.debug("Deleting vpn interface {}", pname);
MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier);
} catch (Exception ex) {
- logger.error("Deletion of vpninterface {} failed due to {}", name, ex);
+ logger.error("Deletion of vpninterface {} failed due to {}", pname, ex);
} finally {
- NeutronvpnUtils.unlockVpnInterface(lockManager, name);
+ NeutronvpnUtils.unlockVpnInterface(lockManager, pname);
}
}
}
String destination = parts[1];
String tapPortName = NeutronvpnUtils.getNeutronPortNamefromPortFixedIp(broker, nextHop);
- String ifname = new StringBuilder(tapPortName).append(":0").toString();
logger.trace("Adding extra route with nexthop {}, destination {}, ifName {}", nextHop,
- destination, ifname);
+ destination, tapPortName);
Adjacency erAdj = new AdjacencyBuilder().setIpAddress(destination).setNextHopIp(nextHop).setKey
(new AdjacencyKey(destination)).build();
if (rtrUp == false) {
- if (ifname.equals(vpnifname)) {
+ if (tapPortName.equals(vpnifname)) {
adjList.add(erAdj);
}
continue;
}
InstanceIdentifier<VpnInterface> vpnIfIdentifier = InstanceIdentifier.builder(VpnInterfaces.class).
- child(VpnInterface.class, new VpnInterfaceKey(ifname)).build();
+ child(VpnInterface.class, new VpnInterfaceKey(tapPortName)).build();
Optional<VpnInterface> optionalVpnInterface = NeutronvpnUtils.read(broker, LogicalDatastoreType
.CONFIGURATION, vpnIfIdentifier);
if (optionalVpnInterface.isPresent()) {
Adjacencies erAdjs = new AdjacenciesBuilder().setAdjacency(Arrays.asList(erAdj)).build();
- VpnInterface vpnIf = new VpnInterfaceBuilder().setKey(new VpnInterfaceKey(ifname))
+ VpnInterface vpnIf = new VpnInterfaceBuilder().setKey(new VpnInterfaceKey(tapPortName))
.addAugmentation(Adjacencies.class, erAdjs).build();
MDSALUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIf);
logger.trace("extra route {} added successfully", route);
} else {
logger.error("VM adjacency for interface {} not present ; cannot add extra route adjacency",
- ifname);
+ tapPortName);
}
} else {
logger.error("Incorrect input received for extra route. {}", parts);
String destination = parts[1];
String tapPortName = NeutronvpnUtils.getNeutronPortNamefromPortFixedIp(broker, nextHop);
- String ifname = new StringBuilder(tapPortName).append(":0").toString();
logger.trace("Removing extra route with nexthop {}, destination {}, ifName {}", nextHop,
- destination, ifname);
+ destination, tapPortName);
InstanceIdentifier<Adjacency> adjacencyIdentifier = InstanceIdentifier.builder(VpnInterfaces.class).
- child(VpnInterface.class, new VpnInterfaceKey(ifname)).augmentation(Adjacencies.class)
+ child(VpnInterface.class, new VpnInterfaceKey(tapPortName)).augmentation(Adjacencies.class)
.child(Adjacency.class, new AdjacencyKey(destination)).build();
MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, adjacencyIdentifier);
logger.trace("extra route {} deleted successfully", route);
LOG.info("Received port UP event for interface {} ", interfaceName);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface
configInterface = InterfaceUtils.getInterface(broker, interfaceName);
+ BigInteger dpnId = InterfaceUtils.getDpIdFromInterface(intrf);
if (configInterface != null && configInterface.getType().equals(Tunnel.class)) {
- BigInteger dpnId = InterfaceUtils.getDpnForInterface(interfaceManager, interfaceName);
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);
}
} else {
- vpnInterfaceManager.processVpnInterfaceUp(interfaceName, intrf.getIfIndex());
+ vpnInterfaceManager.processVpnInterfaceUp(dpnId, interfaceName, intrf.getIfIndex());
}
} catch (Exception e) {
LOG.error("Exception caught in Interface Operational State Up event", e);
LOG.info("Received port DOWN event for interface {} ", interfaceName);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface
intf = InterfaceUtils.getInterface(broker, interfaceName);
+ BigInteger dpId = InterfaceUtils.getDpIdFromInterface(intrf);
if (intf != null && intf.getType().equals(Tunnel.class)) {
- // Get the dpId from del reference itself. Because interfaceManager.getDpnForInterface returns
- // NPE because entry is already deleted in operational data store
- BigInteger dpId = getDpIdFromInterface(intrf);
- if (dpId == null) {
- return;
- }
if(intrf.getOperStatus().equals(Interface.OperStatus.Down)) {
//withdraw all prefixes in all vpns for this dpn from bgp
vpnInterfaceManager.updatePrefixesForDPN(dpId, VpnInterfaceManager.UpdateRouteAction.WITHDRAW_ROUTE);
}
} else {
if (VpnUtil.isVpnInterfaceConfigured(broker, interfaceName)) {
- vpnInterfaceManager.processVpnInterfaceDown(interfaceName, intrf.getIfIndex(), true);
+ vpnInterfaceManager.processVpnInterfaceDown(dpId, interfaceName, intrf.getIfIndex(), true);
}
}
} catch (Exception e) {
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)) {
- BigInteger dpnId = InterfaceUtils.getDpnForInterface(interfaceManager, interfaceName);
+ 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);
}
- public BigInteger getDpIdFromInterface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface infState) {
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
- InterfaceUtils.getInterfaceStateFromOperDS(broker, infState.getName());
- String lowerLayerIf = ifState.getLowerLayerIf().get(0);
- NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
- return new BigInteger(InterfaceUtils.getDpnFromNodeConnectorId(nodeConnectorId));
- }
-
}
InterfaceUtils.getInterfaceStateFromOperDS(broker, interfaceName);
if (interfaceState != null) {
// Interface state is up
- processVpnInterfaceUp(interfaceName, interfaceState.getIfIndex());
+ processVpnInterfaceUp(InterfaceUtils.getDpIdFromInterface(interfaceState), interfaceName, interfaceState.getIfIndex());
} else {
LOG.trace("VPN interfaces are not yet operational.");
}
}
- protected void processVpnInterfaceUp(String interfaceName, int lPortTag) {
+ protected void processVpnInterfaceUp(BigInteger dpId, String interfaceName, int lPortTag) {
VpnInterface vpnInterface = VpnUtil.getConfiguredVpnInterface(broker, interfaceName);
if(vpnInterface == null) {
}
synchronized (interfaceName.intern()) {
- bindService(vpnName, interfaceName, lPortTag);
+ bindService(dpId, vpnName, interfaceName, lPortTag);
updateDpnDbs(vpnName, interfaceName, true);
processVpnInterfaceAdjacencies(VpnUtil.getVpnInterfaceIdentifier(vpnInterface.getName()), vpnInterface);
}
}
- private void bindService(String vpnInstanceName, String vpnInterfaceName, int lPortTag) {
+ private void bindService(BigInteger dpId, String vpnInstanceName, String vpnInterfaceName, int lPortTag) {
int priority = VpnConstants.DEFAULT_FLOW_PRIORITY;
long vpnId = VpnUtil.getVpnId(broker, vpnInstanceName);
VpnConstants.COOKIE_VM_INGRESS_TABLE, instructions);
VpnUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION,
InterfaceUtils.buildServiceId(vpnInterfaceName, VpnConstants.L3VPN_SERVICE_IDENTIFIER), serviceInfo);
- makeArpFlow(VpnConstants.L3VPN_SERVICE_IDENTIFIER, lPortTag, vpnInterfaceName, vpnId, ArpReplyOrRequest.REQUEST, NwConstants.ADD_FLOW);
+ makeArpFlow(dpId, VpnConstants.L3VPN_SERVICE_IDENTIFIER, lPortTag, vpnInterfaceName,
+ vpnId, ArpReplyOrRequest.REQUEST, NwConstants.ADD_FLOW);
}
}
}
- private void makeArpFlow(short sIndex, int lPortTag, String vpnInterfaceName, long vpnId, ArpReplyOrRequest replyOrRequest, int addOrRemoveFlow){
+ private void makeArpFlow(BigInteger dpId,short sIndex, int lPortTag, String vpnInterfaceName,
+ long vpnId, ArpReplyOrRequest replyOrRequest, int addOrRemoveFlow){
List<MatchInfo> matches = new ArrayList<MatchInfo>();
BigInteger metadata = MetaDataUtil.getMetaDataForLPortDispatcher(lPortTag, ++sIndex, BigInteger.valueOf(vpnId));
BigInteger metadataMask = MetaDataUtil.getMetaDataMaskForLPortDispatcher(MetaDataUtil.METADATA_MASK_SERVICE_INDEX,
instructions.add(new InstructionInfo(InstructionType.write_actions, actionsInfos));
// Install the flow entry in L3_INTERFACE_TABLE
- BigInteger dpId = InterfaceUtils.getDpnForInterface(interfaceManager, vpnInterfaceName);
String flowRef = VpnUtil.getFlowRef(dpId, NwConstants.L3_INTERFACE_TABLE,
NwConstants.ETHTYPE_ARP, lPortTag, replyOrRequest.getArpOperation());
FlowEntity flowEntity;
InterfaceUtils.getInterfaceStateFromOperDS(broker, interfaceName);
if (existingVpnInterface.isPresent() && interfaceState != null) {
- processVpnInterfaceDown(interfaceName, interfaceState.getIfIndex(), false);
+ processVpnInterfaceDown(InterfaceUtils.getDpIdFromInterface(interfaceState), interfaceName, interfaceState.getIfIndex(), false);
} else {
LOG.warn("VPN interface {} was unavailable in operational data store to handle remove event", interfaceName);
}
}
- protected void processVpnInterfaceDown(String interfaceName, int lPortTag, boolean isInterfaceStateDown) {
+ protected void processVpnInterfaceDown(BigInteger dpId, String interfaceName, int lPortTag, boolean isInterfaceStateDown) {
VpnInterface vpnInterface = VpnUtil.getOperationalVpnInterface(broker, interfaceName);
if(vpnInterface == null) {
LOG.info("Unable to process delete/down for interface {} as it is not available in operational data store", interfaceName);
synchronized (interfaceName.intern()) {
removeAdjacenciesFromVpn(identifier, vpnInterface);
LOG.info("Unbinding vpn service from interface {} ", interfaceName);
- unbindService(vpnName, interfaceName, lPortTag, isInterfaceStateDown);
+ unbindService(dpId, vpnName, interfaceName, lPortTag, isInterfaceStateDown);
//wait till DCN for removal of vpn interface in operational DS arrives
Runnable notifyTask = new VpnNotifyTask();
}
- private void unbindService(String vpnInstanceName, String vpnInterfaceName, int lPortTag, boolean isInterfaceStateDown) {
+ private void unbindService(BigInteger dpId, String vpnInstanceName, String vpnInterfaceName,
+ int lPortTag, boolean isInterfaceStateDown) {
if (!isInterfaceStateDown) {
VpnUtil.delete(broker, LogicalDatastoreType.CONFIGURATION,
InterfaceUtils.buildServiceId(vpnInterfaceName,
VpnUtil.DEFAULT_CALLBACK);
}
long vpnId = VpnUtil.getVpnId(broker, vpnInstanceName);
- makeArpFlow(VpnConstants.L3VPN_SERVICE_IDENTIFIER, lPortTag, vpnInterfaceName,
+ makeArpFlow(dpId, VpnConstants.L3VPN_SERVICE_IDENTIFIER, lPortTag, vpnInterfaceName,
vpnId, ArpReplyOrRequest.REQUEST, NwConstants.DEL_FLOW);
}
String[] split = portId.getValue().split(OF_URI_SEPARATOR);
return split[1];
}
+
+ public static BigInteger getDpIdFromInterface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
+ String lowerLayerIf = ifState.getLowerLayerIf().get(0);
+ NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
+ return new BigInteger(getDpnFromNodeConnectorId(nodeConnectorId));
+ }
+
}