netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: ndisc.c: reduce size of __ndisc_fill_addr_option()
@ 2017-05-26 22:00 yuan linyu
  2017-05-30  3:30 ` David Miller
  0 siblings, 1 reply; 12+ messages in thread
From: yuan linyu @ 2017-05-26 22:00 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Joe Perches, David Ahern, yuan linyu

From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>

Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
---
 net/ipv6/ndisc.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index d310dc4..414e929 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -148,17 +148,18 @@ void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data,
 
 	opt[0] = type;
 	opt[1] = space>>3;
+	opt   += 2;
+	space -= 2;
 
-	memset(opt + 2, 0, pad);
+	memset(opt, 0, pad);
 	opt   += pad;
 	space -= pad;
 
-	memcpy(opt+2, data, data_len);
-	data_len += 2;
+	memcpy(opt, data, data_len);
 	opt += data_len;
 	space -= data_len;
-	if (space > 0)
-		memset(opt, 0, space);
+
+	memset(opt, 0, space);
 }
 EXPORT_SYMBOL_GPL(__ndisc_fill_addr_option);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread
* Re: [PATCH net-next] net: ndisc.c: reduce size of __ndisc_fill_addr_option()
@ 2017-05-27 15:15 Alexey Dobriyan
  2017-05-30  3:31 ` David Miller
  0 siblings, 1 reply; 12+ messages in thread
From: Alexey Dobriyan @ 2017-05-27 15:15 UTC (permalink / raw)
  To: Linyu.Yuan; +Cc: netdev, davem

> --- a/net/ipv6/ndisc.c
> +++ b/net/ipv6/ndisc.c
> @@ -148,17 +148,18 @@ void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data,

>  	space -= data_len;
> -	if (space > 0)
> -		memset(opt, 0, space);
> +
> +	memset(opt, 0, space);

This can't be right.

And what size are you reducing?

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

end of thread, other threads:[~2017-05-31  1:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-26 22:00 [PATCH net-next] net: ndisc.c: reduce size of __ndisc_fill_addr_option() yuan linyu
2017-05-30  3:30 ` David Miller
2017-05-30  3:41   ` Joe Perches
2017-05-30  3:42     ` David Ahern
2017-05-31  0:07       ` YUAN Linyu
2017-05-31  0:29       ` YUAN Linyu
2017-05-31  0:39         ` David Ahern
2017-05-31  1:00           ` YUAN Linyu
2017-05-31  0:06     ` YUAN Linyu
  -- strict thread matches above, loose matches on Subject: below --
2017-05-27 15:15 Alexey Dobriyan
2017-05-30  3:31 ` David Miller
2017-05-30  4:24   ` 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).