Skip to content

Commit

Permalink
drop_monitor: add missing call to genlmsg_end
Browse files Browse the repository at this point in the history
Update nlmsg_len field with genlmsg_end to enable userspace processing
using nlmsg_next helper. Also adds error handling.

Signed-off-by: Reiter Wolfgang <[email protected]>
Acked-by: Neil Horman <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
wr0112358 authored and davem330 committed Jan 2, 2017
1 parent e1a3a60 commit 4200462
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions net/core/drop_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,39 @@ 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);
al += sizeof(struct nlattr);

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);
Expand Down

0 comments on commit 4200462

Please sign in to comment.