Mercurial > hg > nginx
annotate src/event/ngx_event_udp.h @ 8971:1e2f4e9c8195 quic
QUIC: reworked migration handling.
The quic connection now holds active, backup and probe paths instead
of sockets. The number of migration paths is now limited and cannot
be inflated by a bad client or an attacker.
The client id is now associated with path rather than socket. This allows
to simplify processing of output and connection ids handling.
New migration abandons any previously started migrations. This allows to
free consumed client ids and request new for use in future migrations and
make progress in case when connection id limit is hit during migration.
A path now can be revalidated without losing its state.
The patch also fixes various issues with NAT rebinding case handling:
- paths are now validated (previously, there was no validation
and paths were left in limited state)
- attempt to reuse id on different path is now again verified
(this was broken in 40445fc7c403)
- former path is now validated in case of apparent migration
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Wed, 19 Jan 2022 22:39:24 +0300 |
parents | e7a2d3914877 |
children | ce6d9cf0f567 |
rev | line source |
---|---|
8809
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
2 /* |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
3 * Copyright (C) Nginx, Inc. |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
4 */ |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
5 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
6 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
7 #ifndef _NGX_EVENT_UDP_H_INCLUDED_ |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
8 #define _NGX_EVENT_UDP_H_INCLUDED_ |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
9 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
10 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
11 #include <ngx_config.h> |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
12 #include <ngx_core.h> |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
13 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
14 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
15 #if !(NGX_WIN32) |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
16 |
8810
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
17 #if ((NGX_HAVE_MSGHDR_MSG_CONTROL) \ |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
18 && (NGX_HAVE_IP_SENDSRCADDR || NGX_HAVE_IP_RECVDSTADDR \ |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
19 || NGX_HAVE_IP_PKTINFO \ |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
20 || (NGX_HAVE_INET6 && NGX_HAVE_IPV6_RECVPKTINFO))) |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
21 #define NGX_HAVE_ADDRINFO_CMSG 1 |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
22 #endif |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
23 |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
24 |
8809
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
25 typedef struct { |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
26 ngx_buf_t *buffer; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
27 struct sockaddr *sockaddr; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
28 socklen_t socklen; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
29 } ngx_udp_dgram_t; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
30 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
31 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
32 struct ngx_udp_connection_s { |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
33 ngx_rbtree_node_t node; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
34 ngx_connection_t *connection; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
35 ngx_str_t key; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
36 ngx_udp_dgram_t *dgram; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
37 }; |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
38 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
39 |
8810
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
40 #if (NGX_HAVE_ADDRINFO_CMSG) |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
41 |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
42 typedef union { |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
43 #if (NGX_HAVE_IP_SENDSRCADDR || NGX_HAVE_IP_RECVDSTADDR) |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
44 struct in_addr addr; |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
45 #endif |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
46 |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
47 #if (NGX_HAVE_IP_PKTINFO) |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
48 struct in_pktinfo pkt; |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
49 #endif |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
50 |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
51 #if (NGX_HAVE_INET6 && NGX_HAVE_IPV6_RECVPKTINFO) |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
52 struct in6_pktinfo pkt6; |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
53 #endif |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
54 } ngx_addrinfo_t; |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
55 |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
56 size_t ngx_set_srcaddr_cmsg(struct cmsghdr *cmsg, |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
57 struct sockaddr *local_sockaddr); |
8812
e7a2d3914877
Core: added separate function for local source address cmsg.
Vladimir Homutov <vl@nginx.com>
parents:
8810
diff
changeset
|
58 ngx_int_t ngx_get_srcaddr_cmsg(struct cmsghdr *cmsg, |
e7a2d3914877
Core: added separate function for local source address cmsg.
Vladimir Homutov <vl@nginx.com>
parents:
8810
diff
changeset
|
59 struct sockaddr *local_sockaddr); |
8810
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
60 |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
61 #endif |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
62 |
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
63 |
8809
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
64 void ngx_event_recvmsg(ngx_event_t *ev); |
8810
2dfd313f22f2
Core: made the ngx_sendmsg() function non-static.
Vladimir Homutov <vl@nginx.com>
parents:
8809
diff
changeset
|
65 ssize_t ngx_sendmsg(ngx_connection_t *c, struct msghdr *msg, int flags); |
8809
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
66 void ngx_udp_rbtree_insert_value(ngx_rbtree_node_t *temp, |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
67 ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel); |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
68 void ngx_insert_udp_connection(ngx_connection_t *c, ngx_udp_connection_t *udp, |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
69 ngx_str_t *key); |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
70 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
71 #endif |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
72 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
73 void ngx_delete_udp_connection(void *data); |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
74 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
75 |
6f434af59257
Core: the ngx_event_udp.h header file.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
76 #endif /* _NGX_EVENT_UDP_H_INCLUDED_ */ |