1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2020 Cloudflare
4 #include <bpf/bpf_helpers.h>
7 __uint(type
, BPF_MAP_TYPE_SOCKMAP
);
8 __uint(max_entries
, 1);
14 __uint(type
, BPF_MAP_TYPE_SOCKMAP
);
15 __uint(max_entries
, 1);
18 } dst_sock_map
SEC(".maps");
21 __uint(type
, BPF_MAP_TYPE_SOCKHASH
);
22 __uint(max_entries
, 1);
25 } dst_sock_hash
SEC(".maps");
27 SEC("classifier/copy_sock_map")
28 int copy_sock_map(void *ctx
)
34 sk
= bpf_map_lookup_elem(&src
, &key
);
38 if (bpf_map_update_elem(&dst_sock_map
, &key
, sk
, 0))
41 if (bpf_map_update_elem(&dst_sock_hash
, &key
, sk
, 0))
45 return failed
? SK_DROP
: SK_PASS
;
48 char _license
[] SEC("license") = "GPL";