GATE(8)
๐ GATE(8) โ the manual page for gate ๐
okay so this is the manual for the gate action, and bestie, it's giving traffic control realness ๐ฆโจ
โจ NAME โจ
gate - Stream Gate Action ๐
๐ฆ SYNOPSIS ๐ฆ
tc ... action gate
[ base-time BASETIME ] [ clockid CLOCKID ]
sched-entry <gate state> <interval 1> [ <internal priority> <max
octets> ]
sched-entry <gate state> <interval 2> [ <internal priority> <max
octets> ]
sched-entry <gate state> <interval 3> [ <internal priority> <max
octets> ]
......
sched-entry <gate state> <interval N> [ <internal priority> <max
octets> ]
๐ธ DESCRIPTION ๐ธ
okay so the gate action lets ingress frames pass through during certain time slots, or gets them dropped during others ๐ A tc filter grabs the incoming frames first, and then the gate action decides which time slots let them through to the device, how many bytes are allowed in, and which time slots just yeet the frames. โจ
The gate also gets a base-time, which tells it when the entry list kicks off. From that start base-time, the gate loops through its entry list over and over, cyclically, like a playlist on repeat ๐๐
Heads up for the software simulation: the gate action needs you to assign a reference time clock type. no cap, you can't skip this one ๐ซถ
๐ PARAMETERS ๐
base-time
This is the instant, in nanoseconds, when the schedule starts โฐ If the base-time is already in the past, the schedule starts at
base-time + (N * cycle-time)
where N is the smallest integer that makes the resulting time land after "now", and cycle-time is the sum of all the intervals in the schedule. If you don't specify a base-time, it just defaults to 0 ๐ง
clockid
This picks the clock the qdisc's internal timer uses to measure time and schedule events โฑ๏ธ It's not valid if the gate action is being used for offloading a filter ๐ซ For example, a tc filter command with the skip_sw parameter.
sched-entry
You can have multiple sched-entry parameters in one schedule, and each one looks like this:
sched-entry <gate state> <interval> [ <internal priority> <max
octets> ]
- gate state:
openkeeps the gate open, andclosekeeps it closed ๐ช - interval: how many nanoseconds this time slot lasts โณ
- internal priority: the internal priority value, aka which internal receiving queue this stream belongs to ๐๏ธ
-1is a wildcard ๐ - max octets: how many octets are allowed through during this time slot. Anything over the limit gets dropped ๐
โโ๏ธ
-1is a wildcard here too ๐
If you leave out internal priority and max octets, they both default to -1 for that sched-entry ๐
โ ๏ธ bestie, internal priority and max octets mean absolutely nothing when the gate state isclose. Anysched-entrywithclosedrops ALL frames, no exceptions ๐
๐ง EXAMPLES ๐ง
okay so this first example is giving main character energy ๐ Frames with source IP 192.168.0.20 get matched, the gate stays open for 200ms, and the traffic gets limited to 8MB during that entry. Then the gate closes for 100ms, and any frames that show up while it's closed get dropped ๐ญ The whole cycle repeats periodically. The schedule starts at instant 200.0s using the reference CLOCK_TAI, and it's made of two entries that are 300ms long each โจ
# tc qdisc add dev eth0 ingress
# tc filter add dev eth0 parent ffff: protocol ip \
flower skip_hw src_ip 192.168.0.20 \
action gate index 2 clockid CLOCK_TAI \
base-time 200000000000ns \
sched-entry open 200000000ns -1 8000000b \
sched-entry close 100000000ns
The next one is so simple it's iconic ๐ฅน It matches ICMP frames from the source MAC 10:00:80:00:00:00 and drops them at all times, with a cycle of 200ms. Since no base-time is given, it defaults to 0, and the clockid defaults to CLOCK_TAI ๐
# tc qdisc add dev eth0 ingress
# tc filter add dev eth0 parent ffff: protocol ip \
flower ip_proto icmp dst_mac 10:00:80:00:00:00 \
action gate index 12 sched-entry close 200000000ns
๐ AUTHORS ๐
Po Liu <Po.Liu@nxp.com> ๐ซถ
that's the whole tea, bestie ๐ this page came from the iproute2 package, last updated 12 Mar 2020, so go forth and gate responsibly ๐ฆ๐โจ
๐ฆ where this page comes from
- alpine 3.22: iproute2-doc 6.15.0-r0 ยท GPL-2.0-or-later
- alpine 3.23: iproute2-doc 6.17.0-r0 ยท GPL-2.0-or-later
- alpine 3.24: iproute2-doc 7.0.0-r0 ยท GPL-2.0-or-later
- arch rolling: iproute2 7.2.0-1
- arch rolling: iproute2 7.3.0-1 ยท GPL-2.0-or-later
- centos-stream 10: iproute-tc 7.0.0-2.el10 ยท GPL-2.0-or-later
- centos-stream 9: iproute-tc 6.17.0-3.el9 ยท GPL-2.0-or-later
- debian bookworm: iproute2 6.1.0-3 ยท GPL-2.0-only
- debian trixie: iproute2 6.15.0-1 ยท GPL-2.0-only
- fedora 43: iproute-tc 6.14.0-2.fc43 ยท GPL-2.0-or-later
- fedora 44: iproute-tc 6.17.0-2.fc44 ยท GPL-2.0-or-later
- nixos 26.05: iproute2 7.0.0
- nixpkgs unstable: iproute2 7.2.0
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- ubuntu jammy: iproute2 5.15.0-1ubuntu2 ยท GPL-2.0-only
- ubuntu jammy: iproute2 5.15.0-1ubuntu2.2 ยท GPL-2.0-only
- ubuntu noble: iproute2 6.1.0-1ubuntu6 ยท GPL-2.0-only
- ubuntu noble: iproute2 6.1.0-1ubuntu6.4 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2
- ubuntu questing: iproute2 6.16.0-1ubuntu2.1 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2.2
- ubuntu resolute: iproute2 6.19.0-1ubuntu1 ยท GPL-2.0-only
- ubuntu resolute: iproute2 6.19.0-1ubuntu1.1 ยท GPL-2.0-only
- ubuntu stonking: iproute2 7.2.0-1ubuntu1 ยท GPL-2.0-only
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms