[qca-nss-ecm] Redistribute flows to other LAG
              slaves when link fails on a slave.

- CRs-Fixed: 687948

Change-Id: I627eeb93c9bcdbcf8ab0ba3fad37194a98687517
Signed-off-by: Tushar Mathur <tushar@codeaurora.org>
diff --git a/ecm_front_end_ipv4.c b/ecm_front_end_ipv4.c
index 9c3857c..93c7feb 100644
--- a/ecm_front_end_ipv4.c
+++ b/ecm_front_end_ipv4.c
@@ -3701,16 +3701,6 @@
 		 * Release the assignments and re-obtain them as there may be new ones been reassigned.
 		 */
 		ecm_db_connection_assignments_release(assignment_count, assignments);
-
-		/*
-		 * Interface lists are regenerated in any situation as they determine correct packet flow
-		 * through the system - essential for correct interaction with the NSS and acceleration rule creation.
-		 */
-		DEBUG_TRACE("%p: Clearing interface lists\n", ci);
-		ecm_db_connection_from_interfaces_clear(ci);
-		ecm_db_connection_to_interfaces_clear(ci);
-		ecm_db_connection_from_nat_interfaces_clear(ci);
-		ecm_db_connection_to_nat_interfaces_clear(ci);
 	}
 
 	/*
@@ -4356,16 +4346,6 @@
 		 * Release the assignments and re-obtain them as there may be new ones been reassigned.
 		 */
 		ecm_db_connection_assignments_release(assignment_count, assignments);
-
-		/*
-		 * Interface lists are regenerated in any situation as they determine correct packet flow
-		 * through the system - essential for correct interaction with the NSS and acceleration rule creation.
-		 */
-		DEBUG_TRACE("%p: Clearing interface lists\n", ci);
-		ecm_db_connection_from_interfaces_clear(ci);
-		ecm_db_connection_to_interfaces_clear(ci);
-		ecm_db_connection_from_nat_interfaces_clear(ci);
-		ecm_db_connection_to_nat_interfaces_clear(ci);
 	}
 
 	/*
@@ -4962,16 +4942,6 @@
 		 * Release the assignments and re-obtain them as there may be new ones been reassigned.
 		 */
 		ecm_db_connection_assignments_release(assignment_count, assignments);
-
-		/*
-		 * Interface lists are regenerated in any situation as they determine correct packet flow
-		 * through the system - essential for correct interaction with the NSS and acceleration rule creation.
-		 */
-		DEBUG_TRACE("%p: Clearing interface lists\n", ci);
-		ecm_db_connection_from_interfaces_clear(ci);
-		ecm_db_connection_to_interfaces_clear(ci);
-		ecm_db_connection_from_nat_interfaces_clear(ci);
-		ecm_db_connection_to_nat_interfaces_clear(ci);
 	}
 
 	/*
diff --git a/ecm_front_end_ipv6.c b/ecm_front_end_ipv6.c
index cc97167..7b4a385 100644
--- a/ecm_front_end_ipv6.c
+++ b/ecm_front_end_ipv6.c
@@ -596,7 +596,7 @@
 					}
 
 					next_dev = bond_get_tx_dev(NULL, src_mac_addr, dest_mac_addr, src_addr, dest_addr, htons((uint16_t)ETH_P_IPV6), dest_dev);
-					if (next_dev) {
+					if (next_dev && netif_carrier_ok(next_dev)) {
 						dev_hold(next_dev);
 					} else {
 						DEBUG_WARN("Unable to obtain LAG output slave device\n");
@@ -3990,14 +3990,6 @@
 		 * Release the assignments and re-obtain them as there may be new ones been reassigned.
 		 */
 		ecm_db_connection_assignments_release(assignment_count, assignments);
-
-		/*
-		 * Interface lists are regenerated in any situation as they determine correct packet flow
-		 * through the system - essential for correct interaction with the NSS and acceleration rule creation.
-		 */
-		DEBUG_TRACE("%p: Clearing interface lists\n", ci);
-		ecm_db_connection_from_interfaces_clear(ci);
-		ecm_db_connection_to_interfaces_clear(ci);
 	}
 
 	/*
@@ -4536,14 +4528,6 @@
 		 * Release the assignments and re-obtain them as there may be new ones been reassigned.
 		 */
 		ecm_db_connection_assignments_release(assignment_count, assignments);
-
-		/*
-		 * Interface lists are regenerated in any situation as they determine correct packet flow
-		 * through the system - essential for correct interaction with the NSS and acceleration rule creation.
-		 */
-		DEBUG_TRACE("%p: Clearing interface lists\n", ci);
-		ecm_db_connection_from_interfaces_clear(ci);
-		ecm_db_connection_to_interfaces_clear(ci);
 	}
 
 	/*
@@ -5038,14 +5022,6 @@
 		 * Release the assignments and re-obtain them as there may be new ones been reassigned.
 		 */
 		ecm_db_connection_assignments_release(assignment_count, assignments);
-
-		/*
-		 * Interface lists are regenerated in any situation as they determine correct packet flow
-		 * through the system - essential for correct interaction with the NSS and acceleration rule creation.
-		 */
-		DEBUG_TRACE("%p: Clearing interface lists\n", ci);
-		ecm_db_connection_from_interfaces_clear(ci);
-		ecm_db_connection_to_interfaces_clear(ci);
 	}
 
 	/*
diff --git a/ecm_interface.c b/ecm_interface.c
index ae86266..155489d 100644
--- a/ecm_interface.c
+++ b/ecm_interface.c
@@ -1755,7 +1755,7 @@
 					next_dev = bond_get_tx_dev(NULL, src_mac_addr, dest_mac_addr,
 								   &src_addr_32, &dest_addr_32,
 								   htons((uint16_t)ETH_P_IP), dest_dev);
-					if (next_dev) {
+					if (next_dev && netif_carrier_ok(next_dev)) {
 						dev_hold(next_dev);
 					} else {
 						DEBUG_WARN("Unable to obtain LAG output slave device\n");
@@ -2192,7 +2192,11 @@
 		DEBUG_INFO("Net device: %p, CHANGE\n", dev);
 		if (!netif_carrier_ok(dev)) {
 			DEBUG_INFO("Net device: %p, CARRIER BAD\n", dev);
-			ecm_interface_dev_regenerate_connections(dev);
+			if (netif_is_bond_slave(dev)) {
+				ecm_interface_dev_regenerate_connections(dev->master);
+			} else {
+				ecm_interface_dev_regenerate_connections(dev);
+			}
 		}
 		break;