use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.Vpn in project netvirt by opendaylight.
the class NaptSwitchHA method bestEffortDeletion.
protected void bestEffortDeletion(long routerId, String routerName, Map<String, Long> externalIpLabel, WriteTransaction removeFlowInvTx) {
Collection<String> newExternalIps = NatUtil.getExternalIpsForRouter(dataBroker, routerId);
if (externalIpsCache != null) {
Set<String> removedExternalIps = new HashSet<>(externalIpsCache);
removedExternalIps.removeAll(newExternalIps);
if (removedExternalIps.isEmpty()) {
LOG.info("bestEffortDeletion : No external Ip needed to be removed in bestEffortDeletion " + "method for router {}", routerName);
return;
}
Uuid networkId = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
String vpnName = getExtNetworkVpnName(routerName, networkId);
if (vpnName == null) {
LOG.error("bestEffortDeletion : Vpn is not associated to externalN/w of router {}", routerName);
return;
}
BigInteger naptSwitch = NatUtil.getPrimaryNaptfromRouterName(dataBroker, routerName);
if (naptSwitch == null || naptSwitch.equals(BigInteger.ZERO)) {
LOG.error("bestEffortDeletion : No naptSwitch is selected for router {}", routerName);
return;
}
ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName, networkId);
if (extNwProvType == null) {
return;
}
String gwMacAddress = NatUtil.getExtGwMacAddFromRouterName(dataBroker, routerName);
if (gwMacAddress != null) {
LOG.debug("bestEffortDeletion : External Gateway MAC address {} found for External Router ID {}", gwMacAddress, routerId);
} else {
LOG.error("bestEffortDeletion : No External Gateway MAC address found for External Router ID {}", routerId);
return;
}
if (extNwProvType == ProviderTypes.VXLAN) {
for (String externalIp : removedExternalIps) {
externalRouterListener.clearBgpRoutes(externalIp, vpnName);
externalRouterListener.delFibTsAndReverseTraffic(naptSwitch, routerId, externalIp, vpnName, networkId, NatConstants.DEFAULT_LABEL_VALUE, gwMacAddress, true, removeFlowInvTx);
LOG.debug("bestEffortDeletion : Successfully removed fib entry for externalIp {} for routerId {} " + "on NAPT switch {} ", externalIp, routerId, naptSwitch);
}
} else {
if (externalIpLabel == null || externalIpLabel.isEmpty()) {
LOG.error("bestEffortDeletion : ExternalIpLabel map is empty for router {}", routerName);
return;
}
Long label;
for (String externalIp : removedExternalIps) {
if (externalIpLabel.containsKey(externalIp)) {
label = externalIpLabel.get(externalIp);
LOG.debug("bestEffortDeletion : Label {} for ExternalIp {} for router {}", label, externalIp, routerName);
} else {
LOG.debug("bestEffortDeletion : Label for ExternalIp {} is not found for router {}", externalIp, routerName);
continue;
}
externalRouterListener.clearBgpRoutes(externalIp, vpnName);
externalRouterListener.delFibTsAndReverseTraffic(naptSwitch, routerId, externalIp, vpnName, networkId, label, gwMacAddress, true, removeFlowInvTx);
LOG.debug("bestEffortDeletion : Successfully removed fib entries in switch {} for router {} " + "and externalIps {}", naptSwitch, routerId, externalIp);
}
}
} else {
LOG.debug("bestEffortDeletion : No external IP found for router {}", routerId);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.Vpn in project netvirt by opendaylight.
the class NaptSwitchHA method removeSnatFlowsInOldNaptSwitch.
/* This method checks the switch that gone down is a NaptSwitch for a router.
If it is a NaptSwitch
1) selects new NAPT switch
2) installs nat flows in new NAPT switch
table 21(FIB)->26(PSNAT)->group(resubmit/napttunnel)->36(Terminating)->46(outbound)->47(resubmit)->21
3) modify the group and miss entry flow in other vSwitches pointing to newNaptSwitch
4) Remove nat flows in oldNaptSwitch
*/
/*public void handleNaptSwitchDown(BigInteger dpnId){
LOG.debug("handleNaptSwitchDown method is called with dpnId {}",dpnId);
BigInteger naptSwitch;
try {
NaptSwitches naptSwitches = NatUtil.getNaptSwitch(dataBroker);
if (naptSwitches == null || naptSwitches.getRouterToNaptSwitch() == null
|| naptSwitches.getRouterToNaptSwitch().isEmpty()) {
LOG.debug("NaptSwitchDown: NaptSwitch is not allocated for none of the routers");
return;
}
for (RouterToNaptSwitch routerToNaptSwitch : naptSwitches.getRouterToNaptSwitch()) {
String routerName = routerToNaptSwitch.getRouterName();
naptSwitch = routerToNaptSwitch.getPrimarySwitchId();
boolean naptStatus = isNaptSwitchDown(routerName,dpnId,naptSwitch);
if (!naptStatus) {
LOG.debug("NaptSwitchDown: Switch with DpnId {} is not naptSwitch for router {}",
dpnId, routerName);
} else {
removeSnatFlowsInOldNaptSwitch(routerName,naptSwitch);
return;
}
}
} catch (Exception ex) {
LOG.error("Exception in handleNaptSwitchDown method {}",ex);
}
}*/
protected void removeSnatFlowsInOldNaptSwitch(String routerName, Long routerId, BigInteger naptSwitch, Map<String, Long> externalIpmap, WriteTransaction removeFlowInvTx) {
// remove SNAT flows in old NAPT SWITCH
Uuid networkId = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
String vpnName = getExtNetworkVpnName(routerName, networkId);
if (vpnName == null) {
LOG.error("removeSnatFlowsInOldNaptSwitch : Vpn is not associated to externalN/w of router {}", routerName);
return;
}
ProviderTypes extNwProvType = NatEvpnUtil.getExtNwProvTypeFromRouterName(dataBroker, routerName, networkId);
if (extNwProvType == null) {
LOG.error("removeSnatFlowsInOldNaptSwitch : Unable to retrieve the External Network Provider Type " + "for Router {}", routerName);
return;
}
if (extNwProvType == ProviderTypes.VXLAN) {
evpnNaptSwitchHA.evpnRemoveSnatFlowsInOldNaptSwitch(routerName, routerId, vpnName, naptSwitch, removeFlowInvTx);
} else {
// Remove the Terminating Service table entry which forwards the packet to Outbound NAPT Table
long tunnelId = NatUtil.getTunnelIdForNonNaptToNaptFlow(dataBroker, elanManager, idManager, routerId, routerName);
String tsFlowRef = externalRouterListener.getFlowRefTs(naptSwitch, NwConstants.INTERNAL_TUNNEL_TABLE, tunnelId);
FlowEntity tsNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.INTERNAL_TUNNEL_TABLE, tsFlowRef);
LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for the old napt switch " + "with the DPN ID {} and router ID {}", NwConstants.INTERNAL_TUNNEL_TABLE, naptSwitch, routerId);
mdsalManager.removeFlowToTx(tsNatFlowEntity, removeFlowInvTx);
}
if (NatUtil.isOpenStackVniSemanticsEnforcedForGreAndVxlan(elanManager, extNwProvType)) {
// Remove the flow table 25->44 If there is no FIP Match on table 25 (PDNAT_TABLE)
NatUtil.removePreDnatToSnatTableEntry(mdsalManager, naptSwitch, removeFlowInvTx);
}
// Remove the Outbound flow entry which forwards the packet to Outbound NAPT Table
String outboundNatFlowRef = externalRouterListener.getFlowRefOutbound(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE, routerId);
FlowEntity outboundNatFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE, outboundNatFlowRef);
LOG.info("Remove the flow in table {} for the old napt switch with the DPN ID {} and router ID {}", NwConstants.OUTBOUND_NAPT_TABLE, naptSwitch, routerId);
mdsalManager.removeFlowToTx(outboundNatFlowEntity, removeFlowInvTx);
// Remove the NAPT PFIB TABLE (47->21) which forwards the incoming packet to FIB Table matching on the
// External Subnet Vpn Id.
Collection<Uuid> externalSubnetIdsForRouter = NatUtil.getExternalSubnetIdsForRouter(dataBroker, routerName);
for (Uuid externalSubnetId : externalSubnetIdsForRouter) {
long subnetVpnId = NatUtil.getVpnId(dataBroker, externalSubnetId.getValue());
if (subnetVpnId != -1) {
String natPfibSubnetFlowRef = externalRouterListener.getFlowRefTs(naptSwitch, NwConstants.NAPT_PFIB_TABLE, subnetVpnId);
FlowEntity natPfibFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.NAPT_PFIB_TABLE, natPfibSubnetFlowRef);
mdsalManager.removeFlowToTx(natPfibFlowEntity, removeFlowInvTx);
LOG.debug("removeSnatFlowsInOldNaptSwitch : Removed the flow in table {} with external subnet " + "Vpn Id {} as metadata on Napt Switch {}", NwConstants.NAPT_PFIB_TABLE, subnetVpnId, naptSwitch);
}
}
// Remove the NAPT_PFIB_TABLE(47) flow entry forwards the packet to Fib Table for inbound traffic
// matching on the router ID.
String naptPFibflowRef = externalRouterListener.getFlowRefTs(naptSwitch, NwConstants.NAPT_PFIB_TABLE, routerId);
FlowEntity naptPFibFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.NAPT_PFIB_TABLE, naptPFibflowRef);
LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for the old napt switch " + "with the DPN ID {} and router ID {}", NwConstants.NAPT_PFIB_TABLE, naptSwitch, routerId);
mdsalManager.removeFlowToTx(naptPFibFlowEntity, removeFlowInvTx);
// Remove the NAPT_PFIB_TABLE(47) flow entry forwards the packet to Fib Table for outbound traffic
// matching on the vpn ID.
boolean switchSharedByRouters = false;
Uuid extNetworkId = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
if (extNetworkId != null) {
List<String> routerNamesAssociated = getRouterIdsForExtNetwork(extNetworkId);
for (String routerNameAssociated : routerNamesAssociated) {
if (!routerNameAssociated.equals(routerName)) {
Long routerIdAssociated = NatUtil.getVpnId(dataBroker, routerNameAssociated);
BigInteger naptDpn = NatUtil.getPrimaryNaptfromRouterName(dataBroker, routerNameAssociated);
if (naptDpn != null && naptDpn.equals(naptSwitch)) {
LOG.debug("removeSnatFlowsInOldNaptSwitch : Napt switch {} is also acting as primary " + "for router {}", naptSwitch, routerIdAssociated);
switchSharedByRouters = true;
break;
}
}
}
if (!switchSharedByRouters) {
Long vpnId = getVpnIdForRouter(routerId, extNetworkId);
if (vpnId != NatConstants.INVALID_ID) {
String naptFibflowRef = externalRouterListener.getFlowRefTs(naptSwitch, NwConstants.NAPT_PFIB_TABLE, vpnId);
FlowEntity naptFibFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.NAPT_PFIB_TABLE, naptFibflowRef);
LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for the old napt switch" + " with the DPN ID {} and vpnId {}", NwConstants.NAPT_PFIB_TABLE, naptSwitch, vpnId);
mdsalManager.removeFlowToTx(naptFibFlowEntity, removeFlowInvTx);
} else {
LOG.error("removeSnatFlowsInOldNaptSwitch : Invalid vpnId retrieved for routerId {}", routerId);
return;
}
}
}
// Remove Fib entries,tables 20->44 ,36-> 44
String gwMacAddress = NatUtil.getExtGwMacAddFromRouterName(dataBroker, routerName);
if (externalIpmap != null && !externalIpmap.isEmpty()) {
for (Entry<String, Long> entry : externalIpmap.entrySet()) {
String externalIp = entry.getKey();
Long label = entry.getValue();
externalRouterListener.delFibTsAndReverseTraffic(naptSwitch, routerId, externalIp, vpnName, extNetworkId, label, gwMacAddress, true, removeFlowInvTx);
LOG.debug("removeSnatFlowsInOldNaptSwitch : Successfully removed fib entries in old naptswitch {} " + "for router {} and externalIps {} label {}", naptSwitch, routerId, externalIp, label);
}
} else {
List<String> externalIps = NatUtil.getExternalIpsForRouter(dataBroker, routerName);
if (networkId != null) {
externalRouterListener.clearFibTsAndReverseTraffic(naptSwitch, routerId, networkId, externalIps, null, gwMacAddress, removeFlowInvTx);
LOG.debug("removeSnatFlowsInOldNaptSwitch : Successfully removed fib entries in old naptswitch {} for " + "router {} with networkId {} and externalIps {}", naptSwitch, routerId, networkId, externalIps);
} else {
LOG.debug("removeSnatFlowsInOldNaptSwitch : External network not associated to router {}", routerId);
}
externalRouterListener.removeNaptFibExternalOutputFlows(routerId, naptSwitch, extNetworkId, externalIps, removeFlowInvTx);
}
// For the router ID get the internal IP , internal port and the corresponding external IP and external Port.
IpPortMapping ipPortMapping = NatUtil.getIportMapping(dataBroker, routerId);
if (ipPortMapping == null || ipPortMapping.getIntextIpProtocolType() == null || ipPortMapping.getIntextIpProtocolType().isEmpty()) {
LOG.warn("removeSnatFlowsInOldNaptSwitch : No Internal Ip Port mapping associated to router {}, " + "no flows need to be removed in oldNaptSwitch {}", routerId, naptSwitch);
return;
}
BigInteger cookieSnatFlow = NatUtil.getCookieNaptFlow(routerId);
List<IntextIpProtocolType> intextIpProtocolTypes = ipPortMapping.getIntextIpProtocolType();
for (IntextIpProtocolType intextIpProtocolType : intextIpProtocolTypes) {
if (intextIpProtocolType.getIpPortMap() == null || intextIpProtocolType.getIpPortMap().isEmpty()) {
LOG.debug("removeSnatFlowsInOldNaptSwitch : No {} session associated to router {}," + "no flows need to be removed in oldNaptSwitch {}", intextIpProtocolType.getProtocol(), routerId, naptSwitch);
break;
}
List<IpPortMap> ipPortMaps = intextIpProtocolType.getIpPortMap();
for (IpPortMap ipPortMap : ipPortMaps) {
String ipPortInternal = ipPortMap.getIpPortInternal();
String[] ipPortParts = ipPortInternal.split(":");
if (ipPortParts.length != 2) {
LOG.error("removeSnatFlowsInOldNaptSwitch : Unable to retrieve the Internal IP and port");
continue;
}
String internalIp = ipPortParts[0];
String internalPort = ipPortParts[1];
// Build and remove flow in outbound NAPT table
String switchFlowRef = NatUtil.getNaptFlowRef(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE, String.valueOf(routerId), internalIp, Integer.parseInt(internalPort));
FlowEntity outboundNaptFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE, cookieSnatFlow, switchFlowRef);
LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for old napt switch " + "with the DPN ID {} and router ID {}", NwConstants.OUTBOUND_NAPT_TABLE, naptSwitch, routerId);
mdsalManager.removeFlowToTx(outboundNaptFlowEntity, removeFlowInvTx);
IpPortExternal ipPortExternal = ipPortMap.getIpPortExternal();
if (ipPortExternal == null) {
LOG.debug("removeSnatFlowsInOldNaptSwitch : External Ipport mapping not found for internalIp {} " + "with port {} for router {}", internalIp, internalPort, routerId);
continue;
}
String externalIp = ipPortExternal.getIpAddress();
int externalPort = ipPortExternal.getPortNum();
// Build and remove flow in inbound NAPT table
switchFlowRef = NatUtil.getNaptFlowRef(naptSwitch, NwConstants.INBOUND_NAPT_TABLE, String.valueOf(routerId), externalIp, externalPort);
FlowEntity inboundNaptFlowEntity = NatUtil.buildFlowEntity(naptSwitch, NwConstants.INBOUND_NAPT_TABLE, cookieSnatFlow, switchFlowRef);
LOG.info("removeSnatFlowsInOldNaptSwitch : Remove the flow in table {} for old napt switch with the " + "DPN ID {} and router ID {}", NwConstants.INBOUND_NAPT_TABLE, naptSwitch, routerId);
mdsalManager.removeFlowToTx(inboundNaptFlowEntity, removeFlowInvTx);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.Vpn in project netvirt by opendaylight.
the class NaptSwitchHA method isNaptSwitchDown.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public boolean isNaptSwitchDown(String routerName, Long routerId, BigInteger dpnId, BigInteger naptSwitch, Long routerVpnId, Collection<String> externalIpCache, boolean isClearBgpRts, WriteTransaction writeFlowInvTx) {
externalIpsCache = externalIpCache;
if (!naptSwitch.equals(dpnId)) {
LOG.debug("isNaptSwitchDown : DpnId {} is not a naptSwitch {} for Router {}", dpnId, naptSwitch, routerName);
return false;
}
LOG.debug("NaptSwitch {} is down for Router {}", naptSwitch, routerName);
if (routerId == NatConstants.INVALID_ID) {
LOG.error("isNaptSwitchDown : Invalid routerId returned for routerName {}", routerName);
return true;
}
Uuid networkId = NatUtil.getNetworkIdFromRouterName(dataBroker, routerName);
String vpnName = getExtNetworkVpnName(routerName, networkId);
// elect a new NaptSwitch
naptSwitch = naptSwitchSelector.selectNewNAPTSwitch(routerName);
if (natMode == NatMode.Conntrack) {
Routers extRouters = NatUtil.getRoutersFromConfigDS(dataBroker, routerName);
natServiceManager.notify(extRouters, dpnId, dpnId, SnatServiceManager.Action.SNAT_ALL_SWITCH_DISBL);
natServiceManager.notify(extRouters, naptSwitch, naptSwitch, SnatServiceManager.Action.SNAT_ALL_SWITCH_ENBL);
} else {
if (naptSwitch.equals(BigInteger.ZERO)) {
LOG.warn("isNaptSwitchDown : No napt switch is elected since all the switches for router {}" + " are down. SNAT IS NOT SUPPORTED FOR ROUTER {}", routerName, routerName);
boolean naptUpdatedStatus = updateNaptSwitch(routerName, naptSwitch);
if (!naptUpdatedStatus) {
LOG.debug("isNaptSwitchDown : Failed to update naptSwitch {} for router {} in ds", naptSwitch, routerName);
}
// clearBgpRoutes
if (externalIpsCache != null) {
if (vpnName != null) {
// if (externalIps != null) {
if (isClearBgpRts) {
LOG.debug("isNaptSwitchDown : Clearing both FIB entries and the BGP routes");
for (String externalIp : externalIpsCache) {
externalRouterListener.clearBgpRoutes(externalIp, vpnName);
}
} else {
LOG.debug("isNaptSwitchDown : Clearing the FIB entries but not the BGP routes");
String rd = NatUtil.getVpnRd(dataBroker, vpnName);
for (String externalIp : externalIpsCache) {
LOG.debug("isNaptSwitchDown : Removing Fib entry rd {} prefix {}", rd, externalIp);
fibManager.removeFibEntry(rd, externalIp, null);
}
}
} else {
LOG.debug("isNaptSwitchDown : vpn is not associated to extn/w for router {}", routerName);
}
} else {
LOG.debug("isNaptSwitchDown : No ExternalIps found for subnets under router {}, " + "no bgp routes need to be cleared", routerName);
}
return true;
}
// checking elected switch health status
if (!getSwitchStatus(naptSwitch)) {
LOG.error("isNaptSwitchDown : Newly elected Napt switch {} for router {} is down", naptSwitch, routerName);
return true;
}
LOG.debug("isNaptSwitchDown : New NaptSwitch {} is up for Router {} and can proceed for flow installation", naptSwitch, routerName);
// update napt model for new napt switch
boolean naptUpdated = updateNaptSwitch(routerName, naptSwitch);
if (naptUpdated) {
// update group of ordinary switch point to naptSwitch tunnel port
updateNaptSwitchBucketStatus(routerName, routerId, naptSwitch);
} else {
LOG.error("isNaptSwitchDown : Failed to update naptSwitch model for newNaptSwitch {} for router {}", naptSwitch, routerName);
}
// update table26 forward packets to table46(outbound napt table)
FlowEntity flowEntity = buildSnatFlowEntityForNaptSwitch(naptSwitch, routerName, routerVpnId, NatConstants.ADD_FLOW);
if (flowEntity == null) {
LOG.error("isNaptSwitchDown : Failed to populate flowentity for router {} in naptSwitch {}", routerName, naptSwitch);
} else {
LOG.debug("isNaptSwitchDown : Successfully installed flow in naptSwitch {} for router {}", naptSwitch, routerName);
mdsalManager.addFlowToTx(flowEntity, writeFlowInvTx);
}
installSnatFlows(routerName, routerId, naptSwitch, routerVpnId, writeFlowInvTx);
boolean flowInstalledStatus = handleNatFlowsInNewNaptSwitch(routerName, routerId, dpnId, naptSwitch, routerVpnId, networkId);
if (flowInstalledStatus) {
LOG.debug("isNaptSwitchDown :Installed all active session flows in newNaptSwitch {} for routerName {}", naptSwitch, routerName);
} else {
LOG.error("isNaptSwitchDown : Failed to install flows in newNaptSwitch {} for routerId {}", naptSwitch, routerId);
}
// remove group in new naptswitch, coz this switch acted previously as ordinary switch
long groupId = NatUtil.createGroupId(NatUtil.getGroupIdKey(routerName), idManager);
GroupEntity groupEntity = null;
try {
groupEntity = MDSALUtil.buildGroupEntity(naptSwitch, groupId, routerName, GroupTypes.GroupAll, Collections.emptyList());
LOG.info("isNaptSwitchDown : Removing NAPT Group in new naptSwitch {}", naptSwitch);
mdsalManager.removeGroup(groupEntity);
} catch (Exception ex) {
LOG.error("isNaptSwitchDown : Failed to remove group in new naptSwitch {}", groupEntity, ex);
}
}
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.Vpn in project netvirt by opendaylight.
the class NatEvpnUtil method removeL3GwMacTableEntry.
static void removeL3GwMacTableEntry(final BigInteger dpnId, final long vpnId, final String macAddress, IMdsalApiManager mdsalManager, WriteTransaction removeFlowInvTx) {
List<MatchInfo> matchInfo = new ArrayList<>();
matchInfo.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
matchInfo.add(new MatchEthernetSource(new MacAddress(macAddress)));
LOG.debug("removeL3GwMacTableEntry : Remove flow table {} -> table {} for External Vpn Id = {} " + "and MacAddress = {} on DpnId = {}", NwConstants.L3_GW_MAC_TABLE, NwConstants.INBOUND_NAPT_TABLE, vpnId, macAddress, dpnId);
// Remove the flow entry in L3_GW_MAC_TABLE
String flowRef = NatUtil.getFlowRef(dpnId, NwConstants.L3_GW_MAC_TABLE, vpnId, macAddress);
Flow l3GwMacTableFlowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_GW_MAC_TABLE, flowRef, 21, flowRef, 0, 0, NwConstants.COOKIE_L3_GW_MAC_TABLE, matchInfo, null);
mdsalManager.removeFlowToTx(dpnId, l3GwMacTableFlowEntity, removeFlowInvTx);
LOG.debug("removeL3GwMacTableEntry : Successfully removed flow entity {} on DPN = {}", l3GwMacTableFlowEntity, dpnId);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.Vpn in project netvirt by opendaylight.
the class SNATDefaultRouteProgrammer method addOrDelDefaultFibRouteToSNATForSubnet.
void addOrDelDefaultFibRouteToSNATForSubnet(Subnets subnet, String networkId, int flowAction, long vpnId) {
String subnetId = subnet.getId().getValue();
InstanceIdentifier<VpnInstanceOpDataEntry> networkVpnInstanceIdentifier = NatUtil.getVpnInstanceOpDataIdentifier(networkId);
Optional<VpnInstanceOpDataEntry> networkVpnInstanceOp = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, networkVpnInstanceIdentifier);
if (!networkVpnInstanceOp.isPresent()) {
LOG.debug("addOrDelDefaultFibRouteToSNATForSubnet : Cannot create/remove default FIB route to SNAT flow " + "for subnet {} vpn-instance-op-data entry for network {} does not exist", subnetId, networkId);
return;
}
List<VpnToDpnList> dpnListInVpn = networkVpnInstanceOp.get().getVpnToDpnList();
if (dpnListInVpn == null) {
LOG.debug("addOrDelDefaultFibRouteToSNATForSubnet : Will not add/remove default NAT flow for subnet {} " + "no dpn set for vpn instance {}", subnetId, networkVpnInstanceOp.get());
return;
}
for (VpnToDpnList dpn : dpnListInVpn) {
String macAddress = NatUtil.getSubnetGwMac(dataBroker, subnet.getId(), networkId);
extNetGroupInstaller.installExtNetGroupEntry(new Uuid(networkId), subnet.getId(), dpn.getDpnId(), macAddress);
FlowEntity flowEntity = NatUtil.buildDefaultNATFlowEntityForExternalSubnet(dpn.getDpnId(), vpnId, subnetId, idManager);
if (flowAction == NwConstants.ADD_FLOW || flowAction == NwConstants.MOD_FLOW) {
LOG.info("addOrDelDefaultFibRouteToSNATForSubnet : Installing flow {} for subnetId {}," + "vpnId {} on dpn {}", flowEntity, subnetId, vpnId, dpn.getDpnId());
mdsalManager.installFlow(flowEntity);
} else {
LOG.info("addOrDelDefaultFibRouteToSNATForSubnet : Removing flow for subnetId {}," + "vpnId {} with dpn {}", subnetId, vpnId, dpn);
mdsalManager.removeFlow(flowEntity);
}
}
}
Aggregations