@@ -225,7 +225,7 @@ static inline int __check_agg_selection_timer(struct port *port)
225
225
if (bond == NULL )
226
226
return 0 ;
227
227
228
- return BOND_AD_INFO (bond ).agg_select_timer ? 1 : 0 ;
228
+ return atomic_read ( & BOND_AD_INFO (bond ).agg_select_timer ) ? 1 : 0 ;
229
229
}
230
230
231
231
/**
@@ -1995,7 +1995,7 @@ static void ad_marker_response_received(struct bond_marker *marker,
1995
1995
*/
1996
1996
void bond_3ad_initiate_agg_selection (struct bonding * bond , int timeout )
1997
1997
{
1998
- BOND_AD_INFO (bond ).agg_select_timer = timeout ;
1998
+ atomic_set ( & BOND_AD_INFO (bond ).agg_select_timer , timeout ) ;
1999
1999
}
2000
2000
2001
2001
/**
@@ -2278,6 +2278,28 @@ void bond_3ad_update_ad_actor_settings(struct bonding *bond)
2278
2278
spin_unlock_bh (& bond -> mode_lock );
2279
2279
}
2280
2280
2281
+ /**
2282
+ * bond_agg_timer_advance - advance agg_select_timer
2283
+ * @bond: bonding structure
2284
+ *
2285
+ * Return true when agg_select_timer reaches 0.
2286
+ */
2287
+ static bool bond_agg_timer_advance (struct bonding * bond )
2288
+ {
2289
+ int val , nval ;
2290
+
2291
+ while (1 ) {
2292
+ val = atomic_read (& BOND_AD_INFO (bond ).agg_select_timer );
2293
+ if (!val )
2294
+ return false;
2295
+ nval = val - 1 ;
2296
+ if (atomic_cmpxchg (& BOND_AD_INFO (bond ).agg_select_timer ,
2297
+ val , nval ) == val )
2298
+ break ;
2299
+ }
2300
+ return nval == 0 ;
2301
+ }
2302
+
2281
2303
/**
2282
2304
* bond_3ad_state_machine_handler - handle state machines timeout
2283
2305
* @work: work context to fetch bonding struct to work on from
@@ -2313,9 +2335,7 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
2313
2335
if (!bond_has_slaves (bond ))
2314
2336
goto re_arm ;
2315
2337
2316
- /* check if agg_select_timer timer after initialize is timed out */
2317
- if (BOND_AD_INFO (bond ).agg_select_timer &&
2318
- !(-- BOND_AD_INFO (bond ).agg_select_timer )) {
2338
+ if (bond_agg_timer_advance (bond )) {
2319
2339
slave = bond_first_slave_rcu (bond );
2320
2340
port = slave ? & (SLAVE_AD_INFO (slave )-> port ) : NULL ;
2321
2341
0 commit comments