redis / hiredis

Minimalistic C client for Redis >= 1.2
BSD 3-Clause "New" or "Revised" License
6.21k stars 1.81k forks source link

Binding hiredis client to a VRF device #698

Open steelman72 opened 5 years ago

steelman72 commented 5 years ago

I'm trying to port the hiredis client onto a box running Linux 4.14 kernel that supports multiple VRFs. The Redis server may be reachable through any of the configured VRFs. I was wondering if there is a possibility of adding a new option to redis(Async)ConnectWithOption() calls to bind the TCP socket to a specific VRF device (using SO_BINDTODEVICE). Note that the source IP does not work for me since the IP address can be reused across VRFs on the same box.

Thanks

Ref: https://www.kernel.org/doc/Documentation/networking/vrf.txt

michael-grunder commented 4 years ago

Sorry about the delay, I'm going through old issues.

It's certainly possible to add another flag. I suppose in this case it would have to be a flag accompanied with associated data (for the device name). Another option is to allow you to configure a callback for setting socket options in whichever way you want.

steelman72 commented 4 years ago

Either option sounds fine. Thanks for taking a look into this. Cheers On Saturday, July 11, 2020, 01:47:19 AM GMT+5:30, Michael Grunder notifications@github.com wrote:

Sorry about the delay, I'm going through old issues.

It's certainly possible to add another flag. I suppose in this case it would have to be a flag accompanied with associated data (for the device name). Another option is to allow you to configure a callback for setting socket options in whichever way you want.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

michael-grunder commented 2 years ago

I've been going through all our old issues in preparation for the upcoming release and had time to look at this.

Since we define _XOPEN_SOURCE the only feasible way to add the functionality is to allow users to set a custom callback that we invoke after a successful call to socket.

A small example on how to use it to set SO_BINDTODEVICE