netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-2.6.25 1/8] Create ipv4_is_<type>(__be32 addr) functions
       [not found] <e2ebcbf24539c0a3ef2ac77147dbfa55d8ac9e33.1197432867.git.joe@perches.com>
  2007-12-13 23:38 ` [PATCH net-2.6.25 1/8] Create ipv4_is_<type>(__be32 addr) functions Joe Perches
@ 2007-12-13 23:38 ` Joe Perches
  2007-12-16 21:42   ` David Miller
  2007-12-17 22:37   ` Jan Engelhardt
       [not found] ` <40bae850207de9257479a535ea5ab4e7d1cdeab5.1197432867.git.joe@perches.com>
                   ` (6 subsequent siblings)
  8 siblings, 2 replies; 31+ messages in thread
From: Joe Perches @ 2007-12-13 23:38 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel

Change IPV4 specific macros LOOPBACK MULTICAST LOCAL_MCAST BADCLASS and ZERONET
macros to inline functions ipv4_is_<type>(__be32 addr)

Adds type safety and arguably some readability.

Changes since last submission:

Removed ipv4_addr_octets function
Used hex constants
Converted recently added rfc3330 macros

Signed-off-by: Joe Perches <joe@perches.com>
---
 include/linux/in.h |   87 ++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 74 insertions(+), 13 deletions(-)

diff --git a/include/linux/in.h b/include/linux/in.h
index a8f00ca..f8d6073 100644
--- a/include/linux/in.h
+++ b/include/linux/in.h
@@ -246,21 +246,82 @@ struct sockaddr_in {
 #include <asm/byteorder.h> 
 
 #ifdef __KERNEL__
-/* Some random defines to make it easier in the kernel.. */
-#define LOOPBACK(x)	(((x) & htonl(0xff000000)) == htonl(0x7f000000))
-#define MULTICAST(x)	(((x) & htonl(0xf0000000)) == htonl(0xe0000000))
-#define BADCLASS(x)	(((x) & htonl(0xf0000000)) == htonl(0xf0000000))
-#define ZERONET(x)	(((x) & htonl(0xff000000)) == htonl(0x00000000))
-#define LOCAL_MCAST(x)	(((x) & htonl(0xFFFFFF00)) == htonl(0xE0000000))
+
+static inline bool ipv4_is_loopback(__be32 addr)
+{
+	return (addr & htonl(0xff000000)) == htonl(0x7f000000);
+}
+
+static inline bool ipv4_is_multicast(__be32 addr)
+{
+	return (addr & htonl(0xf0000000)) == htonl(0xe0000000);
+}
+
+static inline bool ipv4_is_local_multicast(__be32 addr)
+{
+	return (addr & htonl(0xffffff00)) == htonl(0xe0000000);
+}
+
+static inline bool ipv4_is_badclass(__be32 addr)
+{
+	return (addr & htonl(0xf0000000)) == htonl(0xf0000000);
+}
+
+static inline bool ipv4_is_zeronet(__be32 addr)
+{
+	return (addr & htonl(0xff000000)) == htonl(0x00000000);
+}
+
+#define LOOPBACK(x)		ipv4_is_loopback(x)
+#define MULTICAST(x)		ipv4_is_multicast(x)
+#define BADCLASS(x)		ipv4_is_badclass(x)
+#define ZERONET(x)		ipv4_is_zeronet(x)
+#define LOCAL_MCAST(x)		ipv4_is_local_multicast(x)
 
 /* Special-Use IPv4 Addresses (RFC3330) */
-#define PRIVATE_10(x)	(((x) & htonl(0xff000000)) == htonl(0x0A000000))
-#define LINKLOCAL_169(x) (((x) & htonl(0xffff0000)) == htonl(0xA9FE0000))
-#define PRIVATE_172(x)	(((x) & htonl(0xfff00000)) == htonl(0xAC100000))
-#define TEST_192(x)	(((x) & htonl(0xffffff00)) == htonl(0xC0000200))
-#define ANYCAST_6TO4(x)	(((x) & htonl(0xffffff00)) == htonl(0xC0586300))
-#define PRIVATE_192(x)	(((x) & htonl(0xffff0000)) == htonl(0xC0A80000))
-#define TEST_198(x)	(((x) & htonl(0xfffe0000)) == htonl(0xC6120000))
+
+static inline bool ipv4_is_private_10(__be32 addr)
+{
+	return (addr & htonl(0xff000000)) == htonl(0x0a000000);
+}
+
+static inline bool ipv4_is_private_172(__be32 addr)
+{
+	return (addr & htonl(0xfff00000)) == htonl(0xac100000);
+}
+
+static inline bool ipv4_is_private_192(__be32 addr)
+{
+	return (addr & htonl(0xffff0000)) == htonl(0xc0a80000);
+}
+
+static inline bool ipv4_is_linklocal_169(__be32 addr)
+{
+	return (addr & htonl(0xffff0000)) == htonl(0xa9fe0000);
+}
+
+static inline bool ipv4_is_anycast_6to4(__be32 addr)
+{
+	return (addr & htonl(0xffffff00)) == htonl(0xc0586300);
+}
+
+static inline bool ipv4_is_test_192(__be32 addr)
+{
+	return (addr & htonl(0xffffff00)) == htonl(0xc0000200);
+}
+
+static inline bool ipv4_is_test_198(__be32 addr)
+{
+	return (addr & htonl(0xfffe0000)) == htonl(0xc6120000);
+}
 #endif
 
+#define PRIVATE_10(x)		ipv4_is_private_10(x)
+#define LINKLOCAL_169(x)	ipv4_is_linklocal_169(x)
+#define PRIVATE_172(x)		ipv4_is_private_172(x)
+#define TEST_192(x)		ipv4_is_test_192(x)
+#define ANYCAST_6TO4(x)		ipv4_is_anycast_6to4(x)
+#define PRIVATE_192(x)		ipv4_is_private_192(x)
+#define TEST_198(x)		ipv4_is_test_198(x)
+
 #endif	/* _LINUX_IN_H */
-- 
1.5.3.7.949.g2221a6


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH net-2.6.25 1/8] Create ipv4_is_<type>(__be32 addr) functions
       [not found] <e2ebcbf24539c0a3ef2ac77147dbfa55d8ac9e33.1197432867.git.joe@perches.com>
@ 2007-12-13 23:38 ` Joe Perches
  2007-12-13 23:38 ` Joe Perches
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 31+ messages in thread
From: Joe Perches @ 2007-12-13 23:38 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel

Change IPV4 specific macros LOOPBACK MULTICAST LOCAL_MCAST BADCLASS and ZERONET
macros to inline functions ipv4_is_<type>(__be32 addr)

Adds type safety and arguably some readability.

Changes since last submission:

Removed ipv4_addr_octets function
Used hex constants
Converted recently added rfc3330 macros

Signed-off-by: Joe Perches <joe@perches.com>
---
 include/linux/in.h |   87 ++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 74 insertions(+), 13 deletions(-)

