如何在Linux中使用c-api查找VRF设备的路由表ID

时间:2018-09-13 11:52:25

标签: c linux routing

我想找到VRF设备和路由表ID之间的关联。

VRF设备'vrf-blue'是已知的,但是结构rtmsg需要表ID'10'。 rtnetlink

# ip link add vrf-blue type vrf table 10

struct rtmsg {
    unsigned char       rtm_family;
    unsigned char       rtm_dst_len;
    unsigned char       rtm_src_len;
    unsigned char       rtm_tos;
    unsigned char       rtm_table;  /* Routing table id */
    unsigned char       rtm_protocol;   /* Routing protocol; see below  */
    unsigned char       rtm_scope;  /* See below */ 
    unsigned char       rtm_type;   /* See below    */
    unsigned        rtm_flags;
};

1 个答案:

答案 0 :(得分:1)

使用详细的输出选项:

ip -d link show type vrf

示例输出:

14: vrf5: <NOARP,MASTER> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 5a:32:3b:9f:e9:ef brd ff:ff:ff:ff:ff:ff promiscuity 0
    vrf table 327 addrgenmode eui64    <----------------table id is 327
15: vrf6: <NOARP,MASTER> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 76:8f:8f:dc:13:8f brd ff:ff:ff:ff:ff:ff promiscuity 0
    vrf table 328 addrgenmode eui64