Skip to content

Commit c60278d

Browse files
[libteam]: Add Fast-Reboot mode for teamd (#3490)
* [libteam]: add special Fast-Reboot teamd stop mode * Fix last packet sending * Update sonic-utilities module
1 parent dd4a50d commit c60278d

File tree

2 files changed

+36
-21
lines changed

2 files changed

+36
-21
lines changed

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

+35-20
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
From a21a3dec9f9b9d825a0229e2963e07862395bbba Mon Sep 17 00:00:00 2001
1+
From 5d418847bf6fa86f049e18c1b57028c71e40a9c4 Mon Sep 17 00:00:00 2001
22
From: Pavel Shirshov <[email protected]>
3-
Date: Fri, 14 Jun 2019 14:20:05 -0700
4-
Subject: [PATCH] [libteam]: Reimplement Warm-Reboot procedure
3+
Date: Thu, 19 Sep 2019 14:49:17 -0700
4+
Subject: [PATCH 1/1] [libteam]: Reimplement Warm-Reboot procedure
55

66
---
77
libteam/ifinfo.c | 6 +-
8-
teamd/teamd.c | 42 +++-
8+
teamd/teamd.c | 57 ++++-
99
teamd/teamd.h | 6 +
1010
teamd/teamd_events.c | 13 ++
1111
teamd/teamd_runner_lacp.c | 474 +++++++++++++++++++++++++++++++++++---
12-
5 files changed, 498 insertions(+), 43 deletions(-)
12+
5 files changed, 509 insertions(+), 47 deletions(-)
1313

1414
diff --git a/libteam/ifinfo.c b/libteam/ifinfo.c
15-
index 46d56a2..b86d34c 100644
15+
index a15788b..e48193e 100644
1616
--- a/libteam/ifinfo.c
1717
+++ b/libteam/ifinfo.c
1818
@@ -109,15 +109,13 @@ static void update_hwaddr(struct team_ifinfo *ifinfo, struct rtnl_link *link)
@@ -34,7 +34,7 @@ index 46d56a2..b86d34c 100644
3434
}
3535
}
3636
diff --git a/teamd/teamd.c b/teamd/teamd.c
37-
index 9dc85b5..96794e8 100644
37+
index 9dc85b5..679da49 100644
3838
--- a/teamd/teamd.c
3939
+++ b/teamd/teamd.c
4040
@@ -117,7 +117,9 @@ static void print_help(const struct teamd_context *ctx) {
@@ -90,51 +90,66 @@ index 9dc85b5..96794e8 100644
9090
if (optind < argc) {
9191
fprintf(stderr, "Too many arguments\n");
9292
return -1;
93-
@@ -390,8 +410,14 @@ static int teamd_run_loop_run(struct teamd_context *ctx)
93+
@@ -390,12 +410,21 @@ static int teamd_run_loop_run(struct teamd_context *ctx)
9494
if (err != -1) {
9595
switch(ctrl_byte) {
9696
case 'q':
97+
+ case 'f':
9798
+ case 'w':
9899
if (quit_in_progress)
99100
return -EBUSY;
100-
+ if (ctrl_byte == 'w') {
101+
- teamd_refresh_ports(ctx);
102+
- err = teamd_flush_ports(ctx);
103+
- if (err)
104+
- return err;
105+
+ if (ctrl_byte == 'w' || ctrl_byte == 'f') {
101106
+ ctx->keep_ports = true;
102107
+ ctx->no_quit_destroy = true;
103-
+ teamd_ports_flush_data(ctx);
108+
+ teamd_refresh_ports(ctx);
109+
+ if (ctrl_byte == 'w')
110+
+ teamd_ports_flush_data(ctx);
111+
+ } else {
112+
+ err = teamd_flush_ports(ctx);
113+
+ if (err)
114+
+ return err;
104115
+ }
105-
teamd_refresh_ports(ctx);
106-
err = teamd_flush_ports(ctx);
107-
if (err)
108-
@@ -434,6 +460,12 @@ void teamd_run_loop_quit(struct teamd_context *ctx, int err)
116+
quit_in_progress = true;
117+
continue;
118+
case 'r':
119+
@@ -434,6 +463,12 @@ void teamd_run_loop_quit(struct teamd_context *ctx, int err)
109120
teamd_run_loop_sent_ctrl_byte(ctx, 'q');
110121
}
111122

112-
+static void teamd_run_loop_quit_w_boot(struct teamd_context *ctx, int err)
123+
+static void teamd_run_loop_quit_a_boot(struct teamd_context *ctx, char type, int err)
113124
+{
114125
+ ctx->run_loop.err = err;
115-
+ teamd_run_loop_sent_ctrl_byte(ctx, 'w');
126+
+ teamd_run_loop_sent_ctrl_byte(ctx, type);
116127
+}
117128
+
118129
void teamd_run_loop_restart(struct teamd_context *ctx)
119130
{
120131
teamd_run_loop_sent_ctrl_byte(ctx, 'r');
121-
@@ -700,6 +732,10 @@ static int callback_daemon_signal(struct teamd_context *ctx, int events,
132+
@@ -700,6 +735,14 @@ static int callback_daemon_signal(struct teamd_context *ctx, int events,
122133
teamd_log_warn("Got SIGINT, SIGQUIT or SIGTERM.");
123134
teamd_run_loop_quit(ctx, 0);
124135
break;
125136
+ case SIGUSR1:
126137
+ teamd_log_warn("Got SIGUSR1.");
127-
+ teamd_run_loop_quit_w_boot(ctx, 0);
138+
+ teamd_run_loop_quit_a_boot(ctx, 'w', 0);
139+
+ break;
140+
+ case SIGUSR2:
141+
+ teamd_log_warn("Got SIGUSR2.");
142+
+ teamd_run_loop_quit_a_boot(ctx, 'f', 0);
128143
+ break;
129144
}
130145
return 0;
131146
}
132-
@@ -1531,7 +1567,7 @@ static int teamd_start(struct teamd_context *ctx, enum teamd_exit_code *p_ret)
147+
@@ -1531,7 +1574,7 @@ static int teamd_start(struct teamd_context *ctx, enum teamd_exit_code *p_ret)
133148
return -errno;
134149
}
135150

136151
- if (daemon_signal_init(SIGINT, SIGTERM, SIGQUIT, SIGHUP, 0) < 0) {
137-
+ if (daemon_signal_init(SIGINT, SIGTERM, SIGQUIT, SIGHUP, SIGUSR1, 0) < 0) {
152+
+ if (daemon_signal_init(SIGINT, SIGTERM, SIGQUIT, SIGHUP, SIGUSR1, SIGUSR2, 0) < 0) {
138153
teamd_log_err("Could not register signal handlers.");
139154
daemon_retval_send(errno);
140155
err = -errno;

src/sonic-utilities

0 commit comments

Comments
 (0)