Revision 31dc63df
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; |
|
57 | 56 |
unsigned int read_poll : 1; |
58 | 57 |
unsigned int write_poll : 1; |
59 | 58 |
unsigned int has_vnet_hdr : 1; |
... | ... | |
262 | 261 |
tap_read_poll(s, 0); |
263 | 262 |
tap_write_poll(s, 0); |
264 | 263 |
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 |
} |
|
278 | 264 |
} |
279 | 265 |
|
280 | 266 |
static void tap_poll(VLANClientState *nc, bool enable) |
... | ... | |
313 | 299 |
s->has_vnet_hdr = vnet_hdr != 0; |
314 | 300 |
s->using_vnet_hdr = 0; |
315 | 301 |
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); |
|
318 | 302 |
tap_set_offload(&s->nc, 0, 0, 0, 0, 0); |
319 | 303 |
tap_read_poll(s, 1); |
320 | 304 |
return s; |
Also available in: Unified diff