BUG 5514: McastMac entries not added correctly 80/36380/2
authorVishal Thapar <vishal.thapar@ericsson.com>
Mon, 14 Mar 2016 15:57:36 +0000 (21:27 +0530)
committerVishal Thapar <vishal.thapar@ericsson.com>
Thu, 17 Mar 2016 17:53:29 +0000 (17:53 +0000)
1. Use uuid as match criteria when updating mac table entries.
2. Add logical-switch-ref as key to mac entries in yang

Change-Id: I4357f1362648b6ce72e5825ad398d0eb166f91e0
Signed-off-by: Vishal Thapar <vishal.thapar@ericsson.com>
hwvtepsouthbound/hwvtepsouthbound-api/src/main/yang/hwvtep.yang
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsLocalRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsLocalUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsRemoteRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsRemoteUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsRemoteRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsRemoteUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/MacEntriesRemoveCommand.java

index 766588ad88f83497ddc3b361bec27532a00df113..927a9b02ac8b4e4f5500f39d76fdfce57920c140 100644 (file)
@@ -247,22 +247,22 @@ module hwvtep {
             uses hwvtep-logical-switch-attributes;
         }
         list local-ucast-macs {
-            key "mac-entry-key";
+            key "mac-entry-key logical-switch-ref";
             uses hwvtep-mac-table-generic-attributes;
             uses hwvtep-ucast-mac-table-attributes;
         }
         list remote-ucast-macs {
-            key "mac-entry-key";
+            key "mac-entry-key logical-switch-ref";
             uses hwvtep-mac-table-generic-attributes;
             uses hwvtep-ucast-mac-table-attributes;
         }
         list local-mcast-macs {
-            key "mac-entry-key";
+            key "mac-entry-key logical-switch-ref";
             uses hwvtep-mac-table-generic-attributes;
             uses hwvtep-mcast-mac-table-attributes;
         }
         list remote-mcast-macs{
-            key "mac-entry-key";
+            key "mac-entry-key logical-switch-ref";
             uses hwvtep-mac-table-generic-attributes;
             uses hwvtep-mcast-mac-table-attributes;
         }
index 25e04a31abb09016535a37bd24c158e1cfc5ea67..109914e11fee0d5f0e694b08e11a09d20d998d42 100644 (file)
@@ -65,6 +65,7 @@ public class McastMacsLocalRemoveCommand extends AbstractTransactCommand {
                 //when mac entry is deleted, its referenced locator set and locators are deleted automatically.
                 //TODO: locator in config DS is not deleted
                 UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+                mcastMacsLocal.getUuidColumn().setData(macEntryUUID);
                 transaction.add(op.delete(mcastMacsLocal.getSchema()).
                         where(mcastMacsLocal.getUuidColumn().getSchema().opEqual(macEntryUUID)).build());
                 transaction.add(op.comment("McastMacLocal: Deleting " + mac.getMacEntryKey().getValue()));
index f9b2871d8271399728cab1376deefd850b28ed6b..facfecfaab382edfbb02aa4aa3af0420308f9269 100644 (file)
@@ -77,16 +77,19 @@ public class McastMacsLocalUpdateCommand extends AbstractTransactCommand {
                 LOG.trace("execute: create LocalMcastMac entry: {}", mcastMacsLocal);
                 transaction.add(op.insert(mcastMacsLocal));
                 transaction.add(op.comment("McastMacLocal: Creating " + localMcastMac.getMacEntryKey().getValue()));
-            } else {
-                LocalMcastMacs updatedMac = operationalMacOptional.get();
-                String existingMac = updatedMac.getMacEntryKey().getValue();
-                McastMacsLocal extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), McastMacsLocal.class);
-                extraMac.setMac("");
+            } else if (operationalMacOptional.get().getMacEntryUuid() != null) {
+                UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+                McastMacsLocal extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
+                                McastMacsLocal.class, null);
+                extraMac.getUuidColumn().setData(macEntryUUID);
                 LOG.trace("execute: update LocalMcastMac entry: {}", mcastMacsLocal);
                 transaction.add(op.update(mcastMacsLocal)
-                        .where(extraMac.getMacColumn().getSchema().opEqual(existingMac))
+                        .where(extraMac.getUuidColumn().getSchema().opEqual(macEntryUUID))
                         .build());
