A few variables linked to the in-kernel Path-Manager are confusing, and
it would help current and future developers, to clarify them.

One of them is 'add_addr_signal_max', which in fact represents the
maximum number of 'signal' endpoints that can be used to announced
addresses, and not the number of ADD_ADDR that can be signalled.

While at it, add an additional name for the corresponding variable in
MPTCP INFO: mptcpi_endp_signal_max. Not to break the current uAPI, the
new name is added as a 'define' pointing to the former name. This will
then also help userspace devs.

No functional changes intended.

Reviewed-by: Geliang Tang <[email protected]>
Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
---
 include/uapi/linux/mptcp.h |  1 +
 net/mptcp/pm.c             |  2 +-
 net/mptcp/pm_kernel.c      | 26 +++++++++++++-------------
 net/mptcp/protocol.h       |  2 +-
 net/mptcp/sockopt.c        |  4 ++--
 5 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h
index 
314200c61f150da445ff87debb154bfd98f324fc..69fc20db1c2f731d5f93cfee4e58a23119ff7a97
 100644
--- a/include/uapi/linux/mptcp.h
+++ b/include/uapi/linux/mptcp.h
@@ -48,6 +48,7 @@ struct mptcp_info {
        __u8    mptcpi_subflows_max;
        #define mptcpi_limit_extra_subflows mptcpi_subflows_max
        __u8    mptcpi_add_addr_signal_max;
+       #define mptcpi_endp_signal_max mptcpi_add_addr_signal_max
        __u8    mptcpi_add_addr_accepted_max;
        __u32   mptcpi_flags;
        __u32   mptcpi_token;
diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index 
502f6c235e06c3f6fdca9dcf3a1d7b8e97fb9df6..1100ba8b1ce8243de46b161fb27272c360559bc3
 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -1037,7 +1037,7 @@ void mptcp_pm_data_reset(struct mptcp_sock *msk)
                WRITE_ONCE(pm->work_pending,
                           (!!mptcp_pm_get_local_addr_max(msk) &&
                            subflows_allowed) ||
-                          !!mptcp_pm_get_add_addr_signal_max(msk));
+                          !!mptcp_pm_get_endp_signal_max(msk));
                WRITE_ONCE(pm->accept_addr,
                           !!mptcp_pm_get_add_addr_accept_max(msk) &&
                           subflows_allowed);
diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c
index 
db0d254d0e6b903fd8b920eb4cda628a811f7d58..740f0b20b941fc457831f3394c187159e9a244e8
 100644
--- a/net/mptcp/pm_kernel.c
+++ b/net/mptcp/pm_kernel.c
@@ -20,7 +20,7 @@ struct pm_nl_pernet {
        struct list_head        local_addr_list;
        unsigned int            addrs;
        unsigned int            stale_loss_cnt;
-       unsigned int            add_addr_signal_max;
+       unsigned int            endp_signal_max;
        unsigned int            add_addr_accept_max;
        unsigned int            local_addr_max;
        unsigned int            limit_extra_subflows;
@@ -46,13 +46,13 @@ static struct pm_nl_pernet *genl_info_pm_nl(struct 
genl_info *info)
        return pm_nl_get_pernet(genl_info_net(info));
 }
 
-unsigned int mptcp_pm_get_add_addr_signal_max(const struct mptcp_sock *msk)
+unsigned int mptcp_pm_get_endp_signal_max(const struct mptcp_sock *msk)
 {
        const struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk);
 
-       return READ_ONCE(pernet->add_addr_signal_max);
+       return READ_ONCE(pernet->endp_signal_max);
 }
-EXPORT_SYMBOL_GPL(mptcp_pm_get_add_addr_signal_max);
+EXPORT_SYMBOL_GPL(mptcp_pm_get_endp_signal_max);
 
 unsigned int mptcp_pm_get_add_addr_accept_max(const struct mptcp_sock *msk)
 {
@@ -275,15 +275,15 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct 
mptcp_sock *msk)
 {
        struct sock *sk = (struct sock *)msk;
        unsigned int limit_extra_subflows;
-       unsigned int add_addr_signal_max;
        bool signal_and_subflow = false;
+       unsigned int endp_signal_max;
        unsigned int local_addr_max;
        struct pm_nl_pernet *pernet;
        struct mptcp_pm_local local;
 
        pernet = pm_nl_get_pernet(sock_net(sk));
 
-       add_addr_signal_max = mptcp_pm_get_add_addr_signal_max(msk);
+       endp_signal_max = mptcp_pm_get_endp_signal_max(msk);
        local_addr_max = mptcp_pm_get_local_addr_max(msk);
        limit_extra_subflows = mptcp_pm_get_limit_extra_subflows(msk);
 
@@ -312,11 +312,11 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct 
mptcp_sock *msk)
 
        pr_debug("local %d:%d signal %d:%d subflows %d:%d\n",
                 msk->pm.local_addr_used, local_addr_max,
-                msk->pm.add_addr_signaled, add_addr_signal_max,
+                msk->pm.add_addr_signaled, endp_signal_max,
                 msk->pm.extra_subflows, limit_extra_subflows);
 
        /* check first for announce */
