Jamal Hadi Salim | d892afe | 2007-10-26 02:49:09 -0700 | [diff] [blame] | 1 | |
| 2 | The "enviromental" rules for authors of any new tc actions are: |
| 3 | |
| 4 | 1) If you stealeth or borroweth any packet thou shalt be branching |
| 5 | from the righteous path and thou shalt cloneth. |
| 6 | |
Matt LaPlante | d919588 | 2008-07-25 19:45:33 -0700 | [diff] [blame] | 7 | For example if your action queues a packet to be processed later, |
| 8 | or intentionally branches by redirecting a packet, then you need to |
Jamal Hadi Salim | d892afe | 2007-10-26 02:49:09 -0700 | [diff] [blame] | 9 | clone the packet. |
Matt LaPlante | d919588 | 2008-07-25 19:45:33 -0700 | [diff] [blame] | 10 | |
Jamal Hadi Salim | d892afe | 2007-10-26 02:49:09 -0700 | [diff] [blame] | 11 | There are certain fields in the skb tc_verd that need to be reset so we |
Matt LaPlante | d919588 | 2008-07-25 19:45:33 -0700 | [diff] [blame] | 12 | avoid loops, etc. A few are generic enough that skb_act_clone() |
| 13 | resets them for you, so invoke skb_act_clone() rather than skb_clone(). |
Jamal Hadi Salim | d892afe | 2007-10-26 02:49:09 -0700 | [diff] [blame] | 14 | |
| 15 | 2) If you munge any packet thou shalt call pskb_expand_head in the case |
| 16 | someone else is referencing the skb. After that you "own" the skb. |
| 17 | You must also tell us if it is ok to munge the packet (TC_OK2MUNGE), |
| 18 | this way any action downstream can stomp on the packet. |
| 19 | |
Matt LaPlante | d919588 | 2008-07-25 19:45:33 -0700 | [diff] [blame] | 20 | 3) Dropping packets you don't own is a no-no. You simply return |
Jamal Hadi Salim | d892afe | 2007-10-26 02:49:09 -0700 | [diff] [blame] | 21 | TC_ACT_SHOT to the caller and they will drop it. |
| 22 | |
| 23 | The "enviromental" rules for callers of actions (qdiscs etc) are: |
| 24 | |
Matt LaPlante | d919588 | 2008-07-25 19:45:33 -0700 | [diff] [blame] | 25 | *) Thou art responsible for freeing anything returned as being |
Jamal Hadi Salim | d892afe | 2007-10-26 02:49:09 -0700 | [diff] [blame] | 26 | TC_ACT_SHOT/STOLEN/QUEUED. If none of TC_ACT_SHOT/STOLEN/QUEUED is |
Matt LaPlante | d919588 | 2008-07-25 19:45:33 -0700 | [diff] [blame] | 27 | returned, then all is great and you don't need to do anything. |
Jamal Hadi Salim | d892afe | 2007-10-26 02:49:09 -0700 | [diff] [blame] | 28 | |
| 29 | Post on netdev if something is unclear. |
| 30 | |