+#if (DEBUG || DEVELOPMENT)
+static uint32_t default_tcp_kao_max = 0;
+SYSCTL_INT(_net_link_generic_system, OID_AUTO, default_tcp_kao_max,
+ CTLFLAG_RW | CTLFLAG_LOCKED, &default_tcp_kao_max, 0, "");
+#else
+static const uint32_t default_tcp_kao_max = 0;
+#endif /* (DEBUG || DEVELOPMENT) */
+
+u_int32_t companion_link_sock_buffer_limit = 0;
+
+static int
+sysctl_set_companion_link_sock_buf_limit SYSCTL_HANDLER_ARGS
+{
+#pragma unused(arg1, arg2)
+ int error, tmp = companion_link_sock_buffer_limit;
+ error = sysctl_handle_int(oidp, &tmp, 0, req);
+ if (tmp < 0) {
+ return EINVAL;
+ }
+ if ((error = priv_check_cred(kauth_cred_get(),
+ PRIV_NET_INTERFACE_CONTROL, 0)) != 0) {
+ return error;
+ }
+
+ u_int32_t new_limit = tmp;
+ if (new_limit == companion_link_sock_buffer_limit) {
+ return 0;
+ }
+
+ bool recover = new_limit == 0 ? true : false;
+ if (recover) {
+ error = inp_recover_companion_link(&tcbinfo);
+ } else {
+ error = inp_limit_companion_link(&tcbinfo, new_limit);
+ }
+ if (!error) {
+ companion_link_sock_buffer_limit = new_limit;
+ }
+ return error;
+}
+
+SYSCTL_PROC(_net_link_generic_system, OID_AUTO, companion_sndbuf_limit,
+ CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_LOCKED | CTLFLAG_ANYBODY,
+ &companion_link_sock_buffer_limit, 0, sysctl_set_companion_link_sock_buf_limit,
+ "I", "set sock send buffer limit of connections using companion links");
+