aboutsummaryrefslogtreecommitdiffstats
path: root/net/decnet/dn_dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/decnet/dn_dev.c')
-rw-r--r--net/decnet/dn_dev.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
index a26ff9f44576..01861feb608d 100644
--- a/net/decnet/dn_dev.c
+++ b/net/decnet/dn_dev.c
@@ -24,7 +24,6 @@
24 * devices. All mtu based now. 24 * devices. All mtu based now.
25 */ 25 */
26 26
27#include <linux/config.h>
28#include <linux/capability.h> 27#include <linux/capability.h>
29#include <linux/module.h> 28#include <linux/module.h>
30#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
@@ -35,6 +34,7 @@
35#include <linux/seq_file.h> 34#include <linux/seq_file.h>
36#include <linux/timer.h> 35#include <linux/timer.h>
37#include <linux/string.h> 36#include <linux/string.h>
37#include <linux/if_addr.h>
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>
@@ -46,6 +46,7 @@
46#include <net/neighbour.h> 46#include <net/neighbour.h>
47#include <net/dst.h> 47#include <net/dst.h>
48#include <net/flow.h> 48#include <net/flow.h>
49#include <net/fib_rules.h>
49#include <net/dn.h> 50#include <net/dn.h>
50#include <net/dn_dev.h> 51#include <net/dn_dev.h>
51#include <net/dn_route.h> 52#include <net/dn_route.h>
@@ -414,11 +415,7 @@ static struct dn_ifaddr *dn_dev_alloc_ifa(void)
414{ 415{
415 struct dn_ifaddr *ifa; 416 struct dn_ifaddr *ifa;
416 417
417 ifa = kmalloc(sizeof(*ifa), GFP_KERNEL); 418 ifa = kzalloc(sizeof(*ifa), GFP_KERNEL);
418
419 if (ifa) {
420 memset(ifa, 0, sizeof(*ifa));
421 }
422 419
423 return ifa; 420 return ifa;
424} 421}
@@ -749,20 +746,23 @@ rtattr_failure:
749static void rtmsg_ifa(int event, struct dn_ifaddr *ifa) 746static void rtmsg_ifa(int event, struct dn_ifaddr *ifa)
750{ 747{
751 struct sk_buff *skb; 748 struct sk_buff *skb;
752 int size = NLMSG_SPACE(sizeof(struct ifaddrmsg)+128); 749 int payload = sizeof(struct ifaddrmsg) + 128;
750 int err = -ENOBUFS;
753 751
754 skb = alloc_skb(size, GFP_KERNEL); 752 skb = alloc_skb(nlmsg_total_size(payload), GFP_KERNEL);
755 if (!skb) { 753 if (skb == NULL)
756 netlink_set_err(rtnl, 0, RTNLGRP_DECnet_IFADDR, ENOBUFS); 754 goto errout;
757 return; 755
758 } 756 err = dn_dev_fill_ifaddr(skb, ifa, 0, 0, event, 0);
759 if (dn_dev_fill_ifaddr(skb, ifa, 0, 0, event, 0) < 0) { 757 if (err < 0) {
760 kfree_skb(skb); 758 kfree_skb(skb);
761 netlink_set_err(rtnl, 0, RTNLGRP_DECnet_IFADDR, EINVAL); 759 goto errout;
762 return;
763 } 760 }
764 NETLINK_CB(skb).dst_group = RTNLGRP_DECnet_IFADDR; 761
765 netlink_broadcast(rtnl, skb, 0, RTNLGRP_DECnet_IFADDR, GFP_KERNEL); 762 err = rtnl_notify(skb, 0, RTNLGRP_DECnet_IFADDR, NULL, GFP_KERNEL);
763errout:
764 if (err < 0)
765 rtnl_set_sk_err(RTNLGRP_DECnet_IFADDR, err);
766} 766}
767 767
768static int dn_dev_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) 768static int dn_dev_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
@@ -1106,10 +1106,9 @@ struct dn_dev *dn_dev_create(struct net_device *dev, int *err)
1106 return NULL; 1106 return NULL;
1107 1107
1108 *err = -ENOBUFS; 1108 *err = -ENOBUFS;
1109 if ((dn_db = kmalloc(sizeof(struct dn_dev), GFP_ATOMIC)) == NULL) 1109 if ((dn_db = kzalloc(sizeof(struct dn_dev), GFP_ATOMIC)) == NULL)
1110 return NULL; 1110 return NULL;
1111 1111
1112 memset(dn_db, 0, sizeof(struct dn_dev));
1113 memcpy(&dn_db->parms, p, sizeof(struct dn_dev_parms)); 1112 memcpy(&dn_db->parms, p, sizeof(struct dn_dev_parms));
1114 smp_wmb(); 1113 smp_wmb();
1115 dev->dn_ptr = dn_db; 1114 dev->dn_ptr = dn_db;
@@ -1423,8 +1422,6 @@ static struct rtnetlink_link dnet_rtnetlink_table[RTM_NR_MSGTYPES] =
1423 [RTM_DELROUTE - RTM_BASE] = { .doit = dn_fib_rtm_delroute, }, 1422 [RTM_DELROUTE - RTM_BASE] = { .doit = dn_fib_rtm_delroute, },
1424 [RTM_GETROUTE - RTM_BASE] = { .doit = dn_cache_getroute, 1423 [RTM_GETROUTE - RTM_BASE] = { .doit = dn_cache_getroute,
1425 .dumpit = dn_fib_dump, }, 1424 .dumpit = dn_fib_dump, },
1426 [RTM_NEWRULE - RTM_BASE] = { .doit = dn_fib_rtm_newrule, },
1427 [RTM_DELRULE - RTM_BASE] = { .doit = dn_fib_rtm_delrule, },
1428 [RTM_GETRULE - RTM_BASE] = { .dumpit = dn_fib_dump_rules, }, 1425 [RTM_GETRULE - RTM_BASE] = { .dumpit = dn_fib_dump_rules, },
1429#else 1426#else
1430 [RTM_GETROUTE - RTM_BASE] = { .doit = dn_cache_getroute, 1427 [RTM_GETROUTE - RTM_BASE] = { .doit = dn_cache_getroute,