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

[DECNET] address: Calculate accurate message size for netlink notifications

Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 107a5fe6
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include <linux/if_arp.h> #include <linux/if_arp.h>
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/rtnetlink.h>
#include <linux/sysctl.h> #include <linux/sysctl.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -47,6 +46,7 @@ ...@@ -47,6 +46,7 @@
#include <net/dst.h> #include <net/dst.h>
#include <net/flow.h> #include <net/flow.h>
#include <net/fib_rules.h> #include <net/fib_rules.h>
#include <net/netlink.h>
#include <net/dn.h> #include <net/dn.h>
#include <net/dn_dev.h> #include <net/dn_dev.h>
#include <net/dn_route.h> #include <net/dn_route.h>
...@@ -711,6 +711,14 @@ static int dn_dev_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *a ...@@ -711,6 +711,14 @@ static int dn_dev_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *a
return rv; return rv;
} }
static inline size_t dn_ifaddr_nlmsg_size(void)
{
return NLMSG_ALIGN(sizeof(struct ifaddrmsg))
+ nla_total_size(IFNAMSIZ) /* IFA_LABEL */
+ nla_total_size(2) /* IFA_ADDRESS */
+ nla_total_size(2); /* IFA_LOCAL */
}
static int dn_dev_fill_ifaddr(struct sk_buff *skb, struct dn_ifaddr *ifa, static int dn_dev_fill_ifaddr(struct sk_buff *skb, struct dn_ifaddr *ifa,
u32 pid, u32 seq, int event, unsigned int flags) u32 pid, u32 seq, int event, unsigned int flags)
{ {
...@@ -744,18 +752,15 @@ static int dn_dev_fill_ifaddr(struct sk_buff *skb, struct dn_ifaddr *ifa, ...@@ -744,18 +752,15 @@ static int dn_dev_fill_ifaddr(struct sk_buff *skb, struct dn_ifaddr *ifa,
static void rtmsg_ifa(int event, struct dn_ifaddr *ifa) static void rtmsg_ifa(int event, struct dn_ifaddr *ifa)
{ {
struct sk_buff *skb; struct sk_buff *skb;
int payload = sizeof(struct ifaddrmsg) + 128;
int err = -ENOBUFS; int err = -ENOBUFS;
skb = alloc_skb(nlmsg_total_size(payload), GFP_KERNEL); skb = alloc_skb(dn_ifaddr_nlmsg_size(), GFP_KERNEL);
if (skb == NULL) if (skb == NULL)
goto errout; goto errout;
err = dn_dev_fill_ifaddr(skb, ifa, 0, 0, event, 0); err = dn_dev_fill_ifaddr(skb, ifa, 0, 0, event, 0);
if (err < 0) { /* failure implies BUG in dn_ifaddr_nlmsg_size() */
kfree_skb(skb); BUG_ON(err < 0);
goto errout;
}
err = rtnl_notify(skb, 0, RTNLGRP_DECnet_IFADDR, NULL, GFP_KERNEL); err = rtnl_notify(skb, 0, RTNLGRP_DECnet_IFADDR, NULL, GFP_KERNEL);
errout: errout:
......
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