FreeBSD kernel IPv4 code
tcp_fastopen.h
Go to the documentation of this file.
1/*-
2 * Copyright (c) 2015-2017 Patrick Kelsey
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD$
27 */
28
29#ifndef _TCP_FASTOPEN_H_
30#define _TCP_FASTOPEN_H_
31
32#ifdef _KERNEL
33
34#include "opt_inet.h"
35
36#define TCP_FASTOPEN_COOKIE_LEN 8 /* SipHash24 64-bit output */
37
38#ifdef TCP_RFC7413
39VNET_DECLARE(unsigned int, tcp_fastopen_client_enable);
40#define V_tcp_fastopen_client_enable VNET(tcp_fastopen_client_enable)
41
42VNET_DECLARE(unsigned int, tcp_fastopen_server_enable);
43#define V_tcp_fastopen_server_enable VNET(tcp_fastopen_server_enable)
44#else
45#define V_tcp_fastopen_client_enable 0
46#define V_tcp_fastopen_server_enable 0
47#endif /* TCP_RFC7413 */
48
50 struct in_addr v4;
51 struct in6_addr v6;
52};
53
56 union tcp_fastopen_ip_addr cce_client_ip; /* network byte order */
57 union tcp_fastopen_ip_addr cce_server_ip; /* network byte order */
58 uint16_t server_port; /* network byte order */
59 uint16_t server_mss; /* host byte order */
62 uint8_t cookie[TCP_FASTOPEN_MAX_COOKIE_LEN];
63 sbintime_t disable_time; /* non-zero value means path is disabled */
64};
65
67
69 struct mtx ccb_mtx;
70 TAILQ_HEAD(bucket_entries, tcp_fastopen_ccache_entry) ccb_entries;
73};
74
76 uma_zone_t zone;
78 unsigned int bucket_limit;
79 unsigned int buckets;
80 unsigned int mask;
82};
83
84#ifdef TCP_RFC7413
85void tcp_fastopen_init(void);
86void tcp_fastopen_destroy(void);
87unsigned int *tcp_fastopen_alloc_counter(void);
88void tcp_fastopen_decrement_counter(unsigned int *);
89int tcp_fastopen_check_cookie(struct in_conninfo *, uint8_t *, unsigned int,
90 uint64_t *);
91void tcp_fastopen_connect(struct tcpcb *);
92void tcp_fastopen_disable_path(struct tcpcb *);
94 uint8_t *);
95#else
96#define tcp_fastopen_init() ((void)0)
97#define tcp_fastopen_destroy() ((void)0)
98#define tcp_fastopen_alloc_counter() NULL
99#define tcp_fastopen_decrement_counter(c) ((void)0)
100#define tcp_fastopen_check_cookie(i, c, l, lc) (-1)
101#define tcp_fastopen_connect(t) ((void)0)
102#define tcp_fastopen_disable_path(t) ((void)0)
103#define tcp_fastopen_update_cache(t, m, l, c) ((void)0)
104#endif /* TCP_RFC7413 */
105
106#endif /* _KERNEL */
107
108#endif /* _TCP_FASTOPEN_H_ */
VNET_DECLARE(struct cc_algo *, default_cc_ptr)
__uint32_t uint32_t
Definition: in.h:62
__uint16_t uint16_t
Definition: in.h:57
__uint8_t uint8_t
Definition: in.h:52
Definition: in.h:83
struct tcp_fastopen_ccache * ccb_ccache
Definition: tcp_fastopen.h:72
TAILQ_HEAD(bucket_entries, tcp_fastopen_ccache_entry) ccb_entries
Definition: tcp_fastopen.h:54
TAILQ_ENTRY(tcp_fastopen_ccache_entry) cce_link
uint16_t server_mss
Definition: tcp_fastopen.h:59
uint8_t cookie[TCP_FASTOPEN_MAX_COOKIE_LEN]
Definition: tcp_fastopen.h:62
uint16_t server_port
Definition: tcp_fastopen.h:58
union tcp_fastopen_ip_addr cce_client_ip
Definition: tcp_fastopen.h:56
uint8_t af
Definition: tcp_fastopen.h:60
uint8_t cookie_len
Definition: tcp_fastopen.h:61
sbintime_t disable_time
Definition: tcp_fastopen.h:63
union tcp_fastopen_ip_addr cce_server_ip
Definition: tcp_fastopen.h:57
struct tcp_fastopen_ccache_bucket * base
Definition: tcp_fastopen.h:77
unsigned int bucket_limit
Definition: tcp_fastopen.h:78
unsigned int mask
Definition: tcp_fastopen.h:80
unsigned int buckets
Definition: tcp_fastopen.h:79
Definition: tcp_var.h:132
#define tcp_fastopen_decrement_counter(c)
Definition: tcp_fastopen.h:99
#define tcp_fastopen_disable_path(t)
Definition: tcp_fastopen.h:102
#define tcp_fastopen_destroy()
Definition: tcp_fastopen.h:97
#define tcp_fastopen_check_cookie(i, c, l, lc)
Definition: tcp_fastopen.h:100
#define tcp_fastopen_alloc_counter()
Definition: tcp_fastopen.h:98
#define tcp_fastopen_init()
Definition: tcp_fastopen.h:96
#define tcp_fastopen_connect(t)
Definition: tcp_fastopen.h:101
#define tcp_fastopen_update_cache(t, m, l, c)
Definition: tcp_fastopen.h:103
struct in6_addr v6
Definition: tcp_fastopen.h:51
struct in_addr v4
Definition: tcp_fastopen.h:50