diff options
Diffstat (limited to 'src/vnet/fib')
-rw-r--r-- | src/vnet/fib/fib_api.h | 1 | ||||
-rw-r--r-- | src/vnet/fib/fib_path.c | 10 | ||||
-rw-r--r-- | src/vnet/fib/fib_path.h | 11 | ||||
-rw-r--r-- | src/vnet/fib/fib_test.c | 43 | ||||
-rw-r--r-- | src/vnet/fib/fib_types.h | 4 |
5 files changed, 61 insertions, 8 deletions
diff --git a/src/vnet/fib/fib_api.h b/src/vnet/fib/fib_api.h index c369e8f8588..e5b94e14124 100644 --- a/src/vnet/fib/fib_api.h +++ b/src/vnet/fib/fib_api.h @@ -41,6 +41,7 @@ add_del_route_t_handler (u8 is_multipath, u8 is_interface_rx, u8 is_rpf_id, u8 is_l2_bridged, + u8 is_source_lookup, u32 fib_index, const fib_prefix_t * prefix, dpo_proto_t next_hop_proto, diff --git a/src/vnet/fib/fib_path.c b/src/vnet/fib/fib_path.c index 889d17def9c..7b713a4b5c5 100644 --- a/src/vnet/fib/fib_path.c +++ b/src/vnet/fib/fib_path.c @@ -1054,6 +1054,8 @@ fib_path_route_flags_to_cfg_flags (const fib_route_path_t *rpath) cfg_flags |= FIB_PATH_CFG_FLAG_EXCLUSIVE; if (rpath->frp_flags & FIB_ROUTE_PATH_DROP) cfg_flags |= FIB_PATH_CFG_FLAG_DROP; + if (rpath->frp_flags & FIB_ROUTE_PATH_SOURCE_LOOKUP) + cfg_flags |= FIB_PATH_CFG_FLAG_DEAG_SRC; return (cfg_flags); } @@ -1695,16 +1697,20 @@ fib_path_resolve (fib_node_index_t path_index) * Resolve via a lookup DPO. * FIXME. control plane should add routes with a table ID */ + lookup_input_t input; lookup_cast_t cast; - + cast = (path->fp_cfg_flags & FIB_PATH_CFG_FLAG_RPF_ID ? LOOKUP_MULTICAST : LOOKUP_UNICAST); + input = (path->fp_cfg_flags & FIB_PATH_CFG_FLAG_DEAG_SRC ? + LOOKUP_INPUT_SRC_ADDR : + LOOKUP_INPUT_DST_ADDR); lookup_dpo_add_or_lock_w_fib_index(path->deag.fp_tbl_id, path->fp_nh_proto, cast, - LOOKUP_INPUT_DST_ADDR, + input, LOOKUP_TABLE_FROM_CONFIG, &path->fp_dpo); break; diff --git a/src/vnet/fib/fib_path.h b/src/vnet/fib/fib_path.h index f986e437a3b..3a0544c1c42 100644 --- a/src/vnet/fib/fib_path.h +++ b/src/vnet/fib/fib_path.h @@ -79,14 +79,13 @@ typedef enum fib_path_cfg_attribute_t_ { */ FIB_PATH_CFG_ATTRIBUTE_LOCAL, /** - * The path is L2. i.e. the parameters therein are to be interpreted as - * pertaining to L2 config. + * The deag path does a source lookup */ - FIB_PATH_CFG_ATTRIBUTE_L2, + FIB_PATH_CFG_ATTRIBUTE_DEAG_SRC, /** * Marker. Add new types before this one, then update it. */ - FIB_PATH_CFG_ATTRIBUTE_LAST = FIB_PATH_CFG_ATTRIBUTE_LOCAL, + FIB_PATH_CFG_ATTRIBUTE_LAST = FIB_PATH_CFG_ATTRIBUTE_DEAG_SRC, } __attribute__ ((packed)) fib_path_cfg_attribute_t; /** @@ -103,7 +102,7 @@ typedef enum fib_path_cfg_attribute_t_ { [FIB_PATH_CFG_ATTRIBUTE_ATTACHED] = "attached", \ [FIB_PATH_CFG_ATTRIBUTE_INTF_RX] = "interface-rx", \ [FIB_PATH_CFG_ATTRIBUTE_RPF_ID] = "rpf-id", \ - [FIB_PATH_CFG_ATTRIBUTE_L2] = "l2", \ + [FIB_PATH_CFG_ATTRIBUTE_DEAG_SRC] = "deag-src", \ } #define FOR_EACH_FIB_PATH_CFG_ATTRIBUTE(_item) \ @@ -124,7 +123,7 @@ typedef enum fib_path_cfg_flags_t_ { FIB_PATH_CFG_FLAG_ATTACHED = (1 << FIB_PATH_CFG_ATTRIBUTE_ATTACHED), FIB_PATH_CFG_FLAG_INTF_RX = (1 << FIB_PATH_CFG_ATTRIBUTE_INTF_RX), FIB_PATH_CFG_FLAG_RPF_ID = (1 << FIB_PATH_CFG_ATTRIBUTE_RPF_ID), - FIB_PATH_CFG_FLAG_L2 = (1 << FIB_PATH_CFG_ATTRIBUTE_L2), + FIB_PATH_CFG_FLAG_DEAG_SRC = (1 << FIB_PATH_CFG_ATTRIBUTE_DEAG_SRC), } __attribute__ ((packed)) fib_path_cfg_flags_t; diff --git a/src/vnet/fib/fib_test.c b/src/vnet/fib/fib_test.c index 03c9ee75f48..da517b0ceea 100644 --- a/src/vnet/fib/fib_test.c +++ b/src/vnet/fib/fib_test.c @@ -3543,6 +3543,49 @@ fib_test_v4 (void) "4.4.4.4/32 is deag in %d %U", lkd->lkd_fib_index, format_dpo_id, dpo, 0); + FIB_TEST((LOOKUP_INPUT_DST_ADDR == lkd->lkd_input), + "4.4.4.4/32 is source deag in %d %U", + lkd->lkd_input, + format_dpo_id, dpo, 0); + + fib_table_entry_delete(fib_index, + &pfx_4_4_4_4_s_32, + FIB_SOURCE_API); + FIB_TEST(FIB_NODE_INDEX_INVALID == + fib_table_lookup_exact_match(fib_index, &pfx_4_4_4_4_s_32), + "4.4.4.4/32 removed"); + vec_free(r_paths); + + /* + * A route deag route in a source lookup table + */ + fib_table_entry_path_add(fib_index, + &pfx_4_4_4_4_s_32, + FIB_SOURCE_API, + FIB_ENTRY_FLAG_NONE, + DPO_PROTO_IP4, + &zero_addr, + ~0, + fib_index, + 1, + NULL, + FIB_ROUTE_PATH_SOURCE_LOOKUP); + + fei = fib_table_lookup_exact_match(fib_index, &pfx_4_4_4_4_s_32); + FIB_TEST((FIB_NODE_INDEX_INVALID != fei), "4.4.4.4/32 present"); + + dpo = fib_entry_contribute_ip_forwarding(fei); + dpo = load_balance_get_bucket(dpo->dpoi_index, 0); + lkd = lookup_dpo_get(dpo->dpoi_index); + + FIB_TEST((fib_index == lkd->lkd_fib_index), + "4.4.4.4/32 is deag in %d %U", + lkd->lkd_fib_index, + format_dpo_id, dpo, 0); + FIB_TEST((LOOKUP_INPUT_SRC_ADDR == lkd->lkd_input), + "4.4.4.4/32 is source deag in %d %U", + lkd->lkd_input, + format_dpo_id, dpo, 0); fib_table_entry_delete(fib_index, &pfx_4_4_4_4_s_32, diff --git a/src/vnet/fib/fib_types.h b/src/vnet/fib/fib_types.h index b5d4ec95911..7eadbb9bb70 100644 --- a/src/vnet/fib/fib_types.h +++ b/src/vnet/fib/fib_types.h @@ -303,6 +303,10 @@ typedef enum fib_route_path_flags_t_ * A local path with a RPF-ID => multicast traffic */ FIB_ROUTE_PATH_RPF_ID = (1 << 7), + /** + * A deag path using the packet's source not destination address. + */ + FIB_ROUTE_PATH_SOURCE_LOOKUP = (1 << 8), } fib_route_path_flags_t; /** |