Commit e7246e12 authored by Willem de Bruijn's avatar Willem de Bruijn Committed by David S. Miller

net-tc: extract skip classify bit from tc_verd

Packets sent by the IFB device skip subsequent tc classification.
A single bit governs this state. Move it out of tc_verd in
anticipation of removing that __u16 completely.

The new bitfield tc_skip_classify temporarily uses one bit of a
hole, until tc_verd is removed completely in a follow-up patch.

Remove the bit hole comment. It could be 2, 3, 4 or 5 bits long.
With that many options, little value in documenting it.

Introduce a helper function to deduplicate the logic in the two
sites that check this bit.

The field tc_skip_classify is set only in IFB on skbs cloned in
act_mirred, so original packet sources do not have to clear the
bit when reusing packets (notably, pktgen and octeon).
Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d6264071
...@@ -81,7 +81,7 @@ static void ifb_ri_tasklet(unsigned long _txp) ...@@ -81,7 +81,7 @@ static void ifb_ri_tasklet(unsigned long _txp)
u32 from = G_TC_FROM(skb->tc_verd); u32 from = G_TC_FROM(skb->tc_verd);
skb->tc_verd = 0; skb->tc_verd = 0;
skb->tc_verd = SET_TC_NCLS(skb->tc_verd); skb->tc_skip_classify = 1;
u64_stats_update_begin(&txp->tsync); u64_stats_update_begin(&txp->tsync);
txp->tx_packets++; txp->tx_packets++;
......
...@@ -589,6 +589,7 @@ static inline bool skb_mstamp_after(const struct skb_mstamp *t1, ...@@ -589,6 +589,7 @@ static inline bool skb_mstamp_after(const struct skb_mstamp *t1,
* @pkt_type: Packet class * @pkt_type: Packet class
* @fclone: skbuff clone status * @fclone: skbuff clone status
* @ipvs_property: skbuff is owned by ipvs * @ipvs_property: skbuff is owned by ipvs
* @tc_skip_classify: do not classify packet. set by IFB device
* @peeked: this packet has been seen already, so stats have been * @peeked: this packet has been seen already, so stats have been
* done for it, don't do them again * done for it, don't do them again
* @nf_trace: netfilter packet trace flag * @nf_trace: netfilter packet trace flag
...@@ -749,7 +750,9 @@ struct sk_buff { ...@@ -749,7 +750,9 @@ struct sk_buff {
#ifdef CONFIG_NET_SWITCHDEV #ifdef CONFIG_NET_SWITCHDEV
__u8 offload_fwd_mark:1; __u8 offload_fwd_mark:1;
#endif #endif
/* 2, 4 or 5 bit hole */ #ifdef CONFIG_NET_CLS_ACT
__u8 tc_skip_classify:1;
#endif
#ifdef CONFIG_NET_SCHED #ifdef CONFIG_NET_SCHED
__u16 tc_index; /* traffic control index */ __u16 tc_index; /* traffic control index */
......
...@@ -418,6 +418,17 @@ static inline bool skb_at_tc_ingress(const struct sk_buff *skb) ...@@ -418,6 +418,17 @@ static inline bool skb_at_tc_ingress(const struct sk_buff *skb)
#endif #endif
} }
static inline bool skb_skip_tc_classify(struct sk_buff *skb)
{
#ifdef CONFIG_NET_CLS_ACT
if (skb->tc_skip_classify) {
skb->tc_skip_classify = 0;
return true;
}
#endif
return false;
}
/* Reset all TX qdiscs greater then index of a device. */ /* Reset all TX qdiscs greater then index of a device. */
static inline void qdisc_reset_all_tx_gt(struct net_device *dev, unsigned int i) static inline void qdisc_reset_all_tx_gt(struct net_device *dev, unsigned int i)
{ {
......
...@@ -22,8 +22,6 @@ bit 6,7: Where this packet was last seen ...@@ -22,8 +22,6 @@ bit 6,7: Where this packet was last seen
1: on the Ingress 1: on the Ingress
2: on the Egress 2: on the Egress
bit 8: when set --> Request not to classify on ingress.
* *
* */ * */
...@@ -36,10 +34,6 @@ bit 8: when set --> Request not to classify on ingress. ...@@ -36,10 +34,6 @@ bit 8: when set --> Request not to classify on ingress.
#define AT_INGRESS 0x1 #define AT_INGRESS 0x1
#define AT_EGRESS 0x2 #define AT_EGRESS 0x2
#define TC_NCLS _TC_MAKEMASK1(8)
#define SET_TC_NCLS(v) ( TC_NCLS | (v & ~TC_NCLS))
#define CLR_TC_NCLS(v) ( v & ~TC_NCLS)
#define S_TC_AT _TC_MAKE32(12) #define S_TC_AT _TC_MAKE32(12)
#define M_TC_AT _TC_MAKEMASK(2,S_TC_AT) #define M_TC_AT _TC_MAKEMASK(2,S_TC_AT)
#define G_TC_AT(x) _TC_GETVALUE(x,S_TC_AT,M_TC_AT) #define G_TC_AT(x) _TC_GETVALUE(x,S_TC_AT,M_TC_AT)
......
...@@ -4093,12 +4093,8 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc) ...@@ -4093,12 +4093,8 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc)
goto out; goto out;
} }
#ifdef CONFIG_NET_CLS_ACT if (skb_skip_tc_classify(skb))
if (skb->tc_verd & TC_NCLS) { goto skip_classify;
skb->tc_verd = CLR_TC_NCLS(skb->tc_verd);
goto ncls;
}
#endif
if (pfmemalloc) if (pfmemalloc)
goto skip_taps; goto skip_taps;
...@@ -4128,8 +4124,8 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc) ...@@ -4128,8 +4124,8 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc)
#endif #endif
#ifdef CONFIG_NET_CLS_ACT #ifdef CONFIG_NET_CLS_ACT
skb->tc_verd = 0; skb->tc_verd = 0;
ncls:
#endif #endif
skip_classify:
if (pfmemalloc && !skb_pfmemalloc_protocol(skb)) if (pfmemalloc && !skb_pfmemalloc_protocol(skb))
goto drop; goto drop;
......
...@@ -426,11 +426,9 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions, ...@@ -426,11 +426,9 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions,
{ {
int ret = -1, i; int ret = -1, i;
if (skb->tc_verd & TC_NCLS) { if (skb_skip_tc_classify(skb))
skb->tc_verd = CLR_TC_NCLS(skb->tc_verd); return TC_ACT_OK;
ret = TC_ACT_OK;
goto exec_done;
}
for (i = 0; i < nr_actions; i++) { for (i = 0; i < nr_actions; i++) {
const struct tc_action *a = actions[i]; const struct tc_action *a = actions[i];
...@@ -439,9 +437,8 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions, ...@@ -439,9 +437,8 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions,
if (ret == TC_ACT_REPEAT) if (ret == TC_ACT_REPEAT)
goto repeat; /* we need a ttl - JHS */ goto repeat; /* we need a ttl - JHS */
if (ret != TC_ACT_PIPE) if (ret != TC_ACT_PIPE)
goto exec_done; break;
} }
exec_done:
return ret; return ret;
} }
EXPORT_SYMBOL(tcf_action_exec); EXPORT_SYMBOL(tcf_action_exec);
......
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