diff options
author | Justus Winter <justus@gnupg.org> | 2017-08-22 19:38:25 +0200 |
---|---|---|
committer | Justus Winter <justus@gnupg.org> | 2017-08-23 19:01:14 +0200 |
commit | 61d5aee1ce02888e78eab4ed85a9c8e631006d7b (patch) | |
tree | a0a7368c0bba2e3c5543e438c95e2657f4f2c5ec /eth-multiplexer | |
parent | ae61f83839ea072533fca15dc75284799e5e0445 (diff) | |
download | hurd-61d5aee1ce02888e78eab4ed85a9c8e631006d7b.tar.gz hurd-61d5aee1ce02888e78eab4ed85a9c8e631006d7b.tar.bz2 hurd-61d5aee1ce02888e78eab4ed85a9c8e631006d7b.zip |
eth-multiplexer: Respect interfaces up flags.
* eth-multiplexer/device_impl.c (ds_device_write): Deny writes when
interface is down.
* eth-multiplexer/vdev.c (add_vdev): Initialize flags to
a sane value.
(broadcast_pack): Skip interfaces that are down.
(broadcast_msg): Likewise.
Diffstat (limited to 'eth-multiplexer')
-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); } |