diff options
Diffstat (limited to 'zebra/rt_netlink.c')
| -rw-r--r-- | zebra/rt_netlink.c | 91 |
1 files changed, 11 insertions, 80 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 0cc2e0217f..e8333ef0cf 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -23,6 +23,10 @@ #ifdef HAVE_NETLINK #include <net/if_arp.h> +#include <linux/lwtunnel.h> +#include <linux/mpls_iptunnel.h> +#include <linux/neighbour.h> +#include <linux/rtnetlink.h> /* Hack for GNU libc version 2. */ #ifndef MSG_TRUNC @@ -61,65 +65,10 @@ #include "zebra/zebra_mroute.h" #include "zebra/zebra_vxlan.h" - -/* TODO - Temporary definitions, need to refine. */ #ifndef AF_MPLS #define AF_MPLS 28 #endif -#ifndef RTA_VIA -#define RTA_VIA 18 -#endif - -#ifndef RTA_NEWDST -#define RTA_NEWDST 19 -#endif - -#ifndef RTA_ENCAP_TYPE -#define RTA_ENCAP_TYPE 21 -#endif - -#ifndef RTA_ENCAP -#define RTA_ENCAP 22 -#endif - -#ifndef RTA_EXPIRES -#define RTA_EXPIRES 23 -#endif - -#ifndef LWTUNNEL_ENCAP_MPLS -#define LWTUNNEL_ENCAP_MPLS 1 -#endif - -#ifndef MPLS_IPTUNNEL_DST -#define MPLS_IPTUNNEL_DST 1 -#endif - -#ifndef NDA_MASTER -#define NDA_MASTER 9 -#endif - -#ifndef NTF_MASTER -#define NTF_MASTER 0x04 -#endif - -#ifndef NTF_SELF -#define NTF_SELF 0x02 -#endif - -#ifndef NTF_EXT_LEARNED -#define NTF_EXT_LEARNED 0x10 -#endif - -#ifndef NDA_IFINDEX -#define NDA_IFINDEX 8 -#endif - -#ifndef NDA_VLAN -#define NDA_VLAN 5 -#endif -/* End of temporary definitions */ - static vlanid_t filter_vlan = 0; struct gw_family_t { @@ -2370,7 +2319,6 @@ int netlink_mpls_multipath(int cmd, zebra_lsp_t *lsp) memset(&req, 0, sizeof req - NL_PKT_BUF_SIZE); - /* * Count # nexthops so we can decide whether to use singlepath * or multipath case. @@ -2394,11 +2342,9 @@ int netlink_mpls_multipath(int cmd, zebra_lsp_t *lsp) } } - if (nexthop_num == 0 || !lsp->best_nhlfe) // unexpected + if ((nexthop_num == 0) || (!lsp->best_nhlfe && (cmd != RTM_DELROUTE))) return 0; - route_type = re_type_from_lsp_type(lsp->best_nhlfe->type); - req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); req.n.nlmsg_flags = NLM_F_CREATE | NLM_F_REQUEST; req.n.nlmsg_type = cmd; @@ -2407,14 +2353,18 @@ int netlink_mpls_multipath(int cmd, zebra_lsp_t *lsp) req.r.rtm_family = AF_MPLS; req.r.rtm_table = RT_TABLE_MAIN; req.r.rtm_dst_len = MPLS_LABEL_LEN_BITS; - req.r.rtm_protocol = zebra2proto(route_type); req.r.rtm_scope = RT_SCOPE_UNIVERSE; req.r.rtm_type = RTN_UNICAST; - if (cmd == RTM_NEWROUTE) + if (cmd == RTM_NEWROUTE) { /* We do a replace to handle update. */ req.n.nlmsg_flags |= NLM_F_REPLACE; + /* set the protocol value if installing */ + route_type = re_type_from_lsp_type(lsp->best_nhlfe->type); + req.r.rtm_protocol = zebra2proto(route_type); + } + /* Fill destination */ lse = mpls_lse_encode(lsp->ile.in_label, 0, 0, 1); addattr_l(&req.n, sizeof req, RTA_DST, &lse, sizeof(mpls_lse_t)); @@ -2524,23 +2474,4 @@ int netlink_mpls_multipath(int cmd, zebra_lsp_t *lsp) return netlink_talk(netlink_talk_filter, &req.n, &zns->netlink_cmd, zns, 0); } - -/* - * Handle failure in LSP install, clear flags for NHLFE. - */ -void clear_nhlfe_installed(zebra_lsp_t *lsp) -{ - zebra_nhlfe_t *nhlfe; - struct nexthop *nexthop; - - for (nhlfe = lsp->nhlfe_list; nhlfe; nhlfe = nhlfe->next) { - nexthop = nhlfe->nexthop; - if (!nexthop) - continue; - - UNSET_FLAG(nhlfe->flags, NHLFE_FLAG_INSTALLED); - UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB); - } -} - #endif /* HAVE_NETLINK */ |
