diff options
author | Justus Winter <justus@gnupg.org> | 2017-09-21 14:20:16 +0200 |
---|---|---|
committer | Justus Winter <justus@gnupg.org> | 2017-09-25 13:06:11 +0200 |
commit | 56957059d60d87e21d2369ffa9b017f9acc14458 (patch) | |
tree | 478f171f7fab006fe891d83caab5c87b62ac3c9f /eth-multiplexer | |
parent | e02b339f6f132774729d77d440ced82817ad1460 (diff) | |
download | hurd-56957059d60d87e21d2369ffa9b017f9acc14458.tar.gz hurd-56957059d60d87e21d2369ffa9b017f9acc14458.tar.bz2 hurd-56957059d60d87e21d2369ffa9b017f9acc14458.zip |
eth-multiplexer: Avoid copying data multiple times.
* eth-multiplexer/vdev.c (broadcast_pack): Construct message just once.
(deliver_pack): Remove function.
(deliver_msg): Make function static.
* eth-multiplexer/vdev.h (deliver_{msg,pack}): Remove declarations.
Diffstat (limited to 'eth-multiplexer')
-rw-r--r-- | eth-multiplexer/vdev.c | 35 | ||||
-rw-r--r-- | eth-multiplexer/vdev.h | 2 |
2 files changed, 15 insertions, 22 deletions
diff --git a/eth-multiplexer/vdev.c b/eth-multiplexer/vdev.c index 7d5390b2..367623d9 100644 --- a/eth-multiplexer/vdev.c +++ b/eth-multiplexer/vdev.c @@ -193,29 +193,13 @@ destroy_vdev (void *port) destroy_filters (&vdev->port_list); } +static int deliver_msg (struct net_rcv_msg *msg, struct vether_device *vdev); + /* Broadcast the packet to all virtual interfaces * except the one the packet is from */ int 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); - } - - return foreach_dev_do (internal_deliver_pack); -} - -/* Create a message, and deliver it. */ -int -deliver_pack (char *data, int datalen, struct vether_device *vdev) -{ struct net_rcv_msg msg; int pack_size; struct ethhdr *header; @@ -236,7 +220,18 @@ deliver_pack (char *data, int datalen, struct vether_device *vdev) packet->length = pack_size + sizeof (struct packet_header); msg.packet_type.msgt_number = packet->length; - return deliver_msg (&msg, 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_msg (&msg, vdev); + } + + return foreach_dev_do (internal_deliver_pack); } /* Broadcast the message to all virtual interfaces. */ @@ -265,7 +260,7 @@ broadcast_msg (struct net_rcv_msg *msg) * Deliver the message to all right pfinet servers that * connects to the virtual network interface. */ -int +static int deliver_msg(struct net_rcv_msg *msg, struct vether_device *vdev) { mach_msg_return_t err; diff --git a/eth-multiplexer/vdev.h b/eth-multiplexer/vdev.h index 85ecff52..8270fedf 100644 --- a/eth-multiplexer/vdev.h +++ b/eth-multiplexer/vdev.h @@ -67,8 +67,6 @@ struct vether_device *lookup_dev_by_name (char *name); int remove_dead_port_from_dev (mach_port_t dead_port); struct vether_device *add_vdev (char *name, size_t size); void destroy_vdev (void *port); -int deliver_msg (struct net_rcv_msg *msg, struct vether_device *vdev); -int deliver_pack (char *data, int datalen, struct vether_device *vdev); boolean_t all_dev_close (); int broadcast_pack (char *data, int datalen, struct vether_device *from_vdev); int broadcast_msg (struct net_rcv_msg *msg); |