FD.io VPP  v18.10-34-gcce845e
Vector Packet Processing
gbp_endpoint.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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 __GBP_ENDPOINT_H__
17 #define __GBP_ENDPOINT_H__
18 
19 #include <plugins/gbp/gbp_types.h>
20 #include <vnet/ip/ip.h>
22 
23 #include <vppinfra/bihash_16_8.h>
25 #include <vppinfra/bihash_24_8.h>
27 
28 /**
29  * Flags for each endpoint
30  */
32 {
37 
38 /**
39  * A Group Based Policy Endpoint.
40  * This is typically a VM or container. If the endpoint is local (i.e. on
41  * the same compute node as VPP) then there is one interface per-endpoint.
42  * If the EP is remote,e.g. reachable over a [vxlan] tunnel, then there
43  * will be multiple EPs reachable over the tunnel and they can be distinguished
44  * via either their MAC or IP Address[es].
45  */
46 typedef struct gbp_endpoint_t_
47 {
48  /**
49  * The interface on which the EP is connected
50  */
52 
53  /**
54  * A vector of ip addresses that below to the endpoint
55  */
56  ip46_address_t *ge_ips;
57 
58  /**
59  * MAC address of the endpoint
60  */
62 
63  /**
64  * The endpoint's designated EPG
65  */
67 
68  /**
69  * Endpoint flags
70  */
73 
74 extern u8 *format_gbp_endpoint (u8 * s, va_list * args);
75 
76 /**
77  * Interface to source EPG DB - a per-interface vector
78  */
79 typedef struct gbp_ep_by_itf_db_t_
80 {
83 
84 typedef struct gbp_ep_by_ip_itf_db_t_
85 {
86  clib_bihash_24_8_t gte_table;
88 
90 {
91  clib_bihash_16_8_t gte_table;
93 
95  const ip46_address_t * ip,
96  const mac_address_t * mac,
97  epg_id_t epg_id, u32 * handle);
98 extern void gbp_endpoint_delete (u32 handle);
99 
100 typedef walk_rc_t (*gbp_endpoint_cb_t) (gbp_endpoint_t * gbpe, void *ctx);
101 extern void gbp_endpoint_walk (gbp_endpoint_cb_t cb, void *ctx);
102 
103 
104 /**
105  * DP functions and databases
106  */
111 
112 /**
113  * Get the endpoint from a port/interface
114  */
117 {
118  return (pool_elt_at_index (gbp_endpoint_pool, gbpei));
119 }
120 
123 {
124  return (gbp_endpoint_get (gbp_ep_by_itf_db.gte_vec[sw_if_index]));
125 }
126 
127 #endif
128 
129 /*
130  * fd.io coding-style-patch-verification: ON
131  *
132  * Local Variables:
133  * eval: (c-set-style "gnu")
134  * End:
135  */
u32 ge_sw_if_index
The interface on which the EP is connected.
Definition: gbp_endpoint.h:51
u16 epg_id_t
Definition: gbp_types.h:21
static gbp_endpoint_t * gbp_endpoint_get(index_t gbpei)
Get the endpoint from a port/interface.
Definition: gbp_endpoint.h:116
A Group Based Policy Endpoint.
Definition: gbp_endpoint.h:46
struct gbp_ep_by_ip_itf_db_t_ gbp_ep_by_ip_itf_db_t
gbp_ep_by_itf_db_t gbp_ep_by_itf_db
DP functions and databases.
Definition: gbp_endpoint.c:26
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:41
void gbp_endpoint_delete(u32 handle)
Definition: gbp_endpoint.c:334
mac_address_t ge_mac
MAC address of the endpoint.
Definition: gbp_endpoint.h:61
gbp_endpoint_flags_t_
Flags for each endpoint.
Definition: gbp_endpoint.h:31
unsigned char u8
Definition: types.h:56
enum walk_rc_t_ walk_rc_t
Walk return code.
gbp_ep_by_mac_itf_db_t gbp_ep_by_mac_itf_db
Definition: gbp_endpoint.c:27
clib_bihash_24_8_t gte_table
Definition: gbp_endpoint.h:86
u32 sw_if_index
Definition: vxlan_gbp.api:39
#define always_inline
Definition: clib.h:94
gbp_endpoint_t * gbp_endpoint_pool
Pool of GBP endpoints.
Definition: gbp_endpoint.c:33
struct gbp_ep_by_itf_db_t_ gbp_ep_by_itf_db_t
Interface to source EPG DB - a per-interface vector.
unsigned int u32
Definition: types.h:88
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:464
long ctx[MAX_CONNS]
Definition: main.c:144
u16 epg_id
Definition: gbp.api:30
clib_bihash_16_8_t gte_table
Definition: gbp_endpoint.h:91
Interface to source EPG DB - a per-interface vector.
Definition: gbp_endpoint.h:79
u8 * format_gbp_endpoint(u8 *s, va_list *args)
Definition: gbp_endpoint.c:458
ip46_address_t * ge_ips
A vector of ip addresses that below to the endpoint.
Definition: gbp_endpoint.h:56
static gbp_endpoint_t * gbp_endpoint_get_itf(u32 sw_if_index)
Definition: gbp_endpoint.h:122
struct gbp_ep_by_mac_itf_db_t_ gbp_ep_by_mac_itf_db_t
walk_rc_t(* gbp_endpoint_cb_t)(gbp_endpoint_t *gbpe, void *ctx)
Definition: gbp_endpoint.h:100
struct gbp_endpoint_t_ gbp_endpoint_t
A Group Based Policy Endpoint.
enum gbp_endpoint_flags_t_ gbp_endpoint_flags_t
Flags for each endpoint.
void gbp_endpoint_walk(gbp_endpoint_cb_t cb, void *ctx)
Definition: gbp_endpoint.c:363
epg_id_t ge_epg_id
The endpoint&#39;s designated EPG.
Definition: gbp_endpoint.h:66
gbp_ep_by_ip_itf_db_t gbp_ep_by_ip_itf_db
Definition: gbp_endpoint.c:28
gbp_endpoint_flags_t ge_flags
Endpoint flags.
Definition: gbp_endpoint.h:71
vl_api_mac_address_t mac
Definition: gbp.api:31
int gbp_endpoint_update(u32 sw_if_index, const ip46_address_t *ip, const mac_address_t *mac, epg_id_t epg_id, u32 *handle)
Definition: gbp_endpoint.c:236