All of lore.kernel.org
 help / color / mirror / Atom feed
From: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
To: davem@davemloft.net, netdev@vger.kernel.org
Cc: yoshfuji@linux-ipv6.org
Subject: [GIT PULL net-next 14/17] ndisc: Concentrate ndisc_send() on sending message.
Date: Tue, 18 Dec 2012 19:56:10 +0900	[thread overview]
Message-ID: <50D04BCA.8020703@linux-ipv6.org> (raw)
In-Reply-To: <50CF84A5.7030706@linux-ipv6.org>

Build NDISC message outside ndisc_send() and concentrate the
function sending sk_buff with given destination/source.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
---
 net/ipv6/ndisc.c |   51 ++++++++++++++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 21 deletions(-)

diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index c0937d3..c974d9d 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -488,26 +488,20 @@ static void __ndisc_send(struct sk_buff *skb, struct dst_entry *dst,
 /*
  *	Send a Neighbour Discover packet
  */
-static void ndisc_send(struct net_device *dev,
+static void ndisc_send(struct sk_buff *skb,
 		       struct neighbour *neigh,
 		       const struct in6_addr *daddr,
-		       const struct in6_addr *saddr,
-		       struct icmp6hdr *icmp6h, const struct in6_addr *target,
-		       int llinfo)
+		       const struct in6_addr *saddr)
 {
 	struct flowi6 fl6;
 	struct dst_entry *dst;
-	struct net *net = dev_net(dev);
+	struct net *net = dev_net(skb->dev);
 	struct sock *sk = net->ipv6.ndisc_sk;
-	struct sk_buff *skb;
+	struct icmp6hdr *icmp6h = icmp6_hdr(skb);
 	u8 type = icmp6h->icmp6_type;
 
-	skb = ndisc_build_skb(dev, daddr, saddr, icmp6h, target, llinfo);
-	if (!skb)
-		return;
-
-	icmpv6_flow_init(sk, &fl6, type, saddr, daddr, dev->ifindex);
-	dst = icmp6_dst_alloc(dev, neigh, &fl6);
+	icmpv6_flow_init(sk, &fl6, type, saddr, daddr, skb->dev->ifindex);
+	dst = icmp6_dst_alloc(skb->dev, neigh, &fl6);
 	if (IS_ERR(dst)) {
 		kfree_skb(skb);
 		return;
@@ -527,6 +521,7 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
 	struct icmp6hdr icmp6h = {
 		.icmp6_type = NDISC_NEIGHBOUR_ADVERTISEMENT,
 	};
+	struct sk_buff *skb;
 
 	/* for anycast or proxy, solicited_addr != src_addr */
 	ifp = ipv6_get_ifaddr(dev_net(dev), solicited_addr, dev, 1);
@@ -548,9 +543,13 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
 	icmp6h.icmp6_solicited = solicited;
 	icmp6h.icmp6_override = override;
 
-	ndisc_send(dev, neigh, daddr, src_addr,
-		   &icmp6h, solicited_addr,
-		   inc_opt ? ND_OPT_TARGET_LL_ADDR : 0);
+	skb = ndisc_build_skb(dev, daddr, src_addr,
+			      &icmp6h, solicited_addr,
+			      inc_opt ? ND_OPT_TARGET_LL_ADDR : 0);
+	if (!skb)
+		return;
+
+	ndisc_send(skb, neigh, daddr, src_addr);
 }
 
 static void ndisc_send_unsol_na(struct net_device *dev)
@@ -582,6 +581,7 @@ void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh,
 	struct icmp6hdr icmp6h = {
 		.icmp6_type = NDISC_NEIGHBOUR_SOLICITATION,
 	};
+	struct sk_buff *skb;
 
 	if (saddr == NULL) {
 		if (ipv6_get_lladdr(dev, &addr_buf,
@@ -590,9 +590,13 @@ void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh,
 		saddr = &addr_buf;
 	}
 
-	ndisc_send(dev, neigh, daddr, saddr,
-		   &icmp6h, solicit,
-		   !ipv6_addr_any(saddr) ? ND_OPT_SOURCE_LL_ADDR : 0);
+	skb = ndisc_build_skb(dev, daddr, saddr,
+			      &icmp6h, solicit,
+			      !ipv6_addr_any(saddr) ? ND_OPT_SOURCE_LL_ADDR : 0);
+	if (!skb)
+		return;
+
+	ndisc_send(skb, neigh, daddr, saddr);
 }
 
 void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
@@ -602,6 +606,7 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
 		.icmp6_type = NDISC_ROUTER_SOLICITATION,
 	};
 	int send_sllao = dev->addr_len;
+	struct sk_buff *skb;
 
 #ifdef CONFIG_IPV6_OPTIMISTIC_DAD
 	/*
@@ -625,9 +630,13 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
 		}
 	}
 #endif
-	ndisc_send(dev, NULL, daddr, saddr,
-		   &icmp6h, NULL,
-		   send_sllao ? ND_OPT_SOURCE_LL_ADDR : 0);
+	skb = ndisc_build_skb(dev, daddr, saddr,
+			      &icmp6h, NULL,
+			      send_sllao ? ND_OPT_SOURCE_LL_ADDR : 0);
+	if (!skb)
+		return;
+
+	ndisc_send(skb, NULL, daddr, saddr);
 }
 
 
-- 
1.7.9.5

  parent reply	other threads:[~2012-12-18 10:56 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-17 20:46 [GIT PULL net-next] NDISC Updates (sender-side clean-up) YOSHIFUJI Hideaki
2012-12-17 22:31 ` David Miller
2012-12-18 10:52 ` [GIT PULL net-next 01/17] ndisc: Fix size calculation for headers YOSHIFUJI Hideaki
2012-12-19  0:23   ` David Miller
2012-12-19  0:24     ` David Miller
2012-12-19  3:00       ` YOSHIFUJI Hideaki
2012-12-19  3:08     ` YOSHIFUJI Hideaki
2012-12-18 10:52 ` [GIT PULL net-next 02/17] ipv6: Introduce __ip6_hdr() for setting IPv6 header YOSHIFUJI Hideaki
2012-12-18 10:53 ` [GIT PULL net-next 03/17] ndisc: Introduce struct red_msg for redirect message YOSHIFUJI Hideaki
2012-12-18 10:54 ` [GIT PULL net-next 04/17] ndisc: Introduce ndisc_fill_redirect_hdr_option() YOSHIFUJI Hideaki
     [not found]   ` <BAY173-W1475D04C810BF9A1D71FB8B0310@phx.gbl>
     [not found]     ` <BAY173-W14E9D67B7924486F0518F0B0310@phx.gbl>
     [not found]       ` <BAY173-W14E9D67B7924486F0518F0B0310-MsuGFMq8XAE@public.gmane.org>
2012-12-18 12:05         ` [IPv6] crashed when __ip6_del_rt() YOSHIFUJI Hideaki
2012-12-18 12:05           ` YOSHIFUJI Hideaki
2012-12-19  3:08   ` [GIT PULL net-next 04/17] ndisc: Introduce ndisc_fill_redirect_hdr_option() YOSHIFUJI Hideaki
2012-12-19 11:47   ` Bjørn Mork
2012-12-19 16:25     ` YOSHIFUJI Hideaki
2012-12-19 17:27       ` YOSHIFUJI Hideaki
2012-12-18 10:54 ` [GIT PULL net-next 05/17] ndisc: Rename and break up __ndisc_send() YOSHIFUJI Hideaki
2012-12-18 10:54 ` [GIT PULL net-next 06/17] ndisc: Introduce ndisc_send_skb_alloc() for sk_buff allocation YOSHIFUJI Hideaki
2012-12-18 10:54 ` [GIT PULL net-next 07/17] ipv6: Move ip6_nd_hdr() to its users' source files YOSHIFUJI Hideaki
2012-12-18 10:54 ` [GIT PULL net-next 08/17] ndisc: Set skb->dev and skb->protocol inside ndisc_alloc_skb() YOSHIFUJI Hideaki
2012-12-18 10:54 ` [GIT PULL net-next 09/17] ndisc: Defer building IPv6 header YOSHIFUJI Hideaki
2012-12-18 10:55 ` [GIT PULL net-next 10/17] ndisc: Reset skb->transport_header inside ndisc_alloc_send_skb() YOSHIFUJI Hideaki
2012-12-18 10:55 ` [GIT PULL net-next 11/17] ndisc: Calculate message body length and option length separately YOSHIFUJI Hideaki
2012-12-18 10:55 ` [GIT PULL net-next 12/17] ndisc: Make ndisc_fill_xxx_option() for sk_buff YOSHIFUJI Hideaki
2012-12-18 10:56 ` [GIT PULL net-next 13/17] ndisc: Calculate checksum and build IPv6 header in __ndisc_send() YOSHIFUJI Hideaki
2012-12-18 10:56 ` YOSHIFUJI Hideaki [this message]
2012-12-18 10:56 ` [GIT PULL net-next 15/17] ndisc: Break down ndisc_build_skb() YOSHIFUJI Hideaki
2012-12-18 10:56 ` [GIT PULL net-next 16/17] ndisc: Fill in ND message on skb directly YOSHIFUJI Hideaki
2012-12-18 10:56 ` [GIT PULL net-next 17/17] ndisc: Use return value of __skb_put(), instead of icmp6_hdr() YOSHIFUJI Hideaki

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=50D04BCA.8020703@linux-ipv6.org \
    --to=yoshfuji@linux-ipv6.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.