Make nft_payload_mangle helper function applying the payload changes. It does not depend on expr context. Change nft_payload_set_eval to use nft_payload_mangle helper. Signed-off-by: Boris Sukholitko <boris.sukholitko@xxxxxxxxxxxx> --- net/netfilter/nft_payload.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c index 3a3c7746e88f..2a41e7e0b3b7 100644 --- a/net/netfilter/nft_payload.c +++ b/net/netfilter/nft_payload.c @@ -798,13 +798,11 @@ struct nft_payload_set { u8 csum_flags; }; -static void nft_payload_set_eval(const struct nft_expr *expr, - struct nft_regs *regs, - const struct nft_pktinfo *pkt) +static int nft_payload_mangle(const struct nft_payload_set *priv, + const struct nft_pktinfo *pkt, + const u32 *src) { - const struct nft_payload_set *priv = nft_expr_priv(expr); struct sk_buff *skb = pkt->skb; - const u32 *src = ®s->data[priv->sreg]; int offset, csum_offset; __wsum fsum, tsum; @@ -862,6 +860,20 @@ static void nft_payload_set_eval(const struct nft_expr *expr, nft_payload_csum_sctp(skb, nft_thoff(pkt))) goto err; } + return 0; +err: + return -1; +} + +static void nft_payload_set_eval(const struct nft_expr *expr, + struct nft_regs *regs, + const struct nft_pktinfo *pkt) +{ + const struct nft_payload_set *priv = nft_expr_priv(expr); + const u32 *src = ®s->data[priv->sreg]; + + if (nft_payload_mangle(priv, pkt, src)) + goto err; return; err: -- 2.32.0
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature