diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index ff7304ae58ac..76b79bd0f25a 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -486,10 +486,11 @@ static int nf_tables_table_notify(const struct nft_ctx *ctx, int event) ctx->report, GFP_KERNEL); err: if (err < 0) { - nfnetlink_set_err(ctx->net, ctx->portid, NFNLGRP_NFTABLES, - err); + if (nfnetlink_set_err(ctx->net, ctx->portid, NFNLGRP_NFTABLES, + -ENOBUFS) > 0) + return -ENOBUFS; } - return err; + return 0; } static int nf_tables_dump_tables(struct sk_buff *skb, @@ -1076,10 +1077,11 @@ static int nf_tables_chain_notify(const struct nft_ctx *ctx, int event) ctx->report, GFP_KERNEL); err: if (err < 0) { - nfnetlink_set_err(ctx->net, ctx->portid, NFNLGRP_NFTABLES, - err); + if (nfnetlink_set_err(ctx->net, ctx->portid, NFNLGRP_NFTABLES, + -ENOBUFS) > 0) + return -ENOBUFS; } - return err; + return 0; } static int nf_tables_dump_chains(struct sk_buff *skb, @@ -1962,10 +1964,11 @@ static int nf_tables_rule_notify(const struct nft_ctx *ctx, ctx->report, GFP_KERNEL); err: if (err < 0) { - nfnetlink_set_err(ctx->net, ctx->portid, NFNLGRP_NFTABLES, - err); + if (nfnetlink_set_err(ctx->net, ctx->portid, NFNLGRP_NFTABLES, + -ENOBUFS) > 0) + return -ENOBUFS; } - return err; + return 0; } struct nft_rule_dump_ctx { @@ -2722,9 +2725,12 @@ static int nf_tables_set_notify(const struct nft_ctx *ctx, err = nfnetlink_send(skb, ctx->net, portid, NFNLGRP_NFTABLES, ctx->report, gfp_flags); err: - if (err < 0) - nfnetlink_set_err(ctx->net, portid, NFNLGRP_NFTABLES, err); - return err; + if (err < 0) { + if (nfnetlink_set_err(ctx->net, portid, NFNLGRP_NFTABLES, + -ENOBUFS) > 0) + return -ENOBUFS; + } + return 0; } static int nf_tables_dump_sets(struct sk_buff *skb, struct netlink_callback *cb) @@ -3532,9 +3538,12 @@ static int nf_tables_setelem_notify(const struct nft_ctx *ctx, err = nfnetlink_send(skb, net, portid, NFNLGRP_NFTABLES, ctx->report, GFP_KERNEL); err: - if (err < 0) - nfnetlink_set_err(net, portid, NFNLGRP_NFTABLES, err); - return err; + if (err < 0) { + if (nfnetlink_set_err(net, portid, NFNLGRP_NFTABLES, + -ENOBUFS) > 0) + return -ENOBUFS; + } + return 0; } static struct nft_trans *nft_trans_elem_alloc(struct nft_ctx *ctx, @@ -4502,9 +4511,11 @@ int nft_obj_notify(struct net *net, struct nft_table *table, err = nfnetlink_send(skb, net, portid, NFNLGRP_NFTABLES, report, gfp); err: if (err < 0) { - nfnetlink_set_err(net, portid, NFNLGRP_NFTABLES, err); + if (nfnetlink_set_err(net, portid, NFNLGRP_NFTABLES, + -ENOBUFS) > 0) + return -ENOBUFS; } - return err; + return 0; } EXPORT_SYMBOL_GPL(nft_obj_notify); @@ -4569,10 +4580,11 @@ static int nf_tables_gen_notify(struct net *net, struct sk_buff *skb, int event) NFNLGRP_NFTABLES, nlmsg_report(nlh), GFP_KERNEL); err: if (err < 0) { - nfnetlink_set_err(net, NETLINK_CB(skb).portid, NFNLGRP_NFTABLES, - err); + if (nfnetlink_set_err(net, NETLINK_CB(skb).portid, + NFNLGRP_NFTABLES, -ENOBUFS) > 0) + return -ENOBUFS; } - return err; + return 0; } static int nf_tables_getgen(struct net *net, struct sock *nlsk,