diff options
author | ian <ian@FreeBSD.org> | 2016-05-31 17:01:54 +0000 |
---|---|---|
committer | ian <ian@FreeBSD.org> | 2016-05-31 17:01:54 +0000 |
commit | 0dfbd8e3cc8b9a97e27d9fb920bada3a7d2d5340 (patch) | |
tree | 55b1461d18254ede25580beb261018a4ca9f09af /lib | |
parent | 8d1337c667c209cb68da838288130a25cf3441d6 (diff) | |
download | FreeBSD-src-0dfbd8e3cc8b9a97e27d9fb920bada3a7d2d5340.zip FreeBSD-src-0dfbd8e3cc8b9a97e27d9fb920bada3a7d2d5340.tar.gz |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libstand/Makefile | 2 | ||||
-rw-r--r-- | lib/libstand/bootp.c | 8 | ||||
-rw-r--r-- | lib/libstand/bootp.h | 1 | ||||
-rw-r--r-- | lib/libstand/bswap.c | 57 | ||||
-rw-r--r-- | lib/libstand/globals.c | 1 | ||||
-rw-r--r-- | lib/libstand/net.h | 1 | ||||
-rw-r--r-- | lib/libstand/stand.h | 5 |
7 files changed, 12 insertions, 63 deletions
diff --git a/lib/libstand/Makefile b/lib/libstand/Makefile index 893ed68..754bac4 100644 --- a/lib/libstand/Makefile +++ b/lib/libstand/Makefile @@ -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 diff --git a/lib/libstand/bootp.c b/lib/libstand/bootp.c index 1af7bd5..f3bc816 100644 --- a/lib/libstand/bootp.c +++ b/lib/libstand/bootp.c @@ -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) diff --git a/lib/libstand/bootp.h b/lib/libstand/bootp.h index ed9101f..47e5649 100644 --- a/lib/libstand/bootp.h +++ b/lib/libstand/bootp.h @@ -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) diff --git a/lib/libstand/bswap.c b/lib/libstand/bswap.c deleted file mode 100644 index 308edda..0000000 --- a/lib/libstand/bswap.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Written by Manuel Bouyer <bouyer@netbsd.org>. - * Public domain. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$NetBSD: bswap32.c,v 1.1 1997/10/09 15:42:33 bouyer Exp $"; -static char *rcsid = "$NetBSD: bswap64.c,v 1.3 2009/03/16 05:59:21 cegger Exp $"; -#endif - -#include <sys/types.h> - -#undef bswap32 -#undef bswap64 - -u_int32_t bswap32(u_int32_t x); -u_int64_t bswap64(u_int64_t x); - -u_int32_t -bswap32(u_int32_t x) -{ - return ((x << 24) & 0xff000000 ) | - ((x << 8) & 0x00ff0000 ) | - ((x >> 8) & 0x0000ff00 ) | - ((x >> 24) & 0x000000ff ); -} - -u_int64_t -bswap64(u_int64_t x) -{ -#ifdef __LP64__ - /* - * Assume we have wide enough registers to do it without touching - * memory. - */ - return ( (x << 56) & 0xff00000000000000UL ) | - ( (x << 40) & 0x00ff000000000000UL ) | - ( (x << 24) & 0x0000ff0000000000UL ) | - ( (x << 8) & 0x000000ff00000000UL ) | - ( (x >> 8) & 0x00000000ff000000UL ) | - ( (x >> 24) & 0x0000000000ff0000UL ) | - ( (x >> 40) & 0x000000000000ff00UL ) | - ( (x >> 56) & 0x00000000000000ffUL ); -#else - /* - * Split the operation in two 32bit steps. - */ - u_int32_t tl, th; - - th = bswap32((u_int32_t)(x & 0x00000000ffffffffULL)); - tl = bswap32((u_int32_t)((x >> 32) & 0x00000000ffffffffULL)); - return ((u_int64_t)th << 32) | tl; -#endif -} diff --git a/lib/libstand/globals.c b/lib/libstand/globals.c index 0310823..8284fae 100644 --- a/lib/libstand/globals.c +++ b/lib/libstand/globals.c @@ -32,5 +32,6 @@ struct in_addr rootip; /* root ip address */ 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 */ diff --git a/lib/libstand/net.h b/lib/libstand/net.h index 94f2aab..ce7df49 100644 --- a/lib/libstand/net.h +++ b/lib/libstand/net.h @@ -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 */ diff --git a/lib/libstand/stand.h b/lib/libstand/stand.h index ebd248d..b5e0d8a 100644 --- a/lib/libstand/stand.h +++ b/lib/libstand/stand.h @@ -334,11 +334,6 @@ static __inline quad_t qmin(quad_t a, quad_t b) { return (a < b ? a : b); } 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); |