netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Moore <paul.moore@hp.com>
To: Thomas Graf <tgraf@suug.ch>
Cc: "David S. Miller" <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [NETLINK]: Do precise netlink message allocations where possible
Date: Fri, 10 Nov 2006 11:04:14 -0500	[thread overview]
Message-ID: <4554A2FE.2020405@hp.com> (raw)
In-Reply-To: <20061110121706.GH8693@postel.suug.ch>

Thomas Graf wrote:
> Account for the netlink message header size directly in nlmsg_new()
> instead of relying on the caller calculate it correctly.
> 
> Replaces error handling of message construction functions when
> constructing notifications with bug traps since a failure implies
> a bug in calculating the size of the skb.
> 
> Signed-off-by: Thomas Graf <tgraf@suug.ch>
> 
> Index: net-2.6.20/include/net/netlink.h
> ===================================================================
> --- net-2.6.20.orig/include/net/netlink.h	2006-11-08 15:29:26.000000000 +0100
> +++ net-2.6.20/include/net/netlink.h	2006-11-10 11:18:34.000000000 +0100
> @@ -500,14 +500,15 @@
>  
>  /**
>   * nlmsg_new - Allocate a new netlink message
> - * @size: maximum size of message
> + * @payload: size of the message payload
>   * @flags: the type of memory to allocate.
>   *
> - * Use NLMSG_GOODSIZE if size isn't know and you need a good default size.
> + * Use NLMSG_DEFAULT_SIZE if the size of the payload isn't known
> + * and a good default is needed.
>   */
> -static inline struct sk_buff *nlmsg_new(int size, gfp_t flags)
> +static inline struct sk_buff *nlmsg_new(size_t payload, gfp_t flags)
>  {
> -	return alloc_skb(size, flags);
> +	return alloc_skb(nlmsg_total_size(payload), flags);
>  }

I like this approach, it makes much more sense to me then the previous
implementation which was a simple "alias" to alloc_skb().  Also, the NetLabel
relevant sections look fine to me.

Acked-by: Paul Moore <paul.moore@hp.com>

-- 
paul moore
linux security @ hp

  reply	other threads:[~2006-11-10 16:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-10 12:17 [NETLINK]: Do precise netlink message allocations where possible Thomas Graf
2006-11-10 16:04 ` Paul Moore [this message]
2006-11-10 22:10   ` David Miller
2006-11-10 22:16   ` Thomas Graf
2006-11-11  4:06     ` Paul Moore

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=4554A2FE.2020405@hp.com \
    --to=paul.moore@hp.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=tgraf@suug.ch \
    /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).