Files
bpfire/lfs
Vincent Li 58b4babde2 xdp-tools: add IFB setup in tc-basic-classifier
commit f0812939ca4f6332d34715673c4fe44fbb1a491b (HEAD -> main, origin/main, origin/HEAD)
    Author: Vincent Li <vincent.mc.li@gmail.com>
    Date:   Mon Nov 3 21:46:30 2025 -0800

        tc-basic-classifier: add IFB setup in user space

        Add the required kernel modules setup and green0 ingress mirror to ifb0
        egress setup in class_filter so it is easier for user. see [0] for
        required kernel modules and ingress shaping. also change the default
        path to /usr/lib/bpf/class_filter.bpf.o  also change the default bpf
        object path to /usr/lib/bpf/class_filter.bpf.o.

        [0]: https://std.rocks/gnulinux_network_traffic_control.html

        for example:

        Complete setup with one command (IFB mirroring + BPF attachment)

        ./class_filter -i green0 -3 10mbit -I -a -v

        Setting up IFB mirroring for ingress traffic shaping on green0
        Loading required kernel modules...
        Executing: modprobe ifb numifbs=1
        Loaded module: ifb numifbs=1
        Executing: modprobe sch_fq_codel
        Loaded module: sch_fq_codel
        Executing: modprobe act_mirred
        Loaded module: act_mirred
        Executing: modprobe act_connmark
        Loaded module: act_connmark
        Successfully loaded all required kernel modules
        Executing: ip link set dev ifb0 up
        Executing: tc qdisc del dev green0 ingress 2>/dev/null
        Executing: tc qdisc add dev green0 ingress handle ffff:
        Executing: tc filter add dev green0 parent ffff: protocol ip u32 match u32 0 0 action connmark action mirred egress redirect dev ifb0 flowid ffff:1
        Successfully setup IFB mirroring:
          - Ingress traffic from green0 mirrored to ifb0 egress

        Verification - IFB status:
        Executing: ip link show ifb0
        7: ifb0: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc htb state UNKNOWN mode DEFAULT group default qlen 32
            link/ether 8e:52:c9:93:13:34 brd ff:ff:ff:ff:ff:ff

        TC configuration on green0 ingress:
        Executing: tc qdisc show dev green0
        qdisc fq_codel 8001: root refcnt 9 limit 10240p flows 1024 quantum 1514 target 5ms interval 100ms memory_limit 32Mb ecn drop_batch 64
        qdisc ingress ffff: parent ffff:fff1 ----------------
        Executing: tc filter show dev green0 parent ffff:
        filter protocol ip pref 49152 u32 chain 0
        filter protocol ip pref 49152 u32 chain 0 fh 800: ht divisor 1
        filter protocol ip pref 49152 u32 chain 0 fh 800::800 order 2048 key ht 800 bkt 0 flowid ffff:1 not_in_hw
          match 00000000/00000000 at 0
                action order 1: connmark zone 0 pipe
                 index 1 ref 1 bind 1

                action order 2: mirred (Egress Redirect to device ifb0) stolen
                index 1 ref 1 bind 1

        Setting up TC qdisc and classes on ifb0 for egress shaping...
        Executing: tc qdisc del dev ifb0 root 2>/dev/null
        Executing: tc qdisc add dev ifb0 root handle 1:0 htb default 30
        Executing: tc class add dev ifb0 parent 1:0 classid 1:1 htb rate 100mbit
        Warning: sch_htb: quantum of class 10001 is big. Consider r2q change.
        Executing: tc class add dev ifb0 parent 1:1 classid 1:30 htb rate 5mbit ceil 10mbit
        Successfully setup TC qdisc and classes on ifb0

        TC configuration on ifb0:
        Executing: tc qdisc show dev ifb0
        qdisc htb 1: root refcnt 2 r2q 10 default 0x30 direct_packets_stat 1 direct_qlen 32
        Executing: tc class show dev ifb0
        class htb 1:1 root rate 100Mbit ceil 100Mbit burst 1600b cburst 1600b
        class htb 1:30 parent 1:1 prio 0 rate 5Mbit ceil 10Mbit burst 1600b cburst 1600b

        Automatically attaching BPF program to ifb0 for classification...
        Attaching BPF program to ifb0...
        Executing: tc filter del dev ifb0 protocol ip parent 1:0 2>/dev/null
        Command failed but ignoring (may be normal): tc filter del dev ifb0 protocol ip parent 1:0 2>/dev/null
        Executing: tc filter add dev ifb0 protocol ip parent 1:0 bpf obj ./class_filter.bpf.o classid 1: direct-action
        Successfully attached BPF program to ifb0 egress (parent 1:0)
        BPF maps automatically pinned to /sys/fs/bpf/tc/globals/
        Verification:
        Executing: tc filter show dev ifb0 parent 1:0
        filter protocol ip pref 49152 bpf chain 0
        filter protocol ip pref 49152 bpf chain 0 handle 0x1 flowid 1: class_filter.bpf.o:[classifier] direct-action not_in_hw id 100 name cls_filter tag 7163f8c072cf7015 jited
        Pinned maps:
        Executing: ls -la /sys/fs/bpf/tc/globals/ 2>/dev/null || echo 'No pinned maps found'
        total 0
        drwx------ 2 root root 0 Nov  3 11:43 .
        drwx------ 3 root root 0 Nov  3 11:24 ..
        -rw------- 1 root root 0 Nov  3 11:43 cls_filter_ip_trie_map
        -rw------- 1 root root 0 Nov  3 11:43 cls_filter_port_map

        Complete setup finished:
          - IFB mirroring configured on green0 -> ifb0
          - TC qdisc and classes setup on ifb0
          - BPF classifier attached to ifb0 egress
          - Ready for port/IP based traffic classification!

        Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
