Add TUN device setup for agent and switch#16
Open
Zeleph25 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add TUN device setup for agent and switch
What was added
This PR lays the networking foundation for packet routing by creating TUN interfaces on both the agent and switch after the MIP handshake completes.
Proto changes:
PacketPrepareRouteForTarget,PacketNextForTarget,PacketIPv4Rawtomip.protofor the upcoming routing implementationvirtual_ipv4toPacketConnectionAcceptedso the switch can tell the agent its assigned virtual IP during handshakePREPARE_ROUTE_FOR_TARGET,NEXT_FOR_TARGET,IPV4_RAWto the packet type enum and dispatchTUN utility (
src/common/tun.cpp):tun_open(name, ipv4, prefix_len)— opens/dev/net/tun, creates a named interface, assigns the virtual IP with configurable prefix length (default/24), and brings the interface uptun_close(fd, name)— brings the interface down and closes the fdioctlconfigurationSwitch changes:
VNET_CONFIG_PATHenv varBlackBoxwith the config at startupblackbox.on_agent_authenticated()on token validation — registers the agent and retrieves its virtual IPvirtual_ipv4inPacketConnectionAcceptedblackbox.on_agent_disconnected()on closeswitch-entrypoint.sh— fails fast with a clear error if config file is missing or is a directoryAgent changes:
virtual_ipv4fromPacketConnectionAcceptedvnet-<agent_name>with the assigned IP after handshakeConductor change:
Docker:
NET_ADMINcapability and/dev/net/tundevice to agent and switch containersVNET_CONFIG_PATHiproute2to switch and agent runtime imageslibgtest-dev/libgmock-devto builder stages and updateCMakeLists.txtto prefer system GTest over FetchContentVerified: