Skip to content

Commit ec624fe

Browse files
Paul Blakeykuba-moo
authored andcommitted
net/sched: Extend qdisc control block with tc control block
BPF layer extends the qdisc control block via struct bpf_skb_data_end and because of that there is no more room to add variables to the qdisc layer control block without going over the skb->cb size. Extend the qdisc control block with a tc control block, and move all tc related variables to there as a pre-step for extending the tc control block with additional members. Signed-off-by: Paul Blakey <paulb@nvidia.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 8ca4090 commit ec624fe

7 files changed

Lines changed: 34 additions & 17 deletions

File tree

include/net/pkt_sched.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,19 @@ static inline void skb_txtime_consumed(struct sk_buff *skb)
193193
skb->tstamp = ktime_set(0, 0);
194194
}
195195

196+
struct tc_skb_cb {
197+
struct qdisc_skb_cb qdisc_cb;
198+
199+
u16 mru;
200+
bool post_ct;
201+
};
202+
203+
static inline struct tc_skb_cb *tc_skb_cb(const struct sk_buff *skb)
204+
{
205+
struct tc_skb_cb *cb = (struct tc_skb_cb *)skb->cb;
206+
207+
BUILD_BUG_ON(sizeof(*cb) > sizeof_field(struct sk_buff, cb));
208+
return cb;
209+
}
210+
196211
#endif

include/net/sch_generic.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,6 @@ struct qdisc_skb_cb {
447447
};
448448
#define QDISC_CB_PRIV_LEN 20
449449
unsigned char data[QDISC_CB_PRIV_LEN];
450-
u16 mru;
451-
bool post_ct;
452450
};
453451

454452
typedef void tcf_chain_head_change_t(struct tcf_proto *tp_head, void *priv);

net/core/dev.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3941,8 +3941,8 @@ sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev)
39413941
return skb;
39423942

39433943
/* qdisc_skb_cb(skb)->pkt_len was already set by the caller. */
3944-
qdisc_skb_cb(skb)->mru = 0;
3945-
qdisc_skb_cb(skb)->post_ct = false;
3944+
tc_skb_cb(skb)->mru = 0;
3945+
tc_skb_cb(skb)->post_ct = false;
39463946
mini_qdisc_bstats_cpu_update(miniq, skb);
39473947

39483948
switch (tcf_classify(skb, miniq->block, miniq->filter_list, &cl_res, false)) {
@@ -5103,8 +5103,8 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret,
51035103
}
51045104

51055105
qdisc_skb_cb(skb)->pkt_len = skb->len;
5106-
qdisc_skb_cb(skb)->mru = 0;
5107-
qdisc_skb_cb(skb)->post_ct = false;
5106+
tc_skb_cb(skb)->mru = 0;
5107+
tc_skb_cb(skb)->post_ct = false;
51085108
skb->tc_at_ingress = 1;
51095109
mini_qdisc_bstats_cpu_update(miniq, skb);
51105110

