From 31a24b656050878af31122b085a345cfe35e742b Mon Sep 17 00:00:00 2001 From: Hongjun Ni Date: Tue, 7 Aug 2018 23:40:48 +0800 Subject: Remove FIB_1.0 support and fix FIB_2.0 issue Change-Id: I90e593993851a364b728034c13e8e69852b558c4 Signed-off-by: Hongjun Ni --- netlink/librtnl/mapper.c | 32 ------------------------------ router/Makefile.am | 13 +++++++++---- router/router/tap_inject.c | 36 ---------------------------------- router/router/tap_inject.h | 1 - router/router/tap_inject_netlink.c | 40 +++----------------------------------- 5 files changed, 12 insertions(+), 110 deletions(-) diff --git a/netlink/librtnl/mapper.c b/netlink/librtnl/mapper.c index 05b7f1d..207013c 100644 --- a/netlink/librtnl/mapper.c +++ b/netlink/librtnl/mapper.c @@ -18,13 +18,7 @@ #include #include - -#ifdef ip6_add_del_route_next_hop -#define FIB_VERSION 1 -#else #include -#define FIB_VERSION 2 -#endif typedef struct { int linux_ifindex; @@ -70,18 +64,6 @@ int mapper_add_del_route(mapper_ns_t *ns, ns_route_t *route, int del) if (route->rtm.rtm_dst_len >= 8 && route->dst[0] == 0xff) return 0; -#if FIB_VERSION == 1 - struct ip6_main_t *im = &ip6_main; - ip6_add_del_route_next_hop(im, //ip6_main - del?IP6_ROUTE_FLAG_DEL:IP6_ROUTE_FLAG_ADD, //flags (not del) - (ip6_address_t *)&route->dst[0], //Dst addr - route->rtm.rtm_dst_len, //Plen - (ip6_address_t *)&route->gateway[0], //next-hop - map->sw_if_index, //sw_if_index - 0, //weight - ~0, //adj_index - ns->v6fib_index); -#else fib_prefix_t prefix; ip46_address_t nh; @@ -99,20 +81,7 @@ int mapper_add_del_route(mapper_ns_t *ns, ns_route_t *route, int del) 0 /* weight */, (fib_mpls_label_t *) MPLS_LABEL_INVALID, FIB_ROUTE_PATH_FLAG_NONE); -#endif /* FIB_VERSION == 1 */ } else { -#if FIB_VERSION == 1 - struct ip4_main_t *im = &ip4_main; - ip4_add_del_route_next_hop(im, //ip4_main - del?IP4_ROUTE_FLAG_DEL:IP4_ROUTE_FLAG_ADD, //flags (not del) - (ip4_address_t *)&route->dst[0], //Dst addr - route->rtm.rtm_dst_len, //Plen - (ip4_address_t *)&route->gateway[0], //next-hop - map->sw_if_index, //sw_if_index - 0, //weight - ~0, //adj_index - ns->v4fib_index); -#else fib_prefix_t prefix; ip46_address_t nh; @@ -130,7 +99,6 @@ int mapper_add_del_route(mapper_ns_t *ns, ns_route_t *route, int del) 0 /* weight */, (fib_mpls_label_t *) MPLS_LABEL_INVALID, FIB_ROUTE_PATH_FLAG_NONE); -#endif /* FIB_VERSION == 1 */ } return 0; diff --git a/router/Makefile.am b/router/Makefile.am index b9de6a1..a4387dd 100644 --- a/router/Makefile.am +++ b/router/Makefile.am @@ -3,10 +3,15 @@ AUTOMAKE_OPTIONS = foreign subdir-objects AM_CFLAGS = -Wall -I@TOOLKIT_INCLUDE@ lib_LTLIBRARIES = router.la -router_la_SOURCES = router/tap_inject.c \ - router/tap_inject_netlink.c \ - router/tap_inject_node.c \ - router/tap_inject_tap.c +router_la_SOURCES = \ + router/tap_inject.c \ + router/tap_inject_netlink.c \ + router/tap_inject_node.c \ + router/tap_inject_tap.c + +nobase_include_HEADERS = \ + router/tap_inject.h + router_la_LDFLAGS = -module router_la_LIBADD = -lrtnl diff --git a/router/router/tap_inject.c b/router/router/tap_inject.c index e8d3f98..f41ae86 100644 --- a/router/router/tap_inject.c +++ b/router/router/tap_inject.c @@ -19,12 +19,7 @@ #include #include #include -#ifdef ip6_add_del_route_next_hop -#define FIB_VERSION 1 -#else #include -#define FIB_VERSION 2 -#endif static tap_inject_main_t tap_inject_main; extern dpo_type_t tap_inject_dpo_type; @@ -146,36 +141,6 @@ tap_inject_enable (void) ip6_register_protocol (IP_PROTOCOL_TCP, im->tx_node_index); ip6_register_protocol (IP_PROTOCOL_UDP, im->tx_node_index); -#if FIB_VERSION == 1 - /* Add IPv4 multicast route. */ - { - ip4_add_del_route_args_t a; - ip_adjacency_t add_adj; - u32 next_node_index; - - memset (&a, 0, sizeof (a)); - memset (&add_adj, 0, sizeof (add_adj)); - - a.add_adj = &add_adj; - a.n_add_adj = 1; - - a.flags = IP4_ROUTE_FLAG_TABLE_ID | IP4_ROUTE_FLAG_ADD; - a.table_index_or_table_id = 0; - a.dst_address.as_u32 = 0x000000E0; /* 224.0.0.0 */ - a.dst_address_length = 24; - a.adj_index = ~0; - - next_node_index = vlib_node_add_next (vm, ip4_lookup_node.index, - im->tx_node_index); - - add_adj.explicit_fib_index = ~0; - add_adj.rewrite_header.node_index = ip4_rewrite_node.index; - add_adj.lookup_next_index = next_node_index; - add_adj.if_address_index = ~0; - - ip4_add_del_route (&ip4_main, &a); - } -#else { dpo_id_t dpo = DPO_INVALID; @@ -203,7 +168,6 @@ tap_inject_enable (void) dpo_reset(&dpo); } -#endif /* FIB_VERSION == 1 */ im->flags |= TAP_INJECT_F_ENABLED; diff --git a/router/router/tap_inject.h b/router/router/tap_inject.h index 001ab52..ec5121a 100644 --- a/router/router/tap_inject.h +++ b/router/router/tap_inject.h @@ -20,7 +20,6 @@ #include #include - #ifndef ETHER_ADDR_LEN #define ETHER_ADDR_LEN 6 #endif diff --git a/router/router/tap_inject_netlink.c b/router/router/tap_inject_netlink.c index 3dca013..bd5da49 100644 --- a/router/router/tap_inject_netlink.c +++ b/router/router/tap_inject_netlink.c @@ -14,25 +14,18 @@ * limitations under the License. */ -#include "tap_inject.h" #include #include -#include #include - -#include #include -#ifdef ip6_add_del_route_next_hop -#define FIB_VERSION 1 -#else #include -#define FIB_VERSION 2 -#endif - +#include #include #include #include +#include "tap_inject.h" + static void add_del_addr (ns_addr_t * a, int is_del) { @@ -124,37 +117,24 @@ add_del_neigh (ns_neigh_t * n, int is_del) if (n->nd.ndm_state & NUD_REACHABLE) { -#if FIB_VERSION == 1 - vnet_arp_set_ip4_over_ethernet (vnet_main, sw_if_index, ~0, &a, 0); -#else vnet_arp_set_ip4_over_ethernet (vnet_main, sw_if_index, &a, 0 /* static */ , 0 /* no fib entry */); -#endif /* FIB_VERSION == 1 */ } else if (n->nd.ndm_state & NUD_FAILED) { -#if FIB_VERSION == 1 - vnet_arp_unset_ip4_over_ethernet (vnet_main, sw_if_index, ~0, &a); -#else vnet_arp_unset_ip4_over_ethernet (vnet_main, sw_if_index, &a); -#endif /* FIB_VERSION == 1 */ } } else if (n->nd.ndm_family == AF_INET6) { if (n->nd.ndm_state & NUD_REACHABLE) { -#if FIB_VERSION == 1 - vnet_set_ip6_ethernet_neighbor (vm, sw_if_index, - (ip6_address_t *) n->dst, n->lladdr, ETHER_ADDR_LEN, 0); -#else vnet_set_ip6_ethernet_neighbor (vm, sw_if_index, (ip6_address_t *) n->dst, n->lladdr, ETHER_ADDR_LEN, 0 /* static */, 0 /* no fib entry */); -#endif /* FIB_VERSION == 1 */ } else vnet_unset_ip6_ethernet_neighbor (vm, sw_if_index, @@ -194,12 +174,6 @@ add_del_route (ns_route_t * r, int is_del) { u32 stack[MPLS_STACK_DEPTH] = {0}; -#if FIB_VERSION == 1 - ip4_add_del_route_next_hop (&ip4_main, - is_del ? IP4_ROUTE_FLAG_DEL : IP4_ROUTE_FLAG_ADD, - (ip4_address_t *) r->dst, r->rtm.rtm_dst_len, - (ip4_address_t *) r->gateway, sw_if_index, 0, ~0, 0); -#else fib_prefix_t prefix; ip46_address_t nh; @@ -234,16 +208,9 @@ add_del_route (ns_route_t * r, int is_del) FIB_ENTRY_FLAG_NONE, rpaths); } -#endif /* FIB_VERSION == 1 */ } else if (r->rtm.rtm_family == AF_INET6) { -#if FIB_VERSION == 1 - ip6_add_del_route_next_hop (&ip6_main, - is_del ? IP6_ROUTE_FLAG_DEL : IP6_ROUTE_FLAG_ADD, - (ip6_address_t *) r->dst, r->rtm.rtm_dst_len, - (ip6_address_t *) r->gateway, sw_if_index, 0, ~0, 0); -#else fib_prefix_t prefix; ip46_address_t nh; memset (&prefix, 0, sizeof (prefix)); @@ -257,7 +224,6 @@ add_del_route (ns_route_t * r, int is_del) &nh, sw_if_index, 0, 0 /* weight */, NULL, FIB_ROUTE_PATH_FLAG_NONE); -#endif /* FIB_VERSION == 1 */ } else if (r->rtm.rtm_family == AF_MPLS) { -- cgit 1.2.3-korg