diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c index 26ceea2057..08f9782cf7 100644 --- a/zebra/kernel_netlink.c +++ b/zebra/kernel_netlink.c @@ -1155,15 +1155,18 @@ static int nl_batch_read_resp(struct nl_batch *bth) * requests at same time. */ while (true) { - ctx = dplane_ctx_dequeue(&(bth->ctx_list)); - if (ctx == NULL) - break; - - dplane_ctx_enqueue_tail(bth->ctx_out_q, ctx); - - /* We have found corresponding context object. */ - if (dplane_ctx_get_ns(ctx)->nls.seq == seq) + ctx = dplane_ctx_get_head(&(bth->ctx_list)); + if (ctx == NULL) { + /* + * This is a situation where we have gotten + * into a bad spot. We need to know that + * this happens( does it? ) + */ + zlog_err( + "%s:WARNING Received netlink Response for an error and no Contexts to associate with it", + __func__); break; + } /* * 'update' context objects take two consecutive @@ -1178,10 +1181,35 @@ static int nl_batch_read_resp(struct nl_batch *bth) ignore_msg = true; break; } + + ctx = dplane_ctx_dequeue(&(bth->ctx_list)); + dplane_ctx_enqueue_tail(bth->ctx_out_q, ctx); + + /* We have found corresponding context object. */ + if (dplane_ctx_get_ns(ctx)->nls.seq == seq) + break; + + if (dplane_ctx_get_ns(ctx)->nls.seq > seq) + zlog_warn( + "%s:WARNING Recieved %u is less than any context on the queue ctx->seq %u", + __func__, seq, + dplane_ctx_get_ns(ctx)->nls.seq); } - if (ignore_msg) + if (ignore_msg) { + /* + * If we ignore the message due to an update + * above we should still fricking decode the + * message for our operator to understand + * what is going on + */ + int err = netlink_parse_error(nl, h, bth->zns->is_cmd, + false); + + zlog_debug("%s: netlink error message seq=%d %d", + __func__, h->nlmsg_seq, err); continue; + } /* * We received a message with the sequence number that isn't diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c index 96a606af98..656ebcf3b7 100644 --- a/zebra/zebra_dplane.c +++ b/zebra/zebra_dplane.c @@ -833,6 +833,13 @@ void dplane_ctx_list_append(struct dplane_ctx_q *to_list, } } +struct zebra_dplane_ctx *dplane_ctx_get_head(struct dplane_ctx_q *q) +{ + struct zebra_dplane_ctx *ctx = TAILQ_FIRST(q); + + return ctx; +} + /* Dequeue a context block from the head of a list */ struct zebra_dplane_ctx *dplane_ctx_dequeue(struct dplane_ctx_q *q) { diff --git a/zebra/zebra_dplane.h b/zebra/zebra_dplane.h index 977f00bd2a..1d55181388 100644 --- a/zebra/zebra_dplane.h +++ b/zebra/zebra_dplane.h @@ -274,6 +274,7 @@ void dplane_ctx_list_append(struct dplane_ctx_q *to_list, /* Dequeue a context block from the head of caller's tailq */ struct zebra_dplane_ctx *dplane_ctx_dequeue(struct dplane_ctx_q *q); +struct zebra_dplane_ctx *dplane_ctx_get_head(struct dplane_ctx_q *q); /* * Accessors for information from the context object