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

core: enable reuse of tcp sockets #1024

Merged
merged 1 commit into from Mar 16, 2017

Conversation

grumvalski
Copy link
Contributor

As discussed on the mailing list and at FOSDEM this is a PR to start the discussion on the support of SO_REUSEPORT.

@miconda
Copy link
Member

miconda commented Mar 14, 2017

The patch is not that complex, so it can be merged, but I think there are few things to add afterwards:

  • find a way to have the option compiled always and enabled if available. Very unlikely someone will re-compile with other define options. With a quick search, maybe uname() (https://linux.die.net/man/2/uname) can be used to detect if the kernel is at least version 3.9.0. Then still have the global kamailio.cfg parameter to enable/disable per kamailio instance.
  • make actual use of this capability -- probably that means ability to create more than one tcp manager process that can listen on the same port and accept new connections

@grumvalski
Copy link
Contributor Author

Thanks for the feedback Daniel.
About the first point, I think that we still need the #define because if SO_REUSEPORT is not defined for the running OS the compilation will fail. As far as I know the option is currently supported in FreeBSD/OpenBSD/NetBSD/Mac OSX, not in Solaris. Maybe we could conditionally add the define in Makefile.defs as it is done for other options depending from the OS?
For the second point for the moment the two concrete usages I've found is for forcing the sending socket in dispatcher and in the uac module, but for sure being able to create additional tcp manager processes is much more interesting!

@miconda
Copy link
Member

miconda commented Mar 16, 2017

I think ifdef can be used to check if SO_REUSEPORT is defined, on macos:

/usr/include/sys/socket.h:136:#define	SO_REUSEPORT	0x0200		/* allow local address & port reuse */

On Linux:

/usr/include/asm-generic/socket.h:25:#define SO_REUSEPORT	15

So it appears it is a define when available.

The two use cases you listed are also important, I haven't thought of them, so I think that if we can get it enabled at compile time based on availability (can be a follow up commit), the PR can be merged.

@grumvalski
Copy link
Contributor Author

Just updated the PR with your suggestion.

@miconda
Copy link
Member

miconda commented Mar 16, 2017

Thanks, it can be merged.

@grumvalski
Copy link
Contributor Author

grumvalski commented Mar 16, 2017

Thank you, I will update the core cookbook to add the new parameter.

- credits to Marco Sinibaldi for the original implementation
@grumvalski grumvalski merged commit 6fcd9f2 into kamailio:master Mar 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants