Revision 8af8ce4d
b/net/tap.c | ||
---|---|---|
53 | 53 |
char down_script[1024]; |
54 | 54 |
char down_script_arg[128]; |
55 | 55 |
uint8_t buf[TAP_BUFSIZE]; |
56 |
Notifier exit_notifier; |
|
56 | 57 |
unsigned int read_poll : 1; |
57 | 58 |
unsigned int write_poll : 1; |
58 | 59 |
unsigned int has_vnet_hdr : 1; |
... | ... | |
261 | 262 |
tap_read_poll(s, 0); |
262 | 263 |
tap_write_poll(s, 0); |
263 | 264 |
close(s->fd); |
265 |
exit_notifier_remove(&s->exit_notifier); |
|
266 |
} |
|
267 |
|
|
268 |
/* Instead of exiting gracefully, we're exiting because someone called |
|
269 |
* exit(), make sure to invoke down script at least |
|
270 |
*/ |
|
271 |
static void tap_cleanup_at_exit(Notifier *notifier) |
|
272 |
{ |
|
273 |
TAPState *s = container_of(notifier, TAPState, exit_notifier); |
|
274 |
|
|
275 |
if (s->down_script[0]) { |
|
276 |
launch_script(s->down_script, s->down_script_arg, s->fd); |
|
277 |
} |
|
264 | 278 |
} |
265 | 279 |
|
266 | 280 |
static void tap_poll(VLANClientState *nc, bool enable) |
... | ... | |
299 | 313 |
s->has_vnet_hdr = vnet_hdr != 0; |
300 | 314 |
s->using_vnet_hdr = 0; |
301 | 315 |
s->has_ufo = tap_probe_has_ufo(s->fd); |
316 |
s->exit_notifier.notify = tap_cleanup_at_exit; |
|
317 |
exit_notifier_add(&s->exit_notifier); |
|
302 | 318 |
tap_set_offload(&s->nc, 0, 0, 0, 0, 0); |
303 | 319 |
tap_read_poll(s, 1); |
304 | 320 |
return s; |
Also available in: Unified diff