@@ -143,11 +143,13 @@ static bool lookup_subflow_by_daddr(const struct list_head *list,
143
143
return false;
144
144
}
145
145
146
- static struct mptcp_pm_addr_entry *
146
+ static bool
147
147
select_local_address (const struct pm_nl_pernet * pernet ,
148
- const struct mptcp_sock * msk )
148
+ const struct mptcp_sock * msk ,
149
+ struct mptcp_pm_addr_entry * new_entry )
149
150
{
150
- struct mptcp_pm_addr_entry * entry , * ret = NULL ;
151
+ struct mptcp_pm_addr_entry * entry ;
152
+ bool found = false;
151
153
152
154
msk_owned_by_me (msk );
153
155
@@ -159,17 +161,21 @@ select_local_address(const struct pm_nl_pernet *pernet,
159
161
if (!test_bit (entry -> addr .id , msk -> pm .id_avail_bitmap ))
160
162
continue ;
161
163
162
- ret = entry ;
164
+ * new_entry = * entry ;
165
+ found = true;
163
166
break ;
164
167
}
165
168
rcu_read_unlock ();
166
- return ret ;
169
+
170
+ return found ;
167
171
}
168
172
169
- static struct mptcp_pm_addr_entry *
170
- select_signal_address (struct pm_nl_pernet * pernet , const struct mptcp_sock * msk )
173
+ static bool
174
+ select_signal_address (struct pm_nl_pernet * pernet , const struct mptcp_sock * msk ,
175
+ struct mptcp_pm_addr_entry * new_entry )
171
176
{
172
- struct mptcp_pm_addr_entry * entry , * ret = NULL ;
177
+ struct mptcp_pm_addr_entry * entry ;
178
+ bool found = false;
173
179
174
180
rcu_read_lock ();
175
181
/* do not keep any additional per socket state, just signal
@@ -184,11 +190,13 @@ select_signal_address(struct pm_nl_pernet *pernet, const struct mptcp_sock *msk)
184
190
if (!(entry -> flags & MPTCP_PM_ADDR_FLAG_SIGNAL ))
185
191
continue ;
186
192
187
- ret = entry ;
193
+ * new_entry = * entry ;
194
+ found = true;
188
195
break ;
189
196
}
190
197
rcu_read_unlock ();
191
- return ret ;
198
+
199
+ return found ;
192
200
}
193
201
194
202
unsigned int mptcp_pm_get_add_addr_signal_max (const struct mptcp_sock * msk )
@@ -512,9 +520,10 @@ __lookup_addr(struct pm_nl_pernet *pernet, const struct mptcp_addr_info *info)
512
520
513
521
static void mptcp_pm_create_subflow_or_signal_addr (struct mptcp_sock * msk )
514
522
{
515
- struct mptcp_pm_addr_entry * local , * signal_and_subflow = NULL ;
516
523
struct sock * sk = (struct sock * )msk ;
524
+ struct mptcp_pm_addr_entry local ;
517
525
unsigned int add_addr_signal_max ;
526
+ bool signal_and_subflow = false;
518
527
unsigned int local_addr_max ;
519
528
struct pm_nl_pernet * pernet ;
520
529
unsigned int subflows_max ;
@@ -565,23 +574,22 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
565
574
if (msk -> pm .addr_signal & BIT (MPTCP_ADD_ADDR_SIGNAL ))
566
575
return ;
567
576
568
- local = select_signal_address (pernet , msk );
569
- if (!local )
577
+ if (!select_signal_address (pernet , msk , & local ))
570
578
goto subflow ;
571
579
572
580
/* If the alloc fails, we are on memory pressure, not worth
573
581
* continuing, and trying to create subflows.
574
582
*/
575
- if (!mptcp_pm_alloc_anno_list (msk , & local -> addr ))
583
+ if (!mptcp_pm_alloc_anno_list (msk , & local . addr ))
576
584
return ;
577
585
578
- __clear_bit (local -> addr .id , msk -> pm .id_avail_bitmap );
586
+ __clear_bit (local . addr .id , msk -> pm .id_avail_bitmap );
579
587
msk -> pm .add_addr_signaled ++ ;
580
- mptcp_pm_announce_addr (msk , & local -> addr , false);
588
+ mptcp_pm_announce_addr (msk , & local . addr , false);
581
589
mptcp_pm_nl_addr_send_ack (msk );
582
590
583
- if (local -> flags & MPTCP_PM_ADDR_FLAG_SUBFLOW )
584
- signal_and_subflow = local ;
591
+ if (local . flags & MPTCP_PM_ADDR_FLAG_SUBFLOW )
592
+ signal_and_subflow = true ;
585
593
}
586
594
587
595
subflow :
@@ -592,26 +600,22 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
592
600
bool fullmesh ;
593
601
int i , nr ;
594
602
595
- if (signal_and_subflow ) {
596
- local = signal_and_subflow ;
597
- signal_and_subflow = NULL ;
598
- } else {
599
- local = select_local_address (pernet , msk );
600
- if (!local )
601
- break ;
602
- }
603
+ if (signal_and_subflow )
604
+ signal_and_subflow = false;
605
+ else if (!select_local_address (pernet , msk , & local ))
606
+ break ;
603
607
604
- fullmesh = !!(local -> flags & MPTCP_PM_ADDR_FLAG_FULLMESH );
608
+ fullmesh = !!(local . flags & MPTCP_PM_ADDR_FLAG_FULLMESH );
605
609
606
610
msk -> pm .local_addr_used ++ ;
607
- __clear_bit (local -> addr .id , msk -> pm .id_avail_bitmap );
608
- nr = fill_remote_addresses_vec (msk , & local -> addr , fullmesh , addrs );
611
+ __clear_bit (local . addr .id , msk -> pm .id_avail_bitmap );
612
+ nr = fill_remote_addresses_vec (msk , & local . addr , fullmesh , addrs );
609
613
if (nr == 0 )
610
614
continue ;
611
615
612
616
spin_unlock_bh (& msk -> pm .lock );
613
617
for (i = 0 ; i < nr ; i ++ )
614
- __mptcp_subflow_connect (sk , & local -> addr , & addrs [i ]);
618
+ __mptcp_subflow_connect (sk , & local . addr , & addrs [i ]);
615
619
spin_lock_bh (& msk -> pm .lock );
616
620
}
617
621
mptcp_pm_nl_check_work_pending (msk );
0 commit comments