Merged. I changed the variable name from ctrl to ctl to be consistent with the bfd spec's convention.
Ethan On Tue, Aug 20, 2013 at 8:41 AM, Alex Wang <al...@nicira.com> wrote: > When there is no incoming data traffic at the interface for a period, > BFD decay allows the bfd session to increase the min_rx. This is > helpful in that some interfaces may usually be idle for a long time. > And cpu consumption can be reduced by processing fewer bfd control > packets. > > Signed-off-by: Alex Wang <al...@nicira.com> > --- > lib/bfd.c | 134 ++++++++++++++++++++++- > lib/bfd.h | 5 +- > ofproto/ofproto-dpif.c | 7 +- > tests/bfd.at | 279 > ++++++++++++++++++++++++++++++++++++++++++++++-- > vswitchd/vswitch.xml | 10 ++ > 5 files changed, 419 insertions(+), 16 deletions(-) > > diff --git a/lib/bfd.c b/lib/bfd.c > index 6f86f26..43ef759 100644 > --- a/lib/bfd.c > +++ b/lib/bfd.c > @@ -28,6 +28,7 @@ > #include "hash.h" > #include "hmap.h" > #include "list.h" > +#include "netdev.h" > #include "netlink.h" > #include "odp-util.h" > #include "ofpbuf.h" > @@ -151,6 +152,9 @@ struct bfd { > bool cpath_down; /* Concatenated Path Down. */ > uint8_t mult; /* bfd.DetectMult. */ > > + struct netdev *netdev; > + uint64_t rx_packets; /* Packets received by 'netdev'. */ > + > enum state state; /* bfd.SessionState. */ > enum state rmt_state; /* bfd.RemoteSessionState. */ > > @@ -186,6 +190,14 @@ struct bfd { > > atomic_bool check_tnl_key; /* Verify tunnel key of inbound packets? */ > atomic_int ref_cnt; > + > + /* BFD decay related variables. */ > + bool in_decay; /* True when bfd is in decay. */ > + int decay_min_rx; /* min_rx is set to decay_min_rx when */ > + /* in decay. */ > + int decay_rx_ctrl; /* Count bfd packets received within decay > */ > + /* detect interval. */ > + long long int decay_detect_time; /* Decay detection time. */ > }; > > static struct ovs_mutex mutex = OVS_MUTEX_INITIALIZER; > @@ -208,6 +220,9 @@ static void bfd_set_state(struct bfd *, enum state, enum > diag) > static uint32_t generate_discriminator(void) OVS_REQUIRES(mutex); > static void bfd_put_details(struct ds *, const struct bfd *) > OVS_REQUIRES(mutex); > +static uint64_t bfd_rx_packets(const struct bfd *) OVS_REQUIRES(mutex); > +static void bfd_try_decay(struct bfd *) OVS_REQUIRES(mutex); > +static void bfd_decay_update(struct bfd *) OVS_REQUIRES(mutex); > static void bfd_unixctl_show(struct unixctl_conn *, int argc, > const char *argv[], void *aux OVS_UNUSED); > static void bfd_unixctl_set_forwarding_override(struct unixctl_conn *, > @@ -255,14 +270,16 @@ bfd_get_status(const struct bfd *bfd, struct smap *smap) > * handle for the session, or NULL if BFD is not enabled according to 'cfg'. > * Also returns NULL if cfg is NULL. */ > struct bfd * > -bfd_configure(struct bfd *bfd, const char *name, const struct smap *cfg) > - OVS_EXCLUDED(mutex) > +bfd_configure(struct bfd *bfd, const char *name, const struct smap *cfg, > + struct netdev *netdev) OVS_EXCLUDED(mutex) > { > static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER; > static atomic_uint16_t udp_src = ATOMIC_VAR_INIT(0); > > + int decay_min_rx; > long long int min_tx, min_rx; > bool need_poll = false; > + bool cfg_min_rx_changed = false; > bool cpath_down; > const char *hwaddr; > uint8_t ea[ETH_ADDR_LEN]; > @@ -293,6 +310,8 @@ bfd_configure(struct bfd *bfd, const char *name, const > struct smap *cfg) > bfd->min_tx = 1000; > bfd->mult = 3; > atomic_init(&bfd->ref_cnt, 1); > + bfd->netdev = netdev_ref(netdev); > + bfd->in_decay = false; > > /* RFC 5881 section 4 > * The source port MUST be in the range 49152 through 65535. The > same > @@ -328,6 +347,22 @@ bfd_configure(struct bfd *bfd, const char *name, const > struct smap *cfg) > || (!bfd_in_poll(bfd) && bfd->cfg_min_rx > bfd->min_rx)) { > bfd->min_rx = bfd->cfg_min_rx; > } > + cfg_min_rx_changed = true; > + need_poll = true; > + } > + > + decay_min_rx = smap_get_int(cfg, "decay_min_rx", 0); > + if (bfd->decay_min_rx != decay_min_rx || cfg_min_rx_changed) { > + if (decay_min_rx > 0 && decay_min_rx < bfd->cfg_min_rx) { > + VLOG_WARN("%s: decay_min_rx cannot be less than %lld ms", > + bfd->name, bfd->cfg_min_rx); > + bfd->decay_min_rx = 0; > + } else { > + bfd->decay_min_rx = decay_min_rx; > + } > + /* Resets decay. */ > + bfd->in_decay = false; > + bfd_decay_update(bfd); > need_poll = true; > } > > @@ -379,6 +414,7 @@ bfd_unref(struct bfd *bfd) OVS_EXCLUDED(mutex) > if (orig == 1) { > ovs_mutex_lock(&mutex); > hmap_remove(all_bfds, &bfd->node); > + netdev_close(bfd->netdev); > free(bfd->name); > free(bfd); > ovs_mutex_unlock(&mutex); > @@ -404,12 +440,27 @@ bfd_wait(const struct bfd *bfd) OVS_EXCLUDED(mutex) > void > bfd_run(struct bfd *bfd) OVS_EXCLUDED(mutex) > { > + long long int now; > + bool old_in_decay; > + > ovs_mutex_lock(&mutex); > - if (bfd->state > STATE_DOWN && time_msec() >= bfd->detect_time) { > + now = time_msec(); > + old_in_decay = bfd->in_decay; > + > + if (bfd->state > STATE_DOWN && now >= bfd->detect_time) { > bfd_set_state(bfd, STATE_DOWN, DIAG_EXPIRED); > } > > - if (bfd->min_tx != bfd->cfg_min_tx || bfd->min_rx != bfd->cfg_min_rx) { > + /* Decay may only happen when state is STATE_UP, bfd->decay_min_rx is > + * configured, and decay_detect_time is reached. */ > + if (bfd->state == STATE_UP && bfd->decay_min_rx > 0 > + && now >= bfd->decay_detect_time) { > + bfd_try_decay(bfd); > + } > + > + if (bfd->min_tx != bfd->cfg_min_tx > + || (bfd->min_rx != bfd->cfg_min_rx && bfd->min_rx != > bfd->decay_min_rx) > + || bfd->in_decay != old_in_decay) { > bfd_poll(bfd); > } > ovs_mutex_unlock(&mutex); > @@ -537,6 +588,9 @@ bfd_process_packet(struct bfd *bfd, const struct flow > *flow, > /* This function is designed to follow section RFC 5880 6.8.6 closely. */ > > ovs_mutex_lock(&mutex); > + /* Increments the decay rx counter. */ > + bfd->decay_rx_ctrl++; > + > if (flow->nw_ttl != 255) { > /* XXX Should drop in the kernel to prevent DOS. */ > goto out; > @@ -686,6 +740,23 @@ bfd_process_packet(struct bfd *bfd, const struct flow > *flow, > out: > ovs_mutex_unlock(&mutex); > } > + > +/* Must be called when the netdev owned by 'bfd' should change. */ > +void > +bfd_set_netdev(struct bfd *bfd, const struct netdev *netdev) > + OVS_EXCLUDED(mutex) > +{ > + ovs_mutex_lock(&mutex); > + if (bfd->netdev != netdev) { > + netdev_close(bfd->netdev); > + bfd->netdev = netdev_ref(netdev); > + if (bfd->decay_min_rx) { > + bfd_decay_update(bfd); > + } > + } > + ovs_mutex_unlock(&mutex); > +} > + > > static bool > bfd_forwarding__(const struct bfd *bfd) OVS_REQUIRES(mutex) > @@ -713,7 +784,7 @@ bfd_poll(struct bfd *bfd) OVS_REQUIRES(mutex) > if (bfd->state > STATE_DOWN && !bfd_in_poll(bfd) > && !(bfd->flags & FLAG_FINAL)) { > bfd->poll_min_tx = bfd->cfg_min_tx; > - bfd->poll_min_rx = bfd->cfg_min_rx; > + bfd->poll_min_rx = bfd->in_decay ? bfd->decay_min_rx : > bfd->cfg_min_rx; > bfd->flags |= FLAG_POLL; > bfd->next_tx = 0; > VLOG_INFO_RL(&rl, "%s: Initiating poll sequence", bfd->name); > @@ -886,10 +957,63 @@ bfd_set_state(struct bfd *bfd, enum state state, enum > diag diag) > bfd->rmt_flags = 0; > bfd->rmt_disc = 0; > bfd->rmt_min_tx = 0; > + /* Resets the min_rx if in_decay. */ > + if (bfd->in_decay) { > + bfd->min_rx = bfd->cfg_min_rx; > + bfd->in_decay = false; > + } > } > + /* Resets the decay when state changes to STATE_UP > + * and decay_min_rx is configured. */ > + if (bfd->state == STATE_UP && bfd->decay_min_rx) { > + bfd_decay_update(bfd); > + } > + } > +} > + > +static uint64_t > +bfd_rx_packets(const struct bfd *bfd) OVS_REQUIRES(mutex) > +{ > + struct netdev_stats stats; > + > + if (!netdev_get_stats(bfd->netdev, &stats)) { > + return stats.rx_packets; > + } else { > + return 0; > } > } > > +/* Decays the bfd->min_rx to bfd->decay_min_rx when 'diff' is less than > + * the 'expect' value. */ > +static void > +bfd_try_decay(struct bfd *bfd) OVS_REQUIRES(mutex) > +{ > + int64_t diff, expect; > + > + /* The 'diff' is the difference between current interface rx_packets > + * stats and last-time check. The 'expect' is the recorded number of > + * bfd control packets received within an approximately decay_min_rx > + * (2000 ms if decay_min_rx is less than 2000 ms) interval. > + * > + * Since the update of rx_packets stats at interface happens > + * asynchronously to the bfd_rx_packets() function, the 'diff' value > + * can be jittered. Thusly, we double the decay_rx_ctrl to provide > + * more wiggle room. */ > + diff = bfd_rx_packets(bfd) - bfd->rx_packets; > + expect = 2 * MAX(bfd->decay_rx_ctrl, 1); > + bfd->in_decay = diff <= expect ? true : false; > + bfd_decay_update(bfd); > +} > + > +/* Updates the rx_packets, decay_rx_ctrl and decay_detect_time. */ > +static void > +bfd_decay_update(struct bfd * bfd) OVS_REQUIRES(mutex) > +{ > + bfd->rx_packets = bfd_rx_packets(bfd); > + bfd->decay_rx_ctrl = 0; > + bfd->decay_detect_time = MAX(bfd->decay_min_rx, 2000) + time_msec(); > +} > + > static uint32_t > generate_discriminator(void) > { > diff --git a/lib/bfd.h b/lib/bfd.h > index 67d012e..0e1e33d 100644 > --- a/lib/bfd.h > +++ b/lib/bfd.h > @@ -24,6 +24,7 @@ > struct bfd; > struct flow; > struct flow_wildcards; > +struct netdev; > struct ofpbuf; > struct smap; > > @@ -40,11 +41,13 @@ void bfd_process_packet(struct bfd *, const struct flow *, > const struct ofpbuf *); > > struct bfd *bfd_configure(struct bfd *, const char *name, > - const struct smap *smap); > + const struct smap *smap, > + struct netdev *netdev); > struct bfd *bfd_ref(const struct bfd *); > void bfd_unref(struct bfd *); > > bool bfd_forwarding(const struct bfd *); > void bfd_get_status(const struct bfd *, struct smap *); > +void bfd_set_netdev(struct bfd *, const struct netdev *); > > #endif /* bfd.h */ > diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c > index 4690215..4b7494c 100644 > --- a/ofproto/ofproto-dpif.c > +++ b/ofproto/ofproto-dpif.c > @@ -1905,6 +1905,10 @@ port_modified(struct ofport *port_) > cfm_set_netdev(port->cfm, port->up.netdev); > } > > + if (port->bfd) { > + bfd_set_netdev(port->bfd, port->up.netdev); > + } > + > if (port->is_tunnel && tnl_port_reconfigure(port, port->up.netdev, > port->odp_port)) { > ofproto_dpif_cast(port->up.ofproto)->backer->need_revalidate = > @@ -2039,7 +2043,8 @@ set_bfd(struct ofport *ofport_, const struct smap *cfg) > struct bfd *old; > > old = ofport->bfd; > - ofport->bfd = bfd_configure(old, netdev_get_name(ofport->up.netdev), > cfg); > + ofport->bfd = bfd_configure(old, netdev_get_name(ofport->up.netdev), > + cfg, ofport->up.netdev); > if (ofport->bfd != old) { > ofproto->backer->need_revalidate = REV_RECONFIGURE; > } > diff --git a/tests/bfd.at b/tests/bfd.at > index fb8b1d3..da45b27 100644 > --- a/tests/bfd.at > +++ b/tests/bfd.at > @@ -20,9 +20,9 @@ AT_CHECK([ovs-appctl bfd/show $1 | sed -e '/Time:/d' | sed > -e '/Discriminator/d' > m4_define([BFD_CHECK_TX], [ > AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/TX Interval/p'],[0], > [dnl > - TX Interval: Approx 1000ms > - Local Minimum TX Interval: $2 > - Remote Minimum TX Interval: $3 > + TX Interval: Approx $2 > + Local Minimum TX Interval: $3 > + Remote Minimum TX Interval: $4 > ]) > ]) > > @@ -30,8 +30,8 @@ m4_define([BFD_CHECK_RX], [ > AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/RX Interval/p'],[0], > [dnl > RX Interval: Approx $2 > - Local Minimum RX Interval: $2 > - Remote Minimum RX Interval: $3 > + Local Minimum RX Interval: $3 > + Remote Minimum RX Interval: $4 > ]) > ]) > AT_SETUP([bfd - basic config on different bridges]) > @@ -202,14 +202,14 @@ BFD_CHECK([p0], [true], [false], [none], [up], [No > Diagnostic], [none], [up], [N > #Edit the min Tx value. > AT_CHECK([ovs-vsctl set interface p0 bfd:min_tx=200]) > for i in `seq 0 20`; do ovs-appctl time/warp 100; done > -BFD_CHECK_TX([p0], [200ms], [100ms]) > -BFD_CHECK_TX([p1], [100ms], [200ms]) > +BFD_CHECK_TX([p0], [1000ms], [200ms], [100ms]) > +BFD_CHECK_TX([p1], [1000ms], [100ms], [200ms]) > > #Edit the min Rx value. > AT_CHECK([ovs-vsctl set interface p1 bfd:min_rx=300]) > for i in `seq 0 20`; do ovs-appctl time/warp 100; done > -BFD_CHECK_RX([p1], [300ms], [1000ms]) > -BFD_CHECK_RX([p0], [1000ms], [300ms]) > +BFD_CHECK_RX([p1], [300ms], [300ms], [1000ms]) > +BFD_CHECK_RX([p0], [1000ms], [1000ms], [300ms]) > > OVS_VSWITCHD_STOP > AT_CLEANUP > @@ -247,3 +247,264 @@ This flow is handled by the userspace slow path because > it: > > OVS_VSWITCHD_STOP > AT_CLEANUP > + > +# Tests below are for bfd decay features. > +AT_SETUP([bfd - bfd decay]) > +OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \ > + add-port br1 p1 -- set Interface p1 type=patch \ > + options:peer=p0 ofport_request=2 -- \ > + add-port br0 p0 -- set Interface p0 type=patch \ > + options:peer=p1 ofport_request=1 -- \ > + set Interface p0 bfd:enable=true bfd:min_tx=300 > bfd:min_rx=300 bfd:decay_min_rx=3000 -- \ > + set Interface p1 bfd:enable=true bfd:min_tx=500 > bfd:min_rx=500]) > + > +ovs-appctl time/stop > + > +# wait for local session state to go from down to up. > +for i in `seq 0 2`; do ovs-appctl time/warp 500; done > +BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], > [init], [No Diagnostic]) > + > + > +# Test-1 BFD decay: decay to decay_min_rx > +# bfd:decay_min_rx is set to 3000ms after the local state of p0 goes up, > +# so for the first 2500ms, there should be no change. > +for i in `seq 0 3`; do ovs-appctl time/warp 500; done > +BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > +BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > +BFD_CHECK_RX([p0], [500ms], [300ms], [500ms]) > + > +# advance the clock by 500ms. > +ovs-appctl time/warp 500 > +# now at 3000ms, min_rx should decay to 3000ms and there should be > +# poll sequence flags. > +BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [final], > [up], [No Diagnostic]) > +BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [poll], > [up], [No Diagnostic]) > +BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > +BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms]) > + > +# since the tx_min of p0 is still 500ms, after 500ms from decay, > +# the control message will be sent from p0 to p1, and p1 'flag' > +# will go back to none. > +ovs-appctl time/warp 500 > +BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > + > +# the rx_min of p0 is 3000ms now, and p1 will send next control message > +# 3000ms after decay. so, advance clock by 2500ms to make that happen. > +for i in `seq 0 4`; do ovs-appctl time/warp 500; done > +BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > +BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > +BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms]) > +# End of Test-1 > ############################################################### > + > + > +# Test-2 BFD decay: go back to cfg_min_rx when there is traffic > +# receive packet at 1/100ms rate for 3000ms. > +for i in `seq 0 30` > +do > + ovs-appctl time/warp 100 > + AT_CHECK([ovs-ofctl packet-out br1 3 2 > "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"], > + [0], [stdout], []) > +done > +# after a decay interval (3000ms), the p0 min_rx will go back to > +# cfg_min_rx. there should be poll sequence flags. > +BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [final], > [up], [No Diagnostic]) > +BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [poll], > [up], [No Diagnostic]) > +BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > +BFD_CHECK_RX([p0], [500ms], [300ms], [500ms]) > + > +# 500ms later, both direction will send control messages, > +# and their 'flag' will go back to none. > +ovs-appctl time/warp 500 > +BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > +BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > +BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > +BFD_CHECK_RX([p0], [500ms], [300ms], [500ms]) > +# End of Test-2 > ############################################################### > + > + > +# Test-3 BFD decay: go back to cfg_min_rx when decay_min_rx is changed > +# advance the clock by 2500ms to 3000m after restore of > +# min_rx. p0 is decayed, and there should be the poll sequence flags. > +for i in `seq 0 4`; do ovs-appctl time/warp 500; done > +BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [final], > [up], [No Diagnostic]) > +BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [poll], > [up], [No Diagnostic]) > +BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > +BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms]) > + > +# advance the clock, to make 'flag' go back to none. > +for i in `seq 0 5`; do ovs-appctl time/warp 500; done > +BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > +BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > + > +# change decay_min_rx to 1000ms. > +# for decay_min_rx < 2000ms, the decay detection time is set to 2000ms. > +# this should firstly reset the min_rx and start poll sequence. > +AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=1000]) > +BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [final], > [up], [No Diagnostic]) > +BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [poll], > [up], [No Diagnostic]) > +BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > +BFD_CHECK_RX([p0], [500ms], [300ms], [500ms]) > + > +# for the following 1500ms, there should be no decay, > +# since the decay_detect_time is set to 2000ms. > +for i in `seq 0 2` > +do > + ovs-appctl time/warp 500 > + BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > + BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > + BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > + BFD_CHECK_RX([p0], [500ms], [300ms], [500ms]) > +done > + > +ovs-appctl time/warp 500 > +# at 2000ms, decay should happen and there should be the poll sequence flags. > +BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [final], > [up], [No Diagnostic]) > +BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [poll], > [up], [No Diagnostic]) > +BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > +BFD_CHECK_RX([p0], [1000ms], [1000ms], [500ms]) > +# advance the clock, so 'flag' go back to none. > +for i in `seq 0 4`; do ovs-appctl time/warp 500; done > +# End of Test-3 > ############################################################### > + > + > +# Test-4 BFD decay: set min_rx to 800ms. > +# this should firstly reset the min_rx and then re-decay to 1000ms. > +AT_CHECK([ovs-vsctl set Interface p0 bfd:min_rx=800]) > +BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [final], > [up], [No Diagnostic]) > +BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [poll], > [up], [No Diagnostic]) > +BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > +BFD_CHECK_RX([p0], [800ms], [800ms], [500ms]) > + > +# for the following 1600ms, there should be no decay, > +# since the decay detection time is set to 2000ms. > +for i in `seq 0 1` > +do > + ovs-appctl time/warp 800 > + BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > + BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > + BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > + BFD_CHECK_RX([p0], [800ms], [800ms], [500ms]) > +done > + > +ovs-appctl time/warp 400 > +# at 2000ms, decay should happen and there should be the poll sequence flags. > +BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [final], > [up], [No Diagnostic]) > +BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [poll], > [up], [No Diagnostic]) > +BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > +BFD_CHECK_RX([p0], [1000ms], [1000ms], [500ms]) > +# advance the clock, so 'flag' go back to none. > +for i in `seq 0 4`; do ovs-appctl time/warp 500; done > +# End of Test-4 > ############################################################### > + > + > +# Test-5 BFD decay: set min_rx to 300ms and decay_min_rx to 5000ms together. > +AT_CHECK([ovs-vsctl set Interface p0 bfd:min_rx=300 bfd:decay_min_rx=5000]) > +BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [final], > [up], [No Diagnostic]) > +BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [poll], > [up], [No Diagnostic]) > +BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > +BFD_CHECK_RX([p0], [500ms], [300ms], [500ms]) > + > +# for decay_min_rx > 2000ms, the decay detection time is set to > +# decay_min_rx (5000ms). > +# for the following 4500ms, there should be no decay, > +# since the decay detection time is set to 5000ms. > +for i in `seq 0 8` > +do > + ovs-appctl time/warp 500 > + BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > + BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > + BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > + BFD_CHECK_RX([p0], [500ms], [300ms], [500ms]) > +done > + > +ovs-appctl time/warp 500 > +# at 5000ms, decay should happen and there should be the poll sequence flags. > +BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [final], > [up], [No Diagnostic]) > +BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [poll], > [up], [No Diagnostic]) > +BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > +BFD_CHECK_RX([p0], [5000ms], [5000ms], [500ms]) > +# advance the clock, to make 'flag' go back to none. > +for i in `seq 0 9`; do ovs-appctl time/warp 500; done > +# End of Test-5 > ############################################################### > + > + > +# Test-6 BFD decay: set decay_min_rx to 0 to disable bfd decay. > +AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=0]) > +# min_rx is reset, and there should be the poll sequence flags. > +BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [final], > [up], [No Diagnostic]) > +BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [poll], > [up], [No Diagnostic]) > +BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > +BFD_CHECK_RX([p0], [500ms], [300ms], [500ms]) > +for i in `seq 0 20` > +do > + ovs-appctl time/warp 500 > + BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > + BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > + BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > + BFD_CHECK_RX([p0], [500ms], [300ms], [500ms]) > +done > +# End of Test-6 > ################################################################ > + > + > +# Test-7 BFD decay: rmt_min_tx is greater than decay_min_rx > +AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=3000 -- set interface > p1 bfd:min_tx=5000]) > +# there will be poll sequences from both sides. and it is hard to determine > the > +# order. so just skip 10000ms and check the RX/TX. at that time, p0 should > be in decay already. > +for i in `seq 0 19`; do echo $i; ovs-appctl bfd/show; ovs-appctl time/warp > 500; done > +BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > +BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > +BFD_CHECK_TX([p0], [500ms], [300ms], [5000ms]) > +BFD_CHECK_RX([p0], [5000ms], [3000ms], [500ms]) > +# then, there should be no change of status, > +for i in `seq 0 9` > +do > + ovs-appctl time/warp 500 > + BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > + BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > + BFD_CHECK_TX([p0], [500ms], [300ms], [5000ms]) > + BFD_CHECK_RX([p0], [5000ms], [3000ms], [500ms]) > +done > +# reset the p1's min_tx to 500ms. > +AT_CHECK([ovs-vsctl set Interface p1 bfd:min_tx=500]) > +# check the poll sequence. since p0 has been in decay, now the RX will show > 3000ms. > +BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [final], > [up], [No Diagnostic]) > +BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [poll], > [up], [No Diagnostic]) > +BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > +BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms]) > +# advance the clock by 3000ms, at that time, p1 will send the control > packets. > +# then there will be no poll flags. > +for i in `seq 0 5`; do ovs-appctl time/warp 500; done > +BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > +BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], > [up], [No Diagnostic]) > +BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > +BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms]) > +# End of Test-7 > ############################################################### > + > + > +# Test-8 BFD decay: state up->down->up. > +# turn bfd off on p1 > +AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false]) > + > +# check the state change of bfd on p0. After 9000 ms (3 min_rx intervals) > +for i in `seq 0 8`; do ovs-appctl time/warp 1000; done > +BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time > Expired], [none], [down], [No Diagnostic]) > +BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms]) > +BFD_CHECK_RX([p0], [300ms], [300ms], [1ms]) > + > +# resume the bfd on p1. the bfd should not go to decay mode direclty. > +AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true]) > +for i in `seq 0 1`; do ovs-appctl time/warp 500; done > +BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time > Expired], [none], [up], [No Diagnostic]) > +BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > +BFD_CHECK_RX([p0], [500ms], [300ms], [500ms]) > + > +# since the decay_min_rx is still 3000ms, so after 3000ms, there should be > the decay and poll sequence. > +for i in `seq 0 5`; do ovs-appctl time/warp 500; done > +BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time > Expired], [final], [up], [No Diagnostic]) > +BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [poll], > [up], [Control Detection Time Expired]) > +BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) > +BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms]) > +# End of Test-8 > ################################################################ > + > +OVS_VSWITCHD_STOP > +AT_CLEANUP > \ No newline at end of file > diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml > index 5bbe943..a697fbc 100644 > --- a/vswitchd/vswitch.xml > +++ b/vswitchd/vswitch.xml > @@ -1896,6 +1896,16 @@ > specified. Defaults to <code>100</code>. > </column> > > + <column name="bfd" key="decay_min_rx" type='{"type": "integer"}'> > + <code>decay_min_rx</code> is used to set the <code>min_rx</code>, > + when there is no obvious incoming data traffic at the interface. > + It cannot be set less than the <code>min_rx</code>. The decay > feature > + is disabled by setting the <code>decay_min_rx</code> to 0. And the > + feature is reset everytime itself or <code>min_rx</code> is > + reconfigured. > + </column> > + > + > <column name="bfd" key="cpath_down" type='{"type": "boolean"}'> > Concatenated path down may be used when the local system should not > have traffic forwarded to it for some reason other than a > connectivty > -- > 1.7.9.5 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev