test_sockmap_invalid_update.c (453B)
1// SPDX-License-Identifier: GPL-2.0 2// Copyright (c) 2020 Cloudflare 3#include "vmlinux.h" 4#include <bpf/bpf_helpers.h> 5 6struct { 7 __uint(type, BPF_MAP_TYPE_SOCKMAP); 8 __uint(max_entries, 1); 9 __type(key, __u32); 10 __type(value, __u64); 11} map SEC(".maps"); 12 13SEC("sockops") 14int bpf_sockmap(struct bpf_sock_ops *skops) 15{ 16 __u32 key = 0; 17 18 if (skops->sk) 19 bpf_map_update_elem(&map, &key, skops->sk, 0); 20 return 0; 21} 22 23char _license[] SEC("license") = "GPL";