aboutsummaryrefslogtreecommitdiff
path: root/src/vpn
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-08-22 14:50:04 +0000
committerChristian Grothoff <christian@grothoff.org>2016-08-22 14:50:04 +0000
commit6ee9d185c22d09d0e7e9da44522b33b03c5fa30b (patch)
tree898c1d392c3a8b871117570a1590aa6edea1bcd4 /src/vpn
parent7b0c53a6b28bb3cedd44cb5dd396329f62aeab90 (diff)
downloadgnunet-6ee9d185c22d09d0e7e9da44522b33b03c5fa30b.tar.gz
gnunet-6ee9d185c22d09d0e7e9da44522b33b03c5fa30b.zip
fix exit CADET port binding for services, remove redundant service/port descriptor transmission from packets
Diffstat (limited to 'src/vpn')
-rw-r--r--src/vpn/gnunet-service-vpn.c64
1 files changed, 37 insertions, 27 deletions
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c
index 785bf7be1..52b1e764e 100644
--- a/src/vpn/gnunet-service-vpn.c
+++ b/src/vpn/gnunet-service-vpn.c
@@ -192,7 +192,7 @@ struct ChannelMessageQueueEntry
192 struct ChannelMessageQueueEntry *prev; 192 struct ChannelMessageQueueEntry *prev;
193 193
194 /** 194 /**
195 * Number of bytes in 'msg'. 195 * Number of bytes in @e msg.
196 */ 196 */
197 size_t len; 197 size_t len;
198 198
@@ -396,7 +396,7 @@ static unsigned long long max_channel_mappings;
396 396
397/** 397/**
398 * Compute the key under which we would store an entry in the 398 * Compute the key under which we would store an entry in the
399 * destination_map for the given IP address. 399 * #destination_map for the given IP address.
400 * 400 *
401 * @param af address family (AF_INET or AF_INET6) 401 * @param af address family (AF_INET or AF_INET6)
402 * @param address IP address, struct in_addr or struct in6_addr 402 * @param address IP address, struct in_addr or struct in6_addr
@@ -518,7 +518,9 @@ send_client_reply (struct GNUNET_SERVER_Client *client,
518 res->header.type = htons (GNUNET_MESSAGE_TYPE_VPN_CLIENT_USE_IP); 518 res->header.type = htons (GNUNET_MESSAGE_TYPE_VPN_CLIENT_USE_IP);
519 res->result_af = htonl (result_af); 519 res->result_af = htonl (result_af);
520 res->request_id = request_id; 520 res->request_id = request_id;
521 GNUNET_memcpy (&res[1], addr, rlen); 521 GNUNET_memcpy (&res[1],
522 addr,
523 rlen);
522 GNUNET_SERVER_notification_context_add (nc, client); 524 GNUNET_SERVER_notification_context_add (nc, client);
523 GNUNET_SERVER_notification_context_unicast (nc, 525 GNUNET_SERVER_notification_context_unicast (nc,
524 client, 526 client,
@@ -795,11 +797,12 @@ create_channel_to_destination (struct DestinationChannel *dt,
795 ts->destination.heap_node = NULL; /* copy is NOT in destination heap */ 797 ts->destination.heap_node = NULL; /* copy is NOT in destination heap */
796 if (dt->destination->is_service) 798 if (dt->destination->is_service)
797 { 799 {
798 ts->channel = GNUNET_CADET_channel_create (cadet_handle, 800 ts->channel
799 ts, 801 = GNUNET_CADET_channel_create (cadet_handle,
800 &dt->destination->details.service_destination.target, 802 ts,
801 &ts->destination.details.service_destination.service_descriptor, 803 &dt->destination->details.service_destination.target,
802 GNUNET_CADET_OPTION_DEFAULT); 804 &ts->destination.details.service_destination.service_descriptor,
805 GNUNET_CADET_OPTION_DEFAULT);
803 if (NULL == ts->channel) 806 if (NULL == ts->channel)
804 { 807 {
805 GNUNET_break (0); 808 GNUNET_break (0);
@@ -810,7 +813,7 @@ create_channel_to_destination (struct DestinationChannel *dt,
810 "Creating channel %p to peer %s offering service %s\n", 813 "Creating channel %p to peer %s offering service %s\n",
811 ts->channel, 814 ts->channel,
812 GNUNET_i2s (&dt->destination->details.service_destination.target), 815 GNUNET_i2s (&dt->destination->details.service_destination.target),
813 GNUNET_h2s (&dt->destination->details.service_destination.service_descriptor)); 816 GNUNET_h2s (&ts->destination.details.service_destination.service_descriptor));
814 } 817 }
815 else 818 else
816 { 819 {
@@ -1169,7 +1172,6 @@ route_packet (struct DestinationEntry *destination,
1169 meaning; if not, we pick a random port (this is a heuristic) */ 1172 meaning; if not, we pick a random port (this is a heuristic) */
1170 usm->source_port = (ntohs (udp->source_port) < 32000) ? udp->source_port : 0; 1173 usm->source_port = (ntohs (udp->source_port) < 32000) ? udp->source_port : 0;
1171 usm->destination_port = udp->destination_port; 1174 usm->destination_port = udp->destination_port;
1172 usm->service_descriptor = destination->details.service_destination.service_descriptor;
1173 GNUNET_memcpy (&usm[1], 1175 GNUNET_memcpy (&usm[1],
1174 &udp[1], 1176 &udp[1],
1175 payload_length - sizeof (struct GNUNET_TUN_UdpHeader)); 1177 payload_length - sizeof (struct GNUNET_TUN_UdpHeader));
@@ -1238,7 +1240,6 @@ route_packet (struct DestinationEntry *destination,
1238 tsm->header.size = htons ((uint16_t) mlen); 1240 tsm->header.size = htons ((uint16_t) mlen);
1239 tsm->header.type = htons (GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START); 1241 tsm->header.type = htons (GNUNET_MESSAGE_TYPE_VPN_TCP_TO_SERVICE_START);
1240 tsm->reserved = htonl (0); 1242 tsm->reserved = htonl (0);
1241 tsm->service_descriptor = destination->details.service_destination.service_descriptor;
1242 tsm->tcp_header = *tcp; 1243 tsm->tcp_header = *tcp;
1243 GNUNET_memcpy (&tsm[1], 1244 GNUNET_memcpy (&tsm[1],
1244 &tcp[1], 1245 &tcp[1],
@@ -1328,7 +1329,6 @@ route_packet (struct DestinationEntry *destination,
1328 ism = (struct GNUNET_EXIT_IcmpServiceMessage *) &tnq[1]; 1329 ism = (struct GNUNET_EXIT_IcmpServiceMessage *) &tnq[1];
1329 ism->header.type = htons (GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_SERVICE); 1330 ism->header.type = htons (GNUNET_MESSAGE_TYPE_VPN_ICMP_TO_SERVICE);
1330 ism->af = htonl (af); /* need to tell destination ICMP protocol family! */ 1331 ism->af = htonl (af); /* need to tell destination ICMP protocol family! */
1331 ism->service_descriptor = destination->details.service_destination.service_descriptor;
1332 ism->icmp_header = *icmp; 1332 ism->icmp_header = *icmp;
1333 /* ICMP protocol translation will be done by the receiver (as we don't know 1333 /* ICMP protocol translation will be done by the receiver (as we don't know
1334 the target AF); however, we still need to possibly discard the payload 1334 the target AF); however, we still need to possibly discard the payload
@@ -2743,11 +2743,14 @@ service_redirect_to_service (void *cls,
2743 2743
2744 /* allocate response IP */ 2744 /* allocate response IP */
2745 result_af = (int) htonl (msg->result_af); 2745 result_af = (int) htonl (msg->result_af);
2746 if (GNUNET_OK != allocate_response_ip (&result_af, 2746 if (GNUNET_OK !=
2747 &addr, 2747 allocate_response_ip (&result_af,
2748 &v4, &v6)) 2748 &addr,
2749 &v4,
2750 &v6))
2749 { 2751 {
2750 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 2752 GNUNET_SERVER_receive_done (client,
2753 GNUNET_SYSERR);
2751 return; 2754 return;
2752 } 2755 }
2753 send_client_reply (client, 2756 send_client_reply (client,
@@ -2779,8 +2782,8 @@ service_redirect_to_service (void *cls,
2779 /* setup destination record */ 2782 /* setup destination record */
2780 de = GNUNET_new (struct DestinationEntry); 2783 de = GNUNET_new (struct DestinationEntry);
2781 de->is_service = GNUNET_YES; 2784 de->is_service = GNUNET_YES;
2782 de->details.service_destination.service_descriptor = msg->service_descriptor;
2783 de->details.service_destination.target = msg->target; 2785 de->details.service_destination.target = msg->target;
2786 de->details.service_destination.service_descriptor = msg->service_descriptor;
2784 get_destination_key_from_ip (result_af, 2787 get_destination_key_from_ip (result_af,
2785 addr, 2788 addr,
2786 &key); 2789 &key);
@@ -2790,9 +2793,10 @@ service_redirect_to_service (void *cls,
2790 &key, 2793 &key,
2791 de, 2794 de,
2792 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); 2795 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
2793 de->heap_node = GNUNET_CONTAINER_heap_insert (destination_heap, 2796 de->heap_node
2794 de, 2797 = GNUNET_CONTAINER_heap_insert (destination_heap,
2795 GNUNET_TIME_absolute_ntoh (msg->expiration_time).abs_value_us); 2798 de,
2799 GNUNET_TIME_absolute_ntoh (msg->expiration_time).abs_value_us);
2796 while (GNUNET_CONTAINER_multihashmap_size (destination_map) > max_destination_mappings) 2800 while (GNUNET_CONTAINER_multihashmap_size (destination_map) > max_destination_mappings)
2797 expire_destination (de); 2801 expire_destination (de);
2798 2802
@@ -2802,7 +2806,8 @@ service_redirect_to_service (void *cls,
2802 de->dt_tail, 2806 de->dt_tail,
2803 dt); 2807 dt);
2804 /* we're done */ 2808 /* we're done */
2805 GNUNET_SERVER_receive_done (client, GNUNET_OK); 2809 GNUNET_SERVER_receive_done (client,
2810 GNUNET_OK);
2806} 2811}
2807 2812
2808 2813
@@ -2993,11 +2998,15 @@ run (void *cls,
2993 cfg = cfg_; 2998 cfg = cfg_;
2994 stats = GNUNET_STATISTICS_create ("vpn", cfg); 2999 stats = GNUNET_STATISTICS_create ("vpn", cfg);
2995 if (GNUNET_OK != 3000 if (GNUNET_OK !=
2996 GNUNET_CONFIGURATION_get_value_number (cfg, "VPN", "MAX_MAPPING", 3001 GNUNET_CONFIGURATION_get_value_number (cfg,
3002 "VPN",
3003 "MAX_MAPPING",
2997 &max_destination_mappings)) 3004 &max_destination_mappings))
2998 max_destination_mappings = 200; 3005 max_destination_mappings = 200;
2999 if (GNUNET_OK != 3006 if (GNUNET_OK !=
3000 GNUNET_CONFIGURATION_get_value_number (cfg, "VPN", "MAX_TUNNELS", 3007 GNUNET_CONFIGURATION_get_value_number (cfg,
3008 "VPN",
3009 "MAX_TUNNELS",
3001 &max_channel_mappings)) 3010 &max_channel_mappings))
3002 max_channel_mappings = 200; 3011 max_channel_mappings = 200;
3003 3012
@@ -3099,10 +3108,11 @@ run (void *cls,
3099 } 3108 }
3100 vpn_argv[6] = NULL; 3109 vpn_argv[6] = NULL;
3101 3110
3102 cadet_handle = 3111 cadet_handle
3103 GNUNET_CADET_connect (cfg_, NULL, 3112 = GNUNET_CADET_connect (cfg_,
3104 &channel_cleaner, 3113 NULL,
3105 cadet_handlers); 3114 &channel_cleaner,
3115 cadet_handlers);
3106 // FIXME never opens ports??? 3116 // FIXME never opens ports???
3107 helper_handle = GNUNET_HELPER_start (GNUNET_NO, 3117 helper_handle = GNUNET_HELPER_start (GNUNET_NO,
3108 "gnunet-helper-vpn", vpn_argv, 3118 "gnunet-helper-vpn", vpn_argv,