Index: /branches/rel_avx_2_7_2/src/backend/sys_cmd.c
===================================================================
--- /branches/rel_avx_2_7_2/src/backend/sys_cmd.c	(revision 8835)
+++ /branches/rel_avx_2_7_2/src/backend/sys_cmd.c	(working copy)
@@ -6605,24 +6605,90 @@
     return 0;
 }
 
-int
-set_if_state(char *interface, int up_down)
+int __avx_get_physical_nic(pci_dev_info_t **nic_vf_numa, int *len) {
+    struct va_port *port_list = NULL;
+    struct pci_root_port *rpt = NULL;
+    int ret = -1;
+
+    rpt = avxpci_module_init();
+    if (!rpt) {
+        printf("avxpci_module_init() failed\n");
+        goto cleanup;
+    }
+    port_list = get_va_port(rpt, len);
+    *nic_vf_numa = _CALLOC(pci_dev_info_t, *len);
+    if (get_pci_dev_info(*nic_vf_numa, VPT_PORT) < 0) {
+        printf("System internal error!\n");
+        goto cleanup;
+    }
+
+    ret = 0;
+
+cleanup:
+    free_va_port(port_list, *len);
+    if (rpt) {
+        avxpci_module_exit(rpt);
+    }
+    return ret;
+}
+
+int __avx_create_socket() {
+    int s;
+    if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+        printf("Unable to create socket\n");
+        return -1;
+    }
+    return s;
+}
+
+#define AVX_BEEP_JUMP(...) \
+    printf(__VA_ARGS__); \
+    goto cleanup
+
+#define AVX_CHECK_IOCTL_JUMP(sock_fd, cmd, ifr) \
+   do { \
+       if (ioctl(sock_fd, (cmd), &ifr) < 0) { \
+           perror("ioctl " #cmd); \
+           close(sock_fd); \
+           goto cleanup; \
+       } \
+   } while (0)
+
+#define AVX_ERR_BEEP_JUMP(err_no, ...) \
+    ret = err_no; \
+    AVX_BEEP_JUMP(__VA_ARGS__)
+
+#define AVX_GET_IF_NAME(if_name, nic_vf_numa, idx) \
+    char if_name[32]; \
+    snprintf( \
+        if_name, \
+        sizeof(if_name), \
+        "enp%ds%df%d", \
+        nic_vf_numa[idx].bus, \
+        nic_vf_numa[idx].dev, \
+        nic_vf_numa[idx].func \
+    )
+
+#define AVX_INIT_IFREQ(ifr) \
+    struct ifreq ifr; \
+    memset(&ifr, 0, sizeof(ifr))
+
+#define AVX_INIT_SET_IFREQ_NAME(ifr, if_name) \
+    AVX_INIT_IFREQ(ifr); \
+    strcpy(ifr.ifr_name, if_name)
+
+static int
+set_if_state(char *port, int up_down)
 {
     int ret = -1;
     int len;
     int port_idx;
-    char if_name[32];
-
-    struct va_port* port_list = NULL;
-    struct pci_root_port *rpt = NULL;
     pci_dev_info_t* nic_vf_numa = NULL;
 
-    if (!interface) {
-        printf("It seems that you do not give me any port number\n");
-        goto cleanup;
-    } else if (strcmp(interface, "mgmt") == 0) {
-        printf("mgmt port does not support this feature\n");
-        goto cleanup;
+    if (!port) {
+        AVX_ERR_BEEP_JUMP(-2, "It seems that you do not give me any port\n");
+    } else if (strcmp(port, "mgmt") == 0) {
+        AVX_ERR_BEEP_JUMP(-2, "mgmt port does not support this feature\n");
     }
 
     /* Only parse the first two digits
@@ -6631,90 +6697,57 @@
      * motherboards do not support
      * more than 99 devices
      * attached to PCI-E. */
-    sscanf(interface, "port%2d", &port_idx);
-
+    sscanf(port, "port%2d", &port_idx);
     if(port_idx < 1 || port_idx > 99) {
-        printf("It seems that you provide an invalide port number\n");
-        goto cleanup;
+        AVX_ERR_BEEP_JUMP(-3, "It seems that you provide an invalid port\n");
     }
 
-	/* Find interface name by its port number */
-    rpt = avxpci_module_init();
-    if (!rpt) {
-        printf("avxpci_module_init() failed\n");
+    if(__avx_get_physical_nic(&nic_vf_numa, &len) < 0)
         goto cleanup;
-    }
 
-    port_list = get_va_port(rpt, &len);
-    nic_vf_numa = _CALLOC(pci_dev_info_t, len);
-    if (get_pci_dev_info(nic_vf_numa, VPT_PORT) < 0) {
-        printf("System internal error!\n");
-        goto cleanup;
-    }
-    snprintf(
-        if_name,
-        sizeof(if_name),
-        "enp%ds%df%d",
-        nic_vf_numa[port_idx - 1].bus,
-        nic_vf_numa[port_idx - 1].dev,
-        nic_vf_numa[port_idx - 1].func
-	);
+    AVX_GET_IF_NAME(if_name, nic_vf_numa, port_idx - 1);
 
-    /* up/down interface */
-    int s;
-    /* Create socket */
-    if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
-        printf("Unable to create socket\n");
+    int s = __avx_create_socket();
+    if(s < 0) {
+        close(s);
         goto cleanup;
     }
 
-    /* Setup our control structures */
-    struct ifreq ifr;
-    memset(&ifr, 0, sizeof(ifr));
-    strcpy(ifr.ifr_name, if_name);
+    /* Initialize control structures */
+    AVX_INIT_SET_IFREQ_NAME(ifr, if_name);
 
     /* Get flags */
-    if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0) {
-        perror("ioctl (SIOCGIFFLAGS)");
-        close(s);
-        goto cleanup;
-    }
+    AVX_CHECK_IOCTL_JUMP(s, SIOCGIFFLAGS, ifr);
 
-    /* Check whether the interface is already in up/down state */
+    /* Check whether the port is already in up/down state */
     int sflags = ifr.ifr_flags;
     if ((up_down == IFF_UP) && (sflags & IFF_UP)) {
-        printf("Interface %s is already up\n", if_name);
-        goto cleanup;
-    } else if ((up_down == -IFF_UP) && !(sflags && IFF_UP)) {
-        printf("Interface %s is already down\n", if_name);
-        goto cleanup;
+        AVX_ERR_BEEP_JUMP(-4, "Interface %s is already up\n", port);
+    } else if ((up_down == -IFF_UP) && !(sflags & IFF_UP)) {
+        AVX_ERR_BEEP_JUMP(-5, "Interface %s is already down\n", port);
     }
 
-	/* Update interface flag */
+	/* Update port flag */
     sflags = 0;
     if (up_down == -IFF_UP) {
-        printf("Set interface %s to down\n", if_name);
+        printf("Set interface %s to down\n", port);
         up_down = -up_down;
         sflags &= ~((uint32_t)up_down);
     } else {
-        printf("Set interface %s to up\n", if_name);
+        printf("Set interface %s to up\n", port);
         sflags |= up_down;
     }
     ifr.ifr_flags = sflags;
 
     /* Set switch_flag */
-    if (ioctl(s, SIOCSIFFLAGS, &ifr) < 0) {
-        perror("ioctl (SIOCSIFFLAGS)");
-        close(s);
-        goto cleanup;
-    }
+    AVX_CHECK_IOCTL_JUMP(s, SIOCSIFFLAGS, ifr);
 
     close(s);
 
     if (ifr.ifr_flags & IFF_UP) {
-        printf("Interface %s startup\n", if_name);
+        printf("Interface %s startup\n", port);
     } else {
-        printf("Interface %s shutdown\n", if_name);
+        printf("Interface %s shutdown\n", port);
     }
 
     /* Grace period for updating interface status */
@@ -6724,12 +6757,8 @@
 
 cleanup:
     _FREE(nic_vf_numa);
-    free_va_port(port_list, len);
-    if(rpt) {
-        avxpci_module_exit(rpt);
-    }
-    if(ret == -1) {
-        printf("Operation of up/down interface is unsuccessful\n");
+    if(ret != 0) {
+        printf("Operation of shutdown/bring-up port is unsuccessful\n");
     }
     return ret;
 }
@@ -6745,3 +6774,57 @@
 {
     return set_if_state(interface, IFF_UP);
 }
+
+#define AVX_IF_SHUTDOWN_CMD_LENGTH 80
+
+char* write_if_shutdown(void)
+{
+    char *save_if = NULL;
+    int len;
+    pci_dev_info_t *nic_vf_numa = NULL;
+
+    if(__avx_get_physical_nic(&nic_vf_numa, &len) < 0)
+        goto cleanup;
+
+    size_t malloc_sz = AVX_IF_SHUTDOWN_CMD_LENGTH * len;
+    save_if = (char *) malloc(sizeof(char) * malloc_sz);
+    if(!save_if) {
+        printf("Cannot malloc save_if\n");
+        return NULL;
+    }
+
+    int i;
+    int idx = 0;
+    for(i = 0; i < len; i++) {
+        AVX_GET_IF_NAME(if_name, nic_vf_numa, i);
+
+        int s = __avx_create_socket();
+        if(s < 0) {
+            close(s);
+            goto cleanup;
+        }
+
+        AVX_INIT_SET_IFREQ_NAME(ifr, if_name);
+        if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0) {
+            close(s);
+            continue;
+        }
+
+        close(s);
+
+        if (!(ifr.ifr_flags & IFF_UP)) {
+            idx += snprintf(
+                save_if + idx,
+                malloc_sz - idx,
+                "interface shutdown port%d\n",
+                i + 1
+            );
+        }
+    }
+
+cleanup:
+    _FREE(nic_vf_numa);
+    return save_if;
+}
+
+#undef AVX_IF_SHUTDOWN_CMD_LENGTH
Index: /branches/rel_avx_2_7_2/src/backend/sys_tool.h
===================================================================
--- /branches/rel_avx_2_7_2/src/backend/sys_tool.h	(revision 8835)
+++ /branches/rel_avx_2_7_2/src/backend/sys_tool.h	(working copy)
@@ -70,6 +70,7 @@
 extern char* write_supportip(void);
 extern char* writessh(void);
 extern char* write_system_interactive(void);
+extern char* write_if_shutdown(void);
 extern int clear_nameserver(char *ip);
 extern int clear_iphost(void);
 extern int ui_clear_supportip(void);
@@ -226,4 +227,5 @@
 extern int openstack_clear_all(void);
 
 int clear_all_va_backup();
+
 #endif  /*_SYS_TOOL_*/
Index: /branches/rel_avx_2_7_2/src/backend/sys_tool.c
===================================================================
--- /branches/rel_avx_2_7_2/src/backend/sys_tool.c	(revision 8835)
+++ /branches/rel_avx_2_7_2/src/backend/sys_tool.c	(working copy)
@@ -340,13 +340,18 @@
     {
         write_monitor,
         CMD_NORMAL | CMD_ARRAYOS | CMD_GLOBAL, 
-        "#Monitor configuration" 
+        "#Monitor configuration"
     },
 
     {
         writessh,
-        CMD_NORMAL|CMD_ARRAYOS|CMD_GLOBAL, 
-        "#ssh configuration" 
+        CMD_NORMAL|CMD_ARRAYOS|CMD_GLOBAL,
+        "#ssh configuration"
+    },
+    {
+        write_if_shutdown,
+        CMD_NORMAL | CMD_ARRAYOS | CMD_GLOBAL,
+        "#interface shutdown"
     },
     /*last entry is empty*/
     {
Index: /branches/rel_avx_2_7_2/src/library/avxvainst/va_resource.c
===================================================================
--- /branches/rel_avx_2_7_2/src/library/avxvainst/va_resource.c	(revision 8835)
+++ /branches/rel_avx_2_7_2/src/library/avxvainst/va_resource.c	(working copy)
@@ -1904,7 +1904,9 @@
 	char pbuf[256] = {0}, buf[1024] = {0};
 	FILE *fp = NULL;
 	char *str = NULL, *str1 = NULL;
-    char status[32] = "status: active ";
+    char status[64] = "status: active ";
+    const char *AVX_IF_STATUS_NO_CARRIER = "status: no carrier ";
+    const char *AVX_IF_STATUS_ADMIN_DOWN = "status: down(Administratively down) ";
 	snprintf(pbuf, sizeof(pbuf), "ethtool %s", interface);
 
 	fp = popen(pbuf, "r");
@@ -1913,6 +1915,21 @@
 		return -1;
 	}
 
+    int sock_fd;
+    if ((sock_fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+        printf("Unable to create socket for getting NIC %s flags\n", interface);
+        return -1;
+    }
+    struct ifreq ifr;
+    memset(&ifr, 0, sizeof(ifr));
+    strcpy(ifr.ifr_name, interface);
+    if (ioctl(sock_fd, SIOCGIFFLAGS, &ifr) < 0) {
+        perror("ioctl SIOCGIFFLAGS");
+        close(sock_fd);
+        return -1;
+    }
+    close(sock_fd);
+
 	while(fgets(pbuf, sizeof(pbuf), fp)){
 		if((str = strstr(pbuf, "Speed")) || (str = strstr(pbuf, "Duplex")) || (str = strstr(pbuf, "Auto-negotiation"))){
 			pbuf[strlen(pbuf) - 1] = ' ';
@@ -1922,7 +1939,11 @@
 				*(str1 + strlen("Unknown!") + 1) = '\0';
 			}
 			if(strstr(pbuf, "Speed") && (str1 = strstr(pbuf, "Unknown!"))){
-				snprintf(status, sizeof(status), "status: no carrier ");
+				snprintf(
+                    status,
+                    sizeof(status),
+                    !(ifr.ifr_flags & IFF_UP) ? AVX_IF_STATUS_ADMIN_DOWN : AVX_IF_STATUS_NO_CARRIER
+                );
 			}
 			strcat(buf, str);
 		}
