FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
adj_nbr.h
Go to the documentation of this file.
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  * @brief
17  * Neighbour Adjacency sub-type. These adjs represent an L3 peer on a
18  * connected link.
19  */
20 
21 #ifndef __ADJ_NBR_H__
22 #define __ADJ_NBR_H__
23 
24 #include <vnet/vnet.h>
25 #include <vnet/adj/adj_types.h>
26 #include <vnet/fib/fib_node.h>
27 #include <vnet/dpo/dpo.h>
28 
29 /**
30  * @brief
31  * Add (and lock) a new or lock an existing neighbour adjacency
32  *
33  * @param nh_proto
34  * The protocol for the next-hop address (v4 or v6)
35  *
36  * @param link_type
37  * A description of the protocol of the packets that will forward
38  * through this adj. On an ethernet interface this is the MAC header's
39  * ether-type
40  *
41  * @param nh_addr
42  * The address of the next-hop/peer to send the packet to
43  *
44  * @param sw_if_index
45  * The interface on which the peer resides
46  */
48  vnet_link_t link_type,
49  const ip46_address_t *nh_addr,
51 
52 /**
53  * @brief
54  * Add (and lock) a new or lock an existing neighbour adjacency
55  *
56  * @param nh_proto
57  * The protocol for the next-hop address (v4 or v6)
58  *
59  * @param link_type
60  * A description of the protocol of the packets that will forward
61  * through this adj. On an ethernet interface this is the MAC header's
62  * ether-type
63  *
64  * @param nh_addr
65  * The address of the next-hop/peer to send the packet to
66  *
67  * @param sw_if_index
68  * The interface on which the peer resides
69  *
70  * @param rewrite
71  * The rewrite to prepend to packets
72  */
74  vnet_link_t link_type,
75  const ip46_address_t *nh_addr,
77  u8 *rewrite);
78 
79 /**
80  * Set the MTU on an adjacency
81  *
82  */
83 extern void adj_nbr_set_mtu(adj_index_t ai, u16 mtu);
84 
85 /**
86  * @brief When adding a rewrite to an adjacency these are flags that
87  * apply to that rewrite
88  */
90 {
92 
93  /**
94  * An indication that the rewrite is incomplete, i.e. that it describes the
95  * ARP/ND rewrite when probing.
96  */
98 
99  /**
100  * An indication that the rewrite is complete, i.e. that it fully describes
101  * the link-layer addressing for the destintation.
102  * The opposite of this is an incomplete rewrite that describes the ARP/ND
103  * rewrite when probing.
104  */
107 
108 /**
109  * @brief
110  * Update the rewrite string for an existing adjacecny.
111  *
112  * @param
113  * The index of the adj to update
114  *
115  * @param
116  * The new rewrite
117  */
118 extern void adj_nbr_update_rewrite(adj_index_t adj_index,
120  u8 *rewrite);
121 
122 /**
123  * @brief
124  * Format aa incomplete neigbour (ARP) adjacency
125  */
126 extern u8* format_adj_nbr_incomplete(u8* s, va_list *ap);
127 
128 /**
129  * @brief
130  * Format a neigbour (REWRITE) adjacency
131  */
132 extern u8* format_adj_nbr(u8* s, va_list *ap);
133 
134 /**
135  * @brief Walk the neighbour Adjacencies on a given interface
136  */
137 extern void adj_nbr_walk (u32 sw_if_index,
138  fib_protocol_t adj_nh_proto,
139  adj_walk_cb_t cb,
140  void *ctx);
141 /**
142  * @brief Walk the neighbour Adjacencies on a given interface with a given next-hop
143  */
144 void
146  fib_protocol_t adj_nh_proto,
147  const ip46_address_t *nh,
148  adj_walk_cb_t cb,
149  void *ctx);
150 
151 /**
152  * @brief Walk adjacencies on a link with a given v4 next-hop.
153  * that is visit the adjacencies with different link types.
154  */
155 void
157  const ip4_address_t *addr,
158  adj_walk_cb_t cb,
159  void *ctx);
160 
161 /**
162  * @brief Walk adjacencies on a link with a given v6 next-hop.
163  * that is visit the adjacencies with different link types.
164  */
165 void
167  const ip6_address_t *addr,
168  adj_walk_cb_t cb,
169  void *ctx);
170 
171 /**
172  * @brief Lookup neighbor adjancency.
173  */
175 adj_nbr_find (fib_protocol_t nh_proto,
176  vnet_link_t link_type,
177  const ip46_address_t *nh_addr,
178  u32 sw_if_index);
179 /**
180  * @brief
181  * Module initialisation
182  */
183 extern void adj_nbr_module_init(void);
184 
185 /**
186  * @brief
187  * Return the size of the adjacency database. for testing purposes
188  */
189 extern u32 adj_nbr_db_size(void);
190 
191 #endif
ADJ_NBR_REWRITE_FLAG_INCOMPLETE
@ ADJ_NBR_REWRITE_FLAG_INCOMPLETE
An indication that the rewrite is incomplete, i.e.
Definition: adj_nbr.h:97
adj_nbr_find
adj_index_t adj_nbr_find(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
Lookup neighbor adjancency.
Definition: adj_nbr.c:109
adj_types.h
format_adj_nbr_incomplete
u8 * format_adj_nbr_incomplete(u8 *s, va_list *ap)
Format aa incomplete neigbour (ARP) adjacency.
Definition: adj_nbr.c:1047
adj_nbr_update_rewrite
void adj_nbr_update_rewrite(adj_index_t adj_index, adj_nbr_rewrite_flag_t flags, u8 *rewrite)
Update the rewrite string for an existing adjacecny.
Definition: adj_nbr.c:340
u16
unsigned short u16
Definition: types.h:57
adj_nbr_rewrite_flag_t_
adj_nbr_rewrite_flag_t_
When adding a rewrite to an adjacency these are flags that apply to that rewrite.
Definition: adj_nbr.h:89
ADJ_NBR_REWRITE_FLAG_COMPLETE
@ ADJ_NBR_REWRITE_FLAG_COMPLETE
An indication that the rewrite is complete, i.e.
Definition: adj_nbr.h:105
adj_nbr_add_or_lock_w_rewrite
adj_index_t adj_nbr_add_or_lock_w_rewrite(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index, u8 *rewrite)
Add (and lock) a new or lock an existing neighbour adjacency.
Definition: adj_nbr.c:303
adj_nbr_module_init
void adj_nbr_module_init(void)
Module initialisation.
Definition: adj_nbr.c:1178
addr
vhost_vring_addr_t addr
Definition: vhost_user.h:130
fib_node.h
adj_nbr_rewrite_flag_t
enum adj_nbr_rewrite_flag_t_ adj_nbr_rewrite_flag_t
When adding a rewrite to an adjacency these are flags that apply to that rewrite.
dpo.h
ADJ_NBR_REWRITE_FLAG_NONE
@ ADJ_NBR_REWRITE_FLAG_NONE
Definition: adj_nbr.h:91
adj_nbr_db_size
u32 adj_nbr_db_size(void)
Return the size of the adjacency database.
Definition: adj_nbr.c:569
nh
vl_api_fib_path_nh_t nh
Definition: fib_types.api:126
fib_protocol_t
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
ip4_address_t
Definition: ip4_packet.h:50
adj_nbr_add_or_lock
adj_index_t adj_nbr_add_or_lock(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
Neighbour Adjacency sub-type.
Definition: adj_nbr.c:257
adj_nbr_set_mtu
void adj_nbr_set_mtu(adj_index_t ai, u16 mtu)
Set the MTU on an adjacency.
Definition: adj_nbr.c:226
u32
unsigned int u32
Definition: types.h:88
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
nh_addr
vl_api_address_t nh_addr
Definition: lisp_gpe.api:222
adj_nbr_walk_nh6
void adj_nbr_walk_nh6(u32 sw_if_index, const ip6_address_t *addr, adj_walk_cb_t cb, void *ctx)
Walk adjacencies on a link with a given v6 next-hop.
Definition: adj_nbr.c:656
adj_nbr_walk_nh
void adj_nbr_walk_nh(u32 sw_if_index, fib_protocol_t adj_nh_proto, const ip46_address_t *nh, adj_walk_cb_t cb, void *ctx)
Walk the neighbour Adjacencies on a given interface with a given next-hop.
Definition: adj_nbr.c:684
adj_index_t
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
vnet_link_t
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
u8
unsigned char u8
Definition: types.h:56
format_adj_nbr
u8 * format_adj_nbr(u8 *s, va_list *ap)
Format a neigbour (REWRITE) adjacency.
Definition: adj_nbr.c:1066
adj_walk_cb_t
adj_walk_rc_t(* adj_walk_cb_t)(adj_index_t ai, void *ctx)
Call back function when walking adjacencies.
Definition: adj_types.h:50
vnet.h
adj_nbr_walk
void adj_nbr_walk(u32 sw_if_index, fib_protocol_t adj_nh_proto, adj_walk_cb_t cb, void *ctx)
Walk the neighbour Adjacencies on a given interface.
Definition: adj_nbr.c:592
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
rewrite
rewrite
Definition: pnat.api:158
adj_nbr_walk_nh4
void adj_nbr_walk_nh4(u32 sw_if_index, const ip4_address_t *addr, adj_walk_cb_t cb, void *ctx)
Walk adjacencies on a link with a given v4 next-hop.
Definition: adj_nbr.c:628
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105