Skip to content

Add switch to switch routing#17

Open
Zeleph25 wants to merge 2 commits into
releasefrom
feat/switch-routing
Open

Add switch to switch routing#17
Zeleph25 wants to merge 2 commits into
releasefrom
feat/switch-routing

Conversation

@Zeleph25

@Zeleph25 Zeleph25 commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Implement switch-to-switch routing

What was added

This PR completes the routing pipeline so packets reach agents on any switch, not just the local one.

Proto changes:

  • Add PacketAgentRegistered - switch reports an agent's virtual IP to the conductor
  • Add PacketSwitchRouteUpdate - conductor broadcasts a route to all switches
  • Add PacketSwitchDisconnected - conductor tells switches to drop routes for a disconnected switch
  • Add AGENT_REGISTERED, SWITCH_ROUTE_UPDATE, SWITCH_DISCONNECTED to the packet type enum and dispatch

Conductor changes:

  • onAgentRegistered - receives an agent's virtual IP from its switch, broadcasts it to all other switches
  • Broadcasts SWITCH_DISCONNECTED to remaining switches when a switch disconnects
  • Tracks assigned_switch per agent, nulled out safely when that switch disconnects

Switch changes:

  • onSwitchRouteUpdate - connects to the peer switch if not already connected, updates the BlackBox routing table
  • onSwitchDisconnected - closes the peer connection, letting onClose clean up routes
  • onIPv4Raw - processes packets arriving from peer switches through the BlackBox and delivers them to the local agent
  • Sends AGENT_REGISTERED to the conductor right after a new agent authenticates
  • New PEER_SWITCH connection role with its own cleanup path in onClose

Verified:

[Switch] Connected to peer switch switch2
[Switch] Route update: 10.0.1.1 → switch2
[Conductor] Agent agent1 registered with IP 10.0.1.1 on switch switch2

Routes propagate correctly from the switch handling the agent to every other connected switch, with no conductor involvement once cached.

@Zeleph25 Zeleph25 changed the title Feat/switch routing Add switch to switch routing Jun 19, 2026
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.

1 participant