netfilter: nft_fwd_netdev: validate family and chain type
Subsystems (2)
Pablo Neira Ayuso
maintainerPATCH 1/2 netfilter: nft_fwd_netdev: validate family and chain type
Make sure the forward action is only used from ingress.
--- net/netfilter/nft_fwd_netdev.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/netfilter/nft_fwd_netdev.c +9 -0
@@ -190,6 +190,13 @@ static int nft_fwd_neigh_dump(struct sk_buff *skb, const struct nft_expr *expr)return -1 ; } +static int nft_fwd_validate (const struct nft_ctx *ctx, +const struct nft_expr *expr, +const struct nft_data **data) +{ +return nft_chain_validate_hooks (ctx->chain, (1 <<NF_NETDEV_INGRESS )); +} +static struct nft_expr_type nft_fwd_netdev_type;static const struct nft_expr_ops nft_fwd_neigh_netdev_ops = { .type = &nft_fwd_netdev_type,
@@ -197,6 +204,7 @@ static const struct nft_expr_ops nft_fwd_neigh_netdev_ops = { .eval = nft_fwd_neigh_eval, .init = nft_fwd_neigh_init, .dump = nft_fwd_neigh_dump, + .validate = nft_fwd_validate, };static const struct nft_expr_ops nft_fwd_netdev_ops = {
@@ -205,6 +213,7 @@ static const struct nft_expr_ops nft_fwd_netdev_ops = { .eval = nft_fwd_netdev_eval, .init = nft_fwd_netdev_init, .dump = nft_fwd_netdev_dump, + .validate = nft_fwd_validate, .offload = nft_fwd_netdev_offload, };
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH 2/2 netfilter: nft_fwd_netdev: allow to redirect to ifb via ingress
Set skb->tc_redirected to 1, otherwise the ifb driver drops the packet. Set skb->tc_from_ingress to 1 to reinject the packet back to the ingress path after leaving the ifb egress path.
This patch inconditionally sets on these two skb fields that are meaningful to the ifb driver. The existing forward action is guaranteed to run from ingress path.
--- net/netfilter/nft_fwd_netdev.c | 4 ++++ 1 file changed, 4 insertions(+)
net/netfilter/nft_fwd_netdev.c +4 -0
@@ -28,6 +28,10 @@ static void nft_fwd_netdev_eval(const struct nft_expr *expr,struct nft_fwd_netdev *priv =nft_expr_priv (expr);int oif = regs->data[priv->sreg_dev]; +/* These are used by ifb only. */ + pkt->skb->tc_redirected =1 ; + pkt->skb->tc_from_ingress =1 ; +nf_fwd_netdev_egress (pkt, oif); regs->verdict.code =NF_STOLEN ; }
Signature · 1 line
2.11.0
kbuild test robot
build botRe: [PATCH nf 2/2] netfilter: nft_fwd_netdev: allow to redirect to ifb via ingress
I love your patch! Yet something to improve:
Hi Pablo,
I love your patch! Yet something to improve:
[auto build test ERROR on nf-next/master]
[also build test ERROR on v5.6-rc7]
[cannot apply to nf/master next-20200326]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Pablo-Neira-Ayuso/netfilter-nft_fwd_netdev-validate-family-and-chain-type/20200325-185403 base: https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git master config: m68k-sun3_defconfig (attached as .config) compiler: m68k-linux-gcc (GCC) 9.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.2.0 make.cross ARCH=m68k
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
net/netfilter/nft_fwd_netdev.c: In function 'nft_fwd_netdev_eval':
>> net/netfilter/nft_fwd_netdev.c:32:10: error: 'struct sk_buff' has no member named 'tc_redirected'
32 | pkt->skb->tc_redirected = 1;
| ^~
>> net/netfilter/nft_fwd_netdev.c:33:10: error: 'struct sk_buff' has no member named 'tc_from_ingress'
33 | pkt->skb->tc_from_ingress = 1;
| ^~vim +32 net/netfilter/nft_fwd_netdev.c
23
24 static void nft_fwd_netdev_eval(const struct nft_expr *expr,
25 struct nft_regs *regs,
26 const struct nft_pktinfo *pkt)
27 {
28 struct nft_fwd_netdev *priv = nft_expr_priv(expr);
29 int oif = regs->data[priv->sreg_dev];
30
31 /* These are used by ifb only. */
> 32 pkt->skb->tc_redirected = 1;
> 33 pkt->skb->tc_from_ingress = 1;
34
35 nf_fwd_netdev_egress(pkt, oif);
36 regs->verdict.code = NF_STOLEN;
37 }
38 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org