that has this router associated.
Multiple fixes for this issue :
(a) When router is associated to BGPVPN , the route gateway IP (x.x.x.1)
is not moved from internal VPN to BGPVPN.
(b) When a network , subnet , router is created and VM is booted , ARP
RESPONDER table (81) contains router gateway MAC in eth_src field.
When router is associated to BGPVPN , eth_src filed in table=81 , entry is
replaced with VM's connected MAC address.
It leads to ping failures.
(c) A network , subnet , router is created and VM is booted. MY MAC table
(19) contains router gateway MAC address . When the router is associated
with BGPVPN , VM's MAC address is added into MY MAC table (19) which is
incorrect.
When router is disassociated , VM's MAC address entry remains in table=19
(stale entry)
Change-Id: Ifd19bdbda90a082bd6f7e21df29d8257ce9eb534
Signed-off-by: HANAMANTAGOUD V Kandagal <hanamantagoud.v.kandagal@ericsson.com>
Signed-off-by: ehvkand <hanamantagoud.v.kandagal@ericsson.com>
Signed-off-by: HANAMANTAGOUD V Kandagal <hanamantagoud.v.kandagal@ericsson.com>
Signed-off-by: Periyasamy Palanisamy <periyasamy.palanisamy@ericsson.com>
Signed-off-by: Vivekanandan Narasimhan <n.vivekanandan@ericsson.com>
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import java.math.BigInteger;
import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.RouterInterface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry;
public interface IFibManager {
void addOrUpdateFibEntry(DataBroker broker, String rd, String prefix, List<String> nextHopList,
int label, RouteOrigin origin, WriteTransaction writeConfigTxn);
+ void addFibEntryForRouterInterface(DataBroker broker, String rd, String prefix,
+ RouterInterface routerInterface, long label, WriteTransaction writeConfigTxn);
void removeOrUpdateFibEntry(DataBroker broker, String rd, String prefix, String nextHopToRemove, WriteTransaction writeConfigTxn);
void removeFibEntry(DataBroker broker, String rd, String prefix, WriteTransaction writeConfigTxn);
void updateFibEntry(DataBroker broker, String rd, String prefix , List<String> nextHopList, WriteTransaction writeConfigTxn);
import org.opendaylight.netvirt.fibmanager.api.IFibManager;
import org.opendaylight.netvirt.fibmanager.api.RouteOrigin;
import org.opendaylight.netvirt.vpnmanager.api.IVpnManager;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.RouterInterface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry;
import org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkCache;
import org.osgi.framework.BundleContext;
FibUtil.addOrUpdateFibEntry(broker, rd, prefix , nextHopList, label, origin, writeConfigTxn);
}
+ @Override
+ public void addFibEntryForRouterInterface(DataBroker broker, String rd, String prefix,
+ RouterInterface routerInterface, long label, WriteTransaction writeConfigTxn) {
+ FibUtil.addFibEntryForRouterInterface(broker, rd, prefix, routerInterface, label, writeConfigTxn);
+ }
+
@Override
public void removeOrUpdateFibEntry(DataBroker broker, String rd, String prefix,
String nextHopToRemove, WriteTransaction writeConfigTxn) {
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.RouterInterface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesBuilder;
import java.math.BigInteger;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
throw new RuntimeException(e.getMessage());
}
}
+
public static void addOrUpdateFibEntry(DataBroker broker, String rd, String prefix, List<String> nextHopList,
int label, RouteOrigin origin, WriteTransaction writeConfigTxn) {
if (rd == null || rd.isEmpty() ) {
}
}
+ public static void addFibEntryForRouterInterface(DataBroker broker,
+ String rd,
+ String prefix,
+ RouterInterface routerInterface,
+ long label,
+ WriteTransaction writeConfigTxn) {
+ if (rd == null || rd.isEmpty() ) {
+ LOG.error("Prefix {} not associated with vpn", prefix);
+ return;
+ }
+
+ try{
+ InstanceIdentifier<VrfEntry> vrfEntryId =
+ InstanceIdentifier.builder(FibEntries.class)
+ .child(VrfTables.class, new VrfTablesKey(rd))
+ .child(VrfEntry.class, new VrfEntryKey(prefix)).build();
+
+ VrfEntry vrfEntry = new VrfEntryBuilder().setKey(new VrfEntryKey(prefix)).setDestPrefix(prefix)
+ .setNextHopAddressList(Arrays.asList(""))
+ .setLabel(label)
+ .setOrigin(RouteOrigin.LOCAL.getValue())
+ .addAugmentation(RouterInterface.class, routerInterface).build();
+
+ if (writeConfigTxn != null) {
+ writeConfigTxn.merge(LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntry, true);
+ } else {
+ MDSALUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntry);
+ }
+ LOG.debug("Created vrfEntry for router-interface-prefix {} rd {} label {}", prefix, rd, label);
+ } catch (Exception e) {
+ LOG.error("addFibEntryToDS: error ", e);
+ }
+ }
+
public static void removeFibEntry(DataBroker broker, String rd, String prefix, WriteTransaction writeConfigTxn) {
if (rd == null || rd.isEmpty()) {
}
}
- protected void updateVpnInterface(Uuid vpnId, Uuid oldVpnId, Port port, boolean isBeingAssociated) {
+ protected void updateVpnInterface(Uuid vpnId, Uuid oldVpnId, Port port, boolean isBeingAssociated, boolean isSubnetIp) {
if (vpnId == null || port == null) {
return;
}
Adjacencies adjacencies = new AdjacenciesBuilder().setAdjacency(adjacencyList).build();
vpnIfBuilder.addAugmentation(Adjacencies.class, adjacencies);
}
- MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIfBuilder
- .build());
-
List<FixedIps> ips = port.getFixedIps();
for (FixedIps ip : ips) {
String ipValue = String.valueOf(ip.getIpAddress().getValue());
NeutronvpnUtils.removeVpnPortFixedIpToPort(dataBroker, oldVpnId.getValue(), ipValue);
}
NeutronvpnUtils.createVpnPortFixedIpToPort(dataBroker, vpnId.getValue(), ipValue, infName, port
- .getMacAddress().getValue(), false, true, false);
+ .getMacAddress().getValue(), isSubnetIp, true, false);
}
+ MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIfBuilder
+ .build());
} else {
LOG.error("VPN Interface {} not found", infName);
}
oldVpnId = sn.getVpnId();
List<String> ips = sn.getRouterInterfaceFixedIps();
for (String ipValue : ips) {
- if (oldVpnId != null) {
- NeutronvpnUtils.removeVpnPortFixedIpToPort(dataBroker, oldVpnId.getValue(), ipValue);
- }
- NeutronvpnUtils.createVpnPortFixedIpToPort(dataBroker, vpnId.getValue(), ipValue, sn
- .getRouterInterfaceName().getValue(), sn.getRouterIntfMacAddress(), true, true, false);
+ // Update the association of router-interface to external vpn
+ String PortName = NeutronvpnUtils.getNeutronPortNameFromVpnPortFixedIp(dataBroker, oldVpnId.getValue(), ipValue);
+ updateVpnInterface(vpnId, oldVpnId, NeutronvpnUtils.getNeutronPort(dataBroker, new Uuid(PortName)),
+ isBeingAssociated, true);
}
}
sn = updateSubnetNode(subnet, null, null, null, null, vpnId);
List<Uuid> portList = sn.getPortList();
if (portList != null) {
for (Uuid port : sn.getPortList()) {
- LOG.debug("Updating vpn-interface for port {}", port.getValue());
+ LOG.debug("Updating vpn-interface for port {} isBeingAssociated {}", port.getValue(), isBeingAssociated);
updateVpnInterface(vpnId, oldVpnId, NeutronvpnUtils.getNeutronPort(dataBroker, port),
- isBeingAssociated);
+ isBeingAssociated, false);
}
}
}
import java.math.BigInteger;
import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.List;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.genius.mdsalutil.NwConstants;
import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.AlivenessMonitorService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.EtherTypes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NeutronVpnPortipPortData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPortKey;
add(id, dataObjectModificationAfter);
}
} catch (Exception e) {
- LOG.error("Error in handling update to vpnPortIpToPort for vpnName {} and IP Address {}", value.getVpnName() , value.getPortFixedip());
- e.printStackTrace();
+ LOG.error("Error in handling update to vpnPortIpToPort for vpnName {} and IP Address {}", value.getVpnName() , value.getPortFixedip(), e);
}
}
writeTx.submit();
}
} catch (Exception e) {
- LOG.error("Error in deserializing packet {} with exception {}", value, e);
+ LOG.error("Error in handling add DCN for VpnPortipToPort {}", value, e);
}
}
writeTx.submit();
}
} catch (Exception e) {
- LOG.error("Error in deserializing packet {} with exception {}", value, e);
+ LOG.error("Error in handling remove DCN for VpnPortipToPort {}", value, e);
}
}
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
import org.opendaylight.genius.datastoreutils.DataStoreJobCoordinator;
-import org.opendaylight.genius.mdsalutil.FlowEntity;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.genius.mdsalutil.MetaDataUtil;
import org.opendaylight.genius.mdsalutil.NwConstants;
import org.opendaylight.netvirt.bgpmanager.api.IBgpManager;
import org.opendaylight.netvirt.fibmanager.api.IFibManager;
import org.opendaylight.netvirt.fibmanager.api.RouteOrigin;
+import org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager;
import org.opendaylight.netvirt.vpnmanager.arp.responder.ArpResponderUtil;
import org.opendaylight.netvirt.vpnmanager.intervpnlink.InterVpnLinkUtil;
import org.opendaylight.netvirt.vpnmanager.utilities.InterfaceUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.router.dpn.list.dpn.vpninterfaces.list.RouterInterfaces;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.router.dpn.list.dpn.vpninterfaces.list.RouterInterfacesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.router.dpn.list.dpn.vpninterfaces.list.RouterInterfacesKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.id.to.vpn.instance.VpnIds;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpntargets.VpnTarget;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.IpVersionBase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.IpVersionV4;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.SubnetKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLink;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
private final OdlArputilService arpManager;
private final OdlInterfaceRpcService ifaceMgrRpcService;
private final VpnFootprintService vpnFootprintService;
+ final INeutronVpnManager neutronVpnService;
private ConcurrentHashMap<String, Runnable> vpnIntfMap = new ConcurrentHashMap<String, Runnable>();
final IFibManager fibManager,
final OdlInterfaceRpcService ifaceMgrRpcService,
final VpnFootprintService vpnFootprintService,
- final VpnOpDataSyncer vpnOpDataSyncer) {
+ final VpnOpDataSyncer vpnOpDataSyncer,
+ final INeutronVpnManager neutronVpnService) {
super(VpnInterface.class, VpnInterfaceManager.class);
this.dataBroker = dataBroker;
this.ifaceMgrRpcService = ifaceMgrRpcService;
this.vpnFootprintService = vpnFootprintService;
this.vpnOpDataSyncer = vpnOpDataSyncer;
+ this.neutronVpnService = neutronVpnService;
vpnInfUpdateTaskExecutor.scheduleWithFixedDelay(new VpnInterfaceUpdateTimerTask(),
0, VPN_INF_UPDATE_TIMER_TASK_DELAY, TIME_UNIT);
}
return;
}
} else if (vpnInterface.isIsRouterInterface()) {
- createVpnInterfaceForRouter(vpnInterface, interfaceName);
-
+ DataStoreJobCoordinator dataStoreCoordinator = DataStoreJobCoordinator.getInstance();
+ dataStoreCoordinator.enqueueJob("VPNINTERFACE-" + vpnInterface.getName(),
+ new Callable<List<ListenableFuture<Void>>>() {
+ @Override
+ public List<ListenableFuture<Void>> call() throws Exception {
+ WriteTransaction writeConfigTxn = dataBroker.newWriteOnlyTransaction();
+ createFibEntryForRouterInterface(vpnInterface, interfaceName, writeConfigTxn);
+ List<ListenableFuture<Void>> futures = new ArrayList<ListenableFuture<Void>>();
+ futures.add(writeConfigTxn.submit());
+ return futures;
+ }
+ });
} else {
LOG.error("Handling addition of VPN interface {} skipped as interfaceState is not available", interfaceName);
}
return futures;
}
});
- setupGwMacIfExternalVpn(dpId, vpnInterfaceName, vpnId, writeInvTxn, NwConstants.ADD_FLOW);
- }
-
- private void setupGwMacIfExternalVpn(BigInteger dpnId, String interfaceName, long vpnId,
- WriteTransaction writeInvTxn, int addOrRemove) {
- InstanceIdentifier<VpnIds> vpnIdsInstanceIdentifier = VpnUtil.getVpnIdToVpnInstanceIdentifier(vpnId);
- Optional<VpnIds> vpnIdsOptional = VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIdsInstanceIdentifier);
- if (vpnIdsOptional.isPresent() && vpnIdsOptional.get().isExternalVpn()) {
- Optional<String> gwMacAddressOptional = InterfaceUtils.getMacAddressForInterface(dataBroker, interfaceName);
- if (!gwMacAddressOptional.isPresent()) {
- LOG.error("Failed to get gwMacAddress for interface {}", interfaceName);
- return;
- }
- String gwMacAddress = gwMacAddressOptional.get();
- FlowEntity flowEntity = VpnUtil.buildL3vpnGatewayFlow(dpnId, gwMacAddress, vpnId);
- if (addOrRemove == NwConstants.ADD_FLOW) {
- mdsalManager.addFlowToTx(flowEntity, writeInvTxn);
- } else if (addOrRemove == NwConstants.DEL_FLOW) {
- mdsalManager.removeFlowToTx(flowEntity, writeInvTxn);
- }
- }
+ setupGwMacIfRequired(dpId, vpnInstanceName, vpnInterfaceName, writeConfigTxn, vpnId, NwConstants.ADD_FLOW);
}
protected void processVpnInterfaceAdjacencies(BigInteger dpnId, final int lPortTag, String vpnName, String interfaceName,
});
} else if (vpnInterface.isIsRouterInterface()) {
-
- List<Adjacency> adjsList = new ArrayList<>();
- Adjacencies adjs = vpnInterface.getAugmentation(Adjacencies.class);
- if (adjs != null) {
- adjsList = adjs.getAdjacency();
- for (Adjacency adj : adjsList) {
- if (adj.isPrimaryAdjacency()) {
- String primaryInterfaceIp = adj.getIpAddress();
- String prefix = VpnUtil.getIpPrefix(primaryInterfaceIp);
- fibManager.removeFibEntry(dataBroker, vpnInterface.getVpnInstanceName(), prefix, null);
- return;
- }
- }
- }
+ DataStoreJobCoordinator dataStoreCoordinator = DataStoreJobCoordinator.getInstance();
+ dataStoreCoordinator.enqueueJob("VPNINTERFACE-" + vpnInterface.getName(),
+ new Callable<List<ListenableFuture<Void>>>() {
+ @Override
+ public List<ListenableFuture<Void>> call() throws Exception {
+ WriteTransaction writeConfigTxn = dataBroker.newWriteOnlyTransaction();
+ deleteFibEntryForRouterInterface(vpnInterface, writeConfigTxn);
+ List<ListenableFuture<Void>> futures = new ArrayList<ListenableFuture<Void>>();
+ futures.add(writeConfigTxn.submit());
+ return futures;
+ }
+ });
} else {
LOG.warn("VPN interface {} was unavailable in operational data store to handle remove event",
interfaceName);
private void addArpResponderFlow(final WriteTransaction writeInvTxn, final BigInteger dpId, final int lPortTag,
final String vpnName, final String ifName, final Uuid subnetId){
LOG.trace("Creating the ARP Responder flow for VPN Interface {}",ifName);
- final Optional<String> gatewayIp = getVpnSubnetGatewayIp(subnetId);
+ final Optional<String> gatewayIp = VpnUtil.getVpnSubnetGatewayIp(dataBroker, subnetId);
if (gatewayIp.isPresent()) {
String gwIp = gatewayIp.get();
LOG.trace("VPN Interface Adjacency Subnet Gateway IP {}", gwIp);
private void removeArpResponderFlow(final WriteTransaction writeInvTxn, final Adjacency adjacency, final int lPortTag, final BigInteger dpId){
final Uuid subnetUuid = adjacency.getSubnetId();
- final Optional<String> gwIp = getVpnSubnetGatewayIp(subnetUuid);
+ final Optional<String> gwIp = VpnUtil.getVpnSubnetGatewayIp(dataBroker, subnetUuid);
if (gwIp.isPresent()) {
LOG.trace("VPNInterface adjacency Gsteway IP {} for ARP Responder removal",gwIp.get());
final String flowId = ArpResponderUtil.getFlowID(lPortTag, gwIp.get());
}
}
- private Optional<String> getVpnSubnetGatewayIp(final Uuid subnetUuid) {
- //VpnPortipToPort vpnPortipToPort = VpnUtil.getNeutronPortFromVpnPortFixedIp(dataBroker, vpnName, interfaceIp);
- Optional<String> gwIpAddress = Optional.absent();
- final SubnetKey subnetkey = new SubnetKey(subnetUuid);
- final InstanceIdentifier<Subnet> subnetidentifier = InstanceIdentifier.create(Neutron.class)
- .child(Subnets.class)
- .child(Subnet.class, subnetkey);
- final Optional<Subnet> subnet = VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetidentifier);
- if (subnet.isPresent()) {
- Class<? extends IpVersionBase> ipVersionBase = subnet.get().getIpVersion();
- if (ipVersionBase.equals(IpVersionV4.class)) {
- LOG.trace("Obtained subnet {} for vpn interface", subnet.get().getUuid().getValue());
- gwIpAddress = Optional.of(subnet.get().getGatewayIp().getIpv4Address().getValue());
- return gwIpAddress;
- }
- }
- return gwIpAddress;
- }
-
-
private void unbindService(BigInteger dpId, String vpnInstanceName, final String vpnInterfaceName,
int lPortTag, boolean isInterfaceStateDown, boolean isConfigRemoval,
WriteTransaction writeConfigTxn, WriteTransaction writeInvTxn) {
});
}
long vpnId = VpnUtil.getVpnId(dataBroker, vpnInstanceName);
- setupGwMacIfExternalVpn(dpId, vpnInterfaceName, vpnId, writeConfigTxn, NwConstants.DEL_FLOW);
+ setupGwMacIfRequired(dpId, vpnInstanceName, vpnInterfaceName, writeConfigTxn, vpnId, NwConstants.DEL_FLOW);
}
+ private void setupGwMacIfRequired(BigInteger dpId, String vpnInstanceName, final String vpnInterfaceName,
+ WriteTransaction writeConfigTxn, long vpnId, int addOrRemove) {
+ // check for router is present for the given vpn interface, if present return it immediately and
+ // do not need to proceed with adding/removing interface mac as mymac flow entry
+ Optional<VpnPortipToPort> routerInterfaceOptional = VpnUtil.getRouterInterfaceForVpnInterface(neutronVpnService,
+ dataBroker, vpnInterfaceName, vpnInstanceName);
+ if (routerInterfaceOptional.isPresent() && routerInterfaceOptional.get().getMacAddress() != null ) {
+ return;
+ }
+ VpnUtil.setupGwMacIfExternalVpn(dataBroker, mdsalManager, dpId, vpnInterfaceName,
+ vpnId, writeConfigTxn, addOrRemove);
+ }
private void removePrefixFromBGP(String rd, String prefix, String nextHop, WriteTransaction writeConfigTxn) {
try {
}
}
- protected void createVpnInterfaceForRouter(VpnInterface vpnInterface, String interfaceName) {
+ protected void createFibEntryForRouterInterface(VpnInterface vpnInterface, String interfaceName, WriteTransaction writeConfigTxn) {
if (vpnInterface == null) {
return;
}
RouterInterface routerInt = new RouterInterfaceBuilder().setUuid(vpnName)
.setMacAddress(macAddress).setIpAddress(primaryInterfaceIp).build();
- VrfEntry vrfEntry = new VrfEntryBuilder().setKey(new VrfEntryKey(prefix)).setDestPrefix(prefix)
- .setNextHopAddressList(Arrays.asList(""))
- .setLabel(label)
- .setOrigin(RouteOrigin.LOCAL.getValue())
- .addAugmentation(RouterInterface.class, routerInt).build();
-
- List<VrfEntry> vrfEntryList = Arrays.asList(vrfEntry);
- InstanceIdentifierBuilder<VrfTables> idBuilder = InstanceIdentifier.builder(FibEntries.class)
- .child(VrfTables.class, new VrfTablesKey(rd));
-
- InstanceIdentifier<VrfEntry> vrfEntryId = InstanceIdentifier.builder(FibEntries.class)
- .child(VrfTables.class, new VrfTablesKey(rd)).child(VrfEntry.class, new VrfEntryKey(prefix))
- .build();
- VpnUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntry);
+ fibManager.addFibEntryForRouterInterface(dataBroker, rd, prefix, routerInt, label, writeConfigTxn);
return;
}
}
LOG.trace("VPN Interface {} of router addition failed as primary adjacency for"
+ " this vpn interface could not be obtained", interfaceName);
}
+
+ protected void deleteFibEntryForRouterInterface(VpnInterface vpnInterface, WriteTransaction writeConfigTxn) {
+ List<Adjacency> adjsList = new ArrayList<>();
+ Adjacencies adjs = vpnInterface.getAugmentation(Adjacencies.class);
+ if (adjs != null) {
+ adjsList = adjs.getAdjacency();
+ for (Adjacency adj : adjsList) {
+ if (adj.isPrimaryAdjacency()) {
+ String primaryInterfaceIp = adj.getIpAddress();
+ String prefix = VpnUtil.getIpPrefix(primaryInterfaceIp);
+ String rd = VpnUtil.getVpnRd(dataBroker, vpnInterface.getVpnInstanceName());
+ fibManager.removeFibEntry(dataBroker, rd, prefix, writeConfigTxn);
+ return;
+ }
+ }
+ }
+ }
}
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.primitives.Ints;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.genius.mdsalutil.MDSALUtil;
-import org.opendaylight.genius.mdsalutil.NwConstants;
-import org.opendaylight.netvirt.fibmanager.api.RouteOrigin;
import org.opendaylight.genius.mdsalutil.FlowEntity;
import org.opendaylight.genius.mdsalutil.InstructionInfo;
import org.opendaylight.genius.mdsalutil.InstructionType;
+import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.genius.mdsalutil.MatchFieldType;
import org.opendaylight.genius.mdsalutil.MatchInfo;
import org.opendaylight.genius.mdsalutil.MetaDataUtil;
+import org.opendaylight.genius.mdsalutil.NwConstants;
import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.genius.utils.cache.DataStoreCache;
+import org.opendaylight.netvirt.fibmanager.api.RouteOrigin;
import org.opendaylight.netvirt.neutronvpn.api.utils.NeutronConstants;
import org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager;
import org.opendaylight.netvirt.vpnmanager.utilities.InterfaceUtils;
import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance;
import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstanceKey;
import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface;
-import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceKey;
import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceBuilder;
+import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceKey;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdPools;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPool;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.IfIndexesInterfaceMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._if.indexes._interface.map.IfIndexInterface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._if.indexes._interface.map.IfIndexInterfaceKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.TimeUnits;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.TryLockInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.TryLockInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.*;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanTagNameMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagName;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagNameKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.L3nexthop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.VpnNexthops;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.VpnNexthopsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.Adjacencies;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.PrefixToInterface;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnToExtraroute;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.RouterInterfaces;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnIdToVpnInstance;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnInstanceOpData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnInstanceToVpnId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnToExtraroute;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.Adjacencies;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.RouterInterfaces;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.VpnIds;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.VpnIdsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.VpnIdsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.PrefixesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.PrefixesKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.router.interfaces.RouterInterfaceBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.router.interfaces.RouterInterface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.router.interfaces.RouterInterfaceBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.router.interfaces.RouterInterfaceKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.RoutersKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.Networks;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.external.networks.NetworksKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdPools;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPool;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.IfIndexesInterfaceMap;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._if.indexes._interface.map.IfIndexInterface;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._if.indexes._interface.map.IfIndexInterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.L3nexthop;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.VpnNexthops;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.VpnNexthopsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NeutronVpnPortipPortData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.NeutronvpnService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.RouterInterfacesMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.Subnetmaps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPort;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPortBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.neutron.vpn.portip.port.data.VpnPortipToPortKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.IpVersionBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.IpVersionV4;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.SubnetKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinkStates;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinks;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.InterVpnLinkState;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.InterVpnLinkStateKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLink;
+import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.data.impl.schema.tree.SchemaValidationFailedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.base.Optional;
+import com.google.common.primitives.Ints;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+
public class VpnUtil {
private static final Logger LOG = LoggerFactory.getLogger(VpnUtil.class);
private static final int DEFAULT_PREFIX_LENGTH = 32;
return false;
}
+ public static void setupGwMacIfExternalVpn(DataBroker dataBroker, IMdsalApiManager mdsalManager, BigInteger dpnId, String interfaceName, long vpnId,
+ WriteTransaction writeInvTxn, int addOrRemove) {
+ InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.id.to.vpn.instance.VpnIds> vpnIdsInstanceIdentifier =
+ getVpnIdToVpnInstanceIdentifier(vpnId);
+ Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.id.to.vpn.instance.VpnIds> vpnIdsOptional = read(dataBroker,
+ LogicalDatastoreType.CONFIGURATION, vpnIdsInstanceIdentifier);
+ if (vpnIdsOptional.isPresent() && vpnIdsOptional.get().isExternalVpn()) {
+ Optional<String> gwMacAddressOptional = InterfaceUtils.getMacAddressForInterface(dataBroker, interfaceName);
+ if (!gwMacAddressOptional.isPresent()) {
+ LOG.error("Failed to get gwMacAddress for interface {}", interfaceName);
+ return;
+ }
+ String gwMacAddress = gwMacAddressOptional.get();
+ FlowEntity flowEntity = VpnUtil.buildL3vpnGatewayFlow(dpnId, gwMacAddress, vpnId);
+ if (addOrRemove == NwConstants.ADD_FLOW) {
+ mdsalManager.addFlowToTx(flowEntity, writeInvTxn);
+ } else if (addOrRemove == NwConstants.DEL_FLOW) {
+ mdsalManager.removeFlowToTx(flowEntity, writeInvTxn);
+ }
+ }
+ }
+
+ public static Optional<VpnPortipToPort> getRouterInterfaceForVpnInterface(INeutronVpnManager neutronVpnService,
+ DataBroker dataBroker, String interfaceName, String vpnName) {
+ final Optional<String> gatewayIp = getVpnSubnetGatewayIp(dataBroker, neutronVpnService.getNeutronSubnet(
+ neutronVpnService.getNeutronPort(interfaceName)
+ .getFixedIps().get(0).getSubnetId()).getUuid());
+ Optional<VpnPortipToPort> gwPortOptional = Optional.absent();
+ if (gatewayIp.isPresent()) {
+ String gwIp = gatewayIp.get();
+ gwPortOptional = Optional.fromNullable(getNeutronPortFromVpnPortFixedIp(dataBroker, vpnName, gwIp));
+ }
+ return gwPortOptional;
+ }
+
+ public static Optional<String> getVpnSubnetGatewayIp(DataBroker dataBroker, final Uuid subnetUuid) {
+ Optional<String> gwIpAddress = Optional.absent();
+ final SubnetKey subnetkey = new SubnetKey(subnetUuid);
+ final InstanceIdentifier<Subnet> subnetidentifier = InstanceIdentifier.create(Neutron.class)
+ .child(Subnets.class)
+ .child(Subnet.class, subnetkey);
+ final Optional<Subnet> subnet = read(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetidentifier);
+ if (subnet.isPresent()) {
+ Class<? extends IpVersionBase> ipVersionBase = subnet.get().getIpVersion();
+ if (ipVersionBase.equals(IpVersionV4.class)) {
+ LOG.trace("Obtained subnet {} for vpn interface", subnet.get().getUuid().getValue());
+ gwIpAddress = Optional.of(subnet.get().getGatewayIp().getIpv4Address().getValue());
+ return gwIpAddress;
+ }
+ }
+ return gwIpAddress;
+ }
+
}
<argument ref="odlInterfaceRpcService" />
<argument ref="vpnFootprintService" />
<argument ref="vpnOpDataSyncer" />
+ <argument ref="neutronVpnService" />
</bean>
<bean id="interfaceStateChangeListener"