From: Thomas Graf <tgraf@suug.ch>
To: Hong Zhiguo <honkiko@gmail.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, stephen@networkplumber.org
Subject: Re: [PATCH net-next] netlink: replace obsolete NLMSG_* with type safe nlmsg_*
Date: Wed, 27 Mar 2013 12:46:08 +0000 [thread overview]
Message-ID: <20130327124608.GA20739@casper.infradead.org> (raw)
In-Reply-To: <1364342762-26861-1-git-send-email-honkiko@gmail.com>
On 03/27/13 at 08:06am, Hong Zhiguo wrote:
> Thomas, please review it. Next should we made nlmsg_* available
> for uapi?
Comments like this should go below the '---' line so they don't
become part of the commit message.
See comments below, I have only listed each point once even though most
of them apply to multiple chunks. So please go over your patch and look
for other occurances for each comment made.
Also, you might have to split up your patch into different non networking
subsystems to get it routed via the respective trees.
> Signed-off-by: Hong Zhiguo <honkiko@gmail.com>
> ---
> drivers/connector/connector.c | 8 ++---
> drivers/scsi/scsi_netlink.c | 4 +--
[...]
> @@ -162,7 +162,7 @@ static void cn_rx_skb(struct sk_buff *__skb)
>
> skb = skb_get(__skb);
>
> - if (skb->len >= NLMSG_SPACE(0)) {
> + if (skb->len >= nlmsg_total_size(0)) {
Can we just replace nlmsg_total_size(0) with NLMSG_HDRLEN. Seems a lot
clearer to me.
> diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
> index e894ca7..394aedb 100644
> --- a/drivers/scsi/scsi_transport_fc.c
> +++ b/drivers/scsi/scsi_transport_fc.c
> @@ -35,7 +35,7 @@
> #include <scsi/scsi_transport.h>
> #include <scsi/scsi_transport_fc.h>
> #include <scsi/scsi_cmnd.h>
> -#include <linux/netlink.h>
> +#include <net/netlink.h>
> #include <net/netlink.h>
You are including <net/netlink.h> twice now.
> @@ -124,7 +124,7 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len)
> return -EINVAL;
> }
>
> - skb = alloc_skb(NLMSG_SPACE(len), GFP_ATOMIC);
> + skb = alloc_skb(nlmsg_total_size(len), GFP_ATOMIC);
We can convert these to nlmsg_new(len, GFP_ATOMIC);
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index aeb8131..1ba25fb 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -2613,10 +2613,10 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
> type -= RTM_BASE;
>
> /* All the messages must have at least 1 byte length */
> - if (nlh->nlmsg_len < NLMSG_LENGTH(sizeof(struct rtgenmsg)))
> + if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(struct rtgenmsg)))
This can be written more clearly as:
if (nlmsg_len(nlh) < sizeof(struct rtgenmsg))
> diff --git a/net/decnet/dn_table.c b/net/decnet/dn_table.c
> index fc42a0a..d98563a 100644
> --- a/net/decnet/dn_table.c
> +++ b/net/decnet/dn_table.c
> @@ -19,7 +19,7 @@
> #include <linux/sockios.h>
> #include <linux/init.h>
> #include <linux/skbuff.h>
> -#include <linux/netlink.h>
> +#include <net/netlink.h>
> #include <linux/rtnetlink.h>
> #include <linux/proc_fs.h>
> #include <linux/netdevice.h>
> @@ -492,7 +492,7 @@ int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb)
> if (!net_eq(net, &init_net))
> return 0;
>
> - if (NLMSG_PAYLOAD(cb->nlh, 0) >= sizeof(struct rtmsg) &&
> + if (nlmsg_attrlen(cb->nlh, 0) >= sizeof(struct rtmsg) &&
nlmsg_attrlen(cb->nlh, 0) is identical to nlmsg_len(cb->nlh) which is
easier to read.
prev parent reply other threads:[~2013-03-27 12:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-27 0:06 [PATCH net-next] netlink: replace obsolete NLMSG_* with type safe nlmsg_* Hong Zhiguo
2013-03-27 12:46 ` Thomas Graf [this message]
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=20130327124608.GA20739@casper.infradead.org \
--to=tgraf@suug.ch \
--cc=davem@davemloft.net \
--cc=honkiko@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.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).