net/sched/act_ct.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -690,10 +690,10 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
690690
u8 family, u16 zone, bool *defrag)
691691
{
692692
enum ip_conntrack_info ctinfo;
693-
struct qdisc_skb_cb cb;
694693
struct nf_conn *ct;
695694
int err = 0;
696695
bool frag;
696+
u16 mru;
697697

698698
/* Previously seen (loopback)? Ignore. */
699699
ct = nf_ct_get(skb, &ctinfo);
@@ -708,7 +708,7 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
708708
return err;
709709

710710
skb_get(skb);
711-
cb = *qdisc_skb_cb(skb);
711+
mru = tc_skb_cb(skb)->mru;
712712

713713
if (family == NFPROTO_IPV4) {
714714
enum ip_defrag_users user = IP_DEFRAG_CONNTRACK_IN + zone;
@@ -722,7 +722,7 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
722722

723723
if (!err) {
724724
*defrag = true;
725-
cb.mru = IPCB(skb)->frag_max_size;
725+
mru = IPCB(skb)->frag_max_size;
726726
}
727727
} else { /* NFPROTO_IPV6 */
728728
#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
@@ -735,7 +735,7 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
735735

736736
if (!err) {
737737
*defrag = true;
738-
cb.mru = IP6CB(skb)->frag_max_size;
738+
mru = IP6CB(skb)->frag_max_size;
739739
}
740740
#else
741741
err = -EOPNOTSUPP;
@@ -744,7 +744,7 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
744744
}
745745

746746
if (err != -EINPROGRESS)
747-
*qdisc_skb_cb(skb) = cb;
747+
tc_skb_cb(skb)->mru = mru;
748748
skb_clear_hash(skb);
749749
skb->ignore_df = 1;
750750
return err;
@@ -963,7 +963,7 @@ static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a,
963963
tcf_action_update_bstats(&c->common, skb);
964964

965965
if (clear) {
966-
qdisc_skb_cb(skb)->post_ct = false;
966+
tc_skb_cb(skb)->post_ct = false;
967967
ct = nf_ct_get(skb, &ctinfo);
968968
if (ct) {
969969
nf_conntrack_put(&ct->ct_general);
@@ -1048,7 +1048,7 @@ static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a,
10481048
out_push:
10491049
skb_push_rcsum(skb, nh_ofs);
10501050

1051-
qdisc_skb_cb(skb)->post_ct = true;
1051+
tc_skb_cb(skb)->post_ct = true;
10521052
out_clear:
10531053
if (defrag)
10541054
qdisc_skb_cb(skb)->pkt_len = skb->len;

net/sched/cls_api.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,12 +1617,14 @@ int tcf_classify(struct sk_buff *skb,
16171617

16181618
/* If we missed on some chain */
16191619
if (ret == TC_ACT_UNSPEC && last_executed_chain) {
1620+
struct tc_skb_cb *cb = tc_skb_cb(skb);
1621+
16201622
ext = tc_skb_ext_alloc(skb);
16211623
if (WARN_ON_ONCE(!ext))
16221624
return TC_ACT_SHOT;
16231625
ext->chain = last_executed_chain;
1624-
ext->mru = qdisc_skb_cb(skb)->mru;
1625-
ext->post_ct = qdisc_skb_cb(skb)->post_ct;
1626+
ext->mru = cb->mru;
1627+
ext->post_ct = cb->post_ct;
16261628
}
16271629

16281630
return ret;

net/sched/cls_flower.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <net/sch_generic.h>
2121
#include <net/pkt_cls.h>
22+
#include <net/pkt_sched.h>
2223
#include <net/ip.h>
2324
#include <net/flow_dissector.h>
2425
#include <net/geneve.h>
@@ -309,7 +310,7 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp,
309310
struct tcf_result *res)
310311
{
311312
struct cls_fl_head *head = rcu_dereference_bh(tp->root);
312-
bool post_ct = qdisc_skb_cb(skb)->post_ct;
313+
bool post_ct = tc_skb_cb(skb)->post_ct;
313314
struct fl_flow_key skb_key;
314315
struct fl_flow_mask *mask;
315316
struct cls_fl_filter *f;

net/sched/sch_frag.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
22
#include <net/netlink.h>
33
#include <net/sch_generic.h>
4+
#include <net/pkt_sched.h>
45
#include <net/dst.h>
56
#include <net/ip.h>
67
#include <net/ip6_fib.h>
@@ -137,7 +138,7 @@ static int sch_fragment(struct net *net, struct sk_buff *skb,
137138

138139
int sch_frag_xmit_hook(struct sk_buff *skb, int (*xmit)(struct sk_buff *skb))
139140
{
140-
u16 mru = qdisc_skb_cb(skb)->mru;
141+
u16 mru = tc_skb_cb(skb)->mru;
141142
int err;
142143

143144
if (mru && skb->len > mru + skb->dev->hard_header_len)

0 commit comments

Comments
 (0)