mirror of
https://github.com/xdp-project/bpf-examples.git
synced 2024-05-06 15:54:53 +00:00
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:
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user