Browse Source

mini-os: netfront: retrieve netmask and gateway via extra function

Commit 1b8ed31f4c ("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 <[email protected]>
Reviewed-by: Samuel Thibault <[email protected]>
master
Juergen Gross Wei Liu 1 year ago
parent
commit
30670e2a0a
4 changed files with 22 additions and 9 deletions
  1. +3
    -1
      include/netfront.h
  2. +3
    -1
      lwip-net.c
  3. +15
    -6
      netfront.c
  4. +1
    -1
      test.c

+ 3
- 1
include/netfront.h View File

@@ -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);


+ 3
- 1
lwip-net.c View File

@@ -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);


+ 15
- 6
netfront.c View File

@@ -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;


+ 1
- 1
test.c View File

@@ -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


Loading…
Cancel
Save