diff options
author | Neale Ranns <nranns@cisco.com> | 2017-11-05 16:26:46 -0800 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2017-11-07 16:13:42 +0000 |
commit | 810086d8fd08445919ae03bf36161037e53a712a (patch) | |
tree | 76a91d3ed49759ef3adae32066f9dcedd75df889 /src/vnet/fib | |
parent | 595992c5c3b5abbdb7e90e61acbee212f25ad59f (diff) |
UDP Encapsulation.
A UDP-encap object that particiapates in the FIB graph and contributes
DPO to teh output chain. It thereofre resembles a tunnel but without the
interface. FIB paths (and henace routes) can then be created to egress
through the UDP-encap. Said routes can have MPLS labels, hence this also
allows MPLSoUPD.
Encap is uni-directional. For decap, one still registers with the UDP port
dispatcher.
Change-Id: I23bd345523b20789a1de1b02022ea1148ca50797
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/fib')
-rw-r--r-- | src/vnet/fib/fib_api.h | 2 | ||||
-rw-r--r-- | src/vnet/fib/fib_node.h | 2 | ||||
-rw-r--r-- | src/vnet/fib/fib_path.c | 73 | ||||
-rw-r--r-- | src/vnet/fib/fib_types.h | 8 |
4 files changed, 84 insertions, 1 deletions
diff --git a/src/vnet/fib/fib_api.h b/src/vnet/fib/fib_api.h index e5b94e14124..655d305372b 100644 --- a/src/vnet/fib/fib_api.h +++ b/src/vnet/fib/fib_api.h @@ -42,10 +42,12 @@ add_del_route_t_handler (u8 is_multipath, u8 is_rpf_id, u8 is_l2_bridged, u8 is_source_lookup, + u8 is_udp_encap, u32 fib_index, const fib_prefix_t * prefix, dpo_proto_t next_hop_proto, const ip46_address_t * next_hop, + u32 next_hop_id, u32 next_hop_sw_if_index, u8 next_hop_fib_index, u16 next_hop_weight, diff --git a/src/vnet/fib/fib_node.h b/src/vnet/fib/fib_node.h index 762e0cf01af..6d26bdd3671 100644 --- a/src/vnet/fib/fib_node.h +++ b/src/vnet/fib/fib_node.h @@ -44,6 +44,7 @@ typedef enum fib_node_type_t_ { FIB_NODE_TYPE_MAP_E, FIB_NODE_TYPE_VXLAN_GPE_TUNNEL, FIB_NODE_TYPE_GENEVE_TUNNEL, + FIB_NODE_TYPE_UDP_ENCAP, /** * Marker. New types before this one. leave the test last. */ @@ -68,6 +69,7 @@ typedef enum fib_node_type_t_ { [FIB_NODE_TYPE_VXLAN_TUNNEL] = "vxlan-tunnel", \ [FIB_NODE_TYPE_MAP_E] = "map-e", \ [FIB_NODE_TYPE_VXLAN_GPE_TUNNEL] = "vxlan-gpe-tunnel", \ + [FIB_NODE_TYPE_UDP_ENCAP] = "udp-encap", \ } /** diff --git a/src/vnet/fib/fib_path.c b/src/vnet/fib/fib_path.c index 926b2f3dfc6..4fccca80672 100644 --- a/src/vnet/fib/fib_path.c +++ b/src/vnet/fib/fib_path.c @@ -36,6 +36,7 @@ #include <vnet/fib/fib_internal.h> #include <vnet/fib/fib_urpf_list.h> #include <vnet/fib/mpls_fib.h> +#include <vnet/udp/udp_encap.h> /** * Enurmeration of path types @@ -74,6 +75,10 @@ typedef enum fib_path_type_t_ { */ FIB_PATH_TYPE_INTF_RX, /** + * interface receive. + */ + FIB_PATH_TYPE_UDP_ENCAP, + /** * receive. it's for-us. */ FIB_PATH_TYPE_RECEIVE, @@ -96,6 +101,7 @@ typedef enum fib_path_type_t_ { [FIB_PATH_TYPE_EXCLUSIVE] = "exclusive", \ [FIB_PATH_TYPE_DEAG] = "deag", \ [FIB_PATH_TYPE_INTF_RX] = "intf-rx", \ + [FIB_PATH_TYPE_UDP_ENCAP] = "udp-encap", \ [FIB_PATH_TYPE_RECEIVE] = "receive", \ } @@ -285,6 +291,12 @@ typedef struct fib_path_t_ { */ u32 fp_interface; } intf_rx; + struct { + /** + * The UDP Encap object this path resolves through + */ + u32 fp_udp_encap_id; + } udp_encap; }; STRUCT_MARK(path_hash_end); @@ -479,6 +491,9 @@ format_fib_path (u8 * s, va_list * args) path->fp_dpo.dpoi_index); break; + case FIB_PATH_TYPE_UDP_ENCAP: + s = format (s, " UDP-encap ID:%d", path->udp_encap.fp_udp_encap_id); + break; case FIB_PATH_TYPE_RECEIVE: case FIB_PATH_TYPE_INTF_RX: case FIB_PATH_TYPE_SPECIAL: @@ -784,6 +799,9 @@ fib_path_unresolve (fib_path_t *path) adj_unlock(path->fp_dpo.dpoi_index); } break; + case FIB_PATH_TYPE_UDP_ENCAP: + udp_encap_unlock_w_index(path->fp_dpo.dpoi_index); + break; case FIB_PATH_TYPE_EXCLUSIVE: dpo_reset(&path->exclusive.fp_ex_dpo); break; @@ -989,6 +1007,33 @@ FIXME comment path->fp_oper_flags |= FIB_PATH_OPER_FLAG_DROP; } break; + case FIB_PATH_TYPE_UDP_ENCAP: + { + dpo_id_t via_dpo = DPO_INVALID; + + /* + * hope for the best - clear if restrictions apply. + */ + path->fp_oper_flags |= FIB_PATH_OPER_FLAG_RESOLVED; + + udp_encap_contribute_forwarding(path->udp_encap.fp_udp_encap_id, + path->fp_nh_proto, + &via_dpo); + /* + * If this path is contributing a drop, then it's not resolved + */ + if (dpo_is_drop(&via_dpo) || load_balance_is_drop(&via_dpo)) + { + path->fp_oper_flags &= ~FIB_PATH_OPER_FLAG_RESOLVED; + } + + /* + * update the path's contributed DPO + */ + dpo_copy(&path->fp_dpo, &via_dpo); + dpo_reset(&via_dpo); + break; + } case FIB_PATH_TYPE_INTF_RX: ASSERT(0); case FIB_PATH_TYPE_DEAG: @@ -1103,6 +1148,11 @@ fib_path_create (fib_node_index_t pl_index, path->receive.fp_interface = rpath->frp_sw_if_index; path->receive.fp_addr = rpath->frp_addr; } + else if (rpath->frp_flags & FIB_ROUTE_PATH_UDP_ENCAP) + { + path->fp_type = FIB_PATH_TYPE_UDP_ENCAP; + path->udp_encap.fp_udp_encap_id = rpath->frp_udp_encap_id; + } else if (path->fp_cfg_flags & FIB_PATH_CFG_FLAG_INTF_RX) { path->fp_type = FIB_PATH_TYPE_INTF_RX; @@ -1346,6 +1396,9 @@ fib_path_cmp_i (const fib_path_t *path1, case FIB_PATH_TYPE_INTF_RX: res = (path1->intf_rx.fp_interface - path2->intf_rx.fp_interface); break; + case FIB_PATH_TYPE_UDP_ENCAP: + res = (path1->udp_encap.fp_udp_encap_id - path2->udp_encap.fp_udp_encap_id); + break; case FIB_PATH_TYPE_SPECIAL: case FIB_PATH_TYPE_RECEIVE: case FIB_PATH_TYPE_EXCLUSIVE: @@ -1460,6 +1513,9 @@ fib_path_cmp_w_route_path (fib_node_index_t path_index, case FIB_PATH_TYPE_INTF_RX: res = (path->intf_rx.fp_interface - rpath->frp_sw_if_index); break; + case FIB_PATH_TYPE_UDP_ENCAP: + res = (path->udp_encap.fp_udp_encap_id - rpath->frp_udp_encap_id); + break; case FIB_PATH_TYPE_DEAG: res = (path->deag.fp_tbl_id - rpath->frp_fib_index); if (0 == res) @@ -1565,6 +1621,7 @@ fib_path_recursive_loop_detect (fib_node_index_t path_index, case FIB_PATH_TYPE_DEAG: case FIB_PATH_TYPE_RECEIVE: case FIB_PATH_TYPE_INTF_RX: + case FIB_PATH_TYPE_UDP_ENCAP: case FIB_PATH_TYPE_EXCLUSIVE: /* * these path types cannot be part of a loop, since they are the leaves @@ -1724,6 +1781,12 @@ fib_path_resolve (fib_node_index_t path_index) &path->receive.fp_addr, &path->fp_dpo); break; + case FIB_PATH_TYPE_UDP_ENCAP: + udp_encap_lock(path->udp_encap.fp_udp_encap_id); + udp_encap_contribute_forwarding(path->udp_encap.fp_udp_encap_id, + path->fp_nh_proto, + &path->fp_dpo); + break; case FIB_PATH_TYPE_INTF_RX: { /* * Resolve via a receive DPO. @@ -1766,6 +1829,7 @@ fib_path_get_resolving_interface (fib_node_index_t path_index) } break; case FIB_PATH_TYPE_INTF_RX: + case FIB_PATH_TYPE_UDP_ENCAP: case FIB_PATH_TYPE_SPECIAL: case FIB_PATH_TYPE_DEAG: case FIB_PATH_TYPE_EXCLUSIVE: @@ -1872,6 +1936,7 @@ fib_path_contribute_urpf (fib_node_index_t path_index, case FIB_PATH_TYPE_DEAG: case FIB_PATH_TYPE_RECEIVE: case FIB_PATH_TYPE_INTF_RX: + case FIB_PATH_TYPE_UDP_ENCAP: /* * these path types don't link to an adj */ @@ -1905,12 +1970,13 @@ fib_path_stack_mpls_disp (fib_node_index_t path_index, &tmp)); dpo_reset(&tmp); break; - } + } case FIB_PATH_TYPE_RECEIVE: case FIB_PATH_TYPE_ATTACHED: case FIB_PATH_TYPE_ATTACHED_NEXT_HOP: case FIB_PATH_TYPE_RECURSIVE: case FIB_PATH_TYPE_INTF_RX: + case FIB_PATH_TYPE_UDP_ENCAP: case FIB_PATH_TYPE_EXCLUSIVE: case FIB_PATH_TYPE_SPECIAL: break; @@ -2072,6 +2138,11 @@ fib_path_contribute_forwarding (fib_node_index_t path_index, path->attached.fp_interface, dpo); break; + case FIB_PATH_TYPE_UDP_ENCAP: + udp_encap_contribute_forwarding(path->udp_encap.fp_udp_encap_id, + path->fp_nh_proto, + dpo); + break; case FIB_PATH_TYPE_RECEIVE: case FIB_PATH_TYPE_SPECIAL: dpo_copy(dpo, &path->fp_dpo); diff --git a/src/vnet/fib/fib_types.h b/src/vnet/fib/fib_types.h index 7eadbb9bb70..ec7f1b374dd 100644 --- a/src/vnet/fib/fib_types.h +++ b/src/vnet/fib/fib_types.h @@ -307,6 +307,10 @@ typedef enum fib_route_path_flags_t_ * A deag path using the packet's source not destination address. */ FIB_ROUTE_PATH_SOURCE_LOOKUP = (1 << 8), + /** + * A path via a UDP encap object. + */ + FIB_ROUTE_PATH_UDP_ENCAP = (1 << 9), } fib_route_path_flags_t; /** @@ -375,6 +379,10 @@ typedef struct fib_route_path_t_ { * The RPF-ID */ fib_rpf_id_t frp_rpf_id; + /** + * UDP encap ID + */ + u32 frp_udp_encap_id; }; /** * The FIB index to lookup the nexthop |