diff --git a/include/linux/in.h b/include/linux/in.h
index a8f00ca..f8d6073 100644
--- a/include/linux/in.h
+++ b/include/linux/in.h
@@ -246,21 +246,82 @@ struct sockaddr_in {
 #include <asm/byteorder.h> 
 
 #ifdef __KERNEL__
-/* Some random defines to make it easier in the kernel.. */
-#define LOOPBACK(x)	(((x) & htonl(0xff000000)) == htonl(0x7f000000))
-#define MULTICAST(x)	(((x) & htonl(0xf0000000)) == htonl(0xe0000000))
-#define BADCLASS(x)	(((x) & htonl(0xf0000000)) == htonl(0xf0000000))
-#define ZERONET(x)	(((x) & htonl(0xff000000)) == htonl(0x00000000))
-#define LOCAL_MCAST(x)	(((x) & htonl(0xFFFFFF00)) == htonl(0xE0000000))
+
+static inline bool ipv4_is_loopback(__be32 addr)
+{
+	return (addr & htonl(0xff000000)) == htonl(0x7f000000);
+}
+
+static inline bool ipv4_is_multicast(__be32 addr)
+{
+	return (addr & htonl(0xf0000000)) == htonl(0xe0000000);
+}
+
+static inline bool ipv4_is_local_multicast(__be32 addr)
+{
+	return (addr & htonl(0xffffff00)) == htonl(0xe0000000);
+}
+
+static inline bool ipv4_is_badclass(__be32 addr)
+{
+	return (addr & htonl(0xf0000000)) == htonl(0xf0000000);
+}
+
+static inline bool ipv4_is_zeronet(__be32 addr)
+{
+	return (addr & htonl(0xff000000)) == htonl(0x00000000);
+}
+
+#define LOOPBACK(x)		ipv4_is_loopback(x)
+#define MULTICAST(x)		ipv4_is_multicast(x)
+#define BADCLASS(x)		ipv4_is_badclass(x)
+#define ZERONET(x)		ipv4_is_zeronet(x)
+#define LOCAL_MCAST(x)		ipv4_is_local_multicast(x)
 
 /* Special-Use IPv4 Addresses (RFC3330) */
-#define PRIVATE_10(x)	(((x) & htonl(0xff000000)) == htonl(0x0A000000))
-#define LINKLOCAL_169(x) (((x) & htonl(0xffff0000)) == htonl(0xA9FE0000))
-#define PRIVATE_172(x)	(((x) & htonl(0xfff00000)) == htonl(0xAC100000))
-#define TEST_192(x)	(((x) & htonl(0xffffff00)) == htonl(0xC0000200))
-#define ANYCAST_6TO4(x)	(((x) & htonl(0xffffff00)) == htonl(0xC0586300))
-#define PRIVATE_192(x)	(((x) & htonl(0xffff0000)) == htonl(0xC0A80000))
-#define TEST_198(x)	(((x) & htonl(0xfffe0000)) == htonl(0xC6120000))
+
+static inline bool ipv4_is_private_10(__be32 addr)
+{
+	return (addr & htonl(0xff000000)) == htonl(0x0a000000);
+}
+
+static inline bool ipv4_is_private_172(__be32 addr)
+{
+	return (addr & htonl(0xfff00000)) == htonl(0xac100000);
+}
+
+static inline bool ipv4_is_private_192(__be32 addr)
+{
+	return (addr & htonl(0xffff0000)) == htonl(0xc0a80000);
+}
+
+static inline bool ipv4_is_linklocal_169(__be32 addr)
+{
+	return (addr & htonl(0xffff0000)) == htonl(0xa9fe0000);
+}
+
+static inline bool ipv4_is_anycast_6to4(__be32 addr)
+{
+	return (addr & htonl(0xffffff00)) == htonl(0xc0586300);
+}
+
+static inline bool ipv4_is_test_192(__be32 addr)
+{
+	return (addr & htonl(0xffffff00)) == htonl(0xc0000200);
+}
+
+static inline bool ipv4_is_test_198(__be32 addr)
+{
+	return (addr & htonl(0xfffe0000)) == htonl(0xc6120000);
+}
 #endif
 
+#define PRIVATE_10(x)		ipv4_is_private_10(x)
+#define LINKLOCAL_169(x)	ipv4_is_linklocal_169(x)
+#define PRIVATE_172(x)		ipv4_is_private_172(x)
+#define TEST_192(x)		ipv4_is_test_192(x)
+#define ANYCAST_6TO4(x)		ipv4_is_anycast_6to4(x)
+#define PRIVATE_192(x)		ipv4_is_private_192(x)
+#define TEST_198(x)		ipv4_is_test_198(x)
+
 #endif	/* _LINUX_IN_H */
-- 
1.5.3.7.949.g2221a6


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH net-2.6.25 2/8] include/net: Use ipv4_is_<type>
       [not found] ` <40bae850207de9257479a535ea5ab4e7d1cdeab5.1197432867.git.joe@perches.com>
@ 2007-12-13 23:38   ` Joe Perches
  2007-12-16 21:43     ` David Miller
  0 siblings, 1 reply; 31+ messages in thread
From: Joe Perches @ 2007-12-13 23:38 UTC (permalink / raw)
  To: netdev


Signed-off-by: Joe Perches <joe@perches.com>
---
 include/net/addrconf.h |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index c56827d..1c3a560 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -252,10 +252,12 @@ static inline int ipv6_addr_is_ll_all_routers(const struct in6_addr *addr)
 
 static inline int ipv6_isatap_eui64(u8 *eui, __be32 addr)
 {
-	eui[0] = (ZERONET(addr) || PRIVATE_10(addr) || LOOPBACK(addr) ||
-		  LINKLOCAL_169(addr) || PRIVATE_172(addr) || TEST_192(addr) ||
-		  ANYCAST_6TO4(addr) || PRIVATE_192(addr) || TEST_198(addr) ||
-		  MULTICAST(addr) || BADCLASS(addr)) ? 0x00 : 0x02;
+	eui[0] = (ipv4_is_zeronet(addr) || ipv4_is_private_10(addr) ||
+		  ipv4_is_loopback(addr) || ipv4_is_linklocal_169(addr) ||
+		  ipv4_is_private_172(addr) || ipv4_is_test_192(addr) ||
+		  ipv4_is_anycast_6to4(addr) || ipv4_is_private_192(addr) ||
+		  ipv4_is_test_198(addr) || ipv4_is_multicast(addr) ||
+		  ipv4_is_badclass(addr)) ? 0x00 : 0x02;
 	eui[1] = 0;
 	eui[2] = 0x5E;
 	eui[3] = 0xFE;
-- 
1.5.3.7.949.g2221a6


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH net-2.6.25 3/8] net/core: Use ipv4_is_<type>
       [not found] ` <63aaea4664a57e3b9a0b7454da94e72b6d462e22.1197432867.git.joe@perches.com>
@ 2007-12-13 23:38   ` Joe Perches
  2007-12-16 21:44     ` David Miller
  0 siblings, 1 reply; 31+ messages in thread
From: Joe Perches @ 2007-12-13 23:38 UTC (permalink / raw)
  To: netdev


Signed-off-by: Joe Perches <joe@perches.com>
---
 net/core/netpoll.c |    3 ++-
 net/core/pktgen.c  |    8 +++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index b1d5acd..6faa128 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -410,7 +410,8 @@ static void arp_reply(struct sk_buff *skb)
 	memcpy(&tip, arp_ptr, 4);
 
 	/* Should we ignore arp? */
-	if (tip != htonl(np->local_ip) || LOOPBACK(tip) || MULTICAST(tip))
+	if (tip != htonl(np->local_ip) ||
+	    ipv4_is_loopback(tip) || ipv4_is_multicast(tip))
 		return;
 
 	size = sizeof(struct arphdr) + 2 * (skb->dev->addr_len + 4);
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 285ec3e..ede1fea 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2358,9 +2358,11 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
 					t = random32() % (imx - imn) + imn;
 					s = htonl(t);
 
