netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Haley <brian.haley@hp.com>
To: David Miller <davem@davemloft.net>,
	YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Cc: netdev@vger.kernel.org
Subject: [PATCH 2/4] [IPv6] Add multicast address type inline
Date: Thu, 05 Apr 2007 23:21:16 -0400	[thread overview]
Message-ID: <4615BCAC.8010201@hp.com> (raw)
In-Reply-To: <151538c13022864224f5ff440e1147f884abb492.1175794415.git.brian.haley@hp.com>

Add multicast address type inline to avoid calls to ipv6_addr_type().

Signed-off-by: Brian Haley <brian.haley@hp.com>
---
  include/net/ipv6.h    |    5 +++++
  net/ipv6/icmp.c       |   12 ++++--------
  net/ipv6/ip6_tunnel.c |    4 ++--
  net/ipv6/route.c      |    4 ++--
  4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index d473789..a888b0e 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -439,6 +439,11 @@ static inline int ipv6_addr_scope_sitelocal(const struct in6_addr *a)
  	return ((a->s6_addr32[0] & htonl(0xFFC00000)) == htonl(0xFEC00000));
  }

+static inline int ipv6_addr_type_multicast(const struct in6_addr *a)
+{
+	return ((a->s6_addr32[0] & htonl(0xFF000000)) == htonl(0xFF000000));
+}
+
  /*
   *	Prototypes exported by ipv6
   */
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index e94992a..709037f 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -312,7 +312,6 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
  	struct flowi fl;
  	struct icmpv6_msg msg;
  	int iif = 0;
-	int addr_type = 0;
  	int len;
  	int hlimit, tclass;
  	int err = 0;
@@ -327,8 +326,6 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
  	 *	Rule (e.1) is enforced by not using icmpv6_send
  	 *	in any code that processes icmp errors.
  	 */
-	addr_type = ipv6_addr_type(&hdr->daddr);
-
  	if (ipv6_chk_addr(&hdr->daddr, skb->dev, 0))
  		saddr = &hdr->daddr;

@@ -336,7 +333,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
  	 *	Dest addr check
  	 */

-	if ((addr_type & IPV6_ADDR_MULTICAST || skb->pkt_type != PACKET_HOST)) {
+	if (ipv6_addr_type_multicast(&hdr->daddr) || skb->pkt_type != PACKET_HOST) {
  		if (type != ICMPV6_PKT_TOOBIG &&
  		    !(type == ICMPV6_PARAMPROB &&
  		      code == ICMPV6_UNK_OPTION &&
@@ -346,13 +343,11 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
  		saddr = NULL;
  	}

-	addr_type = ipv6_addr_type(&hdr->saddr);
-
  	/*
  	 *	Source addr check
  	 */

-	if (addr_type & IPV6_ADDR_LINKLOCAL)
+	if (ipv6_addr_scope_linklocal(&hdr->saddr))
  		iif = skb->dev->ifindex;

  	/*
@@ -361,7 +356,8 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
  	 *	We check unspecified / multicast addresses here,
  	 *	and anycast addresses will be checked later.
  	 */
-	if ((addr_type == IPV6_ADDR_ANY) || (addr_type & IPV6_ADDR_MULTICAST)) {
+	if (ipv6_addr_any(&hdr->saddr) ||
+	    ipv6_addr_type_multicast(&hdr->saddr)) {
  		LIMIT_NETDEBUG(KERN_DEBUG "icmpv6_send: addr_any/mcast source\n");
  		return;
  	}
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index a0902fb..0dd1f63 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1111,8 +1111,8 @@ static void ip6_tnl_link_config(struct ip6_tnl *t)
  	dev->iflink = p->link;

  	if (p->flags & IP6_TNL_F_CAP_XMIT) {
-		int strict = (ipv6_addr_type(&p->raddr) &
-			      (IPV6_ADDR_MULTICAST|IPV6_ADDR_LINKLOCAL));
+		int strict = ipv6_addr_type_multicast(&p->raddr) ||
+			     ipv6_addr_scope_linklocal(&p->raddr);

  		struct rt6_info *rt = rt6_lookup(&p->raddr, &p->laddr,
  						 p->link, strict);
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 53d79ac..32c6398 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -227,8 +227,8 @@ static __inline__ int rt6_check_expired(const struct rt6_info *rt)

  static inline int rt6_need_strict(struct in6_addr *daddr)
  {
-	return (ipv6_addr_type(daddr) &
-		(IPV6_ADDR_MULTICAST | IPV6_ADDR_LINKLOCAL));
+	return (ipv6_addr_is_multicast(daddr) ||
+		ipv6_addr_scope_linklocal(daddr));
  }

  /*


  parent reply	other threads:[~2007-04-06  3:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <11758281863002-git-send-email-brian.haley@hp.com>
2007-04-06  3:21 ` [PATCH 1/4] [IPv6] Add link and site-local scope inline Brian Haley
2007-04-06  3:24   ` YOSHIFUJI Hideaki / 吉藤英明
2007-04-06  6:37     ` Brian Haley
2007-04-06  7:00       ` YOSHIFUJI Hideaki / 吉藤英明
     [not found] ` <117582818660-git-send-email-brian.haley@hp.com>
     [not found]   ` <11758281864173-git-send-email-brian.haley@hp.com>
     [not found]   ` <151538c13022864224f5ff440e1147f884abb492.1175794415.git.brian.haley@hp.com>
2007-04-06  3:21     ` Brian Haley [this message]
2007-04-06  3:42       ` [PATCH 2/4] [IPv6] Add multicast address type inline YOSHIFUJI Hideaki / 吉藤英明
2007-04-06  3:21     ` [PATCH 3/4] Add mapped " Brian Haley
2007-04-06  3:47       ` YOSHIFUJI Hideaki / 吉藤英明
2007-04-06  3:21     ` [PATCH 4/4] Add loopback " Brian Haley
2007-04-06  3:51       ` YOSHIFUJI Hideaki / 吉藤英明
2007-04-06  6:38         ` Brian Haley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4615BCAC.8010201@hp.com \
    --to=brian.haley@hp.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).