Skip to content

Commit 1f3cd06

Browse files
committed
feat!: drop sendto enter evts gen, testing and parsing code
As the `sendto` exit events contain all the information needed, drop `sendto` enter events generation from all drivers, and all related testing and parsing code. BREAKING CHANGE: drop `sendto` enter evts gen and parsing Signed-off-by: Leonardo Di Giovanna <[email protected]>
1 parent 6bcbbaa commit 1f3cd06

File tree

15 files changed

+32
-574
lines changed

15 files changed

+32
-574
lines changed

driver/bpf/fillers.h

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,56 +1682,6 @@ FILLER(sys_send_x, true) {
16821682
return bpf_val_to_ring_len(data, 0, tuple_size);
16831683
}
16841684

1685-
FILLER(sys_sendto_e, true) {
1686-
/* Parameter 1: fd (type: PT_FD) */
1687-
int64_t fd = (int64_t)(int32_t)bpf_syscall_get_argument(data, 0);
1688-
int res = bpf_push_s64_to_ring(data, fd);
1689-
CHECK_RES(res);
1690-
1691-
/* Parameter 2: size (type: PT_UINT32) */
1692-
uint32_t size = (uint32_t)bpf_syscall_get_argument(data, 2);
1693-
res = bpf_push_u32_to_ring(data, size);
1694-
CHECK_RES(res);
1695-
1696-
/* Get the address */
1697-
struct sockaddr __user *usrsockaddr =
1698-
(struct sockaddr __user *)bpf_syscall_get_argument(data, 4);
1699-
1700-
/* Get the address len */
1701-
unsigned long usrsockaddr_len = bpf_syscall_get_argument(data, 5);
1702-
1703-
struct sockaddr *ksockaddr = (struct sockaddr *)data->tmp_scratch;
1704-
bool use_sockaddr_user_data = false;
1705-
bool push_socktuple = true;
1706-
if(usrsockaddr != NULL && usrsockaddr_len != 0) {
1707-
/* Copy the address into kernel memory */
1708-
res = bpf_addr_to_kernel(usrsockaddr, usrsockaddr_len, ksockaddr);
1709-
if(likely(res >= 0)) {
1710-
/* Convert the fd into socket endpoint information */
1711-
use_sockaddr_user_data = true;
1712-
} else {
1713-
/* Do not send any socket endpoint information */
1714-
push_socktuple = false;
1715-
}
1716-
}
1717-
1718-
uint32_t socktuple_size = 0;
1719-
if(push_socktuple) {
1720-
/* Convert the fd into socket endpoint information */
1721-
socktuple_size = bpf_fd_to_socktuple(data,
1722-
fd,
1723-
ksockaddr,
1724-
usrsockaddr_len,
1725-
use_sockaddr_user_data,
1726-
false,
1727-
data->tmp_scratch + sizeof(struct sockaddr_storage));
1728-
}
1729-
1730-
/* Parameter 3: tuple (type: PT_SOCKTUPLE) */
1731-
data->curarg_already_on_frame = true;
1732-
return bpf_val_to_ring_len(data, 0, socktuple_size);
1733-
}
1734-
17351685
FILLER(sys_sendto_x, true) {
17361686
/* Parameter 1: res (type: PT_ERRNO) */
17371687
long retval = bpf_syscall_get_retval(data->ctx);

driver/fillers_table.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const struct ppm_event_entry g_ppm_events[PPM_EVENT_MAX] = {
4747
[PPME_SOCKET_LISTEN_X] = {FILLER_REF(sys_listen_x)},
4848
[PPME_SOCKET_SEND_E] = {FILLER_REF(sys_send_e)},
4949
[PPME_SOCKET_SEND_X] = {FILLER_REF(sys_send_x)},
50-
[PPME_SOCKET_SENDTO_E] = {FILLER_REF(sys_sendto_e)},
50+
[PPME_SOCKET_SENDTO_E] = {FILLER_DISABLED},
5151
[PPME_SOCKET_SENDTO_X] = {FILLER_REF(sys_sendto_x)},
5252
[PPME_SOCKET_RECV_E] = {FILLER_DISABLED},
5353
[PPME_SOCKET_RECV_X] = {FILLER_REF(sys_recv_x)},

driver/modern_bpf/programs/tail_called/events/syscall_dispatched_events/sendto.bpf.c

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,6 @@
88

99
#include <helpers/interfaces/variable_size_event.h>
1010

11-
/*=============================== ENTER EVENT ===========================*/
12-
13-
SEC("tp_btf/sys_enter")
14-
int BPF_PROG(sendto_e, struct pt_regs *regs, long id) {
15-
struct auxiliary_map *auxmap = auxmap__get();
16-
if(!auxmap) {
17-
return 0;
18-
}
19-
auxmap__preload_event_header(auxmap, PPME_SOCKET_SENDTO_E);
20-
21-
/*=============================== COLLECT PARAMETERS ===========================*/
22-
23-
/* Collect parameters at the beginning to manage socketcalls */
24-
unsigned long args[5] = {0};
25-
extract__network_args(args, 5, regs);
26-
27-
/* Parameter 1: fd (type: PT_FD) */
28-
int64_t socket_fd = (int32_t)args[0];
29-
auxmap__store_s64_param(auxmap, socket_fd);
30-
31-
/* Parameter 2: size (type: PT_UINT32) */
32-
uint32_t size = (uint32_t)args[2];
33-
auxmap__store_u32_param(auxmap, size);
34-
35-
/* Parameter 3: tuple (type: PT_SOCKTUPLE) */
36-
/* TODO: Here we don't know if this fd is a socket or not,
37-
* since we are in the enter event and the syscall could fail.
38-
* This shouldn't be a problem since if it is not a socket fd
39-
* the `bpf_probe_read()` call will fail. Probably we have to move it
40-
* in the exit event.
41-
*/
42-
struct sockaddr *usrsockaddr = (struct sockaddr *)args[4];
43-
/* Notice: the following will push an empty parameter if
44-
* something goes wrong (e.g.: fd not valid) */
45-
auxmap__store_socktuple_param(auxmap, socket_fd, OUTBOUND, usrsockaddr);
46-
47-
/*=============================== COLLECT PARAMETERS ===========================*/
48-
49-
auxmap__finalize_event_header(auxmap);
50-
51-
auxmap__submit_event(auxmap);
52-
53-
return 0;
54-
}
55-
56-
/*=============================== ENTER EVENT ===========================*/
57-
5811
/*=============================== EXIT EVENT ===========================*/
5912

6013
SEC("tp_btf/sys_exit")

driver/ppm_fillers.c

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,65 +2353,6 @@ int f_sys_send_x(struct event_filler_arguments *args) {
23532353
return add_sentinel(args);
23542354
}
23552355

2356-
int f_sys_sendto_e(struct event_filler_arguments *args) {
2357-
int res;
2358-
unsigned long val;
2359-
int64_t fd;
2360-
uint32_t size;
2361-
struct sockaddr __user *usrsockaddr;
2362-
unsigned long usrsockaddr_len;
2363-
struct sockaddr_storage address;
2364-
struct sockaddr *ksockaddr = NULL;
2365-
unsigned long sockaddr_len = 0;
2366-
bool use_sockaddr = false;
2367-
char *targetbuf = args->str_storage;
2368-
uint16_t tuple_size = 0;
2369-
2370-
/* Parameter 1: fd (type: PT_FD) */
2371-
syscall_get_arguments_deprecated(args, 0, 1, &val);
2372-
fd = (int64_t)(int32_t)val;
2373-
res = val_to_ring(args, fd, 0, false, 0);
2374-
CHECK_RES(res);
2375-
2376-
/* Parameter 2: size (type: PT_UINT32) */
2377-
syscall_get_arguments_deprecated(args, 2, 1, &val);
2378-
size = (uint32_t)val;
2379-
res = val_to_ring(args, size, 0, false, 0);
2380-
CHECK_RES(res);
2381-
2382-
/* Get the address */
2383-
syscall_get_arguments_deprecated(args, 4, 1, &val);
2384-
usrsockaddr = (struct sockaddr __user *)val;
2385-
2386-
/* Get the address len */
2387-
syscall_get_arguments_deprecated(args, 5, 1, &usrsockaddr_len);
2388-
2389-
if(usrsockaddr != NULL && usrsockaddr_len != 0) {
2390-
/* Copy the address into kernel memory */
2391-
res = addr_to_kernel(usrsockaddr, usrsockaddr_len, (struct sockaddr *)&address);
2392-
if(likely(res >= 0)) {
2393-
ksockaddr = (struct sockaddr *)&address;
2394-
sockaddr_len = usrsockaddr_len;
2395-
use_sockaddr = true;
2396-
}
2397-
}
2398-
2399-
/* Convert the fd into socket endpoint information */
2400-
tuple_size = fd_to_socktuple((int)fd,
2401-
ksockaddr,
2402-
sockaddr_len,
2403-
use_sockaddr,
2404-
false,
2405-
targetbuf,
2406-
STR_STORAGE_SIZE);
2407-
2408-
/* Parameter 3: tuple (type: PT_SOCKTUPLE) */
2409-
res = val_to_ring(args, (uint64_t)(unsigned long)targetbuf, tuple_size, false, 0);
2410-
CHECK_RES(res);
2411-
2412-
return add_sentinel(args);
2413-
}
2414-
24152356
int f_sys_sendto_x(struct event_filler_arguments *args) {
24162357
int res;
24172358
int64_t retval;

driver/ppm_fillers.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ or GPL2.txt for full copies of the license.
4040
FN(sys_accept_x) \
4141
FN(sys_send_e) \
4242
FN(sys_send_x) \
43-
FN(sys_sendto_e) \
4443
FN(sys_sendto_x) \
4544
FN(sys_sendmsg_x) \
4645
FN(sys_sendmsg_x_2) \

0 commit comments

Comments
 (0)