Page MenuHomeFreeBSD

D62058.1795946708.diff
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

D62058.1795946708.diff

diff --git a/stand/common/dev_net.c b/stand/common/dev_net.c
--- a/stand/common/dev_net.c
+++ b/stand/common/dev_net.c
@@ -71,6 +71,7 @@
#endif
static char *netdev_name;
+static int netdev_unit;
static int netdev_sock = -1;
static int netdev_opens;
@@ -78,6 +79,7 @@
static int net_open(struct open_file *, ...);
static int net_close(struct open_file *);
static void net_cleanup(void);
+static void net_switch(struct devdesc *);
static int net_strategy(void *, int, daddr_t, size_t, char *, size_t *);
static int net_print(int);
@@ -129,9 +131,7 @@
va_end(args);
devname = dev->d_dev->dv_name;
- /* Before opening another interface, close the previous one first. */
- if (netdev_sock >= 0 && strcmp(devname, netdev_name) != 0)
- net_cleanup();
+ net_switch(dev);
/* On first open, do netif open, mount, etc. */
if (netdev_opens == 0) {
@@ -143,6 +143,7 @@
return (ENXIO);
}
netdev_name = strdup(devname);
+ netdev_unit = dev->d_unit;
DEBUG_PRINTF(1,("%s: netif_open() succeeded %#x\n",
__func__, rootip.s_addr));
}
@@ -178,6 +179,7 @@
{
int error;
+ net_switch(dev);
if (netdev_sock >= 0)
return (0);
@@ -202,6 +204,7 @@
netdev_sock = -1;
return (ENOMEM);
}
+ netdev_unit = dev->d_unit;
return (error);
}
@@ -235,9 +238,29 @@
free(netdev_name);
netif_close(netdev_sock);
netdev_sock = -1;
+ netdev_opens = 0;
}
}
+/*
+ * Close the open interface if dev names a different one. The cached DHCP
+ * lease goes too: bootp() would ask the new interface's server to renew it.
+ */
+static void
+net_switch(struct devdesc *dev)
+{
+
+ if (netdev_sock < 0)
+ return;
+ if (strcmp(dev->d_dev->dv_name, netdev_name) == 0 &&
+ dev->d_unit == netdev_unit)
+ return;
+ net_cleanup();
+ free(bootp_response);
+ bootp_response = NULL;
+ bootp_response_size = 0;
+}
+
static int
net_strategy(void *devdata, int rw, daddr_t blk, size_t size, char *buf,
size_t *rsize)

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 29, 10:05 AM (7 h, 10 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42021438
Default Alt Text
D62058.1795946708.diff (1 KB)

Event Timeline