Commit 744b096e authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

[WIRELESS]: Use type safe netlink interface

Makes use of the type safe netlink interface and adds a warning
if the message is too big for NLMSG_DEFAULT_SIZE to help debug.
Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 1bec3f1a
...@@ -1129,10 +1129,12 @@ static int rtnetlink_fill_iwinfo(struct sk_buff *skb, struct net_device *dev, ...@@ -1129,10 +1129,12 @@ static int rtnetlink_fill_iwinfo(struct sk_buff *skb, struct net_device *dev,
{ {
struct ifinfomsg *r; struct ifinfomsg *r;
struct nlmsghdr *nlh; struct nlmsghdr *nlh;
unsigned char *b = skb_tail_pointer(skb);
nlh = NLMSG_PUT(skb, 0, 0, type, sizeof(*r)); nlh = nlmsg_put(skb, 0, 0, type, sizeof(*r), 0);
r = NLMSG_DATA(nlh); if (nlh == NULL)
return -EMSGSIZE;
r = nlmsg_data(nlh);
r->ifi_family = AF_UNSPEC; r->ifi_family = AF_UNSPEC;
r->__ifi_pad = 0; r->__ifi_pad = 0;
r->ifi_type = dev->type; r->ifi_type = dev->type;
...@@ -1141,15 +1143,13 @@ static int rtnetlink_fill_iwinfo(struct sk_buff *skb, struct net_device *dev, ...@@ -1141,15 +1143,13 @@ static int rtnetlink_fill_iwinfo(struct sk_buff *skb, struct net_device *dev,
r->ifi_change = 0; /* Wireless changes don't affect those flags */ r->ifi_change = 0; /* Wireless changes don't affect those flags */
/* Add the wireless events in the netlink packet */ /* Add the wireless events in the netlink packet */
RTA_PUT(skb, IFLA_WIRELESS, event_len, event); NLA_PUT(skb, IFLA_WIRELESS, event_len, event);
nlh->nlmsg_len = skb_tail_pointer(skb) - b; return nlmsg_end(skb, nlh);
return skb->len;
nlmsg_failure: nla_put_failure:
rtattr_failure: nlmsg_cancel(skb, nlh);
nlmsg_trim(skb, b); return -EMSGSIZE;
return -1;
} }
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
...@@ -1162,17 +1162,19 @@ rtattr_failure: ...@@ -1162,17 +1162,19 @@ rtattr_failure:
static void rtmsg_iwinfo(struct net_device *dev, char *event, int event_len) static void rtmsg_iwinfo(struct net_device *dev, char *event, int event_len)
{ {
struct sk_buff *skb; struct sk_buff *skb;
int size = NLMSG_GOODSIZE; int err;
skb = alloc_skb(size, GFP_ATOMIC); skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
if (!skb) if (!skb)
return; return;
if (rtnetlink_fill_iwinfo(skb, dev, RTM_NEWLINK, err = rtnetlink_fill_iwinfo(skb, dev, RTM_NEWLINK, event, event_len);
event, event_len) < 0) { if (err < 0) {
WARN_ON(err == -EMSGSIZE);
kfree_skb(skb); kfree_skb(skb);
return; return;
} }
NETLINK_CB(skb).dst_group = RTNLGRP_LINK; NETLINK_CB(skb).dst_group = RTNLGRP_LINK;
skb_queue_tail(&wireless_nlevent_queue, skb); skb_queue_tail(&wireless_nlevent_queue, skb);
tasklet_schedule(&wireless_nlevent_tasklet); tasklet_schedule(&wireless_nlevent_tasklet);
......
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