[hipl-commit] [trunk] Rev 3941: "hipconf nat local port <portno>" works again.

  • From: Miika Komu <miika@xxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Sun, 14 Mar 2010 16:05:30 +0200

Committer: Miika Komu <miika@xxxxxx>
Date: Sun Mar 14 16:05:28 2010 +0200
Revision: 3941
Revision-id: miika@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  "hipconf nat local port <portno>" works again.

Modified:
  M  hipd/init.c
  M  hipd/user.c

=== modified file 'hipd/init.c'
--- hipd/init.c 2010-03-11 12:43:03 +0000
+++ hipd/init.c 2010-03-14 14:05:28 +0000
@@ -552,14 +552,12 @@
 
     HIP_IFEL(hip_init_raw_sock_v6(&hip_raw_sock_output_v6, IPPROTO_HIP), -1, 
"raw sock output v6\n");
     HIP_IFEL(hip_init_raw_sock_v4(&hip_raw_sock_output_v4, IPPROTO_HIP), -1, 
"raw sock output v4\n");
-    // Notice that hip_nat_sock_input should be initialized after 
hip_nat_sock_output
-    // because for the sockets bound to the same address/port, only the last 
socket seems
-    // to receive the packets.
-#if 0
-    HIP_IFEL(hip_create_nat_sock_udp(&hip_nat_sock_output_udp, 0), -1, "raw 
sock output udp\n");
-#else
+    /* hip_nat_sock_input should be initialized after hip_nat_sock_output
+       because for the sockets bound to the same address/port, only the last 
socket seems
+       to receive the packets. NAT input socket is a normal UDP socket where as
+       NAT output socket is a raw socket. A raw output socket support better 
the "shotgun"
+       extension (sending packets from multiple source addresses). */
     HIP_IFEL(hip_init_raw_sock_v4(&hip_nat_sock_output_udp, IPPROTO_UDP), -1, 
"raw sock output udp\n");
-#endif
     HIP_IFEL(hip_init_raw_sock_v6(&hip_raw_sock_input_v6, IPPROTO_HIP), -1, 
"raw sock input v6\n");
     HIP_IFEL(hip_init_raw_sock_v4(&hip_raw_sock_input_v4, IPPROTO_HIP), -1, 
"raw sock input v4\n");
     HIP_IFEL(hip_create_nat_sock_udp(&hip_nat_sock_input_udp, 0, 0), -1, "raw 
sock input udp\n");

=== modified file 'hipd/user.c'
--- hipd/user.c 2010-03-11 11:12:11 +0000
+++ hipd/user.c 2010-03-14 14:05:28 +0000
@@ -1099,12 +1099,10 @@
         if (nat_port) {
             HIP_DEBUG("Setting local NAT port\n");
             hip_set_local_nat_udp_port(nat_port->port);
-            // We need to recreate the NAT UDP sockets to bind to the new port.
-            close(hip_nat_sock_output_udp);
+            /* We need to recreate only the input socket to bind to the new
+               port. Output port must be left intact as it is a raw socket */
             close(hip_nat_sock_input_udp);
-            hip_nat_sock_output_udp = 0;
             hip_nat_sock_input_udp  = 0;
-            hip_create_nat_sock_udp(&hip_nat_sock_output_udp, 0, 1);
             hip_create_nat_sock_udp(&hip_nat_sock_input_udp, 0, 0);
         } else {
             HIP_DEBUG("Setting peer NAT port\n");

Other related posts:

  • » [hipl-commit] [trunk] Rev 3941: "hipconf nat local port <portno>" works again. - Miika Komu