// SPDX-License-Identifier: GPL-2.0-only/* Copyright (c) 2019 Facebook */#include<linux/bpf.h>#include<linux/bpf_verifier.h>#include<linux/btf.h>#include<linux/filter.h>#include<linux/slab.h>#include<linux/numa.h>#include<linux/seq_file.h>#include<linux/refcount.h>#include<linux/mutex.h>#include<linux/btf_ids.h>#include<linux/rcupdate_wait.h>#include<linux/poll.h>structbpf_struct_ops_value{structbpf_struct_ops_common_valuecommon;chardata[]____cacheline_aligned_in_smp;};#define MAX_TRAMP_IMAGE_PAGES 8structbpf_struct_ops_map{structbpf_mapmap;conststructbpf_struct_ops_desc*st_ops_desc;/* protect map_update */structmutexlock;/* link has all the bpf_links that is populated * to the func ptr of the kernel's struct * (in kvalue.data). */structbpf_link**links;/* ksyms for bpf trampolines */structbpf_ksym**ksyms;u32funcs_cnt;u32image_pages_cnt;/* image_pages is an array of pages that has all the trampolines * that stores the func args before calling the bpf_prog. */void*image_pages[MAX_TRAMP_IMAGE_PAGES];/* The owner moduler's btf. */structbtf*btf;/* uvalue->data stores the kernel struct * (e.g. tcp_congestion_ops) that is more useful * to userspace than the kvalue. For example, * the bpf_prog's id is stored instead of the kernel * address of a func ptr. */structbpf_struct_ops_value*uvalue;/* kvalue.data stores the actual kernel's struct * (e.g. tcp_congestion_ops) that will be * registered to the kernel subsystem. */structbpf_struct_ops_valuekvalue;};structbpf_struct_ops_link{structbpf_linklink;structbpf_map__rcu*map;wait_queue_head_twait_hup;};staticDEFINE_MUTEX(update_mutex);#define VALUE_PREFIX "bpf_struct_ops_"#define VALUE_PREFIX_LEN (sizeof(VALUE_PREFIX) - 1)conststructbpf_verifier_opsbpf_struct_ops_verifier_ops={};conststructbpf_prog_opsbpf_struct_ops_prog_ops=