Skip to content

Commit

Permalink
mptcp: drop struct mptcp_pm_add_entry
Browse files Browse the repository at this point in the history
There is no need to add a dedicated address entry type "mptcp_pm_add_entry"
to represent ADD_ADDR addresses. Additional fields for ADD_ADDR addresses
can be added into struct mptcp_pm_addr_entry directly. This makes the path
manager code simpler.

Here "union" can be used to merge struct mptcp_pm_addr_entry and struct
mptcp_pm_add_entry into one. Then all mptcp_pm_add_entry can be replaced by
mptcp_pm_addr_entry.

Although this increases the size of the structure even more, but that's OK
to do so because it is not used in an array.

Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
Geliang Tang authored and intel-lab-lkp committed Nov 7, 2024
1 parent 5abb523 commit 25cd49d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
26 changes: 9 additions & 17 deletions net/mptcp/pm_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@

static int pm_nl_pernet_id;

struct mptcp_pm_add_entry {
struct list_head list;
struct mptcp_addr_info addr;
u8 retrans_times;
struct timer_list add_timer;
struct mptcp_sock *sock;
};

struct pm_nl_pernet {
/* protects pernet updates */
spinlock_t lock;
Expand Down Expand Up @@ -257,11 +249,11 @@ bool mptcp_pm_nl_check_work_pending(struct mptcp_sock *msk)
return true;
}

struct mptcp_pm_add_entry *
struct mptcp_pm_addr_entry *
mptcp_lookup_anno_list_by_saddr(const struct mptcp_sock *msk,
const struct mptcp_addr_info *addr)
{
struct mptcp_pm_add_entry *entry;
struct mptcp_pm_addr_entry *entry;

lockdep_assert_held(&msk->pm.lock);

Expand All @@ -275,7 +267,7 @@ mptcp_lookup_anno_list_by_saddr(const struct mptcp_sock *msk,

bool mptcp_pm_sport_in_anno_list(struct mptcp_sock *msk, const struct sock *sk)
{
struct mptcp_pm_add_entry *entry;
struct mptcp_pm_addr_entry *entry;
struct mptcp_addr_info saddr;
bool ret = false;

Expand All @@ -296,7 +288,7 @@ bool mptcp_pm_sport_in_anno_list(struct mptcp_sock *msk, const struct sock *sk)

static void mptcp_pm_add_timer(struct timer_list *timer)
{
struct mptcp_pm_add_entry *entry = from_timer(entry, timer, add_timer);
struct mptcp_pm_addr_entry *entry = from_timer(entry, timer, add_timer);
struct mptcp_sock *msk = entry->sock;
struct sock *sk = (struct sock *)msk;

Expand Down Expand Up @@ -338,11 +330,11 @@ static void mptcp_pm_add_timer(struct timer_list *timer)
__sock_put(sk);
}

struct mptcp_pm_add_entry *
struct mptcp_pm_addr_entry *
mptcp_pm_del_add_timer(struct mptcp_sock *msk,
const struct mptcp_addr_info *addr, bool check_id)
{
struct mptcp_pm_add_entry *entry;
struct mptcp_pm_addr_entry *entry;
struct sock *sk = (struct sock *)msk;
struct timer_list *add_timer = NULL;

Expand All @@ -366,7 +358,7 @@ mptcp_pm_del_add_timer(struct mptcp_sock *msk,
bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk,
const struct mptcp_addr_info *addr)
{
struct mptcp_pm_add_entry *add_entry = NULL;
struct mptcp_pm_addr_entry *add_entry = NULL;
struct sock *sk = (struct sock *)msk;
struct net *net = sock_net(sk);

Expand Down Expand Up @@ -402,7 +394,7 @@ bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk,

void mptcp_pm_free_anno_list(struct mptcp_sock *msk)
{
struct mptcp_pm_add_entry *entry, *tmp;
struct mptcp_pm_addr_entry *entry, *tmp;
struct sock *sk = (struct sock *)msk;
LIST_HEAD(free_list);

Expand Down Expand Up @@ -1474,7 +1466,7 @@ int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info)
bool mptcp_remove_anno_list_by_saddr(struct mptcp_sock *msk,
const struct mptcp_addr_info *addr)
{
struct mptcp_pm_add_entry *entry;
struct mptcp_pm_addr_entry *entry;

entry = mptcp_pm_del_add_timer(msk, addr, false);
if (entry) {
Expand Down
20 changes: 15 additions & 5 deletions net/mptcp/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,19 @@ struct mptcp_pm_data {
struct mptcp_pm_addr_entry {
struct list_head list;
struct mptcp_addr_info addr;
u8 flags;
int ifindex;
struct socket *lsk;
union {
struct {
u8 flags;
int ifindex;
struct socket *lsk;
};
/* mptcp_pm_add_entry */
struct {
u8 retrans_times;
struct timer_list add_timer;
struct mptcp_sock *sock;
};
};
};

struct mptcp_data_frag {
Expand Down Expand Up @@ -1019,10 +1029,10 @@ bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk,
const struct mptcp_addr_info *addr);
void mptcp_pm_free_anno_list(struct mptcp_sock *msk);
bool mptcp_pm_sport_in_anno_list(struct mptcp_sock *msk, const struct sock *sk);
struct mptcp_pm_add_entry *
struct mptcp_pm_addr_entry *
mptcp_pm_del_add_timer(struct mptcp_sock *msk,
const struct mptcp_addr_info *addr, bool check_id);
struct mptcp_pm_add_entry *
struct mptcp_pm_addr_entry *
mptcp_lookup_anno_list_by_saddr(const struct mptcp_sock *msk,
const struct mptcp_addr_info *addr);
bool mptcp_lookup_subflow_by_saddr(const struct list_head *list,
Expand Down

0 comments on commit 25cd49d

Please sign in to comment.