-       if (msk->pm.add_addr_signaled < add_addr_signal_max) {
+       if (msk->pm.add_addr_signaled < endp_signal_max) {
                /* due to racing events on both ends we can reach here while
                 * previous add address is still running: if we invoke now
                 * mptcp_pm_announce_addr(), that will fail and the
@@ -699,8 +699,8 @@ static int mptcp_pm_nl_append_new_local_addr(struct 
pm_nl_pernet *pernet,
                pernet->next_id = entry->addr.id;
 
        if (entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL) {
-               addr_max = pernet->add_addr_signal_max;
-               WRITE_ONCE(pernet->add_addr_signal_max, addr_max + 1);
+               addr_max = pernet->endp_signal_max;
+               WRITE_ONCE(pernet->endp_signal_max, addr_max + 1);
        }
        if (entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) {
                addr_max = pernet->local_addr_max;
@@ -1098,8 +1098,8 @@ int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct 
genl_info *info)
                return -EINVAL;
        }
        if (entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL) {
-               addr_max = pernet->add_addr_signal_max;
-               WRITE_ONCE(pernet->add_addr_signal_max, addr_max - 1);
+               addr_max = pernet->endp_signal_max;
+               WRITE_ONCE(pernet->endp_signal_max, addr_max - 1);
        }
        if (entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) {
                addr_max = pernet->local_addr_max;
@@ -1185,7 +1185,7 @@ static void __flush_addrs(struct list_head *list)
 
 static void __reset_counters(struct pm_nl_pernet *pernet)
 {
-       WRITE_ONCE(pernet->add_addr_signal_max, 0);
+       WRITE_ONCE(pernet->endp_signal_max, 0);
        WRITE_ONCE(pernet->local_addr_max, 0);
        pernet->addrs = 0;
 }
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 
4c777f87b0497ed623f0d51bf1f87cfa011cf0eb..86c30cd6c1f2ceccba9d14ddac7e6334dd46e21b
 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -1180,7 +1180,7 @@ void __init mptcp_pm_userspace_register(void);
 void __init mptcp_pm_nl_init(void);
 void mptcp_pm_worker(struct mptcp_sock *msk);
 void __mptcp_pm_kernel_worker(struct mptcp_sock *msk);
-unsigned int mptcp_pm_get_add_addr_signal_max(const struct mptcp_sock *msk);
+unsigned int mptcp_pm_get_endp_signal_max(const struct mptcp_sock *msk);
 unsigned int mptcp_pm_get_add_addr_accept_max(const struct mptcp_sock *msk);
 unsigned int mptcp_pm_get_limit_extra_subflows(const struct mptcp_sock *msk);
 unsigned int mptcp_pm_get_local_addr_max(const struct mptcp_sock *msk);
diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
index 
4e82bcfcd34e3a1dffb05799cf181ee2940e75d7..4688e0f25d15d9363b33bdcf3ad75c8295a810e3
 100644
--- a/net/mptcp/sockopt.c
+++ b/net/mptcp/sockopt.c
@@ -974,8 +974,8 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct 
mptcp_info *info)
        if (mptcp_pm_is_kernel(msk)) {
                info->mptcpi_limit_extra_subflows =
                        mptcp_pm_get_limit_extra_subflows(msk);
-               info->mptcpi_add_addr_signal_max =
-                       mptcp_pm_get_add_addr_signal_max(msk);
+               info->mptcpi_endp_signal_max =
+                       mptcp_pm_get_endp_signal_max(msk);
                info->mptcpi_add_addr_accepted_max =
                        mptcp_pm_get_add_addr_accept_max(msk);
                info->mptcpi_local_addr_max =

-- 
2.51.0


Reply via email to