[qca-nss-qdisc] Verify qdisc attached to bridge before attach/detach

Change-Id: I386f197e2c5d87df9661aedeef6521e4c6078eb5
Signed-off-by: Sakthi Vignesh Radhakrishnan <sradhakr@codeaurora.org>
diff --git a/nss_qdisc/nss_qdisc.c b/nss_qdisc/nss_qdisc.c
index 375d667..d101a4b 100644
--- a/nss_qdisc/nss_qdisc.c
+++ b/nss_qdisc/nss_qdisc.c
@@ -2357,8 +2357,7 @@
 		br_num = nss_cmn_get_interface_number(nss_qdisc_ctx, br);
 		br_qdisc = br->qdisc;
 		/*
-		 * TODO: Properly ensure that the interface and bridge are
-		 * shaped by us.
+		 * Ensure the interfaces involved are known to NSS.
 		 */
 		if (if_num < 0 || br_num < 0) {
 			nss_qdisc_info("No action taken since if_num is %d for %s "
@@ -2368,6 +2367,16 @@
 		}
 
 		/*
+		 * Ensure we have nss qdisc configured on the bridge
+		 */
+		struct nss_qdisc *nq = (struct nss_qdisc *)qdisc_priv(br_qdisc);
+		if ((nq->mode != NSS_QDISC_MODE_NSS) && (nq->mode != NSS_QDISC_MODE_PPE)) {
+			nss_qdisc_info("No action taken since nss qdisc is not configured on "
+					" %s interface\n", br->name);
+			break;
+		}
+
+		/*
 		 * Call attach or detach according as per event type.
 		 */
 		if (event == NETDEV_BR_JOIN) {