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