On Fri, Nov 23, 2012 at 04:04:20PM +0000, Stuart Henderson wrote:
> This adds an ioctl to retrieve if_hardmtu, and adds code to
> display it via ifconfig hwfeatures.
> 
> $ ifconfig em0 hwfeatures
> em0: flags=8b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST> mtu 
> 1500
>       hwfeatures=30<VLAN_MTU,VLAN_HWTAGGING> hardmtu=16110
>       lladdr f0:de:f1:f9:a7:52
>       priority: 0
>       trunk: trunkdev trunk0
>       media: Ethernet autoselect (100baseTX full-duplex,rxpause,txpause)
>       status: active
> 
> Added bonus, mention a few other existing ioctls in netintro(4).
> 
> Any comments/bikeshedding about display format/OKs?
> 

I would replace the "=" after hardmtu with a single whitespace to
follow the common ifconfig style.  The "=" is only used for flags-type
fields.

The diff looks fine to me.

> 
> Index: sys/net/if.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if.c,v
> retrieving revision 1.247
> diff -u -p -r1.247 if.c
> --- sys/net/if.c      23 Oct 2012 17:41:00 -0000      1.247
> +++ sys/net/if.c      23 Nov 2012 15:55:02 -0000
> @@ -1268,6 +1268,10 @@ ifioctl(struct socket *so, u_long cmd, c
>               ifr->ifr_mtu = ifp->if_mtu;
>               break;
>  
> +     case SIOCGIFHARDMTU:
> +             ifr->ifr_hardmtu = ifp->if_hardmtu;
> +             break;
> +
>       case SIOCGIFDATA:
>               error = copyout((caddr_t)&ifp->if_data, ifr->ifr_data,
>                   sizeof(ifp->if_data));
> Index: sys/net/if.h
> ===================================================================
> RCS file: /cvs/src/sys/net/if.h,v
> retrieving revision 1.136
> diff -u -p -r1.136 if.h
> --- sys/net/if.h      11 Nov 2012 04:45:37 -0000      1.136
> +++ sys/net/if.h      23 Nov 2012 15:55:02 -0000
> @@ -639,6 +639,7 @@ struct    ifreq {
>  #define      ifr_flags       ifr_ifru.ifru_flags     /* flags */
>  #define      ifr_metric      ifr_ifru.ifru_metric    /* metric */
>  #define      ifr_mtu         ifr_ifru.ifru_metric    /* mtu (overload) */
> +#define      ifr_hardmtu     ifr_ifru.ifru_metric    /* hardmtu (overload) */
>  #define      ifr_media       ifr_ifru.ifru_metric    /* media options 
> (overload) */
>  #define      ifr_rdomainid   ifr_ifru.ifru_metric    /* VRF instance 
> (overload) */
>  #define      ifr_data        ifr_ifru.ifru_data      /* for use by interface 
> */
> Index: sys/net/if_gre.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_gre.c,v
> retrieving revision 1.58
> diff -u -p -r1.58 if_gre.c
> --- sys/net/if_gre.c  14 Apr 2012 09:39:47 -0000      1.58
> +++ sys/net/if_gre.c  23 Nov 2012 15:55:02 -0000
> @@ -475,6 +475,9 @@ gre_ioctl(struct ifnet *ifp, u_long cmd,
>       case SIOCGIFMTU:
>               ifr->ifr_mtu = sc->sc_if.if_mtu;
>               break;
> +     case SIOCGIFHARDMTU:
> +             ifr->ifr_hardmtu = sc->sc_if.if_hardmtu;
> +             break;
>       case SIOCADDMULTI:
>       case SIOCDELMULTI:
>               if (ifr == 0) {
> Index: sys/net/if_spppsubr.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_spppsubr.c,v
> retrieving revision 1.98
> diff -u -p -r1.98 if_spppsubr.c
> --- sys/net/if_spppsubr.c     24 Jul 2012 15:16:20 -0000      1.98
> +++ sys/net/if_spppsubr.c     23 Nov 2012 15:55:02 -0000
> @@ -1117,6 +1117,11 @@ sppp_ioctl(struct ifnet *ifp, u_long cmd
>               ifr->ifr_mtu = ifp->if_mtu;
>               break;
>  #endif
> +#ifdef SIOCGIFHARDMTU
> +     case SIOCGIFHARDMTU:
> +             ifr->ifr_hardmtu = ifp->if_hardmtu;
> +             break;
> +#endif
>  #ifdef SLIOCGETMTU
>       case SLIOCGETMTU:
>               *(short*)data = ifp->if_mtu;
> Index: sys/sys/sockio.h
> ===================================================================
> RCS file: /cvs/src/sys/sys/sockio.h,v
> retrieving revision 1.49
> diff -u -p -r1.49 sockio.h
> --- sys/sys/sockio.h  26 Nov 2011 23:38:18 -0000      1.49
> +++ sys/sys/sockio.h  23 Nov 2012 15:59:06 -0000
> @@ -181,6 +181,8 @@
>  #define SIOCSETKALIVE        _IOW('i', 163, struct ifkalivereq)
>  #define SIOCGETKALIVE        _IOWR('i', 164, struct ifkalivereq)
>  
> +#define      SIOCGIFHARDMTU  _IOWR('i', 165, struct ifreq)   /* get ifnet 
> hardmtu */
> +
>  #define      SIOCSVH         _IOWR('i', 245, struct ifreq)   /* set carp 
> param */
>  #define      SIOCGVH         _IOWR('i', 246, struct ifreq)   /* get carp 
> param */
>  
> Index: sbin/ifconfig/ifconfig.c
> ===================================================================
> RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
> retrieving revision 1.257
> diff -u -p -w -r1.257 ifconfig.c
> --- sbin/ifconfig/ifconfig.c  6 Sep 2012 19:41:59 -0000       1.257
> +++ sbin/ifconfig/ifconfig.c  23 Nov 2012 16:01:07 -0000
> @@ -4722,6 +4722,11 @@ printifhwfeatures(const char *unused, in
>       if (ioctl(s, SIOCGIFDATA, (caddr_t)&ifr) == -1)
>               err(1, "SIOCGIFDATA");
>       printb("\thwfeatures", (u_int)ifrdat.ifi_capabilities, HWFEATURESBITS);
> +
> +     if (ioctl(s, SIOCGIFHARDMTU, (caddr_t)&ifr) != -1) {
> +             if (ifr.ifr_hardmtu)
> +                     printf(" hardmtu %lu", ifr.ifr_hardmtu);
> +     }
>       putchar('\n');
>  }
>  #endif
> Index: share/man/man4/netintro.4
> ===================================================================
> RCS file: /cvs/src/share/man/man4/netintro.4,v
> retrieving revision 1.41
> diff -u -p -r1.41 netintro.4
> --- share/man/man4/netintro.4 3 Dec 2011 23:01:21 -0000       1.41
> +++ share/man/man4/netintro.4 23 Nov 2012 16:03:17 -0000
> @@ -280,6 +280,12 @@ incoming packets are no longer received.
>  When marked up again, the interface is reinitialized.
>  .It Dv SIOCGIFFLAGS Fa "struct ifreq *"
>  Get the interface flags.
> +.It Dv SIOCGIFXFLAGS Fa "struct ifreq *"
> +Get the extended interface flags.
> +.It Dv SIOCGIFMTU Fa "struct ifreq *"
> +Get the current MTU of the interface.
> +.It Dv SIOCGIFHARDMTU Fa "struct ifreq *"
> +Get the maximum hardware MTU of the interface.
>  .It Dv SIOCSIFMEDIA Fa "struct ifreq *"
>  Set the interface media settings.
>  See
> @@ -317,6 +323,9 @@ new static routes added to the kernel us
>  The value is in the range of 0 to 16 with smaller numbers being better.
>  .It Dv SIOCGIFPRIORITY Fa "struct ifreq *"
>  Get the interface priority.
> +.It Dv SIOCGIFRDOMAIN Fa "struct ifreq *"
> +Get the interface routing domain.
> +This identifies which routing table is used for the interface.
>  .It Dv SIOCAIFADDR Fa "struct ifaliasreq *"
>  An interface may have more than one address associated with it
>  in some protocols.

Reply via email to