A federal court of appeals has upheld the right of Texas to defend itself against illegal immigration by erecting a barrier in the Rio Grande River.