A Protocol Independent Hierarchical FIB (VPP-352)
[vpp.git] / vnet / vnet / lisp-gpe / lisp_gpe_adjacency.h
1 /*
2  * Copyright (c) 2016 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  * @file
17  * @brief Common utility functions for IPv4, IPv6 and L2 LISP-GPE adjacencys.
18  *
19  */
20
21 #ifndef LISP_GPE_ADJACENCY_H__
22 #define LISP_GPE_ADJACENCY_H__
23
24 #include <vnet/fib/fib_node.h>
25 #include <vnet/lisp-gpe/lisp_gpe.h>
26
27 /**
28  * @brief A LISP GPE Adjacency.
29  *
30  * A adjacency represents peer on an L3 sub-interface to which to send traffic.
31  * adjacencies are thus present in the EID space.
32  * The peer is identified by the key:{remote-rloc, sub-interface}, which is
33  * equivalent to the usal adjacency key {next-hop, interface}. So curiously
34  * the rloc address from the underlay is used as a next hop address in the overlay
35  * This is OK because:
36  *  1 - the RLOC is unique in the underlay AND there is only one underlay VRF per
37  *      overlay
38  *  2 - the RLOC may overlap with an address in the overlay, but we do not create
39  *      an adj-fib (i.e. a route in the overlay FIB for the rloc)
40  *
41  *
42  */
43 typedef struct lisp_gpe_adjacency_t_
44 {
45   /**
46    * The LISP adj is a part of the FIB control plane graph.
47    */
48   fib_node_t fib_node;
49
50   /**
51    * remote RLOC. The adjacency's next-hop
52    */
53   ip_address_t remote_rloc;
54
55   /**
56    * The VNI. Used in combination with the local-rloc to get the sub-interface
57    */
58   u32 vni;
59
60   /**
61    * The number of locks/reference counts on the adjacency.
62    */
63   u32 locks;
64
65   /**
66    * The index of the LISP L3 subinterface
67    */
68   u32 lisp_l3_sub_index;
69
70   /**
71    * The SW IF index of the sub-interface this adjacency uses.
72    * Cached for convenience from the LISP L3 sub-interface
73    */
74   u32 sw_if_index;
75
76   /**
77    * The index of the LISP GPE tunnel that provides the transport
78    * in the underlay.
79    */
80   u32 tunnel_index;
81
82   /**
83    * Per-link-type FIB adjacencies contributed.
84    * These will be used as a result of a FIB lookup.
85    */
86   adj_index_t adjs[FIB_LINK_NUM];
87
88   /**
89    * This adjacency is a child of the FIB entry to reach the RLOC.
90    * This is so when the reachability of that RLOC changes, we can restack
91    * the FIB adjacnecies.
92    */
93   u32 fib_entry_child_index;
94
95   /**
96    * LISP header fields in HOST byte order
97    */
98   u8 flags;
99   u8 ver_res;
100   u8 res;
101   u8 next_protocol;
102
103 } lisp_gpe_adjacency_t;
104
105 extern index_t lisp_gpe_adjacency_find_or_create_and_lock (const
106                                                            locator_pair_t *
107                                                            pair,
108                                                            u32 rloc_fib_index,
109                                                            u32 vni);
110
111 extern void lisp_gpe_adjacency_unlock (index_t l3si);
112
113 extern const lisp_gpe_adjacency_t *lisp_gpe_adjacency_get (index_t l3si);
114
115 /**
116  * @brief Flags for displaying the adjacency
117  */
118 typedef enum lisp_gpe_adjacency_format_flags_t_
119 {
120   LISP_GPE_ADJ_FORMAT_FLAG_NONE,
121   LISP_GPE_ADJ_FORMAT_FLAG_DETAIL,
122 } lisp_gpe_adjacency_format_flags_t;
123
124 extern u8 *format_lisp_gpe_adjacency (u8 * s, va_list * args);
125
126 #endif
127
128 /*
129  * fd.io coding-style-patch-verification: ON
130  *
131  * Local Variables:
132  * eval: (c-set-style "gnu")
133  * End:
134  */