FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
mpls_tunnel.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __MPLS_TUNNEL_H__
17 #define __MPLS_TUNNEL_H__
18 
19 #include <vnet/mpls/mpls.h>
20 #include <vnet/fib/fib_path_ext.h>
21 
23 {
25  /**
26  * @brief The tunnel is L2 only
27  */
29  /**
30  * @brief The tunnel has an underlying multicast LSP
31  */
35 
36 #define MPLS_TUNNEL_ATTRIBUTES { \
37  [MPLS_TUNNEL_ATTRIBUTE_MCAST] = "multicast", \
38  [MPLS_TUNNEL_ATTRIBUTE_L2] = "L2", \
39 }
40 #define FOR_EACH_MPLS_TUNNEL_ATTRIBUTE(_item) \
41  for (_item = MPLS_TUNNEL_ATTRIBUTE_FIRST; \
42  _item <= MPLS_TUNNEL_ATTRIBUTE_LAST; \
43  _item++)
44 
45 typedef enum mpls_tunnel_flag_t_ {
49 } __attribute__ ((packed)) mpls_tunnel_flags_t;
50 
51 
52 /**
53  * @brief A uni-directional MPLS tunnel
54  */
55 typedef struct mpls_tunnel_t_
56 {
57  /**
58  * @brief The tunnel hooks into the FIB control plane graph.
59  */
61 
62  /**
63  * @brief Tunnel flags
64  */
66 
67  /**
68  * @brief User defined name tag for this MPLS Tunnel.
69  */
70  u8 mt_tag[64];
71 
72  /**
73  * @brief If the tunnel is an L2 tunnel, this is the link type ETHERNET
74  * load-balance
75  */
77 
78  /**
79  * @brief The HW interface index of the tunnel interfaces
80  */
82 
83  /**
84  * @brief The SW interface index of the tunnel interfaces
85  */
87 
88  /**
89  * @brief The path-list over which the tunnel's destination is reachable
90  */
92 
93  /**
94  * @brief sibling index on the path-list so notifications are received.
95  */
97 
98  /**
99  * A vector of path extensions o hold the label stack for each path
100  */
102 } mpls_tunnel_t;
103 
104 /**
105  * @brief Create a new MPLS tunnel
106  * @return the SW Interface index of the newly created tuneel
107  */
108 extern u32 vnet_mpls_tunnel_create (u8 l2_only,
109  u8 is_multicast,
110  u8 *description);
111 
112 /**
113  * @brief Add a path to an MPLS tunnel
114  */
116  fib_route_path_t *rpath);
117 
118 /**
119  * @brief remove a path from a tunnel.
120  * @return the number of remaining paths. 0 implies the tunnel can be deleted
121  */
123  fib_route_path_t *rpath);
124 
125 /**
126  * @brief return the tunnel index from the sw_if_index
127  */
129 
130 /**
131  * @brief Delete an MPLS tunnel
132  */
133 extern void vnet_mpls_tunnel_del (u32 sw_if_index);
134 
135 extern const mpls_tunnel_t *mpls_tunnel_get(u32 index);
136 
137 /**
138  * @brief Callback function invoked while walking MPLS tunnels
139  */
140 typedef void (*mpls_tunnel_walk_cb_t)(u32 index, void *ctx);
141 
142 /**
143  * @brief Walk all the MPLS tunnels
144  */
146  void *ctx);
147 
148 #endif
mpls_tunnel_t_::mt_sibling_index
u32 mt_sibling_index
sibling index on the path-list so notifications are received.
Definition: mpls_tunnel.h:96
MPLS_TUNNEL_ATTRIBUTE_LAST
@ MPLS_TUNNEL_ATTRIBUTE_LAST
Definition: mpls_tunnel.h:33
MPLS_TUNNEL_ATTRIBUTE_L2
@ MPLS_TUNNEL_ATTRIBUTE_L2
The tunnel is L2 only.
Definition: mpls_tunnel.h:28
mpls_tunnel_t_::mt_path_list
fib_node_index_t mt_path_list
The path-list over which the tunnel's destination is reachable.
Definition: mpls_tunnel.h:91
vnet_mpls_tunnel_get_index
int vnet_mpls_tunnel_get_index(u32 sw_if_index)
return the tunnel index from the sw_if_index
Definition: mpls_tunnel.c:829
vnet_mpls_tunnel_path_add
void vnet_mpls_tunnel_path_add(u32 sw_if_index, fib_route_path_t *rpath)
Add a path to an MPLS tunnel.
Definition: mpls_tunnel.c:703
mpls_tunnel_flags_t
enum mpls_tunnel_flag_t_ mpls_tunnel_flags_t
vnet_mpls_tunnel_path_remove
int vnet_mpls_tunnel_path_remove(u32 sw_if_index, fib_route_path_t *rpath)
remove a path from a tunnel.
Definition: mpls_tunnel.c:759
mpls.h
mpls_tunnel_walk
void mpls_tunnel_walk(mpls_tunnel_walk_cb_t cb, void *ctx)
Walk all the MPLS tunnels.
Definition: mpls_tunnel.c:615
mpls_tunnel_walk_cb_t
void(* mpls_tunnel_walk_cb_t)(u32 index, void *ctx)
Callback function invoked while walking MPLS tunnels.
Definition: mpls_tunnel.h:140
MPLS_TUNNEL_ATTRIBUTE_FIRST
@ MPLS_TUNNEL_ATTRIBUTE_FIRST
Definition: mpls_tunnel.h:24
fib_path_ext_list_t_
A list of path-extensions.
Definition: fib_types.h:644
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
MPLS_TUNNEL_FLAG_NONE
@ MPLS_TUNNEL_FLAG_NONE
Definition: mpls_tunnel.h:46
mpls_tunnel_t_::mt_node
fib_node_t mt_node
The tunnel hooks into the FIB control plane graph.
Definition: mpls_tunnel.h:60
MPLS_TUNNEL_ATTRIBUTE_MCAST
@ MPLS_TUNNEL_ATTRIBUTE_MCAST
The tunnel has an underlying multicast LSP.
Definition: mpls_tunnel.h:32
mpls_tunnel_t_::mt_l2_lb
dpo_id_t mt_l2_lb
If the tunnel is an L2 tunnel, this is the link type ETHERNET load-balance.
Definition: mpls_tunnel.h:76
mpls_tunnel_t_::mt_path_exts
fib_path_ext_list_t mt_path_exts
A vector of path extensions o hold the label stack for each path.
Definition: mpls_tunnel.h:101
MPLS_TUNNEL_FLAG_L2
@ MPLS_TUNNEL_FLAG_L2
Definition: mpls_tunnel.h:47
mpls_tunnel_t_
A uni-directional MPLS tunnel.
Definition: mpls_tunnel.h:55
vnet_mpls_tunnel_del
void vnet_mpls_tunnel_del(u32 sw_if_index)
Delete an MPLS tunnel.
Definition: mpls_tunnel.c:627
index
u32 index
Definition: flow_types.api:221
mpls_tunnel_attribute_t
enum mpls_tunnel_attribute_t_ mpls_tunnel_attribute_t
u32
unsigned int u32
Definition: types.h:88
fib_route_path_t_
A representation of a path as described by a route producer.
Definition: fib_types.h:500
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
MPLS_TUNNEL_FLAG_MCAST
@ MPLS_TUNNEL_FLAG_MCAST
Definition: mpls_tunnel.h:48
mpls_tunnel_t
struct mpls_tunnel_t_ mpls_tunnel_t
A uni-directional MPLS tunnel.
fib_node_t_
An node in the FIB graph.
Definition: fib_node.h:301
mpls_tunnel_attribute_t_
mpls_tunnel_attribute_t_
Definition: mpls_tunnel.h:22
mpls_tunnel_get
const mpls_tunnel_t * mpls_tunnel_get(u32 index)
Definition: mpls_tunnel.c:606
u8
unsigned char u8
Definition: types.h:56
mpls_tunnel_t_::mt_flags
mpls_tunnel_flags_t mt_flags
Tunnel flags.
Definition: mpls_tunnel.h:65
vnet_mpls_tunnel_create
u32 vnet_mpls_tunnel_create(u8 l2_only, u8 is_multicast, u8 *description)
Create a new MPLS tunnel.
Definition: mpls_tunnel.c:648
mpls_tunnel_t_::mt_tag
u8 mt_tag[64]
User defined name tag for this MPLS Tunnel.
Definition: mpls_tunnel.h:70
mpls_tunnel_t_::mt_hw_if_index
u32 mt_hw_if_index
The HW interface index of the tunnel interfaces.
Definition: mpls_tunnel.h:81
dpo_id_t_
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:172
fib_path_ext.h
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
mpls_tunnel_t_::mt_sw_if_index
u32 mt_sw_if_index
The SW interface index of the tunnel interfaces.
Definition: mpls_tunnel.h:86
mpls_tunnel_flag_t_
mpls_tunnel_flag_t_
Definition: mpls_tunnel.h:45