From: Thomas Graf <tgraf@suug.ch>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Thomas Graf <tgraf@suug.ch>
Subject: [PATCH 1/3] [DECnet] address: Calculate accurate message size for netlink notifications
Date: Sun, 19 Nov 2006 23:23:27 +0100 [thread overview]
Message-ID: <20061119222420.115227575@lsx.localdomain> (raw)
In-Reply-To: 20061119222326.208529546@lsx.localdomain
[-- Attachment #1: nl_dn_msgsize --]
[-- Type: text/plain, Size: 1716 bytes --]
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Index: net-2.6.20/net/decnet/dn_dev.c
===================================================================
--- net-2.6.20.orig/net/decnet/dn_dev.c 2006-11-19 18:31:06.000000000 +0100
+++ net-2.6.20/net/decnet/dn_dev.c 2006-11-19 18:33:43.000000000 +0100
@@ -38,7 +38,6 @@
#include <linux/if_arp.h>
#include <linux/if_ether.h>
#include <linux/skbuff.h>
-#include <linux/rtnetlink.h>
#include <linux/sysctl.h>
#include <linux/notifier.h>
#include <asm/uaccess.h>
@@ -47,6 +46,7 @@
#include <net/dst.h>
#include <net/flow.h>
#include <net/fib_rules.h>
+#include <net/netlink.h>
#include <net/dn.h>
#include <net/dn_dev.h>
#include <net/dn_route.h>
@@ -713,6 +713,14 @@
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,
u32 pid, u32 seq, int event, unsigned int flags)
{
@@ -746,18 +754,15 @@
static void rtmsg_ifa(int event, struct dn_ifaddr *ifa)
{
struct sk_buff *skb;
- int payload = sizeof(struct ifaddrmsg) + 128;
int err = -ENOBUFS;
- skb = alloc_skb(nlmsg_total_size(payload), GFP_KERNEL);
+ skb = alloc_skb(dn_ifaddr_nlmsg_size(), GFP_KERNEL);
if (skb == NULL)
goto errout;
err = dn_dev_fill_ifaddr(skb, ifa, 0, 0, event, 0);
- if (err < 0) {
- kfree_skb(skb);
- goto errout;
- }
+ /* failure implies BUG in dn_ifaddr_nlmsg_size() */
+ BUG_ON(err < 0);
err = rtnl_notify(skb, 0, RTNLGRP_DECnet_IFADDR, NULL, GFP_KERNEL);
errout:
--
next prev parent reply other threads:[~2006-11-19 22:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-19 22:23 [PATCHSET] DECNet address netlink work Thomas Graf
2006-11-19 22:23 ` Thomas Graf [this message]
2006-11-19 22:23 ` [PATCH 2/3] [DECnet] address: Rename rtmsg_ifa() to dn_ifaddr_notify() Thomas Graf
2006-11-19 22:23 ` [PATCH 3/3] [DECNET] address: Convert to new netlink interface Thomas Graf
2006-11-25 1:15 ` [PATCHSET] DECNet address netlink work David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061119222420.115227575@lsx.localdomain \
--to=tgraf@suug.ch \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox