Skip to content

Commit e8eb36c

Browse files
amirvdavem330
authored andcommitted
net/sched: flower: Return error when hw can't offload and skip_sw is set
When skip_sw is set and hardware fails to apply filter, return error to user. This will make error propagation logic similar to the one currently used in u32 classifier. Also, changed code to use tc_skip_sw() utility function. Signed-off-by: Amir Vadai <[email protected]> Acked-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ce9355a commit e8eb36c

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

net/sched/cls_flower.c

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp,
140140
f = rhashtable_lookup_fast(&head->ht,
141141
fl_key_get_start(&skb_mkey, &head->mask),
142142
head->ht_params);
143-
if (f && !(f->flags & TCA_CLS_FLAGS_SKIP_SW)) {
143+
if (f && !tc_skip_sw(f->flags)) {
144144
*res = f->res;
145145
return tcf_exts_exec(skb, &f->exts, res);
146146
}
@@ -187,19 +187,20 @@ static void fl_hw_destroy_filter(struct tcf_proto *tp, unsigned long cookie)
187187
dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, tp->protocol, &tc);
188188
}
189189

190-
static void fl_hw_replace_filter(struct tcf_proto *tp,
191-
struct flow_dissector *dissector,
192-
struct fl_flow_key *mask,
193-
struct fl_flow_key *key,
194-
struct tcf_exts *actions,
195-
unsigned long cookie, u32 flags)
190+
static int fl_hw_replace_filter(struct tcf_proto *tp,
191+
struct flow_dissector *dissector,
192+
struct fl_flow_key *mask,
193+
struct fl_flow_key *key,
194+
struct tcf_exts *actions,
195+
unsigned long cookie, u32 flags)
196196
{
197197
struct net_device *dev = tp->q->dev_queue->dev;
198198
struct tc_cls_flower_offload offload = {0};
199199
struct tc_to_netdev tc;
200+
int err;
200201

201202
if (!tc_should_offload(dev, tp, flags))
202-
return;
203+
return tc_skip_sw(flags) ? -EINVAL : 0;
203204

204205
offload.command = TC_CLSFLOWER_REPLACE;
205206
offload.cookie = cookie;
@@ -211,7 +212,12 @@ static void fl_hw_replace_filter(struct tcf_proto *tp,
211212
tc.type = TC_SETUP_CLSFLOWER;
212213
tc.cls_flower = &offload;
213214

214-
dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, tp->protocol, &tc);
215+
err = dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, tp->protocol, &tc);
216+
217+
if (tc_skip_sw(flags))
218+
return err;
219+
220+
return 0;
215221
}
216222

217223
static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f)
@@ -572,20 +578,22 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
572578
if (err)
573579
goto errout;
574580

575-
if (!(fnew->flags & TCA_CLS_FLAGS_SKIP_SW)) {
581+
if (!tc_skip_sw(fnew->flags)) {
576582
err = rhashtable_insert_fast(&head->ht, &fnew->ht_node,
577583
head->ht_params);
578584
if (err)
579585
goto errout;
580586
}
581587

582-
fl_hw_replace_filter(tp,
583-
&head->dissector,
584-
&mask.key,
585-
&fnew->key,
586-
&fnew->exts,
587-
(unsigned long)fnew,
588-
fnew->flags);
588+
err = fl_hw_replace_filter(tp,
589+
&head->dissector,
590+
&mask.key,
591+
&fnew->key,
592+
&fnew->exts,
593+
(unsigned long)fnew,
594+
fnew->flags);
595+
if (err)
596+
goto errout;
589597

590598
if (fold) {
591599
rhashtable_remove_fast(&head->ht, &fold->ht_node,

0 commit comments

Comments
 (0)