Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 // Copyright (c) 2020 Cloudflare
0003 #include "vmlinux.h"
0004 #include <bpf/bpf_helpers.h>
0005 
0006 struct {
0007     __uint(type, BPF_MAP_TYPE_SOCKMAP);
0008     __uint(max_entries, 1);
0009     __type(key, __u32);
0010     __type(value, __u64);
0011 } map SEC(".maps");
0012 
0013 SEC("sockops")
0014 int bpf_sockmap(struct bpf_sock_ops *skops)
0015 {
0016     __u32 key = 0;
0017 
0018     if (skops->sk)
0019         bpf_map_update_elem(&map, &key, skops->sk, 0);
0020     return 0;
0021 }
0022 
0023 char _license[] SEC("license") = "GPL";