@@ -529,16 +529,26 @@ int bpf_xdp_query_id(int ifindex, int flags, __u32 *prog_id)
529
529
}
530
530
531
531
532
- typedef int (* qdisc_config_t )(struct libbpf_nla_req * req );
532
+ typedef int (* qdisc_config_t )(struct libbpf_nla_req * req , const struct bpf_tc_hook * hook );
533
533
534
- static int clsact_config (struct libbpf_nla_req * req )
534
+ static int clsact_config (struct libbpf_nla_req * req , const struct bpf_tc_hook * hook )
535
535
{
536
536
req -> tc .tcm_parent = TC_H_CLSACT ;
537
537
req -> tc .tcm_handle = TC_H_MAKE (TC_H_CLSACT , 0 );
538
538
539
539
return nlattr_add (req , TCA_KIND , "clsact" , sizeof ("clsact" ));
540
540
}
541
541
542
+ static int qdisc_config (struct libbpf_nla_req * req , const struct bpf_tc_hook * hook )
543
+ {
544
+ const char * qdisc = OPTS_GET (hook , qdisc , NULL );
545
+
546
+ req -> tc .tcm_parent = OPTS_GET (hook , parent , TC_H_ROOT );
547
+ req -> tc .tcm_handle = OPTS_GET (hook , handle , 0 );
548
+
549
+ return nlattr_add (req , TCA_KIND , qdisc , strlen (qdisc ) + 1 );
550
+ }
551
+
542
552
static int attach_point_to_config (struct bpf_tc_hook * hook ,
543
553
qdisc_config_t * config )
544
554
{
@@ -552,6 +562,9 @@ static int attach_point_to_config(struct bpf_tc_hook *hook,
552
562
return 0 ;
553
563
case BPF_TC_CUSTOM :
554
564
return - EOPNOTSUPP ;
565
+ case BPF_TC_QDISC :
566
+ * config = & qdisc_config ;
567
+ return 0 ;
555
568
default :
556
569
return - EINVAL ;
557
570
}
@@ -596,7 +609,7 @@ static int tc_qdisc_modify(struct bpf_tc_hook *hook, int cmd, int flags)
596
609
req .tc .tcm_family = AF_UNSPEC ;
597
610
req .tc .tcm_ifindex = OPTS_GET (hook , ifindex , 0 );
598
611
599
- ret = config (& req );
612
+ ret = config (& req , hook );
600
613
if (ret < 0 )
601
614
return ret ;
602
615
@@ -639,6 +652,7 @@ int bpf_tc_hook_destroy(struct bpf_tc_hook *hook)
639
652
case BPF_TC_INGRESS :
640
653
case BPF_TC_EGRESS :
641
654
return libbpf_err (__bpf_tc_detach (hook , NULL , true));
655
+ case BPF_TC_QDISC :
642
656
case BPF_TC_INGRESS | BPF_TC_EGRESS :
643
657
return libbpf_err (tc_qdisc_delete (hook ));
644
658
case BPF_TC_CUSTOM :
0 commit comments