Skip to contentSkip to conversation

tap: make set_offload a nop after netdev cleanup

PATCH New Michael S. Tsirkin 1 participant 1 message Oct 31, 2010 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tap: make set_offload a nop after netdev cleanup

virtio-net expects set_offload to succeed after peer cleanup.
Since we don't have an open fd anymore, make it so. Fixes warning about the failure of offload setting.

---
 net/tap.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
net/tap.c +4 -0
index 4cfa538..51c762d 100644
@@ -248,6 +248,9 @@ void tap_set_offload(VLANClientState *nc, int csum, int tso4,
                      int tso6, int ecn, int ufo)
 {
     TAPState *s = DO_UPCAST(TAPState, nc, nc);
+    if (s->fd < 0) {
+        return 0;
+    }
 
     return tap_fd_set_offload(s->fd, csum, tso4, tso6, ecn, ufo);
 }
@@ -269,6 +272,7 @@ static void tap_cleanup(VLANClientState *nc)
     tap_read_poll(s, 0);
     tap_write_poll(s, 0);
     close(s->fd);
+    s->fd = -1;
 }
 
 static void tap_poll(VLANClientState *nc, bool enable)
Signature · 1 line
1.7.3.2.91.g446ac