All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drop_monitor: consider inserted data in genlmsg_end
@ 2017-01-03  0:39 Reiter Wolfgang
  2017-01-03 13:09 ` Neil Horman
  2017-01-03 14:54 ` David Miller
  0 siblings, 2 replies; 8+ messages in thread
From: Reiter Wolfgang @ 2017-01-03  0:39 UTC (permalink / raw)
  To: nhorman; +Cc: davem, netdev, linux-kernel, Reiter Wolfgang

Final nlmsg_len field update must reflect inserted net_dm_drop_point
data.

This patch depends on previous patch:
"drop_monitor: add missing call to genlmsg_end"

Signed-off-by: Reiter Wolfgang <wr0112358@gmail.com>
---
 net/core/drop_monitor.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index f465bad..fb55327 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -102,7 +102,6 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
 	}
 	msg = nla_data(nla);
 	memset(msg, 0, al);
-	genlmsg_end(skb, msg_header);
 	goto out;
 
 err:
@@ -112,6 +111,13 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
 	swap(data->skb, skb);
 	spin_unlock_irqrestore(&data->lock, flags);
 
+	if (skb) {
+		struct nlmsghdr *nlh = (struct nlmsghdr *)skb->data;
+		struct genlmsghdr *gnlh = (struct genlmsghdr *)nlmsg_data(nlh);
+
+		genlmsg_end(skb, genlmsg_data(gnlh));
+	}
+
 	return skb;
 }
 
-- 
2.9.3

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

* Re: [PATCH] drop_monitor: consider inserted data in genlmsg_end
  2017-01-03  0:39 [PATCH] drop_monitor: consider inserted data in genlmsg_end Reiter Wolfgang
@ 2017-01-03 13:09 ` Neil Horman
  2017-01-03 14:54 ` David Miller
  1 sibling, 0 replies; 8+ messages in thread
From: Neil Horman @ 2017-01-03 13:09 UTC (permalink / raw)
  To: Reiter Wolfgang; +Cc: davem, netdev, linux-kernel

On Tue, Jan 03, 2017 at 01:39:10AM +0100, Reiter Wolfgang wrote:
> Final nlmsg_len field update must reflect inserted net_dm_drop_point
> data.
> 
> This patch depends on previous patch:
> "drop_monitor: add missing call to genlmsg_end"
> 
> Signed-off-by: Reiter Wolfgang <wr0112358@gmail.com>
> ---
>  net/core/drop_monitor.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
> index f465bad..fb55327 100644
> --- a/net/core/drop_monitor.c
> +++ b/net/core/drop_monitor.c
> @@ -102,7 +102,6 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
>  	}
>  	msg = nla_data(nla);
>  	memset(msg, 0, al);
> -	genlmsg_end(skb, msg_header);
>  	goto out;
>  
>  err:
> @@ -112,6 +111,13 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
>  	swap(data->skb, skb);
>  	spin_unlock_irqrestore(&data->lock, flags);
>  
> +	if (skb) {
> +		struct nlmsghdr *nlh = (struct nlmsghdr *)skb->data;
> +		struct genlmsghdr *gnlh = (struct genlmsghdr *)nlmsg_data(nlh);
> +
> +		genlmsg_end(skb, genlmsg_data(gnlh));
> +	}
> +
>  	return skb;
>  }
>  
> -- 
> 2.9.3
> 
> 
Acked-by: Neil Horman <nhorman@tuxdriver.com>

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

* Re: [PATCH] drop_monitor: consider inserted data in genlmsg_end
  2017-01-03  0:39 [PATCH] drop_monitor: consider inserted data in genlmsg_end Reiter Wolfgang
  2017-01-03 13:09 ` Neil Horman
@ 2017-01-03 14:54 ` David Miller
  2017-01-03 16:04   ` Neil Horman
  1 sibling, 1 reply; 8+ messages in thread
From: David Miller @ 2017-01-03 14:54 UTC (permalink / raw)
  To: wr0112358; +Cc: nhorman, netdev, linux-kernel

From: Reiter Wolfgang <wr0112358@gmail.com>
Date: Tue,  3 Jan 2017 01:39:10 +0100

> Final nlmsg_len field update must reflect inserted net_dm_drop_point
> data.
> 
> This patch depends on previous patch:
> "drop_monitor: add missing call to genlmsg_end"
> 
> Signed-off-by: Reiter Wolfgang <wr0112358@gmail.com>

I don't understand why the current code doesn't work properly.

All over the tree, the pattern is:

	x = genlmsg_put(skb, ...);
	...
	genlmsg_end(skb, x);

And that is exactly what the code is doing right now.

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

* Re: [PATCH] drop_monitor: consider inserted data in genlmsg_end
  2017-01-03 14:54 ` David Miller
@ 2017-01-03 16:04   ` Neil Horman
  2017-01-03 16:10     ` David Miller
  2017-01-03 23:09     ` Wolfgang Reiter
  0 siblings, 2 replies; 8+ messages in thread
From: Neil Horman @ 2017-01-03 16:04 UTC (permalink / raw)
  To: David Miller; +Cc: wr0112358, netdev, linux-kernel

On Tue, Jan 03, 2017 at 09:54:19AM -0500, David Miller wrote:
> From: Reiter Wolfgang <wr0112358@gmail.com>
> Date: Tue,  3 Jan 2017 01:39:10 +0100
> 
> > Final nlmsg_len field update must reflect inserted net_dm_drop_point
> > data.
> > 
> > This patch depends on previous patch:
> > "drop_monitor: add missing call to genlmsg_end"
> > 
> > Signed-off-by: Reiter Wolfgang <wr0112358@gmail.com>
> 
> I don't understand why the current code doesn't work properly.
> 
> All over the tree, the pattern is:
> 
> 	x = genlmsg_put(skb, ...);
> 	...
> 	genlmsg_end(skb, x);
> 
> And that is exactly what the code is doing right now.
> 

Because reset_per_cpu_data should close the use of of the established skb
that was being written to.  Without this patch we add the END tlv to the skb
that is just getting started for use in the drop monitor, rather than for the
skb that is getting returned for use in sending up to user space listeners.

Or am I missing something?

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

* Re: [PATCH] drop_monitor: consider inserted data in genlmsg_end
  2017-01-03 16:04   ` Neil Horman
@ 2017-01-03 16:10     ` David Miller
  2017-01-03 23:09     ` Wolfgang Reiter
  1 sibling, 0 replies; 8+ messages in thread
From: David Miller @ 2017-01-03 16:10 UTC (permalink / raw)
  To: nhorman; +Cc: wr0112358, netdev, linux-kernel

From: Neil Horman <nhorman@tuxdriver.com>
Date: Tue, 3 Jan 2017 11:04:43 -0500

> On Tue, Jan 03, 2017 at 09:54:19AM -0500, David Miller wrote:
>> From: Reiter Wolfgang <wr0112358@gmail.com>
>> Date: Tue,  3 Jan 2017 01:39:10 +0100
>> 
>> > Final nlmsg_len field update must reflect inserted net_dm_drop_point
>> > data.
>> > 
>> > This patch depends on previous patch:
>> > "drop_monitor: add missing call to genlmsg_end"
>> > 
>> > Signed-off-by: Reiter Wolfgang <wr0112358@gmail.com>
>> 
>> I don't understand why the current code doesn't work properly.
>> 
>> All over the tree, the pattern is:
>> 
>> 	x = genlmsg_put(skb, ...);
>> 	...
>> 	genlmsg_end(skb, x);
>> 
>> And that is exactly what the code is doing right now.
>> 
> 
> Because reset_per_cpu_data should close the use of of the established skb
> that was being written to.  Without this patch we add the END tlv to the skb
> that is just getting started for use in the drop monitor, rather than for the
> skb that is getting returned for use in sending up to user space listeners.
> 
> Or am I missing something?

That's the critical part I didn't see, thanks for explaining.

Applied and queued up for -stabel, thanks.

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

* Re: [PATCH] drop_monitor: consider inserted data in genlmsg_end
  2017-01-03 16:04   ` Neil Horman
  2017-01-03 16:10     ` David Miller
