drop_monitor: consider inserted data in genlmsg_end
authorReiter Wolfgang <wr0112358@gmail.com>
Tue, 3 Jan 2017 00:39:10 +0000 (01:39 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 3 Jan 2017 16:09:44 +0000 (11:09 -0500)
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>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/drop_monitor.c

index f465bad2ef2c69fb6f14010f53a702f2b1546230..fb55327dcfeabdaf3eeecc3a8d176ae215612649 100644 (file)
@@ -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 @@ out:
        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;
 }