[qca-nss-clients] bridgemgr changes to address LAG issue

When eth5 interface is slave of bond0, out of boundary(OOB) error is observed
when bond0 is added to bridge.  Fix is implemented to address array OOB issue.

Change-Id: I826a621d0aacfd04a0574362cd5ab8cd1304c3d3
Signed-off-by: Bhaskar Valaboju <bhaskarv@codeaurora.org>
diff --git a/bridge/nss_bridge_mgr.c b/bridge/nss_bridge_mgr.c
index ee5c2b5..7085cc6 100644
--- a/bridge/nss_bridge_mgr.c
+++ b/bridge/nss_bridge_mgr.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2019, 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.
@@ -326,7 +326,7 @@
 		struct net_device *slave, struct nss_bridge_pvt *b_pvt)
 {
 	uint32_t *port_vsi;
-	int port_id;
+	int32_t port_id;
 	int32_t ifnum;
 	int32_t lagid = 0;
 	int32_t bondid = -1;
@@ -395,7 +395,7 @@
 	}
 
 	spin_lock(&br_mgr_ctx.lock);
-	b_pvt->lag_ports[port_id] = lagid;
+	b_pvt->lag_ports[port_id - 1] = lagid;
 	spin_unlock(&br_mgr_ctx.lock);
 
 	return 0;
@@ -409,7 +409,7 @@
 		struct net_device *slave, struct nss_bridge_pvt *b_pvt)
 {
 	uint32_t *port_vsi;
-	int port_id;
+	int32_t port_id;
 	int32_t ifnum;
 	int32_t lagid = 0;
 	int32_t bondid = -1;
@@ -454,7 +454,7 @@
 	spin_lock(&br_mgr_ctx.lock);
 	port_vsi = &b_pvt->port_vsi[port_id - 1];
 
-	if (b_pvt->lag_ports[port_id] != lagid) {
+	if (b_pvt->lag_ports[port_id - 1] != lagid) {
 		spin_unlock(&br_mgr_ctx.lock);
 		return -1;
 	}
@@ -475,7 +475,7 @@
 	}
 
 	spin_lock(&br_mgr_ctx.lock);
-	b_pvt->lag_ports[port_id] = 0;
+	b_pvt->lag_ports[port_id - 1] = 0;
 	spin_unlock(&br_mgr_ctx.lock);
 
 	/*
@@ -1455,7 +1455,10 @@
 	struct net_device *dev;
 	char *dev_name;
 	char *if_name;
-	int ret = proc_dostring(table, write, buffer, lenp, ppos);
+	int32_t if_num;
+	int ret;
+
+	ret = proc_dostring(table, write, buffer, lenp, ppos);
 	if (ret)
 		return ret;
 
@@ -1470,7 +1473,7 @@
 		return -ENODEV;
 	}
 
-	uint32_t if_num = nss_cmn_get_interface_number_by_dev(dev);
+	if_num = nss_cmn_get_interface_number_by_dev(dev);
 	if (!NSS_BRIDGE_MGR_IF_IS_TYPE_PHYSICAL(if_num)) {
 		nss_bridge_mgr_warn("Only physical interfaces can be marked as WAN interface: if_num %d\n", if_num);
 		return -ENOMSG;
@@ -1490,14 +1493,17 @@
  * nss_bridge_mgr_wan_inf_del_handler
  *	Un-marks an interface as a WAN interface.
  */
-ssize_t nss_bridge_mgr_wan_intf_del_handler(struct ctl_table *table,
+static int nss_bridge_mgr_wan_intf_del_handler(struct ctl_table *table,
 						int write, void __user *buffer,
 						size_t *lenp, loff_t *ppos)
 {
 	struct net_device *dev;
 	char *dev_name;
 	char *if_name;
-	int ret = proc_dostring(table, write, buffer, lenp, ppos);
+	int32_t if_num;
+	int ret;
+
+	ret = proc_dostring(table, write, buffer, lenp, ppos);
 	if (ret)
 		return ret;
 
@@ -1512,7 +1518,7 @@
 		return -ENODEV;
 	}
 
-	uint32_t if_num = nss_cmn_get_interface_number_by_dev(dev);
+	if_num = nss_cmn_get_interface_number_by_dev(dev);
 	if (!NSS_BRIDGE_MGR_IF_IS_TYPE_PHYSICAL(if_num)) {
 		nss_bridge_mgr_warn("Only physical interfaces can be marked/unmarked, if_num: %d\n", if_num);
 		return -ENOMSG;