>From 9408aa4f1896a89d9d354d7a0e0f75cbf0d2fc0f Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov <unlimitedscol...@gmail.com> Date: Tue, 4 Aug 2009 15:09:21 +0300 Subject: [PATCH] Handle the root node of eth-multiplexer correctly.
* eth-multiplexer/device_impl.c (ds_device_open): Check for the device port being MACH_PORT_NULL, too. Check if openstat flags are a subset of mode flags (not conversely). * eth-multiplexer/vdev.c (add_vdev): Copy name only if it is not NULL. --- This patch restores the support for static devnode translators in eth-multiplexer. It makes it possible to do the following: # settrans -a /dev/eth0 devnode eth0 # settrans -a veth eth-multiplexer -i /dev/eth0 # settrans -a foo devnode -M veth 0 # settrans -a /servers/socket/2 pfinet -i foo -a <address> -g <gateway> -m <mask> --- eth-multiplexer/device_impl.c | 7 ++++--- eth-multiplexer/vdev.c | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/eth-multiplexer/device_impl.c b/eth-multiplexer/device_impl.c index f9c8fc3..7ef09a5 100644 --- a/eth-multiplexer/device_impl.c +++ b/eth-multiplexer/device_impl.c @@ -94,7 +94,8 @@ ds_device_open (mach_port_t master_port, mach_port_t reply_port, /* If the virtual device hasn't been created yet, * create it now. */ - if (pi->po->np->nn->ln == NULL) + if (!pi->po->np->nn->ln + || (pi->po->np->nn->ln->vdev.dev_port == MACH_PORT_NULL)) { extern struct port_bucket *port_bucket; extern struct port_class *vdev_portclass; @@ -122,9 +123,9 @@ ds_device_open (mach_port_t master_port, mach_port_t reply_port, dev = (struct vether_device *) pi->po->np->nn->ln; /* check the mode */ openstat = pi->po->openstat; - if (mode & D_READ && !(openstat & O_READ)) + if ((openstat & O_READ) && !(mode & D_READ)) right_mode = 0; - if (mode & D_WRITE && !(openstat & O_WRITE)) + if ((openstat & O_WRITE) && !(mode & D_WRITE)) right_mode = 0; ports_port_deref (pi); diff --git a/eth-multiplexer/vdev.c b/eth-multiplexer/vdev.c index dac9802..6fb88d0 100644 --- a/eth-multiplexer/vdev.c +++ b/eth-multiplexer/vdev.c @@ -135,7 +135,10 @@ add_vdev (char *name, int size, vdev->dev_port = ports_get_right (vdev); ports_port_deref (vdev); - strncpy (vdev->name, name, IFNAMSIZ); + if (name) + strncpy (vdev->name, name, IFNAMSIZ); + else + vdev->name[0] = 0; vdev->if_header_size = ETH_HLEN; vdev->if_mtu = ETH_MTU; vdev->if_header_format = HDR_ETHERNET; -- 1.5.2.4