aboutsummaryrefslogtreecommitdiff
path: root/lib/libstand
Commit message (Collapse)AuthorAgeFilesLines
* Move lib/libstand to sys/boot/libsaWarner Losh2017-10-1282-18677/+0
| | | | | | | | | | Move the sources to sys/boot. Make adjustments related to the move. Kill LIBSTAND_SRC since it's no longer needed. Sponsored by: Netflix Notes: svn path=/head/; revision=324551
* Add $FreeBSD$ to ancient sources that it's missing from.Warner Losh2017-10-122-0/+2
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=324550
* libstand: tftp_open() can leak pkt on errorToomas Soome2017-09-121-0/+1
| | | | | | | | | | The memory can be leaked if we will have pkt set and will get an error during tftp_open() processing. Differential Revision: https://reviews.freebsd.org/D12202 Notes: svn path=/head/; revision=323496
* libstand: nfs_readlink() should return proper return codeToomas Soome2017-09-011-1/+1
| | | | | | | | | | The nfs_readlink() is returning constant 0 instead of variable. Reviewed by: avg Differential Revision: https://reviews.freebsd.org/D12201 Notes: svn path=/head/; revision=323100
* Add stpcpy and stpncpy to libstandWarner Losh2017-08-041-1/+1
| | | | | | | | | This adds the stpcpy and stpncpy functions to libstand. Differential Revision: https://reviews.freebsd.org/D11844 Notes: svn path=/head/; revision=322037
* Don't bother to set target for SEEK_END.Xin LI2017-06-293-5/+0
| | | | | | | | | While there also collapase SEEK_END into default case in lseek. MFC after: 2 weeks Notes: svn path=/head/; revision=320468
* use the same option list for dhcp discovery and requestToomas Soome2017-05-281-28/+31
| | | | | | | | | | | | | The DHCP client is supposed to use the same option request list for both DHCP discovery and request. This will also allow us to fill the list in single function. Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10981 Notes: svn path=/head/; revision=319085
* Use the usual FreeBSD spelling for the DHCP user classBaptiste Daroussin2017-05-271-1/+1
| | | | | | | Reported by: lidl Notes: svn path=/head/; revision=318993
* Always issue the pxe requestBaptiste Daroussin2017-05-273-38/+26
| | | | | | | | | | | | | | | | | All the code are now only issueing one single dhcp request at startup of the loader meaning we can always request a the PXE informations from the dhcp server. Previous code lost that information, meaning no option 55 anymore (meaning not working with the kea dhcp server) and no request for rootpath etc, no user class Remove the flags from the bootp function which is not needed anymore Reviewed by: tsoome Differential Revision: https://reviews.freebsd.org/D10952 Notes: svn path=/head/; revision=318989
* add a comment on vendor index 19 and 20 to avoid confusionBaptiste Daroussin2017-05-271-0/+2
| | | | | | | Suggested by: tsoome Notes: svn path=/head/; revision=318986
* Pass a "FREEBSD" user-class in PXE dhcp requestBaptiste Daroussin2017-05-272-10/+15
| | | | | | | | | | | | | | | | | | rfc3004 allows to pass multiple user classes on dhcp requests this is used by dhcp servers to differentiate the caller if needed. As an example with isc dhcp server it will be possible to make options only for the FreeBSD loaders: if exists user-class and option user-class = "FREEBSD" { option root-path "tftp://192.168.42.1/FreeBSD; } Reviewed by: tsoome Differential Revision: https://reviews.freebsd.org/D10951 Notes: svn path=/head/; revision=318982
* libstand: increase nfs max read size to 16kToomas Soome2017-05-161-1/+1
| | | | | | | | | | | | With ip fragment reassembly implemented, it makes sense to allow larger nfs reads. Note due to loader heap size limit, we do not want to set too large maximum read size. Also we do not change default read size. Reviewed by: bcr, allanjude Differential Revision: https://reviews.freebsd.org/D10754 Notes: svn path=/head/; revision=318356
* loader: add ip layer code into libstandToomas Soome2017-05-154-118/+444
| | | | | | | | | | | | | | | | Implement simple separate ip module and fragment re-assembly. The work is based on send and receive previously implemented in udp.c, moved to ip.c and added the ip fragment re-assembly. This change allows to specify larger tftp or nfs payload, such as: tftp.blksize=4096 or nfs.read_size=4096 Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10631 Notes: svn path=/head/; revision=318320
* libstand: NULL pointer dereference in rarpToomas Soome2017-05-101-1/+1
| | | | | | | | | | | | readether argument is missing & operator. CID: 1374944 Reported by: Coverity, cem Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D10663 Notes: svn path=/head/; revision=318142
* loader: network read reworkToomas Soome2017-05-0615-399/+389
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current read from network is working from up to down - we have some protocol needing the data from the network, so we build the buffer space for that protocol, add the extra space for headers and pass this buffer down to be filled by nif get call in hope, we have guessed the incoming packet size right. Amazingly enough this approach mostly does work, but not always... So, this update does work from down to up - we allocate buffer (based on MTU or frame size info), fill it up, and pass on for upper layers. The obvious problem is that when we should free the buffer - if at all. In the current implementation the upper layer will free the packet on error or when the packet is no longer needed. While working on the issue, the additional issue did pop up - the bios implementation does not have generic get/put interface but is using pxe udpsend/udpreceive instead. So the udp calls are gone and undi interface is implemented instead. Which in turn means slight other changes as we do not need to have duplicated pxe implementation and can just use dev_net. To align packet content, the actual read from nic is using shifted buffer by ETHER_ALIGN (2). Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10232 Notes: svn path=/head/; revision=317887
* distinguish NFS versus TFTP boot by rootpathBaptiste Daroussin2017-05-064-16/+8
| | | | | | | | | | | | | | | | | Don't use DHCP 150 option to decide which protocol use to netboot. When root-path includes ip address - go thru NFS, if ip address not exists in root-path - go thru TFTP from server which ip address is in next-server. But there is one limitation - only one tftp server in network to provide loader and everything else. Does enybody use more than only one? Submitted by: kczekirda Sponsored by: Oktawave MFC after: 3 weeks Relnote: Yes Differential Revision: https://reviews.freebsd.org/D8740 Notes: svn path=/head/; revision=317886
* libstand/dosfs: cache FAT32 in 128 Kb blocks to save loader memoryToomas Soome2017-04-062-95/+115
| | | | | | | | | | | | | | | | | | | | | | | Current implementation of dosfs in libstand reads full File Allocation Table to the RAM in the initialization code. In the extreme case of FAT32 filesystem, this structure will take up to 256-1024 Mb of loader memory, depending on the cluster size. Proposed patch reduces libstands/dosfs memory requirements to 128 Kb for all variants of dosfs filesystem. For FAT12 and FAT16 filesystems, File Allocation Table is cached in full, as before. For FAT32, File Allocation Table is broken into the equal blocks of 128 Kilobytes (32768 entries), and only current block is cached. Because per-filesystem context is now small, global FAT cache (for all instances of dosfs filesystem) is replaced by local per-instance cache. Submitted by: Mikhail.Kupchik_gmail.com Reviewed by: tsoome, allanjude Differential Revision: https://reviews.freebsd.org/D9547 Notes: svn path=/head/; revision=316590
* loader: want mechanism to avoid RA with bcacheToomas Soome2017-04-061-0/+3
| | | | | | | | | | | | | | | | | While we have mechanisms in place to protect ourselves against the read behind the disk end, there is still one corner case. As the GPT partition table has backup table at the end of the disk, and we yet do not know the size of the disk (if the wrong size is provided by the firmware/bios), we need to limit the reads to avoid read ahead in such case. Note: this update does add constant into stand.h, so the incremental build will need to get local stand.h updated first. Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D10187 Notes: svn path=/head/; revision=316578
* Add explicit_bzero() to libstand, and switch GELIBoot to using itAllan Jude2017-03-311-0/+4
| | | | | | | | | | | Make sure sensitive memory is properly cleared when finished with it Reviewed by: Eric McCorkle <eric@metricspace.net> Sponsored by: ScaleEngine Inc. Differential Revision: https://reviews.freebsd.org/D9798 Notes: svn path=/head/; revision=316311
* Remove OLD_NFSV2 from loader and libstandToomas Soome2017-03-302-718/+0
| | | | | | | | | | | | We have parallel NFSv2 and NFSv3 reader implementations, only configurable at build time, defaulting to v3. Remove v2. Reviewed by: allanjude Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D10206 Notes: svn path=/head/; revision=316287
* loader: verify the value from dhcp.interface-mtu and use snprintf to set mtuToomas Soome2017-03-201-3/+22
| | | | | | | | | | | | | | | Since the uset can set dhcp.interface-mtu, we need to try to validate the value. So we verify if the conversion to int is successful and we will not allow to set value greater than max IPv4 packet size. Also use snprintf for safety. Reviewed by: allanjude, bapt Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D8492 Notes: svn path=/head/; revision=315653
* libstand: verify value provided by nfs.read_sizeToomas Soome2017-03-201-10/+35
| | | | | | | | | | | Implement simple value check and feedback. Reviewed by: allanjude, rpokala Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D8491 Notes: svn path=/head/; revision=315648
* Try to extract the RFC1048 data from PXE. If we get enough info we can skipMariusz Zaborski2017-03-092-0/+17
| | | | | | | | | | | | | | the bootp(). It removes unnecessary DHCP request from pxeloader. Submitted by: kczekirda Sponsored by: Oktawave Initiated by: Matthew Dillon Reviewed by: smh, gnn, bapt, oshogbo MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D9847 Notes: svn path=/head/; revision=314948
* Renumber copyright clause 4Warner Losh2017-02-2842-42/+42
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* prefix UFS symbols with UFS_ to reduce namespace pollutionEd Maste2017-02-153-50/+50
| | | | | | | | | | | | | | | | | | | | | Specifically: ROOTINO -> UFS_ROOTINO WINO -> UFS_WINO NXADDR -> UFS_NXADDR NDADDR -> UFS_NDADDR NIADDR -> UFS_NIADDR MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency) Also prefix ext2's and nandfs's NDADDR and NIADDR with EXT2_ and NANDFS_ Reviewed by: kib, mckusick Obtained from: NetBSD MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D9536 Notes: svn path=/head/; revision=313780
* ufs: Use UFS_MAXNAMLEN constantConrad Meyer2017-02-091-1/+1
| | | | | | | | | | | | | | (like NFS, EXT2FS, SVR4, IBCS2) instead of redefining the MAXNAMLEN constant. No functional change. Reviewed by: kib@, markj@ Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D9500 Notes: svn path=/head/; revision=313475
* loader: Replace EFI part devices.Toomas Soome2017-02-061-0/+1
| | | | | | | | | | | | | | | | | | | | Rewrite EFI part device interface to present disk devices in more user friendly way. We keep list of three types of devices: floppy, cd and disk, the visible names: fdX: cdX: and diskX: Use common/disk.c and common/part.c interfaces to manage the partitioning. The lsdev -l will additionally list the device path. Reviewed by: imp, allanjude Approved by: imp (mentor), allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D8581 Notes: svn path=/head/; revision=313333
* remove network mask calculation for Classful networkBaptiste Daroussin2017-01-071-23/+10
| | | | | | | | | | | | | Nowadays it's not necessary to compute network mask from the IP address and compare to given by DHCP. Submitted by: kczekirda Reviewed by: glebius, bapt MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D8740 Notes: svn path=/head/; revision=311659
* Restructure libz, place vendor files in contrib/zlib like other thirdXin LI2017-01-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | party software, this provides more standarized import workflow and makes future upgrades easier. The following files are new with this commit: zconf.h.in zlib.map zlib.pc.in They are not connected to build, but were kept in tree for reference for future maintenance. All our local trivial changes were applied to contrib/zlib, and the contrib/zlib vendor source code is intended to 100% match lib/libz before this commit. MFC after: 2 weeks Notes: svn path=/head/; revision=311275
* loader: nandfs calls strategy with one extra argument.Toomas Soome2016-12-301-1/+1
| | | | | | | | | | | | | The strategy argument cleanup in r310850 did miss another call to strategy(), and left it with extra argument. Reviewed by: allanjude Approved by: allanjude (mentor) MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D9003 Notes: svn path=/head/; revision=310853
* dosfs support in libstand is broken since r298230Toomas Soome2016-12-308-52/+38
| | | | | | | | | | | | | | | | | | | | | | Apparently the libstand dosfs optimization is a bit too optimistic and did introduce possible memory corruption. This patch is backing out the bad part and since this results in dosfs reading full blocks now, we can also remove extra offset argument from dv_strategy callback. The analysis of the issue and the backout patch is provided by Mikhail Kupchik. PR: 214423 Submitted by: Mikhail Kupchik Reported by: Mikhail Kupchik Reviewed by: bapt, allanjude Approved by: allanjude (mentor) MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D8644 Notes: svn path=/head/; revision=310850
* libstand: dosfs cstyle cleanup for return keyword.Toomas Soome2016-12-011-48/+48
| | | | | | | | | Reviewed by: bapt, imp, allanjude Approved by: imp (mentor), allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D8678 Notes: svn path=/head/; revision=309369
* Loader paged/pageable data is not always paged.Toomas Soome2016-11-081-1/+1
| | | | | | | | | | | | | | | | | | | This change does modify devsw dv_print() to return the int value, enabling walkers to interrupt the walk on non zero value from dv_print(). This will allow the pager_print actually to stop displaying data on user input, and additionally pager is used in various *dev_print callbacks, where it was missing. For test, lsdev [-v] command should display data by screenfuls and should stop when the key 'q' is pressed on pager prompt. Reviewed by: allanjude Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D5461 Notes: svn path=/head/; revision=308434
* When issuing a PXE dhcp request, always issue a param request (DHCP option 55)Baptiste Daroussin2016-10-311-1/+11
| | | | | | | | | | | | | | | with all dhcp parameters we might be interested in. Some DHCP server like the new kea (by ISC) expect it. This makes pxeboot functional with ISC kea. Submitted by: Vincent Legout <vincent.legout@gandi.net> MFC after: 1 month Sponsored by: Gandi.net Notes: svn path=/head/; revision=308129
* Fix remaining bugs in libstancd/cd9660.c reported by Bruce Evans.Toomas Soome2016-10-031-2/+2
| | | | | | | | | | | | Fixed text in comments. Reported by: Bruce Evans <brde@optusnet.com.au> Reviewed by: allanjude Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D8119 Notes: svn path=/head/; revision=306638
* Fix remaining cstyle issues in libstand/cd9660.cToomas Soome2016-10-011-3/+1
| | | | | | | | | | Reported by: Bruce Evans <brde@optusnet.com.au> Reviewed by: allanjude Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D8107 Notes: svn path=/head/; revision=306552
* cstyle fix of cd9660_open in libstandToomas Soome2016-09-301-4/+4
| | | | | | | | | | | rS306534 did create bad cstyle by my mistake, correcting it. Reviewed by: allanjude Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D8103 Notes: svn path=/head/; revision=306538
* cd9660_open should check for paddingToomas Soome2016-09-301-1/+9
| | | | | | | | | | | The libstand cd9660 reader code must check for extents having padding. Reviewed by: jhb Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D8101 Notes: svn path=/head/; revision=306534
* Add a comment on the #endif related to the guardsBaptiste Daroussin2016-09-131-1/+1
| | | | | | | Reported by: tsoome Notes: svn path=/head/; revision=305770
* pxeboot: Add nfs.read_size tunable.Sepherosa Ziehau2016-09-081-9/+24
| | | | | | | | | | | | | | Increase this tunable improves kernel loading speed. Submitted by: Jun Su <junsu microsoft com> Reviewed by: rpokala, wblock (previous version) Obtained from: DragonFlyBSD MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7756 Notes: svn path=/head/; revision=305588
* Renumber the advertising clause.Warner Losh2016-09-061-1/+1
| | | | Notes: svn path=/head/; revision=305480
* Netboot: allow both tftpfs and nfs in both pxeboot and loader.efiBaptiste Daroussin2016-08-316-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new 'netproto' variable which can be set for now to NET_TFTP or NET_NFS (default to NET_NONE) From the dhcp options if one sets the root-path option to: "ip:path", the loader will consider it is booting over NFS (meaning same behaviour as the default current behaviour) if the dhcp option "tftp server address" is set (option 150) the loader will consider it is booting over tftpfs, it will then consider the root-path options with 2 possible case 1. "path" then the IP of the tftp server will be the one passed by the option 150, and the files will be retrieved under "path" on the tftp server 2. "ip:path" then the IP of the tftp server will be the one passed in the option "overwritting the IP from the option 150. We could not "abuse" the rootpath option in the form or tftp://ip:path because this is already used for other purpose by iPXE preventing any chainload from iPXE to the FreeBSD loader. Given at each open(), the loader loops over all available filesystems and keep the "best" error, we needed to prevent tftpfs to fallback on nfs and vice versa. the tftpfs and nfs implementation in libstand now return EINVAL early if 'netproto' for that purpose. Reviewed by: tsoome Relnotes: yes Sponsored by: Gandi.net Differential Revision: https://reviews.freebsd.org/D7628 Notes: svn path=/head/; revision=305125
* recvtftp() is broken for large files, report file sizeToomas Soome2016-08-311-2/+4
| | | | | | | | | | | | | | | | The tftp download for large files will cause internal block id to wrap to 0 as the data type is unsigned short. Also provide file size information for stat. PR: 200500 Reported by: tsoome Reviewed by: allanjude Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D7660 Notes: svn path=/head/; revision=305116
* Unused variables and cstyle fix for loader dosfsToomas Soome2016-08-261-4/+4
| | | | | | | | | Reviewed by: imp, allanjude Approved by: imp (mentor), allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D7659 Notes: svn path=/head/; revision=304850
* Fix a bug in the parsing code: always use the len and not 8.Warner Losh2016-05-201-1/+1
| | | | Notes: svn path=/head/; revision=300264
* Add support for %S to libstand as well so /boot/loader and friends canWarner Losh2016-05-171-0/+5
| | | | | | | use it. Notes: svn path=/head/; revision=300078
* libstand: make more use of the howmany() macro when available.Pedro F. Giffuni2016-04-261-1/+1
| | | | | | | | We have a howmany() macro in the <sys/param.h> header that is convenient to re-use as it makes things easier to read. Notes: svn path=/head/; revision=298601
* Unbreak the build if you enable WITH_NANDAllan Jude2016-04-191-2/+2
| | | | | | | | | | Followup to r298230 Submitted by: Nikolai Lifanov <lifanov@mail.lifanov.com> (original version) Sponsored by: ScaleEngine Inc. Notes: svn path=/head/; revision=298242
* A new implementation of the loader block cacheAllan Jude2016-04-188-103/+189
| | | | | | | | | | | | | | | | | | | | The block cache implementation in loader has proven to be almost useless, and in worst case even slowing down the disk reads due to insufficient cache size and extra memory copy. Also the current cache implementation does not cache reads from CDs, or work with zfs built on top of multiple disks. Instead of an LRU, this code uses a simple hash (O(1) read from cache), and instead of a single global cache, a separate cache per block device. The cache also implements limited read-ahead to increase performance. To simplify read ahead management, the read ahead will not wrap over bcache end, so in worst case, single block physical read will be performed to fill the last block in bcache. Booting from a virtual CD over IPMI: 0ms latency, before: 27 second, after: 7 seconds 60ms latency, before: over 12 minutes, after: under 5 minutes. Submitted by: Toomas Soome <tsoome@me.com> Reviewed by: delphij (previous version), emaste (previous version) Relnotes: yes Differential Revision: https://reviews.freebsd.org/D4713 Notes: svn path=/head/; revision=298230
* libstand: use NULL instead of zero for pointers.Pedro F. Giffuni2016-04-183-10/+10
| | | | Notes: svn path=/head/; revision=298210