2 * Copyright (c) 2012-2014 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _NETINET_MPTCP_VAR_H_
30 #define _NETINET_MPTCP_VAR_H_
33 #include <netinet/in.h>
34 #include <netinet/tcp.h>
37 #ifdef BSD_KERNEL_PRIVATE
38 #include <sys/queue.h>
39 #include <sys/protosw.h>
40 #include <kern/locks.h>
41 #include <mach/boolean.h>
42 #include <netinet/mp_pcb.h>
47 * This is an extension to the multipath PCB specific for MPTCP, protected by
48 * the per-PCB mpp_lock (also the socket's lock); MPTCP thread signalling uses
49 * its own mpte_thread_lock due to lock ordering constraints.
52 struct mppcb
*mpte_mppcb
; /* back ptr to multipath PCB */
53 struct mptcb
*mpte_mptcb
; /* ptr to MPTCP PCB */
54 TAILQ_HEAD(, mptopt
) mpte_sopts
; /* list of socket options */
55 TAILQ_HEAD(, mptsub
) mpte_subflows
; /* list of subflows */
56 uint16_t mpte_numflows
; /* # of subflows in list */
57 uint16_t mpte_nummpcapflows
; /* # of MP_CAP subflows */
58 associd_t mpte_associd
; /* MPTCP association ID */
59 connid_t mpte_connid_last
; /* last used connection ID */
61 * Threading (protected by mpte_thread_lock)
63 decl_lck_mtx_data(, mpte_thread_lock
); /* thread lock */
64 struct thread
*mpte_thread
; /* worker thread */
65 uint32_t mpte_thread_active
; /* thread is running */
66 uint32_t mpte_thread_reqs
; /* # of requests for thread */
67 struct mptsub
*mpte_active_sub
; /* ptr to last active subf */
68 uint8_t mpte_flags
; /* per mptcp session flags */
69 uint8_t mpte_lost_aid
; /* storing lost address id */
70 uint8_t mpte_addrid_last
; /* storing address id parm */
74 * Valid values for mpte_flags.
76 #define MPTE_SND_REM_ADDR 0x01 /* Send Remove_addr option */
78 #define mptompte(mp) ((struct mptses *)(mp)->mpp_pcbe)
80 #define MPTE_LOCK_ASSERT_HELD(_mpte) \
81 lck_mtx_assert(&(_mpte)->mpte_mppcb->mpp_lock, LCK_MTX_ASSERT_OWNED)
83 #define MPTE_LOCK_ASSERT_NOTHELD(_mpte) \
84 lck_mtx_assert(&(_mpte)->mpte_mppcb->mpp_lock, LCK_MTX_ASSERT_NOTOWNED)
86 #define MPTE_LOCK(_mpte) \
87 lck_mtx_lock(&(_mpte)->mpte_mppcb->mpp_lock)
89 #define MPTE_LOCK_SPIN(_mpte) \
90 lck_mtx_lock_spin(&(_mpte)->mpte_mppcb->mpp_lock)
92 #define MPTE_CONVERT_LOCK(_mpte) do { \
93 MPTE_LOCK_ASSERT_HELD(_mpte); \
94 lck_mtx_convert_spin(&(_mpte)->mpte_mppcb->mpp_lock); \
97 #define MPTE_UNLOCK(_mpte) \
98 lck_mtx_unlock(&(_mpte)->mpte_mppcb->mpp_lock)
101 * MPTCP socket options
104 TAILQ_ENTRY(mptopt
) mpo_entry
; /* glue to other options */
105 uint32_t mpo_flags
; /* see flags below */
106 int mpo_level
; /* sopt_level */
107 int mpo_name
; /* sopt_name */
108 int mpo_intval
; /* sopt_val */
111 #define MPOF_ATTACHED 0x1 /* attached to MP socket */
112 #define MPOF_SUBFLOW_OK 0x2 /* can be issued on subflow socket */
113 #define MPOF_INTERIM 0x4 /* has not been issued on any subflow */
116 * Structure passed down to TCP during subflow connection establishment
117 * containing information pertaining to the MPTCP.
119 struct mptsub_connreq
{
120 uint32_t mpcr_type
; /* see MPTSUB_CONNREQ_* below */
121 uint32_t mpcr_ifscope
; /* ifscope parameter to connectx(2) */
122 struct proc
*mpcr_proc
; /* process issuing connectx(2) */
125 /* valid values for mpcr_type */
126 #define MPTSUB_CONNREQ_MP_ENABLE 1 /* enable MPTCP */
127 #define MPTSUB_CONNREQ_MP_ADD 2 /* join an existing MPTCP */
132 * Protected by the the per-subflow mpts_lock. Note that mpts_flags
133 * and mpts_evctl are modified via atomic operations.
136 decl_lck_mtx_data(, mpts_lock
); /* per-subflow lock */
137 TAILQ_ENTRY(mptsub
) mpts_entry
; /* glue to peer subflows */
138 uint32_t mpts_refcnt
; /* reference count */
139 uint32_t mpts_flags
; /* see flags below */
140 uint32_t mpts_evctl
; /* subflow control events */
141 uint32_t mpts_family
; /* address family */
142 connid_t mpts_connid
; /* subflow connection ID */
143 int mpts_oldintval
; /* sopt_val before sosetopt */
144 uint32_t mpts_rank
; /* subflow priority/rank */
145 int32_t mpts_soerror
; /* most recent subflow error */
146 struct mptses
*mpts_mpte
; /* back ptr to MPTCP session */
147 struct socket
*mpts_socket
; /* subflow socket */
148 struct sockaddr_list
*mpts_src_sl
; /* source list */
149 struct sockaddr_list
*mpts_dst_sl
; /* destination list */
150 struct ifnet
*mpts_outif
; /* outbound interface */
151 u_int64_t mpts_sndnxt
; /* next byte to send in mp so */
152 u_int32_t mpts_rel_seq
; /* running count of subflow # */
154 u_int64_t mptsl_dsn
; /* Data Sequence Number */
155 u_int32_t mptsl_sseq
; /* Corresponding Data Seq */
156 u_int32_t mptsl_len
; /* length of mapping */
158 struct protosw
*mpts_oprotosw
; /* original protosw */
159 struct mptsub_connreq mpts_mpcr
; /* connection request */
163 * Valid values for mpts_flags. In particular:
165 * - MP_CAPABLE means that the connection is successfully established as
166 * MPTCP and data transfer may occur, but is not yet ready for multipath-
167 * related semantics until MP_READY. I.e. if this is on the first subflow,
168 * it causes the MPTCP socket to transition to a connected state, except
169 * that additional subflows will not be established; they will be marked
170 * with PENDING and will be processed when the first subflow is marked
173 * - MP_READY implies that an MP_CAPABLE connection has been confirmed as
174 * an MPTCP connection. See notes above.
176 * - MP_DEGRADED implies that the connection has lost its MPTCP capabilities
177 * but data transfer on the MPTCP socket is unaffected. Any existing
178 * PENDING subflows will be disconnected, and further attempts to connect
179 * additional subflows will be rejected.
181 * Note that these are per-subflow flags. The setting and clearing of MP_READY
182 * reflects the state of the MPTCP connection with regards to its multipath
183 * semantics, via the MPTCPF_JOIN_READY flag. Until that flag is set (meaning
184 * until at least a subflow is marked with MP_READY), further connectx(2)
185 * attempts to join will be queued. When the flag is cleared (after it has
186 * been set), further connectx(2) will fail (and existing queued ones will be
187 * aborted) and the MPTCP connection loses all of its multipath semantics.
189 * Keep in sync with bsd/dev/dtrace/scripts/mptcp.d.
191 #define MPTSF_ATTACHED 0x1 /* attached to MPTCP PCB */
192 #define MPTSF_CONNECTING 0x2 /* connection was attempted */
193 #define MPTSF_CONNECT_PENDING 0x4 /* will connect when MPTCP is ready */
194 #define MPTSF_CONNECTED 0x8 /* connection is established */
195 #define MPTSF_DISCONNECTING 0x10 /* disconnection was attempted */
196 #define MPTSF_DISCONNECTED 0x20 /* has been disconnected */
197 #define MPTSF_MP_CAPABLE 0x40 /* connected as a MPTCP subflow */
198 #define MPTSF_MP_READY 0x80 /* MPTCP has been confirmed */
199 #define MPTSF_MP_DEGRADED 0x100 /* has lost its MPTCP capabilities */
200 #define MPTSF_SUSPENDED 0x200 /* write-side is flow controlled */
201 #define MPTSF_BOUND_IF 0x400 /* subflow bound to an interface */
202 #define MPTSF_BOUND_IP 0x800 /* subflow bound to a src address */
203 #define MPTSF_BOUND_PORT 0x1000 /* subflow bound to a src port */
204 #define MPTSF_PREFERRED 0x2000 /* primary/preferred subflow */
205 #define MPTSF_SOPT_OLDVAL 0x4000 /* old option value is valid */
206 #define MPTSF_SOPT_INPROG 0x8000 /* sosetopt in progress */
207 #define MPTSF_DELETEOK 0x10000 /* subflow can be deleted */
208 #define MPTSF_FAILINGOVER 0x20000 /* subflow not used for output */
209 #define MPTSF_ACTIVE 0x40000 /* subflow currently in use */
210 #define MPTSF_MPCAP_CTRSET 0x80000 /* mpcap counter */
211 #define MPTSF_FASTJ_SEND 0x100000 /* send data after SYN in MP_JOIN */
212 #define MPTSF_FASTJ_REQD 0x200000 /* fastjoin required */
213 #define MPTSF_USER_DISCONNECT 0x400000 /* User triggered disconnect */
216 "\020\1ATTACHED\2CONNECTING\3PENDING\4CONNECTED\5DISCONNECTING" \
217 "\6DISCONNECTED\7MP_CAPABLE\10MP_READY\11MP_DEGRADED\12SUSPENDED" \
218 "\13BOUND_IF\14BOUND_IP\15BOUND_PORT\16PREFERRED\17SOPT_OLDVAL" \
219 "\20SOPT_INPROG\21NOLINGER\22FAILINGOVER\23ACTIVE\24MPCAP_CTRSET" \
220 "\25FASTJ_SEND\26FASTJ_REQD\27USER_DISCONNECT"
222 #define MPTS_LOCK_ASSERT_HELD(_mpts) \
223 lck_mtx_assert(&(_mpts)->mpts_lock, LCK_MTX_ASSERT_OWNED)
225 #define MPTS_LOCK_ASSERT_NOTHELD(_mpts) \
226 lck_mtx_assert(&(_mpts)->mpts_lock, LCK_MTX_ASSERT_NOTOWNED)
228 #define MPTS_LOCK(_mpts) \
229 lck_mtx_lock(&(_mpts)->mpts_lock)
231 #define MPTS_UNLOCK(_mpts) \
232 lck_mtx_unlock(&(_mpts)->mpts_lock)
234 #define MPTS_ADDREF(_mpts) \
235 mptcp_subflow_addref(_mpts, 0)
237 #define MPTS_ADDREF_LOCKED(_mpts) \
238 mptcp_subflow_addref(_mpts, 1)
240 #define MPTS_REMREF(_mpts) \
241 mptcp_subflow_remref(_mpts)
245 * Keep in sync with bsd/dev/dtrace/mptcp.d
247 typedef enum mptcp_state
{
248 MPTCPS_CLOSED
= 0, /* closed */
249 MPTCPS_LISTEN
= 1, /* not yet implemented */
250 MPTCPS_ESTABLISHED
= 2, /* MPTCP connection established */
251 MPTCPS_CLOSE_WAIT
= 3, /* rcvd DFIN, waiting for close */
252 MPTCPS_FIN_WAIT_1
= 4, /* have closed, sent DFIN */
253 MPTCPS_CLOSING
= 5, /* closed xchd DFIN, waiting DFIN ACK */
254 MPTCPS_LAST_ACK
= 6, /* had DFIN and close; await DFIN ACK */
255 MPTCPS_FIN_WAIT_2
= 7, /* have closed, DFIN is acked */
256 MPTCPS_TIME_WAIT
= 8, /* in 2*MSL quiet wait after close */
257 MPTCPS_FASTCLOSE_WAIT
= 9, /* sent MP_FASTCLOSE */
258 MPTCPS_TERMINATE
= 10, /* terminal state */
261 typedef u_int64_t mptcp_key_t
;
262 typedef u_int32_t mptcp_token_t
;
263 typedef u_int8_t mptcp_addr_id
;
266 /* Address ID list */
267 struct mptcp_subf_auth_entry
{
268 LIST_ENTRY(mptcp_subf_auth_entry
) msae_next
;
269 u_int32_t msae_laddr_rand
; /* Local nonce */
270 u_int32_t msae_raddr_rand
; /* Remote nonce */
271 mptcp_addr_id msae_laddr_id
; /* Local addr ID */
272 mptcp_addr_id msae_raddr_id
; /* Remote addr ID */
276 * MPTCP Protocol Control Block
278 * Protected by per-MPTCP mpt_lock.
279 * Keep in sync with bsd/dev/dtrace/scripts/mptcp.d.
282 decl_lck_mtx_data(, mpt_lock
); /* per MPTCP PCB lock */
283 struct mptses
*mpt_mpte
; /* back ptr to MPTCP session */
284 mptcp_state_t mpt_state
; /* MPTCP state */
285 u_int32_t mpt_flags
; /* see flags below */
286 u_int32_t mpt_refcnt
; /* references held on mptcb */
287 u_int32_t mpt_version
; /* MPTCP proto version */
288 int mpt_softerror
; /* error not yet reported */
290 * Authentication and metadata invariants
292 mptcp_key_t
*mpt_localkey
; /* in network byte order */
293 mptcp_key_t mpt_remotekey
; /* in network byte order */
294 mptcp_token_t mpt_localtoken
; /* HMAC SHA1 of local key */
295 mptcp_token_t mpt_remotetoken
; /* HMAC SHA1 of remote key */
298 * Timer vars for scenarios where subflow level acks arrive, but
301 int mpt_rxtshift
; /* num of consecutive retrans */
302 u_int32_t mpt_rxtstart
; /* time at which rxt started */
303 u_int64_t mpt_rtseq
; /* seq # being tracked */
304 u_int32_t mpt_timer_vals
; /* timer related values */
305 u_int32_t mpt_timewait
; /* timewait */
309 u_int64_t mpt_snduna
; /* DSN of last unacked byte */
310 u_int64_t mpt_sndnxt
; /* DSN of next byte to send */
311 u_int64_t mpt_sndmax
; /* DSN of max byte sent */
312 u_int64_t mpt_local_idsn
; /* First byte's DSN */
313 u_int32_t mpt_sndwnd
;
317 u_int64_t mpt_rcvnxt
; /* Next expected DSN */
318 u_int64_t mpt_rcvatmark
; /* mpsocket marker of rcvnxt */
319 u_int64_t mpt_remote_idsn
; /* Peer's IDSN */
320 u_int32_t mpt_rcvwnd
;
321 LIST_HEAD(, mptcp_subf_auth_entry
) mpt_subauth_list
; /* address IDs */
325 u_int64_t mpt_dsn_at_csum_fail
; /* MPFail Opt DSN */
326 u_int32_t mpt_ssn_at_csum_fail
; /* MPFail Subflow Seq */
330 #define MPT_GC_TICKS (60)
331 int32_t mpt_gc_ticks
; /* Used for zombie deletion */
333 u_int32_t mpt_notsent_lowat
; /* TCP_NOTSENT_LOWAT support */
336 /* valid values for mpt_flags (see also notes on mpts_flags above) */
337 #define MPTCPF_CHECKSUM 0x1 /* checksum DSS option */
338 #define MPTCPF_FALLBACK_TO_TCP 0x2 /* Fallback to TCP */
339 #define MPTCPF_JOIN_READY 0x4 /* Ready to start 2 or more subflows */
340 #define MPTCPF_RECVD_MPFAIL 0x8 /* Received MP_FAIL option */
341 #define MPTCPF_PEEL_OFF 0x10 /* Peel off this socket */
342 #define MPTCPF_SND_64BITDSN 0x20 /* Send full 64-bit DSN */
343 #define MPTCPF_SND_64BITACK 0x40 /* Send 64-bit ACK response */
344 #define MPTCPF_RCVD_64BITACK 0x80 /* Received 64-bit Data ACK */
345 #define MPTCPF_POST_FALLBACK_SYNC 0x100 /* Post fallback resend data */
347 #define MPTCPF_BITS \
348 "\020\1CHECKSUM\2FALLBACK_TO_TCP\3JOIN_READY\4RECVD_MPFAIL\5PEEL_OFF" \
349 "\6SND_64BITDSN\7SND_64BITACK\10RCVD_64BITACK\11POST_FALLBACK_SYNC"
351 /* valid values for mpt_timer_vals */
352 #define MPTT_REXMT 0x01 /* Starting Retransmit Timer */
353 #define MPTT_TW 0x02 /* Starting Timewait Timer */
354 #define MPTT_FASTCLOSE 0x04 /* Starting Fastclose wait timer */
356 #define MPT_LOCK_ASSERT_HELD(_mpt) \
357 lck_mtx_assert(&(_mpt)->mpt_lock, LCK_MTX_ASSERT_OWNED)
359 #define MPT_LOCK_ASSERT_NOTHELD(_mpt) \
360 lck_mtx_assert(&(_mpt)->mpt_lock, LCK_MTX_ASSERT_NOTOWNED)
362 #define MPT_LOCK(_mpt) \
363 lck_mtx_lock(&(_mpt)->mpt_lock)
365 #define MPT_LOCK_SPIN(_mpt) \
366 lck_mtx_lock_spin(&(_mpt)->mpt_lock)
368 #define MPT_CONVERT_LOCK(_mpt) do { \
369 MPT_LOCK_ASSERT_HELD(_mpt); \
370 lck_mtx_convert_spin(&(_mpt)->mpt_lock); \
373 #define MPT_UNLOCK(_mpt) \
374 lck_mtx_unlock(&(_mpt)->mpt_lock)
376 /* events for close FSM */
377 #define MPCE_CLOSE 0x1
378 #define MPCE_RECV_DATA_ACK 0x2
379 #define MPCE_RECV_DATA_FIN 0x4
381 /* mptcb manipulation */
382 #define tptomptp(tp) ((struct mptcb *)((tp)->t_mptcb))
385 * MPTCP control block and state structures are allocated along with
386 * the MP protocol control block; the folllowing represents the layout.
389 struct mppcb mpp
; /* Multipath PCB */
390 struct mptses mpp_ses
; /* MPTCP session */
391 struct mptcb mtcb
; /* MPTCP PCB */
395 SYSCTL_DECL(_net_inet_mptcp
);
396 #endif /* SYSCTL_DECL */
398 extern struct mppcbinfo mtcbinfo
;
399 extern struct pr_usrreqs mptcp_usrreqs
;
401 /* Encryption algorithm related definitions */
402 #define MPTCP_SHA1_RESULTLEN 20
403 #define SHA1_TRUNCATED 8
405 /* List of valid keys to use for MPTCP connections */
406 #define MPTCP_KEY_DIGEST_LEN (MPTCP_SHA1_RESULTLEN)
407 #define MPTCP_MX_KEY_ALLOCS (256)
408 #define MPTCP_KEY_PREALLOCS_MX (16)
409 #define MPTCP_MX_PREALLOC_ZONE_SZ (8192)
411 struct mptcp_key_entry
{
412 LIST_ENTRY(mptcp_key_entry
) mkey_next
;
413 mptcp_key_t mkey_value
;
414 #define MKEYF_FREE 0x0
415 #define MKEYF_INUSE 0x1
416 u_int32_t mkey_flags
;
417 char mkey_digest
[MPTCP_KEY_DIGEST_LEN
];
420 /* structure for managing unique key list */
421 struct mptcp_keys_pool_head
{
422 struct mptcp_key_entry
*lh_first
; /* list of keys */
423 u_int32_t mkph_count
; /* total keys in pool */
424 vm_size_t mkph_key_elm_sz
; /* size of key entry */
425 struct zone
*mkph_key_entry_zone
; /* zone for key entry */
426 decl_lck_mtx_data(, mkph_lock
); /* lock for key list */
429 /* MPTCP Receive Window */
430 #define MPTCP_RWIN_MAX (1<<16)
432 /* MPTCP Debugging Levels */
433 #define MP_NODEBUG 0x0
434 #define MP_ERR_DEBUG 0x1
435 #define MP_VERBOSE_DEBUG_1 0x2
436 #define MP_VERBOSE_DEBUG_2 0x3
437 #define MP_VERBOSE_DEBUG_3 0x4
438 #define MP_VERBOSE_DEBUG_4 0x5 /* output path debugging */
440 /* Mask to obtain 32-bit portion of data sequence number */
441 #define MPTCP_DATASEQ_LOW32_MASK (0xffffffff)
442 #define MPTCP_DATASEQ_LOW32(seq) (seq & MPTCP_DATASEQ_LOW32_MASK)
444 /* Mask to obtain upper 32-bit portion of data sequence number */
445 #define MPTCP_DATASEQ_HIGH32_MASK (0xffffffff00000000)
446 #define MPTCP_DATASEQ_HIGH32(seq) (seq & MPTCP_DATASEQ_HIGH32_MASK)
448 /* Mask to obtain 32-bit portion of data ack */
449 #define MPTCP_DATAACK_LOW32_MASK (0xffffffff)
450 #define MPTCP_DATAACK_LOW32(ack) (ack & MPTCP_DATAACK_LOW32_MASK)
452 /* Mask to obtain upper 32-bit portion of data ack */
453 #define MPTCP_DATAACK_HIGH32_MASK (0xffffffff00000000)
454 #define MPTCP_DATAACK_HIGH32(ack) (ack & MPTCP_DATAACK_HIGH32_MASK)
457 * x is the 64-bit data sequence number, y the 32-bit data seq number to be
458 * extended. z is y extended to the appropriate 64-bit value.
459 * This algorithm is based on the fact that subflow level window sizes are
460 * at the maximum 2**30 (in reality, they are a lot lesser). A high throughput
461 * application sending on a large number of subflows can in theory have very
462 * large MPTCP level send and receive windows. In which case, 64 bit DSNs
463 * must be sent in place of 32 bit DSNs on wire. For us, with 2 subflows at
464 * 512K each, sequence wraparound detection can be done by checking whether
465 * the 32-bit value obtained on wire is 2**31 bytes apart from the stored
466 * lower 32-bits of the Data Sequence Number. Bogus DSNs are dropped by
467 * comparing against rwnd. Bogus DSNs within rwnd cannot be protected against
468 * and are as weak as bogus TCP sequence numbers.
470 #define MPTCP_EXTEND_DSN(x, y, z) { \
471 if ((MPTCP_DATASEQ_LOW32(x) > y) && \
472 ((((u_int32_t)MPTCP_DATASEQ_LOW32(x)) - (u_int32_t)y) >= \
473 (u_int32_t)(1 << 31))) { \
475 * y wrapped around and x and y are 2**31 bytes apart \
477 z = MPTCP_DATASEQ_HIGH32(x) + 0x100000000; \
479 } else if ((MPTCP_DATASEQ_LOW32(x) < y) && \
481 ((u_int32_t)MPTCP_DATASEQ_LOW32(x))) >= \
482 (u_int32_t)(1 << 31))) { \
484 * x wrapped around and x and y are 2**31 apart \
486 z = MPTCP_DATASEQ_HIGH32(x) - 0x100000000; \
489 z = MPTCP_DATASEQ_HIGH32(x) | y; \
493 #define mptcplog(x) do { if (mptcp_verbose >= 1) log x; } while (0)
494 #define mptcplog2(x) do { if (mptcp_verbose >= 2) log x; } while (0)
495 #define mptcplog3(x) do { if (mptcp_verbose >= 3) log x; } while (0)
497 extern int mptcp_enable
; /* Multipath TCP */
498 extern int mptcp_dbg
; /* Multipath TCP DBG */
499 extern int mptcp_mpcap_retries
; /* Multipath TCP retries */
500 extern int mptcp_join_retries
; /* Multipath TCP Join retries */
501 extern int mptcp_dss_csum
; /* Multipath DSS Option checksum */
502 extern int mptcp_fail_thresh
; /* Multipath failover thresh of retransmits */
503 extern int mptcp_subflow_keeptime
; /* Multipath subflow TCP_KEEPALIVE opt */
504 extern int mptcp_mpprio_enable
; /* MP_PRIO option enable/disable */
505 extern int mptcp_remaddr_enable
;/* REMOVE_ADDR option enable/disable */
506 extern int mptcp_fastjoin
; /* Enable FastJoin */
507 extern int mptcp_zerortt_fastjoin
; /* Enable Data after SYN Fast Join */
508 extern int mptcp_rwnotify
; /* Enable RW notification on resume */
509 extern uint32_t mptcp_verbose
; /* verbose and mptcp_dbg must be unified */
510 #define MPPCB_LIMIT 16
511 extern uint32_t mptcp_socket_limit
; /* max number of mptcp sockets allowed */
512 extern uint32_t mptcp_delayed_subf_start
; /* delayed cellular subflow start */
513 extern int tcp_jack_rxmt
; /* Join ACK retransmission value in msecs */
516 extern void mptcp_init(struct protosw
*, struct domain
*);
517 extern int mptcp_ctloutput(struct socket
*, struct sockopt
*);
518 extern struct mptses
*mptcp_sescreate(struct socket
*, struct mppcb
*);
519 extern void mptcp_drain(void);
520 extern struct mptses
*mptcp_drop(struct mptses
*, struct mptcb
*, int);
521 extern struct mptses
*mptcp_close(struct mptses
*, struct mptcb
*);
522 extern int mptcp_lock(struct socket
*, int, void *);
523 extern int mptcp_unlock(struct socket
*, int, void *);
524 extern lck_mtx_t
*mptcp_getlock(struct socket
*, int);
525 extern void mptcp_thread_signal(struct mptses
*);
526 extern void mptcp_flush_sopts(struct mptses
*);
527 extern int mptcp_setconnorder(struct mptses
*, connid_t
, uint32_t);
528 extern int mptcp_getconnorder(struct mptses
*, connid_t
, uint32_t *);
530 extern struct mptopt
*mptcp_sopt_alloc(int);
531 extern const char *mptcp_sopt2str(int, int, char *, int);
532 extern void mptcp_sopt_free(struct mptopt
*);
533 extern void mptcp_sopt_insert(struct mptses
*, struct mptopt
*);
534 extern void mptcp_sopt_remove(struct mptses
*, struct mptopt
*);
535 extern struct mptopt
*mptcp_sopt_find(struct mptses
*, struct sockopt
*);
537 extern struct mptsub
*mptcp_subflow_alloc(int);
538 extern void mptcp_subflow_free(struct mptsub
*);
539 extern void mptcp_subflow_addref(struct mptsub
*, int);
540 extern int mptcp_subflow_add(struct mptses
*, struct mptsub
*,
541 struct proc
*, uint32_t);
542 extern void mptcp_subflow_del(struct mptses
*, struct mptsub
*, boolean_t
);
543 extern void mptcp_subflow_remref(struct mptsub
*);
544 extern int mptcp_subflow_output(struct mptses
*, struct mptsub
*);
545 extern void mptcp_subflow_disconnect(struct mptses
*, struct mptsub
*,
547 extern void mptcp_subflow_sopeeloff(struct mptses
*, struct mptsub
*,
549 extern int mptcp_subflow_sosetopt(struct mptses
*, struct socket
*,
551 extern int mptcp_subflow_sogetopt(struct mptses
*, struct socket
*,
554 extern void mptcp_input(struct mptses
*, struct mbuf
*);
555 extern int mptcp_output(struct mptses
*);
556 extern void mptcp_close_fsm(struct mptcb
*, uint32_t);
558 extern mptcp_token_t
mptcp_get_localtoken(void *);
559 extern mptcp_token_t
mptcp_get_remotetoken(void *);
561 extern u_int64_t
mptcp_get_localkey(void *);
562 extern u_int64_t
mptcp_get_remotekey(void *);
564 extern void mptcp_free_key(mptcp_key_t
*key
);
565 extern void mptcp_hmac_sha1(mptcp_key_t
, mptcp_key_t
, u_int32_t
, u_int32_t
,
567 extern void mptcp_get_hmac(mptcp_addr_id
, struct mptcb
*, u_char
*, int);
568 extern void mptcp_get_rands(mptcp_addr_id
, struct mptcb
*, u_int32_t
*,
570 extern void mptcp_set_raddr_rand(mptcp_addr_id
, struct mptcb
*, mptcp_addr_id
,
572 extern u_int64_t
mptcp_get_trunced_hmac(mptcp_addr_id
, struct mptcb
*mp_tp
);
573 extern int mptcp_generate_token(char *, int, caddr_t
, int);
574 extern int mptcp_generate_idsn(char *, int, caddr_t
, int);
575 extern boolean_t
mptcp_ok_to_keepalive(struct mptcb
*);
576 extern void mptcp_insert_dsn(struct mppcb
*, struct mbuf
*);
577 extern void mptcp_output_getm_dsnmap32(struct socket
*, int, uint32_t,
578 u_int32_t
*, u_int32_t
*, u_int16_t
*, u_int64_t
*);
579 extern void mptcp_output_getm_dsnmap64(struct socket
*, int, uint32_t,
580 u_int64_t
*, u_int32_t
*, u_int16_t
*);
581 extern void mptcp_send_dfin(struct socket
*);
582 extern void mptcp_act_on_txfail(struct socket
*);
583 extern struct mptsub
*mptcp_get_subflow(struct mptses
*, struct mptsub
*);
584 extern struct mptsub
*mptcp_get_pending_subflow(struct mptses
*,
586 extern int mptcp_get_map_for_dsn(struct socket
*, u_int64_t
, u_int32_t
*);
587 extern int32_t mptcp_adj_sendlen(struct socket
*so
, int32_t off
, int32_t len
);
588 extern int32_t mptcp_sbspace(struct mptcb
*);
589 extern void mptcp_notify_mpready(struct socket
*);
590 extern void mptcp_notify_mpfail(struct socket
*);
591 extern void mptcp_notify_close(struct socket
*);
592 extern boolean_t
mptcp_no_rto_spike(struct socket
*);
593 extern int mptcp_set_notsent_lowat(struct mptses
*mpte
, int optval
);
594 extern u_int32_t
mptcp_get_notsent_lowat(struct mptses
*mpte
);
595 extern int mptcp_notsent_lowat_check(struct socket
*so
);
599 #endif /* BSD_KERNEL_PRIVATE */
601 typedef struct mptcp_flow
{
604 struct sockaddr_storage flow_src
;
605 struct sockaddr_storage flow_dst
;
606 conninfo_tcp_t flow_ci
;
609 typedef struct conninfo_mptcp
{
611 size_t mptcpci_nflows
;
612 uint32_t mptcpci_state
;
613 mptcp_flow_t mptcpci_flows
[1];
617 #endif /* _NETINET_MPTCP_VAR_H_ */