Skip to content

Commit

Permalink
Add switchdev-online service to hold off on network init (dentproject#56
Browse files Browse the repository at this point in the history
)

* Add switchdev-online service to hold off on network init

The addresses a race condition between the switchdev driver, udev
and ifupdown2. In some cases, ifupdown2 attempts to configure
switchdev interfaces (1) before they are ready, or (2) before any
udev rules have had a chance to rename them per udev configuration.
When this happens, not all interfaces are configured correctly.

The solution is to

1. create a dummy systemd service for each switchdev interface
   (platform specific) that depends on the well-known systemd
   device path for that netdev (currently
   'sys-subsystem-net-devices-FOO.device'.
2. Make the system-wide network-pre.service depend on *all*
   switchdev devices coming online
3. make ifupdown2 (via networking.service) depend on network-pre.service

See
https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/

Signed-off-by: Carl Roth <rothcar@amazon.com>

* update line ending per review

Signed-off-by: Carl Roth <rothcar@amazon.com>

* Add switchdev-online support for Delta tn48m-dn platforms

- based on fixes for non-DN systems
- please check my work, I don't have physical access to these
  systems to verify port count

Signed-off-by: Carl Roth <rothcar@amazon.com>

* spray for spelling, per review

Signed-off-by: Carl Roth <rothcar@amazon.com>
  • Loading branch information
rothcar authored Mar 9, 2021
1 parent b392bba commit 1d553a9
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Unit]
After=network-pre.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[Unit]
Description=Online state for switchdev device %i

# See e.g.
# https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
Wants=network-pre.target
Before=network-pre.target

# this is the naming scheme currently used for network devices
Wants=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device

[Service]
Type=simple
RemainAfterExit=yes
ExecStart=/bin/true
TimeoutStartSec=30

[Install]
WantedBy=network.target
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ def baseconfig(self):
self.insmod("prestera_sw.ko")
self.insmod("prestera_pci.ko")

# set up systemctl rules
for swp in range(1, 53):
cmd = "systemctl enable switchdev-online@swp%d" % swp
subprocess.check_call(cmd, shell=True)

return True
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ def baseconfig(self):
self.insmod("prestera_sw.ko")
self.insmod("prestera_pci.ko")

# set up systemctl rules
for swp in range(1, 53):
cmd = "systemctl enable switchdev-online@swp%d" % swp
subprocess.check_call(cmd, shell=True)

return True
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,9 @@ def baseconfig(self):
self.insmod("prestera_sw.ko")
self.insmod("prestera_pci.ko")

# set up systemctl rules
for swp in range(1, 49):
cmd = "systemctl enable switchdev-online@swp%d" % swp
subprocess.check_call(cmd, shell=True)

return True
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ def baseconfig(self):
# Suggested by Taras Chornyi
self.modprobe('prestera_pci')

# set up systemctl rules
for swp in range(1, 49):
cmd = "systemctl enable switchdev-online@swp%d" % swp
subprocess.check_call(cmd, shell=True)

return True
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@ def baseconfig(self):
# Suggested by Taras Chornyi
self.modprobe('prestera_pci')

# set up systemctl rules
for swp in range(1, 53):
cmd = "systemctl enable switchdev-online@swp%d" % swp
subprocess.check_call(cmd, shell=True)

return True

Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ def baseconfig(self):
# Suggested by Taras Chornyi
self.modprobe('prestera_pci')

# set up systemctl rules
for swp in range(1, 53):
cmd = "systemctl enable switchdev-online@swp%d" % swp
subprocess.check_call(cmd, shell=True)

return True
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ def baseconfig(self):
# Suggested by Taras Chornyi
self.modprobe('prestera_pci')

# set up systemctl rules
for swp in range(1, 49):
cmd = "systemctl enable switchdev-online@swp%d" % swp
subprocess.check_call(cmd, shell=True)

return True
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ def baseconfig(self):
# Suggested by Taras Chornyi
self.modprobe('prestera_pci')

# set up systemctl rules
for swp in range(1, 53):
cmd = "systemctl enable switchdev-online@swp%d" % swp
subprocess.check_call(cmd, shell=True)

return True
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@ def baseconfig(self):
# Suggested by Taras Chornyi
self.modprobe('prestera_pci')

# set up systemctl rules
for swp in range(1, 53):
cmd = "systemctl enable switchdev-online@swp%d" % swp
subprocess.check_call(cmd, shell=True)

return True

Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ def baseconfig(self):
# Suggested by Taras Chornyi
self.modprobe('prestera_pci')

# set up systemctl rules
for swp in range(1, 53):
cmd = "systemctl enable switchdev-online@swp%d" % swp
subprocess.check_call(cmd, shell=True)

return True

0 comments on commit 1d553a9

Please sign in to comment.