SEC("cgroup/getsockname4") int getsockname4(struct bpf_sock_addr *ctx)
{ if (!get_set_sk_priority(ctx)) return 1;
/* Expose local server as 1.2.3.4:60000 to client. */ if (ctx->user_port == bpf_htons(60123)) {
ctx->user_ip4 = bpf_htonl(0x01020304);
ctx->user_port = bpf_htons(60000);
} return 1;
}
SEC("cgroup/getpeername4") int getpeername4(struct bpf_sock_addr *ctx)
{ struct svc_addr *orig;
if (!get_set_sk_priority(ctx)) return 1;
/* Expose service 1.2.3.4:60000 as peer instead of backend. */ if (ctx->user_port == bpf_htons(60123)) {
orig = bpf_sk_storage_get(&service_mapping, ctx->sk, 0, 0); if (orig) {
ctx->user_ip4 = orig->addr;
ctx->user_port = orig->port;
}
} return 1;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.