Re: [PATCH] make gratuitous ARP repeat count configurable

Alexandre Cassen <[email protected]>
Newsgroups gmane.linux.keepalived.devel
Message-ID <[email protected]>
Hi Patrick,

Would it be possible for you to submit a github patch instead (much more faster to apply). Anyway thanks for your time!

regs,
Alexandre


On 27 May 2014, at 14:35, Patrick Schaaf <[email protected]> wrote:

> Hi,
> 
> introducing the new garp_master_repeat mode in my production setup, I noticed 
> that it is sending 5 GARPs in short succession for each interval, just like 
> the initial (becoming MASTER) operation does. I find that a bit excessive :)
> 
> Looking at the code I saw the '5' being hardcoded in vrrp_send_link_update(), 
> and decided to make it configurable, separately for the two cases of becoming-
> MASTER GARP (new setting garp_master_repeat), and for the periodic refresh 
> case (new setting garp_master_refresh_repeat).
> 
> The default for the becoming-MASTER case is still 5 repetitions, but for the 
> periodic refresh, I changed the default to 1. That default could be changed in 
> include/vrrp.h, #define VRRP_GARP_REFRESH_REP
> 
> Find the patch below.
> 
> best regards
>  Patrick
> 
> diff -urN keepalived-1.2.13/doc/keepalived.conf.SYNOPSIS keepalived-1.2.13-
> bof/doc/keepalived.conf.SYNOPSIS
> --- keepalived-1.2.13/doc/keepalived.conf.SYNOPSIS      2014-05-12 
> 09:11:27.000000000 +0200
> +++ keepalived-1.2.13-bof/doc/keepalived.conf.SYNOPSIS  2014-05-27 
> 12:29:10.330000000 +0200
> @@ -175,9 +175,16 @@
>     }
>     lvs_sync_daemon_interface <STRING> # Binding interface for lvs syncd
>     garp_master_delay <INTEGER>                # delay for gratuitous ARP 
> after MASTER
> -                                       #  state transition
> +                                       #  state transition.
> +                                       #  Default: 5 seconds
> +    garp_master_repeat <INTEGER>       # how often the gratuitous ARP after 
> MASTER
> +                                       #  state transition should be 
> repeated?
> +                                       #  Default: 5 times
>     garp_master_refresh <INTEGER>      # Periodic delay in seconds sending
>                                        #  gratuitous ARP while in MASTER 
> state
> +    garp_master_refresh_repeat <INTEGER># how often the periodically repeated 
> gratuitous ARP
> +                                       #  should be repeated?
> +                                       #  Default: once (per period)
>     virtual_router_id <INTEGER-0..255> # VRRP VRID
>     priority <INTEGER-0..255>          # VRRP PRIO
>     advert_int <INTEGER>               # VRRP Advert interval (use default)
> diff -urN keepalived-1.2.13/keepalived/include/vrrp.h keepalived-1.2.13-
> bof/keepalived/include/vrrp.h
> --- keepalived-1.2.13/keepalived/include/vrrp.h 2014-01-28 14:38:19.000000000 
> +0100
> +++ keepalived-1.2.13-bof/keepalived/include/vrrp.h     2014-05-27 
> 12:20:39.860000000 +0200
> @@ -64,6 +64,8 @@
> #define VRRP_AUTH_AH           2               /* AH(IPSec) authentification 
> - rfc2338.5.3.6 */
> #define VRRP_ADVER_DFL         1               /* advert. interval (in sec) 
> -- rfc2338.5.3.7 */
> #define VRRP_GARP_DELAY        (5 * TIMER_HZ)  /* Default delay to launch 
> gratuitous arp */
> +#define VRRP_GARP_REP          5               /* Default repeat value for 
> initial (MASTER) gratuitous arp */
> +#define VRRP_GARP_REFRESH_REP  1               /* Default repeat value for 
> refresh gratuitous arp */
> 
> /*
>  * parameters per vrrp sync group. A vrrp_sync_group is a set
> @@ -108,6 +110,8 @@
>        int                     garp_delay;             /* Delay to launch 
> gratuitous ARP */
>        int                     garp_refresh;           /* Next scheduled 
> gratuitous ARP refresh */
>        timeval_t               garp_refresh_timer;     /* Next scheduled 
> gratuitous ARP timer */
> +       int                     garp_rep;               /* gratuitous ARP 
> repeat value */
> +       int                     garp_refresh_rep;       /* refresh gratuitous 
> ARP repeat value */
>        int                     vrid;                   /* virtual id. from 
> 1(!) to 255 */
>        int                     base_priority;          /* configured priority 
> value */
>        int                     effective_priority;     /* effective priority 
> value */
> @@ -228,7 +232,7 @@
> extern int open_vrrp_socket(sa_family_t, int, int, int);
> extern int new_vrrp_socket(vrrp_t *);
> extern void close_vrrp_socket(vrrp_t *);
> -extern void vrrp_send_link_update(vrrp_t *);
> +extern void vrrp_send_link_update(vrrp_t *, int);
> extern int vrrp_send_adv(vrrp_t *, int);
> extern int vrrp_state_fault_rx(vrrp_t *, char *, int);
> extern int vrrp_state_master_rx(vrrp_t *, char *, int);
> diff -urN keepalived-1.2.13/keepalived/vrrp/vrrp.c keepalived-1.2.13-
> bof/keepalived/vrrp/vrrp.c
> --- keepalived-1.2.13/keepalived/vrrp/vrrp.c    2014-05-12 09:11:27.000000000 
> +0200
> +++ keepalived-1.2.13-bof/keepalived/vrrp/vrrp.c        2014-05-27 
> 12:23:35.930000000 +0200
> @@ -722,7 +722,7 @@
> }
> 
> void
> -vrrp_send_link_update(vrrp_t * vrrp)
> +vrrp_send_link_update(vrrp_t * vrrp, int rep)
> {
>        int j;
>        ip_address_t *ipaddress;
> @@ -733,7 +733,7 @@
>                return;
> 
>        /* send gratuitous arp for each virtual ip */
> -       for (j = 0; j < 5; j++) {
> +       for (j = 0; j < rep; j++) {
>                if (!LIST_ISEMPTY(vrrp->vip)) {
>                        for (e = LIST_HEAD(vrrp->vip); e; ELEMENT_NEXT(e)) {
>                                ipaddress = ELEMENT_DATA(e);
> @@ -766,7 +766,7 @@
>                vrrp_handle_iproutes(vrrp, IPROUTE_ADD);
> 
>        /* remotes neighbour update */
> -       vrrp_send_link_update(vrrp);
> +       vrrp_send_link_update(vrrp, vrrp->garp_rep ? vrrp->garp_rep : 
> VRRP_GARP_REP);
> 
>        /* set refresh timer */
>        if (vrrp->garp_refresh) {
> @@ -922,7 +922,7 @@
>                vrrp_state_become_master(vrrp);
>                ret = 1;
>        } else if (vrrp->garp_refresh && timer_cmp(time_now, vrrp-
>> garp_refresh_timer) > 0) {
> -               vrrp_send_link_update(vrrp);
> +               vrrp_send_link_update(vrrp, vrrp->garp_refresh_rep ? vrrp-
>> garp_refresh_rep : VRRP_GARP_REFRESH_REP);
>                vrrp->garp_refresh_timer = timer_add_long(time_now, vrrp-
>> garp_refresh);
>        }
> 
> @@ -971,7 +971,7 @@
>                        vrrp->ipsecah_counter->cycle = 0;
>                }
>                vrrp_send_adv(vrrp, vrrp->effective_priority);
> -               vrrp_send_link_update(vrrp);
> +               vrrp_send_link_update(vrrp, vrrp->garp_rep ? vrrp->garp_rep : 
> VRRP_GARP_REP);
>                return 0;
>        } else if (hd->priority == 0) {
>                vrrp_send_adv(vrrp, vrrp->effective_priority);
> diff -urN keepalived-1.2.13/keepalived/vrrp/vrrp_parser.c keepalived-1.2.13-
> bof/keepalived/vrrp/vrrp_parser.c
> --- keepalived-1.2.13/keepalived/vrrp/vrrp_parser.c     2014-01-02 
> 20:53:15.000000000 +0100
> +++ keepalived-1.2.13-bof/keepalived/vrrp/vrrp_parser.c 2014-05-27 
> 12:20:01.210000000 +0200
> @@ -366,6 +366,22 @@
>        vrrp->garp_refresh = atoi(vector_slot(strvec, 1)) * TIMER_HZ;
> }
> static void
> +vrrp_garp_rep_handler(vector_t *strvec)
> +{
> +       vrrp_t *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
> +       vrrp->garp_rep = atoi(vector_slot(strvec, 1));
> +       if (vrrp->garp_rep < 1)
> +               vrrp->garp_rep = 1;
> +}
> +static void
> +vrrp_garp_refresh_rep_handler(vector_t *strvec)
> +{
> +       vrrp_t *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
> +       vrrp->garp_refresh_rep = atoi(vector_slot(strvec, 1));
> +       if (vrrp->garp_refresh_rep < 1)
> +               vrrp->garp_refresh_rep = 1;
> +}
> +static void
> vrrp_auth_type_handler(vector_t *strvec)
> {
>        vrrp_t *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
> @@ -542,6 +558,8 @@
>        install_keyword("lvs_sync_daemon_interface", &vrrp_lvs_syncd_handler);
>        install_keyword("garp_master_delay", &vrrp_garp_delay_handler);
>        install_keyword("garp_master_refresh", &vrrp_garp_refresh_handler);
> +       install_keyword("garp_master_repeat", &vrrp_garp_rep_handler);
> +       install_keyword("garp_master_refresh_repeat", 
> &vrrp_garp_refresh_rep_handler);
>        install_keyword("authentication", NULL);
>        install_sublevel();
>        install_keyword("auth_type", &vrrp_auth_type_handler);
> diff -urN keepalived-1.2.13/keepalived/vrrp/vrrp_scheduler.c 
> keepalived-1.2.13-bof/keepalived/vrrp/vrrp_scheduler.c
> --- keepalived-1.2.13/keepalived/vrrp/vrrp_scheduler.c  2014-05-12 
> 15:14:46.000000000 +0200
> +++ keepalived-1.2.13-bof/keepalived/vrrp/vrrp_scheduler.c      2014-05-27 
> 12:22:30.720000000 +0200
> @@ -709,7 +709,7 @@
>        vrrp_t *vrrp = THREAD_ARG(thread);
> 
>        /* Simply broadcast the gratuitous ARP */
> -       vrrp_send_link_update(vrrp);
> +       vrrp_send_link_update(vrrp, vrrp->garp_rep ? vrrp->garp_rep : 
> VRRP_GARP_REP);
> 
>        return 0;
> }
> 
> 
> ------------------------------------------------------------------------------
> The best possible search technologies are now affordable for all companies.
> Download your FREE open source Enterprise Search Engine today!
> Our experts will assist you in its installation for $59/mo, no commitment.
> Test it for FREE on our Cloud platform anytime!
> http://pubads.g.doubleclick.net/gampad/clk?id=145328191&iu=/4140/ostg.clktrk
> _______________________________________________
> Keepalived-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/keepalived-devel


------------------------------------------------------------------------------
Time is money. Stop wasting it! Get your web API in 5 minutes.
www.restlet.com/download
http://p.sf.net/sfu/restlet
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.