@@ -192,7 +192,7 @@ index 5c2ef56..50e5a08 100644
192
192
struct teamd_port *tdport)
193
193
{
194
194
diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c
195
- index 81324de..2a453bd 100644
195
+ index 81324de..9e88ce0 100644
196
196
--- a/teamd/teamd_runner_lacp.c
197
197
+++ b/teamd/teamd_runner_lacp.c
198
198
@@ -31,6 +31,7 @@
@@ -251,7 +251,35 @@ index 81324de..2a453bd 100644
251
251
return lacp_set_carrier(lacp, false);
252
252
}
253
253
254
- @@ -994,6 +1012,13 @@ static int lacp_port_set_state(struct lacp_port *lacp_port,
254
+ @@ -917,6 +935,18 @@ static void lacp_port_actor_system_update(struct lacp_port *lacp_port)
255
+ memcpy(actor->system, lacp_port->ctx->hwaddr, ETH_ALEN);
256
+ }
257
+
258
+ + static int lacp_portname_to_port_id(const char* name)
259
+ + {
260
+ + #define PORT_PREFIX "Ethernet"
261
+ + const char* strport_id = name + sizeof(PORT_PREFIX) - 1;
262
+ + const int port_id = atoi(strport_id);
263
+ + if ((port_id == 0) && strcmp(strport_id, "0")) {
264
+ + teamd_log_err("%s: Can't convert from port name to port id. Port id is equal to 0, but this is not expected", name);
265
+ + }
266
+ +
267
+ + return htons(port_id);
268
+ + }
269
+ +
270
+ static void lacp_port_actor_init(struct lacp_port *lacp_port)
271
+ {
272
+ struct lacpdu_info *actor = &lacp_port->actor;
273
+ @@ -924,7 +954,7 @@ static void lacp_port_actor_init(struct lacp_port *lacp_port)
274
+ actor->system_priority = htons(lacp_port->lacp->cfg.sys_prio);
275
+ actor->key = htons(lacp_port->cfg.lacp_key);
276
+ actor->port_priority = htons(lacp_port->cfg.lacp_prio);
277
+ - actor->port = htons(lacp_port->tdport->ifindex);
278
+ + actor->port = lacp_portname_to_port_id(lacp_port->tdport->ifname);
279
+ lacp_port_actor_system_update(lacp_port);
280
+ }
281
+
282
+ @@ -994,6 +1024,13 @@ static int lacp_port_set_state(struct lacp_port *lacp_port,
255
283
break;
256
284
}
257
285
@@ -265,7 +293,7 @@ index 81324de..2a453bd 100644
265
293
teamd_log_info("%s: Changed port state: \"%s\" -> \"%s\"",
266
294
lacp_port->tdport->ifname,
267
295
lacp_port_state_name[lacp_port->state],
268
- @@ -1084,26 +1109 ,23 @@ static int lacpdu_send(struct lacp_port *lacp_port)
296
+ @@ -1084,26 +1121 ,23 @@ static int lacpdu_send(struct lacp_port *lacp_port)
269
297
return err;
270
298
}
271
299
@@ -300,7 +328,7 @@ index 81324de..2a453bd 100644
300
328
err = lacp_port_partner_update(lacp_port);
301
329
if (err)
302
330
return err;
303
- @@ -1118,7 +1140 ,7 @@ static int lacpdu_recv(struct lacp_port *lacp_port)
331
+ @@ -1118,7 +1152 ,7 @@ static int lacpdu_recv(struct lacp_port *lacp_port)
304
332
305
333
/* Check if the other side has correct info about us */
306
334
if (!lacp_port->periodic_on &&
@@ -309,7 +337,7 @@ index 81324de..2a453bd 100644
309
337
sizeof(struct lacpdu_info))) {
310
338
err = lacpdu_send(lacp_port);
311
339
if (err)
312
- @@ -1133,6 +1155,77 @@ static int lacpdu_recv(struct lacp_port *lacp_port)
340
+ @@ -1133,6 +1167,65 @@ static int lacpdu_recv(struct lacp_port *lacp_port)
313
341
return 0;
314
342
}
315
343
@@ -334,22 +362,10 @@ index 81324de..2a453bd 100644
334
362
+ struct lacpdu lacpdu;
335
363
+ int err, nitems;
336
364
+ struct teamd_port *tdport;
337
- + bool all_port_read = true;
338
365
+
339
366
+ /* we read saved lacpdu for the current lacp_port */
340
367
+ lacp_port->lacpdu_read = true;
341
368
+
342
- + /* go through all current ports, if the lacp state were read
343
- + for all of them, disable warm_start_read mode */
344
- + teamd_for_each_tdport(tdport, lacp_port->ctx) {
345
- + struct lacp_port *it;
346
- + it = lacp_port_get(lacp_port->lacp, tdport);
347
- + all_port_read = all_port_read && it->lacpdu_read;
348
- + }
349
- +
350
- + if (all_port_read) /* we read lacp state for all ports */
351
- + lacp_port->ctx->warm_start_read = false;
352
- +
353
369
+ strcpy(filename, lacp_port->ctx->lacp_directory);
354
370
+ if (filename[strlen(filename) - 1] != '/')
355
371
+ strcat(filename, "/"); /* Add trailing slash if we don't have one in the filename */
@@ -379,15 +395,29 @@ index 81324de..2a453bd 100644
379
395
+ return err;
380
396
+ }
381
397
+
382
- + teamd_log_err ("%s: LACP state was read", lacp_port->tdport->ifname);
398
+ + teamd_log_info ("%s: LACP state was read", lacp_port->tdport->ifname);
383
399
+
384
400
+ return lacpdu_process(lacp_port, &lacpdu);
385
401
+ }
386
402
+
387
403
static int lacp_callback_timeout(struct teamd_context *ctx, int events,
388
404
void *priv)
389
405
{
390
- @@ -1299,6 +1392,13 @@ static int lacp_port_added(struct teamd_context *ctx,
406
+ @@ -1284,6 +1377,13 @@ static int lacp_port_added(struct teamd_context *ctx,
407
+ goto periodic_callback_del;
408
+ }
409
+
410
+ + /* refresh ports from the kernel */
411
+ + err = team_refresh(ctx->th);
412
+ + if (err) {
413
+ + teamd_log_err("%s: Team refresh failed.", tdport->ifname);
414
+ + goto timeout_callback_del;
415
+ + }
416
+ +
417
+ /* Newly added ports are disabled */
418
+ err = team_set_port_enabled(ctx->th, tdport->ifindex, false);
419
+ if (err) {
420
+ @@ -1299,6 +1399,13 @@ static int lacp_port_added(struct teamd_context *ctx,
391
421
lacp_port_actor_init(lacp_port);
392
422
lacp_port_link_update(lacp_port);
393
423
@@ -401,7 +431,7 @@ index 81324de..2a453bd 100644
401
431
teamd_loop_callback_enable(ctx, LACP_SOCKET_CB_NAME, lacp_port);
402
432
return 0;
403
433
404
- @@ -1321,7 +1421 ,11 @@ static void lacp_port_removed(struct teamd_context *ctx,
434
+ @@ -1321,7 +1428 ,11 @@ static void lacp_port_removed(struct teamd_context *ctx,
405
435
{
406
436
struct lacp_port *lacp_port = priv;
407
437
@@ -414,7 +444,7 @@ index 81324de..2a453bd 100644
414
444
teamd_loop_callback_del(ctx, LACP_TIMEOUT_CB_NAME, lacp_port);
415
445
teamd_loop_callback_del(ctx, LACP_PERIODIC_CB_NAME, lacp_port);
416
446
teamd_loop_callback_del(ctx, LACP_SOCKET_CB_NAME, lacp_port);
417
- @@ -1413,6 +1517 ,31 @@ static void lacp_event_watch_refresh(struct teamd_context *ctx, struct teamd_por
447
+ @@ -1413,6 +1524 ,31 @@ static void lacp_event_watch_refresh(struct teamd_context *ctx, struct teamd_por
418
448
(void) lacpdu_send(lacp_port);
419
449
}
420
450
@@ -446,7 +476,7 @@ index 81324de..2a453bd 100644
446
476
static const struct teamd_event_watch_ops lacp_event_watch_ops = {
447
477
.hwaddr_changed = lacp_event_watch_hwaddr_changed,
448
478
.port_added = lacp_event_watch_port_added,
449
- @@ -1420,21 +1549 ,38 @@ static const struct teamd_event_watch_ops lacp_event_watch_ops = {
479
+ @@ -1420,21 +1556 ,38 @@ static const struct teamd_event_watch_ops lacp_event_watch_ops = {
450
480
.port_changed = lacp_event_watch_port_changed,
451
481
.admin_state_changed = lacp_event_watch_admin_state_changed,
452
482
.refresh = lacp_event_watch_refresh,
@@ -492,7 +522,7 @@ index 81324de..2a453bd 100644
492
522
return 0;
493
523
}
494
524
495
- @@ -1946,7 +2092 ,7 @@ static void lacp_fini(struct teamd_context *ctx, void *priv)
525
+ @@ -1946,7 +2099 ,7 @@ static void lacp_fini(struct teamd_context *ctx, void *priv)
496
526
teamd_state_val_unregister(ctx, &lacp_state_vg, lacp);
497
527
teamd_balancer_fini(lacp->tb);
498
528
teamd_event_watch_unregister(ctx, &lacp_event_watch_ops, lacp);
0 commit comments