From f11b0e6d696429aae78eded6f3ab6c2429d75e49 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Wed, 18 Sep 2024 15:02:00 +0200 Subject: [PATCH] port/builtin: return proper error for sctp When trying to forward sctp port we get a useless "rootlessport spec was not validated" error back even though the spec was validated before. It is not clear to me if other drivers support sctp here so I didn't want to change ValidatePortSpec to disallow sctp. As such simply return a useful error saying the protocol is not supported. Signed-off-by: Paul Holzinger --- pkg/port/builtin/parent/parent.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/port/builtin/parent/parent.go b/pkg/port/builtin/parent/parent.go index 80a17cc9..5954f184 100644 --- a/pkg/port/builtin/parent/parent.go +++ b/pkg/port/builtin/parent/parent.go @@ -159,8 +159,7 @@ func (d *driver) AddPort(ctx context.Context, spec port.Spec) (*port.Status, err case "udp", "udp4", "udp6": err = udp.Run(d.socketPath, spec, routineStopCh, routineStoppedCh, d.logWriter) default: - // NOTREACHED - return nil, errors.New("spec was not validated?") + return nil, fmt.Errorf("unsupported port protocol %s", spec.Proto) } if err != nil { if isEPERM(err) {