aboutsummaryrefslogtreecommitdiffstats
path: root/net/decnet
diff options
context:
space:
mode:
Diffstat (limited to 'net/decnet')
-rw-r--r--net/decnet/dn_dev.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
index 5b451e196fb9..2459a8d236a0 100644
--- a/net/decnet/dn_dev.c
+++ b/net/decnet/dn_dev.c
@@ -38,7 +38,6 @@
38#include <linux/if_arp.h> 38#include <linux/if_arp.h>
39#include <linux/if_ether.h> 39#include <linux/if_ether.h>
40#include <linux/skbuff.h> 40#include <linux/skbuff.h>
41#include <linux/rtnetlink.h>
42#include <linux/sysctl.h> 41#include <linux/sysctl.h>
43#include <linux/notifier.h> 42#include <linux/notifier.h>
44#include <asm/uaccess.h> 43#include <asm/uaccess.h>
@@ -47,6 +46,7 @@
47#include <net/dst.h> 46#include <net/dst.h>
48#include <net/flow.h> 47#include <net/flow.h>
49#include <net/fib_rules.h> 48#include <net/fib_rules.h>
49#include <net/netlink.h>
50#include <net/dn.h> 50#include <net/dn.h>
51#include <net/dn_dev.h> 51#include <net/dn_dev.h>
52#include <net/dn_route.h> 52#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 return rv; 711 return rv;
712} 712}
713 713
714static inline size_t dn_ifaddr_nlmsg_size(void)
715{
716 return NLMSG_ALIGN(sizeof(struct ifaddrmsg))
717 + nla_total_size(IFNAMSIZ) /* IFA_LABEL */
718 + nla_total_size(2) /* IFA_ADDRESS */
719 + nla_total_size(2); /* IFA_LOCAL */
720}
721
714static int dn_dev_fill_ifaddr(struct sk_buff *skb, struct dn_ifaddr *ifa, 722static int dn_dev_fill_ifaddr(struct sk_buff *skb, struct dn_ifaddr *ifa,
715 u32 pid, u32 seq, int event, unsigned int flags) 723 u32 pid, u32 seq, int event, unsigned int flags)
716{ 724{
@@ -744,18 +752,15 @@ rtattr_failure:
744static void rtmsg_ifa(int event, struct dn_ifaddr *ifa) 752static void rtmsg_ifa(int event, struct dn_ifaddr *ifa)
745{ 753{
746 struct sk_buff *skb; 754 struct sk_buff *skb;
747 int payload = sizeof(struct ifaddrmsg) + 128;
748 int err = -ENOBUFS; 755 int err = -ENOBUFS;
749 756
750 skb = alloc_skb(nlmsg_total_size(payload), GFP_KERNEL); 757 skb = alloc_skb(dn_ifaddr_nlmsg_size(), GFP_KERNEL);
751 if (skb == NULL) 758 if (skb == NULL)
752 goto errout; 759 goto errout;
753 760
754 err = dn_dev_fill_ifaddr(skb, ifa, 0, 0, event, 0); 761 err = dn_dev_fill_ifaddr(skb, ifa, 0, 0, event, 0);
755 if (err < 0) { 762 /* failure implies BUG in dn_ifaddr_nlmsg_size() */
756 kfree_skb(skb); 763 BUG_ON(err < 0);
757 goto errout;
758 }
759 764
760 err = rtnl_notify(skb, 0, RTNLGRP_DECnet_IFADDR, NULL, GFP_KERNEL); 765 err = rtnl_notify(skb, 0, RTNLGRP_DECnet_IFADDR, NULL, GFP_KERNEL);
761errout: 766errout: