blob: 461b0376be50c14fb74fd811d8de61f073f54eeb [file] [log] [blame]
// Licensed to Apache Software Foundation (ASF) under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Apache Software Foundation (ASF) licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#include "api.h"
#include "skb.h"
#define MAX_PROTOCOL_SOCKET_READ_LENGTH 255
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, 10000);
__type(key, __u32);
__type(value, __u32);
} process_monitor_control SEC(".maps");
static __inline bool tgid_should_trace(__u32 tgid) {
__u32 *val = bpf_map_lookup_elem(&process_monitor_control, &tgid);
if (!val) {
return false;
}
return (*val) == 1 ? true : false;
}
struct recv_msg_args {
struct sock* sock;
struct msghdr* msg;
};
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, 10000);
__type(key, __u64);
__type(value, struct recv_msg_args);
} receiving_args SEC(".maps");
struct socket_buffer_reader_t {
__u64 timestamp;
void *channel_ref;
__u8 protocol;
__u8 direction;
__u16 size;
__u32 pid;
char buffer[MAX_PROTOCOL_SOCKET_READ_LENGTH + 1];
};
struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__type(key, __u32);
__type(value, struct socket_buffer_reader_t);
__uint(max_entries, 1);
} socket_buffer_reader_map SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
} socket_buffer_send_queue SEC(".maps");