@@ -5795,6 +5795,12 @@ union bpf_attr {
* 0 on success.
*
* **-ENOENT** if the bpf_local_storage cannot be found.
+ *
+ * void *bpf_mptcp_send_info_to_ssk(void *info)
+ * Description
+ * Dynamically cast a *info* pointer to a *sock* pointer.
+ * Return
+ * *info* if casting is valid, or **NULL** otherwise.
*/
#define ___BPF_FUNC_MAPPER(FN, ctx...) \
FN(unspec, 0, ##ctx) \
@@ -6009,6 +6015,7 @@ union bpf_attr {
FN(user_ringbuf_drain, 209, ##ctx) \
FN(cgrp_storage_get, 210, ##ctx) \
FN(cgrp_storage_delete, 211, ##ctx) \
+ FN(mptcp_send_info_to_ssk, 212, ##ctx) \
/* */
/* backwards-compatibility macros for users of __BPF_FUNC_MAPPER that don't
@@ -21,6 +21,26 @@ static struct bpf_struct_ops bpf_mptcp_sched_ops;
static const struct btf_type *mptcp_sock_type, *mptcp_subflow_type __read_mostly;
static u32 mptcp_sock_id, mptcp_subflow_id;
+BPF_CALL_1(bpf_mptcp_send_info_to_ssk, struct subflow_send_info *, info)
+{
+ BTF_TYPE_EMIT(struct sock);
+
+ if (info && info->ssk && sk_fullsock(info->ssk) &&
+ info->ssk->sk_protocol == IPPROTO_TCP &&
+ sk_is_mptcp(info->ssk))
+ return (unsigned long)info->ssk;
+
+ return (unsigned long)NULL;
+}
+
+static const struct bpf_func_proto bpf_mptcp_send_info_to_ssk_proto = {
+ .func = bpf_mptcp_send_info_to_ssk,
+ .gpl_only = false,
+ .ret_type = RET_PTR_TO_BTF_ID_OR_NULL,
+ .arg1_type = ARG_PTR_TO_STACK,
+ .ret_btf_id = &btf_sock_ids[BTF_SOCK_TYPE_SOCK],
+};
+
static const struct bpf_func_proto *
bpf_mptcp_sched_get_func_proto(enum bpf_func_id func_id,
const struct bpf_prog *prog)
@@ -34,6 +54,8 @@ bpf_mptcp_sched_get_func_proto(enum bpf_func_id func_id,
return &bpf_skc_to_tcp6_sock_proto;
case BPF_FUNC_skc_to_tcp_sock:
return &bpf_skc_to_tcp_sock_proto;
+ case BPF_FUNC_mptcp_send_info_to_ssk:
+ return &bpf_mptcp_send_info_to_ssk_proto;
default:
return bpf_base_func_proto(func_id, prog);
}
@@ -1387,11 +1387,6 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
sizeof(struct ipv6hdr) - \
sizeof(struct frag_hdr))
-struct subflow_send_info {
- struct sock *ssk;
- u64 linger_time;
-};
-
void mptcp_subflow_set_active(struct mptcp_subflow_context *subflow)
{
if (!subflow->stale)
@@ -598,6 +598,11 @@ mptcp_subflow_ctx_reset(struct mptcp_subflow_context *subflow)
WRITE_ONCE(subflow->local_id, -1);
}
+struct subflow_send_info {
+ struct sock *ssk;
+ u64 linger_time;
+};
+
/* Convert reset reasons in MPTCP to enum sk_rst_reason type */
static inline enum sk_rst_reason
sk_rst_convert_mptcp_reason(u32 reason)
@@ -5795,6 +5795,12 @@ union bpf_attr {
* 0 on success.
*
* **-ENOENT** if the bpf_local_storage cannot be found.
+ *
+ * void *bpf_mptcp_send_info_to_ssk(void *info)
+ * Description
+ * Dynamically cast a *info* pointer to a *sock* pointer.
+ * Return
+ * *info* if casting is valid, or **NULL** otherwise.
*/
#define ___BPF_FUNC_MAPPER(FN, ctx...) \
FN(unspec, 0, ##ctx) \
@@ -6009,6 +6015,7 @@ union bpf_attr {
FN(user_ringbuf_drain, 209, ##ctx) \
FN(cgrp_storage_get, 210, ##ctx) \
FN(cgrp_storage_delete, 211, ##ctx) \
+ FN(mptcp_send_info_to_ssk, 212, ##ctx) \
/* */
/* backwards-compatibility macros for users of __BPF_FUNC_MAPPER that don't