Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError exception on tcshow with empty qdisc configuration #57

Closed
eroullit opened this issue Mar 11, 2017 · 6 comments
Closed

ValueError exception on tcshow with empty qdisc configuration #57

eroullit opened this issue Mar 11, 2017 · 6 comments
Labels

Comments

@eroullit
Copy link

/ # tc qdisc show dev eth0
/ # tcset --device eth0 --delay 100
/ # tcshow --device eth0
{
    "eth0": {
        "outgoing": {
            "network=0.0.0.0/0": {
                "delay": "100.0",
                "rate": "10G"
            }
        },
        "incoming": {}
    }
}
/ # tc qdisc show dev eth0
qdisc htb 1a1a: root refcnt 2 r2q 10 default 1 direct_packets_stat 0 direct_qlen 2
qdisc netem 1a9a: parent 1a1a:2 limit 1000 delay 100.0ms
/ # tcdel --device eth0
[NOTICE] tcconfig: failed to delete qdisc: no qdisc for incomming packets
/ # tc qdisc show dev eth0
/ # tcshow --device eth0
Traceback (most recent call last):
  File "/usr/bin/tcshow", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python2.7/site-packages/tcconfig/tcshow.py", line 213, in main
    tc_param.update(TcShapingRuleParser(device, logger).get_tc_parameter())
  File "/usr/lib/python2.7/site-packages/tcconfig/tcshow.py", line 74, in get_tc_parameter
    TrafficDirection.OUTGOING: self.__get_shaping_rule(self.device),
  File "/usr/lib/python2.7/site-packages/tcconfig/tcshow.py", line 126, in __get_shaping_rule
    qdisc_param_list = self.__parse_tc_qdisc(device)
  File "/usr/lib/python2.7/site-packages/tcconfig/tcshow.py", line 178, in __parse_tc_qdisc
    run_tc_show(Tc.Subcommand.QDISC, device)))
  File "/usr/lib/python2.7/site-packages/tcconfig/parser.py", line 201, in parse
    raise ValueError("empty text")
ValueError: empty text

It can happen that no qdisc is configured for a specific device and I would have expected that an empty JSON dict to be output.

Regards,

  • Emmanuel
thombashi added a commit that referenced this issue Mar 11, 2017
@thombashi
Copy link
Owner

@eroullit
Thank you for your report.

Unfortunately, I could not reproduce the problem in my environment
(Debian 8.6/Fedora 24, tcconfig 0.7.1, python 2.7.12/3.6.0).

# tcdel --device eth0
[NOTICE] tcconfig: failed to delete qdisc: no qdisc for outgoing packets
[NOTICE] tcconfig: failed to delete qdisc: no qdisc for incomming packets
# tcshow --device eth0
{
    "eth0": {
        "outgoing": {},
        "incoming": {}
    }
}

However, it is true that an exception is not properly handled when parsing value is empty.
I've fixed the problem in tcconfig 0.7.2.
Would you upgrade to this version and re-execute the command?

@thombashi thombashi added the bug label Mar 12, 2017
@eroullit
Copy link
Author

The published fix works great thanks!

/ # tcshow --debug --device eth0
[DEBUG] subprocrunner: tc class show dev eth0
[DEBUG] tcconfig: tc class parse result: []
[DEBUG] subprocrunner: tc filter show dev eth0
[DEBUG] tcconfig: tc filter parse result: []
[DEBUG] subprocrunner: tc qdisc show dev eth0
[DEBUG] subprocrunner: tc filter show dev eth0 root
{
    "eth0": {
        "outgoing": {},
        "incoming": {}
    }
}
/ # pip freeze | grep tcconfig
tcconfig==0.7.2

@ortaltur
Copy link

maybe i'm missing something but the latest version is 0.18.0,
how do i get 0.7.2?

@thombashi
Copy link
Owner

@ortaltur
You can install tcconfig 0.7.2 with the following command:

pip install tcconfig==0.7.2

However, I would recommend using the latest version (0.18.0).
Is there any problem with the latest version?

@ortaltur
Copy link

ortaltur commented Apr 12, 2018

when i'm executing the tcset and tcdel commands in python script (using subprocess.Popen), i get the following error:
[ERROR] tcconfig: RTNETLINK answers: No such file or directory

[ERROR] tcconfig: Cannot find device "ifb6682"

[WARNING] subprocrunner: command='/sbin/tc filter add dev ifb6682 protocol ip parent 1a1a: prio 2 u32 match ip dst 0.0.0.0/0 match ip src 0.0.0.0/0 match ip dport 30302 0xffff flowid 1a1a:1', returncode=1, stderr=Cannot find device "ifb6682"

p.s:
in 0.7.2 the tcdel command doesn't accept --all

@thombashi
Copy link
Owner

@ortaltur
Could you try the following troubleshooting procedure:
http:https://tcconfig.readthedocs.io/en/latest/pages/troubleshooting.html#rtnetlink-answers-no-such-file-or-directory

And, please use the latest version of tcconfig.
Looks like there is no need to use the old version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants