NETVIRT-1037: Upstream Fixes --- Review-3 89/66389/8
authoreupakir <kiran.n.upadhyaya@ericsson.com>
Tue, 12 Dec 2017 14:03:26 +0000 (19:33 +0530)
committerSam Hague <shague@redhat.com>
Sat, 10 Feb 2018 17:02:19 +0000 (17:02 +0000)
This reviews stores gwMac and lportTag into operational vpn interfaces,
in-case retrieval of the same through ietf-interfaces state fails while
handling an interface remove event

Change-Id: Idbeeb9486087786ec38003d198d6ffc30fe0daf5
Signed-off-by: eupakir <kiran.n.upadhyaya@ericsson.com>
vpnservice/vpnmanager/vpnmanager-api/src/main/yang/odl-l3vpn.yang
vpnservice/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/netvirt/vpnmanager/InterfaceStateChangeListener.java
vpnservice/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnInterfaceManager.java
vpnservice/vpnmanager/vpnmanager-impl/src/main/java/org/opendaylight/netvirt/vpnmanager/VpnUtil.java

index f3b40122b5aa01a29b62e53b3f1c684397f71c0b..d8757c6862f5f998dae9909d467c94ca93a62dd9 100644 (file)
@@ -220,6 +220,12 @@ module odl-l3vpn {
             leaf router-interface {
                 type boolean;
             }
+            leaf gateway-mac-address {
+                type string;
+            }
+            leaf lport-tag {
+                type uint32;
+            }
             leaf vpn-interface-state {
               description
                "This flag indicates the state of this interface in the VPN identified by vpn-name.
index b1796deaa3c2a2259d665d1b81564e91ca10d616..5f678172acd4cabd8dc475d7a64c6f65e6b690b7 100644 (file)
@@ -180,6 +180,8 @@ public class InterfaceStateChangeListener
                                         continue;
                                     }
                                     final VpnInterfaceOpDataEntry vpnInterface = optVpnInterface.get();
+                                    String gwMac = intrf.getPhysAddress() != null ? intrf.getPhysAddress().getValue()
+                                            : vpnInterface.getGatewayMacAddress();
                                     BigInteger dpnId = inputDpId;
                                     if (dpnId == null || dpnId.equals(BigInteger.ZERO)) {
                                         dpnId = vpnInterface.getDpnId();
@@ -187,7 +189,7 @@ public class InterfaceStateChangeListener
                                     final int ifIndex = intrf.getIfIndex();
                                     LOG.info("VPN Interface remove event - intfName {} onto vpnName {}"
                                                + " running oper-driver", vpnInterface.getName(), vpnName);
-                                    vpnInterfaceManager.processVpnInterfaceDown(dpnId, ifName, ifIndex, intrf,
+                                    vpnInterfaceManager.processVpnInterfaceDown(dpnId, ifName, ifIndex, gwMac,
                                             vpnInterface, false, writeConfigTxn, writeOperTxn, writeInvTxn);
                                 }
                             }));
@@ -271,8 +273,8 @@ public class InterfaceStateChangeListener
                                             if (optVpnInterface.isPresent()) {
                                                 VpnInterfaceOpDataEntry vpnOpInterface = optVpnInterface.get();
                                                 vpnInterfaceManager.processVpnInterfaceDown(dpnId, vpnIf.getName(),
-                                                        ifIndex, update, vpnOpInterface, true,
-                                                        writeConfigTxn, writeOperTxn, writeInvTxn);
+                                                        ifIndex, update.getPhysAddress().getValue(), vpnOpInterface,
+                                                        true, writeConfigTxn, writeOperTxn, writeInvTxn);
                                             } else {
                                                 LOG.error("InterfaceStateChangeListener Update DOWN - vpnInterface {}"
                                                         + " not available, ignoring event", vpnIf.getName());
index 27b9b2844fced008bfefc5eeb0308fc8fa8efc42..3587f9e730c4d5922f4b2d861a61fa0eb77fd5e3 100755 (executable)
@@ -684,7 +684,8 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
         InstanceIdentifier<Adjacencies> path = identifier.augmentation(Adjacencies.class);
         Optional<Adjacencies> adjacencies = VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, path);
         if (!adjacencies.isPresent()) {
-            addVpnInterfaceToOperational(vpnName, interfaceName, dpnId, null, writeOperTxn);
+            addVpnInterfaceToOperational(vpnName, interfaceName, dpnId, null/*adjacencies*/, (long) lportTag,
+                    null/*gwMac*/, writeOperTxn);
             return;
         }
 
@@ -753,7 +754,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                         gwMac = InterfaceUtils.getMacAddressFromInterfaceState(interfaceState);
                         if (gwMac.isPresent()) {
                             VpnUtil.setupGwMacIfExternalVpn(dataBroker, mdsalManager, dpnId, interfaceName,
-                                    vpnId, writeInvTxn, NwConstants.ADD_FLOW, interfaceState);
+                                    vpnId, writeInvTxn, NwConstants.ADD_FLOW, gwMac.get());
                             arpResponderHandler.addArpResponderFlow(dpnId, lportTag, vpnName, vpnId, interfaceName,
                                     subnetId, gatewayIp.get(), gwMac.get());
                         } else {
@@ -798,8 +799,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                     : RouteOrigin.STATIC;
             L3vpnInput input = new L3vpnInput().setNextHop(nextHop).setRd(rd).setVpnName(vpnName)
                 .setInterfaceName(interfaceName).setNextHopIp(nextHopIp).setPrimaryRd(primaryRd)
-                .setSubnetGatewayMacAddress(vpnInterfaceSubnetGwMacAddress)
-                .setRouteOrigin(origin);
+                .setSubnetGatewayMacAddress(vpnInterfaceSubnetGwMacAddress).setRouteOrigin(origin);
             Adjacency operationalAdjacency = null;
             try {
                 operationalAdjacency = registeredPopulator.createOperationalAdjacency(input);
@@ -817,7 +817,8 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
         }
 
         AdjacenciesOp aug = VpnUtil.getVpnInterfaceOpDataEntryAugmentation(value);
-        addVpnInterfaceToOperational(vpnName, interfaceName, dpnId, aug, writeOperTxn);
+        addVpnInterfaceToOperational(vpnName, interfaceName, dpnId, aug, lportTag, vpnInterfaceSubnetGwMacAddress,
+                writeOperTxn);
 
         L3vpnInput input = new L3vpnInput().setNextHopIp(nextHopIp).setL3vni(l3vni).setPrimaryRd(primaryRd)
                 .setGatewayMac(gwMac.isPresent() ? gwMac.get() : null).setInterfaceName(interfaceName)
@@ -835,9 +836,9 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
     }
 
     private void addVpnInterfaceToOperational(String vpnName, String interfaceName, BigInteger dpnId, AdjacenciesOp aug,
-            WriteTransaction writeOperTxn) {
+                                              long lportTag, String gwMac, WriteTransaction writeOperTxn) {
         VpnInterfaceOpDataEntry opInterface =
-              VpnUtil.getVpnInterfaceOpDataEntry(interfaceName, vpnName, aug, dpnId, Boolean.FALSE);
+              VpnUtil.getVpnInterfaceOpDataEntry(interfaceName, vpnName, aug, dpnId, Boolean.FALSE, lportTag, gwMac);
         InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId = VpnUtil
             .getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
         writeOperTxn.put(LogicalDatastoreType.OPERATIONAL, interfaceId, opInterface,
@@ -1164,87 +1165,90 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
     private void removeVpnInterfaceCall(final InstanceIdentifier<VpnInterface> identifier,
                                 final VpnInterface vpnInterface, final String vpnName,
                                 final String interfaceName) {
-        Interface interfaceState = InterfaceUtils.getInterfaceStateFromOperDS(dataBroker, interfaceName);
-        if (interfaceState != null) {
-            removeVpnInterfaceFromVpn(identifier, vpnInterface, vpnName, interfaceName);
-        } else if (Boolean.TRUE.equals(vpnInterface.isRouterInterface())) {
+        if (Boolean.TRUE.equals(vpnInterface.isRouterInterface())) {
             jobCoordinator.enqueueJob("VPNINTERFACE-" + vpnInterface.getName() + vpnName, () -> {
                 WriteTransaction writeConfigTxn = dataBroker.newWriteOnlyTransaction();
                 deleteFibEntryForRouterInterface(vpnInterface, writeConfigTxn, vpnName);
                 LOG.info("remove: Router interface {} for vpn {}", interfaceName, vpnName);
                 ListenableFuture<Void> futures = writeConfigTxn.submit();
                 String errorText = "removeVpnInterfaceCall: Exception encountered while submitting writeConfigTxn"
-                     + " for interface " + vpnInterface.getName() + " on vpn " + vpnName;
+                        + " for interface " + vpnInterface.getName() + " on vpn " + vpnName;
                 ListenableFutures.addErrorLogging(futures, LOG, errorText);
                 return Collections.singletonList(futures);
             });
         } else {
-            LOG.error("remove: VPN interface {} on dpn {} for vpn {} was unavailable in operational data "
-                    + "store to handle remove event", interfaceName, vpnInterface.getDpnId(), vpnName);
+            Interface interfaceState = InterfaceUtils.getInterfaceStateFromOperDS(dataBroker, interfaceName);
+            removeVpnInterfaceFromVpn(identifier, vpnInterface, vpnName, interfaceName, interfaceState);
         }
     }
 
     @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
     private void removeVpnInterfaceFromVpn(final InstanceIdentifier<VpnInterface> identifier,
                                 final VpnInterface vpnInterface, final String vpnName,
-                                final String interfaceName) {
+                                final String interfaceName, final Interface interfaceState) {
         LOG.info("remove: VPN Interface remove event - intfName {} vpn {} dpn {}" ,vpnInterface.getName(),
                 vpnName, vpnInterface.getDpnId());
         removeInterfaceFromUnprocessedList(identifier, vpnInterface);
-        Interface interfaceState = InterfaceUtils.getInterfaceStateFromOperDS(dataBroker, interfaceName);
-        if (interfaceState != null) {
-            BigInteger dpId = BigInteger.ZERO;
-            try {
-                dpId = InterfaceUtils.getDpIdFromInterface(interfaceState);
-            } catch (NumberFormatException | IllegalStateException e) {
-                LOG.error("remove: Unable to retrieve dpnId from interface operational data store for interface {}"
-                        + " on dpn {} for vpn {} Fetching from vpn interface op data store. ", interfaceName,
-                        vpnInterface.getDpnId(), vpnName, e);
-                dpId = BigInteger.ZERO;
-            }
-            final int ifIndex = interfaceState.getIfIndex();
-            final BigInteger dpnId = dpId;
-            jobCoordinator.enqueueJob("VPNINTERFACE-" + interfaceName + vpnName,
-                () -> {
-                    List<ListenableFuture<Void>> futures = new ArrayList<>();
-                    futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeConfigTxn -> {
-                        futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeOperTxn -> {
-                            futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeInvTxn -> {
-                                LOG.info("remove: - intfName {} onto vpnName {} running config-driven", interfaceName,
-                                        vpnName);
-                                InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId =
-                                        VpnUtil.getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
-                                final Optional<VpnInterfaceOpDataEntry> optVpnInterface =
-                                        VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, interfaceId);
+        jobCoordinator.enqueueJob("VPNINTERFACE-" + interfaceName + vpnName,
+            () -> {
+                List<ListenableFuture<Void>> futures = new ArrayList<>();
+                futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeConfigTxn -> {
+                    futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeOperTxn -> {
+                        futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeInvTxn -> {
+                            LOG.info("remove: - intfName {} onto vpnName {} running config-driven", interfaceName,
+                                    vpnName);
+                            BigInteger dpId = BigInteger.ZERO;
+                            int ifIndex = 0;
+                            String gwMacAddress = null;
+                            InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId =
+                                    VpnUtil.getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
+                            final Optional<VpnInterfaceOpDataEntry> optVpnInterface =
+                                    VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, interfaceId);
+                            if (interfaceState != null) {
+                                try {
+                                    dpId = InterfaceUtils.getDpIdFromInterface(interfaceState);
+                                } catch (NumberFormatException | IllegalStateException e) {
+                                    LOG.error("remove: Unable to retrieve dpnId from interface operational data store"
+                                            + " for interface {} on dpn {} for vpn {} Fetching"
+                                            + " from vpn interface op data store. ", interfaceName,
+                                            vpnInterface.getDpnId(), vpnName, e);
+                                    dpId = BigInteger.ZERO;
+                                }
+                                ifIndex = interfaceState.getIfIndex();
+                                gwMacAddress = interfaceState.getPhysAddress().getValue();
+                            } else {
+                                LOG.info("remove: Interface state not available for {}. Trying to fetch data from"
+                                        + " vpn interface op.", interfaceName);
                                 if (optVpnInterface.isPresent()) {
                                     VpnInterfaceOpDataEntry vpnOpInterface = optVpnInterface.get();
-                                    BigInteger finalDpnId =
-                                            dpnId.equals(BigInteger.ZERO) ? vpnOpInterface.getDpnId() : dpnId;
-                                    processVpnInterfaceDown(finalDpnId, interfaceName, ifIndex, interfaceState,
-                                            vpnOpInterface, false, writeConfigTxn, writeOperTxn, writeInvTxn);
-                                    LOG.info(
-                                            "remove: Removal of vpn interface {} on dpn {} for vpn {} processed "
-                                                    + "successfully",
-                                            interfaceName, vpnInterface.getDpnId(), vpnName);
+                                    dpId = vpnOpInterface.getDpnId();
+                                    ifIndex = vpnOpInterface.getLportTag().intValue();
+                                    gwMacAddress = vpnOpInterface.getGatewayMacAddress();
                                 } else {
-                                    LOG.warn(
-                                            "remove: VPN interface {} on dpn {} for vpn {} was unavailable in "
-                                                    + "operational data store to handle remove event",
-                                            interfaceName, vpnInterface.getDpnId(), vpnName);
+                                    LOG.error("remove: Handling removal of VPN interface {} for vpn {} skipped"
+                                            + " as interfaceState and vpn interface op is not available",
+                                            interfaceName, vpnName);
+                                    return;
                                 }
-                            }));
+                            }
+                            processVpnInterfaceDown(dpId, interfaceName, ifIndex, gwMacAddress,
+                                    optVpnInterface.isPresent() ? optVpnInterface.get() : null, false,
+                                    writeConfigTxn, writeOperTxn, writeInvTxn);
+                            LOG.info(
+                                    "remove: Removal of vpn interface {} on dpn {} for vpn {} processed "
+                                            + "successfully",
+                                    interfaceName, vpnInterface.getDpnId(), vpnName);
                         }));
                     }));
-
-                    return futures;
-                });
-        }
+                }));
+                return futures;
+            });
     }
 
     protected void processVpnInterfaceDown(BigInteger dpId,
                                            String interfaceName,
                                            int lportTag,
-                                           Interface interfaceState,
+                                           String gwMac,
                                            VpnInterfaceOpDataEntry vpnOpInterface,
                                            boolean isInterfaceStateDown,
                                            WriteTransaction writeConfigTxn,
@@ -1265,7 +1269,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                         null);
                 final boolean isBgpVpnInternetVpn = VpnUtil.isBgpVpnInternet(dataBroker, vpnName);
                 removeAdjacenciesFromVpn(dpId, lportTag, interfaceName, vpnName,
-                                 vpnId, writeConfigTxn, writeOperTxn, writeInvTxn, interfaceState);
+                                 vpnId, gwMac, writeConfigTxn, writeOperTxn, writeInvTxn);
                 if (interfaceManager.isExternalInterface(interfaceName)) {
                     processExternalVpnInterface(interfaceName, vpnName, vpnId, dpId, lportTag, writeInvTxn,
                             NwConstants.DEL_FLOW);
@@ -1289,9 +1293,9 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
     }
 
     private void removeAdjacenciesFromVpn(final BigInteger dpnId, final int lportTag, final String interfaceName,
-                                          final String vpnName, final long vpnId, WriteTransaction writeConfigTxn,
-                                          final WriteTransaction writeOperTxn,
-                                          final WriteTransaction writeInvTxn, Interface interfaceState) {
+                                          final String vpnName, final long vpnId, String gwMac,
+                                          WriteTransaction writeConfigTxn, final WriteTransaction writeOperTxn,
+                                          final WriteTransaction writeInvTxn) {
         //Read NextHops
         InstanceIdentifier<VpnInterfaceOpDataEntry> identifier = VpnUtil
                 .getVpnInterfaceOpDataEntryIdentifier(interfaceName, vpnName);
@@ -1336,7 +1340,7 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                                 // So a connected-mac-address was used for this subnet and we need
                                 // to remove the flows for the same here from the L3_GW_MAC_TABLE.
                                 VpnUtil.setupGwMacIfExternalVpn(dataBroker, mdsalManager, dpnId, interfaceName,
-                                        vpnId, writeInvTxn, NwConstants.DEL_FLOW, interfaceState);
+                                        vpnId, writeInvTxn, NwConstants.DEL_FLOW, gwMac);
 
                             }
                             arpResponderHandler.removeArpResponderFlow(dpnId, lportTag, interfaceName, vpnName, vpnId,
@@ -1785,7 +1789,8 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
             AdjacenciesOp aug = VpnUtil.getVpnInterfaceOpDataEntryAugmentation(adjacencies);
             VpnInterfaceOpDataEntry newVpnIntf =
                 VpnUtil.getVpnInterfaceOpDataEntry(currVpnIntf.getName(), currVpnIntf.getVpnInstanceName(),
-                    aug, dpnId, currVpnIntf.isScheduledForRemove());
+                    aug, dpnId, currVpnIntf.isScheduledForRemove(), currVpnIntf.getLportTag(),
+                        currVpnIntf.getGatewayMacAddress());
 
             writeOperTxn.merge(LogicalDatastoreType.OPERATIONAL, identifier, newVpnIntf, true);
         }
