tc-policy: Implement new BPF section that disallow using TXQ zero

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
This commit is contained in:
Jesper Dangaard Brouer
2022-02-01 13:11:31 +01:00
parent 741205e13c
commit a3af1bb99c
2 changed files with 22 additions and 1 deletions

View File

@@ -212,7 +212,8 @@ int tc_attach_egress(struct user_config *cfg, struct tc_txq_policy_kern *obj)
DECLARE_LIBBPF_OPTS(bpf_tc_opts, attach_egress);
/* Selecting BPF-prog here: */
fd = bpf_program__fd(obj->progs.queue_map_4);
//fd = bpf_program__fd(obj->progs.queue_map_4);
fd = bpf_program__fd(obj->progs.not_txq_zero);
if (fd < 0) {
fprintf(stderr, "Couldn't find egress program\n");
err = -ENOENT;

View File

@@ -52,3 +52,23 @@ int queue_map_4 (struct __sk_buff *skb)
return TC_ACT_OK;
}
/*
* Section name "tc" is preferred over "classifier" as its being deprecated
* https://github.com/libbpf/libbpf/wiki/Libbpf-1.0-migration-guide#bpf-program-sec-annotation-deprecations
*/
SEC("tc")
int not_txq_zero (struct __sk_buff *skb)
{
/* Existing skb->queue_mapping can come from skb_record_rx_queue() which
* is usually called by drivers in early RX handling when creating SKB.
*/
/* At this stage queue_mapping is 1-indexed.
* Thus, code is changing TXQ zero to be remapped to TXQ 3. */
if (skb->queue_mapping == 1)
skb->queue_mapping = 4;
return TC_ACT_OK;
}