[mpls-linux-devel] MPLS Tunnel fixes and netlink links.
Status: Beta
Brought to you by:
jleu
From: Ramon C. <cas...@in...> - 2004-02-07 15:47:16
|
All, Although we keep them for the moment for practical reasons, the mpls_tunnel file no longer requires IOCTLs from the main mpls subsystem, (James: the issue we were having to make mpls_tunnel a true module). This was the last step to modularize mpls-tunnel. Nevertheless, as stated before, backwards compat. still prevents this. I have p4submitted the new approach, which is the following: * When loaded, the mpls-tunnel module obtains the netlink table for AF_MPLS. If it is not NULL, the module sets two new "netlink" links up, defining two new "doit" functions. When the tunnel is unloaded, the pointers are reset to NULL. Of course, this assumes that the mpls-tunnel depends on the main module having set up the netlink table (which is logical). We should find a programmatic way to enforce this (e.g. something like 'require_module(mpls-base)) + /* + * Setup netlink links + */ + MPLS_DEBUG("Checking rtnetlink_links\n"); + if (rtnetlink_links[PF_MPLS]) { + MPLS_DEBUG("Setting\n"); + rtnetlink_links[PF_MPLS][MPLS_RTM_TUNNEL_ADD].doit = + mpls_tunnel_add_doit; + rtnetlink_links[PF_MPLS][MPLS_RTM_TUNNEL_DEL].doit = + mpls_tunnel_del_doit; + rtnetlink_links[PF_MPLS][MPLS_RTM_TUNNEL_ADD].dumpit = NULL; + rtnetlink_links[PF_MPLS][MPLS_RTM_TUNNEL_DEL].dumpit = NULL; + } +/***************************************************************************** + NETLINK INTERFACE + *****************************************************************************/ +int +mpls_tunnel_add_doit (struct sk_buff *skb, struct nlmsghdr* msghdr, void *attr) +{ + struct sk_buff *new_skb; + int res; + int size = NLMSG_GOODSIZE; + MPLS_DEBUG("User requested to add a tunnel\n"); + new_skb = alloc_skb(size, GFP_KERNEL); + if (!new_skb) { + netlink_set_err(rtnl, 0, 0, ENOBUFS); + return -EINVAL; + } + NETLINK_CB(new_skb).dst_groups = 0; + res = netlink_unicast (rtnl, new_skb, msghdr->nlmsg_pid, MSG_DONTWAIT); + MPLS_DEBUG("%d\n",res); + return 0; +} Preliminary tests work fine. I will be cleaning up the userspace app, but it is useless until we define the MSG names, formats, return values, etc. (on paper first! :P) James: what else is on the 'must-fix' list? if our firsts tests work fine, we should ask netdev@ for a peer review. Have a nice w.e. R. ps: yeah, yeah... I know I said I would not be hacking for some days, but the main meeting has been postponed, and I'm having fun :P // ------------------------------------------------------------------- // Ramon Casellas - GET/ENST/INFRES/RHD/A508 - cas...@in... |