On Wed, 7 Sep 2016, Martin Husemann wrote:

On Wed, Sep 07, 2016 at 01:50:07PM +0800, Paul Goyette wrote:
I can see a couple of ways to "fix" this:

        1. Rename the module (with all appropriate updates to the
           sets lists in src/distrib/sets/lists), or
        2. Add code to spec_vnops.c to try loading module if_xxx if the
           autoload of module xxx fails.

Add a static list of name exceptions? There probably are few.

OK, perhaps something like the attached diffs?

I'm building now....


+------------------+--------------------------+------------------------+
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:      |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
+------------------+--------------------------+------------------------+
Index: spec_vnops.c
===================================================================
RCS file: /cvsroot/src/sys/miscfs/specfs/spec_vnops.c,v
retrieving revision 1.163
diff -u -p -r1.163 spec_vnops.c
--- spec_vnops.c        20 Aug 2016 12:37:09 -0000      1.163
+++ spec_vnops.c        7 Sep 2016 10:15:08 -0000
@@ -482,6 +482,16 @@ spec_lookup(void *v)
 
 typedef int (*spec_ioctl_t)(dev_t, u_long, void *, int, struct lwp *);
 
+struct dev_to_mod {
+       const char *dev_name, *mod_name;
+};
+
+struct dev_to_mod dev_mod_table[] = {
+       { "tap", "if_tap" },
+       { "tun", "if_tun" },
+       { NULL, NULL }
+};
+       
 /*
  * Open a special file.
  */
@@ -555,6 +565,7 @@ spec_open(void *v)
                VOP_UNLOCK(vp);
                do {
                        const struct cdevsw *cdev;
+                       struct dev_to_mod *conv;
 
                        gen = module_gen;
                        error = cdev_open(dev, ap->a_mode, S_IFCHR, l);
@@ -571,6 +582,15 @@ spec_open(void *v)
                        /* Get device name from devsw_conv array */
                        if ((name = cdevsw_getname(major(dev))) == NULL)
                                break;
+
+                       /* Check exception table for alternate module name */
+                       conv = &dev_to_mod[0];
+                       while (conv->dev_name != NULL) {
+                               if (strcmp(conv->dev_name, name) == 0) {
+                                       name = conv->mod_name;
+                                       break;
+                               conv++;
+                       }
                        
                        /* Try to autoload device module */
                        (void) module_autoload(name, MODULE_CLASS_DRIVER);

Reply via email to