@@ -1821,8 +1826,8 @@ public class VpnInterfaceManager extends AsyncDataTreeChangeListenerBase<VpnInte
                             AdjacenciesOp aug = VpnUtil.getVpnInterfaceOpDataEntryAugmentation(adjacencies);
                             VpnInterfaceOpDataEntry newVpnIntf = VpnUtil
                                     .getVpnInterfaceOpDataEntry(currVpnIntf.getName(),
-                                    currVpnIntf.getVpnInstanceName(),
-                                    aug, dpnId, currVpnIntf.isScheduledForRemove());
+                                    currVpnIntf.getVpnInstanceName(), aug, dpnId, currVpnIntf.isScheduledForRemove(),
+                                            currVpnIntf.getLportTag(), currVpnIntf.getGatewayMacAddress());
 
                             writeOperTxn.merge(LogicalDatastoreType.OPERATIONAL, identifier, newVpnIntf, true);
                             if (adj.getNextHopIpList() != null) {
index 6315f07d204b4ae895b631dd1694dfe26ee08428..8b1f05e101ea0f91e46dc4890a4b86d275b57c87 100755 (executable)
@@ -77,7 +77,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.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.action.types.rev131112.action.list.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
@@ -235,11 +234,10 @@ public final class VpnUtil {
 
     static VpnInterfaceOpDataEntry getVpnInterfaceOpDataEntry(String intfName, String vpnName,
                                         AdjacenciesOp aug, BigInteger dpnId,
-                                        Boolean isSheduledForRemove) {
+                                        Boolean isSheduledForRemove, long lportTag, String gwMac) {
         return new VpnInterfaceOpDataEntryBuilder().setKey(new VpnInterfaceOpDataEntryKey(intfName, vpnName))
-            .setDpnId(dpnId)
-            .setScheduledForRemove(isSheduledForRemove).addAugmentation(AdjacenciesOp.class, aug)
-            .build();
+            .setDpnId(dpnId).setScheduledForRemove(isSheduledForRemove).addAugmentation(AdjacenciesOp.class, aug)
+                .setLportTag(lportTag).setGatewayMacAddress(gwMac).build();
     }
 
     static Optional<VpnInterfaceOpDataEntry> getVpnInterfaceOpDataEntry(DataBroker broker,
@@ -1404,22 +1402,18 @@ public final class VpnUtil {
     }
 
     public static void setupGwMacIfExternalVpn(DataBroker dataBroker, IMdsalApiManager mdsalManager, BigInteger dpnId,
-            String interfaceName, long vpnId, WriteTransaction writeInvTxn, int addOrRemove, org.opendaylight.yang.gen
-            .v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface interfaceState) {
+            String interfaceName, long vpnId, WriteTransaction writeInvTxn, int addOrRemove, String gwMac) {
         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()) {
-            PhysAddress gwMacAddress = interfaceState.getPhysAddress();
-            if (gwMacAddress == null) {
+            if (gwMac == null) {
                 LOG.error("setupGwMacIfExternalVpn: Failed to get gwMacAddress for interface {} on dpn {} vpn {}",
                         interfaceName, dpnId.toString(), vpnIdsOptional.get().getVpnInstanceName());
                 return;
             }
-
-            String gwMac = gwMacAddress.getValue();
             FlowEntity flowEntity = VpnUtil.buildL3vpnGatewayFlow(dpnId, gwMac, vpnId, VpnConstants.INVALID_ID);
             if (addOrRemove == NwConstants.ADD_FLOW) {
                 mdsalManager.addFlowToTx(flowEntity, writeInvTxn);