aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWillem de Bruijn <willemb@google.com>2017-01-07 17:06:35 -0500
committerDavid S. Miller <davem@davemloft.net>2017-01-08 20:58:52 -0500
commite7246e122aaa99ebbb8ad7da80f35a20577bd8af (patch)
treee1da3b73bd34b4e85b7b781276aa3ab65acb15d4
parentd6264071ce7d100a2b7c1f295167796ab5178caf (diff)
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: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ifb.c2
-rw-r--r--include/linux/skbuff.h5
-rw-r--r--include/net/sch_generic.h11
-rw-r--r--include/uapi/linux/pkt_cls.h6
-rw-r--r--net/core/dev.c10
-rw-r--r--net/sched/act_api.c11
6 files changed, 23 insertions, 22 deletions
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index 082534e187fc..442c4c4a9606 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -81,7 +81,7 @@ static void ifb_ri_tasklet(unsigned long _txp)
81 u32 from = G_TC_FROM(skb->tc_verd); 81 u32 from = G_TC_FROM(skb->tc_verd);
82 82
83 skb->tc_verd = 0; 83 skb->tc_verd = 0;
84 skb->tc_verd = SET_TC_NCLS(skb->tc_verd); 84 skb->tc_skip_classify = 1;
85 85
86 u64_stats_update_begin(&txp->tsync); 86 u64_stats_update_begin(&txp->tsync);
87 txp->tx_packets++; 87 txp->tx_packets++;
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index b53c0cfd417e..570f60ec6cb4 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -589,6 +589,7 @@ static inline bool skb_mstamp_after(const struct skb_mstamp *t1,
589 * @pkt_type: Packet class 589 * @pkt_type: Packet class
590 * @fclone: skbuff clone status 590 * @fclone: skbuff clone status
591 * @ipvs_property: skbuff is owned by ipvs 591 * @ipvs_property: skbuff is owned by ipvs
592 * @tc_skip_classify: do not classify packet. set by IFB device
592 * @peeked: this packet has been seen already, so stats have been 593 * @peeked: this packet has been seen already, so stats have been
593 * done for it, don't do them again 594 * done for it, don't do them again
594 * @nf_trace: netfilter packet trace flag 595 * @nf_trace: netfilter packet trace flag
@@ -749,7 +750,9 @@ struct sk_buff {
749#ifdef CONFIG_NET_SWITCHDEV 750#ifdef CONFIG_NET_SWITCHDEV
750 __u8 offload_fwd_mark:1; 751 __u8 offload_fwd_mark:1;
751#endif 752#endif
752 /* 2, 4 or 5 bit hole */ 753#ifdef CONFIG_NET_CLS_ACT
754 __u8 tc_skip_classify:1;
755#endif
753 756
754#ifdef CONFIG_NET_SCHED 757#ifdef CONFIG_NET_SCHED
755 __u16 tc_index; /* traffic control index */ 758 __u16 tc_index; /* traffic control index */
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 498f81b229a4..857356f2d74b 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -418,6 +418,17 @@ static inline bool skb_at_tc_ingress(const struct sk_buff *skb)
418#endif 418#endif
419} 419}
420 420
421static inline bool skb_skip_tc_classify(struct sk_buff *skb)
422{
423#ifdef CONFIG_NET_CLS_ACT
424 if (skb->tc_skip_classify) {
425 skb->tc_skip_classify = 0;
426 return true;
427 }
428#endif
429 return false;
430}
431
421/* Reset all TX qdiscs greater then index of a device. */ 432/* Reset all TX qdiscs greater then index of a device. */
422static inline void qdisc_reset_all_tx_gt(struct net_device *dev, unsigned int i) 433static inline void qdisc_reset_all_tx_gt(struct net_device *dev, unsigned int i)
423{ 434{
diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index bba23dbb3ab6..1eed5d7509bc 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -22,8 +22,6 @@ bit 6,7: Where this packet was last seen
221: on the Ingress 221: on the Ingress
232: on the Egress 232: on the Egress
24 24
25bit 8: when set --> Request not to classify on ingress.
26
27 * 25 *
28 * */ 26 * */
29 27
@@ -36,10 +34,6 @@ bit 8: when set --> Request not to classify on ingress.
36#define AT_INGRESS 0x1 34#define AT_INGRESS 0x1
37#define AT_EGRESS 0x2 35#define AT_EGRESS 0x2
38 36
39#define TC_NCLS _TC_MAKEMASK1(8)
40#define SET_TC_NCLS(v) ( TC_NCLS | (v & ~TC_NCLS))
41#define CLR_TC_NCLS(v) ( v & ~TC_NCLS)
42
43#define S_TC_AT _TC_MAKE32(12) 37#define S_TC_AT _TC_MAKE32(12)
44#define M_TC_AT _TC_MAKEMASK(2,S_TC_AT) 38#define M_TC_AT _TC_MAKEMASK(2,S_TC_AT)
45#define G_TC_AT(x) _TC_GETVALUE(x,S_TC_AT,M_TC_AT) 39#define G_TC_AT(x) _TC_GETVALUE(x,S_TC_AT,M_TC_AT)
diff --git a/net/core/dev.c b/net/core/dev.c
index 56818f7eab2b..e39e35d2e082 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4093,12 +4093,8 @@ another_round:
4093 goto out; 4093 goto out;
4094 } 4094 }
4095 4095
4096#ifdef CONFIG_NET_CLS_ACT 4096 if (skb_skip_tc_classify(skb))
4097 if (skb->tc_verd & TC_NCLS) { 4097 goto skip_classify;
4098 skb->tc_verd = CLR_TC_NCLS(skb->tc_verd);
4099 goto ncls;
4100 }
4101#endif
4102 4098
4103 if (pfmemalloc) 4099 if (pfmemalloc)
4104 goto skip_taps; 4100 goto skip_taps;
@@ -4128,8 +4124,8 @@ skip_taps:
4128#endif 4124#endif
4129#ifdef CONFIG_NET_CLS_ACT 4125#ifdef CONFIG_NET_CLS_ACT
4130 skb->tc_verd = 0; 4126 skb->tc_verd = 0;
4131ncls:
4132#endif 4127#endif
4128skip_classify:
4133 if (pfmemalloc && !skb_pfmemalloc_protocol(skb)) 4129 if (pfmemalloc && !skb_pfmemalloc_protocol(skb))
4134 goto drop; 4130 goto drop;
4135 4131
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 2095c83ce773..f04715a57300 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -426,11 +426,9 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions,
426{ 426{
427 int ret = -1, i; 427 int ret = -1, i;
428 428
429 if (skb->tc_verd & TC_NCLS) { 429 if (skb_skip_tc_classify(skb))
430 skb->tc_verd = CLR_TC_NCLS(skb->tc_verd); 430 return TC_ACT_OK;
431 ret = TC_ACT_OK; 431
432 goto exec_done;
433 }
434 for (i = 0; i < nr_actions; i++) { 432 for (i = 0; i < nr_actions; i++) {
435 const struct tc_action *a = actions[i]; 433 const struct tc_action *a = actions[i];
436 434
@@ -439,9 +437,8 @@ repeat:
439 if (ret == TC_ACT_REPEAT) 437 if (ret == TC_ACT_REPEAT)
440 goto repeat; /* we need a ttl - JHS */ 438 goto repeat; /* we need a ttl - JHS */
441 if (ret != TC_ACT_PIPE) 439 if (ret != TC_ACT_PIPE)
442 goto exec_done; 440 break;
443 } 441 }
444exec_done:
445 return ret; 442 return ret;
446} 443}
447EXPORT_SYMBOL(tcf_action_exec); 444EXPORT_SYMBOL(tcf_action_exec);