brintos

brintos / linux-shallow public Read only

0
0
Text · 453 B · 02a59e2 Raw
24 lines · c
1// SPDX-License-Identifier: GPL-2.02// Copyright (c) 2020 Cloudflare3#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";24