-					while (LOOPBACK(s) || MULTICAST(s)
-					       || BADCLASS(s) || ZERONET(s)
-					       || LOCAL_MCAST(s)) {
+					while (ipv4_is_loopback(s) ||
+					       ipv4_is_multicast(s) ||
+					       ipv4_is_badclass(s) ||
+					       ipv4_is_zeronet(s) ||
+					       ipv4_is_local_multicast(s)) {
 						t = random32() % (imx - imn) + imn;
 						s = htonl(t);
 					}
-- 
1.5.3.7.949.g2221a6


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH net-2.6.25 4/8] net/ipv4: Use ipv4_is_<type>
       [not found] ` <9ab25b88c4c02bb7ba14ff68a8e99bdf4bdef9dd.1197432867.git.joe@perches.com>
@ 2007-12-13 23:38   ` Joe Perches
  2007-12-16 21:45     ` David Miller
  0 siblings, 1 reply; 31+ messages in thread
From: Joe Perches @ 2007-12-13 23:38 UTC (permalink / raw)
  To: netdev
  Cc: Pekka Savola (ipv6), Alexey Kuznetsov, David S. Miller,
	Hideaki YOSHIFUJI, James Morris, Patrick McHardy


Signed-off-by: Joe Perches <joe@perches.com>
---
 net/ipv4/arp.c          |    2 +-
 net/ipv4/datagram.c     |    2 +-
 net/ipv4/devinet.c      |    4 +-
 net/ipv4/fib_frontend.c |    6 ++--
 net/ipv4/igmp.c         |   12 +++++-----
 net/ipv4/ip_gre.c       |   23 +++++++++++---------
 net/ipv4/ipmr.c         |    6 ++--
 net/ipv4/raw.c          |    2 +-
 net/ipv4/route.c        |   52 ++++++++++++++++++++++++++--------------------
 net/ipv4/udp.c          |    2 +-
 10 files changed, 60 insertions(+), 51 deletions(-)

diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 48e7bf6..80bf2d0 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -778,7 +778,7 @@ static int arp_process(struct sk_buff *skb)
  *	Check for bad requests for 127.x.x.x and requests for multicast
  *	addresses.  If this is one such, delete it.
  */
-	if (LOOPBACK(tip) || MULTICAST(tip))
+	if (ipv4_is_loopback(tip) || ipv4_is_multicast(tip))
 		goto out;
 
 /*
diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
index 0301dd4..0c0c73f 100644
--- a/net/ipv4/datagram.c
+++ b/net/ipv4/datagram.c
@@ -40,7 +40,7 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
 
 	oif = sk->sk_bound_dev_if;
 	saddr = inet->saddr;
-	if (MULTICAST(usin->sin_addr.s_addr)) {
+	if (ipv4_is_multicast(usin->sin_addr.s_addr)) {
 		if (!oif)
 			oif = inet->mc_index;
 		if (!saddr)
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 0e2a829..fda7414 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -401,7 +401,7 @@ static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa)
 		in_dev_hold(in_dev);
 		ifa->ifa_dev = in_dev;
 	}
-	if (LOOPBACK(ifa->ifa_local))
+	if (ipv4_is_loopback(ifa->ifa_local))
 		ifa->ifa_scope = RT_SCOPE_HOST;
 	return inet_insert_ifa(ifa);
 }
@@ -580,7 +580,7 @@ static __inline__ int inet_abc_len(__be32 addr)
 {
 	int rc = -1;	/* Something else, probably a multicast. */
 
-	if (ZERONET(addr))
+	if (ipv4_is_zeronet(addr))
 		rc = 0;
 	else {
 		__u32 haddr = ntohl(addr);
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 7962830..b03c4c6 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -167,9 +167,9 @@ static inline unsigned __inet_dev_addr_type(const struct net_device *dev,
 	unsigned ret = RTN_BROADCAST;
 	struct fib_table *local_table;
 
-	if (ZERONET(addr) || BADCLASS(addr))
+	if (ipv4_is_zeronet(addr) || ipv4_is_badclass(addr))
 		return RTN_BROADCAST;
-	if (MULTICAST(addr))
+	if (ipv4_is_multicast(addr))
 		return RTN_MULTICAST;
 
 #ifdef CONFIG_IP_MULTIPLE_TABLES
@@ -710,7 +710,7 @@ void fib_add_ifaddr(struct in_ifaddr *ifa)
 	if (ifa->ifa_broadcast && ifa->ifa_broadcast != htonl(0xFFFFFFFF))
 		fib_magic(RTM_NEWROUTE, RTN_BROADCAST, ifa->ifa_broadcast, 32, prim);
 
-	if (!ZERONET(prefix) && !(ifa->ifa_flags&IFA_F_SECONDARY) &&
+	if (!ipv4_is_zeronet(prefix) && !(ifa->ifa_flags&IFA_F_SECONDARY) &&
 	    (prefix != addr || ifa->ifa_prefixlen < 32)) {
 		fib_magic(RTM_NEWROUTE, dev->flags&IFF_LOOPBACK ? RTN_LOCAL :
 			  RTN_UNICAST, prefix, ifa->ifa_prefixlen, prim);
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index c560a93..1bb4d0d 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1742,7 +1742,7 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
 	int ifindex;
 	int count = 0;
 
-	if (!MULTICAST(addr))
+	if (!ipv4_is_multicast(addr))
 		return -EINVAL;
 
 	rtnl_lock();
@@ -1855,7 +1855,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
 	int leavegroup = 0;
 	int i, j, rv;
 
-	if (!MULTICAST(addr))
+	if (!ipv4_is_multicast(addr))
 		return -EINVAL;
 
 	rtnl_lock();
@@ -1985,7 +1985,7 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex)
 	struct ip_sf_socklist *newpsl, *psl;
 	int leavegroup = 0;
 
-	if (!MULTICAST(addr))
+	if (!ipv4_is_multicast(addr))
 		return -EINVAL;
 	if (msf->imsf_fmode != MCAST_INCLUDE &&
 	    msf->imsf_fmode != MCAST_EXCLUDE)
@@ -2068,7 +2068,7 @@ int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
 	struct inet_sock *inet = inet_sk(sk);
 	struct ip_sf_socklist *psl;
 
-	if (!MULTICAST(addr))
+	if (!ipv4_is_multicast(addr))
 		return -EINVAL;
 
 	rtnl_lock();
@@ -2130,7 +2130,7 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
 	if (psin->sin_family != AF_INET)
 		return -EINVAL;
 	addr = psin->sin_addr.s_addr;
-	if (!MULTICAST(addr))
+	if (!ipv4_is_multicast(addr))
 		return -EINVAL;
 
 	rtnl_lock();
@@ -2180,7 +2180,7 @@ int ip_mc_sf_allow(struct sock *sk, __be32 loc_addr, __be32 rmt_addr, int dif)
 	struct ip_sf_socklist *psl;
 	int i;
 
-	if (!MULTICAST(loc_addr))
+	if (!ipv4_is_multicast(loc_addr))
 		return 1;
 
 	for (pmc=inet->mc_list; pmc; pmc=pmc->next) {
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 02b02a8..591eed4 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -176,7 +176,8 @@ static struct ip_tunnel * ipgre_tunnel_lookup(__be32 remote, __be32 local, __be3
 	}
 	for (t = tunnels_l[h1]; t; t = t->next) {
 		if (local == t->parms.iph.saddr ||
-		     (local == t->parms.iph.daddr && MULTICAST(local))) {
+		     (local == t->parms.iph.daddr &&
+		      ipv4_is_multicast(local))) {
 			if (t->parms.i_key == key && (t->dev->flags&IFF_UP))
 				return t;
 		}
@@ -201,7 +202,7 @@ static struct ip_tunnel **__ipgre_bucket(struct ip_tunnel_parm *parms)
 
 	if (local)
 		prio |= 1;
-	if (remote && !MULTICAST(remote)) {
+	if (remote && !ipv4_is_multicast(remote)) {
 		prio |= 2;
 		h ^= HASH(remote);
 	}
@@ -367,7 +368,8 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
 
 	read_lock(&ipgre_lock);
 	t = ipgre_tunnel_lookup(iph->daddr, iph->saddr, (flags&GRE_KEY) ? *(((__be32*)p) + (grehlen>>2) - 1) : 0);
-	if (t == NULL || t->parms.iph.daddr == 0 || MULTICAST(t->parms.iph.daddr))
+	if (t == NULL || t->parms.iph.daddr == 0 ||
+	    ipv4_is_multicast(t->parms.iph.daddr))
 		goto out;
 
 	if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED)
@@ -619,7 +621,7 @@ static int ipgre_rcv(struct sk_buff *skb)
 		skb_postpull_rcsum(skb, skb_transport_header(skb), offset);
 		skb->pkt_type = PACKET_HOST;
 #ifdef CONFIG_NET_IPGRE_BROADCAST
-		if (MULTICAST(iph->daddr)) {
+		if (ipv4_is_multicast(iph->daddr)) {
 			/* Looped back packet, drop it! */
 			if (((struct rtable*)skb->dst)->fl.iif == 0)
 				goto drop;
@@ -783,7 +785,8 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
 		struct rt6_info *rt6 = (struct rt6_info*)skb->dst;
 
 		if (rt6 && mtu < dst_mtu(skb->dst) && mtu >= IPV6_MIN_MTU) {
-			if ((tunnel->parms.iph.daddr && !MULTICAST(tunnel->parms.iph.daddr)) ||
+			if ((tunnel->parms.iph.daddr &&
+			     !ipv4_is_multicast(tunnel->parms.iph.daddr)) ||
 			    rt6->rt6i_dst.plen == 128) {
 				rt6->rt6i_flags |= RTF_MODIFIED;
 				skb->dst->metrics[RTAX_MTU-1] = mtu;
@@ -956,7 +959,7 @@ ipgre_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
 
 				t = netdev_priv(dev);
 
-				if (MULTICAST(p.iph.daddr))
+				if (ipv4_is_multicast(p.iph.daddr))
 					nflags = IFF_BROADCAST;
 				else if (p.iph.daddr)
 					nflags = IFF_POINTOPOINT;
@@ -1085,7 +1088,7 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev,
 		memcpy(&iph->daddr, daddr, 4);
 		return t->hlen;
 	}
-	if (iph->daddr && !MULTICAST(iph->daddr))
+	if (iph->daddr && !ipv4_is_multicast(iph->daddr))
 		return t->hlen;
 
 	return -t->hlen;
@@ -1108,7 +1111,7 @@ static int ipgre_open(struct net_device *dev)
 {
 	struct ip_tunnel *t = netdev_priv(dev);
 
-	if (MULTICAST(t->parms.iph.daddr)) {
+	if (ipv4_is_multicast(t->parms.iph.daddr)) {
 		struct flowi fl = { .oif = t->parms.link,
 				    .nl_u = { .ip4_u =
 					      { .daddr = t->parms.iph.daddr,
@@ -1131,7 +1134,7 @@ static int ipgre_open(struct net_device *dev)
 static int ipgre_close(struct net_device *dev)
 {
 	struct ip_tunnel *t = netdev_priv(dev);
-	if (MULTICAST(t->parms.iph.daddr) && t->mlink) {
+	if (ipv4_is_multicast(t->parms.iph.daddr) && t->mlink) {
 		struct in_device *in_dev = inetdev_by_index(t->mlink);
 		if (in_dev) {
 			ip_mc_dec_group(in_dev, t->parms.iph.daddr);
@@ -1196,7 +1199,7 @@ static int ipgre_tunnel_init(struct net_device *dev)
 		dev->flags |= IFF_POINTOPOINT;
 
 #ifdef CONFIG_NET_IPGRE_BROADCAST
-		if (MULTICAST(iph->daddr)) {
+		if (ipv4_is_multicast(iph->daddr)) {
 			if (!iph->saddr)
 				return -EINVAL;
 			dev->flags = IFF_BROADCAST;
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 1187928..6586324 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -749,7 +749,7 @@ static int ipmr_mfc_add(struct mfcctl *mfc, int mrtsock)
 		return 0;
 	}
 
-	if (!MULTICAST(mfc->mfcc_mcastgrp.s_addr))
+	if (!ipv4_is_multicast(mfc->mfcc_mcastgrp.s_addr))
 		return -EINVAL;
 
 	c=ipmr_cache_alloc();
@@ -1461,7 +1461,7 @@ int pim_rcv_v1(struct sk_buff * skb)
 	   b. packet is not a NULL-REGISTER
 	   c. packet is not truncated
 	 */
-	if (!MULTICAST(encap->daddr) ||
+	if (!ipv4_is_multicast(encap->daddr) ||
 	    encap->tot_len == 0 ||
 	    ntohs(encap->tot_len) + sizeof(*pim) > skb->len)
 		goto drop;
@@ -1517,7 +1517,7 @@ static int pim_rcv(struct sk_buff * skb)
 	/* check if the inner packet is destined to mcast group */
 	encap = (struct iphdr *)(skb_transport_header(skb) +
 				 sizeof(struct pimreghdr));
-	if (!MULTICAST(encap->daddr) ||
+	if (!ipv4_is_multicast(encap->daddr) ||
 	    encap->tot_len == 0 ||
 	    ntohs(encap->tot_len) + sizeof(*pim) > skb->len)
 		goto drop;
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index f99828e..1bd188f 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -528,7 +528,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
 	if (msg->msg_flags & MSG_DONTROUTE)
 		tos |= RTO_ONLINK;
 
-	if (MULTICAST(daddr)) {
+	if (ipv4_is_multicast(daddr)) {
 		if (!ipc.oif)
 			ipc.oif = inet->mc_index;
 		if (!saddr)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 245f5cf..638554f 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1154,7 +1154,8 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
 		return;
 
 	if (new_gw == old_gw || !IN_DEV_RX_REDIRECTS(in_dev)
-	    || MULTICAST(new_gw) || BADCLASS(new_gw) || ZERONET(new_gw))
+	    || ipv4_is_multicast(new_gw) || ipv4_is_badclass(new_gw)
+	    || ipv4_is_zeronet(new_gw))
 		goto reject_redirect;
 
 	if (!IN_DEV_SHARED_MEDIA(in_dev)) {
@@ -1633,12 +1634,12 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 	if (in_dev == NULL)
 		return -EINVAL;
 
-	if (MULTICAST(saddr) || BADCLASS(saddr) || LOOPBACK(saddr) ||
-	    skb->protocol != htons(ETH_P_IP))
+	if (ipv4_is_multicast(saddr) || ipv4_is_badclass(saddr) ||
+	    ipv4_is_loopback(saddr) || skb->protocol != htons(ETH_P_IP))
 		goto e_inval;
 
-	if (ZERONET(saddr)) {
-		if (!LOCAL_MCAST(daddr))
+	if (ipv4_is_zeronet(saddr)) {
+		if (!ipv4_is_local_multicast(daddr))
 			goto e_inval;
 		spec_dst = inet_select_addr(dev, 0, RT_SCOPE_LINK);
 	} else if (fib_validate_source(saddr, 0, tos, 0,
@@ -1680,7 +1681,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 	}
 
 #ifdef CONFIG_IP_MROUTE
-	if (!LOCAL_MCAST(daddr) && IN_DEV_MFORWARD(in_dev))
+	if (!ipv4_is_local_multicast(daddr) && IN_DEV_MFORWARD(in_dev))
 		rth->u.dst.input = ip_mr_input;
 #endif
 	RT_CACHE_STAT_INC(in_slow_mc);
@@ -1890,7 +1891,8 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 	   by fib_lookup.
 	 */
 
-	if (MULTICAST(saddr) || BADCLASS(saddr) || LOOPBACK(saddr))
+	if (ipv4_is_multicast(saddr) || ipv4_is_badclass(saddr) ||
+	    ipv4_is_loopback(saddr))
 		goto martian_source;
 
 	if (daddr == htonl(0xFFFFFFFF) || (saddr == 0 && daddr == 0))
@@ -1899,10 +1901,11 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 	/* Accept zero addresses only to limited broadcast;
 	 * I even do not know to fix it or not. Waiting for complains :-)
 	 */
-	if (ZERONET(saddr))
+	if (ipv4_is_zeronet(saddr))
 		goto martian_source;
 
-	if (BADCLASS(daddr) || ZERONET(daddr) || LOOPBACK(daddr))
+	if (ipv4_is_badclass(daddr) || ipv4_is_zeronet(daddr) ||
+	    ipv4_is_loopback(daddr))
 		goto martian_destination;
 
 	/*
@@ -1949,7 +1952,7 @@ brd_input:
 	if (skb->protocol != htons(ETH_P_IP))
 		goto e_inval;
 
-	if (ZERONET(saddr))
+	if (ipv4_is_zeronet(saddr))
 		spec_dst = inet_select_addr(dev, 0, RT_SCOPE_LINK);
 	else {
 		err = fib_validate_source(saddr, 0, tos, 0, dev, &spec_dst,
@@ -2079,7 +2082,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 	   Note, that multicast routers are not affected, because
 	   route cache entry is created eventually.
 	 */
-	if (MULTICAST(daddr)) {
+	if (ipv4_is_multicast(daddr)) {
 		struct in_device *in_dev;
 
 		rcu_read_lock();
@@ -2088,7 +2091,8 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
 				ip_hdr(skb)->protocol);
 			if (our
 #ifdef CONFIG_IP_MROUTE
-			    || (!LOCAL_MCAST(daddr) && IN_DEV_MFORWARD(in_dev))
+			    || (!ipv4_is_local_multicast(daddr) &&
+				IN_DEV_MFORWARD(in_dev))
 #endif
 			    ) {
 				rcu_read_unlock();
@@ -2114,14 +2118,14 @@ static inline int __mkroute_output(struct rtable **result,
 	u32 tos = RT_FL_TOS(oldflp);
 	int err = 0;
 
-	if (LOOPBACK(fl->fl4_src) && !(dev_out->flags&IFF_LOOPBACK))
+	if (ipv4_is_loopback(fl->fl4_src) && !(dev_out->flags&IFF_LOOPBACK))
 		return -EINVAL;
 
 	if (fl->fl4_dst == htonl(0xFFFFFFFF))
 		res->type = RTN_BROADCAST;
-	else if (MULTICAST(fl->fl4_dst))
+	else if (ipv4_is_multicast(fl->fl4_dst))
 		res->type = RTN_MULTICAST;
-	else if (BADCLASS(fl->fl4_dst) || ZERONET(fl->fl4_dst))
+	else if (ipv4_is_badclass(fl->fl4_dst) || ipv4_is_zeronet(fl->fl4_dst))
 		return -EINVAL;
 
 	if (dev_out->flags & IFF_LOOPBACK)
@@ -2201,7 +2205,7 @@ static inline int __mkroute_output(struct rtable **result,
 #ifdef CONFIG_IP_MROUTE
 		if (res->type == RTN_MULTICAST) {
 			if (IN_DEV_MFORWARD(in_dev) &&
-			    !LOCAL_MCAST(oldflp->fl4_dst)) {
+			    !ipv4_is_local_multicast(oldflp->fl4_dst)) {
 				rth->u.dst.input = ip_mr_input;
 				rth->u.dst.output = ip_mc_output;
 			}
@@ -2271,9 +2275,9 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
 
 	if (oldflp->fl4_src) {
 		err = -EINVAL;
-		if (MULTICAST(oldflp->fl4_src) ||
-		    BADCLASS(oldflp->fl4_src) ||
-		    ZERONET(oldflp->fl4_src))
+		if (ipv4_is_multicast(oldflp->fl4_src) ||
+		    ipv4_is_badclass(oldflp->fl4_src) ||
+		    ipv4_is_zeronet(oldflp->fl4_src))
 			goto out;
 
 		/* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */
@@ -2290,7 +2294,8 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
 		 */
 
 		if (oldflp->oif == 0
-		    && (MULTICAST(oldflp->fl4_dst) || oldflp->fl4_dst == htonl(0xFFFFFFFF))) {
+		    && (ipv4_is_multicast(oldflp->fl4_dst) ||
+			oldflp->fl4_dst == htonl(0xFFFFFFFF))) {
 			/* Special hack: user can direct multicasts
 			   and limited broadcast via necessary interface
 			   without fiddling with IP_MULTICAST_IF or IP_PKTINFO.
@@ -2327,14 +2332,15 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
 			goto out;	/* Wrong error code */
 		}
 
-		if (LOCAL_MCAST(oldflp->fl4_dst) || oldflp->fl4_dst == htonl(0xFFFFFFFF)) {
+		if (ipv4_is_local_multicast(oldflp->fl4_dst) ||
+		    oldflp->fl4_dst == htonl(0xFFFFFFFF)) {
 			if (!fl.fl4_src)
 				fl.fl4_src = inet_select_addr(dev_out, 0,
 							      RT_SCOPE_LINK);
 			goto make_route;
 		}
 		if (!fl.fl4_src) {
-			if (MULTICAST(oldflp->fl4_dst))
+			if (ipv4_is_multicast(oldflp->fl4_dst))
 				fl.fl4_src = inet_select_addr(dev_out, 0,
 							      fl.fl4_scope);
 			else if (!oldflp->fl4_dst)
@@ -2617,7 +2623,7 @@ static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
 #ifdef CONFIG_IP_MROUTE
 		__be32 dst = rt->rt_dst;
 
-		if (MULTICAST(dst) && !LOCAL_MCAST(dst) &&
+		if (ipv4_is_multicast(dst) && !ipv4_is_local_multicast(dst) &&
 		    IPV4_DEVCONF_ALL(MC_FORWARDING)) {
 			int err = ipmr_get_route(skb, r, nowait);
 			if (err <= 0) {
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 9ed6393..bb2b404 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -623,7 +623,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
 		connected = 0;
 	}
 
-	if (MULTICAST(daddr)) {
+	if (ipv4_is_multicast(daddr)) {
 		if (!ipc.oif)
 			ipc.oif = inet->mc_index;
 		if (!saddr)
-- 
1.5.3.7.949.g2221a6


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH net-2.6.25 5/8] net/netfilter: Use ipv4_is_<type>
       [not found] ` <350bda1cfd4ac57b354451157b9009b3c8ce334e.1197432867.git.joe@perches.com>
  2007-12-13 23:38   ` [PATCH net-2.6.25 5/8] net/netfilter: " Joe Perches
@ 2007-12-13 23:38   ` Joe Perches
  2007-12-16 21:46     ` David Miller
  2007-12-13 23:38   ` Joe Perches
  2 siblings, 1 reply; 31+ messages in thread
