Message ID | 1585873445-25752-1-git-send-email-pavel.contrib@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Fix ifinfo_link_with_port race condition with newlink | expand |
Fri, Apr 03, 2020 at 02:24:05AM CEST, pavel.contrib@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@microsoft.com> >Signed-off-by: Pavel Shirshov <pavel.contrib@gmail.com> Applied, thanks!
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)