Merge "[qca-nss-clients] Added generic NSS APIs to set/reset nexthop."
diff --git a/bridge/nss_bridge_mgr.c b/bridge/nss_bridge_mgr.c
index 2e88def..5407193 100644
--- a/bridge/nss_bridge_mgr.c
+++ b/bridge/nss_bridge_mgr.c
@@ -423,17 +423,28 @@
 	struct net_device *slave;
 
 	/*
+	 * bond enslave/release path is protected by rtnl lock
+	 */
+	ASSERT_RTNL();
+
+	/*
+	 * Wait for RCU QS
+	 */
+	synchronize_rcu();
+
+	/*
 	 * Join each of the bonded slaves to the VSI group
 	 */
-	rcu_read_lock();
-	for_each_netdev_in_bond_rcu(bond_master, slave) {
+	for_each_netdev(&init_net, slave) {
+		if (netdev_master_upper_dev_get(slave) != bond_master) {
+			continue;
+		}
+
 		if (nss_bridge_mgr_add_bond_slave(bond_master, slave, b_pvt)) {
-			rcu_read_unlock();
 			nss_bridge_mgr_warn("%p: Failed to add slave (%s) state in Bridge\n", b_pvt, slave->name);
 			goto cleanup;
 		}
 	}
-	rcu_read_unlock();
 
 	/*
 	 * If already other bond devices are attached to bridge,
@@ -461,13 +472,16 @@
 	}
 
 cleanup:
-	rcu_read_lock();
-	for_each_netdev_in_bond_rcu(bond_master, slave) {
+
+	for_each_netdev(&init_net, slave) {
+		if (netdev_master_upper_dev_get(slave) != bond_master) {
+			continue;
+		}
+
 		if (nss_bridge_mgr_del_bond_slave(bond_master, slave, b_pvt)) {
 			nss_bridge_mgr_warn("%p: Failed to remove slave (%s) from Bridge\n", b_pvt, slave->name);
 		}
 	}
-	rcu_read_unlock();
 
 	return NOTIFY_BAD;
 }
@@ -483,18 +497,23 @@
 
 	nss_bridge_mgr_assert(b_pvt->bond_slave_num == 0);
 
+	ASSERT_RTNL();
+
+	synchronize_rcu();
+
 	/*
 	 * Remove each of the bonded slaves from the VSI group
 	 */
-	rcu_read_lock();
-	for_each_netdev_in_bond_rcu(bond_master, slave) {
+	for_each_netdev(&init_net, slave) {
+		if (netdev_master_upper_dev_get(slave) != bond_master) {
+			continue;
+		}
+
 		if (nss_bridge_mgr_del_bond_slave(bond_master, slave, b_pvt)) {
-			rcu_read_unlock();
-			nss_bridge_mgr_warn("%p: Failed to remove slave (%s) state in Bridge\n", b_pvt, slave->name);
+			nss_bridge_mgr_warn("%p: Failed to remove slave (%s) from Bridge\n", b_pvt, slave->name);
 			goto cleanup;
 		}
 	}
-	rcu_read_unlock();
 
 	/*
 	 * If more than one bond devices are attached to bridge,
@@ -521,13 +540,15 @@
 	}
 
 cleanup:
-	rcu_read_lock();
-	for_each_netdev_in_bond_rcu(bond_master, slave) {
+	for_each_netdev(&init_net, slave) {
+		if (netdev_master_upper_dev_get(slave) != bond_master) {
+			continue;
+		}
+
 		if (nss_bridge_mgr_add_bond_slave(bond_master, slave, b_pvt)) {
-			nss_bridge_mgr_warn("%p: Failed to add slave (%s) to Bridge\n", b_pvt, slave->name);
+			nss_bridge_mgr_warn("%p: Failed to add slave (%s) state in Bridge\n", b_pvt, slave->name);
 		}
 	}
-	rcu_read_unlock();
 
 	return NOTIFY_BAD;
 }
@@ -1567,7 +1588,7 @@
 	/*
 	 * Monitor bridge activity only on supported platform
 	 */
-	if (!of_machine_is_compatible("qcom,ipq807x") && !of_machine_is_compatible("qcom,ipq6018"))
+	if (!of_machine_is_compatible("qcom,ipq807x") && !of_machine_is_compatible("qcom,ipq6018") && !of_machine_is_compatible("qcom,ipq8074"))
 		return 0;
 
 	INIT_LIST_HEAD(&br_mgr_ctx.list);
diff --git a/nss_connmgr_tunipip6.c b/nss_connmgr_tunipip6.c
index 78ca225..6aab27d 100644
--- a/nss_connmgr_tunipip6.c
+++ b/nss_connmgr_tunipip6.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2014, 2017-2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014, 2017-2018, 2020, The Linux Foundation. All rights reserved.
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
  * above copyright notice and this permission notice appear in all copies.
@@ -191,17 +191,17 @@
 	struct nss_tunipip6_msg tnlmsg;
 	struct nss_tunipip6_create_msg *tnlcfg;
 	struct flowi6 *fl6;
-	uint32_t fmr_number = 0;
 	int inner_ifnum, outer_ifnum;
 	uint32_t features = 0;
 	nss_tx_status_t status;
 	struct nss_ctx_instance *nss_ctx;
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
+#if IS_ENABLED(CONFIG_MAP_E_SUPPORT)
+	uint32_t fmr_number = 0;
 	struct __ip6_tnl_fmr *fmr;
 #endif
 
 	/*
-	 * Validate netdev for ipv6-in-ipv4  Tunnel
+	 * Validate netdev for ipv4-in-ipv6 Tunnel
 	 */
 	if (netdev->type != ARPHRD_TUNNEL6 ) {
 		return NOTIFY_DONE;
@@ -282,12 +282,13 @@
 	 * Flow Label In kernel is stored in big endian format.
 	 */
 	tnlcfg->flowlabel = fl6->flowlabel;
+
+#if IS_ENABLED(CONFIG_MAP_E_SUPPORT)
 	tnlcfg->draft03 = tunnel->parms.draft03;
 
 	/*
 	 * Configure FMR table up to MAX_FMR_NUMBER, the rest will be forwarded to BR
 	 */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
 	for (fmr = tunnel->parms.fmrs; fmr && fmr_number < NSS_TUNIPIP6_MAX_FMR_NUMBER; fmr = fmr->next, fmr_number++) {
 		tnlcfg->fmr[fmr_number].ip6_prefix[0] = ntohl(fmr->ip6_prefix.s6_addr32[0]);
 		tnlcfg->fmr[fmr_number].ip6_prefix[1] = ntohl(fmr->ip6_prefix.s6_addr32[1]);
@@ -299,8 +300,9 @@
 		tnlcfg->fmr[fmr_number].ea_len = fmr->ea_len;
 		tnlcfg->fmr[fmr_number].offset = fmr->offset;
 	}
-#endif
+
 	tnlcfg->fmr_number = fmr_number;
+#endif
 
 	/*
 	 * Updating sibling_if_num for encap interface.
diff --git a/pppoe/Makefile b/pppoe/Makefile
index 8ec1f67..05e8749 100644
--- a/pppoe/Makefile
+++ b/pppoe/Makefile
@@ -4,3 +4,9 @@
 ccflags-y += -Werror
 obj-m += qca-nss-pppoe.o
 qca-nss-pppoe-objs := nss_connmgr_pppoe.o
+
+ifeq ($(CONFIG_BONDING), $(filter $(CONFIG_BONDING), y m))
+ifneq ($(findstring 4.4, $(KERNELVERSION)),)
+ccflags-y += -DBONDING_SUPPORT
+endif
+endif
diff --git a/pppoe/nss_connmgr_pppoe.c b/pppoe/nss_connmgr_pppoe.c
index b5ed3c7..91737be 100755
--- a/pppoe/nss_connmgr_pppoe.c
+++ b/pppoe/nss_connmgr_pppoe.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
  * above copyright notice and this permission notice appear in all copies.
@@ -282,7 +282,7 @@
 	 */
 	if (netif_is_bond_master(opt.dev)) {
 		int32_t bondid = -1;
-#if IS_ENABLED(CONFIG_BONDING)
+#if defined(BONDING_SUPPORT)
 		bondid = bond_get_id(opt.dev);
 #endif
 		if (bondid < 0) {