Reputation: 405
Latest Linux Kernel 4.1.4 have MPLS data path support, We can program MPLS Routing table in kernel through NETLINK Socket. A new address family is defined AF_MPLS in socket.h.
I tried some code to write -
req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
req.n.nlmsg_flags = NLM_F_REQUEST|NLM_F_CREATE;
req.n.nlmsg_type = RTM_NEWROUTE;
req.r.rtm_family = AF_MPLS;
req.r.rtm_table = RT_TABLE_MAIN;
req.r.rtm_protocol = RTPROT_BOOT;
req.r.rtm_scope = RT_SCOPE_UNIVERSE;
req.r.rtm_type = RTN_UNICAST;
However I am not able to figure out how to add MPLS Label in Netlink attribute.
Please help me out.
Upvotes: 2
Views: 828
Reputation: 849
According to net/mpls/af_mpls.c:rtm_to_route_config()
, the label should be provided with RTA_DST
NLA.
Pls notice also assertions in the function, they're quite strict.
Upvotes: 4