diff options
author | gVisor bot <gvisor-bot@google.com> | 2019-10-24 18:13:10 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-10-24 18:13:10 +0000 |
commit | 782033599ceb550b1fe97c2e0bd2cfafd025ccaf (patch) | |
tree | b503e999dff3cdd54944ec6a6f7f37d1802e0b8f /pkg/tcpip/stack/nic.go | |
parent | 370b2fd53e7d93d0af7a4fc36e1ed3edffb8246b (diff) | |
parent | f034790ad8c0af42bf510f6c9763e599ac64192d (diff) |
Merge release-20190806.1-319-gf034790 (automated)
Diffstat (limited to 'pkg/tcpip/stack/nic.go')
-rw-r--r-- | pkg/tcpip/stack/nic.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/pkg/tcpip/stack/nic.go b/pkg/tcpip/stack/nic.go index 2d29fa88e..a867f8c00 100644 --- a/pkg/tcpip/stack/nic.go +++ b/pkg/tcpip/stack/nic.go @@ -46,6 +46,10 @@ type NIC struct { stats NICStats + // ndp is the NDP related state for NIC. + // + // Note, read and write operations on ndp require that the NIC is + // appropriately locked. ndp ndpState } @@ -80,6 +84,7 @@ const ( NeverPrimaryEndpoint ) +// newNIC returns a new NIC using the default NDP configurations from stack. func newNIC(stack *Stack, id tcpip.NICID, name string, ep LinkEndpoint, loopback bool) *NIC { // TODO(b/141011931): Validate a LinkEndpoint (ep) is valid. For // example, make sure that the link address it provides is a valid @@ -105,7 +110,8 @@ func newNIC(stack *Stack, id tcpip.NICID, name string, ep LinkEndpoint, loopback }, }, ndp: ndpState{ - dad: make(map[tcpip.Address]dadState), + configs: stack.ndpConfigs, + dad: make(map[tcpip.Address]dadState), }, } nic.ndp.nic = nic @@ -937,6 +943,18 @@ func (n *NIC) dupTentativeAddrDetected(addr tcpip.Address) *tcpip.Error { return n.removePermanentAddressLocked(addr) } +// setNDPConfigs sets the NDP configurations for n. +// +// Note, if c contains invalid NDP configuration values, it will be fixed to +// use default values for the erroneous values. +func (n *NIC) setNDPConfigs(c NDPConfigurations) { + c.validate() + + n.mu.Lock() + n.ndp.configs = c + n.mu.Unlock() +} + type networkEndpointKind int32 const ( |