mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-13 09:20:17 +00:00
netfilter: nft_meta: move interface kind handling to helper
checkpatch complains about == NULL checks in original code, so use !in instead. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
b1327fbc29
commit
a4150a1faa
@ -175,6 +175,30 @@ nft_meta_get_eval_cgroup(u32 *dest, const struct nft_pktinfo *pkt)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static noinline bool nft_meta_get_eval_kind(enum nft_meta_keys key,
|
||||||
|
u32 *dest,
|
||||||
|
const struct nft_pktinfo *pkt)
|
||||||
|
{
|
||||||
|
const struct net_device *in = nft_in(pkt), *out = nft_out(pkt);
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case NFT_META_IIFKIND:
|
||||||
|
if (!in || !in->rtnl_link_ops)
|
||||||
|
return false;
|
||||||
|
strncpy((char *)dest, in->rtnl_link_ops->kind, IFNAMSIZ);
|
||||||
|
break;
|
||||||
|
case NFT_META_OIFKIND:
|
||||||
|
if (!out || !out->rtnl_link_ops)
|
||||||
|
return false;
|
||||||
|
strncpy((char *)dest, out->rtnl_link_ops->kind, IFNAMSIZ);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
@ -286,14 +310,9 @@ void nft_meta_get_eval(const struct nft_expr *expr,
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case NFT_META_IIFKIND:
|
case NFT_META_IIFKIND:
|
||||||
if (in == NULL || in->rtnl_link_ops == NULL)
|
|
||||||
goto err;
|
|
||||||
strncpy((char *)dest, in->rtnl_link_ops->kind, IFNAMSIZ);
|
|
||||||
break;
|
|
||||||
case NFT_META_OIFKIND:
|
case NFT_META_OIFKIND:
|
||||||
if (out == NULL || out->rtnl_link_ops == NULL)
|
if (!nft_meta_get_eval_kind(priv->key, dest, pkt))
|
||||||
goto err;
|
goto err;
|
||||||
strncpy((char *)dest, out->rtnl_link_ops->kind, IFNAMSIZ);
|
|
||||||
break;
|
break;
|
||||||
case NFT_META_TIME_NS:
|
case NFT_META_TIME_NS:
|
||||||
case NFT_META_TIME_DAY:
|
case NFT_META_TIME_DAY:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user