Racism is the belief, or acting on the belief, that your race is superior. That is not the motivation behind this discrimination, therefore it is not racism.
Discrimination is not inherently wrong. It always depends on context.
You might say lying is wrong. I might agree with you, generally. But if you were in Germany in the 1940’s and lied to protect a family from being killed for their race, did you make the wrong choice? Of course not.