@@ -39,7 +39,7 @@ static DEFINE_RWLOCK(cls_mod_lock);
39
39
40
40
/* Find classifier type by string name */
41
41
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 )
43
43
{
44
44
const struct tcf_proto_ops * t , * res = NULL ;
45
45
@@ -57,6 +57,33 @@ static const struct tcf_proto_ops *tcf_proto_lookup_ops(const char *kind)
57
57
return res ;
58
58
}
59
59
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
+
60
87
/* Register(unregister) new classifier type */
61
88
62
89
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,
133
160
if (!tp )
134
161
return ERR_PTR (- ENOBUFS );
135
162
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 );
157
166
goto errout ;
158
167
}
159
168
tp -> classify = tp -> ops -> classify ;
0 commit comments