Skip to content

Commit c7d18f1

Browse files
pavel-shirshovlguohan
authored andcommitted
[teamd]: Fix teamd patch issues, which prevented system WR (#2321)
- What I did Fixed vanilla teamd bug, which prevented teamd to have a correct view of kernel state. Check bug #2 from the message Changed schema for LACP port id. Changed severity of an error message. Removed logic to disable warm_start_read mode, when teamd started. It didn't work in system restart mode, because interfaces were added one by one, and it's impossible to say when everything is added. - How I did it I've added team_refresh() on every port addition I extract port id from the port name. Currently I support only "EthernetX" scheme. We need to add more schemes if we change port scheme. _err -> _info ... - How to verify it Build the image, install on your DUT, reboot it once, then reboot it on WR mode checking LACP state on remote side. The state shouldn't flip.
1 parent 2590aed commit c7d18f1

File tree

1 file changed

+53
-23
lines changed

1 file changed

+53
-23
lines changed

src/libteam/0005-libteam-Add-warm_reboot-mode.patch

+53-23
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ index 5c2ef56..50e5a08 100644
192192
struct teamd_port *tdport)
193193
{
194194
diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c
195-
index 81324de..2a453bd 100644
195+
index 81324de..9e88ce0 100644
196196
--- a/teamd/teamd_runner_lacp.c
197197
+++ b/teamd/teamd_runner_lacp.c
198198
@@ -31,6 +31,7 @@
@@ -251,7 +251,35 @@ index 81324de..2a453bd 100644
251251
return lacp_set_carrier(lacp, false);
252252
}
253253

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,
255283
break;
256284
}
257285

@@ -265,7 +293,7 @@ index 81324de..2a453bd 100644
265293
teamd_log_info("%s: Changed port state: \"%s\" -> \"%s\"",
266294
lacp_port->tdport->ifname,
267295
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)
269297
return err;
270298
}
271299

@@ -300,7 +328,7 @@ index 81324de..2a453bd 100644
300328
err = lacp_port_partner_update(lacp_port);
301329
if (err)
302330
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)
304332

305333
/* Check if the other side has correct info about us */
306334
if (!lacp_port->periodic_on &&
@@ -309,7 +337,7 @@ index 81324de..2a453bd 100644
309337
sizeof(struct lacpdu_info))) {
310338
err = lacpdu_send(lacp_port);
311339
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)
313341
return 0;
314342
}
315343

@@ -334,22 +362,10 @@ index 81324de..2a453bd 100644
334362
+ struct lacpdu lacpdu;
335363
+ int err, nitems;
336364
+ struct teamd_port *tdport;
337-
+ bool all_port_read = true;
338365
+
339366
+ /* we read saved lacpdu for the current lacp_port */
340367
+ lacp_port->lacpdu_read = true;
341368
+
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-
+
353369
+ strcpy(filename, lacp_port->ctx->lacp_directory);
354370
+ if (filename[strlen(filename) - 1] != '/')
355371
+ strcat(filename, "/"); /* Add trailing slash if we don't have one in the filename */
@@ -379,15 +395,29 @@ index 81324de..2a453bd 100644
379395
+ return err;
380396
+ }
381397
+
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);
383399
+
384400
+ return lacpdu_process(lacp_port, &lacpdu);
385401
+}
386402
+
387403
static int lacp_callback_timeout(struct teamd_context *ctx, int events,
388404
void *priv)
389405
{
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,
391421
lacp_port_actor_init(lacp_port);
392422
lacp_port_link_update(lacp_port);
393423

@@ -401,7 +431,7 @@ index 81324de..2a453bd 100644
401431
teamd_loop_callback_enable(ctx, LACP_SOCKET_CB_NAME, lacp_port);
402432
return 0;
403433

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,
405435
{
406436
struct lacp_port *lacp_port = priv;
407437

@@ -414,7 +444,7 @@ index 81324de..2a453bd 100644
414444
teamd_loop_callback_del(ctx, LACP_TIMEOUT_CB_NAME, lacp_port);
415445
teamd_loop_callback_del(ctx, LACP_PERIODIC_CB_NAME, lacp_port);
416446
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
418448
(void) lacpdu_send(lacp_port);
419449
}
420450

@@ -446,7 +476,7 @@ index 81324de..2a453bd 100644
446476
static const struct teamd_event_watch_ops lacp_event_watch_ops = {
447477
.hwaddr_changed = lacp_event_watch_hwaddr_changed,
448478
.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 = {
450480
.port_changed = lacp_event_watch_port_changed,
451481
.admin_state_changed = lacp_event_watch_admin_state_changed,
452482
.refresh = lacp_event_watch_refresh,
@@ -492,7 +522,7 @@ index 81324de..2a453bd 100644
492522
return 0;
493523
}
494524

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)
496526
teamd_state_val_unregister(ctx, &lacp_state_vg, lacp);
497527
teamd_balancer_fini(lacp->tb);
498528
teamd_event_watch_unregister(ctx, &lacp_event_watch_ops, lacp);

0 commit comments

Comments
 (0)