@@ -582,6 +582,13 @@ extern struct mptcp_subflow_context *
bpf_iter_mptcp_subflow_next(struct bpf_iter_mptcp_subflow *it) __weak __ksym;
extern void bpf_iter_mptcp_subflow_destroy(struct bpf_iter_mptcp_subflow *it) __weak __ksym;
+struct bpf_iter_mptcp_address;
+extern int bpf_iter_mptcp_address_new(struct bpf_iter_mptcp_address *it,
+ struct mptcp_sock *msk) __weak __ksym;
+extern struct mptcp_pm_addr_entry *
+bpf_iter_mptcp_address_next(struct bpf_iter_mptcp_address *it) __weak __ksym;
+extern void bpf_iter_mptcp_address_destroy(struct bpf_iter_mptcp_address *it) __weak __ksym;
+
extern int bpf_wq_init(struct bpf_wq *wq, void *p__map, unsigned int flags) __weak __ksym;
extern int bpf_wq_start(struct bpf_wq *wq, unsigned int flags) __weak __ksym;
extern int bpf_wq_set_callback_impl(struct bpf_wq *wq,
@@ -52,6 +52,11 @@ bpf_mptcp_subflow_ctx(const struct sock *sk) __ksym;
extern struct sock *
bpf_mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow) __ksym;
+extern void bpf_spin_lock_bh(spinlock_t *lock) __ksym;
+extern void bpf_spin_unlock_bh(spinlock_t *lock) __ksym;
+
+extern bool bpf_ipv6_addr_v4mapped(const struct mptcp_addr_info *a) __ksym;
+
extern void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
bool scheduled) __ksym;
@@ -58,3 +58,42 @@ int iters_subflow(struct bpf_sockopt *ctx)
bpf_mptcp_sock_release(msk);
return 1;
}
+
+SEC("cgroup/getsockopt")
+int iters_address(struct bpf_sockopt *ctx)
+{
+ struct mptcp_pm_addr_entry *entry;
+ struct bpf_sock *sk = ctx->sk;
+ struct mptcp_sock *msk;
+ int local_ids = 0;
+
+ if (!sk || sk->protocol != IPPROTO_MPTCP ||
+ ctx->level != SOL_TCP || ctx->optname != TCP_CONGESTION)
+ return 1;
+
+ msk = bpf_mptcp_sk((struct sock *)sk);
+ if (msk->pm.server_side)
+ return 1;
+
+ msk = bpf_mptcp_sock_acquire(msk);
+ if (!msk)
+ return 1;
+ bpf_spin_lock_bh(&msk->pm.lock);
+ bpf_for_each(mptcp_address, entry, msk) {
+ /* Here MPTCP-specific path manager kfunc can be called:
+ * this test is not doing anything really useful, only to
+ * verify the iteration works.
+ */
+
+ if (!bpf_ipv6_addr_v4mapped(&entry->addr))
+ break;
+
+ local_ids += entry->addr.id;
+ }
+ bpf_spin_unlock_bh(&msk->pm.lock);
+ bpf_mptcp_sock_release(msk);
+
+ ids = local_ids;
+
+ return 1;
+}