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

Systemd-based socket activation #1171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

schaten
Copy link

@schaten schaten commented Jun 19, 2021

This patch enables systemd-based socket activation of iperf3. To test, build and install this fork, then:

  • mv contrib/iperf3_@.* /etc/systemd/system/
  • systemctl daemon-reload
  • systemctl start iperf3_5201

This will make systemd listen on port 5201. As soon as a client tries to connect, iperf3 is started and takes over.

I originally wanted to add multi-user support, but this is not as easy due to the separate control / data connections.
In combination with loadbalancing (i.e. based on the IP address, client could be NATted to a socket-activated iperf3 instance) it might still be useful..
Also, as the socket-activation was a separate issue, maybe it's useful to others. :)

@gharris999
Copy link

gharris999 commented Dec 30, 2021

This is very helpful. Absent multiple simultaneous client support in iperf3, this allows me to have systemd monitor, say, 24 ports and dynamically launch one-off iperf3 servers to service client requests on those ports. I've built iperf3 from schaten's fork and it works perfectly. It took me a bit to realize that libsystemd-dev was a dependency. I guess that should have been obvious.

Edit: I think schaten's fork requires libsystemd-dev > version 237 in order to work. I.e. won't work on Ubuntu 18.04, but works fine on Ubuntu 20.04 which has version 245.

@friesen-hbk
Copy link

Cool! Yes, it's very helpful!

@mikelpr
Copy link

mikelpr commented Aug 29, 2024

what's blocking the merge of this?

eriksjolund added a commit to eriksjolund/iperf that referenced this pull request Sep 25, 2024
This is a merge commit

Author of the merged in commit
d2d7088
from
https://github.com/schaten/iperf/tree/master
is
Philip Schaten <philip.schaten@stud.uni-goettingen.de>

Erik Sjölund <erik.sjolund@gmail.com> solved the merge conflicts.

As of today 25 September 2024 the PR
esnet#1171
wants to merge 1 commit into
https://github.com/esnet/iperf/tree/master
from
https://github.com/schaten/iperf/tree/master

Info about the branches:

The branch
https://github.com/esnet/iperf/tree/master

is currently the Git commit
0ea9cb6

The branch
https://github.com/schaten/iperf/tree/master
is currently the Git commit
d2d7088
@eriksjolund
Copy link

@schaten Thanks for implementing this functionality!

I would like to use a current esnet:master (https://github.com/esnet/iperf/commits/master/) with the socket activation functionality added. To achieve that I created a git merge commit
eriksjolund@807d33e
in
https://github.com/eriksjolund/iperf/tree/support-socket-activation

I don't know how to properly do git merges, especially the question of which name to write for author. I hope I got it right.
Anyway, a better solution would be to rebase schaten:master on to esnet:master

@schaten could you rebase on to esnet:master and resolve the trivial conflicts?

@schaten
Copy link
Author

schaten commented Sep 25, 2024

Glad to hear this was useful. Thanks everyone. :)
I rebased the branch. Maybe someone (@bmah888) is interested in merging it.

Somehow it took me way too long to test it afterwards, because of the following things. Leaving it here as a reference:

  • Don't forget to regenerate the configure script by running autoconf... Probably very obvious but I don't use autotools so often. The configure script in the git repo should be updated before merging this also. I didn't include that because it changes other stuff that seems unrelated.
  • The socket is started with systemctl start iperf3_@5201.socket (note the '@'), sorry I got this wrong in the initial post here.
  • In the service file under the Unit section, the line Environment=LD_LIBRARY_PATH=/usr/local/lib might be needed if iperf was installed manually with sudo make install.
  • Install libsystemd-dev before building, as @gharris999 mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants