|
|
|
@ -124,8 +124,7 @@ static void exit_handle_request(struct ETCP_CONN* conn, struct ll_entry* entry) |
|
|
|
|
|
|
|
|
|
|
|
if (g_icmp_ctx->raw_sock != SOCKET_INVALID) { |
|
|
|
if (g_icmp_ctx->raw_sock != SOCKET_INVALID) { |
|
|
|
exit_send_echo(inst, client_node_id, dst_ip, echo_id, echo_seq, payload, payload_len); |
|
|
|
exit_send_echo(inst, client_node_id, dst_ip, echo_id, echo_seq, payload, payload_len); |
|
|
|
} else { |
|
|
|
} else if (g_icmp_ctx->test_loopback) { |
|
|
|
// No raw socket (e.g. no root): send simulated echo reply back to client
|
|
|
|
|
|
|
|
struct ll_entry* e = queue_entry_new(0); |
|
|
|
struct ll_entry* e = queue_entry_new(0); |
|
|
|
if (e) { |
|
|
|
if (e) { |
|
|
|
e->dgram = u_malloc(ICMP_PROXY_HDR_SIZE + payload_len); |
|
|
|
e->dgram = u_malloc(ICMP_PROXY_HDR_SIZE + payload_len); |
|
|
|
@ -141,6 +140,8 @@ static void exit_handle_request(struct ETCP_CONN* conn, struct ll_entry* entry) |
|
|
|
etcp_route_send(inst, client_node_id, e); |
|
|
|
etcp_route_send(inst, client_node_id, e); |
|
|
|
} else queue_entry_free(e); |
|
|
|
} else queue_entry_free(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_SOCKET, "icmp_proxy: no raw socket, dropping echo request to 0x%08x", dst_ip); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
drop: |
|
|
|
drop: |
|
|
|
@ -240,6 +241,11 @@ int icmp_proxy_deliver_reply(struct UTUN_INSTANCE* inst, |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void icmp_proxy_set_test_loopback(struct UTUN_INSTANCE* inst, int enabled) { |
|
|
|
|
|
|
|
(void)inst; |
|
|
|
|
|
|
|
if (g_icmp_ctx) g_icmp_ctx->test_loopback = enabled; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void req_expire(struct icmp_proxy_ctx* ctx) { |
|
|
|
static void req_expire(struct icmp_proxy_ctx* ctx) { |
|
|
|
uint64_t now = get_time_tb(); struct icmp_request** prev = &ctx->pending; |
|
|
|
uint64_t now = get_time_tb(); struct icmp_request** prev = &ctx->pending; |
|
|
|
while (*prev) { |
|
|
|
while (*prev) { |
|
|
|
@ -259,6 +265,7 @@ int icmp_proxy_init(struct UTUN_INSTANCE* inst, struct UASYNC* ua) { |
|
|
|
ctx->inst = inst; ctx->ua = ua; ctx->raw_sock = SOCKET_INVALID; |
|
|
|
ctx->inst = inst; ctx->ua = ua; ctx->raw_sock = SOCKET_INVALID; |
|
|
|
ctx->request_timeout_tb = ICMP_TIMEOUT_TB; |
|
|
|
ctx->request_timeout_tb = ICMP_TIMEOUT_TB; |
|
|
|
ctx->is_exit = inst->remote_proxy.enabled; |
|
|
|
ctx->is_exit = inst->remote_proxy.enabled; |
|
|
|
|
|
|
|
ctx->test_loopback = 0; |
|
|
|
g_icmp_ctx = ctx; |
|
|
|
g_icmp_ctx = ctx; |
|
|
|
|
|
|
|
|
|
|
|
if (ctx->is_exit) { |
|
|
|
if (ctx->is_exit) { |
|
|
|
|