Correct the loopback detection logic. Provided by Gilles, reviewed by rhc, RM-approved