mirror of
https://github.com/nginx/nginx.git
synced 2025-01-21 11:42:59 +08:00
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>.
This commit is contained in:
parent
e522bb69f9
commit
bb44bfa631
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user