X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Ffib%2Ffib_path.c;h=ef5d58c9e2b8512bf0f24b7c9987555f639de1aa;hb=cbe25aab3be72154f2c706c39eeba6a77f34450f;hp=eebba1b1548351b5b43927dd5cb0b3f659931674;hpb=097fa66b986f06281f603767d321ab13ab6c88c3;p=vpp.git diff --git a/src/vnet/fib/fib_path.c b/src/vnet/fib/fib_path.c index eebba1b1548..ef5d58c9e2b 100644 --- a/src/vnet/fib/fib_path.c +++ b/src/vnet/fib/fib_path.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -644,10 +645,16 @@ fib_path_last_lock_gone (fib_node_t *node) ASSERT(0); } -static const adj_index_t +static void fib_path_attached_next_hop_get_adj (fib_path_t *path, - vnet_link_t link) + vnet_link_t link, + dpo_id_t *dpo) { + fib_protocol_t nh_proto; + adj_index_t ai; + + nh_proto = dpo_proto_to_fib(path->fp_nh_proto); + if (vnet_sw_interface_is_p2p(vnet_get_main(), path->attached_next_hop.fp_interface)) { @@ -657,33 +664,32 @@ fib_path_attached_next_hop_get_adj (fib_path_t *path, * the subnet address (the attached route) links to the * auto-adj (see below), we want that adj here too. */ - return (adj_nbr_add_or_lock(dpo_proto_to_fib(path->fp_nh_proto), - link, - &zero_addr, - path->attached_next_hop.fp_interface)); + ai = adj_nbr_add_or_lock(nh_proto, link, &zero_addr, + path->attached_next_hop.fp_interface); } else { - return (adj_nbr_add_or_lock(dpo_proto_to_fib(path->fp_nh_proto), - link, - &path->attached_next_hop.fp_nh, - path->attached_next_hop.fp_interface)); + ai = adj_nbr_add_or_lock(nh_proto, link, + &path->attached_next_hop.fp_nh, + path->attached_next_hop.fp_interface); } + + dpo_set(dpo, DPO_ADJACENCY, vnet_link_to_dpo_proto(link), ai); + adj_unlock(ai); } static void fib_path_attached_next_hop_set (fib_path_t *path) { /* - * resolve directly via the adjacnecy discribed by the + * resolve directly via the adjacency discribed by the * interface and next-hop */ - dpo_set(&path->fp_dpo, - DPO_ADJACENCY, - path->fp_nh_proto, - fib_path_attached_next_hop_get_adj( - path, - dpo_proto_to_link(path->fp_nh_proto))); + fib_path_attached_next_hop_get_adj(path, + dpo_proto_to_link(path->fp_nh_proto), + &path->fp_dpo); + + ASSERT(dpo_is_adj(&path->fp_dpo)); /* * become a child of the adjacency so we receive updates @@ -701,10 +707,15 @@ fib_path_attached_next_hop_set (fib_path_t *path) } } -static const adj_index_t +static void fib_path_attached_get_adj (fib_path_t *path, - vnet_link_t link) + vnet_link_t link, + dpo_id_t *dpo) { + fib_protocol_t nh_proto; + + nh_proto = dpo_proto_to_fib(path->fp_nh_proto); + if (vnet_sw_interface_is_p2p(vnet_get_main(), path->attached.fp_interface)) { @@ -712,17 +723,28 @@ fib_path_attached_get_adj (fib_path_t *path, * point-2-point interfaces do not require a glean, since * there is nothing to ARP. Install a rewrite/nbr adj instead */ - return (adj_nbr_add_or_lock(dpo_proto_to_fib(path->fp_nh_proto), - link, - &zero_addr, - path->attached.fp_interface)); + adj_index_t ai; + + ai = adj_nbr_add_or_lock(nh_proto, link, &zero_addr, + path->attached.fp_interface); + + dpo_set(dpo, DPO_ADJACENCY, vnet_link_to_dpo_proto(link), ai); + adj_unlock(ai); + } + else if (vnet_sw_interface_is_nbma(vnet_get_main(), + path->attached.fp_interface)) + { + dpo_copy(dpo, drop_dpo_get(path->fp_nh_proto)); } else { - return (adj_glean_add_or_lock(dpo_proto_to_fib(path->fp_nh_proto), - link, - path->attached.fp_interface, - NULL)); + adj_index_t ai; + + ai = adj_glean_add_or_lock(nh_proto, link, + path->attached.fp_interface, + NULL); + dpo_set(dpo, DPO_ADJACENCY_GLEAN, vnet_link_to_dpo_proto(link), ai); + adj_unlock(ai); } } @@ -909,14 +931,10 @@ fib_path_unresolve (fib_path_t *path) bier_table_ecmp_unlock(path->fp_via_bier_tbl); break; case FIB_PATH_TYPE_ATTACHED_NEXT_HOP: - adj_child_remove(path->fp_dpo.dpoi_index, - path->fp_sibling); - adj_unlock(path->fp_dpo.dpoi_index); - break; case FIB_PATH_TYPE_ATTACHED: - adj_child_remove(path->fp_dpo.dpoi_index, - path->fp_sibling); - adj_unlock(path->fp_dpo.dpoi_index); + if (dpo_is_adj(&path->fp_dpo)) + adj_child_remove(path->fp_dpo.dpoi_index, + path->fp_sibling); break; case FIB_PATH_TYPE_UDP_ENCAP: udp_encap_unlock(path->fp_dpo.dpoi_index); @@ -1088,25 +1106,22 @@ FIXME comment * restack the DPO to pick up the correct DPO sub-type */ uword if_is_up; - adj_index_t ai; if_is_up = vnet_sw_interface_is_up( vnet_get_main(), path->attached_next_hop.fp_interface); - ai = fib_path_attached_next_hop_get_adj( - path, - dpo_proto_to_link(path->fp_nh_proto)); + fib_path_attached_next_hop_get_adj( + path, + dpo_proto_to_link(path->fp_nh_proto), + &path->fp_dpo); path->fp_oper_flags &= ~FIB_PATH_OPER_FLAG_RESOLVED; - if (if_is_up && adj_is_up(ai)) + if (if_is_up && adj_is_up(path->fp_dpo.dpoi_index)) { path->fp_oper_flags |= FIB_PATH_OPER_FLAG_RESOLVED; } - dpo_set(&path->fp_dpo, DPO_ADJACENCY, path->fp_nh_proto, ai); - adj_unlock(ai); - if (!if_is_up) { /* @@ -1233,6 +1248,8 @@ fib_path_route_flags_to_cfg_flags (const fib_route_path_t *rpath) { fib_path_cfg_flags_t cfg_flags = FIB_PATH_CFG_FLAG_NONE; + if (rpath->frp_flags & FIB_ROUTE_PATH_POP_PW_CW) + cfg_flags |= FIB_PATH_CFG_FLAG_POP_PW_CW; if (rpath->frp_flags & FIB_ROUTE_PATH_RESOLVE_VIA_HOST) cfg_flags |= FIB_PATH_CFG_FLAG_RESOLVE_HOST; if (rpath->frp_flags & FIB_ROUTE_PATH_RESOLVE_VIA_ATTACHED) @@ -1573,8 +1590,8 @@ fib_path_cmp_i (const fib_path_t *path1, path2->attached.fp_interface); break; case FIB_PATH_TYPE_RECURSIVE: - res = ip46_address_cmp(&path1->recursive.fp_nh, - &path2->recursive.fp_nh); + res = ip46_address_cmp(&path1->recursive.fp_nh.fp_ip, + &path2->recursive.fp_nh.fp_ip); if (0 == res) { @@ -1924,11 +1941,9 @@ fib_path_resolve (fib_node_index_t path_index) { path->fp_oper_flags &= ~FIB_PATH_OPER_FLAG_RESOLVED; } - dpo_set(&tmp, - DPO_ADJACENCY, - path->fp_nh_proto, - fib_path_attached_get_adj(path, - dpo_proto_to_link(path->fp_nh_proto))); + fib_path_attached_get_adj(path, + dpo_proto_to_link(path->fp_nh_proto), + &tmp); /* * re-fetch after possible mem realloc @@ -1940,9 +1955,12 @@ fib_path_resolve (fib_node_index_t path_index) * become a child of the adjacency so we receive updates * when the interface state changes */ - path->fp_sibling = adj_child_add(path->fp_dpo.dpoi_index, - FIB_NODE_TYPE_PATH, - fib_path_get_index(path)); + if (dpo_is_adj(&path->fp_dpo)) + { + path->fp_sibling = adj_child_add(path->fp_dpo.dpoi_index, + FIB_NODE_TYPE_PATH, + fib_path_get_index(path)); + } dpo_reset(&tmp); break; } @@ -2210,7 +2228,6 @@ fib_path_get_adj (fib_node_index_t path_index) path = fib_path_get(path_index); - ASSERT(dpo_is_adj(&path->fp_dpo)); if (dpo_is_adj(&path->fp_dpo)) { return (path->fp_dpo.dpoi_index); @@ -2381,6 +2398,16 @@ fib_path_stack_mpls_disp (fib_node_index_t path_index, case FIB_PATH_TYPE_DVR: break; } + + if (path->fp_cfg_flags & FIB_PATH_CFG_FLAG_POP_PW_CW) + { + dpo_id_t tmp = DPO_INVALID; + + dpo_copy(&tmp, dpo); + + pw_cw_dpo_create(&tmp, dpo); + dpo_reset(&tmp); + } } void @@ -2419,21 +2446,11 @@ fib_path_contribute_forwarding (fib_node_index_t path_index, case FIB_FORW_CHAIN_TYPE_NSH: case FIB_FORW_CHAIN_TYPE_MCAST_IP4: case FIB_FORW_CHAIN_TYPE_MCAST_IP6: - { - adj_index_t ai; - - /* - * get a appropriate link type adj. - */ - ai = fib_path_attached_next_hop_get_adj( + fib_path_attached_next_hop_get_adj( path, - fib_forw_chain_type_to_link_type(fct)); - dpo_set(dpo, DPO_ADJACENCY, - fib_forw_chain_type_to_dpo_proto(fct), ai); - adj_unlock(ai); - + fib_forw_chain_type_to_link_type(fct), + dpo); break; - } case FIB_FORW_CHAIN_TYPE_BIER: break; } @@ -2536,20 +2553,10 @@ fib_path_contribute_forwarding (fib_node_index_t path_index, case FIB_FORW_CHAIN_TYPE_ETHERNET: case FIB_FORW_CHAIN_TYPE_NSH: case FIB_FORW_CHAIN_TYPE_BIER: - { - adj_index_t ai; - - /* - * get a appropriate link type adj. - */ - ai = fib_path_attached_get_adj( - path, - fib_forw_chain_type_to_link_type(fct)); - dpo_set(dpo, DPO_ADJACENCY, - fib_forw_chain_type_to_dpo_proto(fct), ai); - adj_unlock(ai); - break; - } + fib_path_attached_get_adj(path, + fib_forw_chain_type_to_link_type(fct), + dpo); + break; case FIB_FORW_CHAIN_TYPE_MCAST_IP4: case FIB_FORW_CHAIN_TYPE_MCAST_IP6: { @@ -2558,9 +2565,24 @@ fib_path_contribute_forwarding (fib_node_index_t path_index, /* * Create the adj needed for sending IP multicast traffic */ - ai = adj_mcast_add_or_lock(dpo_proto_to_fib(path->fp_nh_proto), - fib_forw_chain_type_to_link_type(fct), - path->attached.fp_interface); + if (vnet_sw_interface_is_p2p(vnet_get_main(), + path->attached.fp_interface)) + { + /* + * point-2-point interfaces do not require a glean, since + * there is nothing to ARP. Install a rewrite/nbr adj instead + */ + ai = adj_nbr_add_or_lock(dpo_proto_to_fib(path->fp_nh_proto), + fib_forw_chain_type_to_link_type(fct), + &zero_addr, + path->attached.fp_interface); + } + else + { + ai = adj_mcast_add_or_lock(dpo_proto_to_fib(path->fp_nh_proto), + fib_forw_chain_type_to_link_type(fct), + path->attached.fp_interface); + } dpo_set(dpo, DPO_ADJACENCY, fib_forw_chain_type_to_dpo_proto(fct), ai);