diff options
Diffstat (limited to 'include/net/pkt_cls.h')
-rw-r--r-- | include/net/pkt_cls.h | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 6f8d65342d3a..c99508d426cc 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h | |||
@@ -59,7 +59,8 @@ tcf_unbind_filter(struct tcf_proto *tp, struct tcf_result *r) | |||
59 | struct tcf_exts { | 59 | struct tcf_exts { |
60 | #ifdef CONFIG_NET_CLS_ACT | 60 | #ifdef CONFIG_NET_CLS_ACT |
61 | __u32 type; /* for backward compat(TCA_OLD_COMPAT) */ | 61 | __u32 type; /* for backward compat(TCA_OLD_COMPAT) */ |
62 | struct list_head actions; | 62 | int nr_actions; |
63 | struct tc_action **actions; | ||
63 | #endif | 64 | #endif |
64 | /* Map to export classifier specific extension TLV types to the | 65 | /* Map to export classifier specific extension TLV types to the |
65 | * generic extensions API. Unsupported extensions must be set to 0. | 66 | * generic extensions API. Unsupported extensions must be set to 0. |
@@ -72,7 +73,10 @@ static inline void tcf_exts_init(struct tcf_exts *exts, int action, int police) | |||
72 | { | 73 | { |
73 | #ifdef CONFIG_NET_CLS_ACT | 74 | #ifdef CONFIG_NET_CLS_ACT |
74 | exts->type = 0; | 75 | exts->type = 0; |
75 | INIT_LIST_HEAD(&exts->actions); | 76 | exts->nr_actions = 0; |
77 | exts->actions = kcalloc(TCA_ACT_MAX_PRIO, sizeof(struct tc_action *), | ||
78 | GFP_KERNEL); | ||
79 | WARN_ON(!exts->actions); /* TODO: propagate the error to callers */ | ||
76 | #endif | 80 | #endif |
77 | exts->action = action; | 81 | exts->action = action; |
78 | exts->police = police; | 82 | exts->police = police; |
@@ -89,7 +93,7 @@ static inline int | |||
89 | tcf_exts_is_predicative(struct tcf_exts *exts) | 93 | tcf_exts_is_predicative(struct tcf_exts *exts) |
90 | { | 94 | { |
91 | #ifdef CONFIG_NET_CLS_ACT | 95 | #ifdef CONFIG_NET_CLS_ACT |
92 | return !list_empty(&exts->actions); | 96 | return exts->nr_actions; |
93 | #else | 97 | #else |
94 | return 0; | 98 | return 0; |
95 | #endif | 99 | #endif |
@@ -108,6 +112,20 @@ tcf_exts_is_available(struct tcf_exts *exts) | |||
108 | return tcf_exts_is_predicative(exts); | 112 | return tcf_exts_is_predicative(exts); |
109 | } | 113 | } |
110 | 114 | ||
115 | static inline void tcf_exts_to_list(const struct tcf_exts *exts, | ||
116 | struct list_head *actions) | ||
117 | { | ||
118 | #ifdef CONFIG_NET_CLS_ACT | ||
119 | int i; | ||
120 | |||
121 | for (i = 0; i < exts->nr_actions; i++) { | ||
122 | struct tc_action *a = exts->actions[i]; | ||
123 | |||
124 | list_add(&a->list, actions); | ||
125 | } | ||
126 | #endif | ||
127 | } | ||
128 | |||
111 | /** | 129 | /** |
112 | * tcf_exts_exec - execute tc filter extensions | 130 | * tcf_exts_exec - execute tc filter extensions |
113 | * @skb: socket buffer | 131 | * @skb: socket buffer |
@@ -124,12 +142,25 @@ tcf_exts_exec(struct sk_buff *skb, struct tcf_exts *exts, | |||
124 | struct tcf_result *res) | 142 | struct tcf_result *res) |
125 | { | 143 | { |
126 | #ifdef CONFIG_NET_CLS_ACT | 144 | #ifdef CONFIG_NET_CLS_ACT |
127 | if (!list_empty(&exts->actions)) | 145 | if (exts->nr_actions) |
128 | return tcf_action_exec(skb, &exts->actions, res); | 146 | return tcf_action_exec(skb, exts->actions, exts->nr_actions, |
147 | res); | ||
129 | #endif | 148 | #endif |
130 | return 0; | 149 | return 0; |
131 | } | 150 | } |
132 | 151 | ||
152 | #ifdef CONFIG_NET_CLS_ACT | ||
153 | |||
154 | #define tc_no_actions(_exts) ((_exts)->nr_actions == 0) | ||
155 | #define tc_single_action(_exts) ((_exts)->nr_actions == 1) | ||
156 | |||
157 | #else /* CONFIG_NET_CLS_ACT */ | ||
158 | |||
159 | #define tc_no_actions(_exts) true | ||
160 | #define tc_single_action(_exts) false | ||
161 | |||
162 | #endif /* CONFIG_NET_CLS_ACT */ | ||
163 | |||
133 | int tcf_exts_validate(struct net *net, struct tcf_proto *tp, | 164 | int tcf_exts_validate(struct net *net, struct tcf_proto *tp, |
134 | struct nlattr **tb, struct nlattr *rate_tlv, | 165 | struct nlattr **tb, struct nlattr *rate_tlv, |
135 | struct tcf_exts *exts, bool ovr); | 166 | struct tcf_exts *exts, bool ovr); |