2025-11-04 02:18:19 +00:00
..
2023-04-18 21:16:10 +00:00
2024-01-31 10:27:12 +00:00
2023-04-18 21:16:24 +00:00
2022-04-02 14:19:25 +00:00
2023-12-19 11:45:26 +01:00
2023-04-24 18:59:23 +00:00
2023-04-18 21:17:23 +00:00
2023-04-18 21:18:54 +00:00
2025-09-26 01:05:29 +00:00
2024-01-23 13:57:29 +00:00
2022-04-02 14:19:25 +00:00
2023-04-18 21:19:49 +00:00
2023-12-06 11:18:29 +00:00
2023-04-18 21:20:11 +00:00
2023-09-06 09:33:23 +00:00
2024-01-31 10:27:43 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2024-02-14 18:59:48 +00:00
2023-12-06 08:16:33 +01:00
2024-01-23 11:34:45 +00:00
2022-04-02 14:19:25 +00:00
2023-09-12 16:10:14 +00:00
2022-04-02 14:19:25 +00:00
2024-01-29 16:03:31 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2023-01-26 23:19:05 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2024-01-03 21:11:17 +00:00
2023-11-21 19:05:19 +00:00
2023-01-26 23:17:12 +00:00
2022-09-11 08:36:17 +00:00
2023-03-05 14:15:52 +00:00
2022-04-02 14:19:25 +00:00
2024-01-11 11:57:25 +00:00
2023-12-06 11:18:29 +00:00
2022-07-27 09:49:36 +00:00
2023-10-11 07:47:47 +00:00
2023-11-21 19:01:09 +00:00
2022-04-05 05:54:38 +00:00
2022-11-28 13:04:55 +01:00
2022-04-02 14:19:25 +00:00
2022-10-10 18:39:31 +00:00
2024-02-01 16:05:44 +00:00
2022-04-02 14:19:25 +00:00
2024-01-23 11:35:15 +00:00
2025-06-21 17:37:01 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2023-07-26 16:08:59 +00:00
2024-02-01 16:06:40 +00:00
2023-03-04 14:02:05 +00:00
2023-03-05 15:00:03 +00:00
2022-04-02 14:19:25 +00:00
2023-06-15 09:34:37 +00:00
2022-04-02 14:19:25 +00:00
2024-02-09 11:24:59 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2024-01-31 17:04:48 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2022-11-29 13:44:15 +01:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2024-01-23 11:36:51 +00:00
2023-06-15 09:37:19 +00:00
2023-07-26 16:09:00 +00:00
2023-09-12 16:12:53 +00:00
2022-04-24 14:07:44 +00:00
2023-07-26 16:09:00 +00:00
2023-11-21 19:09:32 +00:00
2023-12-06 08:21:05 +01:00
2022-04-02 14:19:25 +00:00
2023-06-24 06:34:18 +00:00
2022-04-02 14:19:25 +00:00
2024-02-01 16:07:15 +00:00
2023-12-30 06:49:41 +00:00
2023-07-31 09:23:21 +00:00
2023-08-08 16:02:35 +00:00
2022-04-02 14:19:25 +00:00
2024-01-23 13:58:10 +00:00
2025-06-11 22:31:03 +00:00
2022-04-02 14:19:25 +00:00
2022-07-09 09:08:11 +00:00
2023-06-15 09:30:34 +00:00
2023-07-31 09:23:03 +00:00
2022-07-09 09:08:22 +00:00
2023-09-12 16:13:34 +00:00
2024-10-28 02:44:48 +00:00
2023-11-21 19:12:54 +00:00
2023-01-18 23:30:15 +00:00
2024-01-31 17:05:40 +00:00
2022-04-02 14:19:25 +00:00
2023-07-26 16:09:00 +00:00
2024-01-16 12:35:30 +00:00
2022-04-02 14:19:25 +00:00
2022-07-11 13:04:01 +00:00
2024-01-31 17:05:56 +00:00
2022-04-02 14:19:25 +00:00
2023-01-26 22:50:22 +00:00
2023-04-24 18:41:52 +00:00
2022-04-02 14:19:25 +00:00
2023-01-05 10:48:21 +00:00
2024-01-03 21:12:45 +00:00
2024-01-23 13:52:57 +00:00
2023-12-30 07:37:04 +00:00
2022-04-02 14:19:25 +00:00
2024-01-23 13:59:39 +00:00
2022-04-24 19:02:42 +00:00
2023-01-05 10:46:36 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2023-11-21 19:01:29 +00:00
2022-12-31 10:56:10 +00:00
2023-08-29 09:51:28 +00:00
2022-09-11 08:35:18 +00:00
2023-01-09 18:36:05 +00:00
2024-01-11 11:57:59 +00:00
2025-06-23 18:41:56 +00:00
2023-08-29 09:54:23 +00:00
2022-04-02 14:19:25 +00:00
2022-09-15 19:45:26 +00:00
2023-12-30 07:33:44 +00:00
2023-06-15 09:31:04 +00:00
2022-04-30 08:56:30 +00:00
2023-07-31 09:19:33 +00:00
2022-11-21 11:01:16 +00:00
2024-10-18 17:16:09 +00:00
2024-05-11 17:41:01 +00:00
2023-06-15 09:35:38 +00:00
2022-04-30 08:54:59 +00:00
2022-12-29 11:22:22 +00:00
2022-12-26 08:30:22 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2022-12-27 16:26:45 +00:00
2022-12-27 16:26:15 +00:00
2024-01-11 11:58:34 +00:00
2023-09-12 16:06:26 +00:00
2024-02-09 11:33:23 +00:00
2022-04-02 14:19:25 +00:00
2024-01-23 14:00:08 +00:00
2022-12-27 16:25:02 +00:00
2022-12-27 16:24:23 +00:00
2023-08-10 06:34:27 +00:00
2022-04-02 14:19:25 +00:00
2024-05-11 17:41:01 +00:00
2022-04-10 10:18:40 +00:00
2022-12-27 16:34:44 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2023-12-30 07:31:01 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2023-05-03 07:28:37 +00:00
2024-01-03 21:26:40 +00:00
2024-01-31 10:28:33 +00:00
2022-12-17 17:20:45 +00:00
2024-01-03 21:19:41 +00:00
2022-04-02 14:19:25 +00:00
2023-11-22 21:35:32 +00:00
2024-01-11 11:59:09 +00:00
2024-01-23 13:53:38 +00:00
2022-11-28 13:09:53 +01:00
2023-09-12 16:15:41 +00:00
2023-02-10 09:27:02 +00:00
2023-01-26 23:11:22 +00:00
2023-03-05 15:13:24 +00:00
2022-12-26 08:36:06 +00:00
2022-11-21 11:02:10 +00:00
2024-02-07 11:21:49 +00:00
2022-05-30 19:45:10 +00:00
2023-07-26 16:08:59 +00:00
2024-01-03 21:07:37 +00:00
2022-12-26 08:40:14 +00:00
2022-04-02 14:19:25 +00:00
2024-01-25 10:23:03 +00:00
2025-07-12 16:09:44 +00:00
2022-04-02 14:19:25 +00:00
2025-02-04 16:47:07 +00:00
2022-04-02 14:19:25 +00:00
2023-12-30 07:30:29 +00:00
2022-12-27 16:31:49 +00:00
2023-03-05 14:53:06 +00:00
2025-01-29 16:27:08 +00:00
2025-05-09 20:19:42 +00:00
2024-01-23 13:53:58 +00:00
2023-12-30 07:29:51 +00:00
2023-11-21 19:27:56 +00:00
2024-09-30 16:28:51 +00:00
2024-01-23 14:00:41 +00:00
2023-10-09 08:17:20 +00:00
2023-01-26 23:17:50 +00:00
2024-02-01 16:08:42 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2023-03-05 15:14:51 +00:00
2023-11-26 09:40:17 +00:00
2022-05-01 08:43:14 +00:00
2024-01-30 17:49:46 +00:00
2023-11-21 19:30:01 +00:00
2022-04-02 14:19:25 +00:00
2024-01-23 13:54:10 +00:00
2024-01-03 21:21:38 +00:00
2023-11-21 19:31:28 +00:00
2023-11-21 19:31:11 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2022-05-02 20:22:22 +00:00
2023-11-21 19:31:40 +00:00
2024-01-29 16:02:18 +00:00
2023-08-24 13:42:04 +00:00
2022-04-29 18:58:17 +00:00
2023-01-26 23:17:27 +00:00
2022-04-29 19:37:10 +00:00
2023-07-26 16:09:00 +00:00
2023-09-12 16:17:48 +00:00
2023-01-04 21:35:28 +00:00
2022-04-02 14:19:25 +00:00
2023-06-15 09:36:10 +00:00
2023-04-18 21:09:58 +00:00
2024-01-03 21:04:20 +00:00
2023-06-15 09:38:19 +00:00
2023-07-26 16:08:59 +00:00
2024-01-03 21:26:40 +00:00
2023-07-26 16:09:00 +00:00
2023-07-01 19:08:20 +00:00
2023-11-21 19:20:19 +00:00
2023-07-26 16:09:00 +00:00
2023-07-26 16:09:00 +00:00
2023-08-07 09:19:13 +00:00
2024-01-30 17:40:51 +00:00
2023-08-16 15:01:26 +00:00
2023-05-03 07:52:11 +00:00
2023-12-30 07:25:59 +00:00
2024-03-01 04:08:02 +00:00
2024-01-23 14:01:09 +00:00
2023-03-05 15:15:10 +00:00
2023-04-24 18:54:21 +00:00
2022-04-02 14:19:25 +00:00
2023-06-22 21:28:05 +00:00
2022-04-02 14:19:25 +00:00
2022-12-27 16:31:06 +00:00
2022-09-01 21:16:49 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2022-09-01 21:16:49 +00:00
2022-04-10 10:05:27 +00:00
2022-09-01 21:16:49 +00:00
2022-04-02 14:19:25 +00:00
2022-06-17 10:22:31 +00:00
2024-01-23 13:55:14 +00:00
2022-04-02 14:19:25 +00:00
2023-07-31 09:27:27 +00:00
2024-01-23 13:56:08 +00:00
2023-08-08 16:07:28 +00:00
2022-04-02 14:19:25 +00:00
2023-09-12 16:18:08 +00:00
2022-12-26 08:56:24 +00:00
2022-11-10 15:13:51 +00:00
2023-10-30 09:53:48 +00:00
2023-11-21 19:21:02 +00:00
2023-12-30 06:50:03 +00:00
2023-08-19 14:30:31 +00:00
2023-03-05 14:15:52 +00:00
2023-07-31 13:47:31 +00:00
2022-04-02 14:19:25 +00:00
2023-05-18 11:24:29 +00:00
2024-02-17 19:58:52 +01:00
2023-03-04 13:54:40 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2023-12-30 07:25:05 +00:00
2022-07-09 14:58:58 +00:00
2023-11-21 19:21:16 +00:00
2022-11-21 11:05:13 +00:00
2024-01-23 14:01:46 +00:00
2023-04-18 21:15:28 +00:00
2022-04-02 14:19:25 +00:00
2024-01-31 17:06:43 +00:00
2024-02-09 11:25:40 +00:00
2023-08-15 09:27:19 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2023-02-10 09:26:37 +00:00
2023-02-10 09:26:37 +00:00
2023-06-15 09:38:39 +00:00
2023-10-09 08:16:24 +00:00
2024-01-11 11:55:59 +00:00
2024-01-23 13:56:42 +00:00
2024-01-03 21:25:57 +00:00
2022-11-23 12:25:36 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2022-11-29 13:42:35 +01:00
2023-10-09 08:17:23 +00:00
2022-04-02 14:19:25 +00:00
2023-08-07 09:17:38 +00:00
2023-08-30 16:16:34 +00:00
2023-05-03 07:28:22 +00:00
2022-04-02 14:19:25 +00:00
2023-11-22 21:41:02 +00:00
2023-06-15 09:38:56 +00:00
2024-01-03 21:27:41 +00:00
2023-08-30 16:17:24 +00:00
2023-08-30 16:17:45 +00:00
2023-12-30 06:43:39 +00:00
2023-11-22 21:38:11 +00:00
2025-05-21 15:53:03 +00:00
2024-02-14 19:00:36 +00:00
2022-04-02 14:19:25 +00:00
2023-11-21 19:23:58 +00:00
2024-02-05 11:02:25 +01:00
2024-02-05 11:05:02 +01:00
2024-02-05 11:06:29 +01:00
2024-02-05 11:07:03 +01:00
2022-04-02 14:19:25 +00:00
2024-01-30 17:49:57 +00:00
2022-04-02 14:19:25 +00:00
2024-01-23 13:57:03 +00:00
2023-08-29 09:55:11 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2023-08-30 16:19:54 +00:00
2022-04-02 14:19:25 +00:00
2023-11-21 19:24:39 +00:00
2023-09-01 10:30:33 +00:00
2022-04-02 14:19:25 +00:00
2024-01-31 10:29:13 +00:00
2022-04-02 14:19:25 +00:00
2022-04-02 14:19:25 +00:00
2024-01-31 10:29:47 +00:00
2023-05-03 07:52:26 +00:00