* [PATCH 2.6 NET] Adjust RTATTR_MAX to IFLA_* changes
@ 2004-09-09 16:31 Thomas Graf
2004-09-09 17:31 ` David S. Miller
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Graf @ 2004-09-09 16:31 UTC (permalink / raw)
To: David S. Miller; +Cc: Jamal Hadi Salim, Eric Lemoine, netdev
IFLA_MAX is now bigger than RTA_MAX with the latest changes in IFLA_*.
Adjust RTATTR to point to IFLA_MAX to have big enough buffer in
rtnetlink_rcv_msg.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
--- linux-2.6.9-rc1-bk15.orig/include/linux/rtnetlink.h 2004-09-08 18:32:05.000000000 +0200
+++ linux-2.6.9-rc1-bk15/include/linux/rtnetlink.h 2004-09-09 17:32:14.000000000 +0200
@@ -662,7 +662,7 @@
/* SUMMARY: maximal rtattr understood by kernel */
-#define RTATTR_MAX RTA_MAX
+#define RTATTR_MAX IFLA_MAX
/* RTnetlink multicast groups */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2.6 NET] Adjust RTATTR_MAX to IFLA_* changes
2004-09-09 16:31 [PATCH 2.6 NET] Adjust RTATTR_MAX to IFLA_* changes Thomas Graf
@ 2004-09-09 17:31 ` David S. Miller
2004-09-09 17:49 ` Thomas Graf
0 siblings, 1 reply; 4+ messages in thread
From: David S. Miller @ 2004-09-09 17:31 UTC (permalink / raw)
To: Thomas Graf; +Cc: hadi, eric.lemoine, netdev
On Thu, 9 Sep 2004 18:31:31 +0200
Thomas Graf <tgraf@suug.ch> wrote:
> IFLA_MAX is now bigger than RTA_MAX with the latest changes in IFLA_*.
> Adjust RTATTR to point to IFLA_MAX to have big enough buffer in
> rtnetlink_rcv_msg.
Ok, this is going to get silly if some other attribute gets
larger than IFLA_* next.
We should just compute this thing at run time.
Else, if the macro can't be deleted because there
are non-trivial other uses, use some expression
involving max().
I just checked iproute2 sources and it does not reference
this thing, so probably best to kill it off, like so.
===== include/linux/rtnetlink.h 1.42 vs edited =====
--- 1.42/include/linux/rtnetlink.h 2004-09-02 13:12:43 -07:00
+++ edited/include/linux/rtnetlink.h 2004-09-09 10:10:08 -07:00
@@ -660,10 +660,6 @@
#define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg))
-/* SUMMARY: maximal rtattr understood by kernel */
-
-#define RTATTR_MAX RTA_MAX
-
/* RTnetlink multicast groups */
#define RTMGRP_LINK 1
===== net/core/rtnetlink.c 1.24 vs edited =====
--- 1.24/net/core/rtnetlink.c 2004-09-02 13:12:43 -07:00
+++ edited/net/core/rtnetlink.c 2004-09-09 10:08:44 -07:00
@@ -401,6 +401,10 @@
return 0;
}
+/* Protected by RTNL sempahore. */
+static struct rtattr **rta_buf;
+static int rtattr_max;
+
/* Process one rtnetlink message. */
static __inline__ int
@@ -408,8 +412,6 @@
{
struct rtnetlink_link *link;
struct rtnetlink_link *link_tab;
- struct rtattr *rta[RTATTR_MAX];
-
int sz_idx, kind;
int min_len;
int family;
@@ -476,7 +478,7 @@
return -1;
}
- memset(&rta, 0, sizeof(rta));
+ memset(rta_buf, 0, (rtattr_max * sizeof(struct rtattr *)));
min_len = rtm_min[sz_idx];
if (nlh->nlmsg_len < min_len)
@@ -491,7 +493,7 @@
if (flavor) {
if (flavor > rta_max[sz_idx])
goto err_inval;
- rta[flavor-1] = attr;
+ rta_buf[flavor-1] = attr;
}
attr = RTA_NEXT(attr, attrlen);
}
@@ -501,7 +503,7 @@
link = &(rtnetlink_links[PF_UNSPEC][type]);
if (link->doit == NULL)
goto err_inval;
- err = link->doit(skb, nlh, (void *)&rta);
+ err = link->doit(skb, nlh, (void *)&rta_buf[0]);
*errp = err;
return err;
@@ -621,6 +623,16 @@
void __init rtnetlink_init(void)
{
+ int i;
+
+ rtattr_max = 0;
+ for (i = 0; i < ARRAY_SIZE(rta_max); i++)
+ if (rta_max[i] > rtattr_max)
+ rtattr_max = rta_max[i];
+ rta_buf = kmalloc(rtattr_max * sizeof(struct rtattr *), GFP_KERNEL);
+ if (!rta_buf)
+ panic("rtnetlink_init: cannot allocate rta_buf\n");
+
rtnl = netlink_kernel_create(NETLINK_ROUTE, rtnetlink_rcv);
if (rtnl == NULL)
panic("rtnetlink_init: cannot initialize rtnetlink\n");
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2.6 NET] Adjust RTATTR_MAX to IFLA_* changes
2004-09-09 17:31 ` David S. Miller
@ 2004-09-09 17:49 ` Thomas Graf
2004-09-09 17:53 ` David S. Miller
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Graf @ 2004-09-09 17:49 UTC (permalink / raw)
To: David S. Miller; +Cc: hadi, eric.lemoine, netdev
* David S. Miller <20040909103149.248a603e.davem@davemloft.net> 2004-09-09 10:31
> On Thu, 9 Sep 2004 18:31:31 +0200
> Thomas Graf <tgraf@suug.ch> wrote:
>
> > IFLA_MAX is now bigger than RTA_MAX with the latest changes in IFLA_*.
> > Adjust RTATTR to point to IFLA_MAX to have big enough buffer in
> > rtnetlink_rcv_msg.
>
> Ok, this is going to get silly if some other attribute gets
> larger than IFLA_* next.
>
> We should just compute this thing at run time.
> Else, if the macro can't be deleted because there
> are non-trivial other uses, use some expression
> involving max().
>
> I just checked iproute2 sources and it does not reference
> this thing, so probably best to kill it off, like so.
This is even better, works fine for me.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2.6 NET] Adjust RTATTR_MAX to IFLA_* changes
2004-09-09 17:49 ` Thomas Graf
@ 2004-09-09 17:53 ` David S. Miller
0 siblings, 0 replies; 4+ messages in thread
From: David S. Miller @ 2004-09-09 17:53 UTC (permalink / raw)
To: Thomas Graf; +Cc: hadi, eric.lemoine, netdev
On Thu, 9 Sep 2004 19:49:43 +0200
Thomas Graf <tgraf@suug.ch> wrote:
> * David S. Miller <20040909103149.248a603e.davem@davemloft.net> 2004-09-09 10:31
> > I just checked iproute2 sources and it does not reference
> > this thing, so probably best to kill it off, like so.
>
> This is even better, works fine for me.
Great, this is what I'll push upstream.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-09-09 17:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-09 16:31 [PATCH 2.6 NET] Adjust RTATTR_MAX to IFLA_* changes Thomas Graf
2004-09-09 17:31 ` David S. Miller
2004-09-09 17:49 ` Thomas Graf
2004-09-09 17:53 ` David S. Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).