Skip to content

Commit

Permalink
added endpoint mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt committed Aug 11, 2023
1 parent 9ff174b commit 935b5f5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions links/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package links
import (
"fmt"
"net"
"sync"

"github.com/containernetworking/plugins/pkg/ns"
"github.com/vishvananda/netlink"
Expand Down Expand Up @@ -39,9 +40,13 @@ type EndpointGeneric struct {
Link Link
MAC net.HardwareAddr
randName string
m sync.Mutex
}

func (e *EndpointGeneric) GetRandIfaceName() string {
e.m.Lock()
defer e.m.Unlock()

// generate random interface name on the fly if not already generated
if e.randName == "" {
e.randName = genRandomIfName()
Expand Down

0 comments on commit 935b5f5

Please sign in to comment.