^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) ================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) TC Actions - Environmental Rules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) ================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) The "environmental" rules for authors of any new tc actions are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 1) If you stealeth or borroweth any packet thou shalt be branching
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) from the righteous path and thou shalt cloneth.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) For example if your action queues a packet to be processed later,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) or intentionally branches by redirecting a packet, then you need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) clone the packet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 2) If you munge any packet thou shalt call pskb_expand_head in the case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) someone else is referencing the skb. After that you "own" the skb.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 3) Dropping packets you don't own is a no-no. You simply return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) TC_ACT_SHOT to the caller and they will drop it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) The "environmental" rules for callers of actions (qdiscs etc) are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #) Thou art responsible for freeing anything returned as being
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) TC_ACT_SHOT/STOLEN/QUEUED. If none of TC_ACT_SHOT/STOLEN/QUEUED is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) returned, then all is great and you don't need to do anything.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) Post on netdev if something is unclear.