# Check interface if it's in dormant status



## onek (Sep 8, 2022)

Hi 
Is there a way to check if my system has interfaces in DORMANT status?
A query via SNMP on 1.3.6.1.2.1.2.2.1.8 returns the interface is DORMANT

The 
	
	



```
ifconfig  [interface]
```
 returns status active

Linux has the 
	
	



```
ip link show [interface]
```
 command that exposes this information.

Thanks for the help!


----------



## covacat (Sep 8, 2022)

according to bsnmp source an interface  with IFF_RUNNING and no link will be dormant so probably if ifconfig shows it as running and no carrier then its dormant


----------



## SirDice (Sep 8, 2022)

It's `ifOperStatus`, so that's administratively up or down. DORMANT isn't correct. It should be 1 for UP, 2 for DOWN and 3 for TESTING.



			https://www.alvestrand.no/objectid/1.3.6.1.2.1.2.2.1.8.html
		






						OID repository - 1.3.6.1.2.1.2.2.1.8 = {iso(1) identified-organization(3) dod(6) internet(1) mgmt(2) mib-2(1) interfaces(2) ifTable(2) ifEntry(1) ifOperStatus(8)}
					

OID repository - 1.3.6.1.2.1.2.2.1.8 = {iso(1) identified-organization(3) dod(6) internet(1) mgmt(2) mib-2(1) interfaces(2) ifTable(2) ifEntry(1) ifOperStatus(8)}




					www.oid-info.com
				





```
% ifconfig em0
em0: flags=8822<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
```
This one's DOWN.


```
% ifconfig em1
em1: flags=8863<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 9000
```
This one's UP.

Edit: reading that OID information, DORMANT is possible, that's 5. 

```
dormant(5),
notPresent(6), -- some component is missing
lowerLayerDown(7) -- down due to state of
```



> "The current operational state of the interface. The testing(3) state indicates that no operational packets can be passed. If ifAdminStatus is down(2) then ifOperStatus should be down(2). If ifAdminStatus is changed to up(1) then ifOperStatus should change to up(1) if the interface is ready to transmit and receive network traffic; *it should change to dormant(5) if the interface is waiting for external actions (such as a serial line waiting for an incoming connection)*; it should remain in the down(2) state if and only if there is a fault that prevents it from going to the up(1) state; it should remain in the notPresent(6) state if the interface has missing (typically, hardware) components."



So based on that, I'm thinking DORMANT is when the interface is UP but 'status' is still "no carrier".


----------



## covacat (Sep 8, 2022)

5 is dormant according to bsnmp source (also its referenced in kernel if_ti driver)

```
volatile u_int32_t ifOperStatus;                        /* 17 */
#define IF_OPER_STATUS_UP       1
#define IF_OPER_STATUS_DOWN     2
#define IF_OPER_STATUS_TESTING  3
#define IF_OPER_STATUS_UNKNOWN  4
#define IF_OPER_STATUS_DORMANT  5
```


----------



## SirDice (Sep 8, 2022)

covacat said:


> 5 is dormant according to bsnmp source (also its referenced in kernel if_ti driver)


Yes, the original source I quoted didn't have it. But looking at the real OID information DORMANT is possible. The explanation regarding _when_ an interface is supposed to be DORMANT isn't very clear though.


----------



## mer (Sep 8, 2022)

The example of a serial line is interesting and I can kind of make sense with it;  a dial line that is configured and enabled for incoming connections I can see it as being "adminstratively UP but since it's not currently in use"  DORMANT makes sense from a purely definitional POV.  But other types of interface?  Not sure.  Can an ethernet interface be UP without an address be considered DORMANT?


----------



## SirDice (Sep 8, 2022)

Sigh, it's been too long since I dabbled with SNMP, I really only use it for network equipment, not for hosts.

`ifAdminStatus` is the administrative status. In other words the difference between `ifconfig <int> up` and `ifconfig <int> down`. That's reflected in the flags output of ifconfig(8).

`ifOperStatus` is the operational status. That's the 'status' line in ifconfig(8). "no carrier" is DOWN, "active" is UP. Still not entirely sure what DORMANT is supposed to be. Maybe a wireless interface that's not associated yet with an AP is considered dormant?


----------



## covacat (Sep 8, 2022)

```
case LEAF_ifOperStatus:
                /*
                 * According to RFC 2863 the state should be Up if the
                 * interface is ready to transmit packets. We takes this to
                 * mean that the interface should be running and should have
                 * a carrier. If it is running and has no carrier we interpret
                 * this as 'waiting for an external event' (plugging in the
                 * cable) and hence return 'dormant'.
                 */
                if (ifp->mib.ifmd_flags & IFF_RUNNING) {
                        if (ifp->mib.ifmd_data.ifi_link_state != LINK_STATE_UP)
                                value->v.integer = 5;   /* state dormant */
                        else
                                value->v.integer = 1;   /* state up */
                } else
                        value->v.integer = 2;   /* state down */
                break;
```

/usr/src/contrib/bsnmp/snmp_mibII/mibII_interfaces.c


----------



## SirDice (Sep 8, 2022)

So, when looking at the ifconfig(8) output, it's when 'flags' says it's RUNNING and 'status' doesn't indicate 'active'. If flags = RUNNING and status = active it's operational status is UP.

A bit of pseudo code:

```
if flags = RUNNING {
  if status != active { 
    ifOperStatus = DORMANT
  } else { 
   ifOperStatus = UP
 }
} else {
  ifOperStatus = DOWN
}
```

Am I correct?


----------



## covacat (Sep 8, 2022)

SirDice said:


> So, when looking at the ifconfig(8) output, it's when 'flags' says it's RUNNING and 'status' doesn't indicate 'active'. If flags = RUNNING and status = active it's operational status is UP.
> 
> A bit of pseudo code:
> 
> ...


looks ok


----------

