FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
adj_internal.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 #ifndef __ADJ_INTERNAL_H__
17 #define __ADJ_INTERNAL_H__
18 
19 #include <vnet/adj/adj.h>
20 #include <vnet/adj/adj_mcast.h>
21 #include <vnet/ip/ip.h>
22 #include <vnet/mpls/mpls.h>
23 #include <vnet/adj/adj_l2.h>
24 #include <vnet/adj/adj_nsh.h>
25 
26 /**
27  * big switch to turn on Adjacency debugging
28  */
29 #undef ADJ_DEBUG
30 
31 /*
32  * Debug macro
33  */
34 #ifdef ADJ_DEBUG
35 #define ADJ_DBG(_adj, _fmt, _args...) \
36 { \
37  clib_warning("adj:[%d:%p]:" _fmt, \
38  _adj - adj_pool, _adj, \
39  ##_args); \
40 }
41 #else
42 #define ADJ_DBG(_e, _fmt, _args...)
43 #endif
44 
45 /*
46  * Vlib nodes
47  */
52 
53 static inline u32
55 {
56  switch (linkt) {
57  case VNET_LINK_IP4:
58  return (ip4_rewrite_node.index);
59  case VNET_LINK_IP6:
60  return (ip6_rewrite_node.index);
61  case VNET_LINK_MPLS:
62  return (mpls_output_node.index);
63  case VNET_LINK_ETHERNET:
64  return (adj_l2_rewrite_node.index);
65  case VNET_LINK_NSH:
66  return (adj_nsh_rewrite_node.index);
67  case VNET_LINK_ARP:
68  break;
69  }
70  ASSERT(0);
71  return (0);
72 }
73 
74 static inline vnet_link_t
76 {
77  switch (fp)
78  {
79  case FIB_PROTOCOL_IP4:
80  return (VNET_LINK_ARP);
81  case FIB_PROTOCOL_IP6:
82  return (VNET_LINK_IP6);
83  case FIB_PROTOCOL_MPLS:
84  return (VNET_LINK_MPLS);
85  }
86  return (0);
87 }
88 
89 static inline ip46_type_t
91 {
92  switch (proto)
93  {
94  case FIB_PROTOCOL_IP4:
95  return (IP46_TYPE_IP4);
96  case FIB_PROTOCOL_IP6:
97  return (IP46_TYPE_IP6);
98  default:
99  return (IP46_TYPE_IP4);
100  }
101  return (IP46_TYPE_IP4);
102 }
103 
104 /**
105  * @brief
106  * Get a pointer to an adjacency object from its index
107  */
108 static inline adj_index_t
110 {
111  return (adj - adj_pool);
112 }
113 
115  ip_lookup_next_t adj_next_index,
116  u32 complete_next_index,
117  u32 next_index,
118  u8 *rewrite);
119 extern void adj_midchain_setup(adj_index_t adj_index,
120  adj_midchain_fixup_t fixup,
121  const void *data,
123 
125 
126 extern void adj_nbr_remove(adj_index_t ai,
127  fib_protocol_t nh_proto,
128  vnet_link_t link_type,
129  const ip46_address_t *nh_addr,
130  u32 sw_if_index);
131 extern void adj_glean_remove(ip_adjacency_t *adj);
133  u32 sw_if_index);
134 extern void adj_midchain_teardown(ip_adjacency_t *adj);
135 
136 extern u32 adj_dpo_get_urpf(const dpo_id_t *dpo);
137 extern u16 adj_dpo_get_mtu(const dpo_id_t *dpo);
138 
139 /*
140  * Adj BFD
141  */
142 extern int adj_bfd_is_up (adj_index_t ai);
143 
144 /*
145  * Adj delegates
146  */
147 extern void adj_delegate_adj_deleted(ip_adjacency_t *adj);
148 extern void adj_delegate_adj_created(ip_adjacency_t *adj);
149 extern void adj_delegate_adj_modified(ip_adjacency_t *adj);
150 extern u8* adj_delegate_format(u8* s, ip_adjacency_t *adj);
151 
152 #endif
adj.h
adj_proto_to_46
static ip46_type_t adj_proto_to_46(fib_protocol_t proto)
Definition: adj_internal.h:90
adj_midchain_tx_node
vlib_node_registration_t adj_midchain_tx_node
(constructor) VLIB_REGISTER_NODE (adj_midchain_tx_node)
Definition: adj_midchain_node.c:213
adj_dpo_get_urpf
u32 adj_dpo_get_urpf(const dpo_id_t *dpo)
Definition: adj.c:321
adj_pool
ip_adjacency_t * adj_pool
The global adjacency pool.
Definition: adj.c:34
next_index
nat44_ei_hairpin_src_next_t next_index
Definition: nat44_ei_hairpinning.c:412
VNET_LINK_ETHERNET
@ VNET_LINK_ETHERNET
Definition: interface.h:350
adj_midchain_fixup_t
void(* adj_midchain_fixup_t)(vlib_main_t *vm, const struct ip_adjacency_t_ *adj, vlib_buffer_t *b0, const void *data)
A function type for post-rewrite fixups on midchain adjacency.
Definition: adj.h:152
adj_mcast.h
IP46_TYPE_IP4
@ IP46_TYPE_IP4
Definition: ip46_address.h:26
adj_alloc
ip_adjacency_t * adj_alloc(fib_protocol_t proto)
Definition: adj.c:64
u16
unsigned short u16
Definition: types.h:57
adj_l2.h
adj_nbr_remove
void adj_nbr_remove(adj_index_t ai, fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
Definition: adj_nbr.c:85
adj_delegate_adj_created
void adj_delegate_adj_created(ip_adjacency_t *adj)
Definition: adj_delegate.c:158
VNET_LINK_ARP
@ VNET_LINK_ARP
Definition: interface.h:351
mpls.h
ip4_rewrite_node
vlib_node_registration_t ip4_rewrite_node
(constructor) VLIB_REGISTER_NODE (ip4_rewrite_node)
Definition: ip4_forward.c:2597
mpls_output_node
vlib_node_registration_t mpls_output_node
(constructor) VLIB_REGISTER_NODE (mpls_output_node)
Definition: mpls_output.c:333
adj_nsh_rewrite_node
vlib_node_registration_t adj_nsh_rewrite_node
(constructor) VLIB_REGISTER_NODE (adj_nsh_rewrite_node)
Definition: adj_nsh.c:168
adj_nbr_update_rewrite_internal
void adj_nbr_update_rewrite_internal(ip_adjacency_t *adj, ip_lookup_next_t adj_next_index, u32 complete_next_index, u32 next_index, u8 *rewrite)
adj_nbr_update_rewrite_internal
Definition: adj_nbr.c:382
adj_glean_remove
void adj_glean_remove(ip_adjacency_t *adj)
Definition: adj_glean.c:301
adj_flags_t
enum adj_flags_t_ adj_flags_t
Flags on an IP adjacency.
adj_delegate_adj_deleted
void adj_delegate_adj_deleted(ip_adjacency_t *adj)
Definition: adj_delegate.c:142
adj_bfd_is_up
int adj_bfd_is_up(adj_index_t ai)
Definition: adj_bfd.c:239
adj_dpo_get_mtu
u16 adj_dpo_get_mtu(const dpo_id_t *dpo)
Definition: adj.c:331
VNET_LINK_IP4
@ VNET_LINK_IP4
Definition: interface.h:344
adj_get_index
static adj_index_t adj_get_index(const ip_adjacency_t *adj)
Get a pointer to an adjacency object from its index.
Definition: adj_internal.h:109
ip6_rewrite_node
vlib_node_registration_t ip6_rewrite_node
(constructor) VLIB_REGISTER_NODE (ip6_rewrite_node)
Definition: ip6_forward.c:2205
VNET_LINK_NSH
@ VNET_LINK_NSH
Definition: interface.h:352
VNET_LINK_MPLS
@ VNET_LINK_MPLS
Definition: interface.h:349
adj_nsh.h
fib_protocol_t
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
ip_adjacency_t_
IP unicast adjacency.
Definition: adj.h:235
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
IP46_TYPE_IP6
@ IP46_TYPE_IP6
Definition: ip46_address.h:27
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
adj_mcast_remove
void adj_mcast_remove(fib_protocol_t proto, u32 sw_if_index)
Definition: adj_mcast.c:180
adj_midchain_tx_no_count_node
vlib_node_registration_t adj_midchain_tx_no_count_node
(constructor) VLIB_REGISTER_NODE (adj_midchain_tx_no_count_node)
Definition: adj_midchain_node.c:234
data
u8 data[128]
Definition: ipsec_types.api:95
ip_lookup_next_t
ip_lookup_next_t
An adjacency is a representation of an attached L3 peer.
Definition: adj.h:50
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
adj_delegate_adj_modified
void adj_delegate_adj_modified(ip_adjacency_t *adj)
Definition: adj_delegate.c:128
adj_get_rewrite_node
static u32 adj_get_rewrite_node(vnet_link_t linkt)
Definition: adj_internal.h:54
FIB_PROTOCOL_MPLS
@ FIB_PROTOCOL_MPLS
Definition: fib_types.h:38
ip.h
u32
unsigned int u32
Definition: types.h:88
adj_fib_proto_2_nd
static vnet_link_t adj_fib_proto_2_nd(fib_protocol_t fp)
Definition: adj_internal.h:75
FIB_PROTOCOL_IP6
@ FIB_PROTOCOL_IP6
Definition: fib_types.h:37
nh_addr
vl_api_address_t nh_addr
Definition: lisp_gpe.api:222
adj_nsh_midchain_node
vlib_node_registration_t adj_nsh_midchain_node
(constructor) VLIB_REGISTER_NODE (adj_nsh_midchain_node)
Definition: adj_nsh.c:180
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.
adj_midchain_setup
void adj_midchain_setup(adj_index_t adj_index, adj_midchain_fixup_t fixup, const void *data, adj_flags_t flags)
adj_midchain_setup
Definition: adj_midchain.c:153
u8
unsigned char u8
Definition: types.h:56
VNET_LINK_IP6
@ VNET_LINK_IP6
Definition: interface.h:348
ip46_type_t
ip46_type_t
Definition: ip46_address.h:22
adj_l2_rewrite_node
vlib_node_registration_t adj_l2_rewrite_node
(constructor) VLIB_REGISTER_NODE (adj_l2_rewrite_node)
Definition: adj_l2.c:185
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
proto
vl_api_ip_proto_t proto
Definition: acl_types.api:51
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
rewrite
rewrite
Definition: pnat.api:158
adj_delegate_format
u8 * adj_delegate_format(u8 *s, ip_adjacency_t *adj)
Definition: adj_delegate.c:172
adj_midchain_teardown
void adj_midchain_teardown(ip_adjacency_t *adj)
adj_midchain_setup
Definition: adj_midchain.c:132
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105