When I adjusted the capability negotiation to check both sides for
presence I made the graceful restart capability lose all AFI/SAFI
elements for the peer capabilities.

This can be viewed with bgpctl show nei: e.g

 Description: beznau-1
  BGP version 4, remote router-id 192.168.0.252
  BGP state = Established, up for 02:11:07
  Last read 00:00:09, holdtime 90s, keepalive interval 30s
  Last write 00:00:06
  Neighbor capabilities:
    Multiprotocol extensions: IPv4 unicast
    4-byte AS numbers
    Route Refresh
    Graceful Restart: Timeout: 90,
  Negotiated capabilities:
    Multiprotocol extensions: IPv4 unicast
    4-byte AS numbers
    Route Refresh

  Message statistics:

Instead of

 Description: beznau-1
  BGP version 4, remote router-id 192.168.0.252
  BGP state = Established, up for 00:02:31
  Last read 00:00:00, holdtime 90s, keepalive interval 30s
  Last write 00:00:00
  Neighbor capabilities:
    Multiprotocol extensions: IPv4 unicast
    4-byte AS numbers
    Route Refresh
    Graceful Restart: Timeout: 90, restarted, IPv4 unicast
  Negotiated capabilities:
    Multiprotocol extensions: IPv4 unicast
    4-byte AS numbers
    Route Refresh

This is just a visual issue. In both cases the flush happens and graceful
refresh remains disabled.

-- 
:wq Claudio

Index: session.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/session.c,v
retrieving revision 1.415
diff -u -p -r1.415 session.c
--- session.c   16 May 2021 09:09:11 -0000      1.415
+++ session.c   18 May 2021 11:38:59 -0000
@@ -2585,24 +2585,24 @@ capa_neg_calc(struct peer *p)
                int8_t  negflags;
 
                /* disable GR if the AFI/SAFI is not present */
-               if (p->capa.ann.grestart.restart == 0 ||
-                   (p->capa.peer.grestart.flags[i] & CAPA_GR_PRESENT &&
+               if ((p->capa.peer.grestart.flags[i] & CAPA_GR_PRESENT &&
                    p->capa.neg.mp[i] == 0))
                        p->capa.peer.grestart.flags[i] = 0;     /* disable */
                /* look at current GR state and decide what to do */
                negflags = p->capa.neg.grestart.flags[i];
                p->capa.neg.grestart.flags[i] = p->capa.peer.grestart.flags[i];
                if (negflags & CAPA_GR_RESTARTING) {
-                       if (!(p->capa.peer.grestart.flags[i] &
-                           CAPA_GR_FORWARD)) {
+                       if (p->capa.ann.grestart.restart != 0 ||
+                           p->capa.peer.grestart.flags[i] & CAPA_GR_FORWARD) {
+                               p->capa.neg.grestart.flags[i] |=
+                                   CAPA_GR_RESTARTING;
+                       } else {
                                if (imsg_rde(IMSG_SESSION_FLUSH, p->conf.id,
                                    &i, sizeof(i)) == -1)
                                        return (-1);
                                log_peer_warnx(&p->conf, "graceful restart of "
                                    "%s, not restarted, flushing", aid2str(i));
-                       } else
-                               p->capa.neg.grestart.flags[i] |=
-                                   CAPA_GR_RESTARTING;
+                       }
                }
        }
        p->capa.neg.grestart.timeout = p->capa.peer.grestart.timeout;

Reply via email to