summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--pkg/dhcp/dhcp_test.go2
-rw-r--r--pkg/tcpip/adapters/gonet/gonet_test.go4
-rw-r--r--pkg/tcpip/network/ipv6/icmp_test.go4
-rw-r--r--pkg/tcpip/sample/tun_tcp_echo/main.go2
-rw-r--r--pkg/tcpip/tcpip.go2
-rw-r--r--pkg/tcpip/tcpip_test.go2
-rw-r--r--runsc/boot/network.go8
7 files changed, 15 insertions, 9 deletions
diff --git a/pkg/dhcp/dhcp_test.go b/pkg/dhcp/dhcp_test.go
index a187c5c2a..d60e3752b 100644
--- a/pkg/dhcp/dhcp_test.go
+++ b/pkg/dhcp/dhcp_test.go
@@ -57,7 +57,7 @@ func createStack(t *testing.T) *stack.Stack {
s.SetRouteTable([]tcpip.Route{{
Destination: tcpip.Address(strings.Repeat("\x00", 4)),
- Mask: tcpip.Address(strings.Repeat("\x00", 4)),
+ Mask: tcpip.AddressMask(strings.Repeat("\x00", 4)),
Gateway: "",
NIC: nicid,
}})
diff --git a/pkg/tcpip/adapters/gonet/gonet_test.go b/pkg/tcpip/adapters/gonet/gonet_test.go
index 86a82f21d..79b7c77ee 100644
--- a/pkg/tcpip/adapters/gonet/gonet_test.go
+++ b/pkg/tcpip/adapters/gonet/gonet_test.go
@@ -68,7 +68,7 @@ func newLoopbackStack() (*stack.Stack, *tcpip.Error) {
// IPv4
{
Destination: tcpip.Address(strings.Repeat("\x00", 4)),
- Mask: tcpip.Address(strings.Repeat("\x00", 4)),
+ Mask: tcpip.AddressMask(strings.Repeat("\x00", 4)),
Gateway: "",
NIC: NICID,
},
@@ -76,7 +76,7 @@ func newLoopbackStack() (*stack.Stack, *tcpip.Error) {
// IPv6
{
Destination: tcpip.Address(strings.Repeat("\x00", 16)),
- Mask: tcpip.Address(strings.Repeat("\x00", 16)),
+ Mask: tcpip.AddressMask(strings.Repeat("\x00", 16)),
Gateway: "",
NIC: NICID,
},
diff --git a/pkg/tcpip/network/ipv6/icmp_test.go b/pkg/tcpip/network/ipv6/icmp_test.go
index b8e53c13e..fabbdc8c7 100644
--- a/pkg/tcpip/network/ipv6/icmp_test.go
+++ b/pkg/tcpip/network/ipv6/icmp_test.go
@@ -108,14 +108,14 @@ func newTestContext(t *testing.T) *testContext {
c.s0.SetRouteTable(
[]tcpip.Route{{
Destination: lladdr1,
- Mask: tcpip.Address(strings.Repeat("\xff", 16)),
+ Mask: tcpip.AddressMask(strings.Repeat("\xff", 16)),
NIC: 1,
}},
)
c.s1.SetRouteTable(
[]tcpip.Route{{
Destination: lladdr0,
- Mask: tcpip.Address(strings.Repeat("\xff", 16)),
+ Mask: tcpip.AddressMask(strings.Repeat("\xff", 16)),
NIC: 1,
}},
)
diff --git a/pkg/tcpip/sample/tun_tcp_echo/main.go b/pkg/tcpip/sample/tun_tcp_echo/main.go
index a4b28a7a3..910d1257f 100644
--- a/pkg/tcpip/sample/tun_tcp_echo/main.go
+++ b/pkg/tcpip/sample/tun_tcp_echo/main.go
@@ -150,7 +150,7 @@ func main() {
s.SetRouteTable([]tcpip.Route{
{
Destination: tcpip.Address(strings.Repeat("\x00", len(addr))),
- Mask: tcpip.Address(strings.Repeat("\x00", len(addr))),
+ Mask: tcpip.AddressMask(strings.Repeat("\x00", len(addr))),
Gateway: "",
NIC: 1,
},
diff --git a/pkg/tcpip/tcpip.go b/pkg/tcpip/tcpip.go
index 5f210cdd0..f5b5ec86b 100644
--- a/pkg/tcpip/tcpip.go
+++ b/pkg/tcpip/tcpip.go
@@ -490,7 +490,7 @@ type Route struct {
// Mask specifies which bits of the Destination and the target address
// must match for this row to be viable.
- Mask Address
+ Mask AddressMask
// Gateway is the gateway to be used if this row is viable.
Gateway Address
diff --git a/pkg/tcpip/tcpip_test.go b/pkg/tcpip/tcpip_test.go
index 9b20c74c6..d283f71c7 100644
--- a/pkg/tcpip/tcpip_test.go
+++ b/pkg/tcpip/tcpip_test.go
@@ -123,7 +123,7 @@ func TestSubnetCreation(t *testing.T) {
func TestRouteMatch(t *testing.T) {
tests := []struct {
d Address
- m Address
+ m AddressMask
a Address
want bool
}{
diff --git a/runsc/boot/network.go b/runsc/boot/network.go
index 0e43c91be..6a2678ac9 100644
--- a/runsc/boot/network.go
+++ b/runsc/boot/network.go
@@ -86,7 +86,7 @@ func (r *Route) toTcpipRoute(id tcpip.NICID) tcpip.Route {
return tcpip.Route{
Destination: ipToAddress(r.Destination),
Gateway: ipToAddress(r.Gateway),
- Mask: ipToAddress(net.IP(r.Mask)),
+ Mask: ipToAddressMask(net.IP(r.Mask)),
NIC: id,
}
}
@@ -203,6 +203,12 @@ func ipToAddress(ip net.IP) tcpip.Address {
return addr
}
+// ipToAddressMask converts IP to tcpip.AddressMask, ignoring the protocol.
+func ipToAddressMask(ip net.IP) tcpip.AddressMask {
+ _, addr := ipToAddressAndProto(ip)
+ return tcpip.AddressMask(addr)
+}
+
// generateRndMac returns a random local MAC address.
// Copied from eth_random_addr() (include/linux/etherdevice.h)
func generateRndMac() net.HardwareAddr {