summaryrefslogtreecommitdiff
path: root/sys/boot/common/dev_net.c
Commit message (Collapse)AuthorAgeFilesLines
* Move sys/boot to stand. Fix all references to new locationWarner Losh2017-11-141-435/+0
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=325834
* Small cleanup in dev_net.cToomas Soome2017-05-281-3/+2
| | | | | | | | | | The variable servip is unused. One leftover printf and small cstyle nit. Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10980 Notes: svn path=/head/; revision=319084
* Update the comments concerning net_parse_rootpath to reflect what it is nowBaptiste Daroussin2017-05-271-2/+14
| | | | | | | | | | | really doing Reported by: rgrimes Reviewed by: rgrimes Differential Revision: https://reviews.freebsd.org/D10959 Notes: svn path=/head/; revision=318999
* Partially revert r314948Baptiste Daroussin2017-05-271-21/+2
| | | | | | | | | | | | | | | | While it sounds like a good idea to extract the RFC1048 data from PXE, in the end it is not and it is causing lots of issues. Our pxeloader might need options which are incompatible with other pxe servers (for example iPXE, but not only). Our pxe loaders are also now settings their own user class, so it is useful to issue our own pxe request at startup Reviewed by: tsoome Differential Revision: https://reviews.freebsd.org/D10953 Notes: svn path=/head/; revision=318990
* Always issue the pxe requestBaptiste Daroussin2017-05-271-1/+1
| | | | | | | | | | | | | | | | | 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
* Support URI scheme for root-path in netbootingBaptiste Daroussin2017-05-271-10/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather that previous attempts to add tftpfs support at the same time as NFS support. This time decide on a proper URI parser rather than hacks. root-path can now be define the following way: For tftpfs: tftp://ip/path tftp:/path (this one will consider the tftp server is the same as the one where the pxeboot file was fetched from) For nfs: nfs:/path nfs://ip/path The historical ip:/path /path are kept on NFS Reviewed by: tsoom, rgrimes Differential Revision: https://reviews.freebsd.org/D10947 Notes: svn path=/head/; revision=318987
* Replacing iterating over rootpath by strsep(3).Mariusz Zaborski2017-05-221-8/+6
| | | | | | | | | | | Submitted by: kczekirda Reviewed by: tsoome, bapt, jhb, oshogbo MFC after: 3 weeks Sponsored by: Oktawave Differential Revision: https://reviews.freebsd.org/D10726 Notes: svn path=/head/; revision=318678
* loader: network read reworkToomas Soome2017-05-061-4/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-061-8/+4
| | | | | | | | | | | | | | | | | 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
* loader: verify the value from dhcp.interface-mtu and use snprintf to set mtuToomas Soome2017-03-201-1/+1
| | | | | | | | | | | | | | | 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
* lsdev device name section headers should be printed by dv_print callback.Toomas Soome2016-11-191-1/+8
| | | | | | | | | | | | | | | | | | | lsdev command does walk over devsw list, prints list element name and will use dv_print() callback to print the device list. Unfortunately this approach will add unneeded noise when there are no particular devices detected. To remove "empty" device section headers, the dv_print() callback should print the header instead. In addition, fixed dv_print callback for md module. Reviewed by: imp Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D8551 Notes: svn path=/head/; revision=308827
* Loader paged/pageable data is not always paged.Toomas Soome2016-11-081-4/+8
| | | | | | | | | | | | | | | | | | | 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
* Stop closing the network device when netbooting for loaders using the commonBaptiste Daroussin2016-10-131-17/+0
| | | | | | | | | | | | | | | | | | | | | | | | | dev_net.c code. The NETIF_OPEN_CLOSE_ONCE flag was added in r201932 to prevent that behaviour on some architectures (sparc64 and powerpc64) the default was left to always open and close the device for each open and close of a file by the loader because it was necessary for u-boot on arm. Since it has been added, the flag was turned on for every arches including the u-boot loader for arm. This also fixes netbooting on RPi3 (tested by gonzo@) For the loader.efi it greatly speeds up netbooting Reviewed by: emaste, gonzo, tsoome Approved by: gonzo MFC after: 1 month Sponsored by: Gandi.net Differential Revision: https://reviews.freebsd.org/D8230 Notes: svn path=/head/; revision=307238
* Remove code that crept in r305125 by accidentBaptiste Daroussin2016-09-131-2/+2
| | | | | | | Reported by: tsoome Notes: svn path=/head/; revision=305769
* Netboot: allow both tftpfs and nfs in both pxeboot and loader.efiBaptiste Daroussin2016-08-311-9/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add tftpfs support for the EFI loaderBaptiste Daroussin2016-08-231-0/+5
| | | | | | | | | | Allow netbooting on efi without having to setup any NFS server by rebuilding the loader with LOADER_TFTP_SUPPORT like for the i386 pxeloader Sponsored by: Gandi.net Notes: svn path=/head/; revision=304677
* If the dhcp server provided an interface-mtu option, transcribe the valueIan Lepore2016-03-211-0/+6
| | | | | | | | | | | 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. This should bring the same functionality when the bootp/dhcp work is done by loader(8) as r297150 does for the in-kernel BOOTP case. Notes: svn path=/head/; revision=297151
* Fix build failure introduced by r296182Stanislav Galabov2016-02-291-1/+0
| | | | | | | Approved by: adrian (mentor) Notes: svn path=/head/; revision=296186
* These changes attempt to put things in order before the introduction of MIPSStanislav Galabov2016-02-291-2/+1
| | | | | | | | | | | | | | | | | | ubldr. The changes are mostly dealing with removing unnecessary casts from the U-Boot API (we're passing only pointers, no obvious reason to cast them to uint32_t), cleaning up some compiler warnings and using the proper printf format specifiers in order to be able to compile cleanly for both 32-bit and 64-bit MIPS targets. Reviewed by: imp Approved by: adrian (mentor) Sponsored by: Smartcom - Bulgaria AD Differential Revision: https://reviews.freebsd.org/D5312 Notes: svn path=/head/; revision=296182
* Refactor net_getparams() to make it easier to get params from sources otherIan Lepore2015-05-181-28/+45
| | | | | | | | | | | | | | | | | | | | than bootp and rarp. The code which splits a serverip:/rootpath string into rootip and a plain pathname is now a separate net_parse_rootpath() function that can be called by others. The code that sets the kernel env vars needed for nfs_diskless is moved into net_open() so that the variables get set no matter where the params came from. There was already code in net_open() that allowed for the possibility that some other entity has set up the network-related global variables. It uses the rootip variable as the key, assuming that if it is set all the other required variables are set too. These changes don't alter the existing behavior, they just make it easier to actually write some new code to get the params from another source (such as the U-Boot environment). Notes: svn path=/head/; revision=283062
* - Add code allowing a network device to only be open and closed onceMarius Strobl2010-01-091-9/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | by keeping it opened after the first open and closing it via the cleanup handler when NETIF_OPEN_CLOSE_ONCE is defined in order to avoid the open-close-dance on every file access which with firmware that for example performs an auto-negotiation on every open causes netbooting to take horribly long. Basically the behavior with this knob enabled resembles the one employed between r60506 and r177108 (and for sparc64 also again since r182919) with the addition that the network device now is closed eventually before entering the kernel and before rebooting. Actually I think this should be the desired MI behavior, however the U-Boot loader actually requires net_close() to be called after every transaction in order for some local shutdown operations to be performed (and which I think thus will break on concurrent opens, i.e. when netdev_opens is > 1, like the loader does at least for disks when LOADER_GZIP_SUPPORT is enabled). - Use NETIF_OPEN_CLOSE_ONCE to replace the hack, which artificially increased netdev_opens for sparc64 in order to keep the network device opened forever, as at least some firmware versions require the network device to be closed eventually before entering the kernel or otherwise will DMA received packets to stale memory. The powerpc OFW loader probably wants NETIF_OPEN_CLOSE_ONCE to be set as well for the same reasons. Notes: svn path=/head/; revision=201932
* Remove clause 3 and 4 from TNF licenses (this was the only 4-clause TNFMarius Strobl2010-01-091-10/+1
| | | | | | | | | license FreeBSD had in sys/boot). Obtained from: NetBSD Notes: svn path=/head/; revision=201901
* - Consistently wrap debugging in NETIF_DEBUG. This basically mergesMarius Strobl2009-12-241-6/+22
| | | | | | | | NetBSD rev 1.19. - Make the functions match their prototypes regarding static. Notes: svn path=/head/; revision=200945
* Revert r177108 and restore r60506 for sparc64 as long as libstandMarius Strobl2008-09-101-0/+3
| | | | | | | | | | | isn't fixed to only open the network device once and not do a open and close dance on every file access; the firmwares of newer sparc64 machines perform an auto-negotiation with every open which in turn causes netbooting to take horribly long if we open and close the device over and over again. Notes: svn path=/head/; revision=182919
* Show info about net devices in loader's 'lsdev' command. While there fix style.Rafal Jaworowski2008-09-031-155/+167
| | | | Notes: svn path=/head/; revision=182731
* Eliminate artificial increasing of 'netdev_opens' counter in loader's ↵Rafal Jaworowski2008-03-121-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | net_open(). This was introduced as a workaround long time ago for some Alpha firmware (which is now gone), and actually prevented net_close() to ever be called. Certain firmwares (U-Boot) need local shutdown operations to be performed on a network controller upon transaction end: such platform-specific hooks are supposed to be called via netif_close() (from within net_close()). This change effectively reverts the following CVS commit: sys/boot/common/dev_net.c revision 1.7 date: 2000/05/13 15:40:46; author: dfr; state: Exp; lines: +2 -1 Only probe network settings on the first open of the network device. The alpha firmware takes a seriously long time to open the network device the first time. Also suppress excessive output while netbooting via loader, unless debugging. While there, make sys/boot/uboot more style(9) compliant. Reviewed by: imp Approved by: cognet (mentor) Notes: svn path=/head/; revision=177108
* Change the following environment variables to kernel options:Brian Somers2004-07-081-1/+1
| | | | | | | | | | | | | | | | bootp -> BOOTP bootp.nfsroot -> BOOTP_NFSROOT bootp.nfsv3 -> BOOTP_NFSV3 bootp.compat -> BOOTP_COMPAT bootp.wired_to -> BOOTP_WIRED_TO - i.e. back out the previous commit. It's already possible to pxeboot(8) with a GENERIC kernel. Pointed out by: dwmalone Notes: svn path=/head/; revision=131840
* Change the following kernel options to environment variables:Brian Somers2004-07-081-1/+1
| | | | | | | | | | | | | | | | | | | | | BOOTP -> bootp BOOTP_NFSROOT -> bootp.nfsroot BOOTP_NFSV3 -> bootp.nfsv3 BOOTP_COMPAT -> bootp.compat BOOTP_WIRED_TO -> bootp.wired_to This lets you PXE boot with a GENERIC kernel by putting this sort of thing in loader.conf: bootp="YES" bootp.nfsroot="YES" bootp.nfsv3="YES" bootp.wired_to="bge1" or even setting the variables manually from the OK prompt. Notes: svn path=/head/; revision=131814
* Override the root server address if an IP address is specified inIan Dowse2003-11-031-7/+9
| | | | | | | | | | | | the root path. This is reported to make non-PXE netbooting, such as is used on sparc64 systems, work correctly when the TFTP server is not the same as the root server. PR: kern/57328 Submitted by: Per Kristian Hove <Per.Hove@math.ntnu.no> Notes: svn path=/head/; revision=121973
* Use __FBSDID().David E. O'Brien2003-08-251-3/+5
| | | | | | | Also some minor style cleanups. Notes: svn path=/head/; revision=119483
* Stash various networking paramters in the environment for the kernelJake Burkholder2002-07-311-0/+9
| | | | | | | to pick up, ala pxe. Notes: svn path=/head/; revision=101112
* Give the network device a print method.Benno Rice2000-11-101-1/+9
| | | | | | | Reviewed by: obrien Notes: svn path=/head/; revision=68547
* Add support to send the string 'PXEClient' as the Vendor classPaul Saab2000-08-111-1/+2
| | | | | | | | | identifier to the DHCP server. Now you can check for this string in your dhcp configuration to decide whether you will hand out a lease to the client or not. Notes: svn path=/head/; revision=64527
* Fix the more obvious warnings to deal with my earlier warning cleanups.John Baldwin2000-08-031-1/+0
| | | | Notes: svn path=/head/; revision=64188
* Only probe network settings on the first open of the network device.Doug Rabson2000-05-131-0/+1
| | | | | | | | The alpha firmware takes a seriously long time to open the network device the first time. Notes: svn path=/head/; revision=60506
* * Fix a stack of warnings.Doug Rabson1999-09-011-10/+8
| | | | | | | | | * Make it possible to type a filename to boot1 so that it is possible to recover from fatally broken versions of /boot/loader. * Make a start at a CD boot program (not yet functional). Notes: svn path=/head/; revision=50737
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Changes to support diskless booting on the alpha:Doug Rabson1999-05-031-4/+21
| | | | | | | | | | | | | | | * Make the network code in the bootstrap more chatty (helps debugging) * Add nfs root stuff to cpu_rootconf(). I also added a check to make sure it really was netbooting which allows the use of the same kernel for local and network boots. * Tweak the de driver so that it takes the speed setting from the console for the alpha (some PWSs have broken de chipsets). This is the same behaviour as NetBSD/alpha. Submitted by: Andrew Gallatin <gallatin@cs.duke.edu> Notes: svn path=/head/; revision=46356
* Make the alpha bootstrap build again, fix some warning and change sdboot to ↵Doug Rabson1998-09-201-2/+1
| | | | | | | daboot. Notes: svn path=/head/; revision=39530
* Minor tweaks to track a couple of i386 changes and to make it compile.Doug Rabson1998-08-221-6/+2
| | | | Notes: svn path=/head/; revision=38475
* This is the new unified bootstrap, sometimes known previously as theMike Smith1998-08-211-0/+275
'three-stage' bootstrap. There are a number of caveats with the code in its current state: - The i386 bootstrap only supports booting from a floppy. - The kernel and kld do not yet know how to deal with the extended information and module summary passed in. - PnP-based autodetection and demand loading of modules is not implemented. - i386 ELF kernel loading is not ready yet. - The i386 bootstrap is loaded via an ugly blockmap. On the alpha, both net- and disk-booting (SRM console machines only) is supported. No blockmaps are used by this code. Obtained from: Parts from the NetBSD/i386 standalone bootstrap. Notes: svn path=/cvs2svn/branches/MSMITH/; revision=38465