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

pidfile is the same when running with -T #396

Open
ezbik opened this issue Oct 31, 2024 · 6 comments
Open

pidfile is the same when running with -T #396

ezbik opened this issue Oct 31, 2024 · 6 comments

Comments

@ezbik
Copy link

ezbik commented Oct 31, 2024

Pid file is the same regardless of interface name , when running with -T :

/run/.pid

Therefore it is impossible to run multiple instances of dhcpcd on different interfaces in test mode.

The bug doesn't exist in Ubuntu 22.04 ( dhcpcd 7.1.0) and appeared in Ubuntu 24.04 ( dhcpcd 10.0.6)

@ezbik ezbik changed the title pid is the same when running with -T pidfile is the same when running with -T Oct 31, 2024
@perkelix
Copy link
Contributor

That's an odd one. Running separate instances of dhcpcd works fine if it's not in test mode. I wonder what test mode does differently to end up with the same PID file. That's clearly a mistake.

@rsmarples
Copy link
Member

Why do you want to use test mode on many interfaces? Sounds like what you really want is the --noconfigure option?

@rsmarples
Copy link
Member

Also, I can't replicate this at all. When running in test mode a pidfile is never created by dhcpcd.

@ezbik
Copy link
Author

ezbik commented Oct 31, 2024

Here is how to reproduce. Get a system with 2 network cards, echo them to the stdin of the script.

echo enp0s3 enp0s8 | xargs -n1| xargs -II -P10 -- bash -c 'bash -c "dhcpcd -4 -1 I -T | grep new_ip_ad" 2>&1 | sed "s@^@I==@" '|sort

Output :

enp0s3==DUID 00:01:00:01:2e:b6:24:a4:02:47:5b:32:b6:f2
enp0s3==dhcpcd exited
enp0s3==dhcpcd-10.0.6 starting
enp0s3==enp0s3: IAID 5b:32:b6:f2
enp0s3==enp0s3: leased 10.0.2.15 for 86400 seconds
enp0s3==enp0s3: rebinding lease of 10.0.2.15
enp0s3==new_ip_address='10.0.2.15'
enp0s8==dhcpcd exited
enp0s8==dhcpcd-10.0.6 starting
enp0s8==main: pidfile_lock 1076662: File exists

You see, they started to fight for the same pidfile. And its content is :

root@px24 [~] # cat /run/.pid 
1076662

I need it to simply query DHCP server status on multiple interfaces without configuring them. Unfortunately --noconfigure doesn't output lots of useful info (full dump of the DHCP response).

So the solution would be to include interface name to the pidfile filename when running with -T.

@ezbik
Copy link
Author

ezbik commented Nov 1, 2024

fixed on my side with unshare -m bash -c "mount -t tmpfs -o size=10M tmpfs /run/; dhcpcd -1 $DEV -T"

@rsmarples
Copy link
Member

--configure has all the information in the environment prefixed with _new.
You could write an exit hook to dump this to a file as well if you wanted.
I'm unsure how to replicate this though as in no instance does dhcpcd create a pidfile with -T for me.

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

No branches or pull requests

3 participants