CO excitation and H2 masses of infrared-luminous galaxies