The DHCPv4 and DHCPv6 relay agents count the requests and replies they forward and the messages they drop #114

Open
opened 2026-10-31 12:42:09 -04:00 by claude · 0 comments
Owner
  • Draft: PQ-44
  • Priority: high (source of the relay series in the DHCP charts)
  • Agent: coder
  • Depends on: #113
  • Decisions: R2-DHCP-RELAY

Why

A node that relays DHCP has no local scopes or leases, so without relay counts its DHCP charts would be empty. The relay agents forward in a few places: Dhcpv4RelayAgent sends a request upstream (src/dotnet/src/Ninlil.Dhcp.Server.Relay/Dhcpv4RelayAgent.cs:205-315, hop check at :222) and a reply down to the client (:397-446); Dhcpv6RelayAgent sends a RELAY-FORW (src/dotnet/src/Ninlil.Dhcp.Server.Relay/Dhcpv6RelayAgent.cs:269-331) and relays a RELAY-REPL down (:349-460, discards at :357 and :392).

What changes

  • Dhcpv4RelayAgent and Dhcpv6RelayAgent take IDhcpMessageCounters (#113) as an optional constructor parameter (null = no counting). They record:
    • RequestForwarded after a request was sent upstream;
    • ReplyForwarded after a reply was sent toward the client;
    • Dropped at every point that discards a message (hop limit, unknown or untrusted sender, no upstream, a malformed relay message), once per message.
  • ServiceCollectionDhcpv4RelayExtension and ServiceCollectionDhcpv6RelayExtension: TryAddSingleton<IDhcpMessageCounters, DhcpMessageCounters>().
  • No relay behaviour changes.

Acceptance

  • Test fails first in src/dotnet/tests/Ninlil.Dhcp.Server.Relay.Tests: one DISCOVER relayed upstream and its OFFER relayed down drain to v4 RequestForwarded = 1, v4 ReplyForwarded = 1.
  • Test: a request over the hop limit drains to v4 Dropped = 1 and nothing forwarded; a DHCPv6 RELAY-REPL over the hop limit drains to v6 Dropped = 1.
  • Test: a node with DHCPv4 relayed and DHCPv6 local resolves one IDhcpMessageCounters instance (src/dotnet/tests/Ninlil.Web.Tests, second host through factory.CreateSecondHost, free ports).
  • dotnet test src/dotnet/tests/Ninlil.Dhcp.Server.Relay.Tests and src/dotnet/tests/Ninlil.Web.Tests pass. No schema, API or option change.

Source

Owner decision 2026-10-31, round 2 (R2-DHCP-RELAY): "separate relay series (requests/replies forwarded, v4 and v6)".

- **Draft:** PQ-44 - **Priority:** high (source of the relay series in the DHCP charts) - **Agent:** coder - **Depends on:** #113 - **Decisions:** R2-DHCP-RELAY ### Why A node that relays DHCP has no local scopes or leases, so without relay counts its DHCP charts would be empty. The relay agents forward in a few places: `Dhcpv4RelayAgent` sends a request upstream (`src/dotnet/src/Ninlil.Dhcp.Server.Relay/Dhcpv4RelayAgent.cs:205-315`, hop check at `:222`) and a reply down to the client (`:397-446`); `Dhcpv6RelayAgent` sends a RELAY-FORW (`src/dotnet/src/Ninlil.Dhcp.Server.Relay/Dhcpv6RelayAgent.cs:269-331`) and relays a RELAY-REPL down (`:349-460`, discards at `:357` and `:392`). ### What changes - `Dhcpv4RelayAgent` and `Dhcpv6RelayAgent` take `IDhcpMessageCounters` (#113) as an optional constructor parameter (null = no counting). They record: - `RequestForwarded` after a request was sent upstream; - `ReplyForwarded` after a reply was sent toward the client; - `Dropped` at every point that discards a message (hop limit, unknown or untrusted sender, no upstream, a malformed relay message), once per message. - `ServiceCollectionDhcpv4RelayExtension` and `ServiceCollectionDhcpv6RelayExtension`: `TryAddSingleton<IDhcpMessageCounters, DhcpMessageCounters>()`. - No relay behaviour changes. ### Acceptance - [ ] Test fails first in `src/dotnet/tests/Ninlil.Dhcp.Server.Relay.Tests`: one DISCOVER relayed upstream and its OFFER relayed down drain to `v4 RequestForwarded = 1`, `v4 ReplyForwarded = 1`. - [ ] Test: a request over the hop limit drains to `v4 Dropped = 1` and nothing forwarded; a DHCPv6 RELAY-REPL over the hop limit drains to `v6 Dropped = 1`. - [ ] Test: a node with DHCPv4 relayed and DHCPv6 local resolves one `IDhcpMessageCounters` instance (`src/dotnet/tests/Ninlil.Web.Tests`, second host through `factory.CreateSecondHost`, free ports). - [ ] `dotnet test src/dotnet/tests/Ninlil.Dhcp.Server.Relay.Tests` and `src/dotnet/tests/Ninlil.Web.Tests` pass. No schema, API or option change. ### Source Owner decision 2026-10-31, round 2 (R2-DHCP-RELAY): "separate relay series (requests/replies forwarded, v4 and v6)".
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
lantea-one/ninlil#114
No description provided.