But don't you think the motivation for favouring your race/country/tribe/religion is often very similar to that of favouring your family or your friends? Maybe there are counterexamples when it's really about resentment and symbolic superiority and whatnot, but I don't think actionable definition should be based that much on intention, or purity of the heart, or how much negative thoughts you had about the discriminatee, when the outcome is the same.
First, you can of course do "bad discrimination" when it comes to favouring your family and friends. That's for example the case with nepotism.
But, I don't know about you, but when I do something nice for my family or my friends, I don't have them compete with non-family or non-friend in my head. I'm never in a situation where I think "oh, X will get this, but I prefer to have my friend having this". This is a horrible situation: friendship is not a zero-sum competition where you reward your friends and punish your non-friends.
If I have the choice of giving a job to my friend or to a foreigner, I will give the job to the most qualified.
And, yes, I can "favour" my country: for example, I may support a national sport team. No discrimination there. But if I have to make a choice between two countries that deserve it equally and that this decision has bad consequence for one country, I will certainly not pick the country I like the most just because I like it the most.
So, again: there are "ok discrimination" and "bad discrimination", both can be about country/family/...