[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 28/43: eth-multiplexer: Allow setting of flags.
From: |
Samuel Thibault |
Subject: |
[hurd] 28/43: eth-multiplexer: Allow setting of flags. |
Date: |
Mon, 11 Sep 2017 07:10:11 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit ae61f83839ea072533fca15dc75284799e5e0445
Author: Justus Winter <address@hidden>
Date: Tue Aug 22 15:05:27 2017 +0200
eth-multiplexer: Allow setting of flags.
* eth-multiplexer/dev_stat.c (wants_all_multi_p): New function.
(vdev_setstat): Likewise.
* eth-multiplexer/device_impl.c (ds_device_set_status): Use new
function.
* eth-multiplexer/vdev.h (vdev_setstat): New declaration.
---
eth-multiplexer/dev_stat.c | 106 ++++++++++++++++++++++++++++++++++++++++++
eth-multiplexer/device_impl.c | 2 +-
eth-multiplexer/vdev.h | 2 +
3 files changed, 109 insertions(+), 1 deletion(-)
diff --git a/eth-multiplexer/dev_stat.c b/eth-multiplexer/dev_stat.c
index d15a7d5..3fc61db 100644
--- a/eth-multiplexer/dev_stat.c
+++ b/eth-multiplexer/dev_stat.c
@@ -41,6 +41,7 @@
#include <mach.h>
#include "vdev.h"
+#include "ethernet.h"
io_return_t
dev_getstat(struct vether_device *ifp, dev_flavor_t flavor,
@@ -104,3 +105,108 @@ dev_getstat(struct vether_device *ifp, dev_flavor_t
flavor,
}
return (D_SUCCESS);
}
+
+static
+int wants_all_multi_p (struct vether_device *v)
+{
+ return !! (v->if_flags & IFF_ALLMULTI);
+}
+
+io_return_t
+vdev_setstat (struct vether_device *ifp, dev_flavor_t flavor,
+ dev_status_t status, size_t count)
+{
+ error_t err = 0;
+ short flags;
+ short delta;
+
+ switch (flavor) {
+ case NET_STATUS:
+ {
+ struct net_status *ns = (struct net_status *) status;
+
+ if (count != NET_STATUS_COUNT)
+ return D_INVALID_SIZE;
+
+ /* We allow only the flags to change. */
+ if (ns->min_packet_size != ifp->if_header_size
+ || ns->max_packet_size != ifp->if_header_size + ifp->if_mtu
+ || ns->header_format != ifp->if_header_format
+ || ns->header_size != ifp->if_header_size
+ || ns->address_size != ifp->if_address_size
+ || ns->mapped_size != 0)
+ return D_INVALID_OPERATION;
+
+ flags = ns->flags;
+ goto change_flags;
+ }
+
+ case NET_FLAGS:
+ if (count != 1)
+ return D_INVALID_SIZE;
+ flags = status[0];
+
+ change_flags:
+ /* What needs to change? */
+ delta = flags ^ ifp->if_flags;
+
+ /* Only allow specific flag changes. */
+ if ((delta
+ /* AIUI IFF_RUNNING shouldn't be toggle-able, but we let this slip. */
+ & ~(IFF_UP | IFF_RUNNING | IFF_DEBUG | IFF_PROMISC | IFF_ALLMULTI))
+ != 0)
+ return D_INVALID_OPERATION;
+
+
+ if (! err && (delta & IFF_PROMISC))
+ {
+ /* The ethernet device is always in promiscuous mode, and we
+ forward all packets. If this flag is cleared for a virtual
+ device, we should filter traffic based on observed MAC
+ addresses from this interface. */
+ /* XXX: Implement this. */
+ }
+
+ if (! err && (delta & IFF_ALLMULTI))
+ {
+ /* We activate IFF_ALLMULTI if at least one virtual device
+ wants it, and deactivate it otherwise. */
+ if ((flags & IFF_ALLMULTI)
+ || foreach_dev_do (wants_all_multi_p))
+ err = eth_set_clear_flags (IFF_ALLMULTI, 0);
+ else
+ err = eth_set_clear_flags (0, IFF_ALLMULTI);
+ }
+
+ if (! err)
+ ifp->if_flags = flags;
+ break;
+
+ case NET_ADDRESS:
+ {
+ int addr_byte_count;
+ int addr_int_count;
+ int i;
+
+ addr_byte_count = ifp->if_address_size;
+ addr_int_count = (addr_byte_count + (sizeof(int)-1)) / sizeof(int);
+
+ if (count != addr_int_count)
+ return D_INVALID_SIZE;
+
+ memcpy(ifp->if_address, status, addr_byte_count);
+ for (i = 0; i < addr_int_count; i++) {
+ int word;
+
+ word = status[i];
+ status[i] = htonl(word);
+ }
+ break;
+ }
+
+ default:
+ return D_INVALID_OPERATION;
+ }
+
+ return err;
+}
diff --git a/eth-multiplexer/device_impl.c b/eth-multiplexer/device_impl.c
index 085a27e..18ebf07 100644
--- a/eth-multiplexer/device_impl.c
+++ b/eth-multiplexer/device_impl.c
@@ -169,7 +169,7 @@ ds_device_set_status (struct vether_device *vdev,
dev_flavor_t flavor,
{
if (vdev == NULL)
return D_NO_SUCH_DEVICE;
- return D_INVALID_OPERATION;
+ return vdev_setstat (vdev, flavor, status, statuslen);
}
kern_return_t
diff --git a/eth-multiplexer/vdev.h b/eth-multiplexer/vdev.h
index c98c441..3c3c320 100644
--- a/eth-multiplexer/vdev.h
+++ b/eth-multiplexer/vdev.h
@@ -79,6 +79,8 @@ int foreach_dev_do (dev_act_func func);
/* dev_stat.c */
io_return_t dev_getstat (struct vether_device *, dev_flavor_t,
dev_status_t, natural_t *);
+io_return_t vdev_setstat (struct vether_device *, dev_flavor_t,
+ dev_status_t, size_t);
#endif
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 38/43: trans/mtab: Fix warnings., (continued)
- [hurd] 38/43: trans/mtab: Fix warnings., Samuel Thibault, 2017/09/11
- [hurd] 41/43: exec: Avoid calling mmap with zero size, Samuel Thibault, 2017/09/11
- [hurd] 24/43: eth-multiplexer: Fix error handling., Samuel Thibault, 2017/09/11
- [hurd] 12/43: Fix typo., Samuel Thibault, 2017/09/11
- [hurd] 21/43: startup: Fix retrieving the privileged ports., Samuel Thibault, 2017/09/11
- [hurd] 25/43: eth-multiplexer: Implement getting the devices flags., Samuel Thibault, 2017/09/11
- [hurd] 20/43: ext2fs: Fix warning., Samuel Thibault, 2017/09/11
- [hurd] 18/43: Make build system more robust., Samuel Thibault, 2017/09/11
- [hurd] 14/43: procfs: Provide 'hostinfo'., Samuel Thibault, 2017/09/11
- [hurd] 23/43: startup: Improve error handling., Samuel Thibault, 2017/09/11
- [hurd] 28/43: eth-multiplexer: Allow setting of flags.,
Samuel Thibault <=
- [hurd] 33/43: libdiskfs: Use control class for the singleton 'bootinfo'., Samuel Thibault, 2017/09/11
- [hurd] 31/43: ext2fs: Improve inlining., Samuel Thibault, 2017/09/11
- [hurd] 08/43: trans/fakeroot: Obey O_NOFOLLOW., Samuel Thibault, 2017/09/11
- [hurd] 35/43: libnetfs: Remove redundant type checks., Samuel Thibault, 2017/09/11
- [hurd] 26/43: eth-multiplexer: Remove local definiton., Samuel Thibault, 2017/09/11
- [hurd] 34/43: libdiskfs: Simplify type checks., Samuel Thibault, 2017/09/11
- [hurd] 16/43: Simplify deallocations., Samuel Thibault, 2017/09/11
- [hurd] 29/43: eth-multiplexer: Respect interfaces up flags., Samuel Thibault, 2017/09/11
- [hurd] 36/43: startup: Don't spin on host_reboot failures., Samuel Thibault, 2017/09/11
- [hurd] 30/43: Drop the register qualifier., Samuel Thibault, 2017/09/11