From: Joe Perches @ 2007-12-13 23:38 UTC (permalink / raw)
  To: netdev; +Cc: Patrick McHardy, coreteam, netfilter-devel, netfilter


Signed-off-by: Joe Perches <joe@perches.com>
---
 net/netfilter/xt_pkttype.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/netfilter/xt_pkttype.c b/net/netfilter/xt_pkttype.c
index c598bbe..2762449 100644
--- a/net/netfilter/xt_pkttype.c
+++ b/net/netfilter/xt_pkttype.c
@@ -31,7 +31,7 @@ pkttype_mt(const struct sk_buff *skb, const struct net_device *in,
 	const struct xt_pkttype_info *info = matchinfo;
 
 	if (skb->pkt_type == PACKET_LOOPBACK)
-		type = MULTICAST(ip_hdr(skb)->daddr)
+		type = ipv4_is_multicast(ip_hdr(skb)->daddr)
 			? PACKET_MULTICAST
 			: PACKET_BROADCAST;
 	else
-- 
1.5.3.7.949.g2221a6


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH net-2.6.25 5/8] net/netfilter: Use ipv4_is_<type>
       [not found] ` <350bda1cfd4ac57b354451157b9009b3c8ce334e.1197432867.git.joe@perches.com>
@ 2007-12-13 23:38   ` Joe Perches
  2007-12-13 23:38   ` Joe Perches
  2007-12-13 23:38   ` Joe Perches
  2 siblings, 0 replies; 31+ messages in thread
From: Joe Perches @ 2007-12-13 23:38 UTC (permalink / raw)
  To: netdev; +Cc: Patrick McHardy, coreteam, netfilter-devel, netfilter


Signed-off-by: Joe Perches <joe@perches.com>
---
 net/netfilter/xt_pkttype.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/netfilter/xt_pkttype.c b/net/netfilter/xt_pkttype.c
index c598bbe..2762449 100644
--- a/net/netfilter/xt_pkttype.c
+++ b/net/netfilter/xt_pkttype.c
@@ -31,7 +31,7 @@ pkttype_mt(const struct sk_buff *skb, const struct net_device *in,
 	const struct xt_pkttype_info *info = matchinfo;
 
 	if (skb->pkt_type == PACKET_LOOPBACK)
-		type = MULTICAST(ip_hdr(skb)->daddr)
+		type = ipv4_is_multicast(ip_hdr(skb)->daddr)
 			? PACKET_MULTICAST
 			: PACKET_BROADCAST;
 	else
-- 
1.5.3.7.949.g2221a6


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH net-2.6.25 5/8] net/netfilter: Use ipv4_is_<type>
       [not found] ` <350bda1cfd4ac57b354451157b9009b3c8ce334e.1197432867.git.joe@perches.com>
  2007-12-13 23:38   ` [PATCH net-2.6.25 5/8] net/netfilter: " Joe Perches
  2007-12-13 23:38   ` Joe Perches
@ 2007-12-13 23:38   ` Joe Perches
  2 siblings, 0 replies; 31+ messages in thread
From: Joe Perches @ 2007-12-13 23:38 UTC (permalink / raw)
  To: netdev; +Cc: Patrick McHardy, coreteam, netfilter-devel, netfilter


Signed-off-by: Joe Perches <joe@perches.com>
---
 net/netfilter/xt_pkttype.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/netfilter/xt_pkttype.c b/net/netfilter/xt_pkttype.c
index c598bbe..2762449 100644
--- a/net/netfilter/xt_pkttype.c
+++ b/net/netfilter/xt_pkttype.c
@@ -31,7 +31,7 @@ pkttype_mt(const struct sk_buff *skb, const struct net_device *in,
 	const struct xt_pkttype_info *info = matchinfo;
 
 	if (skb->pkt_type == PACKET_LOOPBACK)
-		type = MULTICAST(ip_hdr(skb)->daddr)
+		type = ipv4_is_multicast(ip_hdr(skb)->daddr)
 			? PACKET_MULTICAST
 			: PACKET_BROADCAST;
 	else
-- 
1.5.3.7.949.g2221a6


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH net-2.6.25 6/8] sctp: Use ipv4_is_<type>
       [not found] ` <1bb329b93a1f75766b7b89afdfa5ae673e9355ec.1197432867.git.joe@perches.com>
@ 2007-12-13 23:38   ` Joe Perches
  2007-12-14 19:11     ` Vlad Yasevich
  2007-12-16 21:47     ` David Miller
  0 siblings, 2 replies; 31+ messages in thread
From: Joe Perches @ 2007-12-13 23:38 UTC (permalink / raw)
  To: netdev; +Cc: Sridhar Samudrala, Vlad Yasevich, lksctp-developers


Signed-off-by: Joe Perches <joe@perches.com>
---
 include/net/sctp/constants.h |   36 ++++++------------------------------
 net/sctp/protocol.c          |   12 +++++++-----
 2 files changed, 13 insertions(+), 35 deletions(-)

diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h
index 05f22a6..fefcba6 100644
--- a/include/net/sctp/constants.h
+++ b/include/net/sctp/constants.h
@@ -365,36 +365,12 @@ typedef enum {
  * Also, RFC 8.4, non-unicast addresses are not considered valid SCTP
  * addresses.
  */
-#define IS_IPV4_UNUSABLE_ADDRESS(a) \
-	((htonl(INADDR_BROADCAST) == *a) || \
-	(MULTICAST(*a)) || \
-	(((unsigned char *)(a))[0] == 0) || \
-	((((unsigned char *)(a))[0] == 198) && \
-	(((unsigned char *)(a))[1] == 18) && \
-	(((unsigned char *)(a))[2] == 0)) || \
-	((((unsigned char *)(a))[0] == 192) && \
-	(((unsigned char *)(a))[1] == 88) && \
-	(((unsigned char *)(a))[2] == 99)))
-
-/* IPv4 Link-local addresses: 169.254.0.0/16.  */
-#define IS_IPV4_LINK_ADDRESS(a) \
-	((((unsigned char *)(a))[0] == 169) && \
-	(((unsigned char *)(a))[1] == 254))
-
-/* RFC 1918 "Address Allocation for Private Internets" defines the IPv4
- * private address space as the following:
- *
- * 10.0.0.0 - 10.255.255.255 (10/8 prefix)
- * 172.16.0.0.0 - 172.31.255.255 (172.16/12 prefix)
- * 192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
- */
-#define IS_IPV4_PRIVATE_ADDRESS(a) \
-	((((unsigned char *)(a))[0] == 10) || \
-	((((unsigned char *)(a))[0] == 172) && \
-	(((unsigned char *)(a))[1] >= 16) && \
-	(((unsigned char *)(a))[1] < 32)) || \
-	((((unsigned char *)(a))[0] == 192) && \
-	(((unsigned char *)(a))[1] == 168)))
+#define IS_IPV4_UNUSABLE_ADDRESS(a)	    \
+	((htonl(INADDR_BROADCAST) == a) ||  \
+	 ipv4_is_multicast(a) ||	    \
+	 ipv4_is_zeronet(a) ||		    \
+	 ipv4_is_test_198(a) ||		    \
+	 ipv4_is_anycast_6to4(a))
 
 /* Flags used for the bind address copy functions.  */
 #define SCTP_ADDR6_ALLOWED	0x00000001	/* IPv6 address is allowed by
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index d50f610..dc22d71 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -359,7 +359,7 @@ static int sctp_v4_addr_valid(union sctp_addr *addr,
 			      const struct sk_buff *skb)
 {
 	/* Is this a non-unicast address or a unusable SCTP address? */
-	if (IS_IPV4_UNUSABLE_ADDRESS(&addr->v4.sin_addr.s_addr))
+	if (IS_IPV4_UNUSABLE_ADDRESS(addr->v4.sin_addr.s_addr))
 		return 0;
 
 	/* Is this a broadcast address? */
@@ -408,13 +408,15 @@ static sctp_scope_t sctp_v4_scope(union sctp_addr *addr)
 	 */
 
 	/* Check for unusable SCTP addresses. */
-	if (IS_IPV4_UNUSABLE_ADDRESS(&addr->v4.sin_addr.s_addr)) {
+	if (IS_IPV4_UNUSABLE_ADDRESS(addr->v4.sin_addr.s_addr)) {
 		retval =  SCTP_SCOPE_UNUSABLE;
-	} else if (LOOPBACK(addr->v4.sin_addr.s_addr)) {
+	} else if (ipv4_is_loopback(addr->v4.sin_addr.s_addr)) {
 		retval = SCTP_SCOPE_LOOPBACK;
-	} else if (IS_IPV4_LINK_ADDRESS(&addr->v4.sin_addr.s_addr)) {
+	} else if (ipv4_is_linklocal_169(addr->v4.sin_addr.s_addr)) {
 		retval = SCTP_SCOPE_LINK;
-	} else if (IS_IPV4_PRIVATE_ADDRESS(&addr->v4.sin_addr.s_addr)) {
+	} else if (ipv4_is_private_10(addr->v4.sin_addr.s_addr) ||
+		   ipv4_is_private_172(addr->v4.sin_addr.s_addr) ||
+		   ipv4_is_private_192(addr->v4.sin_addr.s_addr)) {
 		retval = SCTP_SCOPE_PRIVATE;
 	} else {
 		retval = SCTP_SCOPE_GLOBAL;
-- 
1.5.3.7.949.g2221a6


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [ofa-general] [PATCH net-2.6.25 7/8] drivers/infiniband: Use ipv4_is_<type>
       [not found] ` <aaf1cd18672fdabaa410bff09200c6a74534bdb0.1197432867.git.joe@perches.com>
@ 2007-12-13 23:39   ` Joe Perches
  2007-12-16 21:47     ` David Miller
  2007-12-13 23:39   ` Joe Perches
  1 sibling, 1 reply; 31+ messages in thread
From: Joe Perches @ 2007-12-13 23:39 UTC (permalink / raw)
  To: netdev; +Cc: general


Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/infiniband/core/addr.c |    4 ++--
 drivers/infiniband/core/cma.c  |    5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 5381c80..0802b79 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -265,11 +265,11 @@ static int addr_resolve_local(struct sockaddr_in *src_in,
 	if (!dev)
 		return -EADDRNOTAVAIL;
 
-	if (ZERONET(src_ip)) {
+	if (ipv4_is_zeronet(src_ip)) {
 		src_in->sin_family = dst_in->sin_family;
 		src_in->sin_addr.s_addr = dst_ip;
 		ret = rdma_copy_addr(addr, dev, dev->dev_addr);
-	} else if (LOOPBACK(src_ip)) {
+	} else if (ipv4_is_loopback(src_ip)) {
 		ret = rdma_translate_ip((struct sockaddr *)dst_in, addr);
 		if (!ret)
 			memcpy(addr->dst_dev_addr, dev->dev_addr, MAX_ADDR_LEN);
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 0751697..b37045c 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -624,7 +624,8 @@ static inline int cma_zero_addr(struct sockaddr *addr)
 	struct in6_addr *ip6;
 
 	if (addr->sa_family == AF_INET)
-		return ZERONET(((struct sockaddr_in *) addr)->sin_addr.s_addr);
+		return ipv4_is_zeronet(
+			((struct sockaddr_in *)addr)->sin_addr.s_addr);
 	else {
 		ip6 = &((struct sockaddr_in6 *) addr)->sin6_addr;
 		return (ip6->s6_addr32[0] | ip6->s6_addr32[1] |
@@ -634,7 +635,7 @@ static inline int cma_zero_addr(struct sockaddr *addr)
 
 static inline int cma_loopback_addr(struct sockaddr *addr)
 {
-	return LOOPBACK(((struct sockaddr_in *) addr)->sin_addr.s_addr);
+	return ipv4_is_loopback(((struct sockaddr_in *) addr)->sin_addr.s_addr);
 }
 
 static inline int cma_any_addr(struct sockaddr *addr)
-- 
1.5.3.7.949.g2221a6

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH net-2.6.25 7/8] drivers/infiniband: Use ipv4_is_<type>
       [not found] ` <aaf1cd18672fdabaa410bff09200c6a74534bdb0.1197432867.git.joe@perches.com>
  2007-12-13 23:39   ` [ofa-general] [PATCH net-2.6.25 7/8] drivers/infiniband: " Joe Perches
@ 2007-12-13 23:39   ` Joe Perches
  1 sibling, 0 replies; 31+ messages in thread
From: Joe Perches @ 2007-12-13 23:39 UTC (permalink / raw)
  To: netdev; +Cc: Hal Rosenstock, Roland Dreier, Sean Hefty, general


Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/infiniband/core/addr.c |    4 ++--
 drivers/infiniband/core/cma.c  |    5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 5381c80..0802b79 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -265,11 +265,11 @@ static int addr_resolve_local(struct sockaddr_in *src_in,
 	if (!dev)
 		return -EADDRNOTAVAIL;
 
-	if (ZERONET(src_ip)) {
+	if (ipv4_is_zeronet(src_ip)) {
 		src_in->sin_family = dst_in->sin_family;
 		src_in->sin_addr.s_addr = dst_ip;
 		ret = rdma_copy_addr(addr, dev, dev->dev_addr);
-	} else if (LOOPBACK(src_ip)) {
+	} else if (ipv4_is_loopback(src_ip)) {
 		ret = rdma_translate_ip((struct sockaddr *)dst_in, addr);
 		if (!ret)
 			memcpy(addr->dst_dev_addr, dev->dev_addr, MAX_ADDR_LEN);
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 0751697..b37045c 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -624,7 +624,8 @@ static inline int cma_zero_addr(struct sockaddr *addr)
 	struct in6_addr *ip6;
 
 	if (addr->sa_family == AF_INET)
-		return ZERONET(((struct sockaddr_in *) addr)->sin_addr.s_addr);
+		return ipv4_is_zeronet(
+			((struct sockaddr_in *)addr)->sin_addr.s_addr);
 	else {
 		ip6 = &((struct sockaddr_in6 *) addr)->sin6_addr;
 		return (ip6->s6_addr32[0] | ip6->s6_addr32[1] |
@@ -634,7 +635,7 @@ static inline int cma_zero_addr(struct sockaddr *addr)
 
 static inline int cma_loopback_addr(struct sockaddr *addr)
 {
-	return LOOPBACK(((struct sockaddr_in *) addr)->sin_addr.s_addr);
+	return ipv4_is_loopback(((struct sockaddr_in *) addr)->sin_addr.s_addr);
 }
 
 static inline int cma_any_addr(struct sockaddr *addr)
-- 
1.5.3.7.949.g2221a6


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH net-2.6.25 8/8] Remove unused IPV4TYPE macros
       [not found] ` <885ea24008e2b1c07e6bff0344f260a0ff104a35.1197432867.git.joe@perches.com>
@ 2007-12-13 23:39   ` Joe Perches
  2007-12-16 21:48     ` David Miller
  2007-12-13 23:39   ` Joe Perches
  1 sibling, 1 reply; 31+ messages in thread
From: Joe Perches @ 2007-12-13 23:39 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel


Signed-off-by: Joe Perches <joe@perches.com>
---
 include/linux/in.h |   14 --------------
 1 files changed, 0 insertions(+), 14 deletions(-)

diff --git a/include/linux/in.h b/include/linux/in.h
index f8d6073..27d8a5a 100644
--- a/include/linux/in.h
+++ b/include/linux/in.h
@@ -272,12 +272,6 @@ static inline bool ipv4_is_zeronet(__be32 addr)
 	return (addr & htonl(0xff000000)) == htonl(0x00000000);
 }
 
-#define LOOPBACK(x)		ipv4_is_loopback(x)
-#define MULTICAST(x)		ipv4_is_multicast(x)
-#define BADCLASS(x)		ipv4_is_badclass(x)
-#define ZERONET(x)		ipv4_is_zeronet(x)
-#define LOCAL_MCAST(x)		ipv4_is_local_multicast(x)
-
 /* Special-Use IPv4 Addresses (RFC3330) */
 
 static inline bool ipv4_is_private_10(__be32 addr)
@@ -316,12 +310,4 @@ static inline bool ipv4_is_test_198(__be32 addr)
 }
 #endif
 
-#define PRIVATE_10(x)		ipv4_is_private_10(x)
-#define LINKLOCAL_169(x)	ipv4_is_linklocal_169(x)
-#define PRIVATE_172(x)		ipv4_is_private_172(x)
-#define TEST_192(x)		ipv4_is_test_192(x)
-#define ANYCAST_6TO4(x)		ipv4_is_anycast_6to4(x)
-#define PRIVATE_192(x)		ipv4_is_private_192(x)
-#define TEST_198(x)		ipv4_is_test_198(x)
-
 #endif	/* _LINUX_IN_H */
-- 
1.5.3.7.949.g2221a6


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH net-2.6.25 8/8] Remove unused IPV4TYPE macros
       [not found] ` <885ea24008e2b1c07e6bff0344f260a0ff104a35.1197432867.git.joe@perches.com>
  2007-12-13 23:39   ` [PATCH net-2.6.25 8/8] Remove unused IPV4TYPE macros Joe Perches
@ 2007-12-13 23:39   ` Joe Perches
  1 sibling, 0 replies; 31+ messages in thread
From: Joe Perches @ 2007-12-13 23:39 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel


Signed-off-by: Joe Perches <joe@perches.com>
---
 include/linux/in.h |   14 --------------
 1 files changed, 0 insertions(+), 14 deletions(-)

diff --git a/include/linux/in.h b/include/linux/in.h
index f8d6073..27d8a5a 100644
--- a/include/linux/in.h
+++ b/include/linux/in.h
@@ -272,12 +272,6 @@ static inline bool ipv4_is_zeronet(__be32 addr)
 	return (addr & htonl(0xff000000)) == htonl(0x00000000);
 }
 
-#define LOOPBACK(x)		ipv4_is_loopback(x)
-#define MULTICAST(x)		ipv4_is_multicast(x)
-#define BADCLASS(x)		ipv4_is_badclass(x)
-#define ZERONET(x)		ipv4_is_zeronet(x)
-#define LOCAL_MCAST(x)		ipv4_is_local_multicast(x)
-
 /* Special-Use IPv4 Addresses (RFC3330) */
 
 static inline bool ipv4_is_private_10(__be32 addr)
@@ -316,12 +310,4 @@ static inline bool ipv4_is_test_198(__be32 addr)
 }
 #endif
 
-#define PRIVATE_10(x)		ipv4_is_private_10(x)
-#define LINKLOCAL_169(x)	ipv4_is_linklocal_169(x)
-#define PRIVATE_172(x)		ipv4_is_private_172(x)
-#define TEST_192(x)		ipv4_is_test_192(x)
-#define ANYCAST_6TO4(x)		ipv4_is_anycast_6to4(x)
-#define PRIVATE_192(x)		ipv4_is_private_192(x)
-#define TEST_198(x)		ipv4_is_test_198(x)

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH net-2.6.25 6/8] sctp: Use ipv4_is_<type>
  2007-12-13 23:38   ` [PATCH net-2.6.25 6/8] sctp: " Joe Perches
@ 2007-12-14 19:11     ` Vlad Yasevich
  2007-12-14 19:14       ` David Miller
  2007-12-16 21:47     ` David Miller
  1 sibling, 1 reply; 31+ messages in thread
From: Vlad Yasevich @ 2007-12-14 19:11 UTC (permalink / raw)
  To: Joe Perches; +Cc: netdev, Sridhar Samudrala, lksctp-developers

Joe Perches wrote:
> Signed-off-by: Joe Perches <joe@perches.com>

Thanks Joe.  I've put this into my tree.

-vlad

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH net-2.6.25 6/8] sctp: Use ipv4_is_<type>
  2007-12-14 19:11     ` Vlad Yasevich
@ 2007-12-14 19:14       ` David Miller
  2007-12-14 19:17         ` Vlad Yasevich
  0 siblings, 1 reply; 31+ messages in thread
From: David Miller @ 2007-12-14 19:14 UTC (permalink / raw)
  To: vladislav.yasevich; +Cc: joe, netdev, sri, lksctp-developers

From: Vlad Yasevich <vladislav.yasevich@hp.com>
Date: Fri, 14 Dec 2007 14:11:44 -0500

> Joe Perches wrote:
> > Signed-off-by: Joe Perches <joe@perches.com>
> 
> Thanks Joe.  I've put this into my tree.

You can't, because your tree won't build without his first patch and I
have to approve that and stick it into my tree first.

Just let me review and potentially pick up all of
Joe's stuff since we have this dependency.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH net-2.6.25 6/8] sctp: Use ipv4_is_<type>
  2007-12-14 19:14       ` David Miller
@ 2007-12-14 19:17         ` Vlad Yasevich
  0 siblings, 0 replies; 31+ messages in thread
From: Vlad Yasevich @ 2007-12-14 19:17 UTC (permalink / raw)
  To: David Miller; +Cc: joe, netdev, sri, lksctp-developers

David Miller wrote:
> From: Vlad Yasevich <vladislav.yasevich@hp.com>
> Date: Fri, 14 Dec 2007 14:11:44 -0500
> 
>> Joe Perches wrote:
>>> Signed-off-by: Joe Perches <joe@perches.com>
>> Thanks Joe.  I've put this into my tree.
> 
> You can't, because your tree won't build without his first patch and I
> have to approve that and stick it into my tree first.
> 
> Just let me review and potentially pick up all of
> Joe's stuff since we have this dependency.
> 

Ok.  In that case, you can have my ACK for the SCTP stuff.

-vlad

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH net-2.6.25 1/8] Create ipv4_is_<type>(__be32 addr) functions
  2007-12-13 23:38 ` Joe Perches
@ 2007-12-16 21:42   ` David Miller
  2007-12-17 22:37   ` Jan Engelhardt
  1 sibling, 0 replies; 31+ messages in thread
From: David Miller @ 2007-12-16 21:42 UTC (permalink / raw)
  To: joe; +Cc: netdev, linux-kernel

From: Joe Perches <joe@perches.com>
Date: Thu, 13 Dec 2007 15:38:54 -0800

> Change IPV4 specific macros LOOPBACK MULTICAST LOCAL_MCAST BADCLASS and ZERONET
> macros to inline functions ipv4_is_<type>(__be32 addr)
> 
> Adds type safety and arguably some readability.
> 
> Changes since last submission:
> 
> Removed ipv4_addr_octets function
> Used hex constants
> Converted recently added rfc3330 macros
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Applied.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH net-2.6.25 2/8] include/net: Use ipv4_is_<type>
  2007-12-13 23:38   ` [PATCH net-2.6.25 2/8] include/net: Use ipv4_is_<type> Joe Perches
@ 2007-12-16 21:43     ` David Miller
  0 siblings, 0 replies; 31+ messages in thread
From: David Miller @ 2007-12-16 21:43 UTC (permalink / raw)
  To: joe; +Cc: netdev

From: Joe Perches <joe@perches.com>
Date: Thu, 13 Dec 2007 15:38:55 -0800

> 
> Signed-off-by: Joe Perches <joe@perches.com>

Applied.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH net-2.6.25 3/8] net/core: Use ipv4_is_<type>
  2007-12-13 23:38   ` [PATCH net-2.6.25 3/8] net/core: " Joe Perches
@ 2007-12-16 21:44     ` David Miller
  0 siblings, 0 replies; 31+ messages in thread
From: David Miller @ 2007-12-16 21:44 UTC (permalink / raw)
  To: joe; +Cc: netdev

From: Joe Perches <joe@perches.com>
Date: Thu, 13 Dec 2007 15:38:56 -0800

> Signed-off-by: Joe Perches <joe@perches.com>

Applied.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH net-2.6.25 4/8] net/ipv4: Use ipv4_is_<type>
  2007-12-13 23:38   ` [PATCH net-2.6.25 4/8] net/ipv4: " Joe Perches
@ 2007-12-16 21:45     ` David Miller
  0 siblings, 0 replies; 31+ messages in thread
From: David Miller @ 2007-12-16 21:45 UTC (permalink / raw)
  To: joe; +Cc: netdev, pekkas, kuznet, yoshfuji, jmorris, kaber

From: Joe Perches <joe@perches.com>
Date: Thu, 13 Dec 2007 15:38:57 -0800

> Signed-off-by: Joe Perches <joe@perches.com>

Applied.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH net-2.6.25 5/8] net/netfilter: Use ipv4_is_<type>
  2007-12-13 23:38   ` Joe Perches
@ 2007-12-16 21:46     ` David Miller
  0 siblings, 0 replies; 31+ messages in thread
