Commit 58050fce authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

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: default avatarThomas 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: default avatarJiri Pirko <jpirko@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9f10d3f6
...@@ -1476,7 +1476,7 @@ static int team_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info) ...@@ -1476,7 +1476,7 @@ static int team_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info)
void *hdr; void *hdr;
int err; int err;
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) if (!msg)
return -ENOMEM; return -ENOMEM;
...@@ -1538,7 +1538,7 @@ static int team_nl_send_generic(struct genl_info *info, struct team *team, ...@@ -1538,7 +1538,7 @@ static int team_nl_send_generic(struct genl_info *info, struct team *team,
struct sk_buff *skb; struct sk_buff *skb;
int err; int err;
skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!skb) if (!skb)
return -ENOMEM; return -ENOMEM;
...@@ -1648,7 +1648,7 @@ static int __send_and_alloc_skb(struct sk_buff **pskb, ...@@ -1648,7 +1648,7 @@ static int __send_and_alloc_skb(struct sk_buff **pskb,
if (err) if (err)
return err; return err;
} }
*pskb = genlmsg_new(NLMSG_DEFAULT_SIZE - GENL_HDRLEN, GFP_KERNEL); *pskb = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!*pskb) if (!*pskb)
return -ENOMEM; return -ENOMEM;
return 0; return 0;
...@@ -2016,7 +2016,7 @@ static int team_nl_send_event_port_list_get(struct team *team) ...@@ -2016,7 +2016,7 @@ static int team_nl_send_event_port_list_get(struct team *team)
int err; int err;
struct net *net = dev_net(team->dev); struct net *net = dev_net(team->dev);
skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!skb) if (!skb)
return -ENOMEM; return -ENOMEM;
......
...@@ -571,7 +571,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw, ...@@ -571,7 +571,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
skb_dequeue(&data->pending); skb_dequeue(&data->pending);
} }
skb = genlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); skb = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_ATOMIC);
if (skb == NULL) if (skb == NULL)
goto nla_put_failure; goto nla_put_failure;
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include <net/netlink.h> #include <net/netlink.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#define GENLMSG_DEFAULT_SIZE (NLMSG_DEFAULT_SIZE - GENL_HDRLEN)
/** /**
* struct genl_multicast_group - generic netlink multicast group * struct genl_multicast_group - generic netlink multicast group
* @name: name of the multicast group, names are per-family * @name: name of the multicast group, names are per-family
......
...@@ -44,7 +44,7 @@ struct genl_family nl802154_family = { ...@@ -44,7 +44,7 @@ struct genl_family nl802154_family = {
struct sk_buff *ieee802154_nl_create(int flags, u8 req) struct sk_buff *ieee802154_nl_create(int flags, u8 req)
{ {
void *hdr; void *hdr;
struct sk_buff *msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); struct sk_buff *msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
unsigned long f; unsigned long f;
if (!msg) if (!msg)
...@@ -80,7 +80,7 @@ struct sk_buff *ieee802154_nl_new_reply(struct genl_info *info, ...@@ -80,7 +80,7 @@ struct sk_buff *ieee802154_nl_new_reply(struct genl_info *info,
int flags, u8 req) int flags, u8 req)
{ {
void *hdr; void *hdr;
struct sk_buff *msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); struct sk_buff *msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
if (!msg) if (!msg)
return NULL; return NULL;
......
...@@ -530,7 +530,7 @@ static int ieee802154_list_iface(struct sk_buff *skb, ...@@ -530,7 +530,7 @@ static int ieee802154_list_iface(struct sk_buff *skb,
if (!dev) if (!dev)
return -ENODEV; return -ENODEV;
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) if (!msg)
goto out_dev; goto out_dev;
......
...@@ -101,7 +101,7 @@ static int ieee802154_list_phy(struct sk_buff *skb, ...@@ -101,7 +101,7 @@ static int ieee802154_list_phy(struct sk_buff *skb,
if (!phy) if (!phy)
return -ENODEV; return -ENODEV;
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) if (!msg)
goto out_dev; goto out_dev;
......
...@@ -72,7 +72,7 @@ static int l2tp_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info) ...@@ -72,7 +72,7 @@ static int l2tp_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info)
void *hdr; void *hdr;
int ret = -ENOBUFS; int ret = -ENOBUFS;
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) { if (!msg) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
...@@ -353,7 +353,7 @@ static int l2tp_nl_cmd_tunnel_get(struct sk_buff *skb, struct genl_info *info) ...@@ -353,7 +353,7 @@ static int l2tp_nl_cmd_tunnel_get(struct sk_buff *skb, struct genl_info *info)
goto out; goto out;
} }
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) { if (!msg) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
...@@ -699,7 +699,7 @@ static int l2tp_nl_cmd_session_get(struct sk_buff *skb, struct genl_info *info) ...@@ -699,7 +699,7 @@ static int l2tp_nl_cmd_session_get(struct sk_buff *skb, struct genl_info *info)
goto out; goto out;
} }
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) { if (!msg) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
......
...@@ -167,7 +167,7 @@ int nfc_genl_targets_found(struct nfc_dev *dev) ...@@ -167,7 +167,7 @@ int nfc_genl_targets_found(struct nfc_dev *dev)
dev->genl_data.poll_req_pid = 0; dev->genl_data.poll_req_pid = 0;
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
if (!msg) if (!msg)
return -ENOMEM; return -ENOMEM;
...@@ -195,7 +195,7 @@ int nfc_genl_target_lost(struct nfc_dev *dev, u32 target_idx) ...@@ -195,7 +195,7 @@ int nfc_genl_target_lost(struct nfc_dev *dev, u32 target_idx)
struct sk_buff *msg; struct sk_buff *msg;
void *hdr; void *hdr;
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) if (!msg)
return -ENOMEM; return -ENOMEM;
...@@ -226,7 +226,7 @@ int nfc_genl_tm_activated(struct nfc_dev *dev, u32 protocol) ...@@ -226,7 +226,7 @@ int nfc_genl_tm_activated(struct nfc_dev *dev, u32 protocol)
struct sk_buff *msg; struct sk_buff *msg;
void *hdr; void *hdr;
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) if (!msg)
return -ENOMEM; return -ENOMEM;
...@@ -258,7 +258,7 @@ int nfc_genl_tm_deactivated(struct nfc_dev *dev) ...@@ -258,7 +258,7 @@ int nfc_genl_tm_deactivated(struct nfc_dev *dev)
struct sk_buff *msg; struct sk_buff *msg;
void *hdr; void *hdr;
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) if (!msg)
return -ENOMEM; return -ENOMEM;
...@@ -288,7 +288,7 @@ int nfc_genl_device_added(struct nfc_dev *dev) ...@@ -288,7 +288,7 @@ int nfc_genl_device_added(struct nfc_dev *dev)
struct sk_buff *msg; struct sk_buff *msg;
void *hdr; void *hdr;
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) if (!msg)
return -ENOMEM; return -ENOMEM;
...@@ -321,7 +321,7 @@ int nfc_genl_device_removed(struct nfc_dev *dev) ...@@ -321,7 +321,7 @@ int nfc_genl_device_removed(struct nfc_dev *dev)
struct sk_buff *msg; struct sk_buff *msg;
void *hdr; void *hdr;
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) if (!msg)
return -ENOMEM; return -ENOMEM;
...@@ -434,7 +434,7 @@ int nfc_genl_dep_link_up_event(struct nfc_dev *dev, u32 target_idx, ...@@ -434,7 +434,7 @@ int nfc_genl_dep_link_up_event(struct nfc_dev *dev, u32 target_idx,
pr_debug("DEP link is up\n"); pr_debug("DEP link is up\n");
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
if (!msg) if (!msg)
return -ENOMEM; return -ENOMEM;
...@@ -473,7 +473,7 @@ int nfc_genl_dep_link_down_event(struct nfc_dev *dev) ...@@ -473,7 +473,7 @@ int nfc_genl_dep_link_down_event(struct nfc_dev *dev)
pr_debug("DEP link is down\n"); pr_debug("DEP link is down\n");
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
if (!msg) if (!msg)
return -ENOMEM; return -ENOMEM;
...@@ -514,7 +514,7 @@ static int nfc_genl_get_device(struct sk_buff *skb, struct genl_info *info) ...@@ -514,7 +514,7 @@ static int nfc_genl_get_device(struct sk_buff *skb, struct genl_info *info)
if (!dev) if (!dev)
return -ENODEV; return -ENODEV;
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) { if (!msg) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_putdev; goto out_putdev;
......
...@@ -7210,7 +7210,7 @@ void nl80211_send_scan_start(struct cfg80211_registered_device *rdev, ...@@ -7210,7 +7210,7 @@ void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
{ {
struct sk_buff *msg; struct sk_buff *msg;
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) if (!msg)
return; return;
...@@ -7286,7 +7286,7 @@ void nl80211_send_sched_scan(struct cfg80211_registered_device *rdev, ...@@ -7286,7 +7286,7 @@ void nl80211_send_sched_scan(struct cfg80211_registered_device *rdev,
{ {
struct sk_buff *msg; struct sk_buff *msg;
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) if (!msg)
return; return;
...@@ -7502,7 +7502,7 @@ void nl80211_send_connect_result(struct cfg80211_registered_device *rdev, ...@@ -7502,7 +7502,7 @@ void nl80211_send_connect_result(struct cfg80211_registered_device *rdev,
struct sk_buff *msg; struct sk_buff *msg;
void *hdr; void *hdr;
msg = nlmsg_new(NLMSG_GOODSIZE, gfp); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
if (!msg) if (!msg)
return; return;
...@@ -7542,7 +7542,7 @@ void nl80211_send_roamed(struct cfg80211_registered_device *rdev, ...@@ -7542,7 +7542,7 @@ void nl80211_send_roamed(struct cfg80211_registered_device *rdev,
struct sk_buff *msg; struct sk_buff *msg;
void *hdr; void *hdr;
msg = nlmsg_new(NLMSG_GOODSIZE, gfp); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
if (!msg) if (!msg)
return; return;
...@@ -7580,7 +7580,7 @@ void nl80211_send_disconnected(struct cfg80211_registered_device *rdev, ...@@ -7580,7 +7580,7 @@ void nl80211_send_disconnected(struct cfg80211_registered_device *rdev,
struct sk_buff *msg; struct sk_buff *msg;
void *hdr; void *hdr;
msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) if (!msg)
return; return;
...@@ -7842,7 +7842,7 @@ void nl80211_send_sta_event(struct cfg80211_registered_device *rdev, ...@@ -7842,7 +7842,7 @@ void nl80211_send_sta_event(struct cfg80211_registered_device *rdev,
{ {
struct sk_buff *msg; struct sk_buff *msg;
msg = nlmsg_new(NLMSG_GOODSIZE, gfp); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
if (!msg) if (!msg)
return; return;
...@@ -7863,7 +7863,7 @@ void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev, ...@@ -7863,7 +7863,7 @@ void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev,
struct sk_buff *msg; struct sk_buff *msg;
void *hdr; void *hdr;
msg = nlmsg_new(NLMSG_GOODSIZE, gfp); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
if (!msg) if (!msg)
return; return;
...@@ -8026,7 +8026,7 @@ nl80211_send_cqm_rssi_notify(struct cfg80211_registered_device *rdev, ...@@ -8026,7 +8026,7 @@ nl80211_send_cqm_rssi_notify(struct cfg80211_registered_device *rdev,
struct nlattr *pinfoattr; struct nlattr *pinfoattr;
void *hdr; void *hdr;
msg = nlmsg_new(NLMSG_GOODSIZE, gfp); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
if (!msg) if (!msg)
return; return;
...@@ -8069,7 +8069,7 @@ void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev, ...@@ -8069,7 +8069,7 @@ void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev,
struct nlattr *rekey_attr; struct nlattr *rekey_attr;
void *hdr; void *hdr;
msg = nlmsg_new(NLMSG_GOODSIZE, gfp); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
if (!msg) if (!msg)
return; return;
...@@ -8113,7 +8113,7 @@ void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev, ...@@ -8113,7 +8113,7 @@ void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev,
struct nlattr *attr; struct nlattr *attr;
void *hdr; void *hdr;
msg = nlmsg_new(NLMSG_GOODSIZE, gfp); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
if (!msg) if (!msg)
return; return;
...@@ -8157,7 +8157,7 @@ void nl80211_ch_switch_notify(struct cfg80211_registered_device *rdev, ...@@ -8157,7 +8157,7 @@ void nl80211_ch_switch_notify(struct cfg80211_registered_device *rdev,
struct sk_buff *msg; struct sk_buff *msg;
void *hdr; void *hdr;
msg = nlmsg_new(NLMSG_GOODSIZE, gfp); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
if (!msg) if (!msg)
return; return;
...@@ -8192,7 +8192,7 @@ nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev, ...@@ -8192,7 +8192,7 @@ nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev,
struct nlattr *pinfoattr; struct nlattr *pinfoattr;
void *hdr; void *hdr;
msg = nlmsg_new(NLMSG_GOODSIZE, gfp); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
if (!msg) if (!msg)
return; return;
...@@ -8236,7 +8236,7 @@ void cfg80211_probe_status(struct net_device *dev, const u8 *addr, ...@@ -8236,7 +8236,7 @@ void cfg80211_probe_status(struct net_device *dev, const u8 *addr,
void *hdr; void *hdr;
int err; int err;
msg = nlmsg_new(NLMSG_GOODSIZE, gfp); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
if (!msg) if (!msg)
return; return;
......
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