Enable UDP decapsulation for both address families
authorTobias Brunner <tobias@strongswan.org>
Thu, 16 Aug 2012 13:26:37 +0000 (15:26 +0200)
committerTobias Brunner <tobias@strongswan.org>
Thu, 16 Aug 2012 13:26:37 +0000 (15:26 +0200)
Since the 3.5 Linux kernel both UDP implementations have a separate static
flag to indicate whether ANY sockets enabled UDP decapsulation.
As we only ever enabled it for one address family (in earlier versions IPv4
only, now for IPv6, if supported, and for IPv4 otherwise) UDP decapsulation
wouldn't work anymore (at least for one address family).

src/libcharon/plugins/socket_default/socket_default_socket.c
src/libcharon/plugins/socket_raw/socket_raw_socket.c

index c2b0734..8ab5a8c 100644 (file)
@@ -534,6 +534,15 @@ static int open_socket(private_socket_default_socket_t *this,
        {
                DBG1(DBG_NET, "installing IKE bypass policy failed");
        }
+
+       /* enable UDP decapsulation for NAT-T sockets */
+       if (port == &this->natt &&
+               !hydra->kernel_interface->enable_udp_decap(hydra->kernel_interface,
+                                                                                                  skt, family, this->natt))
+       {
+               DBG1(DBG_NET, "enabling UDP decapsulation failed");
+       }
+
        return skt;
 }
 
@@ -630,13 +639,6 @@ socket_default_socket_t *socket_default_socket_create()
                return NULL;
        }
 
-       /* enable UDP decapsulation globally, only for one socket needed */
-       if (!hydra->kernel_interface->enable_udp_decap(hydra->kernel_interface,
-                                                       this->ipv6_natt ?: this->ipv4_natt,
-                                                       this->ipv6_natt ? AF_INET6 : AF_INET, this->natt))
-       {
-               DBG1(DBG_NET, "enabling UDP decapsulation failed");
-       }
        return &this->public;
 }
 
index 1b3c9e1..e6d1e4d 100644 (file)
@@ -459,8 +459,8 @@ static int open_send_socket(private_socket_raw_socket_t *this,
                DBG1(DBG_NET, "installing bypass policy on send socket failed");
        }
 
-       /* enable UDP decapsulation globally, only for one socket needed */
-       if (family == AF_INET && port == CHARON_NATT_PORT &&
+       /* enable UDP decapsulation for NAT-T sockets */
+       if (port == CHARON_NATT_PORT &&
                !hydra->kernel_interface->enable_udp_decap(hydra->kernel_interface,
                                                                                                   skt, family, port))
        {