TC-GACT(8)

โœจ gact: Generic actions in tc(8) โœจ

Hiii bestie ๐Ÿฆ‹ Okay so this is the page for gact, the generic action that lives inside tc(8). It's a Linux thing, and honestly it's giving very clean energy ๐Ÿ’…


๐Ÿงš NAME

Okay so the name is just gact, short for generic action. Simple, iconic ๐Ÿ’–

๐Ÿ”ฅ SYNOPSIS

Here's the shape of the command. Read it like a little recipe ๐Ÿ“

tc ... action gact CONTROL [ RAND ] [ INDEX ]
CONTROL := { reclassify | drop | continue | pass | pipe |
        goto chain CHAIN_INDEX |
        jump JUMP_COUNT }

RAND := random RANDTYPE CONTROL VAL
RANDTYPE := { netrand | determ }
VAL := number not exceeding 10000
JUMP_COUNT := absolute jump from start of action list
INDEX := index value used

๐ŸŒธ DESCRIPTION

Okay so gact lets you reclassify, drop, pass, or accept packets. Main character energy ๐Ÿ‘‘ Right now there are only two algorithms. One is deterministic, and the other uses the internal kernel netrand. Both are lowkey iconic ๐Ÿซถ

โœจ OPTIONS โœจ

  • random RANDTYPE CONTROL VAL โ€” This one is the probability setting. It tells you the chance of taking the action, written as 1 out of VAL packets. So 1 out of every VAL packets gets the action ๐ŸŽ€
  • CONTROL โ€” This is where you tell tc how to proceed if the packet matches. For all the possible CONTROL values, go check out tc-actions(8). Literally the place to go ๐Ÿ’œ

๐Ÿฆ‹ EXAMPLES ๐Ÿฆ‹

Okay now the fun part ๐Ÿ˜ญ Here are the examples, all of them, ready to copy.

Apply a rule on ingress to drop packets from a given source address. Bye bye, bad vibes ๐Ÿ™ˆ

# tc filter add dev eth0 parent ffff: protocol ip prio 6 u32 match ip src 10.0.0.9/32 flowid 1:16 action drop

Allow 1 out of 10 packets from the source, randomly, using the netrand generator. Lowkey a probability flex ๐ŸŽฒ

# tc filter add dev eth0 parent ffff: protocol ip prio 6 u32 match ip src 10.0.0.9/32 flowid 1:16 action drop random netrand ok 10

Deterministically accept every second packet. Predictable and periodt ๐Ÿ’…

# tc filter add dev eth0 parent ffff: protocol ip prio 6 u32 match ip src 10.0.0.9/32 flowid 1:16 action drop random determ ok 2

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

Go check these out, they're the real ones ๐Ÿซถ


Okay that's the whole tea ๐Ÿต Shoutout to iproute2, last updated 11 Jan 2023, all about Generic actions in tc(8). Love you, mwah ๐Ÿ’–๐Ÿงšโœจ