summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/sample/tun_tcp_connect
diff options
context:
space:
mode:
authorTony Gong <gongt@google.com>2021-09-15 14:57:10 -0700
committergVisor bot <gvisor-bot@google.com>2021-09-15 15:00:01 -0700
commit8b56b6b83b86009191587c86e134d6c924834831 (patch)
tree2f2b066624bdc02b570f2027235299e419304013 /pkg/tcpip/sample/tun_tcp_connect
parent149ca009678edc580de9f0b1d54f551d376742cb (diff)
Pass address properties in a single struct
Replaced the current AddAddressWithOptions method with AddAddressWithProperties which passes all address properties in a single AddressProperties type. More properties that need to be configured in the future are expected, so adding a type makes adding them easier. PiperOrigin-RevId: 396930729
Diffstat (limited to 'pkg/tcpip/sample/tun_tcp_connect')
-rw-r--r--pkg/tcpip/sample/tun_tcp_connect/main.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/pkg/tcpip/sample/tun_tcp_connect/main.go b/pkg/tcpip/sample/tun_tcp_connect/main.go
index 009cab643..05b879543 100644
--- a/pkg/tcpip/sample/tun_tcp_connect/main.go
+++ b/pkg/tcpip/sample/tun_tcp_connect/main.go
@@ -146,8 +146,12 @@ func main() {
log.Fatal(err)
}
- if err := s.AddAddress(1, ipv4.ProtocolNumber, addr); err != nil {
- log.Fatal(err)
+ protocolAddr := tcpip.ProtocolAddress{
+ Protocol: ipv4.ProtocolNumber,
+ AddressWithPrefix: addr.WithPrefix(),
+ }
+ if err := s.AddProtocolAddress(1, protocolAddr, stack.AddressProperties{}); err != nil {
+ log.Fatalf("AddProtocolAddress(%d, %+v, {}): %s", 1, protocolAddr, err)
}
// Add default route.