Mercurial > hg > dhcpcd
changeset 5387:08cbef5c8e9e draft
Linux: Warn if netlink(7) seq number doesn't match expectation.
While here, ensure it never goes out of scope.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Mon, 22 Jun 2020 22:09:31 +0100 |
| parents | b28b0962bfe2 |
| children | 9bb47d579f62 |
| files | src/if-linux.c |
| diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/if-linux.c Mon Jun 22 21:56:16 2020 +0100 +++ b/src/if-linux.c Mon Jun 22 22:09:31 2020 +0100 @@ -523,8 +523,12 @@ terminated = true; break; } - if (cb != NULL && - (nlm->nlmsg_seq == (uint32_t)ctx->seq || fd == ctx->link_fd)) + if (cb == NULL) + continue; + if (nlm->nlmsg_seq != (uint32_t)ctx->seq && fd != ctx->link_fd) + logwarnx("%s: received sequence %u, expecting %d", + __func__, nlm->nlmsg_seq, ctx->seq); + else r = cb(ctx, cbarg, nlm); } @@ -1013,6 +1017,8 @@ /* Request a reply */ hdr->nlmsg_flags |= NLM_F_ACK; hdr->nlmsg_seq = (uint32_t)++ctx->seq; + if ((unsigned int)ctx->seq > UINT32_MAX) + ctx->seq = 0; #ifdef PRIVSEP if (ctx->options & DHCPCD_PRIVSEP && if_netlinkpriv(protocol, hdr))
