FD.io VPP  v19.08.3-2-gbabecb413
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 static inline u32
47 {
48  switch (linkt) {
49  case VNET_LINK_IP4:
50  return (ip4_rewrite_node.index);
51  case VNET_LINK_IP6:
52  return (ip6_rewrite_node.index);
53  case VNET_LINK_MPLS:
54  return (mpls_output_node.index);
55  case VNET_LINK_ETHERNET:
56  return (adj_l2_rewrite_node.index);
57  case VNET_LINK_NSH:
58  return (adj_nsh_rewrite_node.index);
59  case VNET_LINK_ARP:
60  break;
61  }
62  ASSERT(0);
63  return (0);
64 }
65 
66 static inline vnet_link_t
68 {
69  switch (fp)
70  {
71  case FIB_PROTOCOL_IP4:
72  return (VNET_LINK_ARP);
73  case FIB_PROTOCOL_IP6:
74  return (VNET_LINK_IP6);
75  case FIB_PROTOCOL_MPLS:
76  return (VNET_LINK_MPLS);
77  }
78  return (0);
79 }
80 
81 static inline ip46_type_t
83 {
84  switch (proto)
85  {
86  case FIB_PROTOCOL_IP4:
87  return (IP46_TYPE_IP4);
88  case FIB_PROTOCOL_IP6:
89  return (IP46_TYPE_IP6);
90  default:
91  return (IP46_TYPE_IP4);
92  }
93  return (IP46_TYPE_IP4);
94 }
95 
96 /**
97  * @brief
98  * Get a pointer to an adjacency object from its index
99  */
100 static inline adj_index_t
102 {
103  return (adj - adj_pool);
104 }
105 
107  ip_lookup_next_t adj_next_index,
108  u32 complete_next_index,
109  u32 next_index,
110  u8 *rewrite);
111 extern void adj_midchain_setup(adj_index_t adj_index,
112  adj_midchain_fixup_t fixup,
113  const void *data,
115 
117 
118 extern void adj_nbr_remove(adj_index_t ai,
119  fib_protocol_t nh_proto,
120  vnet_link_t link_type,
121  const ip46_address_t *nh_addr,
122  u32 sw_if_index);
124  u32 sw_if_index);
126  u32 sw_if_index);
127 extern void adj_midchain_teardown(ip_adjacency_t *adj);
128 
129 extern u32 adj_dpo_get_urpf(const dpo_id_t *dpo);
130 
131 /*
132  * Adj BFD
133  */
134 extern int adj_bfd_is_up (adj_index_t ai);
135 
136 /*
137  * Adj delegates
138  */
139 extern void adj_delegate_adj_deleted(ip_adjacency_t *adj);
140 extern u8* adj_delegate_format(u8* s, ip_adjacency_t *adj);
141 
142 #endif
u32 adj_dpo_get_urpf(const dpo_id_t *dpo)
Definition: adj.c:320
u32 flags
Definition: vhost_user.h:141
ip_adjacency_t * adj_pool
The global adjacency pool.
Definition: adj.c:33
void adj_glean_remove(fib_protocol_t proto, u32 sw_if_index)
Definition: adj_glean.c:130
IP unicast adjacency.
Definition: adj.h:221
vlib_node_registration_t ip6_rewrite_node
(constructor) VLIB_REGISTER_NODE (ip6_rewrite_node)
Definition: ip6_forward.c:2222
void adj_delegate_adj_deleted(ip_adjacency_t *adj)
Definition: adj_delegate.c:128
vlib_node_registration_t adj_nsh_rewrite_node
(constructor) VLIB_REGISTER_NODE (adj_nsh_rewrite_node)
Definition: adj_nsh.c:168
u8 data[128]
Definition: ipsec.api:251
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:340
unsigned char u8
Definition: types.h:56
ip_lookup_next_t
An adjacency is a representation of an attached L3 peer.
Definition: adj.h:50
ip_adjacency_t * adj_alloc(fib_protocol_t proto)
Definition: adj.c:63
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
vl_api_interface_index_t sw_if_index
Definition: gre.api:50
unsigned int u32
Definition: types.h:88
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:81
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:170
static adj_index_t adj_get_index(ip_adjacency_t *adj)
Get a pointer to an adjacency object from its index.
Definition: adj_internal.h:101
int adj_bfd_is_up(adj_index_t ai)
Definition: adj_bfd.c:239
void adj_mcast_remove(fib_protocol_t proto, u32 sw_if_index)
Definition: adj_mcast.c:177
vlib_node_registration_t ip4_rewrite_node
(constructor) VLIB_REGISTER_NODE (ip4_rewrite_node)
Definition: ip4_forward.c:2774
void(* adj_midchain_fixup_t)(vlib_main_t *vm, 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
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
#define ASSERT(truth)
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
ip46_type_t
Definition: ip6_packet.h:70
static u32 adj_get_rewrite_node(vnet_link_t linkt)
Definition: adj_internal.h:46
enum adj_flags_t_ adj_flags_t
Flags on an IP adjacency.
u8 * adj_delegate_format(u8 *s, ip_adjacency_t *adj)
Definition: adj_delegate.c:144
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:480
static vnet_link_t adj_fib_proto_2_nd(fib_protocol_t fp)
Definition: adj_internal.h:67
vlib_node_registration_t adj_l2_rewrite_node
(constructor) VLIB_REGISTER_NODE (adj_l2_rewrite_node)
Definition: adj_l2.c:169
void adj_midchain_teardown(ip_adjacency_t *adj)
adj_midchain_setup
Definition: adj_midchain.c:456
vlib_node_registration_t mpls_output_node
(constructor) VLIB_REGISTER_NODE (mpls_output_node)
Definition: mpls_output.c:365
vl_api_fib_path_nh_proto_t proto
Definition: fib_types.api:125
static ip46_type_t adj_proto_to_46(fib_protocol_t proto)
Definition: adj_internal.h:82