diff options
Diffstat (limited to 'Documentation/lguest/lguest.c')
-rw-r--r-- | Documentation/lguest/lguest.c | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c index b88b0ea54e90..7228369d1014 100644 --- a/Documentation/lguest/lguest.c +++ b/Documentation/lguest/lguest.c | |||
@@ -895,6 +895,9 @@ static void handle_console_output(int fd, struct virtqueue *vq, bool timeout) | |||
895 | } | 895 | } |
896 | } | 896 | } |
897 | 897 | ||
898 | /* This is called when we no longer want to hear about Guest changes to a | ||
899 | * virtqueue. This is more efficient in high-traffic cases, but it means we | ||
900 | * have to set a timer to check if any more changes have occurred. */ | ||
898 | static void block_vq(struct virtqueue *vq) | 901 | static void block_vq(struct virtqueue *vq) |
899 | { | 902 | { |
900 | struct itimerval itm; | 903 | struct itimerval itm; |
@@ -939,6 +942,11 @@ static void handle_net_output(int fd, struct virtqueue *vq, bool timeout) | |||
939 | if (!timeout && num) | 942 | if (!timeout && num) |
940 | block_vq(vq); | 943 | block_vq(vq); |
941 | 944 | ||
945 | /* We never quite know how long should we wait before we check the | ||
946 | * queue again for more packets. We start at 500 microseconds, and if | ||
947 | * we get fewer packets than last time, we assume we made the timeout | ||
948 | * too small and increase it by 10 microseconds. Otherwise, we drop it | ||
949 | * by one microsecond every time. It seems to work well enough. */ | ||
942 | if (timeout) { | 950 | if (timeout) { |
943 | if (num < last_timeout_num) | 951 | if (num < last_timeout_num) |
944 | timeout_usec += 10; | 952 | timeout_usec += 10; |
@@ -1447,21 +1455,6 @@ static void configure_device(int fd, const char *tapif, u32 ipaddr) | |||
1447 | err(1, "Bringing interface %s up", tapif); | 1455 | err(1, "Bringing interface %s up", tapif); |
1448 | } | 1456 | } |
1449 | 1457 | ||
1450 | static void get_mac(int fd, const char *tapif, unsigned char hwaddr[6]) | ||
1451 | { | ||
1452 | struct ifreq ifr; | ||
1453 | |||
1454 | memset(&ifr, 0, sizeof(ifr)); | ||
1455 | strcpy(ifr.ifr_name, tapif); | ||
1456 | |||
1457 | /* SIOC stands for Socket I/O Control. G means Get (vs S for Set | ||
1458 | * above). IF means Interface, and HWADDR is hardware address. | ||
1459 | * Simple! */ | ||
1460 | if (ioctl(fd, SIOCGIFHWADDR, &ifr) != 0) | ||
1461 | err(1, "getting hw address for %s", tapif); | ||
1462 | memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, 6); | ||
1463 | } | ||
1464 | |||
1465 | static int get_tun_device(char tapif[IFNAMSIZ]) | 1458 | static int get_tun_device(char tapif[IFNAMSIZ]) |
1466 | { | 1459 | { |
1467 | struct ifreq ifr; | 1460 | struct ifreq ifr; |
@@ -1531,11 +1524,8 @@ static void setup_tun_net(char *arg) | |||
1531 | p = strchr(arg, ':'); | 1524 | p = strchr(arg, ':'); |
1532 | if (p) { | 1525 | if (p) { |
1533 | str2mac(p+1, conf.mac); | 1526 | str2mac(p+1, conf.mac); |
1527 | add_feature(dev, VIRTIO_NET_F_MAC); | ||
1534 | *p = '\0'; | 1528 | *p = '\0'; |
1535 | } else { | ||
1536 | p = arg + strlen(arg); | ||
1537 | /* None supplied; query the randomly assigned mac. */ | ||
1538 | get_mac(ipfd, tapif, conf.mac); | ||
1539 | } | 1529 | } |
1540 | 1530 | ||
1541 | /* arg is now either an IP address or a bridge name */ | 1531 | /* arg is now either an IP address or a bridge name */ |
@@ -1547,13 +1537,10 @@ static void setup_tun_net(char *arg) | |||
1547 | /* Set up the tun device. */ | 1537 | /* Set up the tun device. */ |
1548 | configure_device(ipfd, tapif, ip); | 1538 | configure_device(ipfd, tapif, ip); |
1549 | 1539 | ||
1550 | /* Tell Guest what MAC address to use. */ | ||
1551 | add_feature(dev, VIRTIO_NET_F_MAC); | ||
1552 | add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY); | 1540 | add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY); |
1553 | /* Expect Guest to handle everything except UFO */ | 1541 | /* Expect Guest to handle everything except UFO */ |
1554 | add_feature(dev, VIRTIO_NET_F_CSUM); | 1542 | add_feature(dev, VIRTIO_NET_F_CSUM); |
1555 | add_feature(dev, VIRTIO_NET_F_GUEST_CSUM); | 1543 | add_feature(dev, VIRTIO_NET_F_GUEST_CSUM); |
1556 | add_feature(dev, VIRTIO_NET_F_MAC); | ||
1557 | add_feature(dev, VIRTIO_NET_F_GUEST_TSO4); | 1544 | add_feature(dev, VIRTIO_NET_F_GUEST_TSO4); |
1558 | add_feature(dev, VIRTIO_NET_F_GUEST_TSO6); | 1545 | add_feature(dev, VIRTIO_NET_F_GUEST_TSO6); |
1559 | add_feature(dev, VIRTIO_NET_F_GUEST_ECN); | 1546 | add_feature(dev, VIRTIO_NET_F_GUEST_ECN); |