Skip to content

Commit

Permalink
Check if ch is closed in waitForIPNets
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Popov <[email protected]>
  • Loading branch information
Vladimir Popov committed Sep 29, 2021
1 parent 320bcb1 commit 97967f1
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ func waitForIPNets(ctx context.Context, ch chan netlink.AddrUpdate, l netlink.Li
select {
case <-ctx.Done():
return errors.Wrapf(ctx.Err(), "timeout waiting for update to add ip addresses %s to %s (type: %s)", ipNets, l.Attrs().Name, l.Type())
case update := <-ch:
case update, ok := <-ch:
if !ok {
return errors.Errorf("failed to receive update to add ip addresses %s to %s (type: %s)", ipNets, l.Attrs().Name, l.Type())
}
if update.LinkIndex == l.Attrs().Index {
for i := range ipNets {
if update.LinkAddress.IP.Equal(ipNets[i].IP) && update.Flags&unix.IFA_F_TENTATIVE == 0 {
Expand Down

0 comments on commit 97967f1

Please sign in to comment.