|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [mini-os master] mini-os: netfront: retrieve netmask and gateway via extra function
commit 30670e2a0a635f22b8236eb7b5c78eade244abff
Author: Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Tue Sep 22 12:58:25 2020 +0200
Commit: Wei Liu <wl@xxxxxxx>
CommitDate: Thu Oct 1 09:36:26 2020 +0000
mini-os: netfront: retrieve netmask and gateway via extra function
Commit 1b8ed31f4ce40 ("mini-os: netfront: Read netmask and gateway from
Xenstore") modified init_netfront() to take two additional parameters.
This broke the Xen build as init_netfront() is used in grub stubdom,
too.
So instead of tightly coupling Mini-OS and Xen build via this interface
modification undo this change of init_netfront() and add two other
functions for retrieving the netmask and gateway for a network device.
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
Reviewed-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
---
include/netfront.h | 4 +++-
lwip-net.c | 4 +++-
netfront.c | 21 +++++++++++++++------
test.c | 2 +-
4 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/include/netfront.h b/include/netfront.h
index bc3080e..ec641c8 100644
--- a/include/netfront.h
+++ b/include/netfront.h
@@ -7,7 +7,9 @@ struct netfront_dev *init_netfront(char *nodename,
void (*netif_rx)(unsigned char *data,
int len, void* arg),
unsigned char rawmac[6],
- char **ip, char **mask, char **gw);
+ char **ip);
+char *netfront_get_netmask(struct netfront_dev *dev);
+char *netfront_get_gateway(struct netfront_dev *dev);
void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len);
void shutdown_netfront(struct netfront_dev *dev);
void suspend_netfront(void);
diff --git a/lwip-net.c b/lwip-net.c
index 80d1c8f..7e0d871 100644
--- a/lwip-net.c
+++ b/lwip-net.c
@@ -347,7 +347,9 @@ void start_networking(void)
tprintk("Waiting for network.\n");
- dev = init_netfront(NULL, NULL, rawmac, &ip, &netmask_str, &gw_str);
+ dev = init_netfront(NULL, NULL, rawmac, &ip);
+ netmask_str = netfront_get_netmask(dev);
+ gw_str = netfront_get_gateway(dev);
if (ip) {
ipaddr.addr = inet_addr(ip);
diff --git a/netfront.c b/netfront.c
index 205484b..9057908 100644
--- a/netfront.c
+++ b/netfront.c
@@ -65,6 +65,8 @@ struct netfront_dev {
void (*netif_rx)(unsigned char* data, int len, void* arg);
void *netif_rx_arg;
+
+ struct netfront_dev_list *ldev;
};
struct netfront_dev_list {
@@ -303,7 +305,7 @@ struct netfront_dev *init_netfront(char *_nodename,
void (*thenetif_rx)(unsigned char* data,
int len, void* arg),
unsigned char rawmac[6],
- char **ip, char **mask, char **gw)
+ char **ip)
{
char nodename[256];
struct netfront_dev *dev;
@@ -347,6 +349,7 @@ struct netfront_dev *init_netfront(char *_nodename,
memset(ldev, 0, sizeof(struct netfront_dev_list));
if (_init_netfront(dev, ldev->rawmac, &(ldev->ip), &(ldev->mask),
&(ldev->gw))) {
+ dev->ldev = ldev;
ldev->dev = dev;
ldev->refcount = 1;
ldev->next = NULL;
@@ -376,15 +379,21 @@ out:
}
if (ip)
*ip = strdup(ldev->ip);
- if (mask)
- *mask = strdup(ldev->mask);
- if (gw)
- *gw = strdup(ldev->gw);
err:
return dev;
}
+char *netfront_get_netmask(struct netfront_dev *dev)
+{
+ return dev->ldev->mask ? strdup(dev->ldev->mask) : NULL;
+}
+
+char *netfront_get_gateway(struct netfront_dev *dev)
+{
+ return dev->ldev->gw ? strdup(dev->ldev->gw) : NULL;
+}
+
static struct netfront_dev *_init_netfront(struct netfront_dev *dev,
unsigned char rawmac[6],
char **ip, char **mask, char **gw)
@@ -576,7 +585,7 @@ error:
int netfront_tap_open(char *nodename) {
struct netfront_dev *dev;
- dev = init_netfront(nodename, NETIF_SELECT_RX, NULL, NULL, NULL, NULL);
+ dev = init_netfront(nodename, NETIF_SELECT_RX, NULL, NULL);
if (!dev) {
printk("TAP open failed\n");
errno = EIO;
diff --git a/test.c b/test.c
index 2e5f7f9..42a2666 100644
--- a/test.c
+++ b/test.c
@@ -91,7 +91,7 @@ static struct semaphore net_sem =
__SEMAPHORE_INITIALIZER(net_sem, 0);
static void netfront_thread(void *p)
{
- net_dev = init_netfront(NULL, NULL, NULL, NULL, NULL, NULL);
+ net_dev = init_netfront(NULL, NULL, NULL, NULL);
up(&net_sem);
}
#endif
--
generated by git-patchbot for /home/xen/git/mini-os.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |