Commit 5b01e886d9eb4d5e94384a79634dcb43848e7bbf

Authored by Mark McLoughlin
1 parent 5a6d8815

net: move the tap buffer into TAPState

KVM uses a 64k buffer for reading from tapfd (for GSO support)
and allocates the buffer with TAPState rather than on the stack.

Not allocating it on the stack probably makes sense for qemu
anyway, so merge it in advance of GSO support.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Showing 1 changed file with 3 additions and 3 deletions
@@ -921,6 +921,7 @@ typedef struct TAPState { @@ -921,6 +921,7 @@ typedef struct TAPState {
921 int fd; 921 int fd;
922 char down_script[1024]; 922 char down_script[1024];
923 char down_script_arg[128]; 923 char down_script_arg[128];
  924 + uint8_t buf[4096];
924 } TAPState; 925 } TAPState;
925 926
926 static int launch_script(const char *setup_script, const char *ifname, int fd); 927 static int launch_script(const char *setup_script, const char *ifname, int fd);
@@ -972,12 +973,11 @@ static ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen) @@ -972,12 +973,11 @@ static ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen)
972 static void tap_send(void *opaque) 973 static void tap_send(void *opaque)
973 { 974 {
974 TAPState *s = opaque; 975 TAPState *s = opaque;
975 - uint8_t buf[4096];  
976 int size; 976 int size;
977 977
978 - size = tap_read_packet(s->fd, buf, sizeof(buf)); 978 + size = tap_read_packet(s->fd, s->buf, sizeof(s->buf));
979 if (size > 0) { 979 if (size > 0) {
980 - qemu_send_packet(s->vc, buf, size); 980 + qemu_send_packet(s->vc, s->buf, size);
981 } 981 }
982 } 982 }
983 983