Skip to content

Commit

Permalink
Merge pull request #252 from microsoft/netplan
Browse files Browse the repository at this point in the history
Add netplan-based network topology encoding
  • Loading branch information
abeltrano authored Apr 12, 2024
2 parents 48eb28a + 0ba0cc6 commit 0c1d502
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 46 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ if (WERROR)
add_compile_options(-Werror)
endif()

add_subdirectory(config)
add_subdirectory(packaging)
add_subdirectory(src)

Expand Down
2 changes: 2 additions & 0 deletions config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

add_subdirectory(linux)
2 changes: 2 additions & 0 deletions config/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

add_subdirectory(network)
3 changes: 3 additions & 0 deletions config/linux/network/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

add_subdirectory(cloud)
add_subdirectory(netplan)
1 change: 1 addition & 0 deletions config/linux/network/cloud/99-disable-network-config.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
network: { config: disabled }
7 changes: 7 additions & 0 deletions config/linux/network/cloud/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

install(
FILES
${CMAKE_CURRENT_LIST_DIR}/99-disable-network-config.cfg
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/cloud/cloud.cfg.d
COMPONENT network-config
)
36 changes: 36 additions & 0 deletions config/linux/network/netplan/10-network-netremote-all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# This plan defines a network topology where a set of interfaces provide gateway services to wireless network clients.
#
# Netplan YAML reference: https://netplan.readthedocs.io/en/stable/netplan-yaml/
#
# Instructions:
# 1. Identify all interfaces, ethernet or otherwise, that provide network services such as DHCP, DNS, etc. to wireless
# network clients. This will typically be, but is not limited to, a single ethernet interface.
# 2. For each interface identified above:
# a. Add a network interface definition entry according to its type ('ethernets', 'vlans', etc.) which disables all
# IP addressing. See the netplan yaml reference URL above for complete options if necessary.
# b. Add the interface name to the 'interfaces' property of the brgateway0 bridge definition to make the interface
# available to all bridge slaves.
# 3. Re-generate ("render") the plan using 'sudo netplan generate'.
# 4. Optionally validate the generated configuration using 'sudo netplan try'.
# 5. Apply the generated configuration using 'sudo netplan apply'.
#
# The default template describes a plan where a single ethernet network interface 'eno2' provides all gateway services.
#

network:
version: 2
renderer: networkd
ethernets:
eno2: # ** Change this to the interface that provides gateway network services (DHCP, DNS, etc.). **
# Disable DHCP on all interfaces that will be part of the virtual bridge interface.
dhcp4: no
dhcp6: no
bridges:
# Define a bridge that will act as a gateway to wireless clients.
brgateway0:
# Configure the bridge to obtain its IP address using DHCP.
dhcp4: yes
# Include interfaces that provide the gateway services to wireless clients. DO NOT ADD wireless interfaces here.
interfaces:
- eno2
7 changes: 7 additions & 0 deletions config/linux/network/netplan/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

install(
FILES
${CMAKE_CURRENT_LIST_DIR}/10-network-netremote-all.yaml
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/netplan
COMPONENT network-config
)
1 change: 1 addition & 0 deletions packaging/deb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set(CPACK_COMPONENTS_ALL
server
hostapd
dev
network-config
)

include(CPack)
24 changes: 3 additions & 21 deletions src/linux/external/hostap/systemd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ configure_file(
)

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/[email protected]
${CMAKE_CURRENT_BINARY_DIR}/[email protected]
@ONLY
)

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/[email protected]
${CMAKE_CURRENT_BINARY_DIR}/[email protected]
${CMAKE_CURRENT_SOURCE_DIR}/[email protected]
${CMAKE_CURRENT_BINARY_DIR}/[email protected]
@ONLY
)

Expand All @@ -37,26 +31,14 @@ install(

install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/[email protected]
CONFIGURATIONS Release
DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/system
RENAME [email protected]
COMPONENT hostapd
)

install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/[email protected]
CONFIGURATIONS Debug RelWithDebInfo MinSizeRel
${CMAKE_CURRENT_BINARY_DIR}/[email protected]
DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/system
RENAME [email protected]
COMPONENT hostapd
)

install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/[email protected]
CONFIGURATIONS Debug RelWithDebInfo MinSizeRel
DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/system
COMPONENT hostapd
)
16 changes: 4 additions & 12 deletions src/linux/external/hostap/systemd/hostapd-example.conf.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
#
# Default hostapd configuration file.
#
# To use this with the provided systemd service unit template [email protected],
# (eg. via 'systemctl enable hostapd@wlan0'), copy this file to
# /etc/hostapd/hostapd-<interface>.conf. For example, to use it with wlan0, copy this file to
# /etc/hostapd/hostapd-wlan0.conf and specify the desired SSID after the 'ssid' property below.
#

# Default (generated) hostapd configuration file.
driver=nl80211
ctrl_interface=${CMAKE_INSTALL_FULL_RUNSTATEDIR}/hostapd
ssid=
Expand All @@ -15,6 +7,6 @@ channel=1
auth_algs=3
wpa=2
wpa_passphrase=password
wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256 SAE
wpa_pairwise=TKIP CCMP
rsn_pairwise=CCMP
wpa_key_mgmt=SAE
rsn_pairwise=CCMP
bridge=brgateway0
2 changes: 2 additions & 0 deletions src/linux/external/hostap/systemd/[email protected]
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[Unit]
Description=Generate default hostapd configuration file
AssertPathExists=@CMAKE_INSTALL_FULL_SYSCONFDIR@/hostapd/hostapd-example.conf
ConditionPathExists=!@CMAKE_INSTALL_FULL_SYSCONFDIR@/hostapd/hostapd-%i.conf

[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/usr/bin/cp @CMAKE_INSTALL_FULL_SYSCONFDIR@/hostapd/hostapd-example.conf @CMAKE_INSTALL_FULL_SYSCONFDIR@/hostapd/hostapd-%i.conf
ExecStart=/usr/bin/sed -i '/^#/d' @CMAKE_INSTALL_FULL_SYSCONFDIR@/hostapd/hostapd-%i.conf
ExecStart=/usr/bin/sed -i 's/ssid=/ssid=%l-ap-%i/' @CMAKE_INSTALL_FULL_SYSCONFDIR@/hostapd/hostapd-%i.conf
13 changes: 0 additions & 13 deletions src/linux/external/hostap/systemd/[email protected]

This file was deleted.

File renamed without changes.

0 comments on commit 0c1d502

Please sign in to comment.