Hi,

I was playing with BFD and noticed that the transition from up to down
didnt seem to be reported correctly in the routing message. The uptime
didn't seem to reset and both state and laststate show as down.

RTM_BFD: bidirectional forwarding detection: len 136
        BFD: async state down remote admindown laststate down error 0
             diag none remote none
             discr 1766582563 remote 1427874800
             uptime 05m42s last state time 01s
             mintx 1000000 minrx 1000000 minecho 0 multiplier 3

I tracked this down to what I think is a typo. The code for updating the
laststate and timer is looking at laststate before it's been updated.
Patch below makes it work as expected

RTM_BFD: bidirectional forwarding detection: len 136
        BFD: async state down remote admindown laststate up error 0
             diag none remote none
             discr 967007404 remote 1766582563
             uptime 00s last state time 10s
             mintx 1000000 minrx 1000000 minecho 0 multiplier 3

Mitchell



diff --git sys/net/bfd.c sys/net/bfd.c
index 0d2ec8af512..e1f778ecc8e 100644
--- sys/net/bfd.c
+++ sys/net/bfd.c
@@ -927,7 +928,7 @@ bfd_set_state(struct bfd_config *bfd, unsigned int state)
                bfd->bc_laststate = bfd->bc_state;
        /* FALLTHROUGH */
        case BFD_STATE_DOWN:
-               if (bfd->bc_laststate == BFD_STATE_UP) {
+               if (bfd->bc_state == BFD_STATE_UP) {
                        bfd->bc_laststate = bfd->bc_state;
                        bfd_set_uptime(bfd);
                }

Reply via email to