Skip to content

Commit

Permalink
transport: Fix _find_myself for kernel 6.9
Browse files Browse the repository at this point in the history
Kernel 6.9 seems to have changed AF_NETLINK behavior slightly making
booth unable to start.

Previously it was expected only first item in
the message can be NLMSG_DONE or NLMSG_ERROR type. And it looks this was
true for Kernel < 6.9.

With kernel 6.9 this is no longer true, so any item can be type
NLMSG_DONE or NLMSG_ERROR.

Result was loop was never terminated and booth was waiting for more
messages from kernel which never arrived.

Solution is to change loop a bit so NLMSG_DONE, NLMSG_ERROR and
RTM_NEWADDR are handled correctly.

Signed-off-by: Jan Friesse <[email protected]>
  • Loading branch information
jfriesse committed Apr 23, 2024
1 parent f3fe313 commit 7d93365
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,16 @@ int _find_myself(int family, struct booth_site **mep, int fuzzy_allowed)
return 0;
}

h = (struct nlmsghdr *)rcvbuf;
if (h->nlmsg_type == NLMSG_DONE)
break;

if (h->nlmsg_type == NLMSG_ERROR) {
close(fd);
log_error("netlink socket recvmsg error");
return 0;
}
for (h = (struct nlmsghdr *)rcvbuf; NLMSG_OK(h, status); h = NLMSG_NEXT(h, status)) {
if (h->nlmsg_type == NLMSG_DONE)
goto out;

if (h->nlmsg_type == NLMSG_ERROR) {
close(fd);
log_error("netlink socket recvmsg error");
return 0;
}

while (NLMSG_OK(h, status)) {
if (h->nlmsg_type == RTM_NEWADDR) {
struct ifaddrmsg *ifa = NLMSG_DATA(h);
struct rtattr *tb[IFA_MAX+1];
Expand Down Expand Up @@ -271,10 +270,10 @@ int _find_myself(int family, struct booth_site **mep, int fuzzy_allowed)
}
}
}
h = NLMSG_NEXT(h, status);
}
}

out:
close(fd);

if (!me)
Expand Down

0 comments on commit 7d93365

Please sign in to comment.