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 socket nl_connect_fd() & nl_create_fd() #68

Closed

Conversation

sagilow
Copy link
Contributor

@sagilow sagilow commented Feb 17, 2015

add socket nl_connect_fd() & nl_create_fd()

  • Added option to create socket (fd) without bind.
    It is now possible to forward the socket fd to another child process...
    ...later use nl_connect_fd() to connect to socket from the child process.
  • Added option to disable CLOEXEC even if defined (in socket.h)
    'nl_socket_enable_cloexec' & 'nl_socket_disable_cloexec'
    No change to current default behavior.

Signed-off-by: Sagi Lowenhardt sagil@infinidat.com

-    Added option to create socket (fd) without bind.
     It is now possible to forward the socket fd to another child process...
     ...later use nl_connect_fd() to connect to socket from the child process.

-    Added option to disable CLOEXEC even if defined (in socket.h)
     'nl_socket_enable_cloexec' & 'nl_socket_disable_cloexec'
     No change to current default behavior.

 Signed-off-by: Sagi Lowenhardt <sagil@infinidat.com>
thom311 added a commit that referenced this pull request Mar 5, 2015
This is based on the patch by sagil@infinidat.com, but heavily modified.

Add a function nl_socket_set_fd(), I renamed it from nl_connect_fd().

Now nl_connect() and nl_socket_set_fd() are implemented independently as
they share little code. But they have similar functionality:
to initialize a libnl socket and set it's file descriptor.

A user who wants libnl to setup the socket can continue to use nl_connect().
A user with special requirements should setup the socket entirely. That includes
calling socket() (with or without SOCK_CLOEXEC), bind(), setting buffer size.

For the same reason I dropped nl_create_fd(). It didn't do much more then
calling socket() -- which the user can do directly.

#68

Signed-off-by: Thomas Haller <thaller@redhat.com>
@thom311
Copy link
Owner

thom311 commented Mar 5, 2015

Hi Sagi,

I applied your patch, but in a second commit I completely rewrote it :)

Originally I thought that nl_connect() should call nl_connect_fd(). But I no longer think so because nl_connect_fd() should not call bind() or nl_socket_set_buffer_size().
nl_connect_fd() should just allow the user to setup the fd without configuring it further.

Also, at that point I renamed nl_connect_fd() to nl_socket_set_fd(), because that seems like a better name.

for now, I merged it and close this pull request. Let's see how this goes and if necessary we can improve it later. How do you like it?

Thank you,
Thomas

@thom311 thom311 closed this Mar 5, 2015
chenyt9 pushed a commit to MotorolaMobilityLLC/external-libnl-headers that referenced this pull request May 6, 2022
This is based on the patch by sagil@infinidat.com, but heavily modified.

Add a function nl_socket_set_fd(), I renamed it from nl_connect_fd().

Now nl_connect() and nl_socket_set_fd() are implemented independently as
they share little code. But they have similar functionality:
to initialize a libnl socket and set it's file descriptor.

A user who wants libnl to setup the socket can continue to use nl_connect().
A user with special requirements should setup the socket entirely. That includes
calling socket() (with or without SOCK_CLOEXEC), bind(), setting buffer size.

For the same reason I dropped nl_create_fd(). It didn't do much more then
calling socket() -- which the user can do directly.

thom311/libnl#68

Signed-off-by: Thomas Haller <thaller@redhat.com>
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