public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2 v4] lib: Replace 16384 netlink buf size by macro
@ 2015-02-27  6:31 Vadim Kochan
  2015-02-27 17:38 ` David Miller
  2015-02-28  3:01 ` Stephen Hemminger
  0 siblings, 2 replies; 4+ messages in thread
From: Vadim Kochan @ 2015-02-27  6:31 UTC (permalink / raw)
  To: stephen; +Cc: netdev, Vadim Kochan

From: Vadim Kochan <vadim4j@gmail.com>

Replaced hard coded 16384 netlink buffer size by NLBUF_SIZE,
which can be overridden by -DNLBUF_SIZE.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
---
v4:
    Added "iproute2" in the subject

v3:
    Fixed "overrided" -> overridden" in the
    commit message   : suggested by Sergei Shtylyov

v2:
    Get rid of NL_BUF: suggested by Jiri Pirko

 include/libnetlink.h | 4 ++++
 ip/iplink.c          | 2 +-
 lib/libnetlink.c     | 8 ++++----
 misc/ss.c            | 2 +-
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/include/libnetlink.h b/include/libnetlink.h
index 898275b..1ef7f1f 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -170,5 +170,9 @@ extern int rtnl_from_file(FILE *, rtnl_filter_t handler,
  * messages from dump file */
 #define NLMSG_TSTAMP	15
 
+#ifndef NLBUF_SIZE
+#define NLBUF_SIZE 16384
+#endif
+
 #endif /* __LIBNETLINK_H__ */
 
diff --git a/ip/iplink.c b/ip/iplink.c
index 5893ee4..db60afa 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -770,7 +770,7 @@ int iplink_get(unsigned int flags, char *name, __u32 filt_mask)
 {
 	int len;
 	struct iplink_req req;
-	char answer[16384];
+	char answer[NLBUF_SIZE];
 
 	memset(&req, 0, sizeof(req));
 
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index 77e07ef..666e277 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -194,7 +194,7 @@ int rtnl_dump_filter_l(struct rtnl_handle *rth,
 		.msg_iov = &iov,
 		.msg_iovlen = 1,
 	};
-	char buf[16384];
+	char buf[NLBUF_SIZE];
 	int dump_intr = 0;
 
 	iov.iov_base = buf;
@@ -317,7 +317,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
 		.msg_iov = &iov,
 		.msg_iovlen = 1,
 	};
-	char   buf[16384];
+	char buf[NLBUF_SIZE];
 
 	memset(&nladdr, 0, sizeof(nladdr));
 	nladdr.nl_family = AF_NETLINK;
@@ -432,7 +432,7 @@ int rtnl_listen(struct rtnl_handle *rtnl,
 		.msg_iov = &iov,
 		.msg_iovlen = 1,
 	};
-	char   buf[16384];
+	char buf[NLBUF_SIZE];
 
 	memset(&nladdr, 0, sizeof(nladdr));
 	nladdr.nl_family = AF_NETLINK;
@@ -498,7 +498,7 @@ int rtnl_from_file(FILE *rtnl, rtnl_filter_t handler,
 {
 	int status;
 	struct sockaddr_nl nladdr;
-	char   buf[16384];
+	char buf[NLBUF_SIZE];
 	struct nlmsghdr *h = (void*)buf;
 
 	memset(&nladdr, 0, sizeof(nladdr));
diff --git a/misc/ss.c b/misc/ss.c
index 21a4366..036ede8 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -2222,7 +2222,7 @@ Exit:
 static int tcp_show_netlink_file(struct filter *f)
 {
 	FILE	*fp;
-	char	buf[16384];
+	char buf[NLBUF_SIZE];
 
 	if ((fp = fopen(getenv("TCPDIAG_FILE"), "r")) == NULL) {
 		perror("fopen($TCPDIAG_FILE)");
-- 
2.2.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH iproute2 v4] lib: Replace 16384 netlink buf size by macro
  2015-02-27  6:31 [PATCH iproute2 v4] lib: Replace 16384 netlink buf size by macro Vadim Kochan
@ 2015-02-27 17:38 ` David Miller
  2015-02-27 17:47   ` Vadim Kochan
  2015-02-28  3:01 ` Stephen Hemminger
  1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2015-02-27 17:38 UTC (permalink / raw)
  To: vadim4j; +Cc: stephen, netdev

From: Vadim Kochan <vadim4j@gmail.com>
Date: Fri, 27 Feb 2015 08:31:40 +0200

> From: Vadim Kochan <vadim4j@gmail.com>
> 
> Replaced hard coded 16384 netlink buffer size by NLBUF_SIZE,
> which can be overridden by -DNLBUF_SIZE.
> 
> Signed-off-by: Vadim Kochan <vadim4j@gmail.com>

I would like to know what problem is solved by changing this to
any other value?

And then I would like to know why other potential solutions to
this problem were not considered, such as making the buffer size
dynamic and run-time selectable, perhaps with a size choosen
in a manner to avoid whatever problem you hit with the current
size.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH iproute2 v4] lib: Replace 16384 netlink buf size by macro
  2015-02-27 17:38 ` David Miller
@ 2015-02-27 17:47   ` Vadim Kochan
  0 siblings, 0 replies; 4+ messages in thread
From: Vadim Kochan @ 2015-02-27 17:47 UTC (permalink / raw)
  To: David Miller; +Cc: vadim4j, stephen, netdev

On Fri, Feb 27, 2015 at 12:38:31PM -0500, David Miller wrote:
> From: Vadim Kochan <vadim4j@gmail.com>
> Date: Fri, 27 Feb 2015 08:31:40 +0200
> 
> > From: Vadim Kochan <vadim4j@gmail.com>
> > 
> > Replaced hard coded 16384 netlink buffer size by NLBUF_SIZE,
> > which can be overridden by -DNLBUF_SIZE.
> > 
> > Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
> 
> I would like to know what problem is solved by changing this to
> any other value?
> 
> And then I would like to know why other potential solutions to
> this problem were not considered, such as making the buffer size
> dynamic and run-time selectable, perhaps with a size choosen
> in a manner to avoid whatever problem you hit with the current
> size.

Its just for the case when it might be changed in the future then it can be
easy found and changed. Just reject it if it looks useless. About
dynamic changing I think it makes sense to do it because memset is used
on the each netlink 16384 sized msg.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH iproute2 v4] lib: Replace 16384 netlink buf size by macro
  2015-02-27  6:31 [PATCH iproute2 v4] lib: Replace 16384 netlink buf size by macro Vadim Kochan
  2015-02-27 17:38 ` David Miller
@ 2015-02-28  3:01 ` Stephen Hemminger
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2015-02-28  3:01 UTC (permalink / raw)
  To: Vadim Kochan; +Cc: netdev

On Fri, 27 Feb 2015 08:31:40 +0200
Vadim Kochan <vadim4j@gmail.com> wrote:

> From: Vadim Kochan <vadim4j@gmail.com>
> 
> Replaced hard coded 16384 netlink buffer size by NLBUF_SIZE,
> which can be overridden by -DNLBUF_SIZE.
> 
> Signed-off-by: Vadim Kochan <vadim4j@gmail.com>

I agree with Dave, add -b option

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-02-28  3:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-27  6:31 [PATCH iproute2 v4] lib: Replace 16384 netlink buf size by macro Vadim Kochan
2015-02-27 17:38 ` David Miller
2015-02-27 17:47   ` Vadim Kochan
2015-02-28  3:01 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox