mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
roll forward cl/558267882
This change is correct regardless of the rolled-back changes to IP address selection. PiperOrigin-RevId: 572061466
This commit is contained in:
committed by
gVisor bot
parent
79da11aa57
commit
b3de4851a6
@@ -725,20 +725,31 @@ func TestDualWriteConnectedToV4Mapped(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPreflightBindsEndpoint(t *testing.T) {
|
||||
protocols := map[string]tcpip.NetworkProtocolNumber{
|
||||
"ipv4": ipv4.ProtocolNumber,
|
||||
"ipv6": ipv6.ProtocolNumber,
|
||||
tcs := []struct {
|
||||
name string
|
||||
proto tcpip.NetworkProtocolNumber
|
||||
flow context.TestFlow
|
||||
}{
|
||||
{
|
||||
name: "ipv4",
|
||||
proto: ipv4.ProtocolNumber,
|
||||
flow: context.UnicastV4,
|
||||
},
|
||||
{
|
||||
name: "ipv6",
|
||||
proto: ipv6.ProtocolNumber,
|
||||
flow: context.UnicastV6,
|
||||
},
|
||||
}
|
||||
for name, ipProtocolNumber := range protocols {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
for _, tc := range tcs {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
c := context.New(t, []stack.TransportProtocolFactory{udp.NewProtocol})
|
||||
defer c.Cleanup()
|
||||
|
||||
c.CreateEndpoint(ipProtocolNumber, udp.ProtocolNumber)
|
||||
c.CreateEndpoint(tc.proto, udp.ProtocolNumber)
|
||||
|
||||
flow := context.UnicastV6
|
||||
h := flow.MakeHeader4Tuple(context.Outgoing)
|
||||
writeDstAddr := flow.MapAddrIfApplicable(h.Dst.Addr)
|
||||
h := tc.flow.MakeHeader4Tuple(context.Outgoing)
|
||||
writeDstAddr := tc.flow.MapAddrIfApplicable(h.Dst.Addr)
|
||||
writeOpts := tcpip.WriteOptions{
|
||||
To: &tcpip.FullAddress{Addr: writeDstAddr, Port: h.Dst.Port},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user