diff mbox

teamd: add port_hwaddr_changed for lb runner

Message ID 00a6c3541d47256a3c5fd58d12f395b4eedc26fc.1510029191.git.lucien.xin@gmail.com (mailing list archive)
State Accepted
Headers show

Commit Message

Xin Long Nov. 7, 2017, 4:33 a.m. UTC
To fix the same issue fixed in commit efaa6ae709bb ("teamd: add
port_hwaddr_changed for ab runner") for lb runner, this patch is
to add .port_hwaddr_changed for lb runner as well.

Signed-off-by: Xin Long <lucien.xin@gmail.com>

---
 teamd/teamd_runner_loadbalance.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

-- 
2.1.0

Comments

Jiri Pirko Nov. 7, 2017, 6:29 a.m. UTC | #1
Tue, Nov 07, 2017 at 05:33:11AM CET, lucien.xin@gmail.com wrote:
>To fix the same issue fixed in commit efaa6ae709bb ("teamd: add

>port_hwaddr_changed for ab runner") for lb runner, this patch is

>to add .port_hwaddr_changed for lb runner as well.

>

>Signed-off-by: Xin Long <lucien.xin@gmail.com>


Applied. Thanks
diff mbox

Patch

diff --git a/teamd/teamd_runner_loadbalance.c b/teamd/teamd_runner_loadbalance.c
index a1e2130..b9bfc13 100644
--- a/teamd/teamd_runner_loadbalance.c
+++ b/teamd/teamd_runner_loadbalance.c
@@ -87,8 +87,31 @@  static int lb_event_watch_hwaddr_changed(struct teamd_context *ctx, void *priv)
 	return 0;
 }
 
+static int lb_event_watch_port_hwaddr_changed(struct teamd_context *ctx,
+					      struct teamd_port *tdport,
+					      void *priv)
+{
+	int err;
+
+	if (!teamd_port_present(ctx, tdport))
+		return 0;
+
+	if (!memcmp(team_get_ifinfo_hwaddr(tdport->team_ifinfo),
+		    ctx->hwaddr, ctx->hwaddr_len))
+		return 0;
+
+	err = team_hwaddr_set(ctx->th, tdport->ifindex, ctx->hwaddr,
+			      ctx->hwaddr_len);
+	if (err)
+		teamd_log_err("%s: Failed to set port hardware address.",
+			      tdport->ifname);
+
+	return err;
+}
+
 static const struct teamd_event_watch_ops lb_port_watch_ops = {
 	.hwaddr_changed = lb_event_watch_hwaddr_changed,
+	.port_hwaddr_changed = lb_event_watch_port_hwaddr_changed,
 	.port_added = lb_event_watch_port_added,
 	.port_removed = lb_event_watch_port_removed,
 	.port_link_changed = lb_event_watch_port_link_changed,