From: Tonghao Zhang <redacted>
This patch fix issue:
* If we install tc filters with act_skbedit in clsact hook.
It doesn't work, because netdev_core_pick_tx() overwrites
queue_mapping.
$ tc filter ... action skbedit queue_mapping 1
And this patch is useful:
* We can use FQ + EDT to implement efficient policies. Tx queues
are picked by xps, ndo_select_queue of netdev driver, or skb hash
in netdev_core_pick_tx(). In fact, the netdev driver, and skb
hash are _not_ under control. xps uses the CPUs map to select Tx
queues, but we can't figure out which task_struct of pod/containter
running on this cpu in most case. We can use clsact filters to classify
one pod/container traffic to one Tx queue. Why ?
In containter networking environment, there are two kinds of pod/
containter/net-namespace. One kind (e.g. P1, P2), the high throughput
is key in these applications. But avoid running out of network resource,
the outbound traffic of these pods is limited, using or sharing one
dedicated Tx queues assigned HTB/TBF/FQ Qdisc. Other kind of pods
(e.g. Pn), the low latency of data access is key. And the traffic is not
limited. Pods use or share other dedicated Tx queues assigned FIFO Qdisc.
This choice provides two benefits. First, contention on the HTB/FQ Qdisc
lock is significantly reduced since fewer CPUs contend for the same queue.
More importantly, Qdisc contention can be eliminated completely if each
CPU has its own FIFO Qdisc for the second kind of pods.
There must be a mechanism in place to support classifying traffic based on
pods/container to different Tx queues. Note that clsact is outside of Qdisc
while Qdisc can run a classifier to select a sub-queue under the lock.
In general recording the decision in the skb seems a little heavy handed.
This patch introduces a per-CPU variable, suggested by Eric.
The skip txqueue flag will be cleared to avoid picking Tx queue in
next netdev, for example (not usual case):
eth0 (macvlan in Pod, skbedit queue_mapping) -> eth0.3 (vlan in Host)
-> eth0 (ixgbe in Host).
+----+ +----+ +----+
| P1 | | P2 | | Pn |
+----+ +----+ +----+
| | |
+-----------+-----------+
|
| clsact/skbedit
| MQ
v
+-----------+-----------+
| q0 | q1 | qn
v v v
HTB/FQ HTB/FQ ... FIFO
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Cong Wang <redacted>
Cc: Jiri Pirko <jiri@resnulli.us>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Jonathan Lemon <redacted>
Cc: Eric Dumazet <redacted>
Cc: Alexander Lobakin <redacted>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Talal Ahmad <redacted>
Cc: Kevin Hao <redacted>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Kees Cook <redacted>
Cc: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: Antoine Tenart <atenart@kernel.org>
Cc: Wei Wang <redacted>
Cc: Arnd Bergmann <arnd@arndb.de>
Suggested-by: Eric Dumazet <redacted>
Signed-off-by: Tonghao Zhang <redacted>
---
include/linux/netdevice.h | 21 +++++++++++++++++++++
net/core/dev.c | 6 +++++-
net/sched/act_skbedit.c | 4 +++-
3 files changed, 29 insertions(+), 2 deletions(-)
@@ -2997,6 +2997,7 @@ struct softnet_data {/* written and read only by owning cpu: */struct{u16recursion;+u8skip_txqueue;u8more;}xmit;#ifdef CONFIG_RPS
@@ -4633,6 +4634,26 @@ static inline netdev_tx_t netdev_start_xmit(struct sk_buff *skb, struct net_devireturnrc;}+staticinlinevoidnetdev_xmit_skip_txqueue(void)+{+__this_cpu_write(softnet_data.xmit.skip_txqueue,1);+}++staticinlineboolnetdev_xmit_txqueue_skipped(void)+{+return__this_cpu_read(softnet_data.xmit.skip_txqueue);+}++staticinlinestructnetdev_queue*+netdev_tx_queue_mapping(structnet_device*dev,structsk_buff*skb)+{+intqm=skb_get_queue_mapping(skb);++/* Take effect only on current netdev. */+__this_cpu_write(softnet_data.xmit.skip_txqueue,0);+returnnetdev_get_tx_queue(dev,netdev_cap_txqueue(dev,qm));+}+intnetdev_class_create_file_ns(conststructclass_attribute*class_attr,constvoid*ns);voidnetdev_class_remove_file_ns(conststructclass_attribute*class_attr,
From: Tonghao Zhang <redacted>
This patch allows users to select queue_mapping, range
from A to B. And users can use skb-hash, cgroup classid
and cpuid to select Tx queues. Then we can load balance
packets from A to B queue. The range is an unsigned 16bit
value in decimal format.
$ tc filter ... action skbedit queue_mapping hash-type normal A B
"skbedit queue_mapping QUEUE_MAPPING" (from "man 8 tc-skbedit") is
enhanced with flags:
* SKBEDIT_F_QUEUE_MAPPING_HASH
* SKBEDIT_F_QUEUE_MAPPING_CLASSID
* SKBEDIT_F_QUEUE_MAPPING_CPUID
Use skb->hash, cgroup classid, or cpuid to distribute packets.
Then same range of tx queues can be shared for different flows,
cgroups, or CPUs in a variety of scenarios.
For example, flows F1 may share range R1 with flows F2. The best
way to do that is to set flag to SKBEDIT_F_QUEUE_MAPPING_HASH.
If cgroup C1 share the R1 with cgroup C2 .. Cn, use the
SKBEDIT_F_QUEUE_MAPPING_CLASSID. Of course, in some other scenario,
C1 uses R1, while Cn can use Rn.
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Cong Wang <redacted>
Cc: Jiri Pirko <jiri@resnulli.us>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Jonathan Lemon <redacted>
Cc: Eric Dumazet <redacted>
Cc: Alexander Lobakin <redacted>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Talal Ahmad <redacted>
Cc: Kevin Hao <redacted>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Kees Cook <redacted>
Cc: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: Antoine Tenart <atenart@kernel.org>
Cc: Wei Wang <redacted>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Tonghao Zhang <redacted>
---
include/net/tc_act/tc_skbedit.h | 1 +
include/uapi/linux/tc_act/tc_skbedit.h | 8 +++
net/sched/act_skbedit.c | 74 ++++++++++++++++++++++++--
3 files changed, 79 insertions(+), 4 deletions(-)
@@ -23,6 +24,37 @@staticunsignedintskbedit_net_id;staticstructtc_action_opsact_skbedit_ops;+staticu16tcf_skbedit_hash(structtcf_skbedit_params*params,+structsk_buff*skb)+{+u16queue_mapping=params->queue_mapping;+u16mapping_mod=params->mapping_mod;+u32mapping_hash_type=params->flags&+SKBEDIT_F_QUEUE_MAPPING_HASH_MASK;+u32hash=0;++if(!mapping_hash_type)+returnnetdev_cap_txqueue(skb->dev,queue_mapping);++switch(mapping_hash_type){+caseSKBEDIT_F_QUEUE_MAPPING_CLASSID:+hash=jhash_1word(task_get_classid(skb),0);+break;+caseSKBEDIT_F_QUEUE_MAPPING_HASH:+hash=skb_get_hash(skb);+break;+caseSKBEDIT_F_QUEUE_MAPPING_CPUID:+hash=raw_smp_processor_id();+break;+default:+net_warn_ratelimited("The type of queue_mapping hash is not supported. 0x%x\n",+mapping_hash_type);+}++queue_mapping=queue_mapping+hash%mapping_mod;+returnnetdev_cap_txqueue(skb->dev,queue_mapping);+}+staticinttcf_skbedit_act(structsk_buff*skb,conststructtc_action*a,structtcf_result*res){
From: Cong Wang <hidden> Date: 2021-12-12 02:19:16
On Thu, Dec 9, 2021 at 6:36 PM [off-list ref] wrote:
From: Tonghao Zhang <redacted>
This patch allows users to select queue_mapping, range
from A to B. And users can use skb-hash, cgroup classid
and cpuid to select Tx queues. Then we can load balance
packets from A to B queue. The range is an unsigned 16bit
value in decimal format.
$ tc filter ... action skbedit queue_mapping hash-type normal A B
"skbedit queue_mapping QUEUE_MAPPING" (from "man 8 tc-skbedit") is
enhanced with flags:
* SKBEDIT_F_QUEUE_MAPPING_HASH
* SKBEDIT_F_QUEUE_MAPPING_CLASSID
* SKBEDIT_F_QUEUE_MAPPING_CPUID
With act_bpf you can do all of them... So why do you have to do it
in skbedit?
On Sun, Dec 12, 2021 at 10:19 AM Cong Wang [off-list ref] wrote:
On Thu, Dec 9, 2021 at 6:36 PM [off-list ref] wrote:
quoted
From: Tonghao Zhang <redacted>
This patch allows users to select queue_mapping, range
from A to B. And users can use skb-hash, cgroup classid
and cpuid to select Tx queues. Then we can load balance
packets from A to B queue. The range is an unsigned 16bit
value in decimal format.
$ tc filter ... action skbedit queue_mapping hash-type normal A B
"skbedit queue_mapping QUEUE_MAPPING" (from "man 8 tc-skbedit") is
enhanced with flags:
* SKBEDIT_F_QUEUE_MAPPING_HASH
* SKBEDIT_F_QUEUE_MAPPING_CLASSID
* SKBEDIT_F_QUEUE_MAPPING_CPUID
With act_bpf you can do all of them... So why do you have to do it
in skbedit?
Hi Cong
This idea is inspired by skbedit queue_mapping, and skbedit is
enhanced by this patch.
We support this in skbedit firstly in production. act_bpf can do more
things than this. Anyway we
can support this in both act_skbedit/acc_bpf. 1/2 is changed from
skip_tx_queue in skb to per-cpu var suggested-by Eric. We need another
patch which can change the
per-cpu var in bpf. I will post this patch later.
--
Best regards, Tonghao
From: Cong Wang <hidden> Date: 2021-12-13 22:53:38
On Sat, Dec 11, 2021 at 6:34 PM Tonghao Zhang [off-list ref] wrote:
On Sun, Dec 12, 2021 at 10:19 AM Cong Wang [off-list ref] wrote:
quoted
On Thu, Dec 9, 2021 at 6:36 PM [off-list ref] wrote:
quoted
From: Tonghao Zhang <redacted>
This patch allows users to select queue_mapping, range
from A to B. And users can use skb-hash, cgroup classid
and cpuid to select Tx queues. Then we can load balance
packets from A to B queue. The range is an unsigned 16bit
value in decimal format.
$ tc filter ... action skbedit queue_mapping hash-type normal A B
"skbedit queue_mapping QUEUE_MAPPING" (from "man 8 tc-skbedit") is
enhanced with flags:
* SKBEDIT_F_QUEUE_MAPPING_HASH
* SKBEDIT_F_QUEUE_MAPPING_CLASSID
* SKBEDIT_F_QUEUE_MAPPING_CPUID
With act_bpf you can do all of them... So why do you have to do it
in skbedit?
Hi Cong
This idea is inspired by skbedit queue_mapping, and skbedit is
enhanced by this patch.
This is exactly my question. ;)
We support this in skbedit firstly in production. act_bpf can do more
things than this. Anyway we
can support this in both act_skbedit/acc_bpf. 1/2 is changed from
skip_tx_queue in skb to per-cpu var suggested-by Eric. We need another
patch which can change the
per-cpu var in bpf. I will post this patch later.
The point is if act_bpf can do it, you don't need to bother skbedit at
all. More importantly, you are enforcing policies in kernel, which is
not encouraged. So unless you provide more details, this patch is not
needed at all.
Thanks.
From: Cong Wang <hidden> Date: 2021-12-13 22:58:35
On Thu, Dec 9, 2021 at 6:36 PM [off-list ref] wrote:
From: Tonghao Zhang <redacted>
This patch fix issue:
* If we install tc filters with act_skbedit in clsact hook.
It doesn't work, because netdev_core_pick_tx() overwrites
queue_mapping.
$ tc filter ... action skbedit queue_mapping 1
Interesting, but bpf offers a helper (bpf_set_hash()) to overwrite
skb->hash which could _indirectly_ be used to change queue_mapping.
Does it not work?
BTW, for this skbedit action, I guess it is probably because skbedit was
introduced much earlier than clsact.
Thanks.
On Tue, Dec 14, 2021 at 6:58 AM Cong Wang [off-list ref] wrote:
On Thu, Dec 9, 2021 at 6:36 PM [off-list ref] wrote:
quoted
From: Tonghao Zhang <redacted>
This patch fix issue:
* If we install tc filters with act_skbedit in clsact hook.
It doesn't work, because netdev_core_pick_tx() overwrites
queue_mapping.
$ tc filter ... action skbedit queue_mapping 1
Interesting, but bpf offers a helper (bpf_set_hash()) to overwrite
skb->hash which could _indirectly_ be used to change queue_mapping.
Does it not work?
No
The root cause is that queue_mapping is overwritten by netdev_core_pick_tx.
Tx queues are picked by xps, ndo_select_queue of netdev driver, or skb hash
in netdev_core_pick_tx(). We can't only change the skb-hash. BTW, this patch
fix the issue, more importantly, this is useful (more details, see my
commit message):
* We can use FQ + EDT to implement efficient policies. Tx queues
are picked by xps, ndo_select_queue of netdev driver, or skb hash
in netdev_core_pick_tx(). In fact, the netdev driver, and skb
hash are _not_ under control. xps uses the CPUs map to select Tx
queues, but we can't figure out which task_struct of pod/containter
running on this cpu in most case. We can use clsact filters to classify
one pod/container traffic to one Tx queue. Why ?
In containter networking environment, there are two kinds of pod/
containter/net-namespace. One kind (e.g. P1, P2), the high throughput
is key in these applications. But avoid running out of network resource,
the outbound traffic of these pods is limited, using or sharing one
dedicated Tx queues assigned HTB/TBF/FQ Qdisc. Other kind of pods
(e.g. Pn), the low latency of data access is key. And the traffic is not
limited. Pods use or share other dedicated Tx queues assigned FIFO Qdisc.
This choice provides two benefits. First, contention on the HTB/FQ Qdisc
lock is significantly reduced since fewer CPUs contend for the same queue.
More importantly, Qdisc contention can be eliminated completely if each
CPU has its own FIFO Qdisc for the second kind of pods.
There must be a mechanism in place to support classifying traffic based on
pods/container to different Tx queues. Note that clsact is outside of Qdisc
while Qdisc can run a classifier to select a sub-queue under the lock.
In general recording the decision in the skb seems a little heavy handed.
This patch introduces a per-CPU variable, suggested by Eric.
BTW, for this skbedit action, I guess it is probably because skbedit was
introduced much earlier than clsact.
On Tue, Dec 14, 2021 at 6:53 AM Cong Wang [off-list ref] wrote:
On Sat, Dec 11, 2021 at 6:34 PM Tonghao Zhang [off-list ref] wrote:
quoted
On Sun, Dec 12, 2021 at 10:19 AM Cong Wang [off-list ref] wrote:
quoted
On Thu, Dec 9, 2021 at 6:36 PM [off-list ref] wrote:
quoted
From: Tonghao Zhang <redacted>
This patch allows users to select queue_mapping, range
from A to B. And users can use skb-hash, cgroup classid
and cpuid to select Tx queues. Then we can load balance
packets from A to B queue. The range is an unsigned 16bit
value in decimal format.
$ tc filter ... action skbedit queue_mapping hash-type normal A B
"skbedit queue_mapping QUEUE_MAPPING" (from "man 8 tc-skbedit") is
enhanced with flags:
* SKBEDIT_F_QUEUE_MAPPING_HASH
* SKBEDIT_F_QUEUE_MAPPING_CLASSID
* SKBEDIT_F_QUEUE_MAPPING_CPUID
With act_bpf you can do all of them... So why do you have to do it
in skbedit?
Hi Cong
This idea is inspired by skbedit queue_mapping, and skbedit is
enhanced by this patch.
This is exactly my question. ;)
quoted
We support this in skbedit firstly in production. act_bpf can do more
things than this. Anyway we
can support this in both act_skbedit/acc_bpf. 1/2 is changed from
skip_tx_queue in skb to per-cpu var suggested-by Eric. We need another
patch which can change the
per-cpu var in bpf. I will post this patch later.
The point is if act_bpf can do it, you don't need to bother skbedit at
all. More importantly, you are enforcing policies in kernel, which is
not encouraged. So unless you provide more details, this patch is not
needed at all.
Hi Cong,
1. As I understand it, act_bpf can work with 1/2 patch(but we should
another path to change the skip_txqueue in bpf).
It is easy for kernel developer. But for another user, it is not easy.
tc command is a choice, and easy to use.
2. BTW, act_bpf can't try to instead act_xxx action in future even
though it can do more thing. right ?
3. This patch is more important to work with 1/2, and only enhance the
skbedit queue_mapping function. not a big change.
4. "policies" ? if selecting tx from a range(this patch) is what you
mean "policies", so change the skb mark, priority, tc-peidt
and other tc-action are "policies" too. we still need the different tc actions.
From: Jamal Hadi Salim <jhs@mojatatu.com> Date: 2021-12-14 12:13:06
On 2021-12-13 17:53, Cong Wang wrote:
On Sat, Dec 11, 2021 at 6:34 PM Tonghao Zhang [off-list ref] wrote:
quoted
We support this in skbedit firstly in production. act_bpf can do more
things than this. Anyway we
can support this in both act_skbedit/acc_bpf. 1/2 is changed from
skip_tx_queue in skb to per-cpu var suggested-by Eric. We need another
patch which can change the
per-cpu var in bpf. I will post this patch later.
The point is if act_bpf can do it, you don't need to bother skbedit at
all.
Just a comment on this general statement:
I know of at least one large data centre that wont allow anything
"compiled" to be installed unless it goes through a very long vetting
process(we are talking months).
"Compiled" includes bpf. This is common practise in a few other places
some extreme more than others - the reasons are typically driven by
either some overzelous program manager or security people. Regardless
of the reasoning, this is a real issue.
Note: None of these data centres have a long process if what is
installed is a bash script expressing policy.
In such a case an upstream of a feature such as this is more useful.
cheers,
jamal
On Fri, Dec 10, 2021 at 10:36 AM [off-list ref] wrote:
From: Tonghao Zhang <redacted>
This patch allows users to select queue_mapping, range
from A to B. And users can use skb-hash, cgroup classid
and cpuid to select Tx queues. Then we can load balance
packets from A to B queue. The range is an unsigned 16bit
value in decimal format.
$ tc filter ... action skbedit queue_mapping hash-type normal A B
"skbedit queue_mapping QUEUE_MAPPING" (from "man 8 tc-skbedit") is
enhanced with flags:
* SKBEDIT_F_QUEUE_MAPPING_HASH
* SKBEDIT_F_QUEUE_MAPPING_CLASSID
* SKBEDIT_F_QUEUE_MAPPING_CPUID
Use skb->hash, cgroup classid, or cpuid to distribute packets.
Then same range of tx queues can be shared for different flows,
cgroups, or CPUs in a variety of scenarios.
For example, flows F1 may share range R1 with flows F2. The best
way to do that is to set flag to SKBEDIT_F_QUEUE_MAPPING_HASH.
If cgroup C1 share the R1 with cgroup C2 .. Cn, use the
SKBEDIT_F_QUEUE_MAPPING_CLASSID. Of course, in some other scenario,
C1 uses R1, while Cn can use Rn.
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Cong Wang <redacted>
Cc: Jiri Pirko <jiri@resnulli.us>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Jonathan Lemon <redacted>
Cc: Eric Dumazet <redacted>
Cc: Alexander Lobakin <redacted>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Talal Ahmad <redacted>
Cc: Kevin Hao <redacted>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Kees Cook <redacted>
Cc: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: Antoine Tenart <atenart@kernel.org>
Cc: Wei Wang <redacted>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Tonghao Zhang <redacted>
Hi Jakub, Eric
Do you have any comment?We talk about this patchset in this thread.
Should I resend this patchset with more commit message ?
@@ -23,6 +24,37 @@staticunsignedintskbedit_net_id;staticstructtc_action_opsact_skbedit_ops;+staticu16tcf_skbedit_hash(structtcf_skbedit_params*params,+structsk_buff*skb)+{+u16queue_mapping=params->queue_mapping;+u16mapping_mod=params->mapping_mod;+u32mapping_hash_type=params->flags&+SKBEDIT_F_QUEUE_MAPPING_HASH_MASK;+u32hash=0;++if(!mapping_hash_type)+returnnetdev_cap_txqueue(skb->dev,queue_mapping);++switch(mapping_hash_type){+caseSKBEDIT_F_QUEUE_MAPPING_CLASSID:+hash=jhash_1word(task_get_classid(skb),0);+break;+caseSKBEDIT_F_QUEUE_MAPPING_HASH:+hash=skb_get_hash(skb);+break;+caseSKBEDIT_F_QUEUE_MAPPING_CPUID:+hash=raw_smp_processor_id();+break;+default:+net_warn_ratelimited("The type of queue_mapping hash is not supported. 0x%x\n",+mapping_hash_type);+}++queue_mapping=queue_mapping+hash%mapping_mod;+returnnetdev_cap_txqueue(skb->dev,queue_mapping);+}+staticinttcf_skbedit_act(structsk_buff*skb,conststructtc_action*a,structtcf_result*res){
On Tue, Dec 14, 2021 at 8:13 PM Jamal Hadi Salim [off-list ref] wrote:
On 2021-12-13 17:53, Cong Wang wrote:
quoted
On Sat, Dec 11, 2021 at 6:34 PM Tonghao Zhang [off-list ref] wrote:
quoted
quoted
We support this in skbedit firstly in production. act_bpf can do more
things than this. Anyway we
can support this in both act_skbedit/acc_bpf. 1/2 is changed from
skip_tx_queue in skb to per-cpu var suggested-by Eric. We need another
patch which can change the
per-cpu var in bpf. I will post this patch later.
The point is if act_bpf can do it, you don't need to bother skbedit at
all.
Just a comment on this general statement:
I know of at least one large data centre that wont allow anything
"compiled" to be installed unless it goes through a very long vetting
process(we are talking months).
"Compiled" includes bpf. This is common practise in a few other places
some extreme more than others - the reasons are typically driven by
either some overzelous program manager or security people. Regardless
of the reasoning, this is a real issue.
Yes, I agree with you that
Note: None of these data centres have a long process if what is
installed is a bash script expressing policy.
In such a case an upstream of a feature such as this is more useful.
cheers,
jamal
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-12-15 16:08:46
On Fri, 10 Dec 2021 10:36:26 +0800 xiangxia.m.yue@gmail.com wrote:
From: Tonghao Zhang <redacted>
This patch allows users to select queue_mapping, range
from A to B. And users can use skb-hash, cgroup classid
and cpuid to select Tx queues. Then we can load balance
packets from A to B queue. The range is an unsigned 16bit
value in decimal format.
$ tc filter ... action skbedit queue_mapping hash-type normal A B
"skbedit queue_mapping QUEUE_MAPPING" (from "man 8 tc-skbedit") is
enhanced with flags:
* SKBEDIT_F_QUEUE_MAPPING_HASH
* SKBEDIT_F_QUEUE_MAPPING_CLASSID
* SKBEDIT_F_QUEUE_MAPPING_CPUID
Use skb->hash, cgroup classid, or cpuid to distribute packets.
Then same range of tx queues can be shared for different flows,
cgroups, or CPUs in a variety of scenarios.
For example, flows F1 may share range R1 with flows F2. The best
way to do that is to set flag to SKBEDIT_F_QUEUE_MAPPING_HASH.
If cgroup C1 share the R1 with cgroup C2 .. Cn, use the
SKBEDIT_F_QUEUE_MAPPING_CLASSID. Of course, in some other scenario,
C1 uses R1, while Cn can use Rn.
On Thu, Dec 16, 2021 at 12:09 AM Jakub Kicinski [off-list ref] wrote:
On Fri, 10 Dec 2021 10:36:26 +0800 xiangxia.m.yue@gmail.com wrote:
quoted
From: Tonghao Zhang <redacted>
This patch allows users to select queue_mapping, range
from A to B. And users can use skb-hash, cgroup classid
and cpuid to select Tx queues. Then we can load balance
packets from A to B queue. The range is an unsigned 16bit
value in decimal format.
$ tc filter ... action skbedit queue_mapping hash-type normal A B
"skbedit queue_mapping QUEUE_MAPPING" (from "man 8 tc-skbedit") is
enhanced with flags:
* SKBEDIT_F_QUEUE_MAPPING_HASH
* SKBEDIT_F_QUEUE_MAPPING_CLASSID
* SKBEDIT_F_QUEUE_MAPPING_CPUID
Use skb->hash, cgroup classid, or cpuid to distribute packets.
Then same range of tx queues can be shared for different flows,
cgroups, or CPUs in a variety of scenarios.
For example, flows F1 may share range R1 with flows F2. The best
way to do that is to set flag to SKBEDIT_F_QUEUE_MAPPING_HASH.
If cgroup C1 share the R1 with cgroup C2 .. Cn, use the
SKBEDIT_F_QUEUE_MAPPING_CLASSID. Of course, in some other scenario,
C1 uses R1, while Cn can use Rn.
.type = NLA_U16 ? I think it's okay to use the modern stuff here.
TCA_SKBEDIT_QUEUE_MAPPING_MAX and TCA_SKBEDIT_QUEUE_MAPPING are the
same type of value,
so I use the len of u16 as TCA_SKBEDIT_QUEUE_MAPPING. I think it is better.
quoted
};
static int tcf_skbedit_init(struct net *net, struct nlattr *nla,