1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2 // Copyright (c) 2020 Cloudflare
9 #include <sys/socket.h>
11 #include <bpf/bpf_endian.h>
12 #include <bpf/bpf_helpers.h>
14 #define IP4(a, b, c, d) \
15 bpf_htonl((((__u32)(a) & 0xffU) << 24) | \
16 (((__u32)(b) & 0xffU) << 16) | \
17 (((__u32)(c) & 0xffU) << 8) | \
18 (((__u32)(d) & 0xffU) << 0))
19 #define IP6(aaaa, bbbb, cccc, dddd) \
20 { bpf_htonl(aaaa), bpf_htonl(bbbb), bpf_htonl(cccc), bpf_htonl(dddd) }
22 /* Macros for least-significant byte and word accesses. */
23 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
24 #define LSE_INDEX(index, size) (index)
26 #define LSE_INDEX(index, size) ((size) - (index) - 1)
28 #define LSB(value, index) \
29 (((__u8 *)&(value))[LSE_INDEX((index), sizeof(value))])
30 #define LSW(value, index) \
31 (((__u16 *)&(value))[LSE_INDEX((index), sizeof(value) / 2)])
36 __uint(type, BPF_MAP_TYPE_SOCKMAP);
37 __uint(max_entries, MAX_SOCKS);
40 } redir_map SEC(".maps");
43 __uint(type, BPF_MAP_TYPE_ARRAY);
44 __uint(max_entries, 2);
47 } run_map SEC(".maps");
59 /* Addressable key/value constants for convenience */
60 static const int KEY_PROG1 = PROG1;
61 static const int KEY_PROG2 = PROG2;
62 static const int PROG_DONE = 1;
64 static const __u32 KEY_SERVER_A = SERVER_A;
65 static const __u32 KEY_SERVER_B = SERVER_B;
67 static const __u16 SRC_PORT = bpf_htons(8008);
68 static const __u32 SRC_IP4 = IP4(127, 0, 0, 2);
69 static const __u32 SRC_IP6[] = IP6(0xfd000000, 0x0, 0x0, 0x00000002);
71 static const __u16 DST_PORT = 7007; /* Host byte order */
72 static const __u32 DST_IP4 = IP4(127, 0, 0, 1);
73 static const __u32 DST_IP6[] = IP6(0xfd000000, 0x0, 0x0, 0x00000001);
75 SEC("sk_lookup/lookup_pass")
76 int lookup_pass(struct bpf_sk_lookup *ctx)
81 SEC("sk_lookup/lookup_drop")
82 int lookup_drop(struct bpf_sk_lookup *ctx)
87 SEC("sk_reuseport/reuse_pass")
88 int reuseport_pass(struct sk_reuseport_md *ctx)
93 SEC("sk_reuseport/reuse_drop")
94 int reuseport_drop(struct sk_reuseport_md *ctx)
99 /* Redirect packets destined for port DST_PORT to socket at redir_map[0]. */
100 SEC("sk_lookup/redir_port")
101 int redir_port(struct bpf_sk_lookup *ctx)
106 if (ctx->local_port != DST_PORT)
109 sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_A);
113 err = bpf_sk_assign(ctx, sk, 0);
115 return err ? SK_DROP : SK_PASS;
118 /* Redirect packets destined for DST_IP4 address to socket at redir_map[0]. */
119 SEC("sk_lookup/redir_ip4")
120 int redir_ip4(struct bpf_sk_lookup *ctx)
125 if (ctx->family != AF_INET)
127 if (ctx->local_port != DST_PORT)
129 if (ctx->local_ip4 != DST_IP4)
132 sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_A);
136 err = bpf_sk_assign(ctx, sk, 0);
138 return err ? SK_DROP : SK_PASS;
141 /* Redirect packets destined for DST_IP6 address to socket at redir_map[0]. */
142 SEC("sk_lookup/redir_ip6")
143 int redir_ip6(struct bpf_sk_lookup *ctx)
148 if (ctx->family != AF_INET6)
150 if (ctx->local_port != DST_PORT)
152 if (ctx->local_ip6[0] != DST_IP6[0] ||
153 ctx->local_ip6[1] != DST_IP6[1] ||
154 ctx->local_ip6[2] != DST_IP6[2] ||
155 ctx->local_ip6[3] != DST_IP6[3])
158 sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_A);
162 err = bpf_sk_assign(ctx, sk, 0);
164 return err ? SK_DROP : SK_PASS;
167 SEC("sk_lookup/select_sock_a")
168 int select_sock_a(struct bpf_sk_lookup *ctx)
173 sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_A);
177 err = bpf_sk_assign(ctx, sk, 0);
179 return err ? SK_DROP : SK_PASS;
182 SEC("sk_lookup/select_sock_a_no_reuseport")
183 int select_sock_a_no_reuseport(struct bpf_sk_lookup *ctx)
188 sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_A);
192 err = bpf_sk_assign(ctx, sk, BPF_SK_LOOKUP_F_NO_REUSEPORT);
194 return err ? SK_DROP : SK_PASS;
197 SEC("sk_reuseport/select_sock_b")
198 int select_sock_b(struct sk_reuseport_md *ctx)
200 __u32 key = KEY_SERVER_B;
203 err = bpf_sk_select_reuseport(ctx, &redir_map, &key, 0);
204 return err ? SK_DROP : SK_PASS;
207 /* Check that bpf_sk_assign() returns -EEXIST if socket already selected. */
208 SEC("sk_lookup/sk_assign_eexist")
209 int sk_assign_eexist(struct bpf_sk_lookup *ctx)
215 sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_B);
218 err = bpf_sk_assign(ctx, sk, 0);
223 sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_A);
226 err = bpf_sk_assign(ctx, sk, 0);
227 if (err != -EEXIST) {
228 bpf_printk("sk_assign returned %d, expected %d\n",
233 ret = SK_PASS; /* Success, redirect to KEY_SERVER_B */
240 /* Check that bpf_sk_assign(BPF_SK_LOOKUP_F_REPLACE) can override selection. */
241 SEC("sk_lookup/sk_assign_replace_flag")
242 int sk_assign_replace_flag(struct bpf_sk_lookup *ctx)
248 sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_A);
251 err = bpf_sk_assign(ctx, sk, 0);
256 sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_B);
259 err = bpf_sk_assign(ctx, sk, BPF_SK_LOOKUP_F_REPLACE);
261 bpf_printk("sk_assign returned %d, expected 0\n", err);
265 ret = SK_PASS; /* Success, redirect to KEY_SERVER_B */
272 /* Check that bpf_sk_assign(sk=NULL) is accepted. */
273 SEC("sk_lookup/sk_assign_null")
274 int sk_assign_null(struct bpf_sk_lookup *ctx)
276 struct bpf_sock *sk = NULL;
281 err = bpf_sk_assign(ctx, NULL, 0);
283 bpf_printk("sk_assign returned %d, expected 0\n", err);
287 sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_B);
290 err = bpf_sk_assign(ctx, sk, BPF_SK_LOOKUP_F_REPLACE);
292 bpf_printk("sk_assign returned %d, expected 0\n", err);
298 err = bpf_sk_assign(ctx, NULL, 0);
301 err = bpf_sk_assign(ctx, NULL, BPF_SK_LOOKUP_F_REPLACE);
304 err = bpf_sk_assign(ctx, sk, BPF_SK_LOOKUP_F_REPLACE);
308 ret = SK_PASS; /* Success, redirect to KEY_SERVER_B */
315 /* Check that selected sk is accessible through context. */
316 SEC("sk_lookup/access_ctx_sk")
317 int access_ctx_sk(struct bpf_sk_lookup *ctx)
319 struct bpf_sock *sk1 = NULL, *sk2 = NULL;
324 /* Try accessing unassigned (NULL) ctx->sk field */
325 if (ctx->sk && ctx->sk->family != AF_INET)
328 /* Assign a value to ctx->sk */
329 sk1 = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_A);
332 err = bpf_sk_assign(ctx, sk1, 0);
338 /* Access ctx->sk fields */
339 if (ctx->sk->family != AF_INET ||
340 ctx->sk->type != SOCK_STREAM ||
341 ctx->sk->state != BPF_TCP_LISTEN)
344 /* Reset selection */
345 err = bpf_sk_assign(ctx, NULL, BPF_SK_LOOKUP_F_REPLACE);
351 /* Assign another socket */
352 sk2 = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_B);
355 err = bpf_sk_assign(ctx, sk2, BPF_SK_LOOKUP_F_REPLACE);
361 /* Access reassigned ctx->sk fields */
362 if (ctx->sk->family != AF_INET ||
363 ctx->sk->type != SOCK_STREAM ||
364 ctx->sk->state != BPF_TCP_LISTEN)
367 ret = SK_PASS; /* Success, redirect to KEY_SERVER_B */
376 /* Check narrow loads from ctx fields that support them.
378 * Narrow loads of size >= target field size from a non-zero offset
379 * are not covered because they give bogus results, that is the
380 * verifier ignores the offset.
382 SEC("sk_lookup/ctx_narrow_access")
383 int ctx_narrow_access(struct bpf_sk_lookup *ctx)
389 v4 = (ctx->family == AF_INET);
391 /* Narrow loads from family field */
392 if (LSB(ctx->family, 0) != (v4 ? AF_INET : AF_INET6) ||
393 LSB(ctx->family, 1) != 0 || LSB(ctx->family, 2) != 0 || LSB(ctx->family, 3) != 0)
395 if (LSW(ctx->family, 0) != (v4 ? AF_INET : AF_INET6))
398 /* Narrow loads from protocol field */
399 if (LSB(ctx->protocol, 0) != IPPROTO_TCP ||
400 LSB(ctx->protocol, 1) != 0 || LSB(ctx->protocol, 2) != 0 || LSB(ctx->protocol, 3) != 0)
402 if (LSW(ctx->protocol, 0) != IPPROTO_TCP)
405 /* Narrow loads from remote_port field. Expect SRC_PORT. */
406 if (LSB(ctx->remote_port, 0) != ((SRC_PORT >> 0) & 0xff) ||
407 LSB(ctx->remote_port, 1) != ((SRC_PORT >> 8) & 0xff) ||
408 LSB(ctx->remote_port, 2) != 0 || LSB(ctx->remote_port, 3) != 0)
410 if (LSW(ctx->remote_port, 0) != SRC_PORT)
413 /* Narrow loads from local_port field. Expect DST_PORT. */
414 if (LSB(ctx->local_port, 0) != ((DST_PORT >> 0) & 0xff) ||
415 LSB(ctx->local_port, 1) != ((DST_PORT >> 8) & 0xff) ||
416 LSB(ctx->local_port, 2) != 0 || LSB(ctx->local_port, 3) != 0)
418 if (LSW(ctx->local_port, 0) != DST_PORT)
421 /* Narrow loads from IPv4 fields */
423 /* Expect SRC_IP4 in remote_ip4 */
424 if (LSB(ctx->remote_ip4, 0) != ((SRC_IP4 >> 0) & 0xff) ||
425 LSB(ctx->remote_ip4, 1) != ((SRC_IP4 >> 8) & 0xff) ||
426 LSB(ctx->remote_ip4, 2) != ((SRC_IP4 >> 16) & 0xff) ||
427 LSB(ctx->remote_ip4, 3) != ((SRC_IP4 >> 24) & 0xff))
429 if (LSW(ctx->remote_ip4, 0) != ((SRC_IP4 >> 0) & 0xffff) ||
430 LSW(ctx->remote_ip4, 1) != ((SRC_IP4 >> 16) & 0xffff))
433 /* Expect DST_IP4 in local_ip4 */
434 if (LSB(ctx->local_ip4, 0) != ((DST_IP4 >> 0) & 0xff) ||
435 LSB(ctx->local_ip4, 1) != ((DST_IP4 >> 8) & 0xff) ||
436 LSB(ctx->local_ip4, 2) != ((DST_IP4 >> 16) & 0xff) ||
437 LSB(ctx->local_ip4, 3) != ((DST_IP4 >> 24) & 0xff))
439 if (LSW(ctx->local_ip4, 0) != ((DST_IP4 >> 0) & 0xffff) ||
440 LSW(ctx->local_ip4, 1) != ((DST_IP4 >> 16) & 0xffff))
443 /* Expect 0.0.0.0 IPs when family != AF_INET */
444 if (LSB(ctx->remote_ip4, 0) != 0 || LSB(ctx->remote_ip4, 1) != 0 ||
445 LSB(ctx->remote_ip4, 2) != 0 || LSB(ctx->remote_ip4, 3) != 0)
447 if (LSW(ctx->remote_ip4, 0) != 0 || LSW(ctx->remote_ip4, 1) != 0)
450 if (LSB(ctx->local_ip4, 0) != 0 || LSB(ctx->local_ip4, 1) != 0 ||
451 LSB(ctx->local_ip4, 2) != 0 || LSB(ctx->local_ip4, 3) != 0)
453 if (LSW(ctx->local_ip4, 0) != 0 || LSW(ctx->local_ip4, 1) != 0)
457 /* Narrow loads from IPv6 fields */
459 /* Expect SRC_IP6 in remote_ip6 */
460 if (LSB(ctx->remote_ip6[0], 0) != ((SRC_IP6[0] >> 0) & 0xff) ||
461 LSB(ctx->remote_ip6[0], 1) != ((SRC_IP6[0] >> 8) & 0xff) ||
462 LSB(ctx->remote_ip6[0], 2) != ((SRC_IP6[0] >> 16) & 0xff) ||
463 LSB(ctx->remote_ip6[0], 3) != ((SRC_IP6[0] >> 24) & 0xff) ||
464 LSB(ctx->remote_ip6[1], 0) != ((SRC_IP6[1] >> 0) & 0xff) ||
465 LSB(ctx->remote_ip6[1], 1) != ((SRC_IP6[1] >> 8) & 0xff) ||
466 LSB(ctx->remote_ip6[1], 2) != ((SRC_IP6[1] >> 16) & 0xff) ||
467 LSB(ctx->remote_ip6[1], 3) != ((SRC_IP6[1] >> 24) & 0xff) ||
468 LSB(ctx->remote_ip6[2], 0) != ((SRC_IP6[2] >> 0) & 0xff) ||
469 LSB(ctx->remote_ip6[2], 1) != ((SRC_IP6[2] >> 8) & 0xff) ||
470 LSB(ctx->remote_ip6[2], 2) != ((SRC_IP6[2] >> 16) & 0xff) ||
471 LSB(ctx->remote_ip6[2], 3) != ((SRC_IP6[2] >> 24) & 0xff) ||
472 LSB(ctx->remote_ip6[3], 0) != ((SRC_IP6[3] >> 0) & 0xff) ||
473 LSB(ctx->remote_ip6[3], 1) != ((SRC_IP6[3] >> 8) & 0xff) ||
474 LSB(ctx->remote_ip6[3], 2) != ((SRC_IP6[3] >> 16) & 0xff) ||
475 LSB(ctx->remote_ip6[3], 3) != ((SRC_IP6[3] >> 24) & 0xff))
477 if (LSW(ctx->remote_ip6[0], 0) != ((SRC_IP6[0] >> 0) & 0xffff) ||
478 LSW(ctx->remote_ip6[0], 1) != ((SRC_IP6[0] >> 16) & 0xffff) ||
479 LSW(ctx->remote_ip6[1], 0) != ((SRC_IP6[1] >> 0) & 0xffff) ||
480 LSW(ctx->remote_ip6[1], 1) != ((SRC_IP6[1] >> 16) & 0xffff) ||
481 LSW(ctx->remote_ip6[2], 0) != ((SRC_IP6[2] >> 0) & 0xffff) ||
482 LSW(ctx->remote_ip6[2], 1) != ((SRC_IP6[2] >> 16) & 0xffff) ||
483 LSW(ctx->remote_ip6[3], 0) != ((SRC_IP6[3] >> 0) & 0xffff) ||
484 LSW(ctx->remote_ip6[3], 1) != ((SRC_IP6[3] >> 16) & 0xffff))
486 /* Expect DST_IP6 in local_ip6 */
487 if (LSB(ctx->local_ip6[0], 0) != ((DST_IP6[0] >> 0) & 0xff) ||
488 LSB(ctx->local_ip6[0], 1) != ((DST_IP6[0] >> 8) & 0xff) ||
489 LSB(ctx->local_ip6[0], 2) != ((DST_IP6[0] >> 16) & 0xff) ||
490 LSB(ctx->local_ip6[0], 3) != ((DST_IP6[0] >> 24) & 0xff) ||
491 LSB(ctx->local_ip6[1], 0) != ((DST_IP6[1] >> 0) & 0xff) ||
492 LSB(ctx->local_ip6[1], 1) != ((DST_IP6[1] >> 8) & 0xff) ||
493 LSB(ctx->local_ip6[1], 2) != ((DST_IP6[1] >> 16) & 0xff) ||
494 LSB(ctx->local_ip6[1], 3) != ((DST_IP6[1] >> 24) & 0xff) ||
495 LSB(ctx->local_ip6[2], 0) != ((DST_IP6[2] >> 0) & 0xff) ||
496 LSB(ctx->local_ip6[2], 1) != ((DST_IP6[2] >> 8) & 0xff) ||
497 LSB(ctx->local_ip6[2], 2) != ((DST_IP6[2] >> 16) & 0xff) ||
498 LSB(ctx->local_ip6[2], 3) != ((DST_IP6[2] >> 24) & 0xff) ||
499 LSB(ctx->local_ip6[3], 0) != ((DST_IP6[3] >> 0) & 0xff) ||
500 LSB(ctx->local_ip6[3], 1) != ((DST_IP6[3] >> 8) & 0xff) ||
501 LSB(ctx->local_ip6[3], 2) != ((DST_IP6[3] >> 16) & 0xff) ||
502 LSB(ctx->local_ip6[3], 3) != ((DST_IP6[3] >> 24) & 0xff))
504 if (LSW(ctx->local_ip6[0], 0) != ((DST_IP6[0] >> 0) & 0xffff) ||
505 LSW(ctx->local_ip6[0], 1) != ((DST_IP6[0] >> 16) & 0xffff) ||
506 LSW(ctx->local_ip6[1], 0) != ((DST_IP6[1] >> 0) & 0xffff) ||
507 LSW(ctx->local_ip6[1], 1) != ((DST_IP6[1] >> 16) & 0xffff) ||
508 LSW(ctx->local_ip6[2], 0) != ((DST_IP6[2] >> 0) & 0xffff) ||
509 LSW(ctx->local_ip6[2], 1) != ((DST_IP6[2] >> 16) & 0xffff) ||
510 LSW(ctx->local_ip6[3], 0) != ((DST_IP6[3] >> 0) & 0xffff) ||
511 LSW(ctx->local_ip6[3], 1) != ((DST_IP6[3] >> 16) & 0xffff))
514 /* Expect :: IPs when family != AF_INET6 */
515 if (LSB(ctx->remote_ip6[0], 0) != 0 || LSB(ctx->remote_ip6[0], 1) != 0 ||
516 LSB(ctx->remote_ip6[0], 2) != 0 || LSB(ctx->remote_ip6[0], 3) != 0 ||
517 LSB(ctx->remote_ip6[1], 0) != 0 || LSB(ctx->remote_ip6[1], 1) != 0 ||
518 LSB(ctx->remote_ip6[1], 2) != 0 || LSB(ctx->remote_ip6[1], 3) != 0 ||
519 LSB(ctx->remote_ip6[2], 0) != 0 || LSB(ctx->remote_ip6[2], 1) != 0 ||
520 LSB(ctx->remote_ip6[2], 2) != 0 || LSB(ctx->remote_ip6[2], 3) != 0 ||
521 LSB(ctx->remote_ip6[3], 0) != 0 || LSB(ctx->remote_ip6[3], 1) != 0 ||
522 LSB(ctx->remote_ip6[3], 2) != 0 || LSB(ctx->remote_ip6[3], 3) != 0)
524 if (LSW(ctx->remote_ip6[0], 0) != 0 || LSW(ctx->remote_ip6[0], 1) != 0 ||
525 LSW(ctx->remote_ip6[1], 0) != 0 || LSW(ctx->remote_ip6[1], 1) != 0 ||
526 LSW(ctx->remote_ip6[2], 0) != 0 || LSW(ctx->remote_ip6[2], 1) != 0 ||
527 LSW(ctx->remote_ip6[3], 0) != 0 || LSW(ctx->remote_ip6[3], 1) != 0)
530 if (LSB(ctx->local_ip6[0], 0) != 0 || LSB(ctx->local_ip6[0], 1) != 0 ||
531 LSB(ctx->local_ip6[0], 2) != 0 || LSB(ctx->local_ip6[0], 3) != 0 ||
532 LSB(ctx->local_ip6[1], 0) != 0 || LSB(ctx->local_ip6[1], 1) != 0 ||
533 LSB(ctx->local_ip6[1], 2) != 0 || LSB(ctx->local_ip6[1], 3) != 0 ||
534 LSB(ctx->local_ip6[2], 0) != 0 || LSB(ctx->local_ip6[2], 1) != 0 ||
535 LSB(ctx->local_ip6[2], 2) != 0 || LSB(ctx->local_ip6[2], 3) != 0 ||
536 LSB(ctx->local_ip6[3], 0) != 0 || LSB(ctx->local_ip6[3], 1) != 0 ||
537 LSB(ctx->local_ip6[3], 2) != 0 || LSB(ctx->local_ip6[3], 3) != 0)
539 if (LSW(ctx->remote_ip6[0], 0) != 0 || LSW(ctx->remote_ip6[0], 1) != 0 ||
540 LSW(ctx->remote_ip6[1], 0) != 0 || LSW(ctx->remote_ip6[1], 1) != 0 ||
541 LSW(ctx->remote_ip6[2], 0) != 0 || LSW(ctx->remote_ip6[2], 1) != 0 ||
542 LSW(ctx->remote_ip6[3], 0) != 0 || LSW(ctx->remote_ip6[3], 1) != 0)
546 /* Success, redirect to KEY_SERVER_B */
547 sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_B);
549 bpf_sk_assign(ctx, sk, 0);
555 /* Check that sk_assign rejects SERVER_A socket with -ESOCKNOSUPPORT */
556 SEC("sk_lookup/sk_assign_esocknosupport")
557 int sk_assign_esocknosupport(struct bpf_sk_lookup *ctx)
563 sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_A);
567 err = bpf_sk_assign(ctx, sk, 0);
568 if (err != -ESOCKTNOSUPPORT) {
569 bpf_printk("sk_assign returned %d, expected %d\n",
570 err, -ESOCKTNOSUPPORT);
574 ret = SK_PASS; /* Success, pass to regular lookup */
581 SEC("sk_lookup/multi_prog_pass1")
582 int multi_prog_pass1(struct bpf_sk_lookup *ctx)
584 bpf_map_update_elem(&run_map, &KEY_PROG1, &PROG_DONE, BPF_ANY);
588 SEC("sk_lookup/multi_prog_pass2")
589 int multi_prog_pass2(struct bpf_sk_lookup *ctx)
591 bpf_map_update_elem(&run_map, &KEY_PROG2, &PROG_DONE, BPF_ANY);
595 SEC("sk_lookup/multi_prog_drop1")
596 int multi_prog_drop1(struct bpf_sk_lookup *ctx)
598 bpf_map_update_elem(&run_map, &KEY_PROG1, &PROG_DONE, BPF_ANY);
602 SEC("sk_lookup/multi_prog_drop2")
603 int multi_prog_drop2(struct bpf_sk_lookup *ctx)
605 bpf_map_update_elem(&run_map, &KEY_PROG2, &PROG_DONE, BPF_ANY);
609 static __always_inline int select_server_a(struct bpf_sk_lookup *ctx)
614 sk = bpf_map_lookup_elem(&redir_map, &KEY_SERVER_A);
618 err = bpf_sk_assign(ctx, sk, 0);
626 SEC("sk_lookup/multi_prog_redir1")
627 int multi_prog_redir1(struct bpf_sk_lookup *ctx)
631 ret = select_server_a(ctx);
632 bpf_map_update_elem(&run_map, &KEY_PROG1, &PROG_DONE, BPF_ANY);
636 SEC("sk_lookup/multi_prog_redir2")
637 int multi_prog_redir2(struct bpf_sk_lookup *ctx)
641 ret = select_server_a(ctx);
642 bpf_map_update_elem(&run_map, &KEY_PROG2, &PROG_DONE, BPF_ANY);
646 char _license[] SEC("license") = "Dual BSD/GPL";
647 __u32 _version SEC("version") = 1;