Commit e7eaaf6f authored by Grégoire Henry's avatar Grégoire Henry

Fix netlink_send when using a kernel where NLM_F_MULTI is broken.

Lors d'un appel netlink_read, on suppose que NLM_F_MULTI est toujours
vrai, sauf dans le cas d'un appel depuis kernel_callback.
parent 1c5a2320
...@@ -193,7 +193,7 @@ netlink_read(struct netlink *nl, struct netlink *nl_ignore, int answer, ...@@ -193,7 +193,7 @@ netlink_read(struct netlink *nl, struct netlink *nl_ignore, int answer,
if(len < 0 && (errno == EAGAIN || errno == EINTR)) { if(len < 0 && (errno == EAGAIN || errno == EINTR)) {
int rc; int rc;
rc = wait_for_fd(0, nl->sock, 10); rc = wait_for_fd(0, nl->sock, 100);
if(rc <= 0) { if(rc <= 0) {
if(rc == 0) if(rc == 0)
errno = EAGAIN; errno = EAGAIN;
...@@ -203,11 +203,7 @@ netlink_read(struct netlink *nl, struct netlink *nl_ignore, int answer, ...@@ -203,11 +203,7 @@ netlink_read(struct netlink *nl, struct netlink *nl_ignore, int answer,
} }
if(len < 0) { if(len < 0) {
if(errno == EAGAIN) { perror("netlink_read: recvmsg()");
done = 1;
break;
}
perror("netlink_read: recvmsg");
return 2; return 2;
} else if(len == 0) { } else if(len == 0) {
fprintf(stderr, "netlink_read: EOF\n"); fprintf(stderr, "netlink_read: EOF\n");
...@@ -228,6 +224,8 @@ netlink_read(struct netlink *nl, struct netlink *nl_ignore, int answer, ...@@ -228,6 +224,8 @@ netlink_read(struct netlink *nl, struct netlink *nl_ignore, int answer,
NLMSG_OK(nh, len); NLMSG_OK(nh, len);
nh = NLMSG_NEXT(nh, len)) { nh = NLMSG_NEXT(nh, len)) {
debugf("%s", (nh->nlmsg_flags & NLM_F_MULTI) ? "[multi] " : ""); debugf("%s", (nh->nlmsg_flags & NLM_F_MULTI) ? "[multi] " : "");
if(!answer) // (!(nh->nlmsg_flags & NLM_F_MULTI))
done = 1;
if(nl_ignore && nh->nlmsg_pid == nl_ignore->sockaddr.nl_pid) { if(nl_ignore && nh->nlmsg_pid == nl_ignore->sockaddr.nl_pid) {
debugf("(ignore), "); debugf("(ignore), ");
continue; continue;
...@@ -245,6 +243,8 @@ netlink_read(struct netlink *nl, struct netlink *nl_ignore, int answer, ...@@ -245,6 +243,8 @@ netlink_read(struct netlink *nl, struct netlink *nl_ignore, int answer,
struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA(nh); struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA(nh);
if(err->error == 0) { if(err->error == 0) {
debugf("(ACK)\n"); debugf("(ACK)\n");
// if(!(nh->nlmsg_flags & NLM_F_MULTI) && !fn)
return 0;
} else { } else {
errno = -err->error; errno = -err->error;
perror("netlink_read"); perror("netlink_read");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment