Skip to content

Commit 97a3f84

Browse files
congwangdavem330
authored andcommitted
net_sched: remove unnecessary ops->delete()
All ops->delete() wants is getting the tn->idrinfo, but we already have tc_action before calling ops->delete(), and tc_action has a pointer ->idrinfo. More importantly, each type of action does the same thing, that is, just calling tcf_idr_delete_index(). So it can be just removed. Fixes: b409074 ("net: sched: add 'delete' function to action ops") Cc: Jiri Pirko <jiri@mellanox.com> Cc: Vlad Buslov <vladbu@mellanox.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent edfaf94 commit 97a3f84

File tree

18 files changed

+7
-146
lines changed

18 files changed

+7
-146
lines changed

include/net/act_api.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ struct tc_action_ops {
102102
size_t (*get_fill_size)(const struct tc_action *act);
103103
struct net_device *(*get_dev)(const struct tc_action *a);
104104
void (*put_dev)(struct net_device *dev);
105-
int (*delete)(struct net *net, u32 index);
106105
};
107106

108107
struct tc_action_net {
@@ -158,7 +157,6 @@ void tcf_idr_insert(struct tc_action_net *tn, struct tc_action *a);
158157
void tcf_idr_cleanup(struct tc_action_net *tn, u32 index);
159158
int tcf_idr_check_alloc(struct tc_action_net *tn, u32 *index,
160159
struct tc_action **a, int bind);
161-
int tcf_idr_delete_index(struct tc_action_net *tn, u32 index);
162160
int __tcf_idr_release(struct tc_action *a, bool bind, bool strict);
163161

164162
static inline int tcf_idr_release(struct tc_action *a, bool bind)

net/sched/act_api.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,8 @@ bool tcf_idr_check(struct tc_action_net *tn, u32 index, struct tc_action **a,
337337
}
338338
EXPORT_SYMBOL(tcf_idr_check);
339339

340-
int tcf_idr_delete_index(struct tc_action_net *tn, u32 index)
340+
static int tcf_idr_delete_index(struct tcf_idrinfo *idrinfo, u32 index)
341341
{
342-
struct tcf_idrinfo *idrinfo = tn->idrinfo;
343342
struct tc_action *p;
344343
int ret = 0;
345344

@@ -370,7 +369,6 @@ int tcf_idr_delete_index(struct tc_action_net *tn, u32 index)
370369
spin_unlock(&idrinfo->lock);
371370
return ret;
372371
}
373-
EXPORT_SYMBOL(tcf_idr_delete_index);
374372

375373
int tcf_idr_create(struct tc_action_net *tn, u32 index, struct nlattr *est,
376374
struct tc_action **a, const struct tc_action_ops *ops,
@@ -1182,24 +1180,25 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
11821180
static int tcf_action_delete(struct net *net, struct tc_action *actions[],
11831181
struct netlink_ext_ack *extack)
11841182
{
1185-
u32 act_index;
1186-
int ret, i;
1183+
int i;
11871184

11881185
for (i = 0; i < TCA_ACT_MAX_PRIO && actions[i]; i++) {
11891186
struct tc_action *a = actions[i];
11901187
const struct tc_action_ops *ops = a->ops;
1191-
11921188
/* Actions can be deleted concurrently so we must save their
11931189
* type and id to search again after reference is released.
11941190
*/
1195-
act_index = a->tcfa_index;
1191+
struct tcf_idrinfo *idrinfo = a->idrinfo;
1192+
u32 act_index = a->tcfa_index;
11961193

11971194
if (tcf_action_put(a)) {
11981195
/* last reference, action was deleted concurrently */
11991196
module_put(ops->owner);
12001197
} else {
1198+
int ret;
1199+
12011200
/* now do the delete */
1202-
ret = ops->delete(net, act_index);
1201+
ret = tcf_idr_delete_index(idrinfo, act_index);
12031202
if (ret < 0)
12041203
return ret;
12051204
}

net/sched/act_bpf.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,6 @@ static int tcf_bpf_search(struct net *net, struct tc_action **a, u32 index,
395395
return tcf_idr_search(tn, a, index);
396396
}
397397

398-
static int tcf_bpf_delete(struct net *net, u32 index)
399-
{
400-
struct tc_action_net *tn = net_generic(net, bpf_net_id);
401-
402-
return tcf_idr_delete_index(tn, index);
403-
}
404-
405398
static struct tc_action_ops act_bpf_ops __read_mostly = {
406399
.kind = "bpf",
407400
.type = TCA_ACT_BPF,
@@ -412,7 +405,6 @@ static struct tc_action_ops act_bpf_ops __read_mostly = {
412405
.init = tcf_bpf_init,
413406
.walk = tcf_bpf_walker,
414407
.lookup = tcf_bpf_search,
415-
.delete = tcf_bpf_delete,
416408
.size = sizeof(struct tcf_bpf),
417409
};
418410

net/sched/act_connmark.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,6 @@ static int tcf_connmark_search(struct net *net, struct tc_action **a, u32 index,
198198
return tcf_idr_search(tn, a, index);
199199
}
200200

201-
static int tcf_connmark_delete(struct net *net, u32 index)
202-
{
203-
struct tc_action_net *tn = net_generic(net, connmark_net_id);
204-
205-
return tcf_idr_delete_index(tn, index);
206-
}
207-
208201
static struct tc_action_ops act_connmark_ops = {
209202
.kind = "connmark",
210203
.type = TCA_ACT_CONNMARK,
@@ -214,7 +207,6 @@ static struct tc_action_ops act_connmark_ops = {
214207
.init = tcf_connmark_init,
215208
.walk = tcf_connmark_walker,
216209
.lookup = tcf_connmark_search,
217-
.delete = tcf_connmark_delete,
218210
.size = sizeof(struct tcf_connmark_info),
219211
};
220212

net/sched/act_csum.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -659,13 +659,6 @@ static size_t tcf_csum_get_fill_size(const struct tc_action *act)
659659
return nla_total_size(sizeof(struct tc_csum));
660660
}
661661

662-
static int tcf_csum_delete(struct net *net, u32 index)
663-
{
664-
struct tc_action_net *tn = net_generic(net, csum_net_id);
665-
666-
return tcf_idr_delete_index(tn, index);
667-
}
668-
669662
static struct tc_action_ops act_csum_ops = {
670663
.kind = "csum",
671664
.type = TCA_ACT_CSUM,
@@ -677,7 +670,6 @@ static struct tc_action_ops act_csum_ops = {
677670
.walk = tcf_csum_walker,
678671
.lookup = tcf_csum_search,
679672
.get_fill_size = tcf_csum_get_fill_size,
680-
.delete = tcf_csum_delete,
681673
.size = sizeof(struct tcf_csum),
682674
};
683675

net/sched/act_gact.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,6 @@ static size_t tcf_gact_get_fill_size(const struct tc_action *act)
243243
return sz;
244244
}
245245

246-
static int tcf_gact_delete(struct net *net, u32 index)
247-
{
248-
struct tc_action_net *tn = net_generic(net, gact_net_id);
249-
250-
return tcf_idr_delete_index(tn, index);
251-
}
252-
253246
static struct tc_action_ops act_gact_ops = {
254247
.kind = "gact",
255248
.type = TCA_ACT_GACT,
@@ -261,7 +254,6 @@ static struct tc_action_ops act_gact_ops = {
261254
.walk = tcf_gact_walker,
262255
.lookup = tcf_gact_search,
263256
.get_fill_size = tcf_gact_get_fill_size,
264-
.delete = tcf_gact_delete,
265257
.size = sizeof(struct tcf_gact),
266258
};
267259

net/sched/act_ife.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -853,13 +853,6 @@ static int tcf_ife_search(struct net *net, struct tc_action **a, u32 index,
853853
return tcf_idr_search(tn, a, index);
854854
}
855855

856-
static int tcf_ife_delete(struct net *net, u32 index)
857-
{
858-
struct tc_action_net *tn = net_generic(net, ife_net_id);
859-
860-
return tcf_idr_delete_index(tn, index);
861-
}
862-
863856
static struct tc_action_ops act_ife_ops = {
864857
.kind = "ife",
865858
.type = TCA_ACT_IFE,
@@ -870,7 +863,6 @@ static struct tc_action_ops act_ife_ops = {
870863
.init = tcf_ife_init,
871864
.walk = tcf_ife_walker,
872865
.lookup = tcf_ife_search,
873-
.delete = tcf_ife_delete,
874866
.size = sizeof(struct tcf_ife_info),
875867
};
876868

net/sched/act_ipt.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,6 @@ static int tcf_ipt_search(struct net *net, struct tc_action **a, u32 index,
337337
return tcf_idr_search(tn, a, index);
338338
}
339339

340-
static int tcf_ipt_delete(struct net *net, u32 index)
341-
{
342-
struct tc_action_net *tn = net_generic(net, ipt_net_id);
343-
344-
return tcf_idr_delete_index(tn, index);
345-
}
346-
347340
static struct tc_action_ops act_ipt_ops = {
348341
.kind = "ipt",
349342
.type = TCA_ACT_IPT,
@@ -354,7 +347,6 @@ static struct tc_action_ops act_ipt_ops = {
354347
.init = tcf_ipt_init,
355348
.walk = tcf_ipt_walker,
356349
.lookup = tcf_ipt_search,
357-
.delete = tcf_ipt_delete,
358350
.size = sizeof(struct tcf_ipt),
359351
};
360352

@@ -395,13 +387,6 @@ static int tcf_xt_search(struct net *net, struct tc_action **a, u32 index,
395387
return tcf_idr_search(tn, a, index);
396388
}
397389

398-
static int tcf_xt_delete(struct net *net, u32 index)
399-
{
400-
struct tc_action_net *tn = net_generic(net, xt_net_id);
401-
402-
return tcf_idr_delete_index(tn, index);
403-
}
404-
405390
static struct tc_action_ops act_xt_ops = {
406391
.kind = "xt",
407392
.type = TCA_ACT_XT,
@@ -412,7 +397,6 @@ static struct tc_action_ops act_xt_ops = {
412397
.init = tcf_xt_init,
413398
.walk = tcf_xt_walker,
414399
.lookup = tcf_xt_search,
415-
.delete = tcf_xt_delete,
416400
.size = sizeof(struct tcf_ipt),
417401
};
418402

net/sched/act_mirred.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,6 @@ static void tcf_mirred_put_dev(struct net_device *dev)
395395
dev_put(dev);
396396
}
397397

398-
static int tcf_mirred_delete(struct net *net, u32 index)
399-
{
400-
struct tc_action_net *tn = net_generic(net, mirred_net_id);
401-
402-
return tcf_idr_delete_index(tn, index);
403-
}
404-
405398
static struct tc_action_ops act_mirred_ops = {
406399
.kind = "mirred",
407400
.type = TCA_ACT_MIRRED,
@@ -416,7 +409,6 @@ static struct tc_action_ops act_mirred_ops = {
416409
.size = sizeof(struct tcf_mirred),
417410
.get_dev = tcf_mirred_get_dev,
418411
.put_dev = tcf_mirred_put_dev,
419-
.delete = tcf_mirred_delete,
420412
};
421413

422414
static __net_init int mirred_init_net(struct net *net)

net/sched/act_nat.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,6 @@ static int tcf_nat_search(struct net *net, struct tc_action **a, u32 index,
300300
return tcf_idr_search(tn, a, index);
301301
}
302302

303-
static int tcf_nat_delete(struct net *net, u32 index)
304-
{
305-
struct tc_action_net *tn = net_generic(net, nat_net_id);
306-
307-
return tcf_idr_delete_index(tn, index);
308-
}
309-
310303
static struct tc_action_ops act_nat_ops = {
311304
.kind = "nat",
312305
.type = TCA_ACT_NAT,
@@ -316,7 +309,6 @@ static struct tc_action_ops act_nat_ops = {
316309
.init = tcf_nat_init,
317310
.walk = tcf_nat_walker,
318311
.lookup = tcf_nat_search,
319-
.delete = tcf_nat_delete,
320312
.size = sizeof(struct tcf_nat),
321313
};
322314

0 commit comments

Comments
 (0)