Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit f540c2a

Browse files
committed
Skip sctp protocol hostport mapping.
Signed-off-by: Lantao Liu <[email protected]>
1 parent 0470309 commit f540c2a

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

pkg/server/sandbox_run.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,9 @@ func toCNIPortMappings(criPortMappings []*runtime.PortMapping) []cni.PortMapping
558558
if mapping.HostPort <= 0 {
559559
continue
560560
}
561+
if mapping.Protocol != runtime.Protocol_TCP && mapping.Protocol != runtime.Protocol_UDP {
562+
continue
563+
}
561564
portMappings = append(portMappings, cni.PortMapping{
562565
HostPort: mapping.HostPort,
563566
ContainerPort: mapping.ContainerPort,

pkg/server/sandbox_run_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,30 @@ func TestToCNIPortMappings(t *testing.T) {
403403
},
404404
},
405405
},
406+
"CRI port mapping with unsupported protocol should be skipped": {
407+
criPortMappings: []*runtime.PortMapping{
408+
{
409+
Protocol: runtime.Protocol_SCTP,
410+
ContainerPort: 1234,
411+
HostPort: 5678,
412+
HostIp: "123.124.125.126",
413+
},
414+
{
415+
Protocol: runtime.Protocol_TCP,
416+
ContainerPort: 4321,
417+
HostPort: 8765,
418+
HostIp: "126.125.124.123",
419+
},
420+
},
421+
cniPortMappings: []cni.PortMapping{
422+
{
423+
HostPort: 8765,
424+
ContainerPort: 4321,
425+
Protocol: "tcp",
426+
HostIP: "126.125.124.123",
427+
},
428+
},
429+
},
406430
} {
407431
t.Logf("TestCase %q", desc)
408432
assert.Equal(t, test.cniPortMappings, toCNIPortMappings(test.criPortMappings))

0 commit comments

Comments
 (0)