Fix some debug messages and condition checks in nss_virt_if
Added check on the registration return value in nss_phys_if and nss_virt_if

Change-Id: I3a238321c1bd8194658f35efedfee26771e07c47
Signed-off-by: Sakthi Vignesh Radhakrishnan <sradhakr@codeaurora.org>
diff --git a/nss_phys_if.c b/nss_phys_if.c
index e9db952..701dd0f 100755
--- a/nss_phys_if.c
+++ b/nss_phys_if.c
@@ -281,7 +281,15 @@
  */
 void nss_phys_if_register_handler(uint32_t if_num)
 {
-	nss_core_register_handler(if_num, nss_phys_if_msg_handler, NULL);
+	uint32_t ret;
+
+	ret = nss_core_register_handler(if_num, nss_phys_if_msg_handler, NULL);
+
+	if (ret == NSS_CORE_STATUS_SUCCESS) {
+		nss_info("Message handler registered for interface %d", if_num);
+	} else {
+		nss_warning("Message handler FAILED to be registered for interface %d", if_num);
+	}
 }
 
 EXPORT_SYMBOL(nss_phys_if_tx_msg);
diff --git a/nss_virt_if.c b/nss_virt_if.c
index e2a1cee..8df341a 100755
--- a/nss_virt_if.c
+++ b/nss_virt_if.c
@@ -37,13 +37,18 @@
 	/*
 	 * Sanity check the message type
 	 */
-	if (ncm->type > NSS_IPV4_MAX_MSG_TYPES) {
+	if (ncm->type > NSS_VIRT_IF_MAX_MSG_TYPES) {
 		nss_warning("%p: message type out of range: %d", nss_ctx, ncm->type);
 		return;
 	}
 
+	if (ncm->interface > NSS_MAX_VIRTUAL_INTERFACES) {
+		nss_warning("%p: response for another interface: %d", nss_ctx, ncm->interface);
+		return;
+	}
+
 	if (ncm->len > sizeof(struct nss_virt_if_msg)) {
-		nss_warning("%p: tx request for another interface: %d", nss_ctx, ncm->interface);
+		nss_warning("%p: message length too big: %d", nss_ctx, ncm->len);
 		return;
 	}
 
@@ -199,7 +204,8 @@
 	}
 
 	if (ncm->len > sizeof(struct nss_virt_if_msg)) {
-		nss_warning("%p: invalid length: %d", nss_ctx, ncm->len);
+		nss_warning("%p: invalid length: %d. Length of virt msg is %d",
+				nss_ctx, ncm->len, sizeof(struct nss_virt_if_msg));
 		return NSS_TX_FAILURE;
 	}
 
@@ -352,9 +358,16 @@
 void nss_virt_if_register_handler(void)
 {
 	int i;
+	uint32_t ret;
 	int end = NSS_VIRTUAL_IF_START + NSS_MAX_VIRTUAL_INTERFACES;
+
 	for (i = NSS_VIRTUAL_IF_START; i < end; i++) {
-		nss_core_register_handler(i, nss_virt_if_msg_handler, NULL);
+		ret = nss_core_register_handler(i, nss_virt_if_msg_handler, NULL);
+		if (ret == NSS_CORE_STATUS_SUCCESS) {
+			nss_info("Message handler successfully registered for virtual interface : %d", i);
+		} else {
+			nss_warning("Failed to register message handler for virtual interface : %d", i);
+		}
 	}
 }