netlink: Start sequence number from 1 instead of 0

Netlink messages have a sequence number that's used to match requests to
responses.  It mostly doesn't matter what it is as long as it monotonically
increases, so we just use a global counter which we advance with each
request.

However, we start this counter at 0, so our very first request has sequence
number 0, which is usually reserved for asynchronous messages from the
kernel which aren't in response to a specific request. Since we don't (for
now) use such async messages, this doesn't really matter, but it's not
good practce.  So start the sequence at 1 instead.

Link: https://bugs.passt.top/show_bug.cgi?id=67
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson 2023-08-03 17:19:46 +10:00 committed by Stefano Brivio
parent dee7594180
commit 0a568c847d

View file

@ -40,7 +40,7 @@
/* Socket in init, in target namespace, sequence (just needs to be monotonic) */ /* Socket in init, in target namespace, sequence (just needs to be monotonic) */
int nl_sock = -1; int nl_sock = -1;
int nl_sock_ns = -1; int nl_sock_ns = -1;
static int nl_seq; static int nl_seq = 1;
/** /**
* nl_sock_init_do() - Set up netlink sockets in init or target namespace * nl_sock_init_do() - Set up netlink sockets in init or target namespace