sandbox_run: skip sctp protocol hostport mapping
ref
@@ -114,17 +114,20 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest
}
func convertPortMappings(in []*pb.PortMapping) []*hostport.PortMapping {
- if in == nil {
- return nil
+ var out []*hostport.PortMapping
+ for _, v := range in {
+ if v.HostPort <= 0 {
+ continue
+ }
+ if v.Protocol != pb.Protocol_TCP && v.Protocol != pb.Protocol_UDP {
+ continue
}
- out := make([]*hostport.PortMapping, len(in))
- for i, v := range in {
- out[i] = &hostport.PortMapping{
+ out = append(out, &hostport.PortMapping{
HostPort: v.HostPort,
ContainerPort: v.ContainerPort,
Protocol: v1.Protocol(v.Protocol.String()),
HostIP: v.HostIp,
- }
+ })
}
return out
}
