summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorVladimir Homutov <vl@nginx.com>2021-03-15 19:05:38 +0300
committerVladimir Homutov <vl@nginx.com>2021-03-15 19:05:38 +0300
commitbb44bfa631f2fefff0e9399383b06c9e09668556 (patch)
tree7d1477d97af457374585b3a21068c84502825612 /src
parente522bb69f9e4fa480dfe875a559445ec7831cec9 (diff)
downloadnginx-bb44bfa631f2fefff0e9399383b06c9e09668556.tar.gz
nginx-bb44bfa631f2fefff0e9399383b06c9e09668556.tar.bz2
QUIC: fixed key extraction in bpf.
In case of long header packets, dcid length was not read correctly. While there, macros to parse uint64 was fixed as well as format specifiers to print it in debug mode. Thanks to Gao Yan <gaoyan09@baidu.com>.
Diffstat (limited to 'src')
-rw-r--r--src/event/quic/bpf/ngx_quic_reuseport_helper.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/event/quic/bpf/ngx_quic_reuseport_helper.c b/src/event/quic/bpf/ngx_quic_reuseport_helper.c
index 05919aaa9..2de9b2864 100644
--- a/src/event/quic/bpf/ngx_quic_reuseport_helper.c
+++ b/src/event/quic/bpf/ngx_quic_reuseport_helper.c
@@ -58,10 +58,10 @@ char _license[] SEC("license") = LICENSE;
((__u64)(p)[1] << 48) | \
((__u64)(p)[2] << 40) | \
((__u64)(p)[3] << 32) | \
- (p)[4] << 24 | \
- (p)[5] << 16 | \
- (p)[6] << 8 | \
- (p)[7])
+ ((__u64)(p)[4] << 24) | \
+ ((__u64)(p)[5] << 16) | \
+ ((__u64)(p)[6] << 8) | \
+ ((__u64)(p)[7]))
/*
* actual map object is created by the "bpf" system call,
@@ -82,12 +82,14 @@ int ngx_quic_select_socket_by_dcid(struct sk_reuseport_md *ctx)
end = (unsigned char *) ctx->data_end;
offset = 0;
- advance_data(sizeof(struct udphdr)); /* skip UDP header */
- advance_data(1); /* QUIC flags */
+ advance_data(sizeof(struct udphdr)); /* data at UDP header */
+ advance_data(1); /* data at QUIC flags */
if (data[0] & NGX_QUIC_PKT_LONG) {
- advance_data(4); /* skip QUIC version */
+ advance_data(4); /* data at QUIC version */
+ advance_data(1); /* data at DCID len */
+
len = data[0]; /* read DCID length */
if (len < 8) {
@@ -95,8 +97,6 @@ int ngx_quic_select_socket_by_dcid(struct sk_reuseport_md *ctx)
return SK_PASS;
}
- advance_data(1); /* skip DCID len */
-
} else {
len = NGX_QUIC_SERVER_CID_LEN;
}
@@ -115,17 +115,17 @@ int ngx_quic_select_socket_by_dcid(struct sk_reuseport_md *ctx)
switch (rc) {
case 0:
- debugmsg("nginx quic socket selected by key 0x%x", key);
+ debugmsg("nginx quic socket selected by key 0x%llx", key);
return SK_PASS;
/* kernel returns positive error numbers, errno.h defines positive */
case -ENOENT:
- debugmsg("nginx quic default route for key 0x%x", key);
+ debugmsg("nginx quic default route for key 0x%llx", key);
/* let the default reuseport logic decide which socket to choose */
return SK_PASS;
default:
- debugmsg("nginx quic bpf_sk_select_reuseport err: %d key 0x%x",
+ debugmsg("nginx quic bpf_sk_select_reuseport err: %d key 0x%llx",
rc, key);
goto failed;
}