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 check_ifindex(struct bpf_sk_lookup *ctx) in check_ifindex() argument
90 if (ctx->ingress_ifindex == 1) in check_ifindex()
96 int reuseport_pass(struct sk_reuseport_md *ctx) in reuseport_pass() argument
102 int reuseport_drop(struct sk_reuseport_md *ctx) in reuseport_drop() argument
109 int redir_port(struct bpf_sk_lookup *ctx) in redir_port() argument
114 if (ctx->local_port != DST_PORT) in redir_port()
121 err = bpf_sk_assign(ctx, sk, 0); in redir_port()
128 int redir_ip4(struct bpf_sk_lookup *ctx) in redir_ip4() argument
133 if (ctx->family != AF_INET) in redir_ip4()
135 if (ctx->local_port != DST_PORT) in redir_ip4()
137 if (ctx->local_ip4 != DST_IP4) in redir_ip4()
144 err = bpf_sk_assign(ctx, sk, 0); in redir_ip4()
151 int redir_ip6(struct bpf_sk_lookup *ctx) in redir_ip6() argument
156 if (ctx->family != AF_INET6) in redir_ip6()
158 if (ctx->local_port != DST_PORT) in redir_ip6()
160 if (ctx->local_ip6[0] != DST_IP6[0] || in redir_ip6()
161 ctx->local_ip6[1] != DST_IP6[1] || in redir_ip6()
162 ctx->local_ip6[2] != DST_IP6[2] || in redir_ip6()
163 ctx->local_ip6[3] != DST_IP6[3]) in redir_ip6()
170 err = bpf_sk_assign(ctx, sk, 0); in redir_ip6()
176 int select_sock_a(struct bpf_sk_lookup *ctx) in select_sock_a() argument
185 err = bpf_sk_assign(ctx, sk, 0); in select_sock_a()
191 int select_sock_a_no_reuseport(struct bpf_sk_lookup *ctx) in select_sock_a_no_reuseport() argument
200 err = bpf_sk_assign(ctx, sk, BPF_SK_LOOKUP_F_NO_REUSEPORT); in select_sock_a_no_reuseport()
206 int select_sock_b(struct sk_reuseport_md *ctx) in select_sock_b() argument
211 err = bpf_sk_select_reuseport(ctx, &redir_map, &key, 0); in select_sock_b()
217 int sk_assign_eexist(struct bpf_sk_lookup *ctx) in sk_assign_eexist() argument
226 err = bpf_sk_assign(ctx, sk, 0); in sk_assign_eexist()
234 err = bpf_sk_assign(ctx, sk, 0); in sk_assign_eexist()
250 int sk_assign_replace_flag(struct bpf_sk_lookup *ctx) in sk_assign_replace_flag() argument
259 err = bpf_sk_assign(ctx, sk, 0); in sk_assign_replace_flag()
267 err = bpf_sk_assign(ctx, sk, BPF_SK_LOOKUP_F_REPLACE); in sk_assign_replace_flag()
282 int sk_assign_null(struct bpf_sk_lookup *ctx) in sk_assign_null() argument
289 err = bpf_sk_assign(ctx, NULL, 0); in sk_assign_null()
298 err = bpf_sk_assign(ctx, sk, BPF_SK_LOOKUP_F_REPLACE); in sk_assign_null()
304 if (ctx->sk != sk) in sk_assign_null()
306 err = bpf_sk_assign(ctx, NULL, 0); in sk_assign_null()
309 err = bpf_sk_assign(ctx, NULL, BPF_SK_LOOKUP_F_REPLACE); in sk_assign_null()
312 err = bpf_sk_assign(ctx, sk, BPF_SK_LOOKUP_F_REPLACE); in sk_assign_null()
325 int access_ctx_sk(struct bpf_sk_lookup *ctx) in access_ctx_sk() argument
333 if (ctx->sk && ctx->sk->family != AF_INET) in access_ctx_sk()
340 err = bpf_sk_assign(ctx, sk1, 0); in access_ctx_sk()
343 if (ctx->sk != sk1) in access_ctx_sk()
347 if (ctx->sk->family != AF_INET || in access_ctx_sk()
348 ctx->sk->type != SOCK_STREAM || in access_ctx_sk()
349 ctx->sk->state != BPF_TCP_LISTEN) in access_ctx_sk()
353 err = bpf_sk_assign(ctx, NULL, BPF_SK_LOOKUP_F_REPLACE); in access_ctx_sk()
356 if (ctx->sk) in access_ctx_sk()
363 err = bpf_sk_assign(ctx, sk2, BPF_SK_LOOKUP_F_REPLACE); in access_ctx_sk()
366 if (ctx->sk != sk2) in access_ctx_sk()
370 if (ctx->sk->family != AF_INET || in access_ctx_sk()
371 ctx->sk->type != SOCK_STREAM || in access_ctx_sk()
372 ctx->sk->state != BPF_TCP_LISTEN) in access_ctx_sk()
391 int ctx_narrow_access(struct bpf_sk_lookup *ctx) in ctx_narrow_access() argument
397 v4 = (ctx->family == AF_INET); in ctx_narrow_access()
400 if (LSB(ctx->family, 0) != (v4 ? AF_INET : AF_INET6) || in ctx_narrow_access()
401 LSB(ctx->family, 1) != 0 || LSB(ctx->family, 2) != 0 || LSB(ctx->family, 3) != 0) in ctx_narrow_access()
403 if (LSW(ctx->family, 0) != (v4 ? AF_INET : AF_INET6)) in ctx_narrow_access()
407 if (LSB(ctx->protocol, 0) != IPPROTO_TCP || in ctx_narrow_access()
408 LSB(ctx->protocol, 1) != 0 || LSB(ctx->protocol, 2) != 0 || LSB(ctx->protocol, 3) != 0) in ctx_narrow_access()
410 if (LSW(ctx->protocol, 0) != IPPROTO_TCP) in ctx_narrow_access()
414 if (LSB(ctx->remote_port, 0) != ((SRC_PORT >> 0) & 0xff) || in ctx_narrow_access()
415 LSB(ctx->remote_port, 1) != ((SRC_PORT >> 8) & 0xff)) in ctx_narrow_access()
417 if (LSW(ctx->remote_port, 0) != SRC_PORT) in ctx_narrow_access()
427 val_u32 = *(__u32 *)&ctx->remote_port; in ctx_narrow_access()
432 if (LSB(ctx->local_port, 0) != ((DST_PORT >> 0) & 0xff) || in ctx_narrow_access()
433 LSB(ctx->local_port, 1) != ((DST_PORT >> 8) & 0xff) || in ctx_narrow_access()
434 LSB(ctx->local_port, 2) != 0 || LSB(ctx->local_port, 3) != 0) in ctx_narrow_access()
436 if (LSW(ctx->local_port, 0) != DST_PORT) in ctx_narrow_access()
442 if (LSB(ctx->remote_ip4, 0) != ((SRC_IP4 >> 0) & 0xff) || in ctx_narrow_access()
443 LSB(ctx->remote_ip4, 1) != ((SRC_IP4 >> 8) & 0xff) || in ctx_narrow_access()
444 LSB(ctx->remote_ip4, 2) != ((SRC_IP4 >> 16) & 0xff) || in ctx_narrow_access()
445 LSB(ctx->remote_ip4, 3) != ((SRC_IP4 >> 24) & 0xff)) in ctx_narrow_access()
447 if (LSW(ctx->remote_ip4, 0) != ((SRC_IP4 >> 0) & 0xffff) || in ctx_narrow_access()
448 LSW(ctx->remote_ip4, 1) != ((SRC_IP4 >> 16) & 0xffff)) in ctx_narrow_access()
452 if (LSB(ctx->local_ip4, 0) != ((DST_IP4 >> 0) & 0xff) || in ctx_narrow_access()
453 LSB(ctx->local_ip4, 1) != ((DST_IP4 >> 8) & 0xff) || in ctx_narrow_access()
454 LSB(ctx->local_ip4, 2) != ((DST_IP4 >> 16) & 0xff) || in ctx_narrow_access()
455 LSB(ctx->local_ip4, 3) != ((DST_IP4 >> 24) & 0xff)) in ctx_narrow_access()
457 if (LSW(ctx->local_ip4, 0) != ((DST_IP4 >> 0) & 0xffff) || in ctx_narrow_access()
458 LSW(ctx->local_ip4, 1) != ((DST_IP4 >> 16) & 0xffff)) in ctx_narrow_access()
462 if (LSB(ctx->remote_ip4, 0) != 0 || LSB(ctx->remote_ip4, 1) != 0 || in ctx_narrow_access()
463 LSB(ctx->remote_ip4, 2) != 0 || LSB(ctx->remote_ip4, 3) != 0) in ctx_narrow_access()
465 if (LSW(ctx->remote_ip4, 0) != 0 || LSW(ctx->remote_ip4, 1) != 0) in ctx_narrow_access()
468 if (LSB(ctx->local_ip4, 0) != 0 || LSB(ctx->local_ip4, 1) != 0 || in ctx_narrow_access()
469 LSB(ctx->local_ip4, 2) != 0 || LSB(ctx->local_ip4, 3) != 0) in ctx_narrow_access()
471 if (LSW(ctx->local_ip4, 0) != 0 || LSW(ctx->local_ip4, 1) != 0) in ctx_narrow_access()
478 if (LSB(ctx->remote_ip6[0], 0) != ((SRC_IP6[0] >> 0) & 0xff) || in ctx_narrow_access()
479 LSB(ctx->remote_ip6[0], 1) != ((SRC_IP6[0] >> 8) & 0xff) || in ctx_narrow_access()
480 LSB(ctx->remote_ip6[0], 2) != ((SRC_IP6[0] >> 16) & 0xff) || in ctx_narrow_access()
481 LSB(ctx->remote_ip6[0], 3) != ((SRC_IP6[0] >> 24) & 0xff) || in ctx_narrow_access()
482 LSB(ctx->remote_ip6[1], 0) != ((SRC_IP6[1] >> 0) & 0xff) || in ctx_narrow_access()
483 LSB(ctx->remote_ip6[1], 1) != ((SRC_IP6[1] >> 8) & 0xff) || in ctx_narrow_access()
484 LSB(ctx->remote_ip6[1], 2) != ((SRC_IP6[1] >> 16) & 0xff) || in ctx_narrow_access()
485 LSB(ctx->remote_ip6[1], 3) != ((SRC_IP6[1] >> 24) & 0xff) || in ctx_narrow_access()
486 LSB(ctx->remote_ip6[2], 0) != ((SRC_IP6[2] >> 0) & 0xff) || in ctx_narrow_access()
487 LSB(ctx->remote_ip6[2], 1) != ((SRC_IP6[2] >> 8) & 0xff) || in ctx_narrow_access()
488 LSB(ctx->remote_ip6[2], 2) != ((SRC_IP6[2] >> 16) & 0xff) || in ctx_narrow_access()
489 LSB(ctx->remote_ip6[2], 3) != ((SRC_IP6[2] >> 24) & 0xff) || in ctx_narrow_access()
490 LSB(ctx->remote_ip6[3], 0) != ((SRC_IP6[3] >> 0) & 0xff) || in ctx_narrow_access()
491 LSB(ctx->remote_ip6[3], 1) != ((SRC_IP6[3] >> 8) & 0xff) || in ctx_narrow_access()
492 LSB(ctx->remote_ip6[3], 2) != ((SRC_IP6[3] >> 16) & 0xff) || in ctx_narrow_access()
493 LSB(ctx->remote_ip6[3], 3) != ((SRC_IP6[3] >> 24) & 0xff)) in ctx_narrow_access()
495 if (LSW(ctx->remote_ip6[0], 0) != ((SRC_IP6[0] >> 0) & 0xffff) || in ctx_narrow_access()
496 LSW(ctx->remote_ip6[0], 1) != ((SRC_IP6[0] >> 16) & 0xffff) || in ctx_narrow_access()
497 LSW(ctx->remote_ip6[1], 0) != ((SRC_IP6[1] >> 0) & 0xffff) || in ctx_narrow_access()
498 LSW(ctx->remote_ip6[1], 1) != ((SRC_IP6[1] >> 16) & 0xffff) || in ctx_narrow_access()
499 LSW(ctx->remote_ip6[2], 0) != ((SRC_IP6[2] >> 0) & 0xffff) || in ctx_narrow_access()
500 LSW(ctx->remote_ip6[2], 1) != ((SRC_IP6[2] >> 16) & 0xffff) || in ctx_narrow_access()
501 LSW(ctx->remote_ip6[3], 0) != ((SRC_IP6[3] >> 0) & 0xffff) || in ctx_narrow_access()
502 LSW(ctx->remote_ip6[3], 1) != ((SRC_IP6[3] >> 16) & 0xffff)) in ctx_narrow_access()
505 if (LSB(ctx->local_ip6[0], 0) != ((DST_IP6[0] >> 0) & 0xff) || in ctx_narrow_access()
506 LSB(ctx->local_ip6[0], 1) != ((DST_IP6[0] >> 8) & 0xff) || in ctx_narrow_access()
507 LSB(ctx->local_ip6[0], 2) != ((DST_IP6[0] >> 16) & 0xff) || in ctx_narrow_access()
508 LSB(ctx->local_ip6[0], 3) != ((DST_IP6[0] >> 24) & 0xff) || in ctx_narrow_access()
509 LSB(ctx->local_ip6[1], 0) != ((DST_IP6[1] >> 0) & 0xff) || in ctx_narrow_access()
510 LSB(ctx->local_ip6[1], 1) != ((DST_IP6[1] >> 8) & 0xff) || in ctx_narrow_access()
511 LSB(ctx->local_ip6[1], 2) != ((DST_IP6[1] >> 16) & 0xff) || in ctx_narrow_access()
512 LSB(ctx->local_ip6[1], 3) != ((DST_IP6[1] >> 24) & 0xff) || in ctx_narrow_access()
513 LSB(ctx->local_ip6[2], 0) != ((DST_IP6[2] >> 0) & 0xff) || in ctx_narrow_access()
514 LSB(ctx->local_ip6[2], 1) != ((DST_IP6[2] >> 8) & 0xff) || in ctx_narrow_access()
515 LSB(ctx->local_ip6[2], 2) != ((DST_IP6[2] >> 16) & 0xff) || in ctx_narrow_access()
516 LSB(ctx->local_ip6[2], 3) != ((DST_IP6[2] >> 24) & 0xff) || in ctx_narrow_access()
517 LSB(ctx->local_ip6[3], 0) != ((DST_IP6[3] >> 0) & 0xff) || in ctx_narrow_access()
518 LSB(ctx->local_ip6[3], 1) != ((DST_IP6[3] >> 8) & 0xff) || in ctx_narrow_access()
519 LSB(ctx->local_ip6[3], 2) != ((DST_IP6[3] >> 16) & 0xff) || in ctx_narrow_access()
520 LSB(ctx->local_ip6[3], 3) != ((DST_IP6[3] >> 24) & 0xff)) in ctx_narrow_access()
522 if (LSW(ctx->local_ip6[0], 0) != ((DST_IP6[0] >> 0) & 0xffff) || in ctx_narrow_access()
523 LSW(ctx->local_ip6[0], 1) != ((DST_IP6[0] >> 16) & 0xffff) || in ctx_narrow_access()
524 LSW(ctx->local_ip6[1], 0) != ((DST_IP6[1] >> 0) & 0xffff) || in ctx_narrow_access()
525 LSW(ctx->local_ip6[1], 1) != ((DST_IP6[1] >> 16) & 0xffff) || in ctx_narrow_access()
526 LSW(ctx->local_ip6[2], 0) != ((DST_IP6[2] >> 0) & 0xffff) || in ctx_narrow_access()
527 LSW(ctx->local_ip6[2], 1) != ((DST_IP6[2] >> 16) & 0xffff) || in ctx_narrow_access()
528 LSW(ctx->local_ip6[3], 0) != ((DST_IP6[3] >> 0) & 0xffff) || in ctx_narrow_access()
529 LSW(ctx->local_ip6[3], 1) != ((DST_IP6[3] >> 16) & 0xffff)) in ctx_narrow_access()
533 if (LSB(ctx->remote_ip6[0], 0) != 0 || LSB(ctx->remote_ip6[0], 1) != 0 || in ctx_narrow_access()
534 LSB(ctx->remote_ip6[0], 2) != 0 || LSB(ctx->remote_ip6[0], 3) != 0 || in ctx_narrow_access()
535 LSB(ctx->remote_ip6[1], 0) != 0 || LSB(ctx->remote_ip6[1], 1) != 0 || in ctx_narrow_access()
536 LSB(ctx->remote_ip6[1], 2) != 0 || LSB(ctx->remote_ip6[1], 3) != 0 || in ctx_narrow_access()
537 LSB(ctx->remote_ip6[2], 0) != 0 || LSB(ctx->remote_ip6[2], 1) != 0 || in ctx_narrow_access()
538 LSB(ctx->remote_ip6[2], 2) != 0 || LSB(ctx->remote_ip6[2], 3) != 0 || in ctx_narrow_access()
539 LSB(ctx->remote_ip6[3], 0) != 0 || LSB(ctx->remote_ip6[3], 1) != 0 || in ctx_narrow_access()
540 LSB(ctx->remote_ip6[3], 2) != 0 || LSB(ctx->remote_ip6[3], 3) != 0) in ctx_narrow_access()
542 if (LSW(ctx->remote_ip6[0], 0) != 0 || LSW(ctx->remote_ip6[0], 1) != 0 || in ctx_narrow_access()
543 LSW(ctx->remote_ip6[1], 0) != 0 || LSW(ctx->remote_ip6[1], 1) != 0 || in ctx_narrow_access()
544 LSW(ctx->remote_ip6[2], 0) != 0 || LSW(ctx->remote_ip6[2], 1) != 0 || in ctx_narrow_access()
545 LSW(ctx->remote_ip6[3], 0) != 0 || LSW(ctx->remote_ip6[3], 1) != 0) in ctx_narrow_access()
548 if (LSB(ctx->local_ip6[0], 0) != 0 || LSB(ctx->local_ip6[0], 1) != 0 || in ctx_narrow_access()
549 LSB(ctx->local_ip6[0], 2) != 0 || LSB(ctx->local_ip6[0], 3) != 0 || in ctx_narrow_access()
550 LSB(ctx->local_ip6[1], 0) != 0 || LSB(ctx->local_ip6[1], 1) != 0 || in ctx_narrow_access()
551 LSB(ctx->local_ip6[1], 2) != 0 || LSB(ctx->local_ip6[1], 3) != 0 || in ctx_narrow_access()
552 LSB(ctx->local_ip6[2], 0) != 0 || LSB(ctx->local_ip6[2], 1) != 0 || in ctx_narrow_access()
553 LSB(ctx->local_ip6[2], 2) != 0 || LSB(ctx->local_ip6[2], 3) != 0 || in ctx_narrow_access()
554 LSB(ctx->local_ip6[3], 0) != 0 || LSB(ctx->local_ip6[3], 1) != 0 || in ctx_narrow_access()
555 LSB(ctx->local_ip6[3], 2) != 0 || LSB(ctx->local_ip6[3], 3) != 0) in ctx_narrow_access()
557 if (LSW(ctx->remote_ip6[0], 0) != 0 || LSW(ctx->remote_ip6[0], 1) != 0 || in ctx_narrow_access()
558 LSW(ctx->remote_ip6[1], 0) != 0 || LSW(ctx->remote_ip6[1], 1) != 0 || in ctx_narrow_access()
559 LSW(ctx->remote_ip6[2], 0) != 0 || LSW(ctx->remote_ip6[2], 1) != 0 || in ctx_narrow_access()
560 LSW(ctx->remote_ip6[3], 0) != 0 || LSW(ctx->remote_ip6[3], 1) != 0) in ctx_narrow_access()
567 bpf_sk_assign(ctx, sk, 0); in ctx_narrow_access()
575 int sk_assign_esocknosupport(struct bpf_sk_lookup *ctx) in sk_assign_esocknosupport() argument
585 err = bpf_sk_assign(ctx, sk, 0); in sk_assign_esocknosupport()
600 int multi_prog_pass1(struct bpf_sk_lookup *ctx) in multi_prog_pass1() argument
607 int multi_prog_pass2(struct bpf_sk_lookup *ctx) in multi_prog_pass2() argument
614 int multi_prog_drop1(struct bpf_sk_lookup *ctx) in multi_prog_drop1() argument
621 int multi_prog_drop2(struct bpf_sk_lookup *ctx) in multi_prog_drop2() argument
627 static __always_inline int select_server_a(struct bpf_sk_lookup *ctx) in select_server_a() argument
636 err = bpf_sk_assign(ctx, sk, 0); in select_server_a()
645 int multi_prog_redir1(struct bpf_sk_lookup *ctx) in multi_prog_redir1() argument
647 (void)select_server_a(ctx); in multi_prog_redir1()
653 int multi_prog_redir2(struct bpf_sk_lookup *ctx) in multi_prog_redir2() argument
655 (void)select_server_a(ctx); in multi_prog_redir2()