Search code examples
socketslinux-kernelipv6network-protocolsipv4

Linux kernel IPv4 and IPv6 socket creation: EPROTONOSUPPORT and ESOCKTNOSUPPORT errors


I'm trying to understand IPv4 socket and IPv6 socket Linux kernel implementations.

Both methods inet_create() and inet6_create() looks very similar. They both can return to user space EPROTONOSUPPORT or ESOCKTNOSUPPORT, I wonder on which circumstances this can happen.


Solution

  • ESOCKTNOSUPPORT means that the socket type is not supported for the chosen protocol. For instance, you can't create a SOCK_SEQPACKET with IPPROTO_IP. According to the ip(7) man page, only SOCK_STREAM, SOCK_DGRAM and SOCK_RAW are valid socket types for ip.

    EPROTONOSUPPORT means that the socket protocol chosen is not supported. For instance, if you ask for AF_INET6 and the system administrator has disabled IPv6 by blacklisting the module.