[NET_SCHED]: ematch: module autoloading
authorPatrick McHardy <kaber@trash.net>
Thu, 12 Jul 2007 02:46:26 +0000 (19:46 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 12 Jul 2007 02:46:26 +0000 (19:46 -0700)
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/pkt_cls.h
include/net/pkt_cls.h
net/sched/em_cmp.c
net/sched/em_meta.c
net/sched/em_nbyte.c
net/sched/em_text.c
net/sched/em_u32.c
net/sched/ematch.c

index c3f01b3085a410ac9334fd993d8ee4cd38ed339e..30b8571e6b34c25b2311291ad460e2d1754e7862 100644 (file)
@@ -403,16 +403,13 @@ enum
  *   1..32767          Reserved for ematches inside kernel tree
  *   32768..65535      Free to use, not reliable
  */
-enum
-{
-       TCF_EM_CONTAINER,
-       TCF_EM_CMP,
-       TCF_EM_NBYTE,
-       TCF_EM_U32,
-       TCF_EM_META,
-       TCF_EM_TEXT,
-       __TCF_EM_MAX
-};
+#define        TCF_EM_CONTAINER        0
+#define        TCF_EM_CMP              1
+#define        TCF_EM_NBYTE            2
+#define        TCF_EM_U32              3
+#define        TCF_EM_META             4
+#define        TCF_EM_TEXT             5
+#define        TCF_EM_MAX              5
 
 enum
 {
index 4129df7080797bb665bdd5213f2c1254cad33f47..6c29920cbe2954e8c4aa6eedce6180e17e5cf52a 100644 (file)
@@ -306,6 +306,8 @@ static inline int tcf_em_tree_match(struct sk_buff *skb,
                return 1;
 }
 
+#define MODULE_ALIAS_TCF_EMATCH(kind)  MODULE_ALIAS("ematch-kind-" __stringify(kind))
+
 #else /* CONFIG_NET_EMATCH */
 
 struct tcf_ematch_tree
index 8d6dacd8190054a9cc401d48342232644ad3e7a9..cc49c932641d97c66521c13b45fb4374792d8c4a 100644 (file)
@@ -98,3 +98,4 @@ MODULE_LICENSE("GPL");
 module_init(init_em_cmp);
 module_exit(exit_em_cmp);
 
+MODULE_ALIAS_TCF_EMATCH(TCF_EM_CMP);
index 60acf8cdb27b34774f71dfdf79654349bf26cc5a..650f09c8bd6a77b41f376f9213781547adb032c2 100644 (file)
@@ -848,3 +848,5 @@ MODULE_LICENSE("GPL");
 
 module_init(init_em_meta);
 module_exit(exit_em_meta);
+
+MODULE_ALIAS_TCF_EMATCH(TCF_EM_META);
index b4b36efce29248e37f1e2a941fa45743d76e4f52..370a1b2ea31770b4ce08196f146d43da12f31f4e 100644 (file)
@@ -76,3 +76,5 @@ MODULE_LICENSE("GPL");
 
 module_init(init_em_nbyte);
 module_exit(exit_em_nbyte);
+
+MODULE_ALIAS_TCF_EMATCH(TCF_EM_NBYTE);
index e8f46169449d8c5985cba6baed0096aa1610b2ab..d5cd86efb7d08fa8f3564f5edb89aee9557e5840 100644 (file)
@@ -150,3 +150,5 @@ MODULE_LICENSE("GPL");
 
 module_init(init_em_text);
 module_exit(exit_em_text);
+
+MODULE_ALIAS_TCF_EMATCH(TCF_EM_TEXT);
index 0a2a7fe08de3a9cce042c91865e2209d06ef16e6..112796e4a7c469d7147328ec54d507bd4e468c9f 100644 (file)
@@ -60,3 +60,5 @@ MODULE_LICENSE("GPL");
 
 module_init(init_em_u32);
 module_exit(exit_em_u32);
+
+MODULE_ALIAS_TCF_EMATCH(TCF_EM_U32);
index 24837391640d6e7da5c126579eca26e64894f514..f3a104e323bddd50c299c74c928a95038f1f5af5 100644 (file)
@@ -222,6 +222,19 @@ static int tcf_em_validate(struct tcf_proto *tp,
 
                if (em->ops == NULL) {
                        err = -ENOENT;
+#ifdef CONFIG_KMOD
+                       __rtnl_unlock();
+                       request_module("ematch-kind-%u", em_hdr->kind);
+                       rtnl_lock();
+                       em->ops = tcf_em_lookup(em_hdr->kind);
+                       if (em->ops) {
+                               /* We dropped the RTNL mutex in order to
+                                * perform the module load. Tell the caller
+                                * to replay the request. */
+                               module_put(em->ops->owner);
+                               err = -EAGAIN;
+                       }
+#endif
                        goto errout;
                }