FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
nat44_ei_ha.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 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 NAT active-passive HA
18  */
19 
20 #ifndef __included_nat_ha_h__
21 #define __included_nat_ha_h__
22 
23 #include <vnet/vnet.h>
24 #include <vnet/ip/ip.h>
25 
26 /* Call back functions for received HA events on passive/failover */
27 typedef void (*nat_ha_sadd_cb_t) (ip4_address_t * in_addr, u16 in_port,
28  ip4_address_t * out_addr, u16 out_port,
29  ip4_address_t * eh_addr, u16 eh_port,
30  ip4_address_t * ehn_addr, u16 ehn_port,
31  u8 proto, u32 fib_index, u16 flags,
33 typedef void (*nat_ha_sdel_cb_t) (ip4_address_t * out_addr, u16 out_port,
34  ip4_address_t * eh_addr, u16 eh_port,
35  u8 proto, u32 fib_index, u32 thread_index);
36 typedef void (*nat_ha_sref_cb_t) (ip4_address_t * out_addr, u16 out_port,
37  ip4_address_t * eh_addr, u16 eh_port,
38  u8 proto, u32 fib_index, u32 total_pkts,
39  u64 total_bytes, u32 thread_index);
40 
41 /**
42  * @brief Enable NAT HA
43  */
44 void nat_ha_enable ();
45 
46 /**
47  * @brief Disable NAT HA
48  */
49 void nat_ha_disable ();
50 
51 /**
52  * @brief Initialize NAT HA
53  */
54 void nat_ha_init (vlib_main_t * vm, u32 num_workers, u32 num_threads);
55 
56 /**
57  * @brief Set HA listener (local settings)
58  *
59  * @param addr local IP4 address
60  * @param port local UDP port number
61  * @param path_mtu path MTU between local and failover
62  *
63  * @returns 0 on success, non-zero value otherwise.
64  */
66  u32 path_mtu);
67 
68 /**
69  * @brief Get HA listener/local configuration
70  */
72 
73 /**
74  * @brief Set HA failover (remote settings)
75  *
76  * @param addr failover IP4 address
77  * @param port failvoer UDP port number
78  * @param session_refresh_interval number of seconds after which to send
79  * session counters refresh
80  *
81  * @returns 0 on success, non-zero value otherwise.
82  */
84  u32 session_refresh_interval);
85 
86 /**
87  * @brief Get HA failover/remote settings
88  */
90  u32 * session_refresh_interval);
91 
92 /**
93  * @brief Create session add HA event
94  *
95  * @param in_addr inside IPv4 address
96  * @param in_port inside L4 port number
97  * @param out_addr outside IPv4 address
98  * @param out_port outside L4 port number
99  * @param eh_addr external host IPv4 address
100  * @param eh_port external host L4 port number
101  * @param ehn_addr external host IPv4 address after translation
102  * @param ehn_port external host L4 port number after translation
103  * @param proto L4 protocol
104  * @param fib_index fib index
105  * @param flags session flags
106  * @param thread_index thread index
107  * @param is_resync 1 if HA resync
108  */
109 void nat_ha_sadd (ip4_address_t * in_addr, u16 in_port,
110  ip4_address_t * out_addr, u16 out_port,
111  ip4_address_t * eh_addr, u16 eh_port,
112  ip4_address_t * ehn_addr, u16 ehn_port, u8 proto,
113  u32 fib_index, u16 flags, u32 thread_index, u8 is_resync);
114 
115 /**
116  * @brief Create session delete HA event
117  *
118  * @param out_addr outside IPv4 address
119  * @param out_port outside L4 port number
120  * @param eh_addr external host IPv4 address
121  * @param eh_port external host L4 port number
122  * @param proto L4 protocol
123  * @param fib_index fib index
124  * @param session_thread_index index of thread where this session was stored
125  */
126 void nat_ha_sdel (ip4_address_t *out_addr, u16 out_port,
127  ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index,
128  u32 session_thread_index);
129 
130 /**
131  * @brief Create session refresh HA event
132  *
133  * @param out_addr outside IPv4 address
134  * @param out_port outside L4 port number
135  * @param eh_addr external host IPv4 address
136  * @param eh_port external host L4 port number
137  * @param proto L4 protocol
138  * @param fib_index fib index
139  * @param total_pkts total packets processed
140  * @param total_bytes total bytes processed
141  * @param thread_index thread index
142  * @param last_refreshed last session refresh time
143  * @param now current time
144  */
145 void nat_ha_sref (ip4_address_t * out_addr, u16 out_port,
146  ip4_address_t * eh_addr, u16 eh_port, u8 proto,
147  u32 fib_index, u32 total_pkts, u64 total_bytes,
148  u32 thread_index, f64 * last_refreshed, f64 now);
149 
150 /**
151  * @brief Flush the current HA data (for testing)
152  */
153 void nat_ha_flush (u8 is_resync);
154 
155 typedef void (*nat_ha_resync_event_cb_t) (u32 client_index, u32 pid,
156  u32 missed_count);
157 
158 /**
159  * @brief Resync HA (resend existing sessions to new failover)
160  */
161 int nat_ha_resync (u32 client_index, u32 pid,
162  nat_ha_resync_event_cb_t event_callback);
163 
164 /**
165  * @brief Get resync status
166  *
167  * @param in_resync 1 if resync in progress
168  * @param resync_ack_missed number of missed (not ACKed) messages
169  */
170 void nat_ha_get_resync_status (u8 * in_resync, u32 * resync_ack_missed);
171 
172 #endif /* __included_nat_ha_h__ */
173 
174 /*
175  * fd.io coding-style-patch-verification: ON
176  *
177  * Local Variables:
178  * eval: (c-set-style "gnu")
179  * End:
180  */
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:492
nat_ha_enable
void nat_ha_enable()
Enable NAT HA.
Definition: nat44_ei_ha.c:443
u16
unsigned short u16
Definition: types.h:57
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
nat_ha_resync
int nat_ha_resync(u32 client_index, u32 pid, nat_ha_resync_event_cb_t event_callback)
Resync HA (resend existing sessions to new failover)
Definition: nat44_ei_ha.c:1283
port
u16 port
Definition: lb_types.api:73
nat_ha_flush
void nat_ha_flush(u8 is_resync)
Flush the current HA data (for testing)
Definition: nat44_ei_ha.c:827
addr
vhost_vring_addr_t addr
Definition: vhost_user.h:130
nat_ha_get_failover
void nat_ha_get_failover(ip4_address_t *addr, u16 *port, u32 *session_refresh_interval)
Get HA failover/remote settings.
Definition: nat44_ei_ha.c:555
pid
u32 pid
Definition: dhcp.api:164
nat_ha_get_resync_status
void nat_ha_get_resync_status(u8 *in_resync, u32 *resync_ack_missed)
Get resync status.
Definition: nat44_ei_ha.c:981
nat_ha_sref_cb_t
void(* nat_ha_sref_cb_t)(ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 total_pkts, u64 total_bytes, u32 thread_index)
Definition: nat44_ei_ha.h:36
nat_ha_sdel
void nat_ha_sdel(ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 session_thread_index)
Create session delete HA event.
Definition: nat44_ei_ha.c:860
f64
double f64
Definition: types.h:142
nat_ha_sref
void nat_ha_sref(ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 total_pkts, u64 total_bytes, u32 thread_index, f64 *last_refreshed, f64 now)
Create session refresh HA event.
Definition: nat44_ei_ha.c:879
nat_ha_sdel_cb_t
void(* nat_ha_sdel_cb_t)(ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 fib_index, u32 thread_index)
Definition: nat44_ei_ha.h:33
ip4_address_t
Definition: ip4_packet.h:50
u64
unsigned long u64
Definition: types.h:89
nat_ha_sadd
void nat_ha_sadd(ip4_address_t *in_addr, u16 in_port, ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, ip4_address_t *ehn_addr, u16 ehn_port, u8 proto, u32 fib_index, u16 flags, u32 thread_index, u8 is_resync)
Create session add HA event.
Definition: nat44_ei_ha.c:834
ip.h
nat_ha_sadd_cb_t
void(* nat_ha_sadd_cb_t)(ip4_address_t *in_addr, u16 in_port, ip4_address_t *out_addr, u16 out_port, ip4_address_t *eh_addr, u16 eh_port, ip4_address_t *ehn_addr, u16 ehn_port, u8 proto, u32 fib_index, u16 flags, u32 thread_index)
Definition: nat44_ei_ha.h:27
u32
unsigned int u32
Definition: types.h:88
nat_ha_init
void nat_ha_init(vlib_main_t *vm, u32 num_workers, u32 num_threads)
Initialize NAT HA.
Definition: nat44_ei_ha.c:473
now
f64 now
Definition: nat44_ei_out2in.c:710
vlib_main_t
Definition: main.h:102
nat_ha_resync_event_cb_t
void(* nat_ha_resync_event_cb_t)(u32 client_index, u32 pid, u32 missed_count)
Definition: nat44_ei_ha.h:155
u8
unsigned char u8
Definition: types.h:56
nat_ha_disable
void nat_ha_disable()
Disable NAT HA.
Definition: nat44_ei_ha.c:450
vnet.h
nat_ha_set_listener
int nat_ha_set_listener(vlib_main_t *vm, ip4_address_t *addr, u16 port, u32 path_mtu)
Set HA listener (local settings)
Definition: nat44_ei_ha.c:495
proto
vl_api_ip_proto_t proto
Definition: acl_types.api:51
path_mtu
u16 path_mtu
Definition: ip.api:783
nat_ha_set_failover
int nat_ha_set_failover(vlib_main_t *vm, ip4_address_t *addr, u16 port, u32 session_refresh_interval)
Set HA failover (remote settings)
Definition: nat44_ei_ha.c:540
nat_ha_get_listener
void nat_ha_get_listener(ip4_address_t *addr, u16 *port, u32 *path_mtu)
Get HA listener/local configuration.
Definition: nat44_ei_ha.c:530
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105