-                transaction.add(op.comment("McastMacLocal: Updating " + localMcastMac.getMacEntryKey().getValue()));
+                transaction.add(op.comment("McastMacLocal: Updating " + macEntryUUID));
+            } else {
+                LOG.warn("Unable to update localMcastMacs {} because uuid not found in the operational store",
+                                localMcastMac.getMacEntryKey().getValue());
             }
         }
     }
index 65dc3ee5fc00538e1d41cf780c0f5d4a0e21b45e..78fe8e657c0681ab840fe947f0a9c87764319d3f 100644 (file)
@@ -65,6 +65,7 @@ public class McastMacsRemoteRemoveCommand extends AbstractTransactCommand {
                 //when mac entry is deleted, its referenced locator set and locators are deleted automatically.
                 //TODO: locator in config DS is not deleted
                 UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+                mcastMacsRemote.getUuidColumn().setData(macEntryUUID);
                 transaction.add(op.delete(mcastMacsRemote.getSchema()).
                         where(mcastMacsRemote.getUuidColumn().getSchema().opEqual(macEntryUUID)).build());
                 transaction.add(op.comment("McastMacRemote: Deleting " + mac.getMacEntryKey().getValue()));
index fdeab3d0ec6cf623e3410d179d778f6aa6f14aa7..0404c94017d7b3650cd41ad60dbde0047c9f6c2c 100644 (file)
@@ -77,16 +77,19 @@ public class McastMacsRemoteUpdateCommand extends AbstractTransactCommand {
                 LOG.trace("execute: create RemoteMcastMac entry: {}", mcastMacsRemote);
                 transaction.add(op.insert(mcastMacsRemote));
                 transaction.add(op.comment("McastMacRemote: Creating " + mac.getMacEntryKey().getValue()));
-            } else {
-                RemoteMcastMacs updatedMac = operationalMacOptional.get();
-                String existingMac = updatedMac.getMacEntryKey().getValue();
-                McastMacsRemote extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), McastMacsRemote.class);
-                extraMac.setMac("");
+            } else if (operationalMacOptional.get().getMacEntryUuid() != null) {
+                UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+                McastMacsRemote extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
+                                McastMacsRemote.class, null);
+                extraMac.getUuidColumn().setData(macEntryUUID);
                 LOG.trace("execute: update RemoteMcastMac entry: {}", mcastMacsRemote);
                 transaction.add(op.update(mcastMacsRemote)
-                        .where(extraMac.getMacColumn().getSchema().opEqual(existingMac))
+                        .where(extraMac.getUuidColumn().getSchema().opEqual(macEntryUUID))
                         .build());
-                transaction.add(op.comment("McastMacRemote: Updating " + mac.getMacEntryKey().getValue()));
+                transaction.add(op.comment("McastMacRemote: Updating " + macEntryUUID));
+            } else {
+                LOG.warn("Unable to update remoteMcastMacs {} because uuid not found in the operational store",
+                                mac.getMacEntryKey().getValue());
             }
         }
     }
