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

Change or append/create rules #88

Closed
dastergon opened this issue Oct 1, 2017 · 8 comments
Closed

Change or append/create rules #88

dastergon opened this issue Oct 1, 2017 · 8 comments
Assignees

Comments

@dastergon
Copy link
Contributor

I use tcconfig on multiple hosts where I execute commands via Ansible, therefore, I do not store state. I would like to be able to override rules (on per network basis) without affecting the other rules and, if the rules do not exist, I would like to append (--add) them in the current list of traffic shaping rules. This could be done either by introducing a new option or changing the logic of --change option.

Thanks.

@thombashi
Copy link
Owner

Please let me confirm your suggestion especially the latter part.

changing the logic of --change option.

Does it means to change the logic as follows?

Before (current behavior)

  • Already exist a shaping rule -> Changing the rule parameter
  • NOT exist a shaping rule -> Exit with error

After

  • Already exist a shaping rule -> Changing the rule parameter (no change)
  • NOT exist a shaping rule -> Add a new rule

@dastergon
Copy link
Contributor Author

@thombashi exactly! Add a new rule but do not affect existing rules(i.e., --overwrite behavior).

@thombashi
Copy link
Owner

@dastergon
Thank you for your confirmation.
It sure seems to be one of the common usages.
I would implement the feature in the next release.

@thombashi thombashi self-assigned this Oct 2, 2017
@thombashi
Copy link
Owner

@dastergon
I have changed the --change option behavior as described in the above comment.
Please try tcconfig 0.16.0.

# tcshow -d ens33
{
    "ens33": {
        "outgoing": {},
        "incoming": {}
    }
}
# tcset -d ens33 --delay 10ms --change
# tcshow -d ens33
{
    "ens33": {
        "outgoing": {
            "protocol=ip": {
                "filter_id": "800::800",
                "delay": "10.0ms",
                "rate": "1G"
            }
        },
        "incoming": {}
    }
}

@dastergon
Copy link
Contributor Author

@thombashi

I have an issue when I try to create multiple entries with the --change option.

How to reproduce

tcset --direction outgoing --dst-network 192.168.122.202 --delay 12milliseconds --rate 10Gbps --device ens3 --change
tcset --direction incoming --dst-network 192.168.122.202 --delay 12milliseconds --device ens3 --rate 10Gbps --change

The commands work as expected:

tcshow -d ens3
{
    "ens3": {
        "outgoing": {
            "dst-network=192.168.122.202/32, protocol=ip": {
                "delay": "12.0ms",
                "rate": "10G",
                "filter_id": "800::800"
            }
        },
        "incoming": {
            "dst-network=192.168.122.202/32, protocol=ip": {
                "delay": "12.0ms",
                "rate": "10G",
                "filter_id": "800::800"
            }
        }
    }
}

But when I try to add a new entry for a different network:

tcset --direction outgoing --dst-network 192.168.122.203 --delay 12milliseconds --rate 10Gbps --device ens3 --change; tcset --direction incoming --dst-network 192.168.122.203 --delay 12milliseconds --device ens3 --rate 10Gbps --change;

I get the following error:

[NOTICE] tcconfig: failed to 'tc qdisc add': qdisc already exists (dev ens3, handle=1602:, algo=htb). try to execute with: (a) --overwrite option if you want to overwrite the existing rule. (b) --add option if you want to add a new rule in addition to the existing rules. (c) --change option if you want to change the existing rule parameter.
[NOTICE] tcconfig: failed to add ip link: ip link already exists. try to execute with: (a) --overwrite option if you want to overwrite the existing rule. (b) --add option if you want to add a new rule in addition to the existing rules. (c) --change option if you want to change the existing rule parameter.
[NOTICE] tcconfig: failed to 'tc qdisc add': ingress qdisc already exists. try to execute with: (a) --overwrite option if you want to overwrite the existing rule. (b) --add option if you want to add a new rule in addition to the existing rules. (c) --change option if you want to change the existing rule parameter.
[NOTICE] tcconfig: failed to 'tc qdisc add': qdisc already exists (dev ifb5634, handle=1602:, algo=htb). try to execute with: (a) --overwrite option if you want to overwrite the existing rule. (b) --add option if you want to add a new rule in addition to the existing rules. (c) --change option if you want to change the existing rule parameter.

@thombashi
Copy link
Owner

@dastergon
Sorry to bother you.
I believe the problem fixed at tcconfig 0.16.1.
Could you try this version?

# tcdel -d ens33 -a
# tcset --direction outgoing --dst-network 192.168.122.202 --delay 12milliseconds --rate 1Gbps --device ens33 --change
# tcset --direction incoming --dst-network 192.168.122.202 --delay 12milliseconds --device ens33 --rate 1Gbps --change
# tcset --direction outgoing --dst-network 192.168.122.203 --delay 12milliseconds --rate 1Gbps --device ens33 --change
# tcset --direction incoming --dst-network 192.168.122.203 --delay 12milliseconds --device ens33 --rate 1Gbps --change
# tcshow -d ens33
{
    "ens33": {
        "outgoing": {
            "dst-network=192.168.122.202/32, protocol=ip": {
                "filter_id": "800::800",
                "delay": "12.0ms",
                "rate": "1G"
            },
            "dst-network=192.168.122.203/32, protocol=ip": {
                "filter_id": "800::801",
                "delay": "12.0ms",
                "rate": "1G"
            }
        },
        "incoming": {
            "dst-network=192.168.122.202/32, protocol=ip": {
                "filter_id": "800::800",
                "delay": "12.0ms",
                "rate": "1G"
            },
            "dst-network=192.168.122.203/32, protocol=ip": {
                "filter_id": "800::801",
                "delay": "12.0ms",
                "rate": "1G"
            }
        }
    }
}

thombashi added a commit that referenced this issue Oct 17, 2017
@dastergon
Copy link
Contributor Author

@thombashi It works now! Thanks!

@thombashi
Copy link
Owner

@dastergon
Thank you for confirming.
I will close the issue then.

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

No branches or pull requests

2 participants