Commit 01a0fc82 authored by Florian Westphal's avatar Florian Westphal Committed by Pablo Neira Ayuso

netfilter: nft_meta: place rtclassid handling in a helper

skb_dst is an inline helper with a WARN_ON(), so this is a bit more code
than it looks like.
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 6b2faee0
...@@ -273,6 +273,20 @@ static noinline u32 nft_prandom_u32(void) ...@@ -273,6 +273,20 @@ static noinline u32 nft_prandom_u32(void)
return prandom_u32_state(state); return prandom_u32_state(state);
} }
#ifdef CONFIG_IP_ROUTE_CLASSID
static noinline bool
nft_meta_get_eval_rtclassid(const struct sk_buff *skb, u32 *dest)
{
const struct dst_entry *dst = skb_dst(skb);
if (!dst)
return false;
*dest = dst->tclassid;
return true;
}
#endif
void nft_meta_get_eval(const struct nft_expr *expr, void nft_meta_get_eval(const struct nft_expr *expr,
struct nft_regs *regs, struct nft_regs *regs,
const struct nft_pktinfo *pkt) const struct nft_pktinfo *pkt)
...@@ -319,14 +333,10 @@ void nft_meta_get_eval(const struct nft_expr *expr, ...@@ -319,14 +333,10 @@ void nft_meta_get_eval(const struct nft_expr *expr,
goto err; goto err;
break; break;
#ifdef CONFIG_IP_ROUTE_CLASSID #ifdef CONFIG_IP_ROUTE_CLASSID
case NFT_META_RTCLASSID: { case NFT_META_RTCLASSID:
const struct dst_entry *dst = skb_dst(skb); if (!nft_meta_get_eval_rtclassid(skb, dest))
if (dst == NULL)
goto err; goto err;
*dest = dst->tclassid;
break; break;
}
#endif #endif
#ifdef CONFIG_NETWORK_SECMARK #ifdef CONFIG_NETWORK_SECMARK
case NFT_META_SECMARK: case NFT_META_SECMARK:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment