Browse code

libnetwork/osl: nwIface: unexport sync.Mutex

Don't make the mutex public. This also gives a better clue
if the mutex is used externally.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2023/08/03 06:29:47
Showing 1 changed files
... ...
@@ -27,75 +27,75 @@ type nwIface struct {
27 27
 	routes      []*net.IPNet
28 28
 	bridge      bool
29 29
 	ns          *networkNamespace
30
-	sync.Mutex
30
+	mu          sync.Mutex
31 31
 }
32 32
 
33 33
 func (i *nwIface) SrcName() string {
34
-	i.Lock()
35
-	defer i.Unlock()
34
+	i.mu.Lock()
35
+	defer i.mu.Unlock()
36 36
 
37 37
 	return i.srcName
38 38
 }
39 39
 
40 40
 func (i *nwIface) DstName() string {
41
-	i.Lock()
42
-	defer i.Unlock()
41
+	i.mu.Lock()
42
+	defer i.mu.Unlock()
43 43
 
44 44
 	return i.dstName
45 45
 }
46 46
 
47 47
 func (i *nwIface) DstMaster() string {
48
-	i.Lock()
49
-	defer i.Unlock()
48
+	i.mu.Lock()
49
+	defer i.mu.Unlock()
50 50
 
51 51
 	return i.dstMaster
52 52
 }
53 53
 
54 54
 func (i *nwIface) Bridge() bool {
55
-	i.Lock()
56
-	defer i.Unlock()
55
+	i.mu.Lock()
56
+	defer i.mu.Unlock()
57 57
 
58 58
 	return i.bridge
59 59
 }
60 60
 
61 61
 func (i *nwIface) Master() string {
62
-	i.Lock()
63
-	defer i.Unlock()
62
+	i.mu.Lock()
63
+	defer i.mu.Unlock()
64 64
 
65 65
 	return i.master
66 66
 }
67 67
 
68 68
 func (i *nwIface) MacAddress() net.HardwareAddr {
69
-	i.Lock()
70
-	defer i.Unlock()
69
+	i.mu.Lock()
70
+	defer i.mu.Unlock()
71 71
 
72 72
 	return types.GetMacCopy(i.mac)
73 73
 }
74 74
 
75 75
 func (i *nwIface) Address() *net.IPNet {
76
-	i.Lock()
77
-	defer i.Unlock()
76
+	i.mu.Lock()
77
+	defer i.mu.Unlock()
78 78
 
79 79
 	return types.GetIPNetCopy(i.address)
80 80
 }
81 81
 
82 82
 func (i *nwIface) AddressIPv6() *net.IPNet {
83
-	i.Lock()
84
-	defer i.Unlock()
83
+	i.mu.Lock()
84
+	defer i.mu.Unlock()
85 85
 
86 86
 	return types.GetIPNetCopy(i.addressIPv6)
87 87
 }
88 88
 
89 89
 func (i *nwIface) LinkLocalAddresses() []*net.IPNet {
90
-	i.Lock()
91
-	defer i.Unlock()
90
+	i.mu.Lock()
91
+	defer i.mu.Unlock()
92 92
 
93 93
 	return i.llAddrs
94 94
 }
95 95
 
96 96
 func (i *nwIface) Routes() []*net.IPNet {
97
-	i.Lock()
98
-	defer i.Unlock()
97
+	i.mu.Lock()
98
+	defer i.mu.Unlock()
99 99
 
100 100
 	routes := make([]*net.IPNet, len(i.routes))
101 101
 	for index, route := range i.routes {
... ...
@@ -120,9 +120,9 @@ func (n *networkNamespace) Interfaces() []Interface {
120 120
 }
121 121
 
122 122
 func (i *nwIface) Remove() error {
123
-	i.Lock()
123
+	i.mu.Lock()
124 124
 	n := i.ns
125
-	i.Unlock()
125
+	i.mu.Unlock()
126 126
 
127 127
 	n.Lock()
128 128
 	isDefault := n.isDefault
... ...
@@ -175,9 +175,9 @@ func (i *nwIface) Remove() error {
175 175
 
176 176
 // Returns the sandbox's side veth interface statistics
177 177
 func (i *nwIface) Statistics() (*types.InterfaceStatistics, error) {
178
-	i.Lock()
178
+	i.mu.Lock()
179 179
 	n := i.ns
180
-	i.Unlock()
180
+	i.mu.Unlock()
181 181
 
182 182
 	l, err := n.nlHandle.LinkByName(i.DstName())
183 183
 	if err != nil {