Stability of ion-acoustic cnoidal and solitary waves in a magnetized plasma