diff options
| author | songyanchao <[email protected]> | 2024-05-10 09:47:16 +0000 |
|---|---|---|
| committer | songyanchao <[email protected]> | 2024-05-10 09:47:16 +0000 |
| commit | 33f70f1e0a63c04f06b997ff6b65b46f80c23e0d (patch) | |
| tree | 0d2160df22cabbb91677611bf63edbec4923b7ff | |
| parent | 89a51ff544f372e5689132fe2f6b0c5b56d3283a (diff) | |
🐞 fix: Fix BFD packet ttl error.v4.7.6-20240511
Fix BFD packet ttl error.
| -rw-r--r-- | service/src/node_bfd.c | 5 | ||||
| -rw-r--r-- | test/ptf_test/bfd_test.py | 31 | ||||
| -rw-r--r-- | test/ptf_test/common_pkt.py | 2 |
3 files changed, 38 insertions, 0 deletions
diff --git a/service/src/node_bfd.c b/service/src/node_bfd.c index 5651e51..250bcb7 100644 --- a/service/src/node_bfd.c +++ b/service/src/node_bfd.c @@ -153,6 +153,11 @@ uint8_t bfd_reply(struct rte_ether_hdr * ether_hdr, struct rte_ipv4_hdr * ipv4_h uint32_t swap_ip = ipv4_hdr->dst_addr; ipv4_hdr->dst_addr = ipv4_hdr->src_addr; ipv4_hdr->src_addr = swap_ip; + ipv4_hdr->time_to_live = 255; + + /* Recalculate the checksum */ + ipv4_hdr->hdr_checksum = 0; + ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); /* Swap discriminator */ struct bfd_header_t * bfd_hdr = (struct bfd_header_t *)(udp_hdr + 1); diff --git a/test/ptf_test/bfd_test.py b/test/ptf_test/bfd_test.py index 97db79e..55c7c1d 100644 --- a/test/ptf_test/bfd_test.py +++ b/test/ptf_test/bfd_test.py @@ -113,6 +113,37 @@ class TestForEtherfabric(BaseTest): finally: mrzcpd.stop() +@group("bfd_test_for_ttl") +class TestForTtl(BaseTest): + def setUp(self): + self.dataplane = ptf.dataplane_instance + + def __init__(self): + BaseTest.__init__(self) + + def runTest(self): + try: + # Init & Start mrzcpd + mrzcpd = Mrzcpd(bfd_conf,"") + mrzcpd.start() + + # Create packet + send_bfd_pkt = simple_bfd_packet(eth_dst="10:70:fd:03:c0:bd", eth_src="0a:0a:0a:0a:01:28", + ip_src="10.10.1.40", ip_dst="10.254.60.1",ip_ttl=254, + sta=0, my_discriminator=1111, your_discriminator=0) + + verify_bfd_pkt = mask.Mask( + simple_bfd_packet(eth_dst="0a:0a:0a:0a:01:28", eth_src="10:70:fd:03:c0:bd", + ip_src="10.254.60.1", ip_dst="10.10.1.40",ip_ttl=255, sta=3, your_discriminator=1111)) + + verify_bfd_pkt.set_do_not_care_scapy(UDP, "chksum") + verify_bfd_pkt.set_do_not_care_scapy(BFD, "flags") + verify_bfd_pkt.set_do_not_care_scapy(BFD, "my_discriminator") + + send_packet(self, 0, send_bfd_pkt) + verify_packets(self, verify_bfd_pkt, [0]) + finally: + mrzcpd.stop() """ +--------------------------+ diff --git a/test/ptf_test/common_pkt.py b/test/ptf_test/common_pkt.py index a21758f..7f78c50 100644 --- a/test/ptf_test/common_pkt.py +++ b/test/ptf_test/common_pkt.py @@ -12,6 +12,7 @@ def simple_bfd_packet( eth_src="0a:0a:0a:0a:01:28", ip_src="10.10.1.40", ip_dst="10.254.60.1", + ip_ttl=255, udp_sport=3784, udp_dport=3784, sta=0, @@ -29,6 +30,7 @@ def simple_bfd_packet( eth_src=eth_src, ip_src=ip_src, ip_dst=ip_dst, + ip_ttl=ip_ttl, udp_sport=udp_sport, udp_dport=udp_dport, udp_payload=bfd |