From: David Miller @ 2007-12-16 21:46 UTC (permalink / raw)
  To: joe; +Cc: netdev, kaber, coreteam, netfilter-devel, netfilter

From: Joe Perches <joe@perches.com>
Date: Thu, 13 Dec 2007 15:38:58 -0800

> Signed-off-by: Joe Perches <joe@perches.com>

Applied.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH net-2.6.25 6/8] sctp: Use ipv4_is_<type>
  2007-12-13 23:38   ` [PATCH net-2.6.25 6/8] sctp: " Joe Perches
  2007-12-14 19:11     ` Vlad Yasevich
@ 2007-12-16 21:47     ` David Miller
  1 sibling, 0 replies; 31+ messages in thread
From: David Miller @ 2007-12-16 21:47 UTC (permalink / raw)
  To: joe; +Cc: netdev, sri, vladislav.yasevich, lksctp-developers

From: Joe Perches <joe@perches.com>
Date: Thu, 13 Dec 2007 15:38:59 -0800

> Signed-off-by: Joe Perches <joe@perches.com>

Applied.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH net-2.6.25 7/8] drivers/infiniband: Use ipv4_is_<type>
  2007-12-13 23:39   ` [ofa-general] [PATCH net-2.6.25 7/8] drivers/infiniband: " Joe Perches
@ 2007-12-16 21:47     ` David Miller
  0 siblings, 0 replies; 31+ messages in thread
From: David Miller @ 2007-12-16 21:47 UTC (permalink / raw)
  To: joe; +Cc: netdev, hal.rosenstock, rolandd, mshefty, general

From: Joe Perches <joe@perches.com>
Date: Thu, 13 Dec 2007 15:39:00 -0800

> Signed-off-by: Joe Perches <joe@perches.com>

Applied.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH net-2.6.25 8/8] Remove unused IPV4TYPE macros
  2007-12-13 23:39   ` [PATCH net-2.6.25 8/8] Remove unused IPV4TYPE macros Joe Perches
@ 2007-12-16 21:48     ` David Miller
  2007-12-17  4:01       ` Joe Perches
  0 siblings, 1 reply; 31+ messages in thread
From: David Miller @ 2007-12-16 21:48 UTC (permalink / raw)
  To: joe; +Cc: netdev, linux-kernel

From: Joe Perches <joe@perches.com>
Date: Thu, 13 Dec 2007 15:39:01 -0800

> Signed-off-by: Joe Perches <joe@perches.com>

Applied, thanks for doing this work Joe.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH net-2.6.25 8/8] Remove unused IPV4TYPE macros
  2007-12-16 21:48     ` David Miller
@ 2007-12-17  4:01       ` Joe Perches
  2007-12-17  4:28         ` David Miller
  0 siblings, 1 reply; 31+ messages in thread
From: Joe Perches @ 2007-12-17  4:01 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-kernel

On Sun, 2007-12-16 at 13:48 -0800, David Miller wrote:
> From: Joe Perches <joe@perches.com>
> Date: Thu, 13 Dec 2007 15:39:01 -0800
> > Signed-off-by: Joe Perches <joe@perches.com>
> Applied, thanks for doing this work Joe.

I broke the parisc build.  Bad Joe...

Here's the patch:

Signed-off-by: Joe Perches <joe@perches.com>

diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c
index a6d6b24..703b85e 100644
--- a/drivers/parisc/led.c
+++ b/drivers/parisc/led.c
@@ -364,7 +364,7 @@ static __inline__ int led_get_net_activity(void)
 	    struct in_device *in_dev = __in_dev_get_rcu(dev);
 	    if (!in_dev || !in_dev->ifa_list)
 		continue;
-	    if (LOOPBACK(in_dev->ifa_list->ifa_local))
+	    if (ipv4_is_loopback(in_dev->ifa_list->ifa_local))
 		continue;
 	    stats = dev->get_stats(dev);
 	    rx_total += stats->rx_packets;



^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH net-2.6.25 8/8] Remove unused IPV4TYPE macros
  2007-12-17  4:01       ` Joe Perches
@ 2007-12-17  4:28         ` David Miller
  0 siblings, 0 replies; 31+ messages in thread
From: David Miller @ 2007-12-17  4:28 UTC (permalink / raw)
  To: joe; +Cc: netdev, linux-kernel

From: Joe Perches <joe@perches.com>
Date: Sun, 16 Dec 2007 20:01:06 -0800

> On Sun, 2007-12-16 at 13:48 -0800, David Miller wrote:
> > From: Joe Perches <joe@perches.com>
> > Date: Thu, 13 Dec 2007 15:39:01 -0800
> > > Signed-off-by: Joe Perches <joe@perches.com>
> > Applied, thanks for doing this work Joe.
> 
> I broke the parisc build.  Bad Joe...
> 
> Here's the patch:
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH net-2.6.25 1/8] Create ipv4_is_<type>(__be32 addr) functions
  2007-12-13 23:38 ` Joe Perches
  2007-12-16 21:42   ` David Miller
@ 2007-12-17 22:37   ` Jan Engelhardt
  2007-12-17 22:41     ` David Miller
                       ` (2 more replies)
  1 sibling, 3 replies; 31+ messages in thread
From: Jan Engelhardt @ 2007-12-17 22:37 UTC (permalink / raw)
  To: Joe Perches; +Cc: netdev, Linux Kernel Mailing List, David Miller


On Dec 13 2007 15:38, Joe Perches wrote:
>
>Change IPV4 specific macros LOOPBACK MULTICAST LOCAL_MCAST BADCLASS and ZERONET
>macros to inline functions ipv4_is_<type>(__be32 addr)
>
>Adds type safety and arguably some readability.
>
>Changes since last submission:
>
>Removed ipv4_addr_octets function
>Used hex constants
>Converted recently added rfc3330 macros
>
>Signed-off-by: Joe Perches <joe@perches.com>
>---
>+static inline bool ipv4_is_loopback(__be32 addr)
>+{
>+	return (addr & htonl(0xff000000)) == htonl(0x7f000000);
>+}
>+

Can we use __constant_htonl()?

>+static inline bool ipv4_is_private_10(__be32 addr)
>+{
>+	return (addr & htonl(0xff000000)) == htonl(0x0a000000);
>+}

What are these functions needed for, even? There does not seem to be
any code (at least in davem's net-2.6.25:net/ipv4/, where I dared to grep)
that uses them.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH net-2.6.25 1/8] Create ipv4_is_<type>(__be32 addr) functions
  2007-12-17 22:37   ` Jan Engelhardt
@ 2007-12-17 22:41     ` David Miller
  2007-12-17 22:42     ` Joe Perches
  2007-12-17 22:43     ` David Miller
  2 siblings, 0 replies; 31+ messages in thread
From: David Miller @ 2007-12-17 22:41 UTC (permalink / raw)
  To: jengelh; +Cc: joe, netdev, linux-kernel

From: Jan Engelhardt <jengelh@computergmbh.de>
Date: Mon, 17 Dec 2007 23:37:24 +0100 (CET)

> Can we use __constant_htonl()?

That should only be used in initializers.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH net-2.6.25 1/8] Create ipv4_is_<type>(__be32 addr) functions
  2007-12-17 22:37   ` Jan Engelhardt
  2007-12-17 22:41     ` David Miller
@ 2007-12-17 22:42     ` Joe Perches
  2007-12-17 22:43     ` David Miller
  2 siblings, 0 replies; 31+ messages in thread
From: Joe Perches @ 2007-12-17 22:42 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: netdev, Linux Kernel Mailing List, David Miller

On Mon, 2007-12-17 at 23:37 +0100, Jan Engelhardt wrote:
> >+static inline bool ipv4_is_loopback(__be32 addr)
> >+{
> >+	return (addr & htonl(0xff000000)) == htonl(0x7f000000);
> >+}
> >+
> Can we use __constant_htonl()?

I believe the generated code is the same.

> >+static inline bool ipv4_is_private_10(__be32 addr)
> >+{
> >+	return (addr & htonl(0xff000000)) == htonl(0x0a000000);
> >+}
> 
> What are these functions needed for, even? There does not seem to be
> any code (at least in davem's net-2.6.25:net/ipv4/, where I dared to grep)
> that uses them.

include/net/addrconf.h
net/sctp/protocol.c

cheers, Joe


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH net-2.6.25 1/8] Create ipv4_is_<type>(__be32 addr) functions
  2007-12-17 22:37   ` Jan Engelhardt
  2007-12-17 22:41     ` David Miller
  2007-12-17 22:42     ` Joe Perches
@ 2007-12-17 22:43     ` David Miller
  2007-12-17 23:02       ` Jan Engelhardt
  2 siblings, 1 reply; 31+ messages in thread
From: David Miller @ 2007-12-17 22:43 UTC (permalink / raw)
  To: jengelh; +Cc: joe, netdev, linux-kernel

From: Jan Engelhardt <jengelh@computergmbh.de>
Date: Mon, 17 Dec 2007 23:37:24 +0100 (CET)

> 
> On Dec 13 2007 15:38, Joe Perches wrote:
> >+static inline bool ipv4_is_private_10(__be32 addr)
> >+{
> >+	return (addr & htonl(0xff000000)) == htonl(0x0a000000);
> >+}
> 
> What are these functions needed for, even? There does not seem to be
> any code (at least in davem's net-2.6.25:net/ipv4/, where I dared to grep)
> that uses them.

You really need to grep the whole tree, never ever decrease the scope
of directories to search if you want to see if an interface is used.

It's used by some ipv6 address translation code as well as some
bits in SCTP:

include/net/addrconf.h:	eui[0] = (ipv4_is_zeronet(addr) || ipv4_is_private_10(addr) ||
net/sctp/protocol.c:	} else if (ipv4_is_private_10(addr->v4.sin_addr.s_addr) ||

So lazy...

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH net-2.6.25 1/8] Create ipv4_is_<type>(__be32 addr) functions
  2007-12-17 22:43     ` David Miller
@ 2007-12-17 23:02       ` Jan Engelhardt
  0 siblings, 0 replies; 31+ messages in thread
From: Jan Engelhardt @ 2007-12-17 23:02 UTC (permalink / raw)
  To: David Miller; +Cc: joe, netdev, linux-kernel


On Dec 17 2007 14:43, David Miller wrote:
>> On Dec 13 2007 15:38, Joe Perches wrote:
>> >+static inline bool ipv4_is_private_10(__be32 addr)
>> >+{
>> >+	return (addr & htonl(0xff000000)) == htonl(0x0a000000);
>> >+}
>> 
>> What are these functions needed for, even? There does not seem to be
>> any code (at least in davem's net-2.6.25:net/ipv4/, where I dared to grep)
>> that uses them.
>
>You really need to grep the whole tree, never ever decrease the scope
>of directories to search if you want to see if an interface is used.
>
Hah you got me there :)

>It's used by some ipv6 address translation code as well as some
>bits in SCTP:
>
>include/net/addrconf.h:	eui[0] = (ipv4_is_zeronet(addr) || ipv4_is_private_10(addr) ||
>net/sctp/protocol.c:	} else if (ipv4_is_private_10(addr->v4.sin_addr.s_addr) ||
>
>So lazy...

I just discovered git-grep...

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2007-12-17 23:02 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <e2ebcbf24539c0a3ef2ac77147dbfa55d8ac9e33.1197432867.git.joe@perches.com>
2007-12-13 23:38 ` [PATCH net-2.6.25 1/8] Create ipv4_is_<type>(__be32 addr) functions Joe Perches
2007-12-13 23:38 ` Joe Perches
2007-12-16 21:42   ` David Miller
2007-12-17 22:37   ` Jan Engelhardt
2007-12-17 22:41     ` David Miller
2007-12-17 22:42     ` Joe Perches
2007-12-17 22:43     ` David Miller
2007-12-17 23:02       ` Jan Engelhardt
     [not found] ` <40bae850207de9257479a535ea5ab4e7d1cdeab5.1197432867.git.joe@perches.com>
2007-12-13 23:38   ` [PATCH net-2.6.25 2/8] include/net: Use ipv4_is_<type> Joe Perches
2007-12-16 21:43     ` David Miller
     [not found] ` <63aaea4664a57e3b9a0b7454da94e72b6d462e22.1197432867.git.joe@perches.com>
2007-12-13 23:38   ` [PATCH net-2.6.25 3/8] net/core: " Joe Perches
2007-12-16 21:44     ` David Miller
     [not found] ` <9ab25b88c4c02bb7ba14ff68a8e99bdf4bdef9dd.1197432867.git.joe@perches.com>
2007-12-13 23:38   ` [PATCH net-2.6.25 4/8] net/ipv4: " Joe Perches
2007-12-16 21:45     ` David Miller
     [not found] ` <350bda1cfd4ac57b354451157b9009b3c8ce334e.1197432867.git.joe@perches.com>
2007-12-13 23:38   ` [PATCH net-2.6.25 5/8] net/netfilter: " Joe Perches
2007-12-13 23:38   ` Joe Perches
2007-12-16 21:46     ` David Miller
2007-12-13 23:38   ` Joe Perches
     [not found] ` <1bb329b93a1f75766b7b89afdfa5ae673e9355ec.1197432867.git.joe@perches.com>
2007-12-13 23:38   ` [PATCH net-2.6.25 6/8] sctp: " Joe Perches
2007-12-14 19:11     ` Vlad Yasevich
2007-12-14 19:14       ` David Miller
2007-12-14 19:17         ` Vlad Yasevich
2007-12-16 21:47     ` David Miller
     [not found] ` <aaf1cd18672fdabaa410bff09200c6a74534bdb0.1197432867.git.joe@perches.com>
2007-12-13 23:39   ` [ofa-general] [PATCH net-2.6.25 7/8] drivers/infiniband: " Joe Perches
2007-12-16 21:47     ` David Miller
2007-12-13 23:39   ` Joe Perches
     [not found] ` <885ea24008e2b1c07e6bff0344f260a0ff104a35.1197432867.git.joe@perches.com>
2007-12-13 23:39   ` [PATCH net-2.6.25 8/8] Remove unused IPV4TYPE macros Joe Perches
2007-12-16 21:48     ` David Miller
2007-12-17  4:01       ` Joe Perches
2007-12-17  4:28         ` David Miller
2007-12-13 23:39   ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).