mirror of
https://github.com/safing/portmaster
synced 2025-09-04 03:29:12 +00:00
Add UDPLite check to ip4_datagram_connect hook
This commit is contained in:
parent
67e2dba0d5
commit
8312c7c6b5
3 changed files with 11 additions and 7 deletions
Binary file not shown.
Binary file not shown.
|
@ -105,19 +105,23 @@ int BPF_PROG(udp_v4_connect, struct sock *sk) {
|
||||||
// Read PID (Careful: This is the Thread Group ID in kernel speak!)
|
// Read PID (Careful: This is the Thread Group ID in kernel speak!)
|
||||||
udp_info->pid = __builtin_bswap32((u32)(bpf_get_current_pid_tgid() >> 32));
|
udp_info->pid = __builtin_bswap32((u32)(bpf_get_current_pid_tgid() >> 32));
|
||||||
|
|
||||||
// Set src and dist ports
|
// Set src and dst ports
|
||||||
udp_info->sport = __builtin_bswap16(sk->__sk_common.skc_num);
|
udp_info->sport = __builtin_bswap16(sk->__sk_common.skc_num);
|
||||||
udp_info->dport = sk->__sk_common.skc_dport;
|
udp_info->dport = sk->__sk_common.skc_dport;
|
||||||
|
|
||||||
// Set src and dist IPs
|
// Set src and dst IPs
|
||||||
udp_info->saddr[0] = __builtin_bswap32(sk->__sk_common.skc_rcv_saddr);
|
udp_info->saddr[0] = __builtin_bswap32(sk->__sk_common.skc_rcv_saddr);
|
||||||
udp_info->daddr[0] = __builtin_bswap32(sk->__sk_common.skc_daddr);
|
udp_info->daddr[0] = __builtin_bswap32(sk->__sk_common.skc_daddr);
|
||||||
|
|
||||||
// Set IP version
|
// Set IP version
|
||||||
udp_info->ipVersion = 4;
|
udp_info->ipVersion = 4;
|
||||||
|
|
||||||
// Set protocol. No way to detect udplite for ipv4
|
// Set protocol
|
||||||
udp_info->protocol = UDP;
|
if(sk->sk_protocol == IPPROTO_UDPLITE) {
|
||||||
|
udp_info->protocol = UDPLite;
|
||||||
|
} else {
|
||||||
|
udp_info->protocol = UDP;
|
||||||
|
}
|
||||||
|
|
||||||
// Send event
|
// Send event
|
||||||
bpf_ringbuf_submit(udp_info, 0);
|
bpf_ringbuf_submit(udp_info, 0);
|
||||||
|
@ -154,11 +158,11 @@ int BPF_PROG(udp_v6_connect, struct sock *sk) {
|
||||||
// Read PID (Careful: This is the Thread Group ID in kernel speak!)
|
// Read PID (Careful: This is the Thread Group ID in kernel speak!)
|
||||||
udp_info->pid = __builtin_bswap32((u32)(bpf_get_current_pid_tgid() >> 32));
|
udp_info->pid = __builtin_bswap32((u32)(bpf_get_current_pid_tgid() >> 32));
|
||||||
|
|
||||||
// Set src and dist ports
|
// Set src and dst ports
|
||||||
udp_info->sport = __builtin_bswap16(sk->__sk_common.skc_num);
|
udp_info->sport = __builtin_bswap16(sk->__sk_common.skc_num);
|
||||||
udp_info->dport = sk->__sk_common.skc_dport;
|
udp_info->dport = sk->__sk_common.skc_dport;
|
||||||
|
|
||||||
// Set src and dist IPs
|
// Set src and dst IPs
|
||||||
for(int i = 0; i < 4; i++) {
|
for(int i = 0; i < 4; i++) {
|
||||||
udp_info->saddr[i] = __builtin_bswap32(sk->__sk_common.skc_v6_rcv_saddr.in6_u.u6_addr32[i]);
|
udp_info->saddr[i] = __builtin_bswap32(sk->__sk_common.skc_v6_rcv_saddr.in6_u.u6_addr32[i]);
|
||||||
}
|
}
|
||||||
|
@ -169,7 +173,7 @@ int BPF_PROG(udp_v6_connect, struct sock *sk) {
|
||||||
// IP version
|
// IP version
|
||||||
udp_info->ipVersion = 6;
|
udp_info->ipVersion = 6;
|
||||||
|
|
||||||
// Set protocol for UDPLite
|
// Set protocol
|
||||||
if(sk->sk_protocol == IPPROTO_UDPLITE) {
|
if(sk->sk_protocol == IPPROTO_UDPLITE) {
|
||||||
udp_info->protocol = UDPLite;
|
udp_info->protocol = UDPLite;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue