Allow setting dev->weight using ip(8)
Subsystems (2)
PATCH 1/1 Allow setting dev->weight using ip(8)
Hello
For my own testing purposes, I often need to modify dev->weight. So I patched the kernel and iproute2 to be able to modify dev->weight using ip(8). After all, one can modify tx_queue_len so why not weight?
Two kernel patches attached: one using the ioctl framework and another using the rtnetlink framework. Warning: the attached rtnetlink patch is a superset of Thomas Graf's rtnetlink patch for setting mtu and tx_queue_len.
PS: both patches are against 2.6.5-rc3-ben0 but should apply to any 2.6.
--
Eric
Quoted 6 lines · Eric Lemoine
Hello
For my own testing purposes, I often need to modify
dev->weight. So I patched the kernel and iproute2 to be able to modifydev->weightusing ip(8). After all, one can modifytx_queue_lenso why not weight?
Quoted 7 lines
Two kernel patches attached: one using the ioctl framework and another using the rtnetlink framework. Warning: the attached rtnetlink patch is a superset of Thomas Graf's rtnetlink patch for setting mtu and
tx_queue_len.PS: both patches are against 2.6.5-rc3-ben0 but should apply to any 2.6.
Looks sane.
Not sure if you should encourage ioctl though ;->
Out of curiosity, what/when do you change weight? I think its valuable to do so, just curious. BTW, As Dave pointed out alwauIFLA_WEIGHT
missing user space/ip patch btw.
cheers,
jamal
Quoted 1 line · jamal
to do so, just curious. BTW, As Dave pointed out
alwauIFLA_WEIGHT
LOL ;->
As Dave pointed out any new attributes go to the end of the enumeration. It may not matter in this case if Dave hasnt applied Thomas' patch. Otherwise IFLA_WEIGHT should be last.
cheers,
jamal
Quoted 3 lines
As Dave pointed out any new attributes go to the end of the enumeration. It may not matter in this case if Dave hasnt applied Thomas' patch. Otherwise
IFLA_WEIGHTshould be last.
Right.
New patch attached.
Signature · 1 line
Eric
David S. Miller
maintainerQuoted 7 lines · On Mon, 30 Aug 2004 16:35:57 +0200 Eric Lemoine <[email protected]> wrote:
Quoted 3 lines
As Dave pointed out any new attributes go to the end of the enumeration. It may not matter in this case if Dave hasnt applied Thomas' patch. Otherwise
IFLA_WEIGHTshould be last.Right.
New patch attached.
Please make a patch against Linus's current tree. I put the rest of your rtnetlink device interface changes in, and your patches here duplicate all of that.
I agree also with Jamel wrt. ioctl(), let's not go there if possible. :-)
Quoted 4 lines
Please make a patch against Linus's current tree. I put the rest of your rtnetlink device interface changes in, and your patches here duplicate all of that.
See below.
Quoted 2 lines
I agree also with Jamel wrt.
ioctl(), let's not go there if possible. :-)
Ok.
I did also go the ioctl() way because that's what iproute2-2.6.8 uses.
[Dave: sorry for the sending you this twice]
--
Eric
===== include/linux/rtnetlink.h 1.41 vs edited =====
include/linux/rtnetlink.h Tue Aug 31 11:22:55 2004 renamed from include/linux/rtnetlink.h Wed Aug 25 02:20:27 2004 +2 -0
@@ -565,6 +565,8 @@ #define IFLA_TXQLEN IFLA_TXQLEN IFLA_MAP, #define IFLA_MAP IFLA_MAP + IFLA_WEIGHT, +#define IFLA_WEIGHT IFLA_WEIGHT __IFLA_MAX };
===== net/core/rtnetlink.c 1.23 vs edited =====
net/core/rtnetlink.c Tue Aug 31 11:27:15 2004 renamed from net/core/rtnetlink.c Wed Aug 25 02:20:27 2004 +12 -0
@@ -177,6 +177,11 @@ } if (1) { + u32 weight = dev->weight; + RTA_PUT(skb, IFLA_WEIGHT, sizeof(weight), &weight); + } + + if (1) { struct ifmap map = { .mem_start = dev->mem_start, .mem_end = dev->mem_end,
@@ -331,6 +336,13 @@ goto out; dev->tx_queue_len = *((u32 *) RTA_DATA(ida[IFLA_TXQLEN - 1])); + } + + if (ida[IFLA_WEIGHT - 1]) { + if (ida[IFLA_WEIGHT - 1]->rta_len != RTA_LENGTH(sizeof(u32))) + goto out; + + dev->weight = *((u32 *) RTA_DATA(ida[IFLA_WEIGHT - 1])); } err = 0;
Quoted 9 lines
Quoted 9 lines
For my own testing purposes, I often need to modify
dev->weight. So I patched the kernel and iproute2 to be able to modifydev->weightusing ip(8). After all, one can modifytx_queue_lenso why not weight?Two kernel patches attached: one using the ioctl framework and another using the rtnetlink framework. Warning: the attached rtnetlink patch is a superset of Thomas Graf's rtnetlink patch for setting mtu and
tx_queue_len.
Quoted 4 lines
Quoted 1 line
PS: both patches are against 2.6.5-rc3-ben0 but should apply to any 2.6.
Looks sane.
Not sure if you should encourage ioctl though ;->
iproute still uses ioctl at that time, doesn't it?
Quoted 2 lines
Out of curiosity, what/when do you change weight? I think its valuable to do so, just curious.
With weight one can have the NIC fetch rx descriptors while the rx interrupt remains disabled. This further means that under high input load, one single rx interrupt can result in more than RX_RING_SIZE rx packets polled. Using this + tx polling, I could observe a system fully loaded by the network with no interrupts at all.
Quoted 1 line
missing user space/ip patch btw.
I attached a patch to iproute-2.6.8. To make the patch compile I had to tinker with the Makefile - it seems that KERNEL_INCLUDE does no longer serve any purpose, except for ATM maybe.
Signature · 1 line
Eric
* Eric Lemoine <[email protected]> 2004-08-30 16:33
Quoted 5 lines
iproute still uses ioctl at that time, doesn't it?
[...]
I attached a patch to iproute-2.6.8. To make the patch compile I had to tinker with theMakefile- it seems thatKERNEL_INCLUDEdoes no longer serve any purpose, except for ATM maybe.
I have a patch for it and added support for your new changes. I'm currently holding it back until all issues with the 2.4 backport have been solved.