Fix the get_ifinfo_list() function to retry if nl_recvmsgs fails with error -NLE_DUMP_INTR. Add some extra error reporting to get_ifinfo_list(). This is a fix for https://bugzilla.redhat.com/show_bug.cgi?id=1273052 Signed-off-by: Chris Card ctcard1@gmail.com --- libteam/ifinfo.c | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-)
diff --git a/libteam/ifinfo.c b/libteam/ifinfo.c index 484ac1b..df3d49a 100644 --- a/libteam/ifinfo.c +++ b/libteam/ifinfo.c @@ -332,24 +332,39 @@ int get_ifinfo_list(struct team_handle *th) .rtgen_family = AF_UNSPEC, }; int ret; - - ret = nl_send_simple(th->nl_cli.sock, RTM_GETLINK, NLM_F_DUMP, - &rt_hdr, sizeof(rt_hdr)); - if (ret < 0) - return -nl2syserr(ret); - orig_cb = nl_socket_get_cb(th->nl_cli.sock); - cb = nl_cb_clone(orig_cb); - nl_cb_put(orig_cb); - if (!cb) - return -ENOMEM; - - nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, valid_handler, th); - - ret = nl_recvmsgs(th->nl_cli.sock, cb); - nl_cb_put(cb); + int retry = 1; + + while (retry) { + retry = 0; + ret = nl_send_simple(th->nl_cli.sock, RTM_GETLINK, NLM_F_DUMP, + &rt_hdr, sizeof(rt_hdr)); + if (ret < 0) { + err(th, "get_ifinfo_list: nl_send_simple failed"); + return -nl2syserr(ret); + } + orig_cb = nl_socket_get_cb(th->nl_cli.sock); + cb = nl_cb_clone(orig_cb); + nl_cb_put(orig_cb); + if (!cb) { + err(th, "get_ifinfo_list: nl_cb_clone failed"); + return -ENOMEM; + } + + nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, valid_handler, th); + + ret = nl_recvmsgs(th->nl_cli.sock, cb); + nl_cb_put(cb); + if (ret < 0) { + err(th, "get_ifinfo_list: nl_recvmsgs failed"); + if (ret != -NLE_DUMP_INTR) + return -nl2syserr(ret); + retry = 1; + } + } + ret = check_call_change_handlers(th, TEAM_IFINFO_CHANGE); if (ret < 0) - return -nl2syserr(ret); - return check_call_change_handlers(th, TEAM_IFINFO_CHANGE); + err(th, "get_ifinfo_list: check_call_change_handers failed"); + return ret; }
int ifinfo_list_init(struct team_handle *th)
Thu, Nov 26, 2015 at 10:12:14AM CET, ctcard1@gmail.com wrote:
Fix the get_ifinfo_list() function to retry if nl_recvmsgs fails with error -NLE_DUMP_INTR.
Please fit the patch description within 80cols.
Add some extra error reporting to get_ifinfo_list(). This is a fix for https://bugzilla.redhat.com/show_bug.cgi?id=1273052
You are missing empty line here.
Signed-off-by: Chris Card ctcard1@gmail.com
Also in the subject line, please change it to: [patch libteam] libteam: retry on NLE_DUMP_INTR error
Other than that, all looks good. Thanks.
libteam/ifinfo.c | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-)
diff --git a/libteam/ifinfo.c b/libteam/ifinfo.c index 484ac1b..df3d49a 100644 --- a/libteam/ifinfo.c +++ b/libteam/ifinfo.c @@ -332,24 +332,39 @@ int get_ifinfo_list(struct team_handle *th) .rtgen_family = AF_UNSPEC, }; int ret;
- ret = nl_send_simple(th->nl_cli.sock, RTM_GETLINK, NLM_F_DUMP,
&rt_hdr, sizeof(rt_hdr));
- if (ret < 0)
return -nl2syserr(ret);
- orig_cb = nl_socket_get_cb(th->nl_cli.sock);
- cb = nl_cb_clone(orig_cb);
- nl_cb_put(orig_cb);
- if (!cb)
return -ENOMEM;
- nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, valid_handler, th);
- ret = nl_recvmsgs(th->nl_cli.sock, cb);
- nl_cb_put(cb);
- int retry = 1;
- while (retry) {
retry = 0;
ret = nl_send_simple(th->nl_cli.sock, RTM_GETLINK, NLM_F_DUMP,
&rt_hdr, sizeof(rt_hdr));
if (ret < 0) {
err(th, "get_ifinfo_list: nl_send_simple failed");
return -nl2syserr(ret);
}
orig_cb = nl_socket_get_cb(th->nl_cli.sock);
cb = nl_cb_clone(orig_cb);
nl_cb_put(orig_cb);
if (!cb) {
err(th, "get_ifinfo_list: nl_cb_clone failed");
return -ENOMEM;
}
nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, valid_handler, th);
ret = nl_recvmsgs(th->nl_cli.sock, cb);
nl_cb_put(cb);
if (ret < 0) {
err(th, "get_ifinfo_list: nl_recvmsgs failed");
if (ret != -NLE_DUMP_INTR)
return -nl2syserr(ret);
retry = 1;
}
- }
- ret = check_call_change_handlers(th, TEAM_IFINFO_CHANGE); if (ret < 0)
return -nl2syserr(ret);
- return check_call_change_handlers(th, TEAM_IFINFO_CHANGE);
err(th, "get_ifinfo_list: check_call_change_handers failed");
- return ret;
}
int ifinfo_list_init(struct team_handle *th)
2.4.3 _______________________________________________ libteam mailing list libteam@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/libteam@lists.fedorahosted.org
libteam@lists.fedorahosted.org