@ 2017-01-03 23:09     ` Wolfgang Reiter
  1 sibling, 0 replies; 8+ messages in thread
From: Wolfgang Reiter @ 2017-01-03 23:09 UTC (permalink / raw)
  To: Neil Horman, David Miller; +Cc: netdev, linux-kernel


Yes, genlmsg_end changes nlmsg_len field dependent on skb->tail.
After allocation in reset_per_cpu_data skb->tail is modified in
trace_drop_common via __nla_reserve_nohdr.

Best place for setting nlmsg_len to its final value is after being
swapped out in reset_per_cpu_data.

Neil Horman <nhorman@tuxdriver.com> writes:

> On Tue, Jan 03, 2017 at 09:54:19AM -0500, David Miller wrote:
>> From: Reiter Wolfgang <wr0112358@gmail.com>
>> Date: Tue,  3 Jan 2017 01:39:10 +0100
>> 
>> > Final nlmsg_len field update must reflect inserted net_dm_drop_point
>> > data.
>> > 
>> > This patch depends on previous patch:
>> > "drop_monitor: add missing call to genlmsg_end"
>> > 
>> > Signed-off-by: Reiter Wolfgang <wr0112358@gmail.com>
>> 
>> I don't understand why the current code doesn't work properly.
>> 
>> All over the tree, the pattern is:
>> 
>> 	x = genlmsg_put(skb, ...);
>> 	...
>> 	genlmsg_end(skb, x);
>> 
>> And that is exactly what the code is doing right now.
>> 
>
> Because reset_per_cpu_data should close the use of of the established skb
> that was being written to.  Without this patch we add the END tlv to the skb
> that is just getting started for use in the drop monitor, rather than for the
> skb that is getting returned for use in sending up to user space listeners.
>
> Or am I missing something?

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

* Re: [PATCH] drop_monitor: consider inserted data in genlmsg_end
  2017-01-02 23:34 Reiter Wolfgang
@ 2017-01-03  0:30 ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2017-01-03  0:30 UTC (permalink / raw)
  To: wr0112358; +Cc: nhorman, netdev, linux-kernel

From: Reiter Wolfgang <wr0112358@gmail.com>
Date: Tue,  3 Jan 2017 00:34:10 +0100

> Final nlmsg_len field update must reflect inserted net_dm_drop_point
> data.
> 
> This patch depends on previous patch:
> "drop_monitor: add missing call to genlmsg_end"
> 
> Signed-off-by: Reiter Wolfgang <wr0112358@gmail.com>

Several coding style errors:

> @@ -112,6 +111,12 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
>  	swap(data->skb, skb);
>  	spin_unlock_irqrestore(&data->lock, flags);
>  
> +	if(skb) {

There must be a space between "if" and "(skb)"

> +		struct nlmsghdr *nlh = (struct nlmsghdr *)skb->data;
> +		struct genlmsghdr *gnlh = (struct genlmsghdr *)nlmsg_data(nlh);
> +		genlmsg_end(skb, genlmsg_data(gnlh));
> +	}

There should be an empty line between the local variable declarations
and actual code.

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

* [PATCH] drop_monitor: consider inserted data in genlmsg_end
@ 2017-01-02 23:34 Reiter Wolfgang
  2017-01-03  0:30 ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Reiter Wolfgang @ 2017-01-02 23:34 UTC (permalink / raw)
  To: nhorman; +Cc: davem, netdev, linux-kernel, Reiter Wolfgang

Final nlmsg_len field update must reflect inserted net_dm_drop_point
data.

This patch depends on previous patch:
"drop_monitor: add missing call to genlmsg_end"

Signed-off-by: Reiter Wolfgang <wr0112358@gmail.com>
---
 net/core/drop_monitor.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index f465bad..ccaaf3e 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -102,7 +102,6 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
 	}
 	msg = nla_data(nla);
 	memset(msg, 0, al);
-	genlmsg_end(skb, msg_header);
 	goto out;
 
 err:
@@ -112,6 +111,12 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
 	swap(data->skb, skb);
 	spin_unlock_irqrestore(&data->lock, flags);
 
+	if(skb) {
+		struct nlmsghdr *nlh = (struct nlmsghdr *)skb->data;
+		struct genlmsghdr *gnlh = (struct genlmsghdr *)nlmsg_data(nlh);
+		genlmsg_end(skb, genlmsg_data(gnlh));
+	}
+
 	return skb;
 }
 
-- 
2.9.3

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

end of thread, other threads:[~2017-01-03 23:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-03  0:39 [PATCH] drop_monitor: consider inserted data in genlmsg_end Reiter Wolfgang
2017-01-03 13:09 ` Neil Horman
2017-01-03 14:54 ` David Miller
2017-01-03 16:04   ` Neil Horman
2017-01-03 16:10     ` David Miller
2017-01-03 23:09     ` Wolfgang Reiter
  -- strict thread matches above, loose matches on Subject: below --
2017-01-02 23:34 Reiter Wolfgang
2017-01-03  0:30 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.