kohler / click

The Click modular router: fast modular packet processing and analysis
Other
734 stars 324 forks source link

Make sure that UNIX sockets are removed before binding to them #496

Open klanmiko opened 2 years ago

klanmiko commented 2 years ago

We run linux userspace click under the runit process supervisor. Sometimes click coredumps for one reason or another, and when restarting click we encounter errors about "address already in use", sometimes from the click control socket file, and sometimes from other unix socket files.

Socket and ControlSocket cleanup code will attempt to remove the unix socket files they create. However, if click were to crash or otherwise exit without calling cleanup, click will require an operator to intervene and delete any unix socket resources not removed.

This change places an unlink() call before calls to bind() where a unix socket is used. No error or logging is handled since it is a best effort attempt to cleanup the unix socket.

I haven't done much evaluation on what the side effects might be, but I believe there aren't any? Feedback is appreciated, and I hope this helps.