Skip to content

bfd: listen on RFC 5883 multihop port - #3481

Open
fivetime wants to merge 2 commits into
osrg:masterfrom
fivetime:bfd-rfc5883-upstream
Open

bfd: listen on RFC 5883 multihop port#3481
fivetime wants to merge 2 commits into
osrg:masterfrom
fivetime:bfd-rfc5883-upstream

Conversation

@fivetime

Copy link
Copy Markdown
Contributor

Summary

  • listen on the RFC 5883 multihop BFD control port (4784) in addition to the configured single-hop port
  • keep compatibility with upstream interface/device binding by applying listenAddrs alongside listenInterface
  • add regression coverage for single-hop and multihop port handling, multihop session establishment, and Linux bind-to-device + multihop behavior

Tests

  • go test ./pkg/server -run 'Test_BfdServer(AcceptsSingleHopAndMultihopPorts|EstablishesMultihopSessionOnRFC5883Port|ListenAddrsBindToDeviceAndMultihopPort)$' -race -v\n- go test -race -timeout 240s ./pkg/server\n- go test ./pkg/server\n- golangci-lint run ./pkg/server

Comment thread pkg/server/bfd_server.go
Comment thread pkg/server/bfd_server.go
// 10.0.0.1:4784) instead of the wildcard (:4784). A specific bind wins the
// kernel's most-specific-match UDP demux over any wildcard listener already on
// the port (e.g. a host bfdd owning 0.0.0.0:3784/4784), so an embedded GoBGP
// can run BFD on a host that also runs a system bfdd. Empty → wildcard bind.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all the non ascii characters. Just use -> instead.

fivetime and others added 2 commits July 30, 2026 15:23
start() previously reported success whenever any one of the (host, port)
listen combinations bound, so a server whose single-hop control port
failed to bind could still come up "started" as long as the multihop
port happened to bind — silently running without the ability to receive
single-hop returns.

Treat the single-hop control port (RFC 5881) as required: it must bind
on every configured listen address, otherwise startServer rolls back
every listener it opened (including any best-effort multihop sockets)
and reports failure so the caller retries. The multihop port
(RFC 5883/4784) stays best-effort, since it is commonly already owned by
a host BFD daemon; a failure there is logged but does not fail startup.

Add a regression test that occupies the single-hop port and asserts the
server refuses to come up and tears down the multihop socket it bound.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@fivetime
fivetime force-pushed the bfd-rfc5883-upstream branch from 3b822b1 to 3b203a1 Compare July 30, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants