--- contrib/sendmail/src/conf.c
+++ contrib/sendmail/src/conf.c
@@ -44,6 +44,8 @@
 #if STARTTLS
 # include "tls.h"
 #endif
+#define	MYLOOP_MASKLEN 24
+#define	IN_MY_LOOP(i) (((in_addr_t)(i) & (0xFFFFFFFF << (32 - MYLOOP_MASKLEN))) == (127 << 24))
 
 static void	setupmaps __P((void));
 static void	setupmailers __P((void));
@@ -5290,8 +5292,7 @@
 	SOCKADDR sa;
 {
 	/* XXX how to correctly extract IN_LOOPBACKNET part? */
-#define SM_IS_IPV4_LOOP(a) (((ntohl(a) & IN_CLASSA_NET) \
-	     >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET)
+#define SM_IS_IPV4_LOOP(a) IN_MY_LOOP(ntohl(a))
 #if NETINET6
 	if (sa.sa.sa_family == AF_INET6 &&
 	    IN6_IS_ADDR_V4MAPPED(&sa.sin6.sin6_addr) &&