index a333450bc5a8b808948ce7d5560e48c623a1952c..85e175d7253b9540579b38d86071093f2487bfdb 100644 (file)
@@ -64,6 +64,7 @@ public class UcastMacsLocalRemoveCommand extends AbstractTransactCommand {
                 //when mac entry is deleted, its referenced locators are deleted automatically.
                 //locators in config DS is not deleted and user need to be removed explicitly by user.
                 UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+                ucastMacsLocal.getUuidColumn().setData(macEntryUUID);
                 transaction.add(op.delete(ucastMacsLocal.getSchema()).
                         where(ucastMacsLocal.getUuidColumn().getSchema().opEqual(macEntryUUID)).build());
                 transaction.add(op.comment("UcastMacLocal: Deleting " + mac.getMacEntryKey().getValue()));
index bd9ba06413b81014acb3c54a2e62e688e24bb2f7..f9a161e81a1137d3e0c601cb923b14aeac863729 100644 (file)
@@ -80,16 +80,19 @@ public class UcastMacsLocalUpdateCommand extends AbstractTransactCommand {
                 LOG.trace("execute: creating LocalUcastMac entry: {}", ucastMacsLocal);
                 transaction.add(op.insert(ucastMacsLocal));
                 transaction.add(op.comment("UcastMacLocal: Creating " + localUcastMac.getMacEntryKey().getValue()));
-            } else {
-                LocalUcastMacs updatedMac = operationalMacOptional.get();
-                String existingMac = updatedMac.getMacEntryKey().getValue();
-                UcastMacsLocal extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), UcastMacsLocal.class);
-                extraMac.setMac("");
+            } else if (operationalMacOptional.get().getMacEntryUuid() != null) {
+                UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+                UcastMacsLocal extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
+                                UcastMacsLocal.class, null);
+                extraMac.getUuidColumn().setData(macEntryUUID);
                 LOG.trace("execute: updating LocalUcastMac entry: {}", ucastMacsLocal);
                 transaction.add(op.update(ucastMacsLocal)
-                        .where(extraMac.getMacColumn().getSchema().opEqual(existingMac))
+                        .where(extraMac.getUuidColumn().getSchema().opEqual(macEntryUUID))
                         .build());
-                transaction.add(op.comment("UcastMacLocal: Updating " + localUcastMac.getMacEntryKey().getValue()));
+                transaction.add(op.comment("UcastMacLocal: Updating " + macEntryUUID));
+            } else {
+                LOG.warn("Unable to update localUcastMacs {} because uuid not found in the operational store",
+                                localUcastMac.getMacEntryKey().getValue());
             }
         }
     }
index fed83dc72cad2fd1fdf520add06612109049f5fd..482c0d7f2ed97ebddaafa22c746f6b9033a83654 100644 (file)
@@ -64,6 +64,7 @@ public class UcastMacsRemoteRemoveCommand extends AbstractTransactCommand {
                 //when mac entry is deleted, its referenced locators are deleted automatically.
                 //locators in config DS is not deleted and need to be removed explicitly by user.
                 UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+                ucastMacsRemote.getUuidColumn().setData(macEntryUUID);
                 transaction.add(op.delete(ucastMacsRemote.getSchema()).
                         where(ucastMacsRemote.getUuidColumn().getSchema().opEqual(macEntryUUID)).build());
                 transaction.add(op.comment("UcastMacRemote: Deleting " + mac.getMacEntryKey().getValue()));
index de841c184d5e73b6cb2220cbe213e6361a3488d0..4ae8575ae625a9b68225be64c1e8b9a9ac1cf8af 100644 (file)
@@ -78,16 +78,19 @@ public class UcastMacsRemoteUpdateCommand extends AbstractTransactCommand {
                 LOG.trace("execute: creating RemotUcastMac entry: {}", ucastMacsRemote);
                 transaction.add(op.insert(ucastMacsRemote));
                 transaction.add(op.comment("UcastMacRemote: Creating " + remoteUcastMac.getMacEntryKey().getValue()));
-            } else {
-                RemoteUcastMacs updatedMac = operationalMacOptional.get();
-                String existingMac = updatedMac.getMacEntryKey().getValue();
-                UcastMacsRemote extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), UcastMacsRemote.class);
-                extraMac.setMac("");
+            } else if (operationalMacOptional.get().getMacEntryUuid() != null) {
+                UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+                UcastMacsRemote extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
+                                UcastMacsRemote.class, null);
+                extraMac.getUuidColumn().setData(macEntryUUID);
                 LOG.trace("execute: updating RemotUcastMac entry: {}", ucastMacsRemote);
                 transaction.add(op.update(ucastMacsRemote)
-                        .where(extraMac.getMacColumn().getSchema().opEqual(existingMac))
+                        .where(extraMac.getUuidColumn().getSchema().opEqual(macEntryUUID))
                         .build());
                 transaction.add(op.comment("UcastMacRemote: Updating " + remoteUcastMac.getMacEntryKey().getValue()));
+            } else {
+                LOG.warn("Unable to update remoteMcastMacs {} because uuid not found in the operational store",
+                                remoteUcastMac.getMacEntryKey().getValue());
             }
         }
     }
