diff options
-rw-r--r-- | eth-multiplexer/device_impl.c | 3 | ||||
-rw-r--r-- | eth-multiplexer/vdev.c | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/eth-multiplexer/device_impl.c b/eth-multiplexer/device_impl.c index 18ebf07e..f23738a1 100644 --- a/eth-multiplexer/device_impl.c +++ b/eth-multiplexer/device_impl.c @@ -108,6 +108,9 @@ ds_device_write (struct vether_device *vdev, mach_port_t reply_port, if (vdev == NULL) return D_NO_SUCH_DEVICE; + if ((vdev->if_flags & IFF_UP) == 0) + return D_DEVICE_DOWN; + /* The packet is forwarded to all virtual interfaces and * the interface which the multiplexer connects to. */ broadcast_pack (data, datalen, vdev); diff --git a/eth-multiplexer/vdev.c b/eth-multiplexer/vdev.c index 47dc8d2d..9a1f7b2e 100644 --- a/eth-multiplexer/vdev.c +++ b/eth-multiplexer/vdev.c @@ -145,7 +145,12 @@ add_vdev (char *name, int size, vdev->if_mtu = ETH_MTU; vdev->if_header_format = HDR_ETHERNET; vdev->if_address_size = ETH_ALEN; - vdev->if_flags = 0; + vdev->if_flags = (/* The interface is 'UP' on creation. */ + IFF_UP + /* We have allocated resources for it. */ + | IFF_RUNNING + /* Advertise ethernet-style capabilities. */ + | IFF_BROADCAST | IFF_MULTICAST); /* Compute a pseudo-random but stable ethernet address. */ vdev->if_address[0] = 0x52; @@ -203,8 +208,12 @@ broadcast_pack (char *data, int datalen, struct vether_device *from_vdev) { int internal_deliver_pack (struct vether_device *vdev) { + /* Skip current interface. */ if (from_vdev == vdev) return 0; + /* Skip interfaces that are down. */ + if ((vdev->if_flags & IFF_UP) == 0) + return 0; return deliver_pack (data, datalen, vdev); } @@ -247,6 +256,9 @@ broadcast_msg (struct net_rcv_msg *msg) int internal_deliver_msg (struct vether_device *vdev) { + /* Skip interfaces that are down. */ + if ((vdev->if_flags & IFF_UP) == 0) + return 0; return deliver_msg (msg, vdev); } |