code: func (s *PortManager) ReservePort(networks []tcpip.NetworkProtocolNumber, transport tcpip.TransportProtocolNumber, addr tcpip.Address, port uint16, reuse bool) (reservedPort uint16, err *tcpip.Error) {
  	s.mu.Lock()
  	defer s.mu.Unlock()
  
  	// If a port is specified, just try to reserve it for all network
  	// protocols.
  	if port != 0 {
  		if !s.reserveSpecificPort(networks, transport, addr, port, reuse) {
  			return 0, tcpip.ErrPortInUse
  		}
  		return port, nil
  	}
  
  	// A port wasn't specified, so try to find one.
  	return s.PickEphemeralPort(func(p uint16) (bool, *tcpip.Error) {
  		return s.reserveSpecificPort(networks, transport, addr, p, reuse), nil
  	})
  }
docs: // ReservePort marks a port/IP combination as reserved so that it cannot be
  // reserved by another endpoint. If port is zero, ReservePort will search for
  // an unreserved ephemeral port and reserve it, returning its value in the
  // "port" return value.