netdev.vger.kernel.org archive mirror
 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 11/17] ndisc: Calculate message body length and option length separately.
Date: Tue, 18 Dec 2012 19:55:48 +0900	[thread overview]
Message-ID: <50D04BB4.3080906@linux-ipv6.org> (raw)
In-Reply-To: <50CF84A5.7030706@linux-ipv6.org>

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

diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 073e52a..1100559 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -422,6 +422,7 @@ static struct sk_buff *ndisc_build_skb(struct net_device *dev,
 	struct sk_buff *skb;
 	struct icmp6hdr *hdr;
 	int len;
+	int optlen = 0;
 	u8 *opt;
 
 	if (!dev->addr_len)
@@ -429,13 +430,13 @@ static struct sk_buff *ndisc_build_skb(struct net_device *dev,
 
 	len = sizeof(struct icmp6hdr) + (target ? sizeof(*target) : 0);
 	if (llinfo)
-		len += ndisc_opt_addr_space(dev);
+		optlen += ndisc_opt_addr_space(dev);
 
-	skb = ndisc_alloc_skb(dev, len);
+	skb = ndisc_alloc_skb(dev, len + optlen);
 	if (!skb)
 		return NULL;
 
-	skb_put(skb, len);
+	skb_put(skb, len + optlen);
 
 	hdr = (struct icmp6hdr *)skb_transport_header(skb);
 	memcpy(hdr, icmp6h, sizeof(*hdr));
@@ -1377,7 +1378,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 	struct net_device *dev = skb->dev;
 	struct net *net = dev_net(dev);
 	struct sock *sk = net->ipv6.ndisc_sk;
-	int len = sizeof(struct red_msg);
+	int optlen = 0;
 	struct inet_peer *peer;
 	struct sk_buff *buff;
 	struct red_msg *msg;
@@ -1442,7 +1443,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 			memcpy(ha_buf, neigh->ha, dev->addr_len);
 			read_unlock_bh(&neigh->lock);
 			ha = ha_buf;
-			len += ndisc_opt_addr_space(dev);
+			optlen += ndisc_opt_addr_space(dev);
 		} else
 			read_unlock_bh(&neigh->lock);
 
@@ -1450,15 +1451,16 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 	}
 
 	rd_len = min_t(unsigned int,
-		     IPV6_MIN_MTU-sizeof(struct ipv6hdr)-len, skb->len + 8);
+		       IPV6_MIN_MTU - sizeof(struct ipv6hdr) - sizeof(struct red_msg) - optlen,
+		       skb->len + 8);
 	rd_len &= ~0x7;
-	len += rd_len;
+	optlen += rd_len;
 
-	buff = ndisc_alloc_skb(dev, len);
+	buff = ndisc_alloc_skb(dev, sizeof(struct red_msg) + optlen);
 	if (!buff)
 		goto release;
 
-	skb_put(buff, len);
+	skb_put(buff, sizeof(struct red_msg) + optlen);
 	msg = (struct red_msg *)icmp6_hdr(buff);
 
 	memset(&msg->icmph, 0, sizeof(struct icmp6hdr));
-- 
1.7.9.5

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

Thread overview: 27+ 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
2012-12-19  3:08   ` 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 ` YOSHIFUJI Hideaki [this message]
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 ` [GIT PULL net-next 14/17] ndisc: Concentrate ndisc_send() on sending message YOSHIFUJI Hideaki
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=50D04BB4.3080906@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 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).