Displaying 3 results from an estimated 3 matches for "handle_incoming_vpn_packet".
2015 Dec 10
2
[PATCH] Receive multiple packets at a time
...t.c
+++ b/src/net_packet.c
@@ -695,31 +695,26 @@ static node_t *try_harder(const sockaddr_t *from, const vpn_packet_t *pkt) {
return n;
}
-void handle_incoming_vpn_data(int sock) {
- vpn_packet_t pkt;
+#ifdef HAVE_RECVMMSG
+#define MAX_MSG 256
+#else
+#define MAX_MSG 1
+#endif
+
+static void handle_incoming_vpn_packet(int sock, vpn_packet_t *pkt, sockaddr_t *from) {
char *hostname;
- sockaddr_t from;
- socklen_t fromlen = sizeof(from);
node_t *n;
- pkt.len = recvfrom(listen_socket[sock].udp, (char *) &pkt.seqno, MAXSIZE, 0, &from.sa, &fromlen);
-
- if(pkt.len < 0) {
- if(!sockwouldblock(soc...
2015 Dec 10
0
[PATCH] Receive multiple packets at a time
...eiving packet failed: %s", sockstrerror(sockerrno));
return;
}
for(i = 0; i < num; i++)
{
pkt[i].len = msg[i].msg_len;
if(pkt[i].len <= 0 || pkt[i].len > MAXSIZE)
continue;
handle_incoming_vpn_packet(sock, &pkt[i], &from[i]);
}
#else
vpn_packet_t pkt;
sockaddr_t from;
socklen_t fromlen = sizeof(from);
pkt.len = recvfrom(listen_socket[sock].udp, (char *) &pkt.seqno, MAXSIZE, 0, &from.sa, &fromlen);
if(pkt.len < 0)...
2015 Dec 02
5
[PATCH] Receive multiple packets at a time
Hello,
Linux has a recvmmsg() system call which allows to achieve several
recvfrom() at a time. The patch below makes tinc use it (patch against
1.1-pre11). Basically the patch turns the handle_incoming_vpn_data
variables into arrays (of size 1 when recvmmsg is not available, and
thus compiled the same as before), and makes the code index into the
arrays. You may want to use interdiff -w