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: open keeps the gate open, and close keeps 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 ๐ŸŽŸ๏ธ -1 is a wildcard ๐Ÿƒ
  • max octets: how many octets are allowed through during this time slot. Anything over the limit gets dropped ๐Ÿ™…โ€โ™€๏ธ -1 is 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 is close. Any sched-entry with close drops 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