Hello, I''m using tc to limit the bandwidth of our wireless customers. I have a working script, but I''m not happy with it. I''m trying to write a more sophisticated script, but when I run it, it give me this error: RTNETLINK answers: File exists I have no idea what this error means or how to fix it. Here is a portion of the script (the whole script shapes several interfaces): IDEV=''eth5'' TC=''/sbin/tc'' IPS=''/etc/sysconfig/shaper/shape.ips'' # high priority destination ports - I''ll fill these in later (when this # thing works) HIGHPORT# low priority destination ports LOWPORT $TC qdisc add dev $IDEV root handle 1: cbq bandwidth 1600Kbit cell 8\ avpkt 1000 mpu 64 $TC class add dev $IDEV parent 1: classid 1:1 est 1sec 8sec cbq\ bandwidth 1600Kbit rate 1500kbit allot 1514 maxburst 20 avpkt 1000\ prio 0 bounded isolated cat $IPS | sed -e ''s/#.*$//; s/^ *$//;'' | while read IP RATE STATUS; do if [ "x$IP" == "x" ]; then continue fi # I use the last byte of the customer''s IP''s for the handle, which range # from 76 to 135 ATM. HANDLE="${IP##*.}" # I get the error from the next line. Because it fails to create the # qdisc all the rest fail too. $TC qdisc add dev $IDEV parent 1:1 handle 1:$HANDLE cbq\ bandwidth 1600Kbit cell 8 avpkt 1000 mpu 64 $TC class add dev $IDEV parent 1:$HANDLE classid $HANDLE:\ est 1sec 8sec cbq bandwidth 1600Kbit rate ${RATE}kbit allot 1514\ maxburst 20 avpkt 1000 prio 1 bounded isolated $TC class add dev $IDEV parent $HANDLE: classid $HANDLE:1\ est 1sec 8sec cbq bandwidth 1600Kbit rate ${RATE}kbit allot 1514\ maxburst 20 avpkt 1000 prio 2 $TC class add dev $IDEV parent $HANDLE: classid $HANDLE:2 est 1sec\ 8sec cbq bandwidth 1600Kbit rate $[9*$RATE/10]kbit allot 1514\ maxburst 20 avpkt 1000 prio 3 $TC class add dev $IDEV parent $HANDLE: classid $HANDLE:3 est 1sec\ 8sec cbq bandwidth 1600Kbit rate $[8*$RATE/10]kbit allot 1514\ maxburst 20 avpkt 1000 prio 4 $TC qdisc add dev $IDEV parent $HANDLE:1 sfq quantum 1514b\ perturb 15 $TC qdisc add dev $IDEV parent $HANDLE:2 sfq quantum 1514b\ perturb 15 $TC qdisc add dev $IDEV parent $HANDLE:3 sfq quantum 1514b\ perturb 15 $TC filter add dev $IDEV parent 1: protocol ip prio 16\ u32 match ip src $IP flowid $HANDLE: $TC filter add dev $IDEV parent $HANDLE: protocol ip prio 10\ u32 match ip tos 0x10 0xff flowid $HANDLE:1 $TC filter add dev $IDEV parent $HANDLE: protocol ip prio 11\ u32 match ip protocol 1 0xff flowid $HANDLE:1 $TC filter add dev $IDEV parent $HANDLE: protocol ip prio 12\ u32 match ip protocol 6 0xff match u8 0x05 0x0f at 0 match u16\ 0x0000 0xffc0 at 2 flowid $HANDLE:1 for a in $HIGHPORT; do $TC filter add dev $IDEV parent 1:0 protocol ip prio 14\ u32 match ip dport $a 0xffff flowid $HANDLE:1 done for a in $LOWPORT; do $TC filter add dev $IDEV parent 1:0 protocol ip prio 16\ u32 match ip dport $a 0xffff flowid $HANDLE:3 done $TC filter add dev $IDEV parent 1:0 protocol ip prio 15\ u32 match ip dst 0.0.0.0/0 flowid $HANDLE:2 done There are bound to other problems with this script, but until I can get past the current one, I''m dead in the water. TIA William Murphy Network Administrator Velocity Technologies, Inc.
Leigh Sharpe
2006-Sep-14 22:31 UTC
RE: tc is giving an error: RTNETLINK answers: File exists
This is usually because you are attempting to create a class ID or a Qdisc ID which already exists. Check what value $HANDLE is on each iteration, perhaps using an echo on each pass to display it. I think you''ll find it is trying to use the same value twice. Regards, Leigh Leigh Sharpe Network Systems Engineer Pacific Wireless Ph +61 3 9584 8966 Mob 0408 009 502 email lsharpe@pacificwireless.com.au web www.pacificwireless.com.au -----Original Message----- From: fourcentsshy [mailto:fourcentsshy@velotech.net] Sent: Friday, September 15, 2006 8:15 AM To: lartc@mailman.ds9a.nl Subject: [LARTC] tc is giving an error: RTNETLINK answers: File exists Hello, I''m using tc to limit the bandwidth of our wireless customers. I have a working script, but I''m not happy with it. I''m trying to write a more sophisticated script, but when I run it, it give me this error: RTNETLINK answers: File exists I have no idea what this error means or how to fix it. Here is a portion of the script (the whole script shapes several interfaces): IDEV=''eth5'' TC=''/sbin/tc'' IPS=''/etc/sysconfig/shaper/shape.ips'' # high priority destination ports - I''ll fill these in later (when this # thing works) HIGHPORT# low priority destination ports LOWPORT $TC qdisc add dev $IDEV root handle 1: cbq bandwidth 1600Kbit cell 8\ avpkt 1000 mpu 64 $TC class add dev $IDEV parent 1: classid 1:1 est 1sec 8sec cbq\ bandwidth 1600Kbit rate 1500kbit allot 1514 maxburst 20 avpkt 1000\ prio 0 bounded isolated cat $IPS | sed -e ''s/#.*$//; s/^ *$//;'' | while read IP RATE STATUS; do if [ "x$IP" == "x" ]; then continue fi # I use the last byte of the customer''s IP''s for the handle, which range # from 76 to 135 ATM. HANDLE="${IP##*.}" # I get the error from the next line. Because it fails to create the # qdisc all the rest fail too. $TC qdisc add dev $IDEV parent 1:1 handle 1:$HANDLE cbq\ bandwidth 1600Kbit cell 8 avpkt 1000 mpu 64 $TC class add dev $IDEV parent 1:$HANDLE classid $HANDLE:\ est 1sec 8sec cbq bandwidth 1600Kbit rate ${RATE}kbit allot 1514\ maxburst 20 avpkt 1000 prio 1 bounded isolated $TC class add dev $IDEV parent $HANDLE: classid $HANDLE:1\ est 1sec 8sec cbq bandwidth 1600Kbit rate ${RATE}kbit allot 1514\ maxburst 20 avpkt 1000 prio 2 $TC class add dev $IDEV parent $HANDLE: classid $HANDLE:2 est 1sec\ 8sec cbq bandwidth 1600Kbit rate $[9*$RATE/10]kbit allot 1514\ maxburst 20 avpkt 1000 prio 3 $TC class add dev $IDEV parent $HANDLE: classid $HANDLE:3 est 1sec\ 8sec cbq bandwidth 1600Kbit rate $[8*$RATE/10]kbit allot 1514\ maxburst 20 avpkt 1000 prio 4 $TC qdisc add dev $IDEV parent $HANDLE:1 sfq quantum 1514b\ perturb 15 $TC qdisc add dev $IDEV parent $HANDLE:2 sfq quantum 1514b\ perturb 15 $TC qdisc add dev $IDEV parent $HANDLE:3 sfq quantum 1514b\ perturb 15 $TC filter add dev $IDEV parent 1: protocol ip prio 16\ u32 match ip src $IP flowid $HANDLE: $TC filter add dev $IDEV parent $HANDLE: protocol ip prio 10\ u32 match ip tos 0x10 0xff flowid $HANDLE:1 $TC filter add dev $IDEV parent $HANDLE: protocol ip prio 11\ u32 match ip protocol 1 0xff flowid $HANDLE:1 $TC filter add dev $IDEV parent $HANDLE: protocol ip prio 12\ u32 match ip protocol 6 0xff match u8 0x05 0x0f at 0 match u16\ 0x0000 0xffc0 at 2 flowid $HANDLE:1 for a in $HIGHPORT; do $TC filter add dev $IDEV parent 1:0 protocol ip prio 14\ u32 match ip dport $a 0xffff flowid $HANDLE:1 done for a in $LOWPORT; do $TC filter add dev $IDEV parent 1:0 protocol ip prio 16\ u32 match ip dport $a 0xffff flowid $HANDLE:3 done $TC filter add dev $IDEV parent 1:0 protocol ip prio 15\ u32 match ip dst 0.0.0.0/0 flowid $HANDLE:2 done There are bound to other problems with this script, but until I can get past the current one, I''m dead in the water. TIA William Murphy Network Administrator Velocity Technologies, Inc. _______________________________________________ LARTC mailing list LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc
fourcentsshy
2006-Sep-14 23:11 UTC
RE: tc is giving an error: RTNETLINK answers: File exists
On Fri, 2006-09-15 at 08:31 +1000, Leigh Sharpe wrote:> This is usually because you are attempting to create a class ID or aQdisc ID which already exists.> Check what value $HANDLE is on each iteration, perhaps using an echoon each pass to display it. I think you''ll find it is trying to use the same value twice.> > > Regards, > Leigh > > Leigh Sharpe > Network Systems Engineer > Pacific Wireless > Ph +61 3 9584 8966 > Mob 0408 009 502 > email lsharpe@pacificwireless.com.au > web www.pacificwireless.com.au >Thanks for the quick reply. Not only have I tried that, I inserted an exit statement after the first iteration (to limit the info). The first qdisc in the loop has the handle 1:76 and it''s parent is 1:1. The only other qdisc is the root qdisc that is created before the loop. The script also does a reset, deleting any existing qdiscs, classes or filters, before creating any new ones. Is there a limit to how large the handle can be? Cheers, William Murphy Network Administrator Velocity Technologies, Inc.
fourcentsshy wrote:> > Hello, > > I''m using tc to limit the bandwidth of our wireless customers. I have a > working script, but I''m not happy with it. I''m trying to write a more > sophisticated script, but when I run it, it give me this error: > > RTNETLINK answers: File exists > > I have no idea what this error means or how to fix it.It means pretty much what it says. There is already a record matching closely enough that it is duplicated.> Here is a portion > of the script (the whole script shapes several interfaces): > > IDEV=''eth5'' > TC=''/sbin/tc'' > IPS=''/etc/sysconfig/shaper/shape.ips'' > # high priority destination ports - I''ll fill these in later (when this > # thing works) > HIGHPORT> # low priority destination ports > LOWPORT> > $TC qdisc add dev $IDEV root handle 1: cbq bandwidth 1600Kbit cell 8\ > avpkt 1000 mpu 64 > $TC class add dev $IDEV parent 1: classid 1:1 est 1sec 8sec cbq\ > bandwidth 1600Kbit rate 1500kbit allot 1514 maxburst 20 avpkt 1000\ > prio 0 bounded isolated > > cat $IPS | sed -e ''s/#.*$//; s/^ *$//;'' | while read IP RATE STATUS; do > if [ "x$IP" == "x" ]; then > continue > fi > > # I use the last byte of the customer''s IP''s for the handle, which range > # from 76 to 135 ATM. > > HANDLE="${IP##*.}" > > # I get the error from the next line. Because it fails to create the > # qdisc all the rest fail too. > > $TC qdisc add dev $IDEV parent 1:1 handle 1:$HANDLE cbq\ > bandwidth 1600Kbit cell 8 avpkt 1000 mpu 64 > > $TC class add dev $IDEV parent 1:$HANDLE classid $HANDLE:\ > est 1sec 8sec cbq bandwidth 1600Kbit rate ${RATE}kbit allot 1514\ > maxburst 20 avpkt 1000 prio 1 bounded isolated > $TC class add dev $IDEV parent $HANDLE: classid $HANDLE:1\ > est 1sec 8sec cbq bandwidth 1600Kbit rate ${RATE}kbit allot 1514\ > maxburst 20 avpkt 1000 prio 2 > $TC class add dev $IDEV parent $HANDLE: classid $HANDLE:2 est 1sec\ > 8sec cbq bandwidth 1600Kbit rate $[9*$RATE/10]kbit allot 1514\ > maxburst 20 avpkt 1000 prio 3 > $TC class add dev $IDEV parent $HANDLE: classid $HANDLE:3 est 1sec\ > 8sec cbq bandwidth 1600Kbit rate $[8*$RATE/10]kbit allot 1514\ > maxburst 20 avpkt 1000 prio 4 > $TC qdisc add dev $IDEV parent $HANDLE:1 sfq quantum 1514b\ > perturb 15 > $TC qdisc add dev $IDEV parent $HANDLE:2 sfq quantum 1514b\ > perturb 15 > $TC qdisc add dev $IDEV parent $HANDLE:3 sfq quantum 1514b\ > perturb 15 > $TC filter add dev $IDEV parent 1: protocol ip prio 16\ > u32 match ip src $IP flowid $HANDLE: > $TC filter add dev $IDEV parent $HANDLE: protocol ip prio 10\ > u32 match ip tos 0x10 0xff flowid $HANDLE:1 > $TC filter add dev $IDEV parent $HANDLE: protocol ip prio 11\ > u32 match ip protocol 1 0xff flowid $HANDLE:1 > $TC filter add dev $IDEV parent $HANDLE: protocol ip prio 12\ > u32 match ip protocol 6 0xff match u8 0x05 0x0f at 0 match u16\ > 0x0000 0xffc0 at 2 flowid $HANDLE:1 > > for a in $HIGHPORT; do > $TC filter add dev $IDEV parent 1:0 protocol ip prio 14\ > u32 match ip dport $a 0xffff flowid $HANDLE:1 > done > for a in $LOWPORT; do > $TC filter add dev $IDEV parent 1:0 protocol ip prio 16\ > u32 match ip dport $a 0xffff flowid $HANDLE:3 > done > $TC filter add dev $IDEV parent 1:0 protocol ip prio 15\ > u32 match ip dst 0.0.0.0/0 flowid $HANDLE:2 > done > > There are bound to other problems with this script, but until I can get > past the current one, I''m dead in the water. TIAYou do not say which line or lines is causing the error so this is a guess. Run `tc -s filter show dev $IDEV'' sending the output to a file because there will be a lot of it. I think you will find a ton of "duplicate" filters. Set prio to the same value (16 or 10 perhaps) for each and every line in your `$TC filter'' lines. -- gypsy
fourcentsshy wrote:> Is there a limit to how large the > handle can be?Yes. The handle is in hex, so I _think_ the max is 255. Maybe Stef Coene''s web site or a search of this mailing list will give you the RIGHT answer. I hate getting old; I should remember what the max here is. -- gypsy
fourcentsshy
2006-Sep-15 19:47 UTC
Re: tc is giving an error: RTNETLINK answers: File exists
On Thu, 2006-09-14 at 21:36 -0700, gypsy wrote:> fourcentsshy wrote: > > > > Hello, > > > > I''m using tc to limit the bandwidth of our wireless customers. I have a > > working script, but I''m not happy with it. I''m trying to write a more > > sophisticated script, but when I run it, it give me this error: > > > > RTNETLINK answers: File exists > > > > I have no idea what this error means or how to fix it. > > It means pretty much what it says. There is already a record matching > closely enough that it is duplicated. >That is what puzzles me the most. If you look at the script, I create the root qdisc, add a class to it and when I try to add a qdisc to that class on the first iteration in the loop, I get the error right off. The script also deletes all qdiscs, classes and filters before it creates any new ones. On the first iteration of the loop, the handle is 1:76 with it''s parent 1:1, which should be unique, since it''s only the second qdisc created. As Leigh Sharpe suggested, I had already inserted echo statements into the script so I could examine what was really going on. For this device, the error takes place on the third command. the command sequence take place like this: /sbin/tc qdisc add dev eth5 root handle 1: cbq bandwidth 1600Kbit\ cell 8 avpkt 1000 mpu 64 /sbin/tc class add dev eth5 parent 1: classid 1:1 est 1sec 8sec cbq\ bandwidth 1600Kbit rate 1500kbit allot 1514 maxburst 20 avpkt 1000\ prio 0 bounded isolated /sbin/tc qdisc add dev eth5 parent 1:1 handle 1:76 cbq\ bandwidth 1600Kbit cell 8 avpkt 1000 mpu 64 RTNETLINK answers: File exists Like I said, I start by resetting all the devices on the machine, so there is no possible way there can be any existing qdisc with a handle of 1:76 for that device, yet I get the error anyway. The script is setup as a service to be run at startup, so checking the status after running the script for that device, I get this: [qdisc - eth5] qdisc cbq 1: rate 1600Kbit (bounded,isolated) prio no-transmit Sent 139719 bytes 181 pkt (dropped 0, overlimits 0 requeues 0) rate 0bit 0pps backlog 0b 0p requeues 0 borrowed 0 overactions 0 avgidle 5120 undertime 0 ------------------------ [class - eth5] class cbq 1:11 parent 1:1 leaf 8236: rate 700000bit prio 2 Sent 13814 bytes 42 pkt (dropped 0, overlimits 0 requeues 0) rate 11792bit 4pps backlog 0b 0p requeues 0 borrowed 0 overactions 0 avgidle 306884 undertime 0 class cbq 1: root rate 100000Kbit (bounded,isolated) prio no-transmit Sent 60 bytes 1 pkt (dropped 0, overlimits 0 requeues 0) rate 0bit 0pps backlog 0b 0p requeues 0 borrowed 0 overactions 0 avgidle 81 undertime 0 class cbq 1:10 parent 1:1 leaf 8235: rate 750000bit prio 1 Sent 6712 bytes 48 pkt (dropped 0, overlimits 0 requeues 0) rate 2008bit 2pps backlog 0b 0p requeues 0 borrowed 0 overactions 0 avgidle 148506 undertime 0 class cbq 1:1 parent 1: rate 800000bit (bounded,isolated) prio no-transmit Sent 20526 bytes 90 pkt (dropped 0, overlimits 0 requeues 0) rate 13800bit 7pps backlog 0b 0p requeues 0 borrowed 0 overactions 0 avgidle 57889 undertime 0 class cbq 1:12 parent 1:1 leaf 8237: rate 700000bit prio 3 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) rate 0bit 0pps backlog 0b 0p requeues 0 borrowed 0 overactions 0 avgidle 329838 undertime 0 Maybe I''m blind, but I don''t see any qdisc or class with a handle of 1:76. Something else is wrong, but I don''t see it.> > Here is a portion > > of the script (the whole script shapes several interfaces): > > > > IDEV=''eth5'' > > TC=''/sbin/tc'' > > IPS=''/etc/sysconfig/shaper/shape.ips'' > > # high priority destination ports - I''ll fill these in later (when this > > # thing works) > > HIGHPORT> > # low priority destination ports > > LOWPORT> > > > $TC qdisc add dev $IDEV root handle 1: cbq bandwidth 1600Kbit cell 8\ > > avpkt 1000 mpu 64 > > $TC class add dev $IDEV parent 1: classid 1:1 est 1sec 8sec cbq\ > > bandwidth 1600Kbit rate 1500kbit allot 1514 maxburst 20 avpkt 1000\ > > prio 0 bounded isolated > > > > cat $IPS | sed -e ''s/#.*$//; s/^ *$//;'' | while read IP RATE STATUS; do > > if [ "x$IP" == "x" ]; then > > continue > > fi > > > > # I use the last byte of the customer''s IP''s for the handle, which range > > # from 76 to 135 ATM. > > > > HANDLE="${IP##*.}" > > > > # I get the error from the next line. Because it fails to create the > > # qdisc all the rest fail too. > > > > $TC qdisc add dev $IDEV parent 1:1 handle 1:$HANDLE cbq\ > > bandwidth 1600Kbit cell 8 avpkt 1000 mpu 64 > > > > $TC class add dev $IDEV parent 1:$HANDLE classid $HANDLE:\ > > est 1sec 8sec cbq bandwidth 1600Kbit rate ${RATE}kbit allot 1514\ > > maxburst 20 avpkt 1000 prio 1 bounded isolated > > $TC class add dev $IDEV parent $HANDLE: classid $HANDLE:1\ > > est 1sec 8sec cbq bandwidth 1600Kbit rate ${RATE}kbit allot 1514\ > > maxburst 20 avpkt 1000 prio 2 > > $TC class add dev $IDEV parent $HANDLE: classid $HANDLE:2 est 1sec\ > > 8sec cbq bandwidth 1600Kbit rate $[9*$RATE/10]kbit allot 1514\ > > maxburst 20 avpkt 1000 prio 3 > > $TC class add dev $IDEV parent $HANDLE: classid $HANDLE:3 est 1sec\ > > 8sec cbq bandwidth 1600Kbit rate $[8*$RATE/10]kbit allot 1514\ > > maxburst 20 avpkt 1000 prio 4 > > $TC qdisc add dev $IDEV parent $HANDLE:1 sfq quantum 1514b\ > > perturb 15 > > $TC qdisc add dev $IDEV parent $HANDLE:2 sfq quantum 1514b\ > > perturb 15 > > $TC qdisc add dev $IDEV parent $HANDLE:3 sfq quantum 1514b\ > > perturb 15 > > $TC filter add dev $IDEV parent 1: protocol ip prio 16\ > > u32 match ip src $IP flowid $HANDLE: > > $TC filter add dev $IDEV parent $HANDLE: protocol ip prio 10\ > > u32 match ip tos 0x10 0xff flowid $HANDLE:1 > > $TC filter add dev $IDEV parent $HANDLE: protocol ip prio 11\ > > u32 match ip protocol 1 0xff flowid $HANDLE:1 > > $TC filter add dev $IDEV parent $HANDLE: protocol ip prio 12\ > > u32 match ip protocol 6 0xff match u8 0x05 0x0f at 0 match u16\ > > 0x0000 0xffc0 at 2 flowid $HANDLE:1 > > > > for a in $HIGHPORT; do > > $TC filter add dev $IDEV parent 1:0 protocol ip prio 14\ > > u32 match ip dport $a 0xffff flowid $HANDLE:1 > > done > > for a in $LOWPORT; do > > $TC filter add dev $IDEV parent 1:0 protocol ip prio 16\ > > u32 match ip dport $a 0xffff flowid $HANDLE:3 > > done > > $TC filter add dev $IDEV parent 1:0 protocol ip prio 15\ > > u32 match ip dst 0.0.0.0/0 flowid $HANDLE:2 > > done > > > > There are bound to other problems with this script, but until I can get > > past the current one, I''m dead in the water. TIA > > You do not say which line or lines is causing the error so this is a > guess.I inserted a comment in the script that points out which command causes the error. It''s the first command inside the loop.> > Run `tc -s filter show dev $IDEV'' sending the output to a file because > there will be a lot of it. I think you will find a ton of "duplicate" > filters.I inserted an exit statement right after the command that give the error. The script never gets to the statements that creates the filters. Checking the status of the service would display the filters along with the qdiscs and classes, but there are none.> > Set prio to the same value (16 or 10 perhaps) for each and every line in > your `$TC filter'' lines.If I ever get this script working, I''ll do that. ;-)
fourcentsshy wrote:> the script so I could examine what was really going on. For this device, > the error takes place on the third command. the command sequence take > place like this: > > /sbin/tc qdisc add dev eth5 root handle 1: cbq bandwidth 1600Kbit\ > cell 8 avpkt 1000 mpu 64 > > /sbin/tc class add dev eth5 parent 1: classid 1:1 est 1sec 8sec cbq\ > bandwidth 1600Kbit rate 1500kbit allot 1514 maxburst 20 avpkt 1000\ > prio 0 bounded isolated > > /sbin/tc qdisc add dev eth5 parent 1:1 handle 1:76 cbq\ > bandwidth 1600Kbit cell 8 avpkt 1000 mpu 64This says to me "cell", not "ceil". That''s a mistake.> RTNETLINK answers: File exists > > Like I said, I start by resetting all the devices on the machine, so > there is no possible way there can be any existing qdisc with a handle > of 1:76 for that device, yet I get the error anyway. The script is setup > as a service to be run at startup, so checking the status after running > the script for that device, I get this:==--snip--=> error. The script never gets to the statements that creates the filters.> Checking the status of the service would display the filters along with > the qdiscs and classes, but there are none. > > > > > Set prio to the same value (16 or 10 perhaps) for each and every line in > > your `$TC filter'' lines. > > If I ever get this script working, I''ll do that. ;-)One more thing. You can send your commands to a database (mysql or whatever). Once disallowing duplicate records and again allowing dups. The difference is the Bad Boy. I use HTB not CBQ but I still think the parameter is "ceil" not "cell" and fixing that will help or solve. -- gypsy
Yongle Lai
2006-Sep-18 02:01 UTC
Re: tc is giving an error: RTNETLINK answers: File exists
Since handle xxxx:0000 represents QDISC, so in the handle 1:76, the QDISC ID is 1:0, that''s the reason. Yongle -----Original Message----- From: lartc-bounces@mailman.ds9a.nl [mailto:lartc-bounces@mailman.ds9a.nl] On Behalf Of lartc-request@mailman.ds9a.nl Sent: 2006年9月16日 18:00 To: lartc@mailman.ds9a.nl Subject: LARTC Digest, Vol 19, Issue 19 Send LARTC mailing list submissions to lartc@mailman.ds9a.nl To subscribe or unsubscribe via the World Wide Web, visit http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc or, via email, send a message with subject or body ''help'' to lartc-request@mailman.ds9a.nl You can reach the person managing the list at lartc-owner@mailman.ds9a.nl When replying, please edit your Subject line so it is more specific than "Re: Contents of LARTC digest..." Today''s Topics: 1. Re: tc is giving an error: RTNETLINK answers: File exists (fourcentsshy) 2. Re: Re: htb traffic shaping problem (Bugzilla-Redirect) ---------------------------------------------------------------------- Message: 1 Date: Fri, 15 Sep 2006 12:47:53 -0700 From: fourcentsshy <fourcentsshy@velotech.net> Subject: Re: [LARTC] tc is giving an error: RTNETLINK answers: File exists To: gypsy <gypsy@iswest.com>, lartc <lartc@mailman.ds9a.nl> Message-ID: <1158349674.7896.34.camel@glyph.velotech.net> Content-Type: text/plain On Thu, 2006-09-14 at 21:36 -0700, gypsy wrote:> fourcentsshy wrote: > > > > Hello, > > > > I''m using tc to limit the bandwidth of our wireless customers. I > > have a working script, but I''m not happy with it. I''m trying to > > write a more sophisticated script, but when I run it, it give me this error: > > > > RTNETLINK answers: File exists > > > > I have no idea what this error means or how to fix it. > > It means pretty much what it says. There is already a record matching > closely enough that it is duplicated. >That is what puzzles me the most. If you look at the script, I create the root qdisc, add a class to it and when I try to add a qdisc to that class on the first iteration in the loop, I get the error right off. The script also deletes all qdiscs, classes and filters before it creates any new ones. On the first iteration of the loop, the handle is 1:76 with it''s parent 1:1, which should be unique, since it''s only the second qdisc created. As Leigh Sharpe suggested, I had already inserted echo statements into the script so I could examine what was really going on. For this device, the error takes place on the third command. the command sequence take place like this: /sbin/tc qdisc add dev eth5 root handle 1: cbq bandwidth 1600Kbit\ cell 8 avpkt 1000 mpu 64 /sbin/tc class add dev eth5 parent 1: classid 1:1 est 1sec 8sec cbq\ bandwidth 1600Kbit rate 1500kbit allot 1514 maxburst 20 avpkt 1000\ prio 0 bounded isolated /sbin/tc qdisc add dev eth5 parent 1:1 handle 1:76 cbq\ bandwidth 1600Kbit cell 8 avpkt 1000 mpu 64 RTNETLINK answers: File exists Like I said, I start by resetting all the devices on the machine, so there is no possible way there can be any existing qdisc with a handle of 1:76 for that device, yet I get the error anyway. The script is setup as a service to be run at startup, so checking the status after running the script for that device, I get this: [qdisc - eth5] qdisc cbq 1: rate 1600Kbit (bounded,isolated) prio no-transmit Sent 139719 bytes 181 pkt (dropped 0, overlimits 0 requeues 0) rate 0bit 0pps backlog 0b 0p requeues 0 borrowed 0 overactions 0 avgidle 5120 undertime 0 ------------------------ [class - eth5] class cbq 1:11 parent 1:1 leaf 8236: rate 700000bit prio 2 Sent 13814 bytes 42 pkt (dropped 0, overlimits 0 requeues 0) rate 11792bit 4pps backlog 0b 0p requeues 0 borrowed 0 overactions 0 avgidle 306884 undertime 0 class cbq 1: root rate 100000Kbit (bounded,isolated) prio no-transmit Sent 60 bytes 1 pkt (dropped 0, overlimits 0 requeues 0) rate 0bit 0pps backlog 0b 0p requeues 0 borrowed 0 overactions 0 avgidle 81 undertime 0 class cbq 1:10 parent 1:1 leaf 8235: rate 750000bit prio 1 Sent 6712 bytes 48 pkt (dropped 0, overlimits 0 requeues 0) rate 2008bit 2pps backlog 0b 0p requeues 0 borrowed 0 overactions 0 avgidle 148506 undertime 0 class cbq 1:1 parent 1: rate 800000bit (bounded,isolated) prio no-transmit Sent 20526 bytes 90 pkt (dropped 0, overlimits 0 requeues 0) rate 13800bit 7pps backlog 0b 0p requeues 0 borrowed 0 overactions 0 avgidle 57889 undertime 0 class cbq 1:12 parent 1:1 leaf 8237: rate 700000bit prio 3 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) rate 0bit 0pps backlog 0b 0p requeues 0 borrowed 0 overactions 0 avgidle 329838 undertime 0 Maybe I''m blind, but I don''t see any qdisc or class with a handle of 1:76. Something else is wrong, but I don''t see it.> > Here is a portion > > of the script (the whole script shapes several interfaces): > > > > IDEV=''eth5'' > > TC=''/sbin/tc'' > > IPS=''/etc/sysconfig/shaper/shape.ips'' > > # high priority destination ports - I''ll fill these in later (when > > this # thing works) HIGHPORT= # low priority destination ports > > LOWPORT> > > > $TC qdisc add dev $IDEV root handle 1: cbq bandwidth 1600Kbit cell > > 8\ avpkt 1000 mpu 64 $TC class add dev $IDEV parent 1: classid 1:1 > > est 1sec 8sec cbq\ bandwidth 1600Kbit rate 1500kbit allot 1514 > > maxburst 20 avpkt 1000\ prio 0 bounded isolated > > > > cat $IPS | sed -e ''s/#.*$//; s/^ *$//;'' | while read IP RATE STATUS; do > > if [ "x$IP" == "x" ]; then > > continue > > fi > > > > # I use the last byte of the customer''s IP''s for the handle, which > > range # from 76 to 135 ATM. > > > > HANDLE="${IP##*.}" > > > > # I get the error from the next line. Because it fails to create the > > # qdisc all the rest fail too. > > > > $TC qdisc add dev $IDEV parent 1:1 handle 1:$HANDLE cbq\ > > bandwidth 1600Kbit cell 8 avpkt 1000 mpu 64 > > > > $TC class add dev $IDEV parent 1:$HANDLE classid $HANDLE:\ est > > 1sec 8sec cbq bandwidth 1600Kbit rate ${RATE}kbit allot 1514\ > > maxburst 20 avpkt 1000 prio 1 bounded isolated > > $TC class add dev $IDEV parent $HANDLE: classid $HANDLE:1\ est > > 1sec 8sec cbq bandwidth 1600Kbit rate ${RATE}kbit allot 1514\ > > maxburst 20 avpkt 1000 prio 2 > > $TC class add dev $IDEV parent $HANDLE: classid $HANDLE:2 est > > 1sec\ 8sec cbq bandwidth 1600Kbit rate $[9*$RATE/10]kbit allot > > 1514\ maxburst 20 avpkt 1000 prio 3 > > $TC class add dev $IDEV parent $HANDLE: classid $HANDLE:3 est > > 1sec\ 8sec cbq bandwidth 1600Kbit rate $[8*$RATE/10]kbit allot > > 1514\ maxburst 20 avpkt 1000 prio 4 > > $TC qdisc add dev $IDEV parent $HANDLE:1 sfq quantum 1514b\ > > perturb 15 > > $TC qdisc add dev $IDEV parent $HANDLE:2 sfq quantum 1514b\ > > perturb 15 > > $TC qdisc add dev $IDEV parent $HANDLE:3 sfq quantum 1514b\ > > perturb 15 > > $TC filter add dev $IDEV parent 1: protocol ip prio 16\ > > u32 match ip src $IP flowid $HANDLE: > > $TC filter add dev $IDEV parent $HANDLE: protocol ip prio 10\ > > u32 match ip tos 0x10 0xff flowid $HANDLE:1 > > $TC filter add dev $IDEV parent $HANDLE: protocol ip prio 11\ > > u32 match ip protocol 1 0xff flowid $HANDLE:1 > > $TC filter add dev $IDEV parent $HANDLE: protocol ip prio 12\ > > u32 match ip protocol 6 0xff match u8 0x05 0x0f at 0 match u16\ > > 0x0000 0xffc0 at 2 flowid $HANDLE:1 > > > > for a in $HIGHPORT; do > > $TC filter add dev $IDEV parent 1:0 protocol ip prio 14\ > > u32 match ip dport $a 0xffff flowid $HANDLE:1 > > done > > for a in $LOWPORT; do > > $TC filter add dev $IDEV parent 1:0 protocol ip prio 16\ > > u32 match ip dport $a 0xffff flowid $HANDLE:3 > > done > > $TC filter add dev $IDEV parent 1:0 protocol ip prio 15\ > > u32 match ip dst 0.0.0.0/0 flowid $HANDLE:2 done > > > > There are bound to other problems with this script, but until I can > > get past the current one, I''m dead in the water. TIA > > You do not say which line or lines is causing the error so this is a > guess.I inserted a comment in the script that points out which command causes the error. It''s the first command inside the loop.> > Run `tc -s filter show dev $IDEV'' sending the output to a file because > there will be a lot of it. I think you will find a ton of "duplicate" > filters.I inserted an exit statement right after the command that give the error. The script never gets to the statements that creates the filters. Checking the status of the service would display the filters along with the qdiscs and classes, but there are none.> > Set prio to the same value (16 or 10 perhaps) for each and every line > in your `$TC filter'' lines.If I ever get this script working, I''ll do that. ;-) ------------------------------ Message: 2 Date: Fri, 15 Sep 2006 19:38:36 -0600 From: Bugzilla-Redirect <bugzilla@sysreset.com> Subject: Re: [LARTC] Re: htb traffic shaping problem To: lartc@mailman.ds9a.nl Message-ID: <6.2.0.14.2.20060915193530.02eaf330@linux.sysreset.com> Content-Type: text/plain; charset="iso-8859-1"; format=flowed Yes, the output is below: eth0 Link encap:Ethernet HWaddr 00:11:09:2A:A6:F6 inet addr:10.0.0.50 Bcast:10.0.0.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:4244867 errors:0 dropped:0 overruns:0 frame:0 TX packets:1306632 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3898905509 (3.6 GiB) TX bytes:1756030081 (1.6 GiB) Interrupt:19 And from ethtool: Settings for eth0: Supported ports: [ MII ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Advertised auto-negotiation: Yes Speed: 1000Mb/s Duplex: Full Port: MII PHYAD: 1 Transceiver: external Auto-negotiation: on Supports Wake-on: g Wake-on: d Link detected: yes Thanks. -Ryan Power At 04:32 PM 9/14/2006, you wrote:>Hi, > >could you check the mtu set on eth0 with an ifconfig? >I tried my own setup and it works fine... > > >Regards, > >Eric Janz >Departamento de Sistemas >Grupo Barceló Viajes------------------------------ _______________________________________________ LARTC mailing list LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc End of LARTC Digest, Vol 19, Issue 19 *************************************
fourcentsshy
2006-Sep-18 20:33 UTC
Re: tc is giving an error: RTNETLINK answers: File exists
On Sat, 2006-09-16 at 09:14 -0700, gypsy wrote:> fourcentsshy wrote: > > the script so I could examine what was really going on. For this device, > > the error takes place on the third command. the command sequence take > > place like this: > > > > /sbin/tc qdisc add dev eth5 root handle 1: cbq bandwidth 1600Kbit\ > > cell 8 avpkt 1000 mpu 64 > > > > /sbin/tc class add dev eth5 parent 1: classid 1:1 est 1sec 8sec cbq\ > > bandwidth 1600Kbit rate 1500kbit allot 1514 maxburst 20 avpkt 1000\ > > prio 0 bounded isolated > > > > /sbin/tc qdisc add dev eth5 parent 1:1 handle 1:76 cbq\ > > bandwidth 1600Kbit cell 8 avpkt 1000 mpu 64 > This says to me "cell", not "ceil". That''s a mistake.I wish that were true. It would make this problem so much easier to solve. The HTB classes use the ceil parameter, but CBQ qdiscs use the cell parameter for packet transmission time calculations. The manual says it has a reasonable default, but the working script I have didn''t shape properly until I played with it. ATM, since I''m debugging the script, its setup to exit after the 3rd tc command I''ve listed above. tc doesn''t seem to care what handle I give the second qdisc. I''ve tried many different handles and every time I get the same error: RTNETLINK answers: File exists. I''ve even tried running those very same lines on different machines, with different Linux distros on them. I keep getting the same error on them as well. It would be helpful if the device let me know which file it''s talking about. The working script only adds CBQ classes to CBQ classes. Is it possible that its forbidden to add a CBQ qdisc to a CBQ class?> > ==--snip--= > One more thing. > You can send your commands to a database (mysql or whatever). Once > disallowing duplicate records and again allowing dups. The difference > is the Bad Boy.I do love mysql and work with it almost daily (great fun). I thought about writing a customer database for the very reason you mentioned, but dups are not the problem. I do have a working script that uses the same resource file with no problems. It limits customer bandwidth nicely and even uses the same method of choosing handles, but there is a minor problem with load balancing. I''d very much like to fix that.> > I use HTB not CBQ but I still think the parameter is "ceil" not "cell" > and fixing that will help or solve.When I first started playing with tc, I tried using HTBs because they looked easier to work with. I couldn''t get them to work, so I tried the CBQs. They didn''t work either. It turned out that one of our technicians has installed an older version of Fedora on the gateway server and that version of tc was broken. I upgraded it to FC4 and the script came alive. Since the script was working, I didn''t bother to switch back to the HTBs (but I''m strongly considering doing just that). Thanks for your time. I guess I''ll keep trying different things. Cheers, William Murphy Velocity Technologies, Inc.
Yongle Lai
2006-Sep-19 06:12 UTC
Re: tc is giving an error: RTNETLINK answers: File exists
Hi Fourcentsshy, 1. After the 1st command is executed, there is a QDISC: 1:0 After the 2nd command is executed, there is a CLASS: 1;1 (CLASS and QDISC have different namespace) After the 3td command is executed, request for creating QDISC: 1:0 failed since there is a QDISC with the handle 1:0 already. You could try handle 2:0 in the 3td command. You need care that handle 1:76 equal to 1:0, QDISC just uses the higher 2 bytes. 2. I have tried the 3 commands which you gived. If I replace 1:76 with 2:0, the 3 commands could be executed successfully. 3. The parameters ceil and cell are right for each QDISC. For HTB, tc would calculate the cell according to other parameters because PKT_SCHED need cell. So for different QDISC, TC need different parameters. Bests, Yongle Lai -----Original Message----- Message: 8 Date: Mon, 18 Sep 2006 13:33:18 -0700 From: fourcentsshy <fourcentsshy@velotech.net> Subject: Re: [LARTC] tc is giving an error: RTNETLINK answers: File exists To: gypsy <gypsy@iswest.com>, lartc <lartc@mailman.ds9a.nl> Message-ID: <1158611598.7714.58.camel@glyph.velotech.net> Content-Type: text/plain On Sat, 2006-09-16 at 09:14 -0700, gypsy wrote:> fourcentsshy wrote: > > the script so I could examine what was really going on. For this > > device, the error takes place on the third command. the command > > sequence take place like this: > > > > /sbin/tc qdisc add dev eth5 root handle 1: cbq bandwidth 1600Kbit\ > > cell 8 avpkt 1000 mpu 64 > > > > /sbin/tc class add dev eth5 parent 1: classid 1:1 est 1sec 8sec cbq\ > > bandwidth 1600Kbit rate 1500kbit allot 1514 maxburst 20 avpkt 1000\ > > prio 0 bounded isolated > > > > /sbin/tc qdisc add dev eth5 parent 1:1 handle 1:76 cbq\ bandwidth > > 1600Kbit cell 8 avpkt 1000 mpu 64 > This says to me "cell", not "ceil". That''s a mistake.I wish that were true. It would make this problem so much easier to solve. The HTB classes use the ceil parameter, but CBQ qdiscs use the cell parameter for packet transmission time calculations. The manual says it has a reasonable default, but the working script I have didn''t shape properly until I played with it. ATM, since I''m debugging the script, its setup to exit after the 3rd tc command I''ve listed above. tc doesn''t seem to care what handle I give the second qdisc. I''ve tried many different handles and every time I get the same error: RTNETLINK answers: File exists. I''ve even tried running those very same lines on different machines, with different Linux distros on them. I keep getting the same error on them as well. It would be helpful if the device let me know which file it''s talking about. The working script only adds CBQ classes to CBQ classes. Is it possible that its forbidden to add a CBQ qdisc to a CBQ class?> > ==--snip--= > One more thing. > You can send your commands to a database (mysql or whatever). Once > disallowing duplicate records and again allowing dups. The difference > is the Bad Boy.I do love mysql and work with it almost daily (great fun). I thought about writing a customer database for the very reason you mentioned, but dups are not the problem. I do have a working script that uses the same resource file with no problems. It limits customer bandwidth nicely and even uses the same method of choosing handles, but there is a minor problem with load balancing. I''d very much like to fix that.> > I use HTB not CBQ but I still think the parameter is "ceil" not "cell" > and fixing that will help or solve.When I first started playing with tc, I tried using HTBs because they looked easier to work with. I couldn''t get them to work, so I tried the CBQs. They didn''t work either. It turned out that one of our technicians has installed an older version of Fedora on the gateway server and that version of tc was broken. I upgraded it to FC4 and the script came alive. Since the script was working, I didn''t bother to switch back to the HTBs (but I''m strongly considering doing just that). Thanks for your time. I guess I''ll keep trying different things. Cheers, William Murphy Velocity Technologies, Inc.
fourcentsshy
2006-Sep-19 18:47 UTC
Re: tc is giving an error: RTNETLINK answers: File exists
I''ve solved the problem. It turns out tc didn''t like the sequence the commands were in. The script was set up to create a qdisc for each customer and attach a rate limiting class to it. It looked like this: 1: root qdisk | 1:1 child class /|\ / | \ / | \ / | \ 1:76 1:77 1:78... customer qdiscs | | | 76: 77: 78: rate limiting classes /|\ ... / | \ / | \ / | \ 76:1 76:2 76:3 child classes to handle load balancing My bad. It should have looked like this: 1: root qdisk | 1:1 child class /|\ / | \ / | \ / | \ 1:76 1:77 1:78... customer rate limiting classes | | | 76: 77: 78: customer qdiscs /|\ ... / | \ / | \ / | \ 76:1 76:2 76:3 child classes to handle load balancing I had rewritten the script to use HTBs, yet the same error occured. That''s when I noticed the problem with the handles. switching the 2 commands fixed it.