netfilter: nfnetlink: allow commit to fail
authorFlorian Westphal <fw@strlen.de>
Thu, 24 May 2018 22:25:47 +0000 (00:25 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 28 May 2018 22:27:26 +0000 (00:27 +0200)
->commit() cannot fail at the moment.

Followup-patch adds kmalloc calls in the commit phase, so we'll need
to be able to handle errors.

Make it so that -EGAIN causes a full replay, and make other errors
cause the transaction to fail.

Failing is ok from a consistency point of view as long as we
perform all actions that could return an error before
we increment the generation counter and the base seq.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nfnetlink.c

index 03ead8a..88c9e22 100644 (file)
@@ -441,7 +441,14 @@ done:
                kfree_skb(skb);
                goto replay;
        } else if (status == NFNL_BATCH_DONE) {
-               ss->commit(net, oskb);
+               err = ss->commit(net, oskb);
+               if (err == -EAGAIN) {
+                       status |= NFNL_BATCH_REPLAY;
+                       goto done;
+               } else if (err) {
+                       ss->abort(net, oskb);
+                       netlink_ack(oskb, nlmsg_hdr(oskb), err, NULL);
+               }
        } else {
                ss->abort(net, oskb);
        }