From afb8f2c70d7274dca9f8eae2c810e67bcbf1d715 Mon Sep 17 00:00:00 2001 From: lynnemorrison Date: Fri, 10 Jun 2022 12:46:31 -0400 Subject: [PATCH] tests: update timers in BFD VRF test Increase BFD Echo timers to make test stable. Signed-off-by: Lynne Morrison --- bfdd/bfd_packet.c | 24 ++++++++++++--------- bfdd/bfdd_cli.c | 7 +++++- tests/topotests/bfd_vrf_topo1/r1/bfdd.conf | 4 ++++ tests/topotests/bfd_vrf_topo1/r1/peers.json | 2 +- tests/topotests/bfd_vrf_topo1/r2/bfdd.conf | 8 ++++++- tests/topotests/bfd_vrf_topo1/r2/peers.json | 2 +- tests/topotests/bfd_vrf_topo1/r3/bfdd.conf | 4 +++- 7 files changed, 36 insertions(+), 15 deletions(-) diff --git a/bfdd/bfd_packet.c b/bfdd/bfd_packet.c index fcacbcc07b61..89f447bce085 100644 --- a/bfdd/bfd_packet.c +++ b/bfdd/bfd_packet.c @@ -147,7 +147,7 @@ int _ptm_bfd_send(struct bfd_session *bs, uint16_t *port, const void *data, * Checksum is not set in the packet, just computed. * * pkt - * VRRP packet, fully filled out except for checksum field. + * Packet, fully filled out except for checksum field. * * pktsize * sizeof(*pkt) @@ -156,7 +156,7 @@ int _ptm_bfd_send(struct bfd_session *bs, uint16_t *port, const void *data, * IP address that pkt will be transmitted from and too. * * Returns: - * VRRP checksum in network byte order. + * Checksum in network byte order. */ static uint16_t bfd_pkt_checksum(struct udphdr *pkt, size_t pktsize, struct in6_addr *ip, sa_family_t family) @@ -428,7 +428,6 @@ void ptm_bfd_snd(struct bfd_session *bfd, int fbit) #ifdef BFD_LINUX /* * receive the ipv4 echo packet that was loopback in the peers forwarding plane - * */ ssize_t bfd_recv_ipv4_fp(int sd, uint8_t *msgbuf, size_t msgbuflen, uint8_t *ttl, ifindex_t *ifindex, @@ -470,8 +469,9 @@ ssize_t bfd_recv_ipv4_fp(int sd, uint8_t *msgbuf, size_t msgbuflen, checksum = in_cksum((const void *)ip, sizeof(struct iphdr)); if (recv_checksum != checksum) { if (bglobal.debug_network) - zlog_debug("%s: invalid iphdr checksum expected 0x%x rcvd 0x%x", - __func__, checksum, recv_checksum ); + zlog_debug( + "%s: invalid iphdr checksum expected 0x%x rcvd 0x%x", + __func__, checksum, recv_checksum); return -1; } @@ -501,11 +501,12 @@ ssize_t bfd_recv_ipv4_fp(int sd, uint8_t *msgbuf, size_t msgbuflen, recv_checksum = uh->check; uh->check = 0; checksum = bfd_pkt_checksum(uh, ntohs(uh->len), - (struct in6_addr *)&ip->saddr, AF_INET); + (struct in6_addr *)&ip->saddr, AF_INET); if (recv_checksum != checksum) { if (bglobal.debug_network) - zlog_debug("%s: invalid udphdr checksum expected 0x%x rcvd 0x%x", - __func__, checksum, recv_checksum ); + zlog_debug( + "%s: invalid udphdr checksum expected 0x%x rcvd 0x%x", + __func__, checksum, recv_checksum); return -1; } return mlen; @@ -1574,7 +1575,11 @@ int bp_echo_socket(const struct vrf *vrf) sll.sll_family = AF_PACKET; sll.sll_protocol = htons(ETH_P_IP); sll.sll_ifindex = 0; - bind(s, (struct sockaddr *)&sll, sizeof(sll)); + if (bind(s, (struct sockaddr *)&sll, sizeof(sll)) < 0) { + zlog_warn("Failed to bind echo socket: %s", + safe_strerror(errno)); + return -1; + } return s; } @@ -1586,7 +1591,6 @@ int bp_echo_socket(const struct vrf *vrf) frr_with_privs(&bglobal.bfdd_privs) { s = vrf_socket(AF_INET, SOCK_DGRAM, 0, vrf->vrf_id, vrf->name); } - if (s == -1) zlog_fatal("echo-socket: socket: %s", strerror(errno)); diff --git a/bfdd/bfdd_cli.c b/bfdd/bfdd_cli.c index 142c962c1369..3cb9edc1633e 100644 --- a/bfdd/bfdd_cli.c +++ b/bfdd/bfdd_cli.c @@ -428,8 +428,13 @@ DEFPY_YANG( } if (!no && !bglobal.bg_use_dplane) { +#ifdef BFD_LINUX vty_out(vty, - "%% Echo mode works correctly for ipv4, but only works when the peer is also FRR for IPv6.\n"); + "%% Echo mode works correctly for IPv4, but only works when the peer is also FRR for IPv6.\n"); +#else + vty_out(vty, + "%% Current implementation of echo mode works only when the peer is also FRR.\n"); +#endif /* BFD_LINUX */ } nb_cli_enqueue_change(vty, "./echo-mode", NB_OP_MODIFY, diff --git a/tests/topotests/bfd_vrf_topo1/r1/bfdd.conf b/tests/topotests/bfd_vrf_topo1/r1/bfdd.conf index 8fca09968685..82b6e987fc52 100644 --- a/tests/topotests/bfd_vrf_topo1/r1/bfdd.conf +++ b/tests/topotests/bfd_vrf_topo1/r1/bfdd.conf @@ -5,7 +5,11 @@ ! bfd peer 192.168.0.2 vrf r1-bfd-cust1 + receive-interval 1000 + transmit-interval 1000 echo-mode + echo transmit-interval 500 + echo receive-interval 500 no shutdown ! ! diff --git a/tests/topotests/bfd_vrf_topo1/r1/peers.json b/tests/topotests/bfd_vrf_topo1/r1/peers.json index f49768ff759b..57cea71e539b 100644 --- a/tests/topotests/bfd_vrf_topo1/r1/peers.json +++ b/tests/topotests/bfd_vrf_topo1/r1/peers.json @@ -1,7 +1,7 @@ [ { "remote-receive-interval": 1000, - "remote-transmit-interval": 500, + "remote-transmit-interval": 1000, "peer": "192.168.0.2", "status": "up" } diff --git a/tests/topotests/bfd_vrf_topo1/r2/bfdd.conf b/tests/topotests/bfd_vrf_topo1/r2/bfdd.conf index 4490090ec62f..968008f79a45 100644 --- a/tests/topotests/bfd_vrf_topo1/r2/bfdd.conf +++ b/tests/topotests/bfd_vrf_topo1/r2/bfdd.conf @@ -6,12 +6,18 @@ bfd peer 192.168.0.1 vrf r2-bfd-cust1 receive-interval 1000 - transmit-interval 500 + transmit-interval 1000 echo-mode + echo transmit-interval 500 + echo receive-interval 500 no shutdown ! peer 192.168.1.1 vrf r2-bfd-cust1 + receive-interval 1000 + transmit-interval 1000 echo-mode + echo transmit-interval 500 + echo receive-interval 500 no shutdown ! ! diff --git a/tests/topotests/bfd_vrf_topo1/r2/peers.json b/tests/topotests/bfd_vrf_topo1/r2/peers.json index 267459c7a87e..ac5664934b8f 100644 --- a/tests/topotests/bfd_vrf_topo1/r2/peers.json +++ b/tests/topotests/bfd_vrf_topo1/r2/peers.json @@ -4,7 +4,7 @@ "status": "up" }, { - "remote-echo-receive-interval": 100, + "remote-echo-receive-interval": 500, "peer": "192.168.1.1", "status": "up" }, diff --git a/tests/topotests/bfd_vrf_topo1/r3/bfdd.conf b/tests/topotests/bfd_vrf_topo1/r3/bfdd.conf index 0333320898c8..a5426e2d18a0 100644 --- a/tests/topotests/bfd_vrf_topo1/r3/bfdd.conf +++ b/tests/topotests/bfd_vrf_topo1/r3/bfdd.conf @@ -5,7 +5,9 @@ ! bfd peer 192.168.1.2 vrf r3-bfd-cust1 - echo-interval 100 + receive-interval 1000 + transmit-interval 1000 + echo-interval 500 echo-mode no shutdown !