aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorNeil Horman <nhorman@tuxdriver.com>2009-04-27 06:17:31 -0400
committerDavid S. Miller <davem@davemloft.net>2009-04-27 06:17:31 -0400
commit683703a26e4677db437a1480682851e27c7a154f (patch)
tree2279d2b07ea895e84ffffc854fee7771ff674dd7 /net/core
parentfa466e91bdf214e6e136e9da9a46a52775a1e884 (diff)
drop_monitor: Update netlink protocol to include netlink attribute header in alert message
When I initially implemented this protocol, I disregarded the use of netlink attribute headers, thinking for my purposes they weren't needed. I've come to find out that, as I'm starting to work with sending down messages with associated data (like config messages), the kernel code spits out warnings about trailing data in a netlink skb that doesn't have an associated header on it. As such, I'm going to start including attribute headers in my netlink transaction, and so for completeness, I should likely include them on messages bound from the kernel to user space. This patch adds that header to the kernel, and bumps the protocol version accordingly Signed-off-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/drop_monitor.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index 9fd0dc3cca99..2797b711a978 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -51,7 +51,7 @@ static struct genl_family net_drop_monitor_family = {
51 .id = GENL_ID_GENERATE, 51 .id = GENL_ID_GENERATE,
52 .hdrsize = 0, 52 .hdrsize = 0,
53 .name = "NET_DM", 53 .name = "NET_DM",
54 .version = 1, 54 .version = 2,
55 .maxattr = NET_DM_CMD_MAX, 55 .maxattr = NET_DM_CMD_MAX,
56}; 56};
57 57
@@ -65,13 +65,17 @@ static void reset_per_cpu_data(struct per_cpu_dm_data *data)
65{ 65{
66 size_t al; 66 size_t al;
67 struct net_dm_alert_msg *msg; 67 struct net_dm_alert_msg *msg;
68 struct nlattr *nla;
68 69
69 al = sizeof(struct net_dm_alert_msg); 70 al = sizeof(struct net_dm_alert_msg);
70 al += dm_hit_limit * sizeof(struct net_dm_drop_point); 71 al += dm_hit_limit * sizeof(struct net_dm_drop_point);
72 al += sizeof(struct nlattr);
73
71 data->skb = genlmsg_new(al, GFP_KERNEL); 74 data->skb = genlmsg_new(al, GFP_KERNEL);
72 genlmsg_put(data->skb, 0, 0, &net_drop_monitor_family, 75 genlmsg_put(data->skb, 0, 0, &net_drop_monitor_family,
73 0, NET_DM_CMD_ALERT); 76 0, NET_DM_CMD_ALERT);
74 msg = __nla_reserve_nohdr(data->skb, sizeof(struct net_dm_alert_msg)); 77 nla = nla_reserve(data->skb, NLA_UNSPEC, sizeof(struct net_dm_alert_msg));
78 msg = nla_data(nla);
75 memset(msg, 0, al); 79 memset(msg, 0, al);
76 atomic_set(&data->dm_hit_count, dm_hit_limit); 80 atomic_set(&data->dm_hit_count, dm_hit_limit);
77} 81}
@@ -115,6 +119,7 @@ static void trace_kfree_skb_hit(struct sk_buff *skb, void *location)
115{ 119{
116 struct net_dm_alert_msg *msg; 120 struct net_dm_alert_msg *msg;
117 struct nlmsghdr *nlh; 121 struct nlmsghdr *nlh;
122 struct nlattr *nla;
118 int i; 123 int i;
119 struct per_cpu_dm_data *data = &__get_cpu_var(dm_cpu_data); 124 struct per_cpu_dm_data *data = &__get_cpu_var(dm_cpu_data);
120 125
@@ -127,7 +132,8 @@ static void trace_kfree_skb_hit(struct sk_buff *skb, void *location)
127 } 132 }
128 133
129 nlh = (struct nlmsghdr *)data->skb->data; 134 nlh = (struct nlmsghdr *)data->skb->data;
130 msg = genlmsg_data(nlmsg_data(nlh)); 135 nla = genlmsg_data(nlmsg_data(nlh));
136 msg = nla_data(nla);
131 for (i = 0; i < msg->entries; i++) { 137 for (i = 0; i < msg->entries; i++) {
132 if (!memcmp(&location, msg->points[i].pc, sizeof(void *))) { 138 if (!memcmp(&location, msg->points[i].pc, sizeof(void *))) {
133 msg->points[i].count++; 139 msg->points[i].count++;
@@ -139,6 +145,7 @@ static void trace_kfree_skb_hit(struct sk_buff *skb, void *location)
139 * We need to create a new entry 145 * We need to create a new entry
140 */ 146 */
141 __nla_reserve_nohdr(data->skb, sizeof(struct net_dm_drop_point)); 147 __nla_reserve_nohdr(data->skb, sizeof(struct net_dm_drop_point));
148 nla->nla_len += NLA_ALIGN(sizeof(struct net_dm_drop_point));
142 memcpy(msg->points[msg->entries].pc, &location, sizeof(void *)); 149 memcpy(msg->points[msg->entries].pc, &location, sizeof(void *));
143 msg->points[msg->entries].count = 1; 150 msg->points[msg->entries].count = 1;
144 msg->entries++; 151 msg->entries++;