Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add switchdev-online service to hold off on network init #56

Merged
merged 4 commits into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

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

I am wondering about this line, as the drop-in above has

After=network-pre.target

Isn’t that a contradiction?

/cc @tjjh89017

Copy link

@tjjh89017 tjjh89017 Apr 9, 2021

Choose a reason for hiding this comment

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

@paulmenzel
Suppose you mean After=network-pre.target in networking.service.d/switchdev-online.conf conflicts with Before=network-pre.target in [email protected] (these are two different service description file)

In Rothcar's patch, he want to guarantee that networking.service will always be executed after ONLP insert ASIC driver.
he made [email protected] will always be before network-pre.target.
and networking.service (ifupdown2) will always be after network-pre.target

So you can see this order below in Rothcar's patch:

  1. execute [email protected] (load driver, let Linux can see those port)
  2. reach network-pre.target
  3. execute networking.service (load config. if ports isn't existing, it will fail)

and in my PR #65
try to guarantee this order below (from No. 3 to 5)

  1. execute [email protected] (load driver, let Linux can see those port)
  2. reach network-pre.target
  3. execute networking.service (load config. if ports and config are mismatch, it will fail)
  4. reach network.target
  5. execute other service which need network (e.g. isc-dhcp-server. if ports are not configured correctly, it will fail)

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I totally screwed up, and in networking.service.d/switchdev-online.conf only read switchdev-online and associated it with the switchdev-online unit. But it belongs to to the unit networking.service. Sorry about that.


# 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