Tue, Mar 24, 2020 at 03:43:47AM CET, pavel.contrib(a)gmail.com wrote:
When a member port is enslaved into a port channel
immediately after the port channel was created,
it is possible to get member port ifinfo structure
not initialized for the member port because of a race
condition.
The race condition here occurs because order of
following events is not strict:
- adding the member port to the port channel;
- creating ifinfo structure for the member port.
The error message "Failed to link port with ifinfo" is
thrown when a member port is tried to be added to the
team handler's port list before ifinfo structure was
initialized.
To fix this situation ifinfo_find_create() is used
to search member ports ifinfo structure in
ifinfo_link_with_port().
Signed-off-by: Shuotian Cheng <shuche(a)microsoft.com>
From is: Shuotian Cheng <pavel.contrib(a)gmail.com>
Looks messed up. Please fix.
>Signed-off-by: Pavel Shirshov <pavel.contrib(a)gmail.com>
>---
> libteam/ifinfo.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
>diff --git a/libteam/ifinfo.c b/libteam/ifinfo.c
>index 46d56a2..a15788b 100644
>--- a/libteam/ifinfo.c
>+++ b/libteam/ifinfo.c
>@@ -453,7 +453,10 @@ int ifinfo_link_with_port(struct team_handle *th, uint32_t
ifindex,
> {
> struct team_ifinfo *ifinfo;
>
>- ifinfo = ifinfo_find(th, ifindex);
>+ if (port)
>+ ifinfo = ifinfo_find_create(th, ifindex);
>+ else
>+ ifinfo = ifinfo_find(th, ifindex);
> if (!ifinfo)
> return -ENOENT;
> if (ifinfo->linked)
>--
>2.7.4
>