aboutsummaryrefslogtreecommitdiff
path: root/sys/boot/common
diff options
context:
space:
mode:
authorToomas Soome <tsoome@FreeBSD.org>2017-05-06 20:32:27 +0000
committerToomas Soome <tsoome@FreeBSD.org>2017-05-06 20:32:27 +0000
commitda8fb057e520892de8cd09d883c0efa57c4deb66 (patch)
treea59af8376ca6e14eee2cab02ba85af6fa548377b /sys/boot/common
parenta872bf12f8c976591eb3150fcbd0509575b917d0 (diff)
downloadsrc-da8fb057e520892de8cd09d883c0efa57c4deb66.tar.gz
src-da8fb057e520892de8cd09d883c0efa57c4deb66.zip
loader: network read rework
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
Notes: svn path=/head/; revision=317887
Diffstat (limited to 'sys/boot/common')
-rw-r--r--sys/boot/common/dev_net.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/sys/boot/common/dev_net.c b/sys/boot/common/dev_net.c
index c9162975d3b9..b7127163c77e 100644
--- a/sys/boot/common/dev_net.c
+++ b/sys/boot/common/dev_net.c
@@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$");
#include <netinet/in_systm.h>
#include <stand.h>
+#include <stddef.h>
#include <string.h>
#include <net.h>
#include <netif.h>
@@ -79,7 +80,7 @@ static int net_init(void);
static int net_open(struct open_file *, ...);
static int net_close(struct open_file *);
static void net_cleanup(void);
-static int net_strategy();
+static int net_strategy(void *, int, daddr_t, size_t, char *, size_t *);
static int net_print(int);
static int net_getparams(int sock);
@@ -216,7 +217,8 @@ net_cleanup(void)
}
static int
-net_strategy()
+net_strategy(void *devdata, int rw, daddr_t blk, size_t size, char *buf,
+ size_t *rsize)
{
return (EIO);
@@ -246,6 +248,8 @@ net_getparams(int sock)
{
char buf[MAXHOSTNAMELEN];
n_long rootaddr, smask;
+ struct iodesc *d = socktodesc(sock);
+ extern struct in_addr servip;
#ifdef SUPPORT_BOOTP
/*
@@ -254,8 +258,26 @@ net_getparams(int sock)
* be initialized. If any remain uninitialized, we will
* use RARP and RPC/bootparam (the Sun way) to get them.
*/
- if (try_bootp)
- bootp(sock, BOOTP_NONE);
+ if (try_bootp) {
+ int rc = -1;
+ if (bootp_response != NULL) {
+ rc = dhcp_try_rfc1048(bootp_response->bp_vend,
+ bootp_response_size -
+ offsetof(struct bootp, bp_vend));
+
+ if (servip.s_addr == 0)
+ servip = bootp_response->bp_siaddr;
+ if (rootip.s_addr == 0)
+ rootip = bootp_response->bp_siaddr;
+ if (gateip.s_addr == 0)
+ gateip = bootp_response->bp_giaddr;
+ if (myip.s_addr == 0)
+ myip = bootp_response->bp_yiaddr;
+ d->myip = myip;
+ }
+ if (rc < 0)
+ bootp(sock, BOOTP_NONE);
+ }
if (myip.s_addr != 0)
goto exit;
#ifdef NETIF_DEBUG