github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/freebsd/socket_inet_tcp.txt (about)

     1  # Copyright 2017 syzkaller project authors. All rights reserved.
     2  # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  # AF_INET and AF_INET6: TCP support
     5  
     6  include <sys/types.h>
     7  include <sys/ktls.h>
     8  include <sys/malloc.h>
     9  include <sys/socket.h>
    10  include <sys/time.h>
    11  include <netinet/in.h>
    12  include <netinet/tcp.h>
    13  include <netinet/cc/cc_newreno.h>
    14  include <opencrypto/cryptodev.h>
    15  
    16  resource sock_tcp[sock_in]
    17  
    18  socket$inet_tcp(domain const[AF_INET], type const[SOCK_STREAM], proto const[0]) sock_tcp
    19  
    20  resource sock_tcp6[sock_in6]
    21  
    22  socket$inet6_tcp(domain const[AF_INET6], type const[SOCK_STREAM], proto const[0]) sock_tcp6
    23  
    24  # Generic TCP socket options
    25  
    26  tcp_option_types_int = TCP_NODELAY, TCP_MAXSEG, TCP_NOPUSH, TCP_NOOPT, TCP_MD5SIG, TCP_LOG, TCP_REMOTE_UDP_ENCAPS_PORT, TCP_DELACK, TCP_KEEPINIT, TCP_KEEPIDLE, TCP_KEEPINTVL, TCP_KEEPCNT, TCP_PCAP_OUT, TCP_PCAP_IN
    27  
    28  tcp_option_types_buf = TCP_INFO, TCP_LOGBUF, TCP_LOGID, TCP_LOGDUMP, TCP_LOGDUMPID, TCP_CONGESTION, TCP_CCALGOOPT, TCP_FASTOPEN, TCP_FUNCTION_BLK
    29  
    30  getsockopt$inet_tcp_int(fd sock_tcp, level const[IPPROTO_TCP], optname flags[tcp_option_types_int], optval ptr[out, int32], optlen ptr[inout, len[optval, int32]])
    31  setsockopt$inet_tcp_int(fd sock_tcp, level const[IPPROTO_TCP], optname flags[tcp_option_types_int], optval ptr[in, int32], optlen len[optval])
    32  getsockopt$inet6_tcp_int(fd sock_tcp6, level const[IPPROTO_TCP], optname flags[tcp_option_types_int], optval ptr[out, int32], optlen ptr[inout, len[optval, int32]])
    33  setsockopt$inet6_tcp_int(fd sock_tcp6, level const[IPPROTO_TCP], optname flags[tcp_option_types_int], optval ptr[in, int32], optlen len[optval])
    34  
    35  getsockopt$inet_tcp_buf(fd sock_tcp, level const[IPPROTO_TCP], optname flags[tcp_option_types_buf], optval buffer[out], optlen ptr[inout, len[optval, int32]])
    36  setsockopt$inet_tcp_buf(fd sock_tcp, level const[IPPROTO_TCP], optname flags[tcp_option_types_buf], optval buffer[in], optlen len[optval])
    37  getsockopt$inet6_tcp_buf(fd sock_tcp6, level const[IPPROTO_TCP], optname flags[tcp_option_types_buf], optval buffer[out], optlen ptr[inout, len[optval, int32]])
    38  setsockopt$inet6_tcp_buf(fd sock_tcp6, level const[IPPROTO_TCP], optname flags[tcp_option_types_buf], optval buffer[in], optlen len[optval])
    39  
    40  # Specific TCP socket options
    41  
    42  setsockopt$inet_tcp_TCP_CONGESTION(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_CONGESTION], optval ptr[in, string[tcp_congestion_control_alg_names]], optlen len[optval])
    43  setsockopt$inet6_tcp_TCP_CONGESTION(fd sock_tcp6, level const[IPPROTO_TCP], optname const[TCP_CONGESTION], optval ptr[in, string[tcp_congestion_control_alg_names]], optlen len[optval])
    44  
    45  tcp_congestion_control_alg_names = "cdg", "chd", "cubic", "dctcp", "hd", "htcp", "newreno", "vegas"
    46  
    47  setsockopt$inet_tcp_TCP_CCALGOOPT(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_CCALGOOPT], optval ptr[in, cc_opts], optlen len[optval])
    48  setsockopt$inet6_tcp_TCP_CCALGOOPT(fd sock_tcp6, level const[IPPROTO_TCP], optname const[TCP_CCALGOOPT], optval ptr[in, cc_opts], optlen len[optval])
    49  
    50  cc_opts [
    51  	newreno	cc_newreno_opts
    52  	generic	cc_generic_opts
    53  ] [varlen]
    54  
    55  cc_newreno_opts {
    56  	name	flags[cc_newreno_opts_names, int32]
    57  	val	int32
    58  }
    59  
    60  cc_newreno_opts_names = CC_NEWRENO_BETA, CC_NEWRENO_BETA_ECN
    61  
    62  cc_generic_opts {
    63  	val	array[int8]
    64  }
    65  
    66  setsockopt$inet_tcp_TCP_FUNCTION_BLK(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_FUNCTION_BLK], optval ptr[in, tcp_function_set], optlen len[optval])
    67  setsockopt$inet6_tcp_TCP_FUNCTION_BLK(fd sock_tcp6, level const[IPPROTO_TCP], optname const[TCP_FUNCTION_BLK], optval ptr[in, tcp_function_set], optlen len[optval])
    68  
    69  tcp_function_set {
    70  	function_set_name	string[tcp_function_set_names, TCP_FUNCTION_NAME_LEN_MAX]
    71  	pcbcnt			int32
    72  }
    73  
    74  tcp_function_set_names = "freebsd", "rack", "bbr"
    75  
    76  setsockopt$inet_tcp_TCP_FASTOPEN(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_FASTOPEN], optval ptr[in, tcp_fastopen], optlen len[optval])
    77  setsockopt$inet6_tcp_TCP_FASTOPEN(fd sock_tcp6, level const[IPPROTO_TCP], optname const[TCP_FASTOPEN], optval ptr[in, tcp_fastopen], optlen len[optval])
    78  
    79  tcp_fastopen {
    80  	enable	int32
    81  	psk	array[int8, TCP_FASTOPEN_PSK_LEN]
    82  }
    83  
    84  getsockopt$inet_tcp_TCP_RXTLS_MODE(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_RXTLS_MODE], optval ptr[out, int32], optlen ptr[inout, len[optval, int32]])
    85  getsockopt$inet_tcp_TCP_TXTLS_MODE(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_TXTLS_MODE], optval ptr[out, int32], optlen ptr[inout, len[optval, int32]])
    86  setsockopt$inet_tcp_TCP_TXTLS_MODE(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_TXTLS_MODE], optval ptr[in, flags[tls_tx_mode, int32]], optlen len[optval])
    87  
    88  tls_tx_mode = TCP_TLS_MODE_NONE, TCP_TLS_MODE_SW, TCP_TLS_MODE_IFNET, TCP_TLS_MODE_TOE
    89  
    90  setsockopt$inet_tcp_TCP_TXTLS_ENABLE(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_TXTLS_ENABLE], optval ptr[in, tls_enable], optlen bytesize[optval])
    91  setsockopt$inet_tcp_TCP_RXTLS_ENABLE(fd sock_tcp, level const[IPPROTO_TCP], optname const[TCP_RXTLS_ENABLE], optval ptr[in, tls_enable], optlen bytesize[optval])
    92  
    93  tls_enable {
    94  	cipher_key		ptr[in, array[int8]]
    95  	iv			ptr[in, array[int8]]
    96  	auth_key		ptr[in, array[int8]]
    97  	cipher_algorithm	flags[ktls_cipher_algo, int32]
    98  	cipher_key_len		bytesize[cipher_key, int32]
    99  	iv_len			bytesize[iv, int32]
   100  	auth_algorithm		flags[ktls_auth_algo, int32]
   101  	auth_key_len		bytesize[auth_key, int32]
   102  	flags			const[0, int32]
   103  	tls_vmajor		flags[ktls_vmajor, int8]
   104  	tls_vminor		flags[ktls_vminor, int8]
   105  	rec_seq			array[int8, 8]
   106  }
   107  
   108  ktls_cipher_algo = CRYPTO_AES_NIST_GCM_16, CRYPTO_AES_CBC, CRYPTO_CHACHA20_POLY1305
   109  ktls_auth_algo = 0, CRYPTO_AES_128_NIST_GMAC, CRYPTO_AES_192_NIST_GMAC, CRYPTO_AES_256_NIST_GMAC
   110  ktls_vmajor = TLS_MAJOR_VER_ONE
   111  ktls_vminor = TLS_MINOR_VER_ZERO, TLS_MINOR_VER_ONE, TLS_MINOR_VER_TWO, TLS_MINOR_VER_THREE