index c4871a35fb266caa811ed6f16fe7982cf2306afb..50ec461f4d39c92e5075f6c65f2638168c8e2cfc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -9,36 +9,49 @@
 package org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md;
 
 import java.util.Collection;
+import java.util.Map;
 
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundConstants;
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundMapper;
 import org.opendaylight.ovsdb.lib.message.TableUpdates;
+import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
+import org.opendaylight.ovsdb.schema.hardwarevtep.LogicalSwitch;
 import org.opendaylight.ovsdb.schema.hardwarevtep.McastMacsLocal;
 import org.opendaylight.ovsdb.schema.hardwarevtep.McastMacsRemote;
 import org.opendaylight.ovsdb.schema.hardwarevtep.UcastMacsLocal;
 import org.opendaylight.ovsdb.schema.hardwarevtep.UcastMacsRemote;
 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.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalMcastMacs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalMcastMacsKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacsKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacsKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class MacEntriesRemoveCommand extends AbstractTransactionCommand {
 
+    private static final Logger LOG = LoggerFactory.getLogger(MacEntriesRemoveCommand.class);
+    Map<UUID, LogicalSwitch> lSwitchUpdatedRows;
+
     public MacEntriesRemoveCommand(HwvtepConnectionInstance key, TableUpdates updates, DatabaseSchema dbSchema) {
         super(key, updates, dbSchema);
+        lSwitchUpdatedRows = TyperUtils.extractRowsUpdated(LogicalSwitch.class, getUpdates(), getDbSchema());
     }
 
+
     @Override
     public void execute(ReadWriteTransaction transaction) {
         removeUcastMacsLocal(transaction);
@@ -51,21 +64,33 @@ public class MacEntriesRemoveCommand extends AbstractTransactionCommand {
         Collection<UcastMacsLocal> deletedLUMRows =
                 TyperUtils.extractRowsRemoved(UcastMacsLocal.class, getUpdates(), getDbSchema()).values();
         for (UcastMacsLocal lum : deletedLUMRows) {
-            InstanceIdentifier<LocalUcastMacs> lumId = getOvsdbConnectionInstance().getInstanceIdentifier()
-                    .augmentation(HwvtepGlobalAugmentation.class)
-                    .child(LocalUcastMacs.class, new LocalUcastMacsKey(new MacAddress(lum.getMac())));
-            transaction.delete(LogicalDatastoreType.OPERATIONAL, lumId);
+            if(lum.getMac() != null && lum.getLogicalSwitchColumn() != null &&
+                            lum.getLogicalSwitchColumn().getData() != null) {
+                InstanceIdentifier<LocalUcastMacs> lumId = getOvsdbConnectionInstance().getInstanceIdentifier()
+                    .augmentation(HwvtepGlobalAugmentation.class).child(LocalUcastMacs.class,
+                                    new LocalUcastMacsKey(getLogicalSwitchRef(lum.getLogicalSwitchColumn().getData()),
+                                                    getMacAddress(lum.getMac())));
+                transaction.delete(LogicalDatastoreType.OPERATIONAL, lumId);
+            } else {
+                LOG.debug("Failed to delete UcastMacLocal entry {}", lum.getUuid());
+            }
         }
     }
 
     private void removeUcastMacsRemote(ReadWriteTransaction transaction) {
         Collection<UcastMacsRemote> deletedUMRRows =
                 TyperUtils.extractRowsRemoved(UcastMacsRemote.class, getUpdates(), getDbSchema()).values();
-        for (UcastMacsRemote lum : deletedUMRRows) {
-            InstanceIdentifier<RemoteUcastMacs> lumId = getOvsdbConnectionInstance().getInstanceIdentifier()
-                    .augmentation(HwvtepGlobalAugmentation.class)
-                    .child(RemoteUcastMacs.class, new RemoteUcastMacsKey(new MacAddress(lum.getMac())));
-            transaction.delete(LogicalDatastoreType.OPERATIONAL, lumId);
+        for (UcastMacsRemote rum : deletedUMRRows) {
+            if(rum.getMac() != null && rum.getLogicalSwitchColumn() != null &&
+                            rum.getLogicalSwitchColumn().getData() != null) {
+                InstanceIdentifier<RemoteUcastMacs> rumId = getOvsdbConnectionInstance().getInstanceIdentifier()
+                    .augmentation(HwvtepGlobalAugmentation.class).child(RemoteUcastMacs.class,
+                                    new RemoteUcastMacsKey(getLogicalSwitchRef(rum.getLogicalSwitchColumn().getData()),
+                                                    getMacAddress(rum.getMac())));
+                transaction.delete(LogicalDatastoreType.OPERATIONAL, rumId);
+            } else {
+                LOG.debug("Failed to delete UcastMacRemote entry {}", rum.getUuid());
+            }
         }
     }
 
@@ -73,22 +98,46 @@ public class MacEntriesRemoveCommand extends AbstractTransactionCommand {
         Collection<McastMacsLocal> deletedLMMRows =
                 TyperUtils.extractRowsRemoved(McastMacsLocal.class, getUpdates(), getDbSchema()).values();
         for (McastMacsLocal lmm : deletedLMMRows) {
-            InstanceIdentifier<LocalMcastMacs> lumId = getOvsdbConnectionInstance().getInstanceIdentifier()
+            if(lmm.getMac() != null && lmm.getLogicalSwitchColumn() != null &&
+                            lmm.getLogicalSwitchColumn().getData() != null) {
+                InstanceIdentifier<LocalMcastMacs> lumId = getOvsdbConnectionInstance().getInstanceIdentifier()
                     .augmentation(HwvtepGlobalAugmentation.class)
-                    .child(LocalMcastMacs.class, new LocalMcastMacsKey(getMacAddress(lmm.getMac())));
-            transaction.delete(LogicalDatastoreType.OPERATIONAL, lumId);
+                    .child(LocalMcastMacs.class,
+                                    new LocalMcastMacsKey(getLogicalSwitchRef(lmm.getLogicalSwitchColumn().getData()),
+                                                    getMacAddress(lmm.getMac())));
+                transaction.delete(LogicalDatastoreType.OPERATIONAL, lumId);
+            } else {
+                LOG.debug("Failed to delete McastMacLocal entry {}", lmm.getUuid());
+            }
         }
     }
 
     private void removeMcastMacsRemote(ReadWriteTransaction transaction) {
         Collection<McastMacsRemote> deletedMMRRows =
                 TyperUtils.extractRowsRemoved(McastMacsRemote.class, getUpdates(), getDbSchema()).values();
-        for (McastMacsRemote lum : deletedMMRRows) {
-            InstanceIdentifier<RemoteMcastMacs> lumId = getOvsdbConnectionInstance().getInstanceIdentifier()
+        for (McastMacsRemote rmm : deletedMMRRows) {
+            if(rmm.getMac() != null && rmm.getLogicalSwitchColumn() != null &&
+                            rmm.getLogicalSwitchColumn().getData() != null) {
+                InstanceIdentifier<RemoteMcastMacs> lumId = getOvsdbConnectionInstance().getInstanceIdentifier()
                     .augmentation(HwvtepGlobalAugmentation.class)
-                    .child(RemoteMcastMacs.class, new RemoteMcastMacsKey(getMacAddress(lum.getMac())));
-            transaction.delete(LogicalDatastoreType.OPERATIONAL, lumId);
+                    .child(RemoteMcastMacs.class,
+                                    new RemoteMcastMacsKey(getLogicalSwitchRef(rmm.getLogicalSwitchColumn().getData()),
+                                                    getMacAddress(rmm.getMac())));
+                transaction.delete(LogicalDatastoreType.OPERATIONAL, lumId);
+            } else {
+                LOG.debug("Failed to delete McastMacRemote entry {}", rmm.getUuid());
+            }
+        }
+    }
+
+    private HwvtepLogicalSwitchRef getLogicalSwitchRef(UUID switchUUID) {
+        LogicalSwitch logicalSwitch = lSwitchUpdatedRows.get(switchUUID);
+        if (logicalSwitch != null) {
+            InstanceIdentifier<LogicalSwitches> lSwitchIid =
+                    HwvtepSouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance(), logicalSwitch);
+            return new HwvtepLogicalSwitchRef(lSwitchIid);
         }
+        return null;
     }
 
     private MacAddress getMacAddress(String mac) {