Skip to content

Commit f34e8bf

Browse files
jpirkodavem330
authored andcommitted
net: sched: push ops lookup bits into tcf_proto_lookup_ops()
Push all bits that take care of ops lookup, including module loading outside tcf_proto_create() function, into tcf_proto_lookup_ops() Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d3585ed commit f34e8bf

File tree

1 file changed

+31
-22
lines changed

1 file changed

+31
-22
lines changed

net/sched/cls_api.c

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static DEFINE_RWLOCK(cls_mod_lock);
3939

4040
/* Find classifier type by string name */
4141

42-
static const struct tcf_proto_ops *tcf_proto_lookup_ops(const char *kind)
42+
static const struct tcf_proto_ops *__tcf_proto_lookup_ops(const char *kind)
4343
{
4444
const struct tcf_proto_ops *t, *res = NULL;
4545

@@ -57,6 +57,33 @@ static const struct tcf_proto_ops *tcf_proto_lookup_ops(const char *kind)
5757
return res;
5858
}
5959

60+
static const struct tcf_proto_ops *
61+
tcf_proto_lookup_ops(const char *kind, struct netlink_ext_ack *extack)
62+
{
63+
const struct tcf_proto_ops *ops;
64+
65+
ops = __tcf_proto_lookup_ops(kind);
66+
if (ops)
67+
return ops;
68+
#ifdef CONFIG_MODULES
69+
rtnl_unlock();
70+
request_module("cls_%s", kind);
71+
rtnl_lock();
72+
ops = __tcf_proto_lookup_ops(kind);
73+
/* We dropped the RTNL semaphore in order to perform
74+
* the module load. So, even if we succeeded in loading
75+
* the module we have to replay the request. We indicate
76+
* this using -EAGAIN.
77+
*/
78+
if (ops) {
79+
module_put(ops->owner);
80+
return ERR_PTR(-EAGAIN);
81+
}
82+
#endif
83+
NL_SET_ERR_MSG(extack, "TC classifier not found");
84+
return ERR_PTR(-ENOENT);
85+
}
86+
6087
/* Register(unregister) new classifier type */
6188

6289
int register_tcf_proto_ops(struct tcf_proto_ops *ops)
@@ -133,27 +160,9 @@ static struct tcf_proto *tcf_proto_create(const char *kind, u32 protocol,
133160
if (!tp)
134161
return ERR_PTR(-ENOBUFS);
135162

136-
err = -ENOENT;
137-
tp->ops = tcf_proto_lookup_ops(kind);
138-
if (!tp->ops) {
139-
#ifdef CONFIG_MODULES
140-
rtnl_unlock();
141-
request_module("cls_%s", kind);
142-
rtnl_lock();
143-
tp->ops = tcf_proto_lookup_ops(kind);
144-
/* We dropped the RTNL semaphore in order to perform
145-
* the module load. So, even if we succeeded in loading
146-
* the module we have to replay the request. We indicate
147-
* this using -EAGAIN.
148-
*/
149-
if (tp->ops) {
150-
module_put(tp->ops->owner);
151-
err = -EAGAIN;
152-
} else {
153-
NL_SET_ERR_MSG(extack, "TC classifier not found");
154-
err = -ENOENT;
155-
}
156-
#endif
163+
tp->ops = tcf_proto_lookup_ops(kind, extack);
164+
if (IS_ERR(tp->ops)) {
165+
err = PTR_ERR(tp->ops);
157166
goto errout;
158167
}
159168
tp->classify = tp->ops->classify;

0 commit comments

Comments
 (0)