Kernel TLS

Jeffrey Walton noloader at gmail.com
Fri Nov 29 14:36:10 EST 2019


Hi Everyone,

I'm trying to run through the example at
https://www.kernel.org/doc/html/latest/networking/tls.html#kernel-tls
.

I'm working on Fedora 31 x86_64 (fully patched). Running my program results in:

    $ ./ktls
    setsockopt failed, 2, No such file or directory

I observed:

    $ cat /proc/sys/net/ipv4/tcp_available_ulp
    $

Is there a way to enable ULP at boot? Or is this a kernel config
option? Or maybe I am doing something else wrong?

Below is the sample code.

Jeff

==============================

#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>

#include <sys/socket.h>
#include <sys/types.h>

#include <linux/tls.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>

int main()
{
    int sock = socket(AF_INET, SOCK_STREAM, 0);
    if (sock == -1)
    {
        printf("socket failed, %d, %s\n", errno, strerror(errno));
        return 1;
    }

    if (setsockopt(sock, SOL_TCP, TCP_ULP, "tls", sizeof("tls")) == -1 )
    {
        printf("setsockopt failed, %d, %s\n", errno, strerror(errno));
        return 1;
    }

    close (sock);
    return 0;
}



More information about the Kernelnewbies mailing list