Lines Matching refs:ctx
76 int lookup_pass(struct bpf_sk_lookup *ctx) in lookup_pass() argument
82 int lookup_drop(struct bpf_sk_lookup *ctx) in lookup_drop() argument
88 int reuseport_pass(struct sk_reuseport_md *ctx) in reuseport_pass() argument
94 int reuseport_drop(struct sk_reuseport_md *ctx) in reuseport_drop() argument
101 int redir_port(struct bpf_sk_lookup *ctx) in redir_port() argument
106 if (ctx->local_port != DST_PORT) in redir_port()
113 err = bpf_sk_assign(ctx, sk, 0); in redir_port()
120 int redir_ip4(struct bpf_sk_lookup *ctx) in redir_ip4() argument
125 if (ctx->family != AF_INET) in redir_ip4()
127 if (ctx->local_port != DST_PORT) in redir_ip4()
129 if (ctx->local_ip4 != DST_IP4) in redir_ip4()
136 err = bpf_sk_assign(ctx, sk, 0); in redir_ip4()
143 int redir_ip6(struct bpf_sk_lookup *ctx) in redir_ip6() argument
148 if (ctx->family != AF_INET6) in redir_ip6()
150 if (ctx->local_port != DST_PORT) in redir_ip6()
152 if (ctx->local_ip6[0] != DST_IP6[0] || in redir_ip6()
153 ctx->local_ip6[1] != DST_IP6[1] || in redir_ip6()
154 ctx->local_ip6[2] != DST_IP6[2] || in redir_ip6()
155 ctx->local_ip6[3] != DST_IP6[3]) in redir_ip6()
162 err = bpf_sk_assign(ctx, sk, 0); in redir_ip6()
168 int select_sock_a(struct bpf_sk_lookup *ctx) in select_sock_a() argument
177 err = bpf_sk_assign(ctx, sk, 0); in select_sock_a()
183 int select_sock_a_no_reuseport(struct bpf_sk_lookup *ctx) in select_sock_a_no_reuseport() argument
192 err = bpf_sk_assign(ctx, sk, BPF_SK_LOOKUP_F_NO_REUSEPORT); in select_sock_a_no_reuseport()
198 int select_sock_b(struct sk_reuseport_md *ctx) in select_sock_b() argument
203 err = bpf_sk_select_reuseport(ctx, &redir_map, &key, 0); in select_sock_b()
209 int sk_assign_eexist(struct bpf_sk_lookup *ctx) in sk_assign_eexist() argument
218 err = bpf_sk_assign(ctx, sk, 0); in sk_assign_eexist()
226 err = bpf_sk_assign(ctx, sk, 0); in sk_assign_eexist()
242 int sk_assign_replace_flag(struct bpf_sk_lookup *ctx) in sk_assign_replace_flag() argument
251 err = bpf_sk_assign(ctx, sk, 0); in sk_assign_replace_flag()
259 err = bpf_sk_assign(ctx, sk, BPF_SK_LOOKUP_F_REPLACE); in sk_assign_replace_flag()
274 int sk_assign_null(struct bpf_sk_lookup *ctx) in sk_assign_null() argument
281 err = bpf_sk_assign(ctx, NULL, 0); in sk_assign_null()
290 err = bpf_sk_assign(ctx, sk, BPF_SK_LOOKUP_F_REPLACE); in sk_assign_null()
296 if (ctx->sk != sk) in sk_assign_null()
298 err = bpf_sk_assign(ctx, NULL, 0); in sk_assign_null()
301 err = bpf_sk_assign(ctx, NULL, BPF_SK_LOOKUP_F_REPLACE); in sk_assign_null()
304 err = bpf_sk_assign(ctx, sk, BPF_SK_LOOKUP_F_REPLACE); in sk_assign_null()
317 int access_ctx_sk(struct bpf_sk_lookup *ctx) in access_ctx_sk() argument
325 if (ctx->sk && ctx->sk->family != AF_INET) in access_ctx_sk()
332 err = bpf_sk_assign(ctx, sk1, 0); in access_ctx_sk()
335 if (ctx->sk != sk1) in access_ctx_sk()
339 if (ctx->sk->family != AF_INET || in access_ctx_sk()
340 ctx->sk->type != SOCK_STREAM || in access_ctx_sk()
341 ctx->sk->state != BPF_TCP_LISTEN) in access_ctx_sk()
345 err = bpf_sk_assign(ctx, NULL, BPF_SK_LOOKUP_F_REPLACE); in access_ctx_sk()
348 if (ctx->sk) in access_ctx_sk()
355 err = bpf_sk_assign(ctx, sk2, BPF_SK_LOOKUP_F_REPLACE); in access_ctx_sk()
358 if (ctx->sk != sk2) in access_ctx_sk()
362 if (ctx->sk->family != AF_INET || in access_ctx_sk()
363 ctx->sk->type != SOCK_STREAM || in access_ctx_sk()
364 ctx->sk->state != BPF_TCP_LISTEN) in access_ctx_sk()
383 int ctx_narrow_access(struct bpf_sk_lookup *ctx) in ctx_narrow_access() argument
389 v4 = (ctx->family == AF_INET); in ctx_narrow_access()
392 if (LSB(ctx->family, 0) != (v4 ? AF_INET : AF_INET6) || in ctx_narrow_access()
393 LSB(ctx->family, 1) != 0 || LSB(ctx->family, 2) != 0 || LSB(ctx->family, 3) != 0) in ctx_narrow_access()
395 if (LSW(ctx->family, 0) != (v4 ? AF_INET : AF_INET6)) in ctx_narrow_access()
399 if (LSB(ctx->protocol, 0) != IPPROTO_TCP || in ctx_narrow_access()
400 LSB(ctx->protocol, 1) != 0 || LSB(ctx->protocol, 2) != 0 || LSB(ctx->protocol, 3) != 0) in ctx_narrow_access()
402 if (LSW(ctx->protocol, 0) != IPPROTO_TCP) in ctx_narrow_access()
406 if (LSB(ctx->remote_port, 0) != ((SRC_PORT >> 0) & 0xff) || in ctx_narrow_access()
407 LSB(ctx->remote_port, 1) != ((SRC_PORT >> 8) & 0xff) || in ctx_narrow_access()
408 LSB(ctx->remote_port, 2) != 0 || LSB(ctx->remote_port, 3) != 0) in ctx_narrow_access()
410 if (LSW(ctx->remote_port, 0) != SRC_PORT) in ctx_narrow_access()
414 if (LSB(ctx->local_port, 0) != ((DST_PORT >> 0) & 0xff) || in ctx_narrow_access()
415 LSB(ctx->local_port, 1) != ((DST_PORT >> 8) & 0xff) || in ctx_narrow_access()
416 LSB(ctx->local_port, 2) != 0 || LSB(ctx->local_port, 3) != 0) in ctx_narrow_access()
418 if (LSW(ctx->local_port, 0) != DST_PORT) in ctx_narrow_access()
424 if (LSB(ctx->remote_ip4, 0) != ((SRC_IP4 >> 0) & 0xff) || in ctx_narrow_access()
425 LSB(ctx->remote_ip4, 1) != ((SRC_IP4 >> 8) & 0xff) || in ctx_narrow_access()
426 LSB(ctx->remote_ip4, 2) != ((SRC_IP4 >> 16) & 0xff) || in ctx_narrow_access()
427 LSB(ctx->remote_ip4, 3) != ((SRC_IP4 >> 24) & 0xff)) in ctx_narrow_access()
429 if (LSW(ctx->remote_ip4, 0) != ((SRC_IP4 >> 0) & 0xffff) || in ctx_narrow_access()
430 LSW(ctx->remote_ip4, 1) != ((SRC_IP4 >> 16) & 0xffff)) in ctx_narrow_access()
434 if (LSB(ctx->local_ip4, 0) != ((DST_IP4 >> 0) & 0xff) || in ctx_narrow_access()
435 LSB(ctx->local_ip4, 1) != ((DST_IP4 >> 8) & 0xff) || in ctx_narrow_access()
436 LSB(ctx->local_ip4, 2) != ((DST_IP4 >> 16) & 0xff) || in ctx_narrow_access()
437 LSB(ctx->local_ip4, 3) != ((DST_IP4 >> 24) & 0xff)) in ctx_narrow_access()
439 if (LSW(ctx->local_ip4, 0) != ((DST_IP4 >> 0) & 0xffff) || in ctx_narrow_access()
440 LSW(ctx->local_ip4, 1) != ((DST_IP4 >> 16) & 0xffff)) in ctx_narrow_access()
444 if (LSB(ctx->remote_ip4, 0) != 0 || LSB(ctx->remote_ip4, 1) != 0 || in ctx_narrow_access()
445 LSB(ctx->remote_ip4, 2) != 0 || LSB(ctx->remote_ip4, 3) != 0) in ctx_narrow_access()
447 if (LSW(ctx->remote_ip4, 0) != 0 || LSW(ctx->remote_ip4, 1) != 0) in ctx_narrow_access()
450 if (LSB(ctx->local_ip4, 0) != 0 || LSB(ctx->local_ip4, 1) != 0 || in ctx_narrow_access()
451 LSB(ctx->local_ip4, 2) != 0 || LSB(ctx->local_ip4, 3) != 0) in ctx_narrow_access()
453 if (LSW(ctx->local_ip4, 0) != 0 || LSW(ctx->local_ip4, 1) != 0) in ctx_narrow_access()
460 if (LSB(ctx->remote_ip6[0], 0) != ((SRC_IP6[0] >> 0) & 0xff) || in ctx_narrow_access()
461 LSB(ctx->remote_ip6[0], 1) != ((SRC_IP6[0] >> 8) & 0xff) || in ctx_narrow_access()
462 LSB(ctx->remote_ip6[0], 2) != ((SRC_IP6[0] >> 16) & 0xff) || in ctx_narrow_access()
463 LSB(ctx->remote_ip6[0], 3) != ((SRC_IP6[0] >> 24) & 0xff) || in ctx_narrow_access()
464 LSB(ctx->remote_ip6[1], 0) != ((SRC_IP6[1] >> 0) & 0xff) || in ctx_narrow_access()
465 LSB(ctx->remote_ip6[1], 1) != ((SRC_IP6[1] >> 8) & 0xff) || in ctx_narrow_access()
466 LSB(ctx->remote_ip6[1], 2) != ((SRC_IP6[1] >> 16) & 0xff) || in ctx_narrow_access()
467 LSB(ctx->remote_ip6[1], 3) != ((SRC_IP6[1] >> 24) & 0xff) || in ctx_narrow_access()
468 LSB(ctx->remote_ip6[2], 0) != ((SRC_IP6[2] >> 0) & 0xff) || in ctx_narrow_access()
469 LSB(ctx->remote_ip6[2], 1) != ((SRC_IP6[2] >> 8) & 0xff) || in ctx_narrow_access()
470 LSB(ctx->remote_ip6[2], 2) != ((SRC_IP6[2] >> 16) & 0xff) || in ctx_narrow_access()
471 LSB(ctx->remote_ip6[2], 3) != ((SRC_IP6[2] >> 24) & 0xff) || in ctx_narrow_access()
472 LSB(ctx->remote_ip6[3], 0) != ((SRC_IP6[3] >> 0) & 0xff) || in ctx_narrow_access()
473 LSB(ctx->remote_ip6[3], 1) != ((SRC_IP6[3] >> 8) & 0xff) || in ctx_narrow_access()
474 LSB(ctx->remote_ip6[3], 2) != ((SRC_IP6[3] >> 16) & 0xff) || in ctx_narrow_access()
475 LSB(ctx->remote_ip6[3], 3) != ((SRC_IP6[3] >> 24) & 0xff)) in ctx_narrow_access()
477 if (LSW(ctx->remote_ip6[0], 0) != ((SRC_IP6[0] >> 0) & 0xffff) || in ctx_narrow_access()
478 LSW(ctx->remote_ip6[0], 1) != ((SRC_IP6[0] >> 16) & 0xffff) || in ctx_narrow_access()
479 LSW(ctx->remote_ip6[1], 0) != ((SRC_IP6[1] >> 0) & 0xffff) || in ctx_narrow_access()
480 LSW(ctx->remote_ip6[1], 1) != ((SRC_IP6[1] >> 16) & 0xffff) || in ctx_narrow_access()
481 LSW(ctx->remote_ip6[2], 0) != ((SRC_IP6[2] >> 0) & 0xffff) || in ctx_narrow_access()
482 LSW(ctx->remote_ip6[2], 1) != ((SRC_IP6[2] >> 16) & 0xffff) || in ctx_narrow_access()
483 LSW(ctx->remote_ip6[3], 0) != ((SRC_IP6[3] >> 0) & 0xffff) || in ctx_narrow_access()
484 LSW(ctx->remote_ip6[3], 1) != ((SRC_IP6[3] >> 16) & 0xffff)) in ctx_narrow_access()
487 if (LSB(ctx->local_ip6[0], 0) != ((DST_IP6[0] >> 0) & 0xff) || in ctx_narrow_access()
488 LSB(ctx->local_ip6[0], 1) != ((DST_IP6[0] >> 8) & 0xff) || in ctx_narrow_access()
489 LSB(ctx->local_ip6[0], 2) != ((DST_IP6[0] >> 16) & 0xff) || in ctx_narrow_access()
490 LSB(ctx->local_ip6[0], 3) != ((DST_IP6[0] >> 24) & 0xff) || in ctx_narrow_access()
491 LSB(ctx->local_ip6[1], 0) != ((DST_IP6[1] >> 0) & 0xff) || in ctx_narrow_access()
492 LSB(ctx->local_ip6[1], 1) != ((DST_IP6[1] >> 8) & 0xff) || in ctx_narrow_access()
493 LSB(ctx->local_ip6[1], 2) != ((DST_IP6[1] >> 16) & 0xff) || in ctx_narrow_access()
494 LSB(ctx->local_ip6[1], 3) != ((DST_IP6[1] >> 24) & 0xff) || in ctx_narrow_access()
495 LSB(ctx->local_ip6[2], 0) != ((DST_IP6[2] >> 0) & 0xff) || in ctx_narrow_access()
496 LSB(ctx->local_ip6[2], 1) != ((DST_IP6[2] >> 8) & 0xff) || in ctx_narrow_access()
497 LSB(ctx->local_ip6[2], 2) != ((DST_IP6[2] >> 16) & 0xff) || in ctx_narrow_access()
498 LSB(ctx->local_ip6[2], 3) != ((DST_IP6[2] >> 24) & 0xff) || in ctx_narrow_access()
499 LSB(ctx->local_ip6[3], 0) != ((DST_IP6[3] >> 0) & 0xff) || in ctx_narrow_access()
500 LSB(ctx->local_ip6[3], 1) != ((DST_IP6[3] >> 8) & 0xff) || in ctx_narrow_access()
501 LSB(ctx->local_ip6[3], 2) != ((DST_IP6[3] >> 16) & 0xff) || in ctx_narrow_access()
502 LSB(ctx->local_ip6[3], 3) != ((DST_IP6[3] >> 24) & 0xff)) in ctx_narrow_access()
504 if (LSW(ctx->local_ip6[0], 0) != ((DST_IP6[0] >> 0) & 0xffff) || in ctx_narrow_access()
505 LSW(ctx->local_ip6[0], 1) != ((DST_IP6[0] >> 16) & 0xffff) || in ctx_narrow_access()
506 LSW(ctx->local_ip6[1], 0) != ((DST_IP6[1] >> 0) & 0xffff) || in ctx_narrow_access()
507 LSW(ctx->local_ip6[1], 1) != ((DST_IP6[1] >> 16) & 0xffff) || in ctx_narrow_access()
508 LSW(ctx->local_ip6[2], 0) != ((DST_IP6[2] >> 0) & 0xffff) || in ctx_narrow_access()
509 LSW(ctx->local_ip6[2], 1) != ((DST_IP6[2] >> 16) & 0xffff) || in ctx_narrow_access()
510 LSW(ctx->local_ip6[3], 0) != ((DST_IP6[3] >> 0) & 0xffff) || in ctx_narrow_access()
511 LSW(ctx->local_ip6[3], 1) != ((DST_IP6[3] >> 16) & 0xffff)) in ctx_narrow_access()
515 if (LSB(ctx->remote_ip6[0], 0) != 0 || LSB(ctx->remote_ip6[0], 1) != 0 || in ctx_narrow_access()
516 LSB(ctx->remote_ip6[0], 2) != 0 || LSB(ctx->remote_ip6[0], 3) != 0 || in ctx_narrow_access()
517 LSB(ctx->remote_ip6[1], 0) != 0 || LSB(ctx->remote_ip6[1], 1) != 0 || in ctx_narrow_access()
518 LSB(ctx->remote_ip6[1], 2) != 0 || LSB(ctx->remote_ip6[1], 3) != 0 || in ctx_narrow_access()
519 LSB(ctx->remote_ip6[2], 0) != 0 || LSB(ctx->remote_ip6[2], 1) != 0 || in ctx_narrow_access()
520 LSB(ctx->remote_ip6[2], 2) != 0 || LSB(ctx->remote_ip6[2], 3) != 0 || in ctx_narrow_access()
521 LSB(ctx->remote_ip6[3], 0) != 0 || LSB(ctx->remote_ip6[3], 1) != 0 || in ctx_narrow_access()
522 LSB(ctx->remote_ip6[3], 2) != 0 || LSB(ctx->remote_ip6[3], 3) != 0) in ctx_narrow_access()
524 if (LSW(ctx->remote_ip6[0], 0) != 0 || LSW(ctx->remote_ip6[0], 1) != 0 || in ctx_narrow_access()
525 LSW(ctx->remote_ip6[1], 0) != 0 || LSW(ctx->remote_ip6[1], 1) != 0 || in ctx_narrow_access()
526 LSW(ctx->remote_ip6[2], 0) != 0 || LSW(ctx->remote_ip6[2], 1) != 0 || in ctx_narrow_access()
527 LSW(ctx->remote_ip6[3], 0) != 0 || LSW(ctx->remote_ip6[3], 1) != 0) in ctx_narrow_access()
530 if (LSB(ctx->local_ip6[0], 0) != 0 || LSB(ctx->local_ip6[0], 1) != 0 || in ctx_narrow_access()
531 LSB(ctx->local_ip6[0], 2) != 0 || LSB(ctx->local_ip6[0], 3) != 0 || in ctx_narrow_access()
532 LSB(ctx->local_ip6[1], 0) != 0 || LSB(ctx->local_ip6[1], 1) != 0 || in ctx_narrow_access()
533 LSB(ctx->local_ip6[1], 2) != 0 || LSB(ctx->local_ip6[1], 3) != 0 || in ctx_narrow_access()
534 LSB(ctx->local_ip6[2], 0) != 0 || LSB(ctx->local_ip6[2], 1) != 0 || in ctx_narrow_access()
535 LSB(ctx->local_ip6[2], 2) != 0 || LSB(ctx->local_ip6[2], 3) != 0 || in ctx_narrow_access()
536 LSB(ctx->local_ip6[3], 0) != 0 || LSB(ctx->local_ip6[3], 1) != 0 || in ctx_narrow_access()
537 LSB(ctx->local_ip6[3], 2) != 0 || LSB(ctx->local_ip6[3], 3) != 0) in ctx_narrow_access()
539 if (LSW(ctx->remote_ip6[0], 0) != 0 || LSW(ctx->remote_ip6[0], 1) != 0 || in ctx_narrow_access()
540 LSW(ctx->remote_ip6[1], 0) != 0 || LSW(ctx->remote_ip6[1], 1) != 0 || in ctx_narrow_access()
541 LSW(ctx->remote_ip6[2], 0) != 0 || LSW(ctx->remote_ip6[2], 1) != 0 || in ctx_narrow_access()
542 LSW(ctx->remote_ip6[3], 0) != 0 || LSW(ctx->remote_ip6[3], 1) != 0) in ctx_narrow_access()
549 bpf_sk_assign(ctx, sk, 0); in ctx_narrow_access()
557 int sk_assign_esocknosupport(struct bpf_sk_lookup *ctx) in sk_assign_esocknosupport() argument
567 err = bpf_sk_assign(ctx, sk, 0); in sk_assign_esocknosupport()
582 int multi_prog_pass1(struct bpf_sk_lookup *ctx) in multi_prog_pass1() argument
589 int multi_prog_pass2(struct bpf_sk_lookup *ctx) in multi_prog_pass2() argument
596 int multi_prog_drop1(struct bpf_sk_lookup *ctx) in multi_prog_drop1() argument
603 int multi_prog_drop2(struct bpf_sk_lookup *ctx) in multi_prog_drop2() argument
609 static __always_inline int select_server_a(struct bpf_sk_lookup *ctx) in select_server_a() argument
618 err = bpf_sk_assign(ctx, sk, 0); in select_server_a()
627 int multi_prog_redir1(struct bpf_sk_lookup *ctx) in multi_prog_redir1() argument
631 ret = select_server_a(ctx); in multi_prog_redir1()
637 int multi_prog_redir2(struct bpf_sk_lookup *ctx) in multi_prog_redir2() argument
641 ret = select_server_a(ctx); in multi_prog_redir2()