Currently, when initializing an action, the user-space can specify and use arbitrary values for the tcfa_action field. If the value is unknown by the kernel, is implicitly threaded as TC_ACT_UNSPEC. This change explicitly checks for unknown values at action creation time, and explicitly convert them to TC_ACT_UNSPEC. No functional changes are introduced, but this will allow introducing tcfa_action values not exposed to user-space in a later patch. Note: we can't use the above to hide TC_ACT_REDIRECT from user-space, as the latter is already part of uAPI. v3 -> v4: - use an helper to check for action validity (JiriP) - emit an extack for invalid actions (JiriP) v4 -> v5: - keep messages on a single line, drop net_warn (Marcelo)
Showing the changes to include/uapi/linux (1 of 2 files). Show all
Unified · Split
| @@ -45,6 +45,7 @@ enum { · 44 unmodified lines | ||
| 45 | 45 | * the skb and act like everything |
| 46 | 46 | * is alright. |
| 47 | 47 | */ |
| 48 | +#define TC_ACT_VALUE_MAX TC_ACT_TRAP | |
| 48 | 49 | |
| 49 | 50 | /* There is a special kind of actions called "extended actions", |
| 50 | 51 | * which need a value parameter. These have a local opcode located in |
| @@ -55,11 +56,12 @@ enum { · 4 unmodified lines | ||
| 55 | 56 | #define __TC_ACT_EXT_SHIFT 28 |
| 56 | 57 | #define __TC_ACT_EXT(local) ((local) << __TC_ACT_EXT_SHIFT) |
| 57 | 58 | #define TC_ACT_EXT_VAL_MASK ((1 << __TC_ACT_EXT_SHIFT) - 1) |
| 58 | −#define TC_ACT_EXT_CMP(combined, opcode) \ | |
| 59 | − (((combined) & (~TC_ACT_EXT_VAL_MASK)) == opcode) | |
| 59 | +#define TC_ACT_EXT_OPCODE(combined) ((combined) & (~TC_ACT_EXT_VAL_MASK)) | |
| 60 | +#define TC_ACT_EXT_CMP(combined, opcode) (TC_ACT_EXT_OPCODE(combined) == opcode) | |
| 60 | 61 | |
| 61 | 62 | #define TC_ACT_JUMP __TC_ACT_EXT(1) |
| 62 | 63 | #define TC_ACT_GOTO_CHAIN __TC_ACT_EXT(2) |
| 64 | +#define TC_ACT_EXT_OPCODE_MAX TC_ACT_GOTO_CHAIN | |
| 63 | 65 | |
| 64 | 66 | /* Action type identifiers*/ |
| 65 | 67 | enum { |