Commit 4200462d authored by Reiter Wolfgang's avatar Reiter Wolfgang Committed by David S. Miller

drop_monitor: add missing call to genlmsg_end

Update nlmsg_len field with genlmsg_end to enable userspace processing
using nlmsg_next helper. Also adds error handling.
Signed-off-by: default avatarReiter Wolfgang <wr0112358@gmail.com>
Acked-by: default avatarNeil Horman <nhorman@tuxdriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e1a3a60a
...@@ -75,6 +75,7 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data) ...@@ -75,6 +75,7 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
struct nlattr *nla; struct nlattr *nla;
struct sk_buff *skb; struct sk_buff *skb;
unsigned long flags; unsigned long flags;
void *msg_header;
al = sizeof(struct net_dm_alert_msg); al = sizeof(struct net_dm_alert_msg);
al += dm_hit_limit * sizeof(struct net_dm_drop_point); 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) ...@@ -82,17 +83,31 @@ static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
skb = genlmsg_new(al, GFP_KERNEL); skb = genlmsg_new(al, GFP_KERNEL);
if (skb) { if (!skb)
genlmsg_put(skb, 0, 0, &net_drop_monitor_family, goto err;
0, NET_DM_CMD_ALERT);
nla = nla_reserve(skb, NLA_UNSPEC, msg_header = genlmsg_put(skb, 0, 0, &net_drop_monitor_family,
sizeof(struct net_dm_alert_msg)); 0, NET_DM_CMD_ALERT);
msg = nla_data(nla); if (!msg_header) {
memset(msg, 0, al); nlmsg_free(skb);
} else { skb = NULL;
mod_timer(&data->send_timer, jiffies + HZ / 10); 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); spin_lock_irqsave(&data->lock, flags);
swap(data->skb, skb); swap(data->skb, skb);
spin_unlock_irqrestore(&data->lock, flags); spin_unlock_irqrestore(&data->lock, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment