* [PATCH] drop_monitor: add missing call to genlmsg_end
@ 2016-12-31 20:11 Reiter Wolfgang
2017-01-01 2:41 ` Neil Horman
2017-01-02 3:01 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Reiter Wolfgang @ 2016-12-31 20:11 UTC (permalink / raw)
To: nhorman; +Cc: davem, netdev, linux-kernel, Reiter Wolfgang
Update nlmsg_len field with genlmsg_end to enable userspace processing
using nlmsg_next helper. Also adds error handling.
Signed-off-by: Reiter Wolfgang <wr0112358@gmail.com>
---
net/core/drop_monitor.c | 33 ++++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index 8e0c063..f465bad 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -75,6 +75,7 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
struct nlattr *nla;
struct sk_buff *skb;
unsigned long flags;
+ void *msg_header;
al = sizeof(struct net_dm_alert_msg);
al += dm_hit_limit * sizeof(struct net_dm_drop_point);
@@ -82,17 +83,31 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
skb = genlmsg_new(al, GFP_KERNEL);
- if (skb) {
- genlmsg_put(skb, 0, 0, &net_drop_monitor_family,
- 0, NET_DM_CMD_ALERT);
- nla = nla_reserve(skb, NLA_UNSPEC,
- sizeof(struct net_dm_alert_msg));
- msg = nla_data(nla);
- memset(msg, 0, al);
- } else {
- mod_timer(&data->send_timer, jiffies + HZ / 10);
+ if (!skb)
+ goto err;
+
+ msg_header = genlmsg_put(skb, 0, 0, &net_drop_monitor_family,
+ 0, NET_DM_CMD_ALERT);
+ if (!msg_header) {
+ nlmsg_free(skb);
+ skb = NULL;
+ goto err;
+ }
+ nla = nla_reserve(skb, NLA_UNSPEC,
+ sizeof(struct net_dm_alert_msg));
+ if (!nla) {
+ nlmsg_free(skb);
+ skb = NULL;
+ goto err;
}
+ msg = nla_data(nla);
+ memset(msg, 0, al);
+ genlmsg_end(skb, msg_header);
+ goto out;
+err:
+ mod_timer(&data->send_timer, jiffies + HZ / 10);
+out:
spin_lock_irqsave(&data->lock, flags);
swap(data->skb, skb);
spin_unlock_irqrestore(&data->lock, flags);
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drop_monitor: add missing call to genlmsg_end
2016-12-31 20:11 [PATCH] drop_monitor: add missing call to genlmsg_end Reiter Wolfgang
@ 2017-01-01 2:41 ` Neil Horman
2017-01-02 3:01 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Neil Horman @ 2017-01-01 2:41 UTC (permalink / raw)
To: Reiter Wolfgang; +Cc: davem, netdev, linux-kernel
On Sat, Dec 31, 2016 at 09:11:57PM +0100, Reiter Wolfgang wrote:
> Update nlmsg_len field with genlmsg_end to enable userspace processing
> using nlmsg_next helper. Also adds error handling.
>
> Signed-off-by: Reiter Wolfgang <wr0112358@gmail.com>
> ---
> net/core/drop_monitor.c | 33 ++++++++++++++++++++++++---------
> 1 file changed, 24 insertions(+), 9 deletions(-)
>
> diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
> index 8e0c063..f465bad 100644
> --- a/net/core/drop_monitor.c
> +++ b/net/core/drop_monitor.c
> @@ -75,6 +75,7 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
> struct nlattr *nla;
> struct sk_buff *skb;
> unsigned long flags;
> + void *msg_header;
>
> al = sizeof(struct net_dm_alert_msg);
> al += dm_hit_limit * sizeof(struct net_dm_drop_point);
> @@ -82,17 +83,31 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
>
> skb = genlmsg_new(al, GFP_KERNEL);
>
> - if (skb) {
> - genlmsg_put(skb, 0, 0, &net_drop_monitor_family,
> - 0, NET_DM_CMD_ALERT);
> - nla = nla_reserve(skb, NLA_UNSPEC,
> - sizeof(struct net_dm_alert_msg));
> - msg = nla_data(nla);
> - memset(msg, 0, al);
> - } else {
> - mod_timer(&data->send_timer, jiffies + HZ / 10);
> + if (!skb)
> + goto err;
> +
> + msg_header = genlmsg_put(skb, 0, 0, &net_drop_monitor_family,
> + 0, NET_DM_CMD_ALERT);
> + if (!msg_header) {
> + nlmsg_free(skb);
> + skb = NULL;
> + goto err;
> + }
> + nla = nla_reserve(skb, NLA_UNSPEC,
> + sizeof(struct net_dm_alert_msg));
> + if (!nla) {
> + nlmsg_free(skb);
> + skb = NULL;
> + goto err;
> }
> + msg = nla_data(nla);
> + memset(msg, 0, al);
> + genlmsg_end(skb, msg_header);
> + goto out;
>
> +err:
> + mod_timer(&data->send_timer, jiffies + HZ / 10);
> +out:
> spin_lock_irqsave(&data->lock, flags);
> swap(data->skb, skb);
> spin_unlock_irqrestore(&data->lock, flags);
> --
> 2.9.3
>
>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drop_monitor: add missing call to genlmsg_end
2016-12-31 20:11 [PATCH] drop_monitor: add missing call to genlmsg_end Reiter Wolfgang
2017-01-01 2:41 ` Neil Horman
@ 2017-01-02 3:01 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-01-02 3:01 UTC (permalink / raw)
To: wr0112358; +Cc: nhorman, netdev, linux-kernel
From: Reiter Wolfgang <wr0112358@gmail.com>
Date: Sat, 31 Dec 2016 21:11:57 +0100
> Update nlmsg_len field with genlmsg_end to enable userspace processing
> using nlmsg_next helper. Also adds error handling.
>
> Signed-off-by: Reiter Wolfgang <wr0112358@gmail.com>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-02 3:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-31 20:11 [PATCH] drop_monitor: add missing call to genlmsg_end Reiter Wolfgang
2017-01-01 2:41 ` Neil Horman
2017-01-02 3:01 ` David Miller
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).