]> xenbits.xensource.com Git - freebsd.git/commitdiff
Add SIOCGIFDOWNREASON.
authorkib <kib@FreeBSD.org>
Tue, 17 Sep 2019 18:49:13 +0000 (18:49 +0000)
committerkib <kib@FreeBSD.org>
Tue, 17 Sep 2019 18:49:13 +0000 (18:49 +0000)
The ioctl(2) is intended to provide more details about the cause of
the down for the link.

Eventually we might define a comprehensive list of codes for the
situations.  But interface also allows the driver to provide free-form
null-terminated ASCII string to provide arbitrary non-formalized
information.  Sample implementation exists for mlx5(4), where the
string is fetched from firmware controlling the port.

Reviewed by: hselasky, rrs
Sponsored by: Mellanox Technologies
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D21527

sys/net/if.c
sys/net/if.h
sys/sys/sockio.h

index cfd0c20658884da38ebfe906e986c5f484a9c5ab..8de83b2d7bc57d0df6a086c881e9a817e2834390 100644 (file)
@@ -2891,6 +2891,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
        case SIOCGIFGENERIC:
        case SIOCGIFRSSKEY:
        case SIOCGIFRSSHASH:
+       case SIOCGIFDOWNREASON:
                if (ifp->if_ioctl == NULL)
                        return (EOPNOTSUPP);
                error = (*ifp->if_ioctl)(ifp, cmd, data);
index add4df55a3d9d853eba4666915b3bd14d0690b83..fbcc06863bd4317f5ec67034dccb7527222160a5 100644 (file)
@@ -585,6 +585,16 @@ struct ifrsshash {
 
 #define        IFNET_PCP_NONE  0xff    /* PCP disabled */
 
+#define        IFDR_MSG_SIZE           64
+#define        IFDR_REASON_MSG         1
+#define        IFDR_REASON_VENDOR      2
+struct ifdownreason {
+       char            ifdr_name[IFNAMSIZ];
+       uint32_t        ifdr_reason;
+       uint32_t        ifdr_vendor;
+       char            ifdr_msg[IFDR_MSG_SIZE];
+};
+
 #endif /* __BSD_VISIBLE */
 
 #ifdef _KERNEL
index 89901bd40b447f84798707348e9a3b100551162b..447e2c884028b1e7fe704f7e7409a06d4cabccda 100644 (file)
 #define        SIOCGLANPCP     _IOWR('i', 152, struct ifreq)   /* Get (V)LAN PCP */
 #define        SIOCSLANPCP      _IOW('i', 153, struct ifreq)   /* Set (V)LAN PCP */
 
+#define        SIOCGIFDOWNREASON       _IOWR('i', 154, struct ifdownreason)
+
 #endif /* !_SYS_SOCKIO_H_ */