kernel-netlink: Fallback to UDP if detecting socket protocol fails
authorMartin Willi <martin@revosec.ch>
Mon, 29 Sep 2014 15:11:53 +0000 (17:11 +0200)
committerMartin Willi <martin@revosec.ch>
Fri, 21 Nov 2014 09:55:45 +0000 (10:55 +0100)
getsockopt(SO_PROTOCOL) is not supported before 2.6.32. Default to UDP if
either the SO_PROTOCOL define is missing or the syscall fails.

src/libhydra/plugins/kernel_netlink/kernel_netlink_ipsec.c

index f0ada41..0f88b64 100644 (file)
@@ -2720,10 +2720,12 @@ static bool add_port_bypass(private_kernel_netlink_ipsec_t *this,
        {
                return FALSE;
        }
        {
                return FALSE;
        }
+#ifdef SO_PROTOCOL /* since 2.6.32 */
        len = sizeof(bypass.proto);
        if (getsockopt(fd, SOL_SOCKET, SO_PROTOCOL, &bypass.proto, &len) != 0)
        len = sizeof(bypass.proto);
        if (getsockopt(fd, SOL_SOCKET, SO_PROTOCOL, &bypass.proto, &len) != 0)
-       {
-               return FALSE;
+#endif
+       {       /* assume UDP if SO_PROTOCOL not supported */
+               bypass.proto = IPPROTO_UDP;
        }
        switch (family)
        {
        }
        switch (family)
        {