]> git.puffer.fish Git - mirror/frr.git/commitdiff
nhrpd: Add Hop Count Validation Before Forwarding in nhrp_peer_recv() 18598/head
authorzmw12306 <zmw12306@gmail.com>
Mon, 7 Apr 2025 20:13:45 +0000 (16:13 -0400)
committerzmw12306 <zmw12306@gmail.com>
Mon, 7 Apr 2025 20:13:45 +0000 (16:13 -0400)
According to [RFC 2332, Section 5.1], if an NHS receives a packet that it would normally forward and the hop count is zero, it must send an error indication back to the source and drop the packet.

Signed-off-by: zmw12306 <zmw12306@gmail.com>
nhrpd/nhrp_peer.c

index fa11980c18ff0469ead03b6960ff9160d6739899..97932795a3f8d732a1172f0a5cfd7d4a3a83cfc8 100644 (file)
@@ -1355,6 +1355,11 @@ void nhrp_peer_recv(struct nhrp_peer *p, struct zbuf *zb)
                }
                break;
        case NHRP_ROUTE_NBMA_NEXTHOP:
+               if (hdr->hop_count == 0) {
+                       nhrp_packet_send_error(&pp, NHRP_ERROR_HOP_COUNT_EXCEEDED, 0);
+                       info = "hop count exceeded";
+                       goto drop;
+               }
                nhrp_peer_forward(peer, &pp);
                break;
        case NHRP_ROUTE_BLACKHOLE: