diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-12-06 21:31:05 +0000 | 
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2019-05-17 00:27:08 +0000 | 
| commit | 1d21789e169e903b0de56ddec110e573728f7139 (patch) | |
| tree | 1b3ac40aa991117718fc35fcbe65297e5e285761 /vrrpd/vrrp.h | |
| parent | c23edd740255f0199aaabeaed59aeeff81de9538 (diff) | |
vrrpd: clean up configuration code, fix skew bug
* Update vrrp.[ch] file header to be more accurate
* Make vrrp_update_times() private again
* Add times reset function and use it
* Add priority and advertisement interval setter functions and use them
* Add command to change advertisement interval
* Allow showing all VRRP instances
* Improve doc comments on functions
* Add ability to shutdown router
* Reorganize vrrp.h
* Add doc comments to vrrp.h
* Fix bug where Skew_time was not used to compute Master_Down_Interval
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'vrrpd/vrrp.h')
| -rw-r--r-- | vrrpd/vrrp.h | 106 | 
1 files changed, 68 insertions, 38 deletions
diff --git a/vrrpd/vrrp.h b/vrrpd/vrrp.h index 240144d3b3..1564cced59 100644 --- a/vrrpd/vrrp.h +++ b/vrrpd/vrrp.h @@ -1,5 +1,5 @@  /* - * VRRPD global definitions + * VRRPD global definitions and state machine   * Copyright (C) 2018 Cumulus Networks, Inc.   *               Quentin Young   * @@ -21,11 +21,13 @@  #define _VRRP_H  #include <zebra.h> -#include "linklist.h" -#include "hash.h" -#include "if.h" -#include "thread.h" -#include "hook.h" + +#include "lib/hash.h" +#include "lib/hook.h" +#include "lib/if.h" +#include "lib/linklist.h" +#include "lib/privs.h" +#include "lib/thread.h"  /* Global definitions */  #define VRRP_DEFAULT_ADVINT 100 @@ -127,24 +129,22 @@ struct vrrp_vrouter {  	} fsm;  }; -/* State machine */ -#define VRRP_STATE_INITIALIZE 1 -#define VRRP_STATE_MASTER 2 -#define VRRP_STATE_BACKUP 3 -#define VRRP_EVENT_STARTUP 1 -#define VRRP_EVENT_SHUTDOWN 2 - -DECLARE_HOOK(vrrp_change_state_hook, (struct vrrp_vrouter *vr, int to), (vr, to)); -/* End state machine */ - -  /*   * Initialize VRRP global datastructures.   */  void vrrp_init(void); + +/* Creation and destruction ------------------------------------------------ */ +  /*   * Create and register a new VRRP Virtual Router. + * + * ifp + *    Base interface to configure VRRP on + * + * vrid + *    Virtual Router Identifier   */  struct vrrp_vrouter *vrrp_vrouter_create(struct interface *ifp, uint8_t vrid); @@ -153,38 +153,36 @@ struct vrrp_vrouter *vrrp_vrouter_create(struct interface *ifp, uint8_t vrid);   */  void vrrp_vrouter_destroy(struct vrrp_vrouter *vr); + +/* Configuration controllers ----------------------------------------------- */ +  /* - * Sets advertisement_interval and master_adver_interval on a Virtual Router, - * then recalculates and sets skew_time and master_down_interval based on these - * values. + * Change the priority of a VRRP Virtual Router.   * - * vr - *    Virtual Router to operate on + * Also recalculates timers using new priority.   * - * advertisement_interval - *    Advertisement_Interval to set + * vr + *    Virtual Router to change priority of   * - * master_adver_interval - *    Master_Adver_Interval to set + * priority + *    New priority   */ -void vrrp_update_times(struct vrrp_vrouter *vr, uint16_t advertisement_interval, -		       uint16_t master_adver_interval); +void vrrp_set_priority(struct vrrp_vrouter *vr, uint8_t priority);  /* - * Change the priority of a VRRP Virtual Router. - * - * Recalculates timers using new priority. + * Set Advertisement Interval on this Virtual Router.   *   * vr   *    Virtual Router to change priority of   * - * priority - *    New priority + * advertisement_interval + *    New advertisement interval   */ -void vrrp_update_priority(struct vrrp_vrouter *vr, uint8_t priority); +void vrrp_set_advertisement_interval(struct vrrp_vrouter *vr, +				     uint16_t advertisement_interval);  /* - * Add IPv4 address to a VRRP Virtual Router + * Add IPv4 address to a VRRP Virtual Router.   *   * vr   *    Virtual Router to add IPv4 address to @@ -194,14 +192,46 @@ void vrrp_update_priority(struct vrrp_vrouter *vr, uint8_t priority);   */  void vrrp_add_ip(struct vrrp_vrouter *vr, struct in_addr v4); + +/* State machine ----------------------------------------------------------- */ + +#define VRRP_STATE_INITIALIZE 1 +#define VRRP_STATE_MASTER 2 +#define VRRP_STATE_BACKUP 3 +#define VRRP_EVENT_STARTUP 1 +#define VRRP_EVENT_SHUTDOWN 2 +  /* - * Find VRRP Virtual Router by Virtual Router ID + * This hook called whenever the state of a Virtual Router changes, after the + * specific internal state handlers have run. + * + * Use this if you need to react to state changes to perform non-critical + * tasks. Critical tasks should go in the internal state change handlers.   */ -struct vrrp_vrouter *vrrp_lookup(uint8_t vrid); +DECLARE_HOOK(vrrp_change_state_hook, (struct vrrp_vrouter *vr, int to), (vr, to));  /* - * Trigger VRRP event + * Trigger a VRRP event on a given Virtual Router.. + * + * vr + *    Virtual Router to operate on + * + * event + *    Event to kick off. All event related processing will have completed upon + *    return of this function. + * + * Returns: + *    < 0 if the event created an error + *      0 otherwise   */  int vrrp_event(struct vrrp_vrouter *vr, int event); + +/* Other ------------------------------------------------------------------- */ + +/* + * Find VRRP Virtual Router by Virtual Router ID + */ +struct vrrp_vrouter *vrrp_lookup(uint8_t vrid); +  #endif /* _VRRP_H */  | 
