zebra: Store the sequence number to use as part of the dp_info

Store and use the sequence number instead of using what is in
the `struct nlsock`.  Future commits are going away from storing
the `struct nlsock` and the copy of the nlsock was guaranteeing
unique sequence numbers per message.  So let's store the
sequence number to use instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2022-02-08 09:47:24 -05:00
parent b564209367
commit 3670f5047c
2 changed files with 10 additions and 7 deletions

View file

@ -1038,7 +1038,7 @@ netlink_talk_info(int (*filter)(struct nlmsghdr *, ns_id_t, int startup),
const struct nlsock *nl; const struct nlsock *nl;
nl = &(dp_info->nls); nl = &(dp_info->nls);
n->nlmsg_seq = nl->seq; n->nlmsg_seq = dp_info->seq;
n->nlmsg_pid = nl->snl.nl_pid; n->nlmsg_pid = nl->snl.nl_pid;
if (IS_ZEBRA_DEBUG_KERNEL) if (IS_ZEBRA_DEBUG_KERNEL)
@ -1172,8 +1172,8 @@ static int nl_batch_read_resp(struct nl_batch *bth)
* 'update' context objects take two consecutive * 'update' context objects take two consecutive
* sequence numbers. * sequence numbers.
*/ */
if (dplane_ctx_is_update(ctx) if (dplane_ctx_is_update(ctx) &&
&& dplane_ctx_get_ns(ctx)->nls.seq + 1 == seq) { dplane_ctx_get_ns(ctx)->seq + 1 == seq) {
/* /*
* This is the situation where we get a response * This is the situation where we get a response
* to a message that should be ignored. * to a message that should be ignored.
@ -1186,14 +1186,14 @@ static int nl_batch_read_resp(struct nl_batch *bth)
dplane_ctx_enqueue_tail(bth->ctx_out_q, ctx); dplane_ctx_enqueue_tail(bth->ctx_out_q, ctx);
/* We have found corresponding context object. */ /* We have found corresponding context object. */
if (dplane_ctx_get_ns(ctx)->nls.seq == seq) if (dplane_ctx_get_ns(ctx)->seq == seq)
break; break;
if (dplane_ctx_get_ns(ctx)->nls.seq > seq) if (dplane_ctx_get_ns(ctx)->seq > seq)
zlog_warn( zlog_warn(
"%s:WARNING Recieved %u is less than any context on the queue ctx->seq %u", "%s:WARNING Recieved %u is less than any context on the queue ctx->seq %u",
__func__, seq, __func__, seq,
dplane_ctx_get_ns(ctx)->nls.seq); dplane_ctx_get_ns(ctx)->seq);
} }
if (ignore_msg) { if (ignore_msg) {
@ -1360,7 +1360,7 @@ enum netlink_msg_status netlink_batch_add_msg(
return FRR_NETLINK_ERROR; return FRR_NETLINK_ERROR;
} }
seq = dplane_ctx_get_ns(ctx)->nls.seq; seq = dplane_ctx_get_ns(ctx)->seq;
if (ignore_res) if (ignore_res)
seq++; seq++;

View file

@ -42,6 +42,7 @@ struct zebra_dplane_info {
#if defined(HAVE_NETLINK) #if defined(HAVE_NETLINK)
struct nlsock nls; struct nlsock nls;
int seq;
bool is_cmd; bool is_cmd;
#endif #endif
}; };
@ -57,8 +58,10 @@ zebra_dplane_info_from_zns(struct zebra_dplane_info *zns_info,
zns_info->is_cmd = is_cmd; zns_info->is_cmd = is_cmd;
if (is_cmd) { if (is_cmd) {
zns_info->nls = zns->netlink_cmd; zns_info->nls = zns->netlink_cmd;
zns_info->seq = zns->netlink_cmd.seq;
} else { } else {
zns_info->nls = zns->netlink; zns_info->nls = zns->netlink;
zns_info->seq = zns->netlink.seq;
} }
#endif /* NETLINK */ #endif /* NETLINK */
} }