[libteam] Upgrade libteam to 1.28-1 and reorganize patches (#2956)

Signed-off-by: yorke <yorke.yuan@asterfusion.com>
This commit is contained in:
yorke 2019-06-05 03:55:26 +08:00 committed by pavel-shirshov
parent 552684fc08
commit 6dbae0e3cd
18 changed files with 236 additions and 631 deletions

View File

@ -1,6 +1,6 @@
# libteam packages # libteam packages
LIBTEAM_VERSION = 1.26-1 LIBTEAM_VERSION = 1.28-1
export LIBTEAM_VERSION export LIBTEAM_VERSION

View File

@ -1,59 +0,0 @@
From 2f9248dd07d51361bc0a93ef70d0f8ac2631af35 Mon Sep 17 00:00:00 2001
From: Shuotian Cheng <shuche@microsoft.com>
Date: Fri, 20 Jan 2017 12:10:13 -0800
Subject: [PATCH] libteam: Add team_get_port_enabled function
---
include/team.h | 2 ++
libteam/libteam.c | 22 ++++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/include/team.h b/include/team.h
index 20ebcf6..9ae517d 100644
--- a/include/team.h
+++ b/include/team.h
@@ -68,6 +68,8 @@ int team_get_bpf_hash_func(struct team_handle *th, struct sock_fprog *fp);
int team_set_bpf_hash_func(struct team_handle *th, const struct sock_fprog *fp);
int team_set_port_enabled(struct team_handle *th,
uint32_t port_ifindex, bool val);
+int team_get_port_enabled(struct team_handle *th,
+ uint32_t port_ifindex, bool *enabled);
int team_set_port_user_linkup_enabled(struct team_handle *th,
uint32_t port_ifindex, bool val);
int team_get_port_user_linkup(struct team_handle *th,
diff --git a/libteam/libteam.c b/libteam/libteam.c
index ac187aa..106e5cf 100644
--- a/libteam/libteam.c
+++ b/libteam/libteam.c
@@ -1295,6 +1295,28 @@ int team_set_port_enabled(struct team_handle *th,
/**
* @param th libteam library context
* @param port_ifindex port interface index
+ * @param enabled where the enabled state will be stored
+ *
+ * @details Gets enabled state for port identified by port_ifindex
+ *
+ * @return Zero on success or negative number in case of an error.
+ **/
+TEAM_EXPORT
+int team_get_port_enabled(struct team_handle *th,
+ uint32_t port_ifindex, bool *enabled)
+{
+ struct team_option *option;
+
+ option = team_get_option(th, "np", "enabled", port_ifindex);
+ if (!option)
+ return -ENOENT;
+ *enabled = team_get_option_value_bool(option);
+ return 0;
+}
+
+/**
+ * @param th libteam library context
+ * @param port_ifindex port interface index
* @param val boolean value
*
* @details Enables or disable user linkup for port identified by port_ifindex
--
2.1.4

View File

@ -1,36 +0,0 @@
From 43e512b114176feb1828ff0a75f0224f2b219a2d Mon Sep 17 00:00:00 2001
From: Jipan Yang <jipan.yang@alibaba-inc.com>
Date: Sun, 24 Feb 2019 00:04:15 -0800
Subject: [PATCH] Skip setting the same hwaddr to lag port to avoid disrupting
neighbor entries
Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>
---
teamd/teamd.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/teamd/teamd.c b/teamd/teamd.c
index 225b8c8..e28aa7d 100644
--- a/teamd/teamd.c
+++ b/teamd/teamd.c
@@ -866,7 +866,16 @@ static int teamd_set_hwaddr(struct teamd_context *ctx)
err = -EINVAL;
goto free_hwaddr;
}
- err = team_hwaddr_set(ctx->th, ctx->ifindex, hwaddr, hwaddr_len);
+
+ if(!memcmp(hwaddr, ctx->hwaddr, hwaddr_len))
+ {
+ err = 0;
+ teamd_log_dbg("Skip setting same hwaddr string: \"%s\".", hwaddr_str);
+ }
+ else
+ {
+ err = team_hwaddr_set(ctx->th, ctx->ifindex, hwaddr, hwaddr_len);
+ }
if (!err)
ctx->hwaddr_explicit = true;
free_hwaddr:
--
2.9.2

View File

@ -1,71 +0,0 @@
commit 15b56de0f309c942f0f3a588f40944d078db97f9
Author: Pavel Shirshov <pavelsh@microsoft.com>
Date: Tue Apr 16 12:18:12 2019 -0700
teamd: lacp: update port state according to partner's sync bit
Backport of
https://github.com/jpirko/libteam/commit/54f137c10579bf97800c61ebb13e732aa1d843e6#diff-f17610bfcc2bafe661a9f3ba496ebf12
According to 6.4.15 of IEEE 802.1AX-2014, Figure 6-22, the state that the
port is selected moves MUX state from DETACHED to ATTACHED.
But ATTACHED state does not mean that the port can send and receive user
frames. COLLECTING_DISTRIBUTION state is the state that the port can send
and receive user frames. To move MUX state from ATTACHED to
COLLECTING_DISTRIBUTION, the partner state should be sync as well as the
port selected.
In function lacp_port_actor_update(), only INFO_STATE_SYNCHRONIZATION
should be set to the actor.state when the port is selected.
INFO_STATE_COLLECTING and INFO_STATE_DISTRIBUTING should be set to false
with ATTACHED mode and set to true when INFO_STATE_SYNCHRONIZATION of
partner.state is set.
In function lacp_port_should_be_{enabled, disabled}(), we also need to
check the INFO_STATE_SYNCHRONIZATION bit of partner.state.
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c
index dae9086..5fa026a 100644
--- a/teamd/teamd_runner_lacp.c
+++ b/teamd/teamd_runner_lacp.c
@@ -361,7 +361,8 @@ static int lacp_port_should_be_enabled(struct lacp_port *lacp_port)
struct lacp *lacp = lacp_port->lacp;
if (lacp_port_selected(lacp_port) &&
- lacp_port->agg_lead == lacp->selected_agg_lead)
+ lacp_port->agg_lead == lacp->selected_agg_lead &&
+ lacp_port->partner.state & INFO_STATE_SYNCHRONIZATION)
return true;
return false;
}
@@ -371,7 +372,8 @@ static int lacp_port_should_be_disabled(struct lacp_port *lacp_port)
struct lacp *lacp = lacp_port->lacp;
if (!lacp_port_selected(lacp_port) ||
- lacp_port->agg_lead != lacp->selected_agg_lead)
+ lacp_port->agg_lead != lacp->selected_agg_lead ||
+ !(lacp_port->partner.state & INFO_STATE_SYNCHRONIZATION))
return true;
return false;
}
@@ -966,9 +968,14 @@ static void lacp_port_actor_update(struct lacp_port *lacp_port)
state |= INFO_STATE_LACP_ACTIVITY;
if (lacp_port->lacp->cfg.fast_rate)
state |= INFO_STATE_LACP_TIMEOUT;
- if (lacp_port_selected(lacp_port))
+ if (lacp_port_selected(lacp_port) &&
+ lacp_port_agg_selected(lacp_port)) {
state |= INFO_STATE_SYNCHRONIZATION;
- state |= INFO_STATE_COLLECTING | INFO_STATE_DISTRIBUTING;
+ state &= ~(INFO_STATE_COLLECTING | INFO_STATE_DISTRIBUTING);
+ if (lacp_port->partner.state & INFO_STATE_SYNCHRONIZATION)
+ state |= INFO_STATE_COLLECTING |
+ INFO_STATE_DISTRIBUTING;
+ }
if (lacp_port->state == PORT_STATE_EXPIRED)
state |= INFO_STATE_EXPIRED;
if (lacp_port->state == PORT_STATE_DEFAULTED)

View File

@ -1,302 +0,0 @@
commit 046fb6ba0aec8246075b18d787daec43201566fa
Author: Antti Tiainen <atiainen@forcepoint.com>
Date: Mon Feb 6 15:41:05 2017 +0200
libteam: resynchronize ifinfo after lost RTNLGRP_LINK notifications
When there's a large number of interfaces (e.g. vlans), teamd loses
link notifications as it cannot read them as fast as kernel is
broadcasting them. This often prevents teamd starting properly if
started concurrently when other links are being set up. It can also
fail when it's up and running, especially in the cases where the team
device itself has a lot of vlans under it.
This can easily be reproduces by simple example (in SMP system) by
manually adding team device with a bunch of vlans, putting it up,
and starting teamd with --take-over option:
root@debian:~# ip link add name team0 type team
root@debian:~# for i in `seq 100 150` ; do
> ip link add link team0 name team0.$i type vlan id $i ; done
root@debian:~# ip link set team0 up
root@debian:~# cat teamd.conf
{
"device": "team0",
"runner": {
"name": "activebackup"
},
"ports": {
"eth1": {},
"eth2": {}
}
}
root@debian:~# teamd -o -N -f teamd.conf
At this point, teamd will not give any error messages or other
indication that something is wrong. But state will not look healthy:
root@debian:~# teamdctl team0 state
setup:
runner: activebackup
ports:
eth1
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
Failed to parse JSON port dump.
command call failed (Invalid argument)
If checking state dump, it will show that port eth2 is missing info.
Running strace to teamd will reveal that there's one recvmsgs() that
returned -1 with errno ENOBUFS. What happened in this example was
that when teamd started, all vlans got carrier up, and kernel flooded
notifications faster than teamd could read them. It then lost events
related to port eth2 getting enslaved and up.
The socket that joins RTNLGRP_LINK notifications uses default libnl
32k buffer size. Netlink messages are large (over 1k), and this buffer
gets easily full. Kernel neither knows nor cares were notification
broadcasts delivered. This cannot be fixed by simply increasing the
buffer size, as there's no size that is guaranteed to work in every
use case, and this can require several megabytes of buffer (a way over
normal rmem_max limit) if there are hunderds of vlans.
Only way to recover from this is to refresh all ifinfo list, as it's
invalidated at this point. It cannot easily work around of this by
just refreshing team device and its ports, because library side might
not have ports linked due to events missed, and it doesn't know about
teamd configuration.
Checks now return value of nl_recvmsgs_default() for event socket. In
case of ENOBUFS (which libnl nicely changes to ENOMEM), refreshes
all ifinfo list. get_ifinfo_list() also checks now for removed interfaces
in case of missed dellink event. Currently all TEAM_IFINFO_CHANGE
handlers processed events one by one, so it had to be changed to support
multiple ifinfo changes. For this, ifinfo changed flags are cleared
and removed entries destroyed only after all handlers have been called.
Also, increased nl_cli.sock_event receive buffers to 96k like all other
sockets. Added possibility to change this via environment variable.
Signed-off-by: Antti Tiainen <atiainen@forcepoint.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
diff --git a/libteam/ifinfo.c b/libteam/ifinfo.c
index 72155ae..5c32a9c 100644
--- a/libteam/ifinfo.c
+++ b/libteam/ifinfo.c
@@ -72,6 +72,10 @@ struct team_ifinfo {
#define CHANGED_PHYS_PORT_ID (1 << 5)
#define CHANGED_PHYS_PORT_ID_LEN (1 << 6)
#define CHANGED_ADMIN_STATE (1 << 7)
+/* This is only used when tagging interfaces for finding
+ * removed, and thus not included to CHANGED_ANY.
+ */
+#define CHANGED_REFRESHING (1 << 8)
#define CHANGED_ANY (CHANGED_REMOVED | CHANGED_HWADDR | \
CHANGED_HWADDR_LEN | CHANGED_IFNAME | \
CHANGED_MASTER_IFINDEX | CHANGED_PHYS_PORT_ID | \
@@ -202,7 +206,7 @@ static struct team_ifinfo *ifinfo_find(struct team_handle *th, uint32_t ifindex)
return NULL;
}
-static void clear_last_changed(struct team_handle *th)
+void ifinfo_clear_changed(struct team_handle *th)
{
struct team_ifinfo *ifinfo;
@@ -236,7 +240,7 @@ static void ifinfo_destroy(struct team_ifinfo *ifinfo)
free(ifinfo);
}
-static void ifinfo_destroy_removed(struct team_handle *th)
+void ifinfo_destroy_removed(struct team_handle *th)
{
struct team_ifinfo *ifinfo, *tmp;
@@ -254,8 +258,6 @@ static void obj_input_newlink(struct nl_object *obj, void *arg, bool event)
uint32_t ifindex;
int err;
- ifinfo_destroy_removed(th);
-
link = (struct rtnl_link *) obj;
ifindex = rtnl_link_get_ifindex(link);
@@ -269,7 +271,7 @@ static void obj_input_newlink(struct nl_object *obj, void *arg, bool event)
return;
}
- clear_last_changed(th);
+ clear_changed(ifinfo);
ifinfo_update(ifinfo, link);
if (event)
@@ -292,8 +294,6 @@ static void event_handler_obj_input_dellink(struct nl_object *obj, void *arg)
uint32_t ifindex;
int err;
- ifinfo_destroy_removed(th);
-
link = (struct rtnl_link *) obj;
ifindex = rtnl_link_get_ifindex(link);
@@ -311,7 +311,7 @@ static void event_handler_obj_input_dellink(struct nl_object *obj, void *arg)
return;
}
- clear_last_changed(th);
+ clear_changed(ifinfo);
set_changed(ifinfo, CHANGED_REMOVED);
set_call_change_handlers(th, TEAM_IFINFO_CHANGE);
}
@@ -367,6 +367,14 @@ int get_ifinfo_list(struct team_handle *th)
};
int ret;
int retry = 1;
+ struct team_ifinfo *ifinfo;
+
+ /* Tag all ifinfo, this is cleared in newlink handler.
+ * Any interface that has this after dump is processed
+ * has been removed.
+ */
+ list_for_each_node_entry(ifinfo, &th->ifinfo_list, list)
+ set_changed(ifinfo, CHANGED_REFRESHING);
while (retry) {
retry = 0;
@@ -395,6 +403,15 @@ int get_ifinfo_list(struct team_handle *th)
retry = 1;
}
}
+
+ list_for_each_node_entry(ifinfo, &th->ifinfo_list, list) {
+ if (is_changed(ifinfo, CHANGED_REFRESHING)) {
+ clear_changed(ifinfo);
+ set_changed(ifinfo, CHANGED_REMOVED);
+ set_call_change_handlers(th, TEAM_IFINFO_CHANGE);
+ }
+ }
+
ret = check_call_change_handlers(th, TEAM_IFINFO_CHANGE);
if (ret < 0)
err(th, "get_ifinfo_list: check_call_change_handers failed");
diff --git a/libteam/libteam.c b/libteam/libteam.c
index ac187aa..d5f22cd 100644
--- a/libteam/libteam.c
+++ b/libteam/libteam.c
@@ -236,6 +236,10 @@ int check_call_change_handlers(struct team_handle *th,
break;
}
}
+ if (call_type_mask & TEAM_IFINFO_CHANGE) {
+ ifinfo_destroy_removed(th);
+ ifinfo_clear_changed(th);
+ }
th->change_handler.pending_type_mask &= ~call_type_mask;
return err;
}
@@ -546,6 +550,11 @@ int team_destroy(struct team_handle *th)
#endif
/* \endcond */
+/* libnl uses default 32k socket receive buffer size,
+ * whicn can get too small. Use 96k for all sockets.
+ */
+#define NETLINK_RCVBUF 983040
+
/**
* @param th libteam library context
* @param ifindex team device interface index
@@ -561,6 +570,8 @@ int team_init(struct team_handle *th, uint32_t ifindex)
int err;
int grp_id;
int val;
+ int eventbufsize;
+ const char *env;
if (!ifindex) {
err(th, "Passed interface index %d is not valid.", ifindex);
@@ -589,12 +600,12 @@ int team_init(struct team_handle *th, uint32_t ifindex)
return -errno;
}
- err = nl_socket_set_buffer_size(th->nl_sock, 98304, 0);
+ err = nl_socket_set_buffer_size(th->nl_sock, NETLINK_RCVBUF, 0);
if (err) {
err(th, "Failed to set buffer size of netlink sock.");
return -nl2syserr(err);
}
- err = nl_socket_set_buffer_size(th->nl_sock_event, 98304, 0);
+ err = nl_socket_set_buffer_size(th->nl_sock_event, NETLINK_RCVBUF, 0);
if (err) {
err(th, "Failed to set buffer size of netlink event sock.");
return -nl2syserr(err);
@@ -627,6 +638,25 @@ int team_init(struct team_handle *th, uint32_t ifindex)
nl_socket_modify_cb(th->nl_cli.sock_event, NL_CB_VALID,
NL_CB_CUSTOM, cli_event_handler, th);
nl_cli_connect(th->nl_cli.sock_event, NETLINK_ROUTE);
+
+ env = getenv("TEAM_EVENT_BUFSIZE");
+ if (env) {
+ eventbufsize = strtol(env, NULL, 10);
+ /* ignore other errors, libnl forces minimum 32k and
+ * too large values are truncated to system rmem_max
+ */
+ if (eventbufsize < 0)
+ eventbufsize = 0;
+ } else {
+ eventbufsize = NETLINK_RCVBUF;
+ }
+
+ err = nl_socket_set_buffer_size(th->nl_cli.sock_event, eventbufsize, 0);
+ if (err) {
+ err(th, "Failed to set cli event socket buffer size.");
+ return err;
+ }
+
err = nl_socket_add_membership(th->nl_cli.sock_event, RTNLGRP_LINK);
if (err < 0) {
err(th, "Failed to add netlink membership.");
@@ -767,7 +797,23 @@ static int get_cli_sock_event_fd(struct team_handle *th)
static int cli_sock_event_handler(struct team_handle *th)
{
- nl_recvmsgs_default(th->nl_cli.sock_event);
+ int err;
+
+ err = nl_recvmsgs_default(th->nl_cli.sock_event);
+ err = -nl2syserr(err);
+
+ /* libnl thinks ENOBUFS and ENOMEM are same. Hope it was ENOBUFS. */
+ if (err == -ENOMEM) {
+ warn(th, "Lost link notifications from kernel.");
+ /* There's no way to know what events were lost and no
+ * way to get them again. Refresh all.
+ */
+ err = get_ifinfo_list(th);
+ }
+
+ if (err)
+ return err;
+
return check_call_change_handlers(th, TEAM_IFINFO_CHANGE);
}
diff --git a/libteam/team_private.h b/libteam/team_private.h
index a07632f..a5eb0be 100644
--- a/libteam/team_private.h
+++ b/libteam/team_private.h
@@ -115,6 +115,9 @@ int ifinfo_link_with_port(struct team_handle *th, uint32_t ifindex,
int ifinfo_link(struct team_handle *th, uint32_t ifindex,
struct team_ifinfo **p_ifinfo);
void ifinfo_unlink(struct team_ifinfo *ifinfo);
+void ifinfo_clear_changed(struct team_handle *th);
+void ifinfo_destroy_removed(struct team_handle *th);
+int get_ifinfo_list(struct team_handle *th);
int get_options_handler(struct nl_msg *msg, void *arg);
int option_list_alloc(struct team_handle *th);
int option_list_init(struct team_handle *th);

View File

@ -1,46 +0,0 @@
From 28ccb37eb388e7e3d214a9b05011f8421f0d65ac Mon Sep 17 00:00:00 2001
From: Ying Xie <ying.xie@microsoft.com>
Date: Fri, 26 Apr 2019 23:30:38 +0000
Subject: [PATCH] teamd: do not process lacpdu before the port ifinfo is set
Now the port ifinfo will be set in obj_input_newlink when a RTM_NEWLINK
event is received.
But when a port is being added, if a lacpdu gets received on this port
before the RTM_NEWLINK event, lacpdu_recv will process the packet with
incorrect port ifinfo.
In Patrick's case, as ifinfo->master_ifindex was 0, it would skip this
port in teamd_for_each_tdport, which caused lacp_port->agg_lead not to
be updated in lacp_switch_agg_lead. Later the lacp_port actor would go
to a unexpected state.
This patch is to avoid it by checking teamd_port_present in lacpdu_recv
so that it would not process lacpdu before the port ifinfo is set.
Reported-by: Patrick Talbert <ptalbert@redhat.com>
Tested-by: Patrick Talbert <ptalbert@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
teamd/teamd_runner_lacp.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c
index 78f05dd..c8ae541 100644
--- a/teamd/teamd_runner_lacp.c
+++ b/teamd/teamd_runner_lacp.c
@@ -1132,6 +1132,9 @@ static int lacpdu_process(struct lacp_port *lacp_port, struct lacpdu* lacpdu)
{
int err;
+ if (!teamd_port_present(lacp_port->ctx, lacp_port->tdport))
+ return 0;
+
if (!lacpdu_check(lacpdu)) {
teamd_log_warn("malformed LACP PDU came.");
return 0;
--
2.7.4

View File

@ -1,22 +0,0 @@
diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c
index 4a3fe6b..19592c5 100644
--- a/teamd/teamd_runner_lacp.c
+++ b/teamd/teamd_runner_lacp.c
@@ -1182,12 +1182,17 @@ static int lacpdu_recv(struct lacp_port *lacp_port)
struct lacpdu lacpdu;
struct sockaddr_ll ll_from;
int err;
+ bool admin_state;
err = teamd_recvfrom(lacp_port->sock, &lacpdu, sizeof(lacpdu), 0,
(struct sockaddr *) &ll_from, sizeof(ll_from));
if (err <= 0)
return err;
+ admin_state = team_get_ifinfo_admin_state(lacp_port->ctx->ifinfo);
+ if (!admin_state)
+ return 0;
+
return lacpdu_process(lacp_port, &lacpdu);
}

View File

@ -12,17 +12,17 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
rm -rf ./libteam rm -rf ./libteam
git clone https://github.com/jpirko/libteam.git git clone https://github.com/jpirko/libteam.git
pushd ./libteam pushd ./libteam
git checkout -b teamd -f v1.26 git checkout -b teamd -f 5c5e498bff9
# Apply patch series # Apply patch series
stg init stg init
stg import -s ../series stg import -s ../patch/series
popd popd
# Obtain debian packaging # Obtain debian packaging
git clone https://salsa.debian.org/debian/libteam.git tmp git clone https://salsa.debian.org/debian/libteam.git tmp
pushd ./tmp pushd ./tmp
git checkout -f da006f2 # v1.26 git checkout -f 7188c361 # v1.28-1
popd popd
mv tmp/debian libteam/ mv tmp/debian libteam/

View File

@ -1,17 +1,17 @@
From a5c8f3f41c575ebb7018e67cb3d1f724f0685850 Mon Sep 17 00:00:00 2001 From 10602c2b1184aa0c6907b5a7f06fcba8a7141148 Mon Sep 17 00:00:00 2001
From: Shuotian Cheng <shuche@microsoft.com> From: Shuotian Cheng <shuche@microsoft.com>
Date: Mon, 27 Feb 2017 14:21:09 -0800 Date: Mon, 27 Feb 2017 14:21:09 -0800
Subject: [PATCH] libteam: Temporarily remove redundant debug messages Subject: [PATCH 1/8] libteam: Temporarily remove redundant debug messages
--- ---
teamd/teamd_runner_lacp.c | 2 -- teamd/teamd_runner_lacp.c | 2 --
1 file changed, 2 deletions(-) 1 file changed, 2 deletions(-)
diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c
index 9c77fae..5e37a4c 100644 index d292d69..7c91aed 100644
--- a/teamd/teamd_runner_lacp.c --- a/teamd/teamd_runner_lacp.c
+++ b/teamd/teamd_runner_lacp.c +++ b/teamd/teamd_runner_lacp.c
@@ -922,8 +922,6 @@ static void lacp_port_actor_update(struct lacp_port *lacp_port) @@ -929,8 +929,6 @@ static void lacp_port_actor_update(struct lacp_port *lacp_port)
state |= INFO_STATE_DEFAULTED; state |= INFO_STATE_DEFAULTED;
if (teamd_port_count(lacp_port->ctx) > 0) if (teamd_port_count(lacp_port->ctx) > 0)
state |= INFO_STATE_AGGREGATION; state |= INFO_STATE_AGGREGATION;
@ -21,5 +21,5 @@ index 9c77fae..5e37a4c 100644
} }
-- --
2.1.4 2.7.4

View File

@ -1,21 +1,23 @@
From 417e9dfdccbbee2cf86e46e994e8ece3433b46a4 Mon Sep 17 00:00:00 2001 From 0ce56490a44191c4b17a75cc21aa6a5bdc535f1d Mon Sep 17 00:00:00 2001
From: Pavel Shirshov <pavelsh@microsoft.com> From: yorke <yorke.yuan@asterfusion.com>
Date: Wed, 20 Sep 2017 00:34:07 +0000 Date: Mon, 3 Jun 2019 11:58:19 +0800
Subject: [PATCH] [teamd] lacp runner will send lacp update right after it Subject: [PATCH 2/8] [teamd] lacp runner will send lacp update right after it
received SIGINT signal received SIGINT signal From: Pavel Shirshov <pavelsh@microsoft.com>
Date: Wed, 20 Sep 2017 00:34:07 +0000
Signed-off-by: yorke <yorke.yuan@asterfusion.com>
--- ---
teamd/teamd.c | 1 + teamd/teamd.c | 1 +
teamd/teamd.h | 3 +++ teamd/teamd.h | 3 +++
teamd/teamd_events.c | 13 +++++++++++++ teamd/teamd_events.c | 13 +++++++++++++
teamd/teamd_runner_lacp.c | 10 ++++++++++ teamd/teamd_runner_lacp.c | 11 +++++++++++
4 files changed, 27 insertions(+) 4 files changed, 28 insertions(+)
diff --git a/teamd/teamd.c b/teamd/teamd.c diff --git a/teamd/teamd.c b/teamd/teamd.c
index aac2511..c987333 100644 index 6c47312..58d4fc8 100644
--- a/teamd/teamd.c --- a/teamd/teamd.c
+++ b/teamd/teamd.c +++ b/teamd/teamd.c
@@ -386,6 +386,7 @@ static int teamd_run_loop_run(struct teamd_context *ctx) @@ -392,6 +392,7 @@ static int teamd_run_loop_run(struct teamd_context *ctx)
case 'q': case 'q':
if (quit_in_progress) if (quit_in_progress)
return -EBUSY; return -EBUSY;
@ -24,13 +26,13 @@ index aac2511..c987333 100644
if (err) if (err)
return err; return err;
diff --git a/teamd/teamd.h b/teamd/teamd.h diff --git a/teamd/teamd.h b/teamd/teamd.h
index 5dbfb9b..ef0fb1c 100644 index 01bd022..e71a5dc 100644
--- a/teamd/teamd.h --- a/teamd/teamd.h
+++ b/teamd/teamd.h +++ b/teamd/teamd.h
@@ -189,11 +189,14 @@ struct teamd_event_watch_ops { @@ -193,11 +193,14 @@ struct teamd_event_watch_ops {
struct teamd_port *tdport, void *priv); int (*port_master_ifindex_changed)(struct teamd_context *ctx,
int (*port_ifname_changed)(struct teamd_context *ctx, struct teamd_port *tdport,
struct teamd_port *tdport, void *priv); void *priv);
+ void (*refresh)(struct teamd_context *ctx, + void (*refresh)(struct teamd_context *ctx,
+ struct teamd_port *tdport, void *priv); + struct teamd_port *tdport, void *priv);
int (*option_changed)(struct teamd_context *ctx, int (*option_changed)(struct teamd_context *ctx,
@ -43,7 +45,7 @@ index 5dbfb9b..ef0fb1c 100644
struct teamd_port *tdport); struct teamd_port *tdport);
void teamd_event_port_removed(struct teamd_context *ctx, void teamd_event_port_removed(struct teamd_context *ctx,
diff --git a/teamd/teamd_events.c b/teamd/teamd_events.c diff --git a/teamd/teamd_events.c b/teamd/teamd_events.c
index 1a95974..5c2ef56 100644 index 65aa46a..221803e 100644
--- a/teamd/teamd_events.c --- a/teamd/teamd_events.c
+++ b/teamd/teamd_events.c +++ b/teamd/teamd_events.c
@@ -34,6 +34,19 @@ struct event_watch_item { @@ -34,6 +34,19 @@ struct event_watch_item {
@ -67,25 +69,27 @@ index 1a95974..5c2ef56 100644
struct teamd_port *tdport) struct teamd_port *tdport)
{ {
diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c
index 9c77fae..e38c291 100644 index 7c91aed..4dbd015 100644
--- a/teamd/teamd_runner_lacp.c --- a/teamd/teamd_runner_lacp.c
+++ b/teamd/teamd_runner_lacp.c +++ b/teamd/teamd_runner_lacp.c
@@ -1383,12 +1383,22 @@ static int lacp_event_watch_port_changed(struct teamd_context *ctx, @@ -1421,6 +1421,16 @@ static int lacp_event_watch_port_changed(struct teamd_context *ctx,
return lacp_port_link_update(lacp_port); return lacp_port_link_update(lacp_port);
} }
+static void lacp_event_watch_refresh(struct teamd_context *ctx, struct teamd_port *tdport, void *priv) +static void lacp_event_watch_refresh(struct teamd_context *ctx,
+ struct teamd_port *tdport, void *priv)
+{ +{
+ struct lacp *lacp = priv; + struct lacp *lacp = priv;
+
+ struct lacp_port *lacp_port = lacp_port_get(lacp, tdport); + struct lacp_port *lacp_port = lacp_port_get(lacp, tdport);
+
+ if (lacp_port_selected(lacp_port)) + if (lacp_port_selected(lacp_port))
+ (void) lacpdu_send(lacp_port); + (void) lacpdu_send(lacp_port);
+} +}
+ +
static const struct teamd_event_watch_ops lacp_event_watch_ops = { static const struct teamd_event_watch_ops lacp_event_watch_ops = {
.hwaddr_changed = lacp_event_watch_hwaddr_changed, .hwaddr_changed = lacp_event_watch_hwaddr_changed,
.port_added = lacp_event_watch_port_added, .port_hwaddr_changed = lacp_event_watch_port_hwaddr_changed,
@@ -1428,6 +1438,7 @@ static const struct teamd_event_watch_ops lacp_event_watch_ops = {
.port_removed = lacp_event_watch_port_removed, .port_removed = lacp_event_watch_port_removed,
.port_changed = lacp_event_watch_port_changed, .port_changed = lacp_event_watch_port_changed,
.admin_state_changed = lacp_event_watch_admin_state_changed, .admin_state_changed = lacp_event_watch_admin_state_changed,

View File

@ -1,16 +1,17 @@
From ec966f9a0229bd7226e3abe15b56659b36af9d66 Mon Sep 17 00:00:00 2001 From 9b40af58575a89d06be51cfbb5a2265a59826110 Mon Sep 17 00:00:00 2001
From: Haiyang Zheng <haiyang.z@alibaba-inc.com> From: yorke <yorke.yuan@asterfusion.com>
Date: Fri, 15 Dec 2017 21:07:53 -0800 Date: Mon, 3 Jun 2019 12:02:36 +0800
Subject: [patch libteam] [libteam] Add fallback support for single-member-port Subject: [PATCH 3/8] [libteam] Add fallback support for single-member-port LAG
LAG From: Haiyang Zheng <haiyang.z@alibaba-inc.com> Date: Fri, 15 Dec
2017 21:07:53 -0800
Signed-off-by: Haiyang Zheng <haiyang.z@alibaba-inc.com> Signed-off-by: yorke <yorke.yuan@asterfusion.com>
--- ---
teamd/teamd_runner_lacp.c | 42 ++++++++++++++++++++++++++++++++++++++++-- teamd/teamd_runner_lacp.c | 42 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 40 insertions(+), 2 deletions(-) 1 file changed, 40 insertions(+), 2 deletions(-)
diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c
index 9c77fae..a3646a6 100644 index 4dbd015..9836824 100644
--- a/teamd/teamd_runner_lacp.c --- a/teamd/teamd_runner_lacp.c
+++ b/teamd/teamd_runner_lacp.c +++ b/teamd/teamd_runner_lacp.c
@@ -138,6 +138,8 @@ struct lacp { @@ -138,6 +138,8 @@ struct lacp {
@ -70,7 +71,7 @@ index 9c77fae..a3646a6 100644
return false; return false;
return true; return true;
} }
@@ -1452,6 +1475,16 @@ static int lacp_state_fast_rate_get(struct teamd_context *ctx, @@ -1502,6 +1525,16 @@ static int lacp_state_fast_rate_get(struct teamd_context *ctx,
return 0; return 0;
} }
@ -87,7 +88,7 @@ index 9c77fae..a3646a6 100644
static int lacp_state_select_policy_get(struct teamd_context *ctx, static int lacp_state_select_policy_get(struct teamd_context *ctx,
struct team_state_gsc *gsc, struct team_state_gsc *gsc,
void *priv) void *priv)
@@ -1479,6 +1512,11 @@ static const struct teamd_state_val lacp_state_vals[] = { @@ -1529,6 +1562,11 @@ static const struct teamd_state_val lacp_state_vals[] = {
.getter = lacp_state_fast_rate_get, .getter = lacp_state_fast_rate_get,
}, },
{ {

View File

@ -0,0 +1,36 @@
From e18cbe5a6c76366923a8ace830c89056a1542745 Mon Sep 17 00:00:00 2001
From: yorke <yorke.yuan@asterfusion.com>
Date: Mon, 3 Jun 2019 12:06:00 +0800
Subject: [PATCH 4/8] Skip setting the same hwaddr to lag port to avoid
disrupting From: Jipan Yang <jipan.yang@alibaba-inc.com> Date: Sun,
24 Feb 2019 00:04:15 -0800
Signed-off-by: yorke <yorke.yuan@asterfusion.com>
---
teamd/teamd.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/teamd/teamd.c b/teamd/teamd.c
index 58d4fc8..9dc85b5 100644
--- a/teamd/teamd.c
+++ b/teamd/teamd.c
@@ -834,7 +834,15 @@ static int teamd_set_hwaddr(struct teamd_context *ctx)
err = -EINVAL;
goto free_hwaddr;
}
- err = team_hwaddr_set(ctx->th, ctx->ifindex, hwaddr, hwaddr_len);
+
+ if(!memcmp(hwaddr, ctx->hwaddr, hwaddr_len)) {
+ err = 0;
+ teamd_log_dbg("Skip setting same hwaddr string: \"%s\".", hwaddr_str);
+ }
+ else{
+ err = team_hwaddr_set(ctx->th, ctx->ifindex, hwaddr, hwaddr_len);
+ }
+
if (!err)
ctx->hwaddr_explicit = true;
free_hwaddr:
--
2.7.4

View File

@ -0,0 +1,31 @@
From 39e5b0a15bf276dffa6b8c61594ee945248a4e27 Mon Sep 17 00:00:00 2001
From: yorke <yorke.yuan@asterfusion.com>
Date: Mon, 3 Jun 2019 12:32:33 +0800
Subject: [PATCH 5/8] Increase default buffer size from 98304 to 983040
From: Pavel Shirshov <pavelsh@microsoft.com>
https://github.com/Azure/sonic-buildimage/pull/2822
Signed-off-by: yorke <yorke.yuan@asterfusion.com>
---
libteam/libteam.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libteam/libteam.c b/libteam/libteam.c
index 9c9c93a..2cc80ca 100644
--- a/libteam/libteam.c
+++ b/libteam/libteam.c
@@ -551,9 +551,9 @@ int team_destroy(struct team_handle *th)
/* \endcond */
/* libnl uses default 32k socket receive buffer size,
- * which can get too small. Use 192k for all sockets.
+ * which can get too small. Use 960k for all sockets.
*/
-#define NETLINK_RCVBUF 196608
+#define NETLINK_RCVBUF 983040
/**
* @param th libteam library context
--
2.7.4

View File

@ -0,0 +1,37 @@
From f1eec95dd0475591897a781eba15d8d8ce370a6a Mon Sep 17 00:00:00 2001
From: yorke <yorke.yuan@asterfusion.com>
Date: Mon, 3 Jun 2019 13:21:07 +0800
Subject: [PATCH 6/8] [teamd]: Administratively shutdown port channel has
member ports in deselected state and traffic is not forwarded From:
phanindra-tv https://github.com/Azure/sonic-buildimage/pull/2882
Signed-off-by: yorke <yorke.yuan@asterfusion.com>
---
teamd/teamd_runner_lacp.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c
index 9836824..7bf3700 100644
--- a/teamd/teamd_runner_lacp.c
+++ b/teamd/teamd_runner_lacp.c
@@ -1101,12 +1101,17 @@ static int lacpdu_recv(struct lacp_port *lacp_port)
struct lacpdu lacpdu;
struct sockaddr_ll ll_from;
int err;
+ bool admin_state;
err = teamd_recvfrom(lacp_port->sock, &lacpdu, sizeof(lacpdu), 0,
(struct sockaddr *) &ll_from, sizeof(ll_from));
if (err <= 0)
return err;
+ admin_state = team_get_ifinfo_admin_state(lacp_port->ctx->ifinfo);
+ if (!admin_state)
+ return 0;
+
if (!teamd_port_present(lacp_port->ctx, lacp_port->tdport))
return 0;
--
2.7.4

View File

@ -1,17 +1,20 @@
From 0e0ee4a68b118d540d9ef5836a55483fcfb8771b Mon Sep 17 00:00:00 2001 From b82da0dc94ca34b039396328a8c2fcb61aa73c0f Mon Sep 17 00:00:00 2001
From: Pavel Shirshov <pavelsh@microsoft.com> From: yorke <yorke.yuan@asterfusion.com>
Date: Wed, 29 May 2019 19:15:20 +0000 Date: Mon, 3 Jun 2019 13:27:26 +0800
Subject: [PATCH] Send LACP PDU immediately if our state changed Subject: [PATCH 7/8] Send LACP PDU immediately if our state changed From:
Pavel Shirshov <pavelsh@microsoft.com> Date: Wed, 29 May 2019 19:15:20
+0000
Signed-off-by: yorke <yorke.yuan@asterfusion.com>
--- ---
teamd/teamd_runner_lacp.c | 8 ++++---- teamd/teamd_runner_lacp.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-) 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c
index 19592c5..a505284 100644 index 7bf3700..4016b15 100644
--- a/teamd/teamd_runner_lacp.c --- a/teamd/teamd_runner_lacp.c
+++ b/teamd/teamd_runner_lacp.c +++ b/teamd/teamd_runner_lacp.c
@@ -1049,8 +1049,7 @@ static int lacp_port_set_state(struct lacp_port *lacp_port, @@ -1017,8 +1017,7 @@ static int lacp_port_set_state(struct lacp_port *lacp_port,
return err; return err;
lacp_port_actor_update(lacp_port); lacp_port_actor_update(lacp_port);
@ -21,7 +24,7 @@ index 19592c5..a505284 100644
return lacpdu_send(lacp_port); return lacpdu_send(lacp_port);
} }
@@ -1160,9 +1159,10 @@ static int lacpdu_process(struct lacp_port *lacp_port, struct lacpdu* lacpdu) @@ -1136,9 +1135,10 @@ static int lacpdu_recv(struct lacp_port *lacp_port)
if (err) if (err)
return err; return err;
@ -29,8 +32,8 @@ index 19592c5..a505284 100644
+ +
/* Check if the other side has correct info about us */ /* Check if the other side has correct info about us */
- if (!lacp_port->periodic_on && - if (!lacp_port->periodic_on &&
- memcmp(&lacpdu->partner, &lacp_port->actor, - memcmp(&lacpdu.partner, &lacp_port->actor,
+ if (memcmp(&lacpdu->partner, &lacp_port->actor, + if (memcmp(&lacpdu.partner, &lacp_port->actor,
sizeof(struct lacpdu_info))) { sizeof(struct lacpdu_info))) {
err = lacpdu_send(lacp_port); err = lacpdu_send(lacp_port);
if (err) if (err)

View File

@ -1,8 +1,24 @@
From fe097ebcadd52e56a589c38a9c821cf1a84d6b67 Mon Sep 17 00:00:00 2001
From: yorke <yorke.yuan@asterfusion.com>
Date: Mon, 3 Jun 2019 14:48:14 +0800
Subject: [PATCH 8/8] [libteam] Add warm_reboot mode From: pavel-shirshov
<pavelsh@microsoft.com> and Ying Xie <ying.xie@microsoft.com>
https://github.com/Azure/sonic-buildimage/pull/2173
Signed-off-by: yorke <yorke.yuan@asterfusion.com>
---
libteam/ifinfo.c | 6 +-
teamd/teamd.c | 46 +++++++++-
teamd/teamd.h | 7 ++
teamd/teamd_events.c | 13 +++
teamd/teamd_runner_lacp.c | 209 +++++++++++++++++++++++++++++++++++++++-------
5 files changed, 245 insertions(+), 36 deletions(-)
diff --git a/libteam/ifinfo.c b/libteam/ifinfo.c diff --git a/libteam/ifinfo.c b/libteam/ifinfo.c
index 72155ae..44de4ca 100644 index 46d56a2..b86d34c 100644
--- a/libteam/ifinfo.c --- a/libteam/ifinfo.c
+++ b/libteam/ifinfo.c +++ b/libteam/ifinfo.c
@@ -105,15 +105,13 @@ static void update_hwaddr(struct team_ifinfo *ifinfo, struct rtnl_link *link) @@ -109,15 +109,13 @@ static void update_hwaddr(struct team_ifinfo *ifinfo, struct rtnl_link *link)
hwaddr_len = nl_addr_get_len(nl_addr); hwaddr_len = nl_addr_get_len(nl_addr);
if (ifinfo->hwaddr_len != hwaddr_len) { if (ifinfo->hwaddr_len != hwaddr_len) {
ifinfo->hwaddr_len = hwaddr_len; ifinfo->hwaddr_len = hwaddr_len;
@ -21,10 +37,10 @@ index 72155ae..44de4ca 100644
} }
} }
diff --git a/teamd/teamd.c b/teamd/teamd.c diff --git a/teamd/teamd.c b/teamd/teamd.c
index c987333..225b8c8 100644 index 9dc85b5..1a974d1 100644
--- a/teamd/teamd.c --- a/teamd/teamd.c
+++ b/teamd/teamd.c +++ b/teamd/teamd.c
@@ -116,7 +116,9 @@ static void print_help(const struct teamd_context *ctx) { @@ -117,7 +117,9 @@ static void print_help(const struct teamd_context *ctx) {
" -D --dbus-enable Enable D-Bus interface\n" " -D --dbus-enable Enable D-Bus interface\n"
" -Z --zmq-enable=ADDRESS Enable ZeroMQ interface\n" " -Z --zmq-enable=ADDRESS Enable ZeroMQ interface\n"
" -U --usock-enable Enable UNIX domain socket interface\n" " -U --usock-enable Enable UNIX domain socket interface\n"
@ -35,7 +51,7 @@ index c987333..225b8c8 100644
ctx->argv0); ctx->argv0);
printf("Available runners: "); printf("Available runners: ");
for (i = 0; i < TEAMD_RUNNER_LIST_SIZE; i++) { for (i = 0; i < TEAMD_RUNNER_LIST_SIZE; i++) {
@@ -129,7 +131,7 @@ static void print_help(const struct teamd_context *ctx) { @@ -130,7 +132,7 @@ static void print_help(const struct teamd_context *ctx) {
static int parse_command_line(struct teamd_context *ctx, static int parse_command_line(struct teamd_context *ctx,
int argc, char *argv[]) { int argc, char *argv[]) {
@ -44,7 +60,7 @@ index c987333..225b8c8 100644
static const struct option long_options[] = { static const struct option long_options[] = {
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{ "daemonize", no_argument, NULL, 'd' }, { "daemonize", no_argument, NULL, 'd' },
@@ -149,10 +151,12 @@ static int parse_command_line(struct teamd_context *ctx, @@ -151,10 +153,12 @@ static int parse_command_line(struct teamd_context *ctx,
{ "zmq-enable", required_argument, NULL, 'Z' }, { "zmq-enable", required_argument, NULL, 'Z' },
{ "usock-enable", no_argument, NULL, 'U' }, { "usock-enable", no_argument, NULL, 'U' },
{ "usock-disable", no_argument, NULL, 'u' }, { "usock-disable", no_argument, NULL, 'u' },
@ -53,12 +69,12 @@ index c987333..225b8c8 100644
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
- while ((opt = getopt_long(argc, argv, "hdkevf:c:p:groNt:nDZ:Uu", - while ((opt = getopt_long(argc, argv, "hdkevf:c:p:gl:roNt:nDZ:Uu",
+ while ((opt = getopt_long(argc, argv, "hdkevf:c:p:groNt:nDZ:UuwL:", + while ((opt = getopt_long(argc, argv, "hdkevf:c:p:gl:roNt:nDZ:UuwL:",
long_options, NULL)) >= 0) { long_options, NULL)) >= 0) {
switch(opt) { switch(opt) {
@@ -230,11 +234,29 @@ static int parse_command_line(struct teamd_context *ctx, @@ -236,11 +240,29 @@ static int parse_command_line(struct teamd_context *ctx,
case 'u': case 'u':
ctx->usock.enabled = false; ctx->usock.enabled = false;
break; break;
@ -88,7 +104,7 @@ index c987333..225b8c8 100644
if (optind < argc) { if (optind < argc) {
fprintf(stderr, "Too many arguments\n"); fprintf(stderr, "Too many arguments\n");
return -1; return -1;
@@ -384,8 +406,14 @@ static int teamd_run_loop_run(struct teamd_context *ctx) @@ -390,8 +412,14 @@ static int teamd_run_loop_run(struct teamd_context *ctx)
if (err != -1) { if (err != -1) {
switch(ctrl_byte) { switch(ctrl_byte) {
case 'q': case 'q':
@ -103,7 +119,7 @@ index c987333..225b8c8 100644
teamd_refresh_ports(ctx); teamd_refresh_ports(ctx);
err = teamd_flush_ports(ctx); err = teamd_flush_ports(ctx);
if (err) if (err)
@@ -428,6 +456,12 @@ void teamd_run_loop_quit(struct teamd_context *ctx, int err) @@ -434,6 +462,12 @@ void teamd_run_loop_quit(struct teamd_context *ctx, int err)
teamd_run_loop_sent_ctrl_byte(ctx, 'q'); teamd_run_loop_sent_ctrl_byte(ctx, 'q');
} }
@ -116,7 +132,7 @@ index c987333..225b8c8 100644
void teamd_run_loop_restart(struct teamd_context *ctx) void teamd_run_loop_restart(struct teamd_context *ctx)
{ {
teamd_run_loop_sent_ctrl_byte(ctx, 'r'); teamd_run_loop_sent_ctrl_byte(ctx, 'r');
@@ -694,6 +728,10 @@ static int callback_daemon_signal(struct teamd_context *ctx, int events, @@ -700,6 +734,10 @@ static int callback_daemon_signal(struct teamd_context *ctx, int events,
teamd_log_warn("Got SIGINT, SIGQUIT or SIGTERM."); teamd_log_warn("Got SIGINT, SIGQUIT or SIGTERM.");
teamd_run_loop_quit(ctx, 0); teamd_run_loop_quit(ctx, 0);
break; break;
@ -127,7 +143,7 @@ index c987333..225b8c8 100644
} }
return 0; return 0;
} }
@@ -1507,7 +1545,7 @@ static int teamd_start(struct teamd_context *ctx, enum teamd_exit_code *p_ret) @@ -1531,7 +1569,7 @@ static int teamd_start(struct teamd_context *ctx, enum teamd_exit_code *p_ret)
return -errno; return -errno;
} }
@ -137,10 +153,10 @@ index c987333..225b8c8 100644
daemon_retval_send(errno); daemon_retval_send(errno);
err = -errno; err = -errno;
diff --git a/teamd/teamd.h b/teamd/teamd.h diff --git a/teamd/teamd.h b/teamd/teamd.h
index ef0fb1c..622c365 100644 index e71a5dc..f83a2d9 100644
--- a/teamd/teamd.h --- a/teamd/teamd.h
+++ b/teamd/teamd.h +++ b/teamd/teamd.h
@@ -125,6 +125,10 @@ struct teamd_context { @@ -126,6 +126,10 @@ struct teamd_context {
char * hwaddr; char * hwaddr;
uint32_t hwaddr_len; uint32_t hwaddr_len;
bool hwaddr_explicit; bool hwaddr_explicit;
@ -151,8 +167,8 @@ index ef0fb1c..622c365 100644
struct { struct {
struct list_item callback_list; struct list_item callback_list;
int ctrl_pipe_r; int ctrl_pipe_r;
@@ -191,12 +195,15 @@ struct teamd_event_watch_ops { @@ -195,12 +199,15 @@ struct teamd_event_watch_ops {
struct teamd_port *tdport, void *priv); void *priv);
void (*refresh)(struct teamd_context *ctx, void (*refresh)(struct teamd_context *ctx,
struct teamd_port *tdport, void *priv); struct teamd_port *tdport, void *priv);
+ void (*port_flush_data)(struct teamd_context *ctx, + void (*port_flush_data)(struct teamd_context *ctx,
@ -168,7 +184,7 @@ index ef0fb1c..622c365 100644
struct teamd_port *tdport); struct teamd_port *tdport);
void teamd_event_port_removed(struct teamd_context *ctx, void teamd_event_port_removed(struct teamd_context *ctx,
diff --git a/teamd/teamd_events.c b/teamd/teamd_events.c diff --git a/teamd/teamd_events.c b/teamd/teamd_events.c
index 5c2ef56..50e5a08 100644 index 221803e..bd4dcc1 100644
--- a/teamd/teamd_events.c --- a/teamd/teamd_events.c
+++ b/teamd/teamd_events.c +++ b/teamd/teamd_events.c
@@ -47,6 +47,19 @@ void teamd_refresh_ports(struct teamd_context *ctx) @@ -47,6 +47,19 @@ void teamd_refresh_ports(struct teamd_context *ctx)
@ -192,7 +208,7 @@ index 5c2ef56..50e5a08 100644
struct teamd_port *tdport) struct teamd_port *tdport)
{ {
diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c
index 81324de..9e88ce0 100644 index 4016b15..087efa9 100644
--- a/teamd/teamd_runner_lacp.c --- a/teamd/teamd_runner_lacp.c
+++ b/teamd/teamd_runner_lacp.c +++ b/teamd/teamd_runner_lacp.c
@@ -31,6 +31,7 @@ @@ -31,6 +31,7 @@
@ -221,7 +237,7 @@ index 81324de..9e88ce0 100644
struct { struct {
uint32_t speed; uint32_t speed;
uint8_t duplex; uint8_t duplex;
@@ -491,15 +496,28 @@ static int lacp_update_carrier(struct lacp *lacp) @@ -493,15 +498,28 @@ static int lacp_update_carrier(struct lacp *lacp)
bool state; bool state;
int err; int err;
@ -251,7 +267,7 @@ index 81324de..9e88ce0 100644
return lacp_set_carrier(lacp, false); return lacp_set_carrier(lacp, false);
} }
@@ -917,6 +935,18 @@ static void lacp_port_actor_system_update(struct lacp_port *lacp_port) @@ -919,6 +937,18 @@ static void lacp_port_actor_system_update(struct lacp_port *lacp_port)
memcpy(actor->system, lacp_port->ctx->hwaddr, ETH_ALEN); memcpy(actor->system, lacp_port->ctx->hwaddr, ETH_ALEN);
} }
@ -270,7 +286,7 @@ index 81324de..9e88ce0 100644
static void lacp_port_actor_init(struct lacp_port *lacp_port) static void lacp_port_actor_init(struct lacp_port *lacp_port)
{ {
struct lacpdu_info *actor = &lacp_port->actor; struct lacpdu_info *actor = &lacp_port->actor;
@@ -924,7 +954,7 @@ static void lacp_port_actor_init(struct lacp_port *lacp_port) @@ -926,7 +956,7 @@ static void lacp_port_actor_init(struct lacp_port *lacp_port)
actor->system_priority = htons(lacp_port->lacp->cfg.sys_prio); actor->system_priority = htons(lacp_port->lacp->cfg.sys_prio);
actor->key = htons(lacp_port->cfg.lacp_key); actor->key = htons(lacp_port->cfg.lacp_key);
actor->port_priority = htons(lacp_port->cfg.lacp_prio); actor->port_priority = htons(lacp_port->cfg.lacp_prio);
@ -279,7 +295,7 @@ index 81324de..9e88ce0 100644
lacp_port_actor_system_update(lacp_port); lacp_port_actor_system_update(lacp_port);
} }
@@ -994,6 +1024,13 @@ static int lacp_port_set_state(struct lacp_port *lacp_port, @@ -1006,6 +1036,13 @@ static int lacp_port_set_state(struct lacp_port *lacp_port,
break; break;
} }
@ -293,7 +309,7 @@ index 81324de..9e88ce0 100644
teamd_log_info("%s: Changed port state: \"%s\" -> \"%s\"", teamd_log_info("%s: Changed port state: \"%s\" -> \"%s\"",
lacp_port->tdport->ifname, lacp_port->tdport->ifname,
lacp_port_state_name[lacp_port->state], lacp_port_state_name[lacp_port->state],
@@ -1084,26 +1121,23 @@ static int lacpdu_send(struct lacp_port *lacp_port) @@ -1095,34 +1132,26 @@ static int lacpdu_send(struct lacp_port *lacp_port)
return err; return err;
} }
@ -303,12 +319,20 @@ index 81324de..9e88ce0 100644
- struct lacpdu lacpdu; - struct lacpdu lacpdu;
- struct sockaddr_ll ll_from; - struct sockaddr_ll ll_from;
int err; int err;
- bool admin_state;
-
- err = teamd_recvfrom(lacp_port->sock, &lacpdu, sizeof(lacpdu), 0, - err = teamd_recvfrom(lacp_port->sock, &lacpdu, sizeof(lacpdu), 0,
- (struct sockaddr *) &ll_from, sizeof(ll_from)); - (struct sockaddr *) &ll_from, sizeof(ll_from));
- if (err <= 0) - if (err <= 0)
- return err; - return err;
- -
- admin_state = team_get_ifinfo_admin_state(lacp_port->ctx->ifinfo);
- if (!admin_state)
- return 0;
if (!teamd_port_present(lacp_port->ctx, lacp_port->tdport))
return 0;
- if (!lacpdu_check(&lacpdu)) { - if (!lacpdu_check(&lacpdu)) {
+ if (!lacpdu_check(lacpdu)) { + if (!lacpdu_check(lacpdu)) {
teamd_log_warn("malformed LACP PDU came."); teamd_log_warn("malformed LACP PDU came.");
@ -328,16 +352,16 @@ index 81324de..9e88ce0 100644
err = lacp_port_partner_update(lacp_port); err = lacp_port_partner_update(lacp_port);
if (err) if (err)
return err; return err;
@@ -1118,7 +1152,7 @@ static int lacpdu_recv(struct lacp_port *lacp_port) @@ -1138,7 +1167,7 @@ static int lacpdu_recv(struct lacp_port *lacp_port)
lacp_port_actor_update(lacp_port);
/* Check if the other side has correct info about us */ /* Check if the other side has correct info about us */
if (!lacp_port->periodic_on && - if (memcmp(&lacpdu.partner, &lacp_port->actor,
- memcmp(&lacpdu.partner, &lacp_port->actor, + if (memcmp(&lacpdu->partner, &lacp_port->actor,
+ memcmp(&lacpdu->partner, &lacp_port->actor,
sizeof(struct lacpdu_info))) { sizeof(struct lacpdu_info))) {
err = lacpdu_send(lacp_port); err = lacpdu_send(lacp_port);
if (err) if (err)
@@ -1133,6 +1167,65 @@ static int lacpdu_recv(struct lacp_port *lacp_port) @@ -1153,6 +1182,70 @@ static int lacpdu_recv(struct lacp_port *lacp_port)
return 0; return 0;
} }
@ -346,12 +370,17 @@ index 81324de..9e88ce0 100644
+ struct lacpdu lacpdu; + struct lacpdu lacpdu;
+ struct sockaddr_ll ll_from; + struct sockaddr_ll ll_from;
+ int err; + int err;
+ bool admin_state;
+ +
+ err = teamd_recvfrom(lacp_port->sock, &lacpdu, sizeof(lacpdu), 0, + err = teamd_recvfrom(lacp_port->sock, &lacpdu, sizeof(lacpdu), 0,
+ (struct sockaddr *) &ll_from, sizeof(ll_from)); + (struct sockaddr *) &ll_from, sizeof(ll_from));
+ if (err <= 0) + if (err <= 0)
+ return err; + return err;
+ +
+ admin_state = team_get_ifinfo_admin_state(lacp_port->ctx->ifinfo);
+ if (!admin_state)
+ return 0;
+
+ return lacpdu_process(lacp_port, &lacpdu); + return lacpdu_process(lacp_port, &lacpdu);
+} +}
+ +
@ -403,7 +432,7 @@ index 81324de..9e88ce0 100644
static int lacp_callback_timeout(struct teamd_context *ctx, int events, static int lacp_callback_timeout(struct teamd_context *ctx, int events,
void *priv) void *priv)
{ {
@@ -1284,6 +1377,13 @@ static int lacp_port_added(struct teamd_context *ctx, @@ -1304,6 +1397,13 @@ static int lacp_port_added(struct teamd_context *ctx,
goto periodic_callback_del; goto periodic_callback_del;
} }
@ -417,7 +446,7 @@ index 81324de..9e88ce0 100644
/* Newly added ports are disabled */ /* Newly added ports are disabled */
err = team_set_port_enabled(ctx->th, tdport->ifindex, false); err = team_set_port_enabled(ctx->th, tdport->ifindex, false);
if (err) { if (err) {
@@ -1299,6 +1399,13 @@ static int lacp_port_added(struct teamd_context *ctx, @@ -1319,6 +1419,13 @@ static int lacp_port_added(struct teamd_context *ctx,
lacp_port_actor_init(lacp_port); lacp_port_actor_init(lacp_port);
lacp_port_link_update(lacp_port); lacp_port_link_update(lacp_port);
@ -431,7 +460,7 @@ index 81324de..9e88ce0 100644
teamd_loop_callback_enable(ctx, LACP_SOCKET_CB_NAME, lacp_port); teamd_loop_callback_enable(ctx, LACP_SOCKET_CB_NAME, lacp_port);
return 0; return 0;
@@ -1321,7 +1428,11 @@ static void lacp_port_removed(struct teamd_context *ctx, @@ -1341,7 +1448,11 @@ static void lacp_port_removed(struct teamd_context *ctx,
{ {
struct lacp_port *lacp_port = priv; struct lacp_port *lacp_port = priv;
@ -444,7 +473,7 @@ index 81324de..9e88ce0 100644
teamd_loop_callback_del(ctx, LACP_TIMEOUT_CB_NAME, lacp_port); teamd_loop_callback_del(ctx, LACP_TIMEOUT_CB_NAME, lacp_port);
teamd_loop_callback_del(ctx, LACP_PERIODIC_CB_NAME, lacp_port); teamd_loop_callback_del(ctx, LACP_PERIODIC_CB_NAME, lacp_port);
teamd_loop_callback_del(ctx, LACP_SOCKET_CB_NAME, lacp_port); teamd_loop_callback_del(ctx, LACP_SOCKET_CB_NAME, lacp_port);
@@ -1413,6 +1524,31 @@ static void lacp_event_watch_refresh(struct teamd_context *ctx, struct teamd_por @@ -1459,6 +1570,31 @@ static void lacp_event_watch_refresh(struct teamd_context *ctx,
(void) lacpdu_send(lacp_port); (void) lacpdu_send(lacp_port);
} }
@ -475,8 +504,8 @@ index 81324de..9e88ce0 100644
+ +
static const struct teamd_event_watch_ops lacp_event_watch_ops = { static const struct teamd_event_watch_ops lacp_event_watch_ops = {
.hwaddr_changed = lacp_event_watch_hwaddr_changed, .hwaddr_changed = lacp_event_watch_hwaddr_changed,
.port_added = lacp_event_watch_port_added, .port_hwaddr_changed = lacp_event_watch_port_hwaddr_changed,
@@ -1420,21 +1556,38 @@ static const struct teamd_event_watch_ops lacp_event_watch_ops = { @@ -1467,21 +1603,38 @@ static const struct teamd_event_watch_ops lacp_event_watch_ops = {
.port_changed = lacp_event_watch_port_changed, .port_changed = lacp_event_watch_port_changed,
.admin_state_changed = lacp_event_watch_admin_state_changed, .admin_state_changed = lacp_event_watch_admin_state_changed,
.refresh = lacp_event_watch_refresh, .refresh = lacp_event_watch_refresh,
@ -522,7 +551,7 @@ index 81324de..9e88ce0 100644
return 0; return 0;
} }
@@ -1946,7 +2099,7 @@ static void lacp_fini(struct teamd_context *ctx, void *priv) @@ -1993,7 +2146,7 @@ static void lacp_fini(struct teamd_context *ctx, void *priv)
teamd_state_val_unregister(ctx, &lacp_state_vg, lacp); teamd_state_val_unregister(ctx, &lacp_state_vg, lacp);
teamd_balancer_fini(lacp->tb); teamd_balancer_fini(lacp->tb);
teamd_event_watch_unregister(ctx, &lacp_event_watch_ops, lacp); teamd_event_watch_unregister(ctx, &lacp_event_watch_ops, lacp);
@ -531,3 +560,6 @@ index 81324de..9e88ce0 100644
} }
const struct teamd_runner teamd_runner_lacp = { const struct teamd_runner teamd_runner_lacp = {
--
2.7.4

8
src/libteam/patch/series Normal file
View File

@ -0,0 +1,8 @@
0001-libteam-Temporarily-remove-redundant-debug-messages.patch
0002-teamd-lacp-runner-will-send-lacp-update-right-after-.patch
0003-libteam-Add-fallback-support-for-single-member-port-.patch
0004-Skip-setting-the-same-hwaddr-to-lag-port-to-avoid-di.patch
0005-Increase-default-buffer-size-from-98304-to-983040.patch
0006-teamd-Administratively-shutdown-port-channel-has-mem.patch
0007-Send-LACP-PDU-immediately-if-our-state-changed.patch
0008-libteam-Add-warm_reboot-mode.patch

View File

@ -1,11 +0,0 @@
0001-libteam-Add-team_get_port_enabled-function.patch
0002-libteam-Temporarily-remove-redundant-debug-mes.patch
0003-teamd-lacp-runner-will-send-lacp-update-right-after-.patch
0004-libteam-Add-lacp-fallback-support-for-single-member-.patch
0005-libteam-Add-warm_reboot-mode.patch
0007-Skip-setting-the-same-hwaddr-to-lag-port-to-avoid-di.patch
0010-teamd-lacp-update-port-state-according-to-partners-sy.patch
0011-libteam-resynchronize-ifinfo-after-lost-RTNLGRP_LINK-.patch
0012-teamd-do-not-process-lacpdu-before-the-port-ifinfo-i.patch
0013-teamd-lacp-port-admin-down-recv-not-processing.patch
0014-Send-LACP-PDU-immediately-if-our-state-changed.patch