Skip to content
Advertisement

register protocol handler for a transport protocol in Linux kernel

I’m trying to implement the QUIC protocol in the Linux kernel. Since QUIC is working on top of UDP, I’ve been using the UDP code as a learning base. Now I want to register the protocol handler for the QUIC protocol but I don’t understand how and where to do it as I can’t find the relevant code piece in the UDP source file. I’ve searched on the internet but all the examples talk about registering the handler for IPv4 and I don’t find a similar implementation in UDP (or TCP). Can someone point me to how the UDP protocol handler is registered? That’ll help me in doing the same thing with QUIC.

Advertisement

Answer

UDP protocol is registered in inet_init() function (in net/ipv4/af_inet.c file):

if (inet_add_protocol(&udp_protocol, IPPROTO_UDP) < 0)
    pr_crit("%s: Cannot add UDP protocoln", __func__);

And UDP protocol handler is .handler field in udp_protocol structure:

static const struct net_protocol udp_protocol = {
    .early_demux =  udp_v4_early_demux,
    .handler =      udp_rcv,
    .err_handler =  udp_err,
    .no_policy =    1,
    .netns_ok =     1,
};
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement