mirror of
https://gitea.invidious.io/iv-org/litespeed-quic.git
synced 2024-08-15 00:53:43 +00:00
Latest changes
- Improve checks of number of incoming streams limit and associated error reporting. - Small improvements to the recent DNS resolution code.
This commit is contained in:
parent
1da9d1fdd5
commit
7a9b83ff9d
4 changed files with 81 additions and 13 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2018-05-18
|
||||||
|
|
||||||
|
- Improve checks of number of incoming streams limit and associated
|
||||||
|
error reporting.
|
||||||
|
|
||||||
2018-05-16
|
2018-05-16
|
||||||
|
|
||||||
- [FEATURE] DNS resolution
|
- [FEATURE] DNS resolution
|
||||||
|
|
|
@ -95,6 +95,8 @@ enum full_conn_flags {
|
||||||
FC_TICK_CLOSE = (1 <<20), /* We returned TICK_CLOSE */
|
FC_TICK_CLOSE = (1 <<20), /* We returned TICK_CLOSE */
|
||||||
FC_HSK_FAILED = (1 <<21),
|
FC_HSK_FAILED = (1 <<21),
|
||||||
FC_HAVE_SAVED_ACK = (1 <<22),
|
FC_HAVE_SAVED_ACK = (1 <<22),
|
||||||
|
FC_ABORT_COMPLAINED
|
||||||
|
= (1 <<23),
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FC_IMMEDIATE_CLOSE_FLAGS \
|
#define FC_IMMEDIATE_CLOSE_FLAGS \
|
||||||
|
@ -224,15 +226,17 @@ struct full_conn
|
||||||
snprintf((conn)->fc_errmsg, MAX_ERRMSG, __VA_ARGS__); \
|
snprintf((conn)->fc_errmsg, MAX_ERRMSG, __VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define ABORT_WITH_FLAG(conn, flag, ...) do { \
|
#define ABORT_WITH_FLAG(conn, log_level, flag, ...) do { \
|
||||||
SET_ERRMSG(conn, __VA_ARGS__); \
|
SET_ERRMSG(conn, __VA_ARGS__); \
|
||||||
(conn)->fc_flags |= flag; \
|
if (!((conn)->fc_flags & FC_ABORT_COMPLAINED)) \
|
||||||
LSQ_ERROR("Abort connection: " __VA_ARGS__); \
|
LSQ_LOG(log_level, "Abort connection: " __VA_ARGS__); \
|
||||||
|
(conn)->fc_flags |= flag|FC_ABORT_COMPLAINED; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define ABORT_ERROR(...) ABORT_WITH_FLAG(conn, FC_ERROR, __VA_ARGS__)
|
#define ABORT_ERROR(...) \
|
||||||
|
ABORT_WITH_FLAG(conn, LSQ_LOG_ERROR, FC_ERROR, __VA_ARGS__)
|
||||||
#define ABORT_TIMEOUT(...) ABORT_WITH_FLAG(conn, FC_TIMED_OUT, __VA_ARGS__)
|
#define ABORT_WARN(...) \
|
||||||
|
ABORT_WITH_FLAG(conn, LSQ_LOG_WARN, FC_ERROR, __VA_ARGS__)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
idle_alarm_expired (void *ctx, lsquic_time_t expiry, lsquic_time_t now);
|
idle_alarm_expired (void *ctx, lsquic_time_t expiry, lsquic_time_t now);
|
||||||
|
@ -725,13 +729,51 @@ count_streams (const struct full_conn *conn, int peer)
|
||||||
stream = lsquic_hashelem_getdata(el);
|
stream = lsquic_hashelem_getdata(el);
|
||||||
ours = (1 & stream->id) ^ is_server;
|
ours = (1 & stream->id) ^ is_server;
|
||||||
if (ours ^ peer)
|
if (ours ^ peer)
|
||||||
count += !lsquic_stream_is_closed(stream);
|
count += !(lsquic_stream_is_closed(stream)
|
||||||
|
/* When counting peer-initiated streams, do not
|
||||||
|
* include those that have been reset:
|
||||||
|
*/
|
||||||
|
|| (peer && lsquic_stream_is_reset(stream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
enum stream_count { SCNT_ALL, SCNT_PEER, SCNT_CLOSED, SCNT_RESET,
|
||||||
|
SCNT_RES_UNCLO /* reset and not closed */, N_SCNTS };
|
||||||
|
|
||||||
|
static void
|
||||||
|
collect_stream_counts (const struct full_conn *conn, int peer,
|
||||||
|
unsigned counts[N_SCNTS])
|
||||||
|
{
|
||||||
|
const lsquic_stream_t *stream;
|
||||||
|
int ours;
|
||||||
|
int is_server;
|
||||||
|
struct lsquic_hash_elem *el;
|
||||||
|
|
||||||
|
peer = !!peer;
|
||||||
|
is_server = !!(conn->fc_flags & FC_SERVER);
|
||||||
|
memset(counts, 0, N_SCNTS * sizeof(counts[0]));
|
||||||
|
|
||||||
|
for (el = lsquic_hash_first(conn->fc_pub.all_streams); el;
|
||||||
|
el = lsquic_hash_next(conn->fc_pub.all_streams))
|
||||||
|
{
|
||||||
|
++counts[SCNT_ALL];
|
||||||
|
stream = lsquic_hashelem_getdata(el);
|
||||||
|
ours = (1 & stream->id) ^ is_server;
|
||||||
|
if (ours ^ peer)
|
||||||
|
{
|
||||||
|
++counts[SCNT_PEER];
|
||||||
|
counts[SCNT_CLOSED] += lsquic_stream_is_closed(stream);
|
||||||
|
counts[SCNT_RESET] += lsquic_stream_is_reset(stream);
|
||||||
|
counts[SCNT_RES_UNCLO] += lsquic_stream_is_reset(stream)
|
||||||
|
&& !lsquic_stream_is_closed(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
full_conn_ci_destroy (lsquic_conn_t *lconn)
|
full_conn_ci_destroy (lsquic_conn_t *lconn)
|
||||||
{
|
{
|
||||||
|
@ -1120,8 +1162,17 @@ process_stream_frame (struct full_conn *conn, lsquic_packet_in_t *packet_in,
|
||||||
LSQ_DEBUG("number of peer-initiated streams: %u", in_count);
|
LSQ_DEBUG("number of peer-initiated streams: %u", in_count);
|
||||||
if (in_count >= conn->fc_cfg.max_streams_in)
|
if (in_count >= conn->fc_cfg.max_streams_in)
|
||||||
{
|
{
|
||||||
ABORT_ERROR("incoming stream would exceed limit: %u",
|
if (!(conn->fc_flags & FC_ABORT_COMPLAINED))
|
||||||
conn->fc_cfg.max_streams_in);
|
{
|
||||||
|
enum stream_count counts[N_SCNTS];
|
||||||
|
collect_stream_counts(conn, 1, counts);
|
||||||
|
ABORT_WARN("incoming stream would exceed limit: %u. "
|
||||||
|
"all: %u; peer: %u; closed: %u; reset: %u; reset "
|
||||||
|
"and not closed: %u", conn->fc_cfg.max_streams_in,
|
||||||
|
counts[SCNT_ALL], counts[SCNT_PEER],
|
||||||
|
counts[SCNT_CLOSED], counts[SCNT_RESET],
|
||||||
|
counts[SCNT_RES_UNCLO]);
|
||||||
|
}
|
||||||
lsquic_malo_put(stream_frame);
|
lsquic_malo_put(stream_frame);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3081,8 +3132,17 @@ find_stream_on_non_stream_frame (struct full_conn *conn, uint32_t stream_id,
|
||||||
LSQ_DEBUG("number of peer-initiated streams: %u", in_count);
|
LSQ_DEBUG("number of peer-initiated streams: %u", in_count);
|
||||||
if (in_count >= conn->fc_cfg.max_streams_in)
|
if (in_count >= conn->fc_cfg.max_streams_in)
|
||||||
{
|
{
|
||||||
ABORT_ERROR("incoming %s for stream %u would exceed "
|
if (!(conn->fc_flags & FC_ABORT_COMPLAINED))
|
||||||
"limit: %u", what, stream_id, conn->fc_cfg.max_streams_in);
|
{
|
||||||
|
enum stream_count counts[N_SCNTS];
|
||||||
|
collect_stream_counts(conn, 1, counts);
|
||||||
|
ABORT_WARN("incoming %s for stream %u would exceed "
|
||||||
|
"limit: %u. all: %u; peer: %u; closed: %u; reset: %u; reset "
|
||||||
|
"and not closed: %u",
|
||||||
|
what, stream_id, conn->fc_cfg.max_streams_in, counts[SCNT_ALL],
|
||||||
|
counts[SCNT_PEER], counts[SCNT_CLOSED], counts[SCNT_RESET],
|
||||||
|
counts[SCNT_RES_UNCLO]);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if ((conn->fc_flags & FC_GOING_AWAY) &&
|
if ((conn->fc_flags & FC_GOING_AWAY) &&
|
||||||
|
|
|
@ -92,8 +92,7 @@ prog_print_common_options (const struct prog *prog, FILE *out)
|
||||||
#else
|
#else
|
||||||
" -s SERVER Server address. Takes on the form of host:port or host.\n"
|
" -s SERVER Server address. Takes on the form of host:port or host.\n"
|
||||||
" If host is not an IPv4 or IPv6 address, it is resolved.\n"
|
" If host is not an IPv4 or IPv6 address, it is resolved.\n"
|
||||||
" If port is not set, the default is 443. If -s is not\n"
|
" If port is not set, the default is 443.\n"
|
||||||
" specified, the value of SNI is used (see the -H flag).\n"
|
|
||||||
#endif
|
#endif
|
||||||
" Examples:\n"
|
" Examples:\n"
|
||||||
" 127.0.0.1:12345\n"
|
" 127.0.0.1:12345\n"
|
||||||
|
@ -103,6 +102,8 @@ prog_print_common_options (const struct prog *prog, FILE *out)
|
||||||
#if HAVE_REGEX
|
#if HAVE_REGEX
|
||||||
" 8443\n"
|
" 8443\n"
|
||||||
#endif
|
#endif
|
||||||
|
" If -s is not specified, the value of SNI is used (see\n"
|
||||||
|
" the -H flag).\n"
|
||||||
#if LSQUIC_DONTFRAG_SUPPORTED
|
#if LSQUIC_DONTFRAG_SUPPORTED
|
||||||
" -D Set `do not fragment' flag on outgoing UDP packets\n"
|
" -D Set `do not fragment' flag on outgoing UDP packets\n"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "test_config.h"
|
||||||
#if HAVE_REGEX
|
#if HAVE_REGEX
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue