daemon/libnetwork/types: remove TransportPort.Equal()

The `TransporPort` type is comparable; it doesn't have fields that
require special handling. It's defined as;

    // TransportPort represents a local Layer 4 endpoint
    type TransportPort struct {
        Proto Protocol
        Port  uint16
    }

where `Protocol` is an int (with a stringer interface);

    type Protocol uint8

So we can remove the `Equal` method, and simplify places where it's
compared.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-08-10 19:58:46 +02:00
parent 561e14ea3f
commit 1e11e64c9c
3 changed files with 2 additions and 25 deletions

View File

@@ -158,15 +158,9 @@ func compareConnConfig(a, b *connectivityConfiguration) bool {
if a == nil || b == nil {
return false
}
if len(a.ExposedPorts) != len(b.ExposedPorts) ||
len(a.PortBindings) != len(b.PortBindings) {
if !slices.Equal(a.ExposedPorts, b.ExposedPorts) {
return false
}
for i := 0; i < len(a.ExposedPorts); i++ {
if !a.ExposedPorts[i].Equal(&b.ExposedPorts[i]) {
return false
}
}
for i := 0; i < len(a.PortBindings); i++ {
if !comparePortBinding(&a.PortBindings[i].PortBinding, &b.PortBindings[i].PortBinding) {
return false

View File

@@ -154,7 +154,7 @@ func matchLink(l stubFirewallerLink, parentIP, childIP netip.Addr, ports []types
return false
}
for i, p := range l.ports {
if !p.Equal(&ports[i]) {
if p != ports[i] {
return false
}
}

View File

@@ -43,23 +43,6 @@ type TransportPort struct {
Port uint16
}
// Equal checks if this instance of TransportPort is equal to the passed one
func (t *TransportPort) Equal(o *TransportPort) bool {
if t == o {
return true
}
if o == nil {
return false
}
if t.Proto != o.Proto || t.Port != o.Port {
return false
}
return true
}
// String returns the TransportPort structure in string form
func (t *TransportPort) String() string {
return fmt.Sprintf("%s/%d", t.Proto.String(), t.Port)