3.1.2. Link Message Types
RTM_GETLINK (user→kernel)
Lookup link by 1. interface index or 2. link name (IFLA_IFNAME) and return a single RTM_NEWLINK message containing the link configuration and statistics or a netlink error message if no such link was found.
Parameters:
Address family
If the address family is set to PF_BRIDGE, only bridging devices will be returned.
If the address family is set to PF_INET6, only ipv6 enabled devices will be returned.
Flags:
NLM_F_DUMP If set, all links will be returned in form of a multipart message.
Returns:
EINVAL if neither interface nor link name are set
ENODEV if no link was found
ENOBUFS if allocation failed
RTM_NEWLINK (user→kernel)
Creates a new or updates an existing link. Only virtual links may be created but all links may be updated.
Flags:
NLM_F_CREATE Create link if it does not exist
NLM_F_EXCL Return EEXIST if link already exists
Returns:
EINVAL malformed message or invalid configuration parameters
EAFNOSUPPORT if a address family specific configuration (IFLA_AF_SPEC) is not supported.
EOPNOTSUPP if the link does not support modification of parameters
EEXIST if NLM_F_EXCL was set and the link exists alraedy
ENODEV if the link does not exist and NLM_F_CREATE is not set
RTM_NEWLINK (kernel→user)
This message type is used in reply to a RTM_GETLINK request and carries the configuration and statistics of a link. If multiple links need to be sent, the messages will be sent in form of a multipart message.
The message type is also used for notifications sent by the kernel to the multicast group RTNLGRP_LINK to inform about various link events. It is therefore recommended to always use a separate link socket for link notifications in order to separate between the two message types.
TODO: document how to detect different notifications
RTM_DELLINK (user→kernel)
Lookup link by 1. interface index or 2. link name (IFLA_IFNAME) and delete the virtual link.
Returns:
EINVAL if neither interface nor link name are set
ENODEV if no link was found
ENOTSUPP if the operation is not supported (not a virtual link)
RTM_DELLINK (kernel→user)
Notification sent by the kernel to the multicast group RTNLGRP_LINK when
a network device was unregistered (change == ~0)
a bridging device was deleted (address family will be PF_BRIDGE)