linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Thomas Graf <tgraf@suug.ch>
Cc: linux-can@vger.kernel.org, Marc Kleine-Budde <mkl@pengutronix.de>
Subject: Re: [PATCH 3/4] can: Properly fill the netlink header when responding to RTM_GETROUTE
Date: Sat, 07 Jul 2012 11:18:33 +0200	[thread overview]
Message-ID: <4FF7FEE9.1000509@hartkopp.net> (raw)
In-Reply-To: <f719ba361ffa7d76dc1248d41acdbe726ecd9c4c.1341489914.git.tgraf@suug.ch>

Hello Thomas,

besides the fact that i would like to simplify this patch (3/4) as shown
below, i was able to test it now.

You may add my

Tested-by: Oliver Hartkopp <socketcan@hartkopp.net>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>

to the next post.

Do you have an URL to pull this patch set for Marc?

Thanks for your effort!

Best regards,
Oliver



On 05.07.2012 14:19, Thomas Graf wrote:

>  - set message type to RTM_NEWROUTE
>  - relate to original request by inheriting the sequence and port number.
>  - set NLM_F_MULTI because it's a dump and more messages will follow
> 
> Signed-off-by: Thomas Graf <tgraf@suug.ch>
> ---
>  net/can/gw.c |   10 +++++++---
>  1 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/net/can/gw.c b/net/can/gw.c
> index a1c639c..20c36e1 100644
> --- a/net/can/gw.c
> +++ b/net/can/gw.c
> @@ -444,11 +444,14 @@ static int cgw_notifier(struct notifier_block *nb,
>  	return NOTIFY_DONE;
>  }
>  
> -static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
> +static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj, int type,
> +		       u32 pid, u32 seq, int flags)
>  {
>  	struct cgw_frame_mod mb;
>  	struct rtcanmsg *rtcan;
> -	struct nlmsghdr *nlh = nlmsg_put(skb, 0, 0, 0, sizeof(*rtcan), 0);
> +	struct nlmsghdr *nlh;
> +
> +	nlh = nlmsg_put(skb, pid, seq, type, sizeof(*rtcan), flags);
>  	if (!nlh)
>  		return -EMSGSIZE;
>  
> @@ -546,7 +549,8 @@ static int cgw_dump_jobs(struct sk_buff *skb, struct netlink_callback *cb)
>  		if (idx < s_idx)
>  			goto cont;
>  
> -		if (cgw_put_job(skb, gwj) < 0)
> +		if (cgw_put_job(skb, gwj, RTM_NEWROUTE, NETLINK_CB(cb->skb).pid,
> +		    cb->nlh->nlmsg_seq, NLM_F_MULTI) < 0)
>  			break;
>  cont:
>  		idx++;




Hello Thomas,

what about this approach which reduces the number of parameters and stack
space when calling cgw_put_job() ??


diff --git a/net/can/gw.c b/net/can/gw.c
index b41acf2..b6b9e0a 100644
--- a/net/can/gw.c
+++ b/net/can/gw.c
@@ -444,11 +444,15 @@ static int cgw_notifier(struct notifier_block *nb,
 	return NOTIFY_DONE;
 }
-static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj)
+static int cgw_put_job(struct sk_buff *skb, struct cgw_job *gwj,
+		       struct netlink_callback *cb)
 {
 	struct cgw_frame_mod mb;
 	struct rtcanmsg *rtcan;
-	struct nlmsghdr *nlh = nlmsg_put(skb, 0, 0, 0, sizeof(*rtcan), 0);
+	struct nlmsghdr *nlh;
+
+	nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq,
+			RTM_NEWROUTE, sizeof(*rtcan), NLM_F_MULTI);
 	if (!nlh)
 		return -EMSGSIZE;
@@ -571,7 +575,7 @@ static int cgw_dump_jobs(struct sk_buff *skb, struct netlink_callback *cb)
 		if (idx < s_idx)
 			goto cont;
-		if (cgw_put_job(skb, gwj) < 0)
+		if (cgw_put_job(skb, gwj, cb) < 0)
 			break;
 cont:
 		idx++;


Regards,
Oliver

  parent reply	other threads:[~2012-07-07  9:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-05 12:19 [PATCH 0/4] can: gw: Netlink related fixes Thomas Graf
2012-07-05 12:19 ` [PATCH 1/4] can: Don't bump nlmsg_len manually Thomas Graf
2012-07-05 12:19 ` [PATCH 2/4] can: Use nla_policy to validate netlink attributes Thomas Graf
2012-07-05 12:19 ` [PATCH 3/4] can: Properly fill the netlink header when responding to RTM_GETROUTE Thomas Graf
2012-07-06 20:39   ` Oliver Hartkopp
2012-07-09  9:43     ` Thomas Graf
2012-07-09 16:28       ` Oliver Hartkopp
2012-07-07  9:18   ` Oliver Hartkopp [this message]
2012-07-10 15:29     ` Marc Kleine-Budde
2012-07-10 18:48       ` Oliver Hartkopp
2012-07-05 12:19 ` [PATCH 4/4] can: Remove pointless casts Thomas Graf
2012-07-05 16:16 ` [PATCH 0/4] can: gw: Netlink related fixes Oliver Hartkopp
2012-07-10 20:55 ` Marc Kleine-Budde

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=4FF7FEE9.1000509@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --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).