int tracepoint_skb_copy_datagram_iovec()

in bpf/accesslog/syscalls/transfer.c [489:539]


int tracepoint_skb_copy_datagram_iovec(struct trace_event_raw_skb_copy_datagram_iovec* ctx) {
    __u64 id = bpf_get_current_pid_tgid();
    struct sk_buff *buff = (struct sk_buff *)ctx->skbaddr;
    struct sock_data_args_t *data_args = bpf_map_lookup_elem(&socket_data_args, &id);
    if (data_args == NULL) {
        bpf_map_delete_elem(&sk_buff_receive_detail_map, &buff);
        return 0;
    }

    struct sock *sock = _(buff->sk);
    if (sock != NULL) {
        data_args->sk_role = get_sock_role(data_args->sk_role, sock);
    }

    data_args->package_count++;
    data_args->total_package_size += _(buff->len);

    struct skb_receive_detail *detail = bpf_map_lookup_elem(&sk_buff_receive_detail_map, &buff);
    if (detail == NULL) {
        return 0;
    }
    bpf_map_delete_elem(&sk_buff_receive_detail_map, &buff);

    // l4
    data_args->enter_l4_time = detail->enter_tcp_rcv_time;
    data_args->exit_l4_time = detail->exit_tcp_rcv_time;

    // l3
    if (detail->exit_ip_rcv_time > 0 && detail->enter_ip_rcv_time > 0) {
        data_args->l3_duration += detail->exit_ip_rcv_time - detail->enter_ip_rcv_time;
    }
    if (detail->ip_rcv_finish_time > 0 && detail->enter_ip_rcv_time > 0) {
        data_args->l3_rcv_duration += detail->ip_rcv_finish_time - detail->enter_ip_rcv_time;
    }
    if (detail->ip_local_finish_time > 0 && detail->ip_local_time > 0) {
        data_args->l3_local_duration += detail->ip_local_finish_time - detail->ip_local_time;
    }
    data_args->total_net_filter_count += detail->total_nf_count;
    data_args->total_net_filter_time += detail->total_nf_time;

    // l2
    data_args->ifindex = detail->ifindex;
    if (detail->netif_receive_time > 0 && detail->ip_local_time > 0) {
        data_args->total_package_to_queue_time += detail->ip_local_time - detail->netif_receive_time;
    }
    if (detail->ip_local_time > 0) {
        data_args->total_package_receive_from_queue_time += bpf_ktime_get_ns() - detail->ip_local_time;
    }

    return 0;
}