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

Update loading and chaining of the connection_limit #65

Merged
merged 1 commit into from
Nov 2, 2023

Conversation

sanfern
Copy link
Contributor

@sanfern sanfern commented Sep 11, 2023

This PR is to make changes to the connection limit program to load from the l3afd. Specifically, the modification involves removing the loading and chaining functionality from the user program. The user program will no longer run as a daemon. Additionally, maps will be accessed from a directory path specific to the interface, which is located at /sys/bpf/fs/<iface>.

@sanfern
Copy link
Contributor Author

sanfern commented Sep 12, 2023

This PR depends l3af-project/l3afd#279

@sanfern sanfern added this to the eBPF enhancements milestone Sep 22, 2023
@sanfern sanfern linked an issue Sep 22, 2023 that may be closed by this pull request
@sanfern sanfern force-pushed the sanfern-rem-load-cl branch from 48d4f58 to 0d6e440 Compare September 24, 2023 13:28
Comment on lines +41 to +42
static int is_ipv4_loopback(uint32_t *addr4);
static int is_ipv6_loopback(struct in6_addr *addr6);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why the inconsistent types? i.e. why not struct in_addr in line 41?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The purpose of this method is to confirm whether the local address is a loopback address or not. It achieves this by extracting the current connection count from procfs. When it comes to IPv4, the local address is in uint32 format, whereas for IPv6 addresses, there are multiple uint32 values. Therefore, the data is organized into a struct and then passed to this verification method.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That doesn't answer the question. Why the inconsistent types of uint32_t vs struct in6_addr? Why not simply uint8_t* in both cases? or struct in_addr and struct in6_addr?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Filed #69

connection-limit/connection_limit_user.c Outdated Show resolved Hide resolved
connection-limit/connection_limit_user.c Outdated Show resolved Hide resolved
connection-limit/connection_limit_user.c Outdated Show resolved Hide resolved
connection-limit/connection_limit_user.c Outdated Show resolved Hide resolved
connection-limit/connection_limit_user.c Outdated Show resolved Hide resolved
@sanfern sanfern added the enhancement New feature or request label Sep 27, 2023
@sanfern sanfern force-pushed the sanfern-rem-load-cl branch from 0d6e440 to a859eb6 Compare September 27, 2023 17:55
@sanfern sanfern self-assigned this Oct 3, 2023
@sanfern sanfern force-pushed the sanfern-rem-load-cl branch 2 times, most recently from 47b3041 to ede7129 Compare October 4, 2023 19:30

int map_fd[MAP_COUNT];
int conn_count_map_fd = -1, tcp_conns_map_fd = -1, conn_info_map_fd = -1;
Copy link

Choose a reason for hiding this comment

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

can we retain map_fd[] array and have enums for each index like, CONN_COUNT, TCP_CONNS & CONN_INFO so that its extensible ?

snprintf(map_dir, MAP_PATH_SIZE, "%s/%s", map_base_dir, ifname);
struct stat st = {0};
if (stat(map_dir, &st) != 0) {
mkdir (map_dir, 0700);
Copy link

@aka320 aka320 Oct 13, 2023

Choose a reason for hiding this comment

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

can we handle the error case for mkdir()


memset(ports, '\0', 2048);
Copy link

@aka320 aka320 Oct 13, 2023

Choose a reason for hiding this comment

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

can we have MACRO for the array size ?

@sanfern sanfern force-pushed the sanfern-rem-load-cl branch 2 times, most recently from f4f4092 to 3208c69 Compare October 13, 2023 19:13
@sanfern sanfern force-pushed the sanfern-rem-load-cl branch from 3208c69 to 9fe0987 Compare October 28, 2023 19:18
@sanfern sanfern merged commit 4ab8fc6 into l3af-project:main Nov 2, 2023
@sanfern sanfern deleted the sanfern-rem-load-cl branch November 2, 2023 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Remove hard coding of map paths in eBPF programs
3 participants