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

Bind to a list of Network Interfaces #471

Merged
merged 33 commits into from
Jul 11, 2024
Merged

Bind to a list of Network Interfaces #471

merged 33 commits into from
Jul 11, 2024

Conversation

waahm7
Copy link
Contributor

@waahm7 waahm7 commented Jun 27, 2024

Description of changes:

  • Updates the connection manager to take a list of network interface names to distribute the connections.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov-commenter
Copy link

codecov-commenter commented Jun 27, 2024

Codecov Report

Attention: Patch coverage is 26.08696% with 17 lines in your changes missing coverage. Please review.

Project coverage is 79.32%. Comparing base (079ccfd) to head (3f123bd).

Files Patch % Lines
source/connection_manager.c 26.08% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #471      +/-   ##
==========================================
- Coverage   79.42%   79.32%   -0.11%     
==========================================
  Files          27       27              
  Lines       11575    11597      +22     
==========================================
+ Hits         9194     9199       +5     
- Misses       2381     2398      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@waahm7 waahm7 changed the title WIP | Bind to a list of Network Interfaces Bind to a list of Network Interfaces Jun 28, 2024
@waahm7 waahm7 marked this pull request as ready for review June 28, 2024 17:32
* is set, this list will be ignored and all the connections will go to that network interface. This option is only
* supported on Linux and macOS and will be ignored on other platforms.
*/
const struct aws_array_list *network_interface_names_list;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just have users pass a normal-ass C-array, and separate length.

Suggested change
const struct aws_array_list *network_interface_names_list;
const struct aws_byte_cursor *network_interface_names_array;
size_t num_network_interface_names;

There's already precedent for this, see a few lines up:

const struct aws_http2_setting *initial_settings_array;
size_t num_initial_settings;

It's simpler for everyone to just use vanilla C arrays. Most uses of this will be in language bindings, and most other languages have their own easier-to-use way to create an array. C++ users can do: std::vector<aws_byte_cursor> names and pass it like names.data(), names.size(). C users can still use aws_array_list if they want, and pass a pointer to the first item. Or simply use aws_mem_calloc().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, in S3, the precedence is array list for checksum algorithms list. I debated between char *[16] and aws_array_arraylist, but aws_byte_cursor * seems much nicer. I will update it to that.

* round-robin algorithm. We picked round-robin because it is trivial to implement and good enough. We can later
* update to a more complex distribution algorithm if required.
*/
struct aws_array_list network_interface_names_list;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial: _list makes me think aws_linked_list

Suggested change
struct aws_array_list network_interface_names_list;
struct aws_array_list network_interface_names;

? aws_array_list_length(options->network_interface_names_list)
: 0;
/* Ignore the network_interface_names_list if socket_options already contains a network_interface_name. */
if (manager->socket_options.network_interface_name[0] == '\0' && network_interface_names_list_length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debatable: maybe raise an error if both are set? instead of silently ignoring one of them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated.

source/connection_manager.c Outdated Show resolved Hide resolved
source/connection_manager.c Outdated Show resolved Hide resolved
@waahm7 waahm7 requested a review from graebm July 3, 2024 22:14
@waahm7 waahm7 merged commit 652e2fe into main Jul 11, 2024
35 checks passed
@waahm7 waahm7 deleted the bind-network-interface branch July 11, 2024 18:22
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.

3 participants