netfilter: nft_fwd_netdev: Fix CONFIG_NET_CLS_ACT=n build
Subsystems (5)
PATCH 1/1 netfilter: nft_fwd_netdev: Fix CONFIG_NET_CLS_ACT=n build
If CONFIG_NET_CLS_ACT=n:
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’
pkt->skb->tc_redirected = 1;
^~
net/netfilter/nft_fwd_netdev.c:33:10: error: ‘struct sk_buff’ has no member named ‘tc_from_ingress’
pkt->skb->tc_from_ingress = 1;
^~Fix this by protecting this code hunk with the appropriate #ifdef.
--- net/netfilter/nft_fwd_netdev.c | 2 ++ 1 file changed, 2 insertions(+)
net/netfilter/nft_fwd_netdev.c +2 -0
@@ -28,9 +28,11 @@ 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]; +#ifdef CONFIG_NET_CLS_ACT /* These are used by ifb only. */ pkt->skb->tc_redirected =1 ; pkt->skb->tc_from_ingress =1 ; +#endif nf_fwd_netdev_egress (pkt, oif); regs->verdict.code =NF_STOLEN ;
Signature · 1 line
2.17.1
Pablo Neira Ayuso
maintainerQuoted 11 lines · Geert Uytterhoeven
If
CONFIG_NET_CLS_ACT=n: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’ pkt->skb->tc_redirected = 1; ^~ net/netfilter/nft_fwd_netdev.c:33:10: error: ‘struct sk_buff’ has no member named ‘tc_from_ingress’ pkt->skb->tc_from_ingress = 1; ^~Fix this by protecting this code hunk with the appropriate #ifdef.
Sorry about this, and thank you for fixing up this so fast.
I'm attaching an alternative fix to avoid a dependency on tc from netfilter. Still testing, if fine and no objections I'll formally submit this.
drivers/net/Kconfig +1 -0
@@ -149,6 +149,7 @@ config NET_FC config IFB tristate "Intermediate Functional Block support" depends on NET_CLS_ACT + select NET_REDIRECT ---help--- This is an intermediate driver that allows sharing of resources.
drivers/net/ifb.c +3 -3
@@ -75,7 +75,7 @@ static void ifb_ri_tasklet(unsigned long _txp) }while ((skb =__skb_dequeue (&txp->tq)) !=NULL ) { - skb->tc_redirected =0 ; + skb->redirected =0 ; skb->tc_skip_classify =1 ;u64_stats_update_begin (&txp->tsync);
@@ -96,7 +96,7 @@ static void ifb_ri_tasklet(unsigned long _txp)rcu_read_unlock (); skb->skb_iif = txp->dev->ifindex; -if (!skb->tc_from_ingress) { +if (!skb->from_ingress) {dev_queue_xmit (skb); }else {skb_pull_rcsum (skb, skb->mac_len);
@@ -243,7 +243,7 @@ static netdev_tx_t ifb_xmit(struct sk_buff *skb, struct net_device *dev) txp->rx_bytes += skb->len;u64_stats_update_end (&txp->rsync); -if (!skb->tc_redirected || !skb->skb_iif) { +if (!skb->redirected || !skb->skb_iif) {dev_kfree_skb (skb); dev->stats.rx_dropped++;return NETDEV_TX_OK ;
include/linux/skbuff.h +30 -2
@@ -848,8 +848,10 @@ struct sk_buff {#ifdef CONFIG_NET_CLS_ACT __u8 tc_skip_classify:1; __u8 tc_at_ingress:1; - __u8 tc_redirected:1; - __u8 tc_from_ingress:1; +#endif +#ifdef CONFIG_NET_REDIRECT + __u8 redirected:1; + __u8 from_ingress:1;#endif #ifdef CONFIG_TLS_DEVICE __u8 decrypted:1;
@@ -4579,5 +4581,31 @@ static inline __wsum lco_csum(struct sk_buff *skb)return csum_partial (l4_hdr, csum_start - l4_hdr, partial); } +static inline bool skb_is_redirected (const struct sk_buff *skb) +{ +#ifdef CONFIG_NET_REDIRECT +return skb->redirected; +#else +return false; +#endif +} + +static inline void skb_set_redirected (struct sk_buff *skb,bool from_ingress) +{ +#ifdef CONFIG_NET_REDIRECT + skb->redirected =1 ; + skb->from_ingress = from_ingress; +if (skb->from_ingress) + skb->tstamp =0 ; +#endif +} + +static inline void skb_reset_redirect (struct sk_buff *skb) +{ +#ifdef CONFIG_NET_REDIRECT + skb->redirected =0 ; +#endif +} +#endif /* __KERNEL__ */ #endif /* _LINUX_SKBUFF_H */
include/net/sch_generic.h +0 -16
@@ -675,22 +675,6 @@ void __qdisc_calculate_pkt_len(struct sk_buff *skb, const struct qdisc_size_table *stab);int skb_do_redirect (struct sk_buff *); -static inline void skb_reset_tc (struct sk_buff *skb) -{ -#ifdef CONFIG_NET_CLS_ACT - skb->tc_redirected =0 ; -#endif -} - -static inline bool skb_is_tc_redirected (const struct sk_buff *skb) -{ -#ifdef CONFIG_NET_CLS_ACT -return skb->tc_redirected; -#else -return false; -#endif -} -static inline bool skb_at_tc_ingress (const struct sk_buff *skb) {#ifdef CONFIG_NET_CLS_ACT
net/Kconfig +3 -0
@@ -52,6 +52,9 @@ config NET_INGRESS config NET_EGRESS bool +config NET_REDIRECT + bool + config SKB_EXTENSIONS bool
net/core/dev.c +2 -2
@@ -4516,7 +4516,7 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb,/* Reinjected packets coming from act_mirred or similar should * not get XDP generic processing. */ -if (skb_is_tc_redirected (skb)) +if (skb_is_redirected (skb))return XDP_PASS ;/* XDP packets must be linear and must have sufficient headroom
@@ -5063,7 +5063,7 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc, goto out; }#endif -skb_reset_tc (skb); +skb_reset_redirect (skb); skip_classify:if (pfmemalloc && !skb_pfmemalloc_protocol (skb)) goto drop;
net/netfilter/nft_fwd_netdev.c +2 -3
@@ -28,9 +28,8 @@ 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 ; +/* This is used by ifb only. */ +skb_set_redirected (pkt->skb, true);nf_fwd_netdev_egress (pkt, oif); regs->verdict.code =NF_STOLEN ;
net/sched/act_mirred.c +2 -4
@@ -284,10 +284,8 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,/* mirror is always swallowed */ if (is_redirect) { - skb2->tc_redirected =1 ; - skb2->tc_from_ingress = skb2->tc_at_ingress; -if (skb2->tc_from_ingress) - skb2->tstamp =0 ; +skb_set_redirected (skb2, skb2->tc_at_ingress); +/* let's the caller reinsert the packet, if possible */ if (use_reinsert) { res->ingress = want_ingress;
Hi Pablo,
Quoted 11 lines · Pablo Neira Ayuso
Quoted 10 lines · Geert Uytterhoeven
If
CONFIG_NET_CLS_ACT=n: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’ pkt->skb->tc_redirected = 1; ^~ net/netfilter/nft_fwd_netdev.c:33:10: error: ‘struct sk_buff’ has no member named ‘tc_from_ingress’ pkt->skb->tc_from_ingress = 1; ^~
Quoted 7 lines
Quoted 1 line
Fix this by protecting this code hunk with the appropriate #ifdef.
Sorry about this, and thank you for fixing up this so fast.
I'm attaching an alternative fix to avoid a dependency on tc from netfilter. Still testing, if fine and no objections I'll formally submit this.
Thanks, that fixes the issue, too.
(Note that I didn't do a full build).
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Pablo Neira Ayuso
maintainerQuoted 16 lines · Geert Uytterhoeven
Hi Pablo,
Quoted 13 lines · Pablo Neira Ayuso
Quoted 11 lines · Geert Uytterhoeven
If
CONFIG_NET_CLS_ACT=n: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’ pkt->skb->tc_redirected = 1; ^~ net/netfilter/nft_fwd_netdev.c:33:10: error: ‘struct sk_buff’ has no member named ‘tc_from_ingress’ pkt->skb->tc_from_ingress = 1; ^~Fix this by protecting this code hunk with the appropriate #ifdef.
Quoted 8 lines
Quoted 5 lines
Sorry about this, and thank you for fixing up this so fast.
I'm attaching an alternative fix to avoid a dependency on tc from netfilter. Still testing, if fine and no objections I'll formally submit this.
Thanks, that fixes the issue, too.
(Note that I didn't do a full build).
Thanks. I'll submit formaly asap.
There was another spot I forgot to update in net/core/pktgen.c, I will include that chunk too in my formal submission.