From 102705470366b871109d2c3bf182c151ab71eb01 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 17 Oct 2017 12:08:55 +0200 Subject: [*] Support hop-counting in request header, protocol version 3 We steal 8 bits from the request offset to count hops when requests get relayed by proxies. This still leaves plenty of bits for the offset (56 bits, supporting images of up to 72 petabytes). This is used to detect proxy cycles. The algorithm is not perfect but should prevent endless relays of the same request. This is backwards compatible to old clients and servers, as the server only ever sets the hopcount in relayed requests if the upstream server is using protocol version 3 or newer, and clients are automatically upwards compatible as there is practically no image larger than 74PB, so the newly introduced hop count field is always 0 even in requests from old clients. --- src/server/uplink.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/server/uplink.h') diff --git a/src/server/uplink.h b/src/server/uplink.h index c8cf4eb..2b41dfc 100644 --- a/src/server/uplink.h +++ b/src/server/uplink.h @@ -8,11 +8,11 @@ void uplink_globalsInit(); uint64_t uplink_getTotalBytesReceived(); -bool uplink_init(dnbd3_image_t *image, int sock, dnbd3_host_t *host); +bool uplink_init(dnbd3_image_t *image, int sock, dnbd3_host_t *host, int version); void uplink_removeClient(dnbd3_connection_t *uplink, dnbd3_client_t *client); -bool uplink_request(dnbd3_client_t *client, uint64_t handle, uint64_t start, uint32_t length); +bool uplink_request(dnbd3_client_t *client, uint64_t handle, uint64_t start, uint32_t length, uint8_t hopCount); void uplink_shutdown(dnbd3_image_t *image); -- cgit v1.2.3-55-g7522