wg: try again if dump is interrupted

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2017-10-08 16:24:37 +02:00
parent 38ac0ff08e
commit 8774fccff3
1 changed files with 4 additions and 1 deletions

View File

@ -855,11 +855,12 @@ static int kernel_get_device(struct wgdevice **dev, const char *interface)
struct mnlg_socket *nlg; struct mnlg_socket *nlg;
struct get_device_ctx ctx = { 0 }; struct get_device_ctx ctx = { 0 };
try_again:
*dev = ctx.device = calloc(1, sizeof(struct wgdevice)); *dev = ctx.device = calloc(1, sizeof(struct wgdevice));
if (!*dev) if (!*dev)
return -errno; return -errno;
nlg= mnlg_socket_open(WG_GENL_NAME, WG_GENL_VERSION); nlg = mnlg_socket_open(WG_GENL_NAME, WG_GENL_VERSION);
if (!nlg) { if (!nlg) {
free_wgdevice(*dev); free_wgdevice(*dev);
*dev = NULL; *dev = NULL;
@ -884,6 +885,8 @@ out:
mnlg_socket_close(nlg); mnlg_socket_close(nlg);
if (ret) { if (ret) {
free_wgdevice(*dev); free_wgdevice(*dev);
if (ret == -EINTR)
goto try_again;
*dev = NULL; *dev = NULL;
} }
errno = -ret; errno = -ret;