aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2012-06-27 23:57:45 -0400
committerDavid S. Miller <davem@davemloft.net>2012-06-28 20:56:43 -0400
commit58050fce3530939372e6c2f4b4beb76fcb4caa65 (patch)
treeee2b85eda9973fed36102dad66f583e43a4a6cab
parent9f10d3f6f966ef6f6a8d025a4b1d341923d04607 (diff)
net: Use NLMSG_DEFAULT_SIZE in combination with nlmsg_new()
Using NLMSG_GOODSIZE results in multiple pages being used as nlmsg_new() will automatically add the size of the netlink header to the payload thus exceeding the page limit. NLMSG_DEFAULT_SIZE takes this into account. Signed-off-by: Thomas Graf <tgraf@suug.ch> Cc: Jiri Pirko <jpirko@redhat.com> Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Cc: Sergey Lapin <slapin@ossfans.org> Cc: Johannes Berg <johannes@sipsolutions.net> Cc: Lauro Ramos Venancio <lauro.venancio@openbossa.org> Cc: Aloisio Almeida Jr <aloisio.almeida@openbossa.org> Cc: Samuel Ortiz <sameo@linux.intel.com> Reviewed-by: Jiri Pirko <jpirko@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/team/team.c8
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c2
-rw-r--r--include/net/genetlink.h2
-rw-r--r--net/ieee802154/netlink.c4
-rw-r--r--net/ieee802154/nl-mac.c2
-rw-r--r--net/ieee802154/nl-phy.c2
-rw-r--r--net/l2tp/l2tp_netlink.c6
-rw-r--r--net/nfc/netlink.c18
-rw-r--r--net/wireless/nl80211.c26
9 files changed, 36 insertions, 34 deletions
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 5350eeaa22ce..89853c31e7f4 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -1476,7 +1476,7 @@ static int team_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info)
1476 void *hdr; 1476 void *hdr;
1477 int err; 1477 int err;
1478 1478
1479 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 1479 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1480 if (!msg) 1480 if (!msg)
1481 return -ENOMEM; 1481 return -ENOMEM;
1482 1482
@@ -1538,7 +1538,7 @@ static int team_nl_send_generic(struct genl_info *info, struct team *team,
1538 struct sk_buff *skb; 1538 struct sk_buff *skb;
1539 int err; 1539 int err;
1540 1540
1541 skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 1541 skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1542 if (!skb) 1542 if (!skb)
1543 return -ENOMEM; 1543 return -ENOMEM;
1544 1544
@@ -1648,7 +1648,7 @@ static int __send_and_alloc_skb(struct sk_buff **pskb,
1648 if (err) 1648 if (err)
1649 return err; 1649 return err;
1650 } 1650 }
1651 *pskb = genlmsg_new(NLMSG_DEFAULT_SIZE - GENL_HDRLEN, GFP_KERNEL); 1651 *pskb = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_KERNEL);
1652 if (!*pskb) 1652 if (!*pskb)
1653 return -ENOMEM; 1653 return -ENOMEM;
1654 return 0; 1654 return 0;
@@ -2016,7 +2016,7 @@ static int team_nl_send_event_port_list_get(struct team *team)
2016 int err; 2016 int err;
2017 struct net *net = dev_net(team->dev); 2017 struct net *net = dev_net(team->dev);
2018 2018
2019 skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 2019 skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
2020 if (!skb) 2020 if (!skb)
2021 return -ENOMEM; 2021 return -ENOMEM;
2022 2022
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index a0b7cfd34685..a9ba3f7ea62b 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -571,7 +571,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
571 skb_dequeue(&data->pending); 571 skb_dequeue(&data->pending);
572 } 572 }
573 573
574 skb = genlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); 574 skb = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_ATOMIC);
575 if (skb == NULL) 575 if (skb == NULL)
576 goto nla_put_failure; 576 goto nla_put_failure;
577 577
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index ccb68880abf5..48905cd3884c 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -5,6 +5,8 @@
5#include <net/netlink.h> 5#include <net/netlink.h>
6#include <net/net_namespace.h> 6#include <net/net_namespace.h>
7 7
8#define GENLMSG_DEFAULT_SIZE (NLMSG_DEFAULT_SIZE - GENL_HDRLEN)
9
8/** 10/**
9 * struct genl_multicast_group - generic netlink multicast group 11 * struct genl_multicast_group - generic netlink multicast group
10 * @name: name of the multicast group, names are per-family 12 * @name: name of the multicast group, names are per-family
diff --git a/net/ieee802154/netlink.c b/net/ieee802154/netlink.c
index c8097ae2482f..97351e1d07a4 100644
--- a/net/ieee802154/netlink.c
+++ b/net/ieee802154/netlink.c
@@ -44,7 +44,7 @@ struct genl_family nl802154_family = {
44struct sk_buff *ieee802154_nl_create(int flags, u8 req) 44struct sk_buff *ieee802154_nl_create(int flags, u8 req)
45{ 45{
46 void *hdr; 46 void *hdr;
47 struct sk_buff *msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); 47 struct sk_buff *msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
48 unsigned long f; 48 unsigned long f;
49 49
50 if (!msg) 50 if (!msg)
@@ -80,7 +80,7 @@ struct sk_buff *ieee802154_nl_new_reply(struct genl_info *info,
80 int flags, u8 req) 80 int flags, u8 req)
81{ 81{
82 void *hdr; 82 void *hdr;
83 struct sk_buff *msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); 83 struct sk_buff *msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
84 84
85 if (!msg) 85 if (!msg)
86 return NULL; 86 return NULL;
diff --git a/net/ieee802154/nl-mac.c b/net/ieee802154/nl-mac.c
index ca92587720f4..1e9917124e75 100644
--- a/net/ieee802154/nl-mac.c
+++ b/net/ieee802154/nl-mac.c
@@ -530,7 +530,7 @@ static int ieee802154_list_iface(struct sk_buff *skb,
530 if (!dev) 530 if (!dev)
531 return -ENODEV; 531 return -ENODEV;
532 532
533 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 533 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
534 if (!msg) 534 if (!msg)
535 goto out_dev; 535 goto out_dev;
536 536
diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
index eed291626da6..d54be34cca94 100644
--- a/net/ieee802154/nl-phy.c
+++ b/net/ieee802154/nl-phy.c
@@ -101,7 +101,7 @@ static int ieee802154_list_phy(struct sk_buff *skb,
101 if (!phy) 101 if (!phy)
102 return -ENODEV; 102 return -ENODEV;
103 103
104 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 104 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
105 if (!msg) 105 if (!msg)
106 goto out_dev; 106 goto out_dev;
107 107
diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c
index ddc553e76671..d71cd9229a47 100644
--- a/net/l2tp/l2tp_netlink.c
+++ b/net/l2tp/l2tp_netlink.c
@@ -72,7 +72,7 @@ static int l2tp_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info)
72 void *hdr; 72 void *hdr;
73 int ret = -ENOBUFS; 73 int ret = -ENOBUFS;
74 74
75 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 75 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
76 if (!msg) { 76 if (!msg) {
77 ret = -ENOMEM; 77 ret = -ENOMEM;
78 goto out; 78 goto out;
@@ -353,7 +353,7 @@ static int l2tp_nl_cmd_tunnel_get(struct sk_buff *skb, struct genl_info *info)
353 goto out; 353 goto out;
354 } 354 }
355 355
356 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 356 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
357 if (!msg) { 357 if (!msg) {
358 ret = -ENOMEM; 358 ret = -ENOMEM;
359 goto out; 359 goto out;
@@ -699,7 +699,7 @@ static int l2tp_nl_cmd_session_get(struct sk_buff *skb, struct genl_info *info)
699 goto out; 699 goto out;
700 } 700 }
701 701
702 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 702 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
703 if (!msg) { 703 if (!msg) {
704 ret = -ENOMEM; 704 ret = -ENOMEM;
705 goto out; 705 goto out;
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index 03c31db38f12..f4f07f9b61c0 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -167,7 +167,7 @@ int nfc_genl_targets_found(struct nfc_dev *dev)
167 167
168 dev->genl_data.poll_req_pid = 0; 168 dev->genl_data.poll_req_pid = 0;
169 169
170 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); 170 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
171 if (!msg) 171 if (!msg)
172 return -ENOMEM; 172 return -ENOMEM;
173 173
@@ -195,7 +195,7 @@ int nfc_genl_target_lost(struct nfc_dev *dev, u32 target_idx)
195 struct sk_buff *msg; 195 struct sk_buff *msg;
196 void *hdr; 196 void *hdr;
197 197
198 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 198 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
199 if (!msg) 199 if (!msg)
200 return -ENOMEM; 200 return -ENOMEM;
201 201
@@ -226,7 +226,7 @@ int nfc_genl_tm_activated(struct nfc_dev *dev, u32 protocol)
226 struct sk_buff *msg; 226 struct sk_buff *msg;
227 void *hdr; 227 void *hdr;
228 228
229 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 229 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
230 if (!msg) 230 if (!msg)
231 return -ENOMEM; 231 return -ENOMEM;
232 232
@@ -258,7 +258,7 @@ int nfc_genl_tm_deactivated(struct nfc_dev *dev)
258 struct sk_buff *msg; 258 struct sk_buff *msg;
259 void *hdr; 259 void *hdr;
260 260
261 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 261 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
262 if (!msg) 262 if (!msg)
263 return -ENOMEM; 263 return -ENOMEM;
264 264
@@ -288,7 +288,7 @@ int nfc_genl_device_added(struct nfc_dev *dev)
288 struct sk_buff *msg; 288 struct sk_buff *msg;
289 void *hdr; 289 void *hdr;
290 290
291 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 291 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
292 if (!msg) 292 if (!msg)
293 return -ENOMEM; 293 return -ENOMEM;
294 294
@@ -321,7 +321,7 @@ int nfc_genl_device_removed(struct nfc_dev *dev)
321 struct sk_buff *msg; 321 struct sk_buff *msg;
322 void *hdr; 322 void *hdr;
323 323
324 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 324 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
325 if (!msg) 325 if (!msg)
326 return -ENOMEM; 326 return -ENOMEM;
327 327
@@ -434,7 +434,7 @@ int nfc_genl_dep_link_up_event(struct nfc_dev *dev, u32 target_idx,
434 434
435 pr_debug("DEP link is up\n"); 435 pr_debug("DEP link is up\n");
436 436
437 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); 437 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
438 if (!msg) 438 if (!msg)
439 return -ENOMEM; 439 return -ENOMEM;
440 440
@@ -473,7 +473,7 @@ int nfc_genl_dep_link_down_event(struct nfc_dev *dev)
473 473
474 pr_debug("DEP link is down\n"); 474 pr_debug("DEP link is down\n");
475 475
476 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); 476 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
477 if (!msg) 477 if (!msg)
478 return -ENOMEM; 478 return -ENOMEM;
479 479
@@ -514,7 +514,7 @@ static int nfc_genl_get_device(struct sk_buff *skb, struct genl_info *info)
514 if (!dev) 514 if (!dev)
515 return -ENODEV; 515 return -ENODEV;
516 516
517 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 517 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
518 if (!msg) { 518 if (!msg) {
519 rc = -ENOMEM; 519 rc = -ENOMEM;
520 goto out_putdev; 520 goto out_putdev;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 7ae54b82291f..cbdc0fd67a14 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -7210,7 +7210,7 @@ void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
7210{ 7210{
7211 struct sk_buff *msg; 7211 struct sk_buff *msg;
7212 7212
7213 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 7213 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
7214 if (!msg) 7214 if (!msg)
7215 return; 7215 return;
7216 7216
@@ -7286,7 +7286,7 @@ void nl80211_send_sched_scan(struct cfg80211_registered_device *rdev,
7286{ 7286{
7287 struct sk_buff *msg; 7287 struct sk_buff *msg;
7288 7288
7289 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 7289 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
7290 if (!msg) 7290 if (!msg)
7291 return; 7291 return;
7292 7292
@@ -7502,7 +7502,7 @@ void nl80211_send_connect_result(struct cfg80211_registered_device *rdev,
7502 struct sk_buff *msg; 7502 struct sk_buff *msg;
7503 void *hdr; 7503 void *hdr;
7504 7504
7505 msg = nlmsg_new(NLMSG_GOODSIZE, gfp); 7505 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
7506 if (!msg) 7506 if (!msg)
7507 return; 7507 return;
7508 7508
@@ -7542,7 +7542,7 @@ void nl80211_send_roamed(struct cfg80211_registered_device *rdev,
7542 struct sk_buff *msg; 7542 struct sk_buff *msg;
7543 void *hdr; 7543 void *hdr;
7544 7544
7545 msg = nlmsg_new(NLMSG_GOODSIZE, gfp); 7545 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
7546 if (!msg) 7546 if (!msg)
7547 return; 7547 return;
7548 7548
@@ -7580,7 +7580,7 @@ void nl80211_send_disconnected(struct cfg80211_registered_device *rdev,
7580 struct sk_buff *msg; 7580 struct sk_buff *msg;
7581 void *hdr; 7581 void *hdr;
7582 7582
7583 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 7583 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
7584 if (!msg) 7584 if (!msg)
7585 return; 7585 return;
7586 7586
@@ -7842,7 +7842,7 @@ void nl80211_send_sta_event(struct cfg80211_registered_device *rdev,
7842{ 7842{
7843 struct sk_buff *msg; 7843 struct sk_buff *msg;
7844 7844
7845 msg = nlmsg_new(NLMSG_GOODSIZE, gfp); 7845 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
7846 if (!msg) 7846 if (!msg)
7847 return; 7847 return;
7848 7848
@@ -7863,7 +7863,7 @@ void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev,
7863 struct sk_buff *msg; 7863 struct sk_buff *msg;
7864 void *hdr; 7864 void *hdr;
7865 7865
7866 msg = nlmsg_new(NLMSG_GOODSIZE, gfp); 7866 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
7867 if (!msg) 7867 if (!msg)
7868 return; 7868 return;
7869 7869
@@ -8026,7 +8026,7 @@ nl80211_send_cqm_rssi_notify(struct cfg80211_registered_device *rdev,
8026 struct nlattr *pinfoattr; 8026 struct nlattr *pinfoattr;
8027 void *hdr; 8027 void *hdr;
8028 8028
8029 msg = nlmsg_new(NLMSG_GOODSIZE, gfp); 8029 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
8030 if (!msg) 8030 if (!msg)
8031 return; 8031 return;
8032 8032
@@ -8069,7 +8069,7 @@ void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev,
8069 struct nlattr *rekey_attr; 8069 struct nlattr *rekey_attr;
8070 void *hdr; 8070 void *hdr;
8071 8071
8072 msg = nlmsg_new(NLMSG_GOODSIZE, gfp); 8072 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
8073 if (!msg) 8073 if (!msg)
8074 return; 8074 return;
8075 8075
@@ -8113,7 +8113,7 @@ void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev,
8113 struct nlattr *attr; 8113 struct nlattr *attr;
8114 void *hdr; 8114 void *hdr;
8115 8115
8116 msg = nlmsg_new(NLMSG_GOODSIZE, gfp); 8116 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
8117 if (!msg) 8117 if (!msg)
8118 return; 8118 return;
8119 8119
@@ -8157,7 +8157,7 @@ void nl80211_ch_switch_notify(struct cfg80211_registered_device *rdev,
8157 struct sk_buff *msg; 8157 struct sk_buff *msg;
8158 void *hdr; 8158 void *hdr;
8159 8159
8160 msg = nlmsg_new(NLMSG_GOODSIZE, gfp); 8160 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
8161 if (!msg) 8161 if (!msg)
8162 return; 8162 return;
8163 8163
@@ -8192,7 +8192,7 @@ nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev,
8192 struct nlattr *pinfoattr; 8192 struct nlattr *pinfoattr;
8193 void *hdr; 8193 void *hdr;
8194 8194
8195 msg = nlmsg_new(NLMSG_GOODSIZE, gfp); 8195 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
8196 if (!msg) 8196 if (!msg)
8197 return; 8197 return;
8198 8198
@@ -8236,7 +8236,7 @@ void cfg80211_probe_status(struct net_device *dev, const u8 *addr,
8236 void *hdr; 8236 void *hdr;
8237 int err; 8237 int err;
8238 8238
8239 msg = nlmsg_new(NLMSG_GOODSIZE, gfp); 8239 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
8240 if (!msg) 8240 if (!msg)
8241 return; 8241 return;
8242 8242