Lines Matching refs:ctx

32 static __inline int bind_to_device(struct bpf_sock_addr *ctx)  in bind_to_device()  argument
40 if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, in bind_to_device()
43 if (bpf_getsockopt(ctx, SOL_SOCKET, SO_BINDTOIFINDEX, in bind_to_device()
46 if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, in bind_to_device()
49 if (bpf_getsockopt(ctx, SOL_SOCKET, SO_BINDTOIFINDEX, in bind_to_device()
53 if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, in bind_to_device()
56 if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTOIFINDEX, in bind_to_device()
59 if (bpf_setsockopt(ctx, SOL_SOCKET, SO_BINDTODEVICE, in bind_to_device()
66 static __inline int bind_reuseport(struct bpf_sock_addr *ctx) in bind_reuseport() argument
70 if (bpf_setsockopt(ctx, SOL_SOCKET, SO_REUSEPORT, in bind_reuseport()
73 if (bpf_getsockopt(ctx, SOL_SOCKET, SO_REUSEPORT, in bind_reuseport()
77 if (bpf_setsockopt(ctx, SOL_SOCKET, SO_REUSEPORT, in bind_reuseport()
80 if (bpf_getsockopt(ctx, SOL_SOCKET, SO_REUSEPORT, in bind_reuseport()
87 static __inline int misc_opts(struct bpf_sock_addr *ctx, int opt) in misc_opts() argument
92 if (bpf_getsockopt(ctx, SOL_SOCKET, opt, &old, sizeof(old)) || in misc_opts()
95 if (bpf_setsockopt(ctx, SOL_SOCKET, opt, &new, sizeof(new))) in misc_opts()
97 if (bpf_getsockopt(ctx, SOL_SOCKET, opt, &tmp, sizeof(tmp)) || in misc_opts()
100 if (bpf_setsockopt(ctx, SOL_SOCKET, opt, &old, sizeof(old))) in misc_opts()
107 int bind_v6_prog(struct bpf_sock_addr *ctx) in bind_v6_prog() argument
114 sk = ctx->sk; in bind_v6_prog()
121 if (ctx->type != SOCK_STREAM && ctx->type != SOCK_DGRAM) in bind_v6_prog()
124 if (ctx->user_ip6[0] != bpf_htonl(SERV6_IP_0) || in bind_v6_prog()
125 ctx->user_ip6[1] != bpf_htonl(SERV6_IP_1) || in bind_v6_prog()
126 ctx->user_ip6[2] != bpf_htonl(SERV6_IP_2) || in bind_v6_prog()
127 ctx->user_ip6[3] != bpf_htonl(SERV6_IP_3) || in bind_v6_prog()
128 ctx->user_port != bpf_htons(SERV6_PORT)) in bind_v6_prog()
134 user_ip6 |= load_byte(ctx->user_ip6[i], 0, sizeof(user_ip6)); in bind_v6_prog()
135 user_ip6 |= load_byte(ctx->user_ip6[i], 1, sizeof(user_ip6)); in bind_v6_prog()
136 user_ip6 |= load_byte(ctx->user_ip6[i], 2, sizeof(user_ip6)); in bind_v6_prog()
137 user_ip6 |= load_byte(ctx->user_ip6[i], 3, sizeof(user_ip6)); in bind_v6_prog()
138 if (ctx->user_ip6[i] != user_ip6) in bind_v6_prog()
143 user_port |= load_byte(ctx->user_port, 0, sizeof(user_port)); in bind_v6_prog()
144 user_port |= load_byte(ctx->user_port, 1, sizeof(user_port)); in bind_v6_prog()
145 if (ctx->user_port != user_port) in bind_v6_prog()
151 user_ip6 |= load_word(ctx->user_ip6[i], 0, sizeof(user_ip6)); in bind_v6_prog()
152 user_ip6 |= load_word(ctx->user_ip6[i], 1, sizeof(user_ip6)); in bind_v6_prog()
153 if (ctx->user_ip6[i] != user_ip6) in bind_v6_prog()
158 if (bind_to_device(ctx)) in bind_v6_prog()
162 if (misc_opts(ctx, SO_MARK) || misc_opts(ctx, SO_PRIORITY)) in bind_v6_prog()
166 if (bind_reuseport(ctx)) in bind_v6_prog()
169 ctx->user_ip6[0] = bpf_htonl(SERV6_REWRITE_IP_0); in bind_v6_prog()
170 ctx->user_ip6[1] = bpf_htonl(SERV6_REWRITE_IP_1); in bind_v6_prog()
171 ctx->user_ip6[2] = bpf_htonl(SERV6_REWRITE_IP_2); in bind_v6_prog()
172 ctx->user_ip6[3] = bpf_htonl(SERV6_REWRITE_IP_3); in bind_v6_prog()
173 ctx->user_port = bpf_htons(SERV6_REWRITE_PORT); in bind_v6_prog()
179 int bind_v6_deny_prog(struct bpf_sock_addr *ctx) in bind_v6_deny_prog() argument