FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
vrrp_api.c
Go to the documentation of this file.
1 /*
2  * vrrp.c - vpp vrrp plug-in
3  *
4  * Copyright 2019-2020 Rubicon Communications, LLC (Netgate)
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  *
8  */
9 
10 #include <vnet/vnet.h>
11 #include <vnet/plugin/plugin.h>
12 #include <vrrp/vrrp.h>
13 
14 #include <vlibapi/api.h>
15 #include <vlibmemory/api.h>
16 #include <vpp/app/version.h>
17 
18 /* define message IDs */
19 #include <vnet/format_fns.h>
20 #include <vrrp/vrrp.api_enum.h>
21 #include <vrrp/vrrp.api_types.h>
22 
23 #define REPLY_MSG_ID_BASE vrrp_main.msg_id_base
25 
26 /* API message handlers */
27 static void
29 {
30  vl_api_vrrp_vr_add_del_reply_t *rmp;
31  vrrp_vr_config_t vr_conf;
32  u32 api_flags;
33  ip46_address_t *addrs = 0;
34  int rv;
35 
37 
38  api_flags = htonl (mp->flags);
39 
40  clib_memset (&vr_conf, 0, sizeof (vr_conf));
41 
42  vr_conf.sw_if_index = ntohl (mp->sw_if_index);
43  vr_conf.vr_id = mp->vr_id;
44  vr_conf.priority = mp->priority;
45  vr_conf.adv_interval = ntohs (mp->interval);
46 
47  if (api_flags & VRRP_API_VR_PREEMPT)
48  vr_conf.flags |= VRRP_VR_PREEMPT;
49 
50  if (api_flags & VRRP_API_VR_ACCEPT)
51  vr_conf.flags |= VRRP_VR_ACCEPT;
52 
53  if (api_flags & VRRP_API_VR_UNICAST)
54  vr_conf.flags |= VRRP_VR_UNICAST;
55 
56  if (api_flags & VRRP_API_VR_IPV6)
57  vr_conf.flags |= VRRP_VR_IPV6;
58 
59  if (mp->is_add)
60  {
61  int i;
62 
63  for (i = 0; i < mp->n_addrs; i++)
64  {
65  ip46_address_t *addr;
66  void *src, *dst;
67  int len;
68 
69  vec_add2 (addrs, addr, 1);
70 
71  if (ntohl (mp->addrs[i].af) == ADDRESS_IP4)
72  {
73  src = &mp->addrs[i].un.ip4;
74  dst = &addr->ip4;
75  len = sizeof (addr->ip4);
76  }
77  else
78  {
79  src = &mp->addrs[i].un.ip6;
80  dst = &addr->ip6;
81  len = sizeof (addr->ip6);
82  }
83 
84  clib_memcpy (dst, src, len);
85  }
86 
87  vr_conf.vr_addrs = addrs;
88  }
89 
90  if (vr_conf.priority == 0)
91  {
92  clib_warning ("VR priority must be > 0");
93  rv = VNET_API_ERROR_INVALID_VALUE;
94  }
95  else if (vr_conf.adv_interval == 0)
96  {
97  clib_warning ("VR advertisement interval must be > 0");
98  rv = VNET_API_ERROR_INVALID_VALUE;
99  }
100  else if (vr_conf.vr_id == 0)
101  {
102  clib_warning ("VR ID must be > 0");
103  rv = VNET_API_ERROR_INVALID_VALUE;
104  }
105  else
106  rv = vrrp_vr_add_del (mp->is_add, &vr_conf);
107 
108  vec_free (addrs);
109 
111  REPLY_MACRO (VL_API_VRRP_VR_ADD_DEL_REPLY);
112 }
113 
114 static vl_api_vrrp_vr_state_t
116 {
117  if (vr_state == VRRP_VR_STATE_BACKUP)
119  if (vr_state == VRRP_VR_STATE_MASTER)
121  if (vr_state == VRRP_VR_STATE_INTF_DOWN)
123 
124  return VRRP_API_VR_STATE_INIT;
125 }
126 
127 static void
129  u32 context)
130 {
131  vrrp_main_t *vmp = &vrrp_main;
133  int n_addrs, msg_size;
134  ip46_address_t *addr;
135  vl_api_address_t *api_addr;
136  u32 api_flags = 0;
137 
138  n_addrs = vec_len (vr->config.vr_addrs);
139  msg_size = sizeof (*mp) + n_addrs * sizeof (*api_addr);
140  mp = vl_msg_api_alloc (msg_size);
141  if (!mp)
142  return;
143  clib_memset (mp, 0, msg_size);
144  mp->_vl_msg_id = htons (VL_API_VRRP_VR_DETAILS + vmp->msg_id_base);
145  mp->context = context;
146 
147  /* config */
148  mp->config.sw_if_index = htonl (vr->config.sw_if_index);
149  mp->config.vr_id = vr->config.vr_id;
150  mp->config.priority = vr->config.priority;
151  mp->config.interval = htons (vr->config.adv_interval);
152 
153  if (vr->config.flags & VRRP_VR_PREEMPT)
154  api_flags |= VRRP_API_VR_PREEMPT;
155  if (vr->config.flags & VRRP_VR_ACCEPT)
156  api_flags |= VRRP_API_VR_ACCEPT;
157  if (vrrp_vr_is_unicast (vr))
158  api_flags |= VRRP_API_VR_UNICAST;
159  if (vrrp_vr_is_ipv6 (vr))
160  api_flags |= VRRP_API_VR_IPV6;
161 
162  mp->config.flags = htonl (api_flags);
163 
164  /* runtime */
165  mp->runtime.state = htonl (vrrp_vr_state_encode (vr->runtime.state));
166 
167  mp->runtime.master_adv_int = htons (vr->runtime.master_adv_int);
168  mp->runtime.skew = htons (vr->runtime.skew);
169  mp->runtime.master_down_int = htons (vr->runtime.master_down_int);
170  clib_memcpy (&mp->runtime.mac, &vr->runtime.mac, sizeof (vr->runtime.mac));
171 
172  mp->runtime.tracking.interfaces_dec = htonl (vr->tracking.interfaces_dec);
173  mp->runtime.tracking.priority = vrrp_vr_priority (vr);
174 
175  /* addrs */
176  mp->n_addrs = vec_len (vr->config.vr_addrs);
177  api_addr = mp->addrs;
179  {
180  void *src, *dst;
181  size_t len;
182 
183  if (vrrp_vr_is_ipv6 (vr))
184  {
185  api_addr->af = ADDRESS_IP6;
186  dst = &api_addr->un.ip6;
187  src = &addr->ip6;
188  len = sizeof (addr->ip6);
189  }
190  else
191  {
192  api_addr->af = ADDRESS_IP4;
193  dst = &api_addr->un.ip4;
194  src = &addr->ip4;
195  len = sizeof (addr->ip4);
196  }
197  clib_memcpy (dst, src, len);
198  api_addr++;
199  }
200 
201  vl_api_send_msg (reg, (u8 *) mp);
202 }
203 
204 static void
206 {
207  vrrp_main_t *vmp = &vrrp_main;
209  vrrp_vr_t *vr;
211 
213  if (!reg)
214  return;
215 
216  sw_if_index = htonl (mp->sw_if_index);
217 
218  /* *INDENT-OFF* */
219  pool_foreach (vr, vmp->vrs) {
220 
221  if (sw_if_index && (sw_if_index != ~0) &&
222  (sw_if_index != vr->config.sw_if_index))
223  continue;
224 
225  send_vrrp_vr_details (vr, reg, mp->context);
226  }
227  /* *INDENT-ON* */
228 }
229 
230 static void
232 {
233  vl_api_vrrp_vr_start_stop_reply_t *rmp;
234  vrrp_vr_key_t vr_key;
235  int rv;
236 
237  clib_memset (&vr_key, 0, sizeof (vr_key));
238 
239  vr_key.sw_if_index = ntohl (mp->sw_if_index);
240  vr_key.vr_id = mp->vr_id;
241  vr_key.is_ipv6 = (mp->is_ipv6 != 0);
242 
243  rv = vrrp_vr_start_stop ((mp->is_start != 0), &vr_key);
244 
245  REPLY_MACRO (VL_API_VRRP_VR_START_STOP_REPLY);
246 }
247 
248 static void
250 {
251  vl_api_vrrp_vr_set_peers_reply_t *rmp;
252  vrrp_vr_key_t vr_key;
253  ip46_address_t *peer_addrs = 0;
254  int i;
255  int rv;
256 
257  clib_memset (&vr_key, 0, sizeof (vr_key));
258 
259  vr_key.sw_if_index = ntohl (mp->sw_if_index);
260  vr_key.vr_id = mp->vr_id;
261  vr_key.is_ipv6 = (mp->is_ipv6 != 0);
262 
263  for (i = 0; i < mp->n_addrs; i++)
264  {
265  ip46_address_t *peer;
266 
267  vec_add2 (peer_addrs, peer, 1);
268 
269  if (mp->is_ipv6)
270  clib_memcpy (&peer->ip6, mp->addrs[i].un.ip6, 16);
271  else
272  clib_memcpy (&peer->ip4, mp->addrs[i].un.ip4, 4);
273  }
274 
275  rv = vrrp_vr_set_peers (&vr_key, peer_addrs);
276 
277  vec_free (peer_addrs);
278  REPLY_MACRO (VL_API_VRRP_VR_SET_PEERS_REPLY);
279 }
280 
281 static void
283  u32 context)
284 {
285  vrrp_main_t *vmp = &vrrp_main;
287  int n_addrs, msg_size;
288  ip46_address_t *addr;
289  vl_api_address_t *api_addr;
290 
291  n_addrs = vec_len (vr->config.peer_addrs);
292  msg_size = sizeof (*mp) + n_addrs * sizeof (*api_addr);
293  mp = vl_msg_api_alloc (msg_size);
294  if (!mp)
295  return;
296  clib_memset (mp, 0, msg_size);
297  mp->_vl_msg_id = htons (VL_API_VRRP_VR_PEER_DETAILS + vmp->msg_id_base);
298  mp->context = context;
299 
300  mp->sw_if_index = htonl (vr->config.sw_if_index);
301  mp->vr_id = vr->config.vr_id;
302  mp->is_ipv6 = vrrp_vr_is_ipv6 (vr);
303 
304  /* addrs */
305  mp->n_peer_addrs = n_addrs;
306  api_addr = mp->peer_addrs;
308  {
309  void *src, *dst;
310  size_t len;
311 
312  if (vrrp_vr_is_ipv6 (vr))
313  {
314  api_addr->af = ADDRESS_IP6;
315  dst = &api_addr->un.ip6;
316  src = &addr->ip6;
317  len = sizeof (addr->ip6);
318  }
319  else
320  {
321  api_addr->af = ADDRESS_IP4;
322  dst = &api_addr->un.ip4;
323  src = &addr->ip4;
324  len = sizeof (addr->ip4);
325  }
326  clib_memcpy (dst, src, len);
327  api_addr++;
328  }
329 
330  vl_api_send_msg (reg, (u8 *) mp);
331 }
332 
333 static void
335 {
336  vrrp_main_t *vmp = &vrrp_main;
338  vrrp_vr_t *vr;
339  vrrp_vr_key_t vr_key;
340 
342  if (!reg)
343  return;
344 
345  vr_key.sw_if_index = ntohl (mp->sw_if_index);
346 
347  if (vr_key.sw_if_index && (vr_key.sw_if_index != ~0))
348  {
349  uword *p;
350  u32 vr_index = ~0;
351 
352  vr_key.vr_id = mp->vr_id;
353  vr_key.is_ipv6 = mp->is_ipv6;
354 
355  p = mhash_get (&vmp->vr_index_by_key, &vr_key);
356  if (!p)
357  return;
358 
359  vr_index = p[0];
360  vr = pool_elt_at_index (vmp->vrs, vr_index);
361  send_vrrp_vr_peer_details (vr, reg, mp->context);
362 
363  return;
364  }
365 
366  /* *INDENT-OFF* */
367  pool_foreach (vr, vmp->vrs) {
368 
369  if (!vec_len (vr->config.peer_addrs))
370  continue;
371 
372  send_vrrp_vr_details (vr, reg, mp->context);
373 
374  }
375  /* *INDENT-ON* */
376 }
377 
378 static void
381 {
382  vl_api_vrrp_vr_track_if_add_del_reply_t *rmp;
383  vrrp_vr_t *vr;
384  vrrp_vr_tracking_if_t *track_if, *track_ifs = 0;
385  int rv = 0, i;
386 
387  /* lookup VR and return error if it does not exist */
388  vr =
389  vrrp_vr_lookup (ntohl (mp->sw_if_index), mp->vr_id, (mp->is_ipv6 != 0));
390  if (!vr)
391  {
392  rv = VNET_API_ERROR_INVALID_VALUE;
393  goto done;
394  }
395 
396  for (i = 0; i < mp->n_ifs; i++)
397  {
398  vl_api_vrrp_vr_track_if_t *api_track_if = &mp->ifs[i];
399 
400  vec_add2 (track_ifs, track_if, 1);
401  track_if->sw_if_index = ntohl (api_track_if->sw_if_index);
402  track_if->priority = api_track_if->priority;
403  }
404 
405  rv = vrrp_vr_tracking_ifs_add_del (vr, track_ifs, mp->is_add != 0);
406 
407 done:
408  vec_free (track_ifs);
409  REPLY_MACRO (VL_API_VRRP_VR_TRACK_IF_ADD_DEL_REPLY);
410 }
411 
412 static void
414  u32 context)
415 {
416  vrrp_main_t *vmp = &vrrp_main;
418  int n_ifs, msg_size;
419  vl_api_vrrp_vr_track_if_t *api_track_if;
420  vrrp_vr_tracking_if_t *track_if;
421 
422  if (!vr)
423  return;
424 
425  n_ifs = vec_len (vr->tracking.interfaces);
426  msg_size = sizeof (*mp) + n_ifs * sizeof (*api_track_if);
427  mp = vl_msg_api_alloc (msg_size);
428  if (!mp)
429  return;
430  clib_memset (mp, 0, msg_size);
431  mp->_vl_msg_id = htons (VL_API_VRRP_VR_TRACK_IF_DETAILS + vmp->msg_id_base);
432  mp->context = context;
433 
434  mp->sw_if_index = htonl (vr->config.sw_if_index);
435  mp->vr_id = vr->config.vr_id;
436  mp->is_ipv6 = vrrp_vr_is_ipv6 (vr);
437 
438  /* tracked interfaces */
439  mp->n_ifs = n_ifs;
440  api_track_if = mp->ifs;
441  vec_foreach (track_if, vr->tracking.interfaces)
442  {
443  api_track_if->sw_if_index = htonl (track_if->sw_if_index);
444  api_track_if->priority = track_if->priority;
445  api_track_if += 1;
446  }
447 
448  vl_api_send_msg (reg, (u8 *) mp);
449 }
450 
451 static void
453 {
454  vrrp_main_t *vmp = &vrrp_main;
456  vrrp_vr_t *vr;
457 
459  if (!reg)
460  return;
461 
462  if (!mp->dump_all)
463  {
464  vr = vrrp_vr_lookup (ntohl (mp->sw_if_index), mp->vr_id, mp->is_ipv6);
465  send_vrrp_vr_track_if_details (vr, reg, mp->context);
466 
467  return;
468  }
469 
470  /* *INDENT-OFF* */
471  pool_foreach (vr, vmp->vrs) {
472 
473  if (!vec_len (vr->tracking.interfaces))
474  continue;
475 
476  send_vrrp_vr_track_if_details (vr, reg, mp->context);
477 
478  }
479  /* *INDENT-ON* */
480 }
481 
482 static void
484  vl_api_registration_t * vl_reg,
485  vrrp_vr_t * vr, vrrp_vr_state_t new_state)
486 {
487  vrrp_main_t *vmp = &vrrp_main;
489 
490  mp = vl_msg_api_alloc (sizeof (*mp));
491 
492  clib_memset (mp, 0, sizeof (*mp));
493  mp->_vl_msg_id = ntohs (VL_API_VRRP_VR_EVENT + vmp->msg_id_base);
494  mp->client_index = reg->client_index;
495  mp->pid = reg->client_pid;
496  mp->vr.sw_if_index = ntohl (vr->config.sw_if_index);
497  mp->vr.vr_id = vr->config.vr_id;
498  mp->vr.is_ipv6 = ((vr->config.flags & VRRP_VR_IPV6) != 0);
499 
500  mp->old_state = htonl (vrrp_vr_state_encode (vr->runtime.state));
501  mp->new_state = htonl (vrrp_vr_state_encode (new_state));
502 
503  vl_api_send_msg (vl_reg, (u8 *) mp);
504 }
505 
506 void
508 {
511  vl_api_registration_t *vl_reg;
512 
513  /* *INDENT-OFF* */
514  pool_foreach (reg, vam->vrrp_vr_events_registrations)
515  {
517  if (vl_reg)
518  send_vrrp_vr_event (reg, vl_reg, vr, new_state);
519  }
520  /* *INDENT-ON* */
521 }
522 
523 pub_sub_handler (vrrp_vr_events, VRRP_VR_EVENTS);
524 
525 /* Set up the API message handling tables */
526 #include <vrrp/vrrp.api.c>
527 clib_error_t *
529 {
530  vrrp_main_t *vmp = &vrrp_main;
531 
532  /* Ask for a correctly-sized block of API message decode slots */
534 
535  return 0;
536 }
537 
538 /* *INDENT-ON* */
539 
540 /*
541  * fd.io coding-style-patch-verification: ON
542  *
543  * Local Variables:
544  * eval: (c-set-style "gnu")
545  * End:
546  */
vl_api_vrrp_vr_set_peers_t
VRRP: set unicast peers for a VR.
Definition: vrrp.api:137
send_vrrp_vr_details
static void send_vrrp_vr_details(vrrp_vr_t *vr, vl_api_registration_t *reg, u32 context)
Definition: vrrp_api.c:128
vl_api_vrrp_vr_peer_details_t::context
u32 context
Definition: vrrp.api:172
vl_api_vrrp_vr_event_t
Notification about VRRP VR state change event.
Definition: vrrp.api:253
vl_api_vrrp_vr_details_t::context
u32 context
Definition: vrrp.api:104
vl_api_vrrp_vr_add_del_t::interval
u16 interval
Definition: vrrp.api:57
VALIDATE_SW_IF_INDEX
#define VALIDATE_SW_IF_INDEX(mp)
Definition: api_helper_macros.h:281
vl_api_client_index_to_registration
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
vl_api_vrrp_vr_add_del_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: vrrp.api:54
api.h
vl_api_vrrp_vr_peer_dump_t::vr_id
u8 vr_id
Definition: vrrp.api:159
vrrp_vr_config
Definition: vrrp.h:69
vrrp_vr
Definition: vrrp.h:106
vl_api_vrrp_vr_start_stop_t_handler
static void vl_api_vrrp_vr_start_stop_t_handler(vl_api_vrrp_vr_start_stop_t *mp)
Definition: vrrp_api.c:231
vrrp_vr::config
vrrp_vr_config_t config
Definition: vrrp.h:108
vl_api_vrrp_vr_track_if_dump_t::context
u32 context
Definition: vrrp.api:221
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
VRRP_API_VR_ACCEPT
@ VRRP_API_VR_ACCEPT
Definition: vrrp.api:24
vl_api_vrrp_vr_peer_details_t::n_peer_addrs
u8 n_peer_addrs
Definition: vrrp.api:176
vl_api_vrrp_vr_track_if_details_t::is_ipv6
u8 is_ipv6
Definition: vrrp.api:241
vrrp_vr_config::vr_addrs
ip46_address_t * vr_addrs
Definition: vrrp.h:76
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
vl_api_vrrp_vr_track_if_add_del_t::is_add
u8 is_add
Definition: vrrp.api:206
vl_api_vrrp_vr_track_if_add_del_t::is_ipv6
u8 is_ipv6
Definition: vrrp.api:204
vrrp_vr_config::peer_addrs
ip46_address_t * peer_addrs
Definition: vrrp.h:77
vl_api_send_msg
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
vrrp_vr_runtime::master_down_int
u16 master_down_int
Definition: vrrp.h:99
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
vl_api_vrrp_vr_peer_details_t::peer_addrs
vl_api_address_t peer_addrs[n_peer_addrs]
Definition: vrrp.api:177
vl_api_vrrp_vr_add_del_t
VRRP: Add or delete a VRRP virtual router.
Definition: vrrp.api:50
VRRP_API_VR_STATE_BACKUP
@ VRRP_API_VR_STATE_BACKUP
Definition: vrrp.api:77
VRRP_VR_UNICAST
@ VRRP_VR_UNICAST
Definition: vrrp.h:25
vpe_api_main_t
Definition: api_helper_macros.h:414
vl_api_vrrp_vr_track_if_add_del_t::n_ifs
u8 n_ifs
Definition: vrrp.api:207
vrrp_plugin_api_hookup
clib_error_t * vrrp_plugin_api_hookup(vlib_main_t *vm)
Definition: vrrp_api.c:528
vl_api_vrrp_vr_track_if_add_del_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: vrrp.api:203
vl_api_vrrp_vr_dump_t::client_index
u32 client_index
Definition: vrrp.api:69
vl_api_vrrp_vr_track_if_add_del_t::ifs
vl_api_vrrp_vr_track_if_t ifs[n_ifs]
Definition: vrrp.api:208
vrrp_vr_config::flags
vrrp_vr_flags_t flags
Definition: vrrp.h:75
mhash_get
static uword * mhash_get(mhash_t *h, const void *key)
Definition: mhash.h:110
VRRP_VR_ACCEPT
@ VRRP_VR_ACCEPT
Definition: vrrp.h:24
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
api.h
vrrp_vr::runtime
vrrp_vr_runtime_t runtime
Definition: vrrp.h:109
vrrp_vr_is_ipv6
static u8 vrrp_vr_is_ipv6(vrrp_vr_t *vr)
Definition: vrrp.h:312
vrrp_main_t::vr_index_by_key
mhash_t vr_index_by_key
Definition: vrrp.h:161
vl_api_vrrp_vr_track_if_details_t::context
u32 context
Definition: vrrp.api:238
vrrp_vr_tracking_if
Definition: vrrp.h:57
vrrp_vr_state_encode
static vl_api_vrrp_vr_state_t vrrp_vr_state_encode(vrrp_vr_state_t vr_state)
Definition: vrrp_api.c:115
vl_api_vrrp_vr_track_if_details_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: vrrp.api:239
vrrp_vr_config::priority
u8 priority
Definition: vrrp.h:73
addr
vhost_vring_addr_t addr
Definition: vhost_user.h:130
vrrp_vr_tracking_if::priority
u8 priority
Definition: vrrp.h:60
vl_api_vrrp_vr_event_t::old_state
vl_api_vrrp_vr_state_t old_state
Definition: vrrp.api:258
ADDRESS_IP6
@ ADDRESS_IP6
Definition: ip_types.api:23
vl_api_vrrp_vr_dump_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: vrrp.api:71
vrrp_vr_event
void vrrp_vr_event(vrrp_vr_t *vr, vrrp_vr_state_t new_state)
Definition: vrrp_api.c:507
vl_api_vrrp_vr_add_del_t::priority
u8 priority
Definition: vrrp.api:56
vrrp_vr_is_unicast
static u8 vrrp_vr_is_unicast(vrrp_vr_t *vr)
Definition: vrrp.h:318
VRRP_API_VR_STATE_MASTER
@ VRRP_API_VR_STATE_MASTER
Definition: vrrp.api:78
vl_api_vrrp_vr_peer_details_t::is_ipv6
u8 is_ipv6
Definition: vrrp.api:175
vl_api_vrrp_vr_track_if_details_t
VRRP: VR interface tracking dump response.
Definition: vrrp.api:236
vl_api_vrrp_vr_peer_dump_t::is_ipv6
u8 is_ipv6
Definition: vrrp.api:158
vl_api_vrrp_vr_start_stop_t::is_ipv6
u8 is_ipv6
Definition: vrrp.api:124
vl_api_vrrp_vr_track_if_add_del_t_handler
static void vl_api_vrrp_vr_track_if_add_del_t_handler(vl_api_vrrp_vr_track_if_add_del_t *mp)
Definition: vrrp_api.c:380
vl_api_vrrp_vr_peer_dump_t
VRRP: dump virtual router peer address data.
Definition: vrrp.api:154
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: bfd_api.c:451
vl_api_vrrp_vr_track_if_dump_t::client_index
u32 client_index
Definition: vrrp.api:220
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
VRRP_API_VR_STATE_INTF_DOWN
@ VRRP_API_VR_STATE_INTF_DOWN
Definition: vrrp.api:79
VRRP_API_VR_STATE_INIT
@ VRRP_API_VR_STATE_INIT
Definition: vrrp.api:76
len
u8 len
Definition: ip_types.api:103
vec_add2
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:644
vl_api_vrrp_vr_details_t::config
vl_api_vrrp_vr_conf_t config
Definition: vrrp.api:105
vl_api_vrrp_vr_peer_dump_t::client_index
u32 client_index
Definition: vrrp.api:155
vl_api_vrrp_vr_details_t::addrs
vl_api_address_t addrs[n_addrs]
Definition: vrrp.api:108
vl_api_vrrp_vr_details_t::n_addrs
u8 n_addrs
Definition: vrrp.api:107
vl_api_registration_
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
vl_api_vrrp_vr_event_t::vr
vl_api_vrrp_vr_key_t vr
Definition: vrrp.api:257
REPLY_MACRO
#define REPLY_MACRO(t)
Definition: api_helper_macros.h:30
vl_api_vrrp_vr_set_peers_t::is_ipv6
u8 is_ipv6
Definition: vrrp.api:142
vpe_client_registration_t::client_pid
u32 client_pid
Definition: api_helper_macros.h:411
vl_api_vrrp_vr_details_t
VRRP: VR dump response.
Definition: vrrp.api:103
vl_api_vrrp_vr_peer_details_t::vr_id
u8 vr_id
Definition: vrrp.api:174
vl_api_vrrp_vr_dump_t_handler
static void vl_api_vrrp_vr_dump_t_handler(vl_api_vrrp_vr_dump_t *mp)
Definition: vrrp_api.c:205
vrrp_vr_set_peers
int vrrp_vr_set_peers(vrrp_vr_key_t *vr_key, ip46_address_t *peers)
Definition: vrrp.c:803
vl_api_vrrp_vr_start_stop_t::is_start
u8 is_start
Definition: vrrp.api:125
peer
vl_api_address_t peer
Definition: teib.api:28
vrrp_vr_key::sw_if_index
u32 sw_if_index
Definition: vrrp.h:31
vrrp.h
vrrp_vr_runtime::master_adv_int
u16 master_adv_int
Definition: vrrp.h:97
VRRP_API_VR_PREEMPT
@ VRRP_API_VR_PREEMPT
Definition: vrrp.api:23
uword
u64 uword
Definition: types.h:112
vrrp_vr_tracking_if::sw_if_index
u32 sw_if_index
Definition: vrrp.h:59
send_vrrp_vr_track_if_details
static void send_vrrp_vr_track_if_details(vrrp_vr_t *vr, vl_api_registration_t *reg, u32 context)
Definition: vrrp_api.c:413
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
vl_api_vrrp_vr_start_stop_t::vr_id
u8 vr_id
Definition: vrrp.api:123
vl_api_vrrp_vr_set_peers_t::addrs
vl_api_address_t addrs[n_addrs]
Definition: vrrp.api:144
vl_api_vrrp_vr_peer_dump_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: vrrp.api:157
vl_api_vrrp_vr_track_if_dump_t
VRRP: dump virtual router interface tracking data.
Definition: vrrp.api:219
src
vl_api_address_t src
Definition: gre.api:54
vrrp_vr::tracking
vrrp_vr_tracking_t tracking
Definition: vrrp.h:110
vrrp_main_t
Definition: vrrp.h:145
vl_api_vrrp_vr_event_t::client_index
u32 client_index
Definition: vrrp.api:255
VRRP_VR_IPV6
@ VRRP_VR_IPV6
Definition: vrrp.h:26
vrrp_vr_state_t
enum vrrp_vr_state vrrp_vr_state_t
vl_api_vrrp_vr_peer_details_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: vrrp.api:173
vrrp_vr_lookup
static vrrp_vr_t * vrrp_vr_lookup(u32 sw_if_index, u8 vr_id, u8 is_ipv6)
Definition: vrrp.h:231
vrrp_vr_runtime::state
vrrp_vr_state_t state
Definition: vrrp.h:96
vl_api_vrrp_vr_track_if_dump_t::vr_id
u8 vr_id
Definition: vrrp.api:224
vrrp_vr_runtime::mac
mac_address_t mac
Definition: vrrp.h:100
BAD_SW_IF_INDEX_LABEL
#define BAD_SW_IF_INDEX_LABEL
Definition: api_helper_macros.h:289
plugin.h
vl_api_vrrp_vr_track_if_details_t::n_ifs
u8 n_ifs
Definition: vrrp.api:242
vl_api_vrrp_vr_track_if_details_t::ifs
vl_api_vrrp_vr_track_if_t ifs[n_ifs]
Definition: vrrp.api:243
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
send_vrrp_vr_peer_details
static void send_vrrp_vr_peer_details(vrrp_vr_t *vr, vl_api_registration_t *reg, u32 context)
Definition: vrrp_api.c:282
vl_api_vrrp_vr_add_del_t::vr_id
u8 vr_id
Definition: vrrp.api:55
vl_api_vrrp_vr_add_del_t::flags
vl_api_vrrp_vr_flags_t flags
Definition: vrrp.api:58
vrrp_vr_config::vr_id
u8 vr_id
Definition: vrrp.h:72
vl_api_vrrp_vr_track_if_dump_t::dump_all
u8 dump_all
Definition: vrrp.api:225
vl_api_vrrp_vr_set_peers_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: vrrp.api:140
vrrp_vr_key
Definition: vrrp.h:29
vl_api_vrrp_vr_peer_dump_t_handler
static void vl_api_vrrp_vr_peer_dump_t_handler(vl_api_vrrp_vr_peer_dump_t *mp)
Definition: vrrp_api.c:334
format_fns.h
pub_sub_handler
pub_sub_handler(vrrp_vr_events, VRRP_VR_EVENTS)
vrrp_vr_key::is_ipv6
u8 is_ipv6
Definition: vrrp.h:33
vl_api_vrrp_vr_track_if_dump_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: vrrp.api:222
u32
unsigned int u32
Definition: types.h:88
vl_api_vrrp_vr_set_peers_t::n_addrs
u8 n_addrs
Definition: vrrp.api:143
vl_api_vrrp_vr_add_del_t_handler
static void vl_api_vrrp_vr_add_del_t_handler(vl_api_vrrp_vr_add_del_t *mp)
Definition: vrrp_api.c:28
vl_api_vrrp_vr_track_if_details_t::vr_id
u8 vr_id
Definition: vrrp.api:240
dst
vl_api_ip4_address_t dst
Definition: pnat.api:41
vl_api_vrrp_vr_dump_t
VRRP: dump virtual router data.
Definition: vrrp.api:68
vl_api_vrrp_vr_dump_t::context
u32 context
Definition: vrrp.api:70
vl_api_vrrp_vr_event_t::new_state
vl_api_vrrp_vr_state_t new_state
Definition: vrrp.api:259
send_vrrp_vr_event
static void send_vrrp_vr_event(vpe_client_registration_t *reg, vl_api_registration_t *vl_reg, vrrp_vr_t *vr, vrrp_vr_state_t new_state)
Definition: vrrp_api.c:483
api_helper_macros.h
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
vl_api_vrrp_vr_track_if_dump_t::is_ipv6
u8 is_ipv6
Definition: vrrp.api:223
vrrp_vr_config::adv_interval
u16 adv_interval
Definition: vrrp.h:74
vrrp_main_t::msg_id_base
u16 msg_id_base
Definition: vrrp.h:148
vpe_client_registration_t::client_index
u32 client_index
Definition: api_helper_macros.h:410
vrrp_vr_tracking_ifs_add_del
int vrrp_vr_tracking_ifs_add_del(vrrp_vr_t *vr, vrrp_vr_tracking_if_t *track_ifs, u8 is_add)
Definition: vrrp.c:998
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
vl_api_vrrp_vr_peer_dump_t::context
u32 context
Definition: vrrp.api:156
vrrp_vr_tracking::interfaces_dec
u32 interfaces_dec
Definition: vrrp.h:66
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vl_api_vrrp_vr_start_stop_t
VRRP: start or shutdown the VRRP protocol for a virtual router.
Definition: vrrp.api:119
vrrp_vr_start_stop
int vrrp_vr_start_stop(u8 is_start, vrrp_vr_key_t *vr_key)
Definition: vrrp.c:710
vl_api_vrrp_vr_track_if_add_del_t
VRRP: Add/delete VR priority tracking of interface status.
Definition: vrrp.api:199
vrrp_vr_runtime::skew
u16 skew
Definition: vrrp.h:98
vl_api_vrrp_vr_set_peers_t_handler
static void vl_api_vrrp_vr_set_peers_t_handler(vl_api_vrrp_vr_set_peers_t *mp)
Definition: vrrp_api.c:249
vl_api_vrrp_vr_add_del_t::is_add
u8 is_add
Definition: vrrp.api:53
VRRP_API_VR_IPV6
@ VRRP_API_VR_IPV6
Definition: vrrp.api:26
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
vl_api_vrrp_vr_add_del_t::n_addrs
u8 n_addrs
Definition: vrrp.api:59
context
u32 context
Definition: ip.api:780
vrrp_main_t::vrs
vrrp_vr_t * vrs
Definition: vrrp.h:151
vl_api_vrrp_vr_add_del_t::addrs
vl_api_address_t addrs[n_addrs]
Definition: vrrp.api:60
rv
int __clib_unused rv
Definition: application.c:491
vl_api_vrrp_vr_track_if_dump_t_handler
static void vl_api_vrrp_vr_track_if_dump_t_handler(vl_api_vrrp_vr_track_if_dump_t *mp)
Definition: vrrp_api.c:452
vl_api_vrrp_vr_track_if_add_del_t::vr_id
u8 vr_id
Definition: vrrp.api:205
vrrp_vr_add_del
int vrrp_vr_add_del(u8 is_add, vrrp_vr_config_t *vr_conf)
Definition: vrrp.c:622
vrrp_vr_config::sw_if_index
u32 sw_if_index
Definition: vrrp.h:71
VRRP_API_VR_UNICAST
@ VRRP_API_VR_UNICAST
Definition: vrrp.api:25
vl_api_vrrp_vr_start_stop_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: vrrp.api:122
vnet.h
vl_api_vrrp_vr_peer_details_t
VRRP: VR peer dump response.
Definition: vrrp.api:170
vl_api_vrrp_vr_set_peers_t::vr_id
u8 vr_id
Definition: vrrp.api:141
vrrp_vr_key::vr_id
u8 vr_id
Definition: vrrp.h:32
ADDRESS_IP4
@ ADDRESS_IP4
Definition: ip_types.api:22
vrrp_vr_tracking::interfaces
vrrp_vr_tracking_if_t * interfaces
Definition: vrrp.h:65
vpe_client_registration_t
Definition: api_helper_macros.h:408
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
vl_api_vrrp_vr_details_t::runtime
vl_api_vrrp_vr_runtime_t runtime
Definition: vrrp.api:106
vrrp_vr_priority
static u8 vrrp_vr_priority(vrrp_vr_t *vr)
Definition: vrrp.h:356
vrrp_main
vrrp_main_t vrrp_main
Definition: vrrp.c:25
vl_api_vrrp_vr_event_t::pid
u32 pid
Definition: vrrp.api:256
VRRP_VR_PREEMPT
@ VRRP_VR_PREEMPT
Definition: vrrp.h:23
vpe_api_main
vpe_api_main_t vpe_api_main
Definition: interface_api.c:55
vl_msg_api_alloc
void * vl_msg_api_alloc(int nbytes)
Definition: memory_shared.c:199