Browse code

libnetwork/osl: nwIface: add godoc

Copy the godoc from the interface to the implementation.

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

Sebastiaan van Stijn authored on 2023/08/09 05:51:11
Showing 1 changed files
... ...
@@ -14,6 +14,11 @@ import (
14 14
 	"github.com/vishvananda/netns"
15 15
 )
16 16
 
17
+// nwIface represents the settings and identity of a network device.
18
+// It is used as a return type for Network.Link, and it is common practice
19
+// for the caller to use this information when moving interface SrcName from
20
+// host namespace to DstName in a different net namespace with the appropriate
21
+// network settings.
17 22
 type nwIface struct {
18 23
 	srcName     string
19 24
 	dstName     string
... ...
@@ -28,10 +33,15 @@ type nwIface struct {
28 28
 	ns          *networkNamespace
29 29
 }
30 30
 
31
+// SrcName returns the name of the interface in the origin network namespace.
31 32
 func (i *nwIface) SrcName() string {
32 33
 	return i.srcName
33 34
 }
34 35
 
36
+// DstName returns the name that will be assigned to the interface once
37
+// moved inside a network namespace. When the caller passes in a DstName,
38
+// it is only expected to pass a prefix. The name will be modified with an
39
+// auto-generated suffix.
35 40
 func (i *nwIface) DstName() string {
36 41
 	return i.dstName
37 42
 }
... ...
@@ -40,10 +50,12 @@ func (i *nwIface) DstMaster() string {
40 40
 	return i.dstMaster
41 41
 }
42 42
 
43
+// Bridge returns true if the interface is a bridge.
43 44
 func (i *nwIface) Bridge() bool {
44 45
 	return i.bridge
45 46
 }
46 47
 
48
+// Master returns the srcname of the master interface for this interface.
47 49
 func (i *nwIface) Master() string {
48 50
 	return i.master
49 51
 }
... ...
@@ -52,18 +64,23 @@ func (i *nwIface) MacAddress() net.HardwareAddr {
52 52
 	return types.GetMacCopy(i.mac)
53 53
 }
54 54
 
55
+// Address returns the IPv4 address for the interface.
55 56
 func (i *nwIface) Address() *net.IPNet {
56 57
 	return types.GetIPNetCopy(i.address)
57 58
 }
58 59
 
60
+// AddressIPv6 returns the IPv6 address for the interface.
59 61
 func (i *nwIface) AddressIPv6() *net.IPNet {
60 62
 	return types.GetIPNetCopy(i.addressIPv6)
61 63
 }
62 64
 
65
+// LinkLocalAddresses returns the link-local IP addresses assigned to the
66
+// interface.
63 67
 func (i *nwIface) LinkLocalAddresses() []*net.IPNet {
64 68
 	return i.llAddrs
65 69
 }
66 70
 
71
+// Routes returns IP routes for the interface.
67 72
 func (i *nwIface) Routes() []*net.IPNet {
68 73
 	routes := make([]*net.IPNet, len(i.routes))
69 74
 	for index, route := range i.routes {
... ...
@@ -73,6 +90,8 @@ func (i *nwIface) Routes() []*net.IPNet {
73 73
 	return routes
74 74
 }
75 75
 
76
+// Remove an interface from the sandbox by renaming to original name
77
+// and moving it out of the sandbox.
76 78
 func (i *nwIface) Remove() error {
77 79
 	i.ns.Lock()
78 80
 	isDefault := i.ns.isDefault
... ...
@@ -123,7 +142,7 @@ func (i *nwIface) Remove() error {
123 123
 	return nil
124 124
 }
125 125
 
126
-// Returns the sandbox's side veth interface statistics
126
+// Statistics returns the sandbox's side veth interface statistics.
127 127
 func (i *nwIface) Statistics() (*types.InterfaceStatistics, error) {
128 128
 	l, err := i.ns.nlHandle.LinkByName(i.DstName())
129 129
 	if err != nil {