bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The patch of boot to open a virtual network interface


From: zhengda
Subject: Re: The patch of boot to open a virtual network interface
Date: Tue, 19 Aug 2008 17:00:01 +0200
User-agent: Thunderbird 2.0.0.16 (X11/20080707)

Neal H. Walfield wrote:
At Tue, 19 Aug 2008 15:48:11 +0200,
zhengda wrote:
2008-07-29 Zheng Da <zhengda1936@gmail.com>

        * boot/boot.c (ds_device_open): Handle the request to open the virtual 
network device.

diff -u boot.old/boot.c boot/boot.c
--- boot.old/boot.c     2008-08-17 18:38:02.000000000 +0200
+++ boot/boot.c 2008-08-17 18:36:40.520000000 +0200
@@ -964,6 +964,22 @@
       *devicetype = MACH_MSG_TYPE_MAKE_SEND;
       return 0;
     }
+  else if (strncmp (name, "veth", 4) == 0)
+    {
+      char buf[128];
+      mach_port_t net_device;
+
+      snprintf (buf, sizeof(buf), "/dev/%s", name);
+      net_device = file_name_lookup (buf, 0, 0);
+      if (net_device == MACH_PORT_NULL)
+       {
+         error (0, errno, "file_name_lookup");
+         return errno;
+       }
+
+      *devicetype = MACH_MSG_TYPE_MOVE_SEND;
+      return device_open (net_device, mode, "eth", device);
+    }
*devicetype = MACH_MSG_TYPE_MOVE_SEND;
   return device_open (master_device_port, mode, name, device);

I don't like this approach.  This allows the subhurd to access any
object in the parent hurd that boot can access.  Boot should take an
option indicating which device to use for the network interface and
only make that node available.  Moreover, you should not assume that
it is in /dev: a normal use could implement a proxy translator that
implements the network interface.
If the device file isn't in /dev, how does boot or other components such as pfinet find the device file and open it? For example, the '-i' option of pfinet specifies a device name. If the device file is in /dev, this option still works. Otherwise, we have to tell pfinet the whole path of the device file. I think it's a little weird.

Zheng Da




reply via email to

[Prev in Thread] Current Thread [Next in Thread]