Author: ian
Date: Tue May 31 17:01:54 2016
New Revision: 301056
URL: https://svnweb.freebsd.org/changeset/base/301056

Log:
  MFC r297147, r297148, r297149, r297150, r297151:
  
    Make both the loader and kernel use the interface-mtu option if the
    dhcp server provides it.  Made up of these (semi-)related changes...
  
    [kernel...] If the dhcp server provides an interface-mtu option, parse
    the value and set that mtu on the interface.
  
    [libstand...]
  
    Garbage collect the bswap routines from libstand, use sys/endian.h.
  
    If the dhcp server delivers an interface-mtu option, parse it and store
    the value in a new global intf_mtu for use by the application.
  
    [loader...]
  
    If the dhcp server provided an interface-mtu option, transcribe the value
    to the boot.netif.mtu env var, which will be picked up by pre-existing code
    in nfs_mountroot() and used to configure the interface accordingly.
  
  PR:           187094

Deleted:
  stable/10/lib/libstand/bswap.c
Modified:
  stable/10/lib/libstand/Makefile
  stable/10/lib/libstand/bootp.c
  stable/10/lib/libstand/bootp.h
  stable/10/lib/libstand/globals.c
  stable/10/lib/libstand/net.h
  stable/10/lib/libstand/stand.h
  stable/10/sys/boot/common/dev_net.c
  stable/10/sys/boot/i386/libi386/pxe.c
  stable/10/sys/boot/libstand32/Makefile
  stable/10/sys/boot/userboot/libstand/Makefile
  stable/10/sys/nfs/bootp_subr.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libstand/Makefile
==============================================================================
--- stable/10/lib/libstand/Makefile     Tue May 31 16:58:00 2016        
(r301055)
+++ stable/10/lib/libstand/Makefile     Tue May 31 17:01:54 2016        
(r301056)
@@ -43,7 +43,7 @@ CFLAGS+=      -G0 -fno-pic -mno-abicalls
 .endif
 
 # standalone components and stuff we have modified locally
-SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c 
gets.c \
+SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c environment.c getopt.c gets.c \
        globals.c pager.c printf.c strdup.c strerror.c strtol.c strtoul.c 
random.c \
        sbrk.c twiddle.c zalloc.c zalloc_malloc.c
 

Modified: stable/10/lib/libstand/bootp.c
==============================================================================
--- stable/10/lib/libstand/bootp.c      Tue May 31 16:58:00 2016        
(r301055)
+++ stable/10/lib/libstand/bootp.c      Tue May 31 17:01:54 2016        
(r301056)
@@ -39,6 +39,7 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/types.h>
+#include <sys/endian.h>
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
 
@@ -393,6 +394,13 @@ vend_rfc1048(cp, len)
                                val = (const char *)cp;
                        strlcpy(hostname, val, sizeof(hostname));
                }
+               if (tag == TAG_INTF_MTU) {
+                       if ((val = getenv("dhcp.interface-mtu")) != NULL) {
+                               intf_mtu = (u_int)strtoul(val, NULL, 0);
+                       } else {
+                               intf_mtu = be16dec(cp);
+                       }
+               }
 #ifdef SUPPORT_DHCP
                if (tag == TAG_DHCP_MSGTYPE) {
                        if(*cp != expected_dhcpmsgtype)

Modified: stable/10/lib/libstand/bootp.h
==============================================================================
--- stable/10/lib/libstand/bootp.h      Tue May 31 16:58:00 2016        
(r301055)
+++ stable/10/lib/libstand/bootp.h      Tue May 31 17:01:54 2016        
(r301056)
@@ -91,6 +91,7 @@ struct bootp {
 #define TAG_DOMAINNAME         ((unsigned char)  15)
 #define TAG_SWAPSERVER         ((unsigned char)  16)
 #define TAG_ROOTPATH           ((unsigned char)  17)
+#define TAG_INTF_MTU           ((unsigned char)  26)
 
 #ifdef SUPPORT_DHCP
 #define TAG_REQ_ADDR           ((unsigned char)  50)

Modified: stable/10/lib/libstand/globals.c
==============================================================================
--- stable/10/lib/libstand/globals.c    Tue May 31 16:58:00 2016        
(r301055)
+++ stable/10/lib/libstand/globals.c    Tue May 31 17:01:54 2016        
(r301056)
@@ -32,5 +32,6 @@ struct        in_addr rootip;                 /* root ip addr
 struct in_addr swapip;                 /* swap ip address */
 struct in_addr gateip;                 /* swap ip address */
 n_long netmask = 0xffffff00;           /* subnet or net mask */
+u_int  intf_mtu;                       /* interface mtu from bootp/dhcp */
 int    errno;                          /* our old friend */
 

Modified: stable/10/lib/libstand/net.h
==============================================================================
--- stable/10/lib/libstand/net.h        Tue May 31 16:58:00 2016        
(r301055)
+++ stable/10/lib/libstand/net.h        Tue May 31 17:01:54 2016        
(r301056)
@@ -83,6 +83,7 @@ extern        struct in_addr swapip;
 extern struct in_addr gateip;
 extern struct in_addr nameip;
 extern n_long netmask;
+extern u_int intf_mtu;
 
 extern int debug;                      /* defined in the machdep sources */
 

Modified: stable/10/lib/libstand/stand.h
==============================================================================
--- stable/10/lib/libstand/stand.h      Tue May 31 16:58:00 2016        
(r301055)
+++ stable/10/lib/libstand/stand.h      Tue May 31 17:01:54 2016        
(r301056)
@@ -334,11 +334,6 @@ static __inline quad_t qmin(quad_t a, qu
 static __inline u_long ulmax(u_long a, u_long b) { return (a > b ? a : b); }
 static __inline u_long ulmin(u_long a, u_long b) { return (a < b ? a : b); }
 
-/* swaps (undocumented, useful?) */
-#ifdef __i386__
-extern u_int32_t       bswap32(u_int32_t x);
-extern u_int64_t       bswap64(u_int64_t x);
-#endif
 
 /* null functions for device/filesystem switches (undocumented) */
 extern int     nodev(void);

Modified: stable/10/sys/boot/common/dev_net.c
==============================================================================
--- stable/10/sys/boot/common/dev_net.c Tue May 31 16:58:00 2016        
(r301055)
+++ stable/10/sys/boot/common/dev_net.c Tue May 31 17:01:54 2016        
(r301056)
@@ -171,6 +171,12 @@ net_open(struct open_file *f, ...)
                setenv("boot.netif.gateway", inet_ntoa(gateip), 1);
                setenv("boot.nfsroot.server", inet_ntoa(rootip), 1);
                setenv("boot.nfsroot.path", rootpath, 1);
+               if (intf_mtu != 0) {
+                       char mtu[16];
+                       sprintf(mtu, "%u", intf_mtu);
+                       setenv("boot.netif.mtu", mtu, 1);
+               }
+
        }
        netdev_opens++;
        f->f_devdata = &netdev_sock;

Modified: stable/10/sys/boot/i386/libi386/pxe.c
==============================================================================
--- stable/10/sys/boot/i386/libi386/pxe.c       Tue May 31 16:58:00 2016        
(r301055)
+++ stable/10/sys/boot/i386/libi386/pxe.c       Tue May 31 17:01:54 2016        
(r301056)
@@ -312,6 +312,11 @@ pxe_open(struct open_file *f, ...)
                    sprintf(temp, "%6D", bootplayer.CAddr, ":");
                    setenv("boot.netif.hwaddr", temp, 1);
                }
+               if (intf_mtu != 0) {
+                       char mtu[16];
+                       sprintf(mtu, "%u", intf_mtu);
+                       setenv("boot.netif.mtu", mtu, 1);
+               }
                setenv("boot.nfsroot.server", inet_ntoa(rootip), 1);
                setenv("boot.nfsroot.path", rootpath, 1);
                setenv("dhcp.host-name", hostname, 1);

Modified: stable/10/sys/boot/libstand32/Makefile
==============================================================================
--- stable/10/sys/boot/libstand32/Makefile      Tue May 31 16:58:00 2016        
(r301055)
+++ stable/10/sys/boot/libstand32/Makefile      Tue May 31 17:01:54 2016        
(r301056)
@@ -45,7 +45,7 @@ CFLAGS+=      -G0 -fno-pic -mno-abicalls
 .endif
 
 # standalone components and stuff we have modified locally
-SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c 
gets.c \
+SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c environment.c getopt.c gets.c \
        globals.c pager.c printf.c strdup.c strerror.c strtol.c strtoul.c 
random.c \
        sbrk.c twiddle.c zalloc.c zalloc_malloc.c
 

Modified: stable/10/sys/boot/userboot/libstand/Makefile
==============================================================================
--- stable/10/sys/boot/userboot/libstand/Makefile       Tue May 31 16:58:00 
2016        (r301055)
+++ stable/10/sys/boot/userboot/libstand/Makefile       Tue May 31 17:01:54 
2016        (r301056)
@@ -42,7 +42,7 @@ CFLAGS+=      -msoft-float -D_STANDALONE
 .endif
 
 # standalone components and stuff we have modified locally
-SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c 
gets.c \
+SRCS+= gzguts.h zutil.h __main.c assert.c bcd.c environment.c getopt.c gets.c \
        globals.c pager.c printf.c strdup.c strerror.c strtol.c random.c \
        sbrk.c twiddle.c zalloc.c zalloc_malloc.c
 

Modified: stable/10/sys/nfs/bootp_subr.c
==============================================================================
--- stable/10/sys/nfs/bootp_subr.c      Tue May 31 16:58:00 2016        
(r301055)
+++ stable/10/sys/nfs/bootp_subr.c      Tue May 31 17:01:54 2016        
(r301056)
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/endian.h>
 #include <sys/jail.h>
 #include <sys/kernel.h>
 #include <sys/sockio.h>
@@ -154,6 +155,7 @@ struct bootpc_ifcontext {
        int dhcpquerytype;              /* dhcp type sent */
        struct in_addr dhcpserver;
        int gotdhcpserver;
+       uint16_t mtu;
 };
 
 #define TAG_MAXLEN 1024
@@ -195,6 +197,7 @@ struct bootpc_globalcontext {
 #define TAG_ROUTERS      3  /* Routers (in order of preference) */
 #define TAG_HOSTNAME    12  /* Client host name */
 #define TAG_ROOT        17  /* Root path */
+#define TAG_INTF_MTU    26  /* Interface MTU Size (RFC2132) */
 
 /* DHCP specific tags */
 #define TAG_OVERLOAD    52  /* Option Overload */
@@ -1030,7 +1033,19 @@ bootpc_adjust_interface(struct bootpc_if
                return (0);
        }
 
-       printf("Adjusted interface %s\n", ifctx->ireq.ifr_name);
+       printf("Adjusted interface %s", ifctx->ireq.ifr_name);
+
+       /* Do BOOTP interface options */
+       if (ifctx->mtu != 0) {
+               printf(" (MTU=%d%s)", ifctx->mtu, 
+                   (ifctx->mtu > 1514) ? "/JUMBO" : "");
+               ifr->ifr_mtu = ifctx->mtu;
+               error = ifioctl(bootp_so, SIOCSIFMTU, (caddr_t) ifr, td);
+               if (error != 0)
+                       panic("%s: SIOCSIFMTU, error=%d", __func__, error);
+       }
+       printf("\n");
+
        /*
         * Do enough of ifconfig(8) so that the chosen interface
         * can talk to the servers.  (just set the address)
@@ -1518,6 +1533,11 @@ bootpc_decode_reply(struct nfsv3_diskles
                p[i] = '\0';
        }
 
+       p = bootpc_tag(&gctx->tag, &ifctx->reply, ifctx->replylen,
+                      TAG_INTF_MTU);
+       if (p != NULL) {
+               ifctx->mtu = be16dec(p);
+       }
 
        printf("\n");
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to