RTM消息

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)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值