I am learning TC recently. I want to do something like $TC class add dev {ifName} parent {parent} classid {classid} htb rate {limit}, but received netlink receive: invalid argument as a result.
Minimal code example to reproduce the issue
Because I don't want to change the network config in host, I call AddHTBClass in Linux network namespace(ip nets add ns1, BTW, I'm using Ubuntu20.04). I noticed that tc.Config has NetNS attribute, but I'm not sure how to deal with it, so I use another way to make the func works in NS correctly. To make the ns environment, use the bash below:
ip netns add ns1
ovs-vsctl add-br br0
ifconfig br0 up
ip link add v-ns1 type veth peer name b-ns1
ovs-vsctl add-port br0 b-ns1
ifconfig b-ns1 up
ip link set v-ns1 netns ns1
ip netns exec ns1 ifconfig v-ns1 up
Here's my main func. in this function, v-ns1 is one side of a veth pair where the other side b-ns1 is set on an ovs in the host .
Describe the issue
I am learning TC recently. I want to do something like
$TC class add dev {ifName} parent {parent} classid {classid} htb rate {limit}
, but receivednetlink receive: invalid argument
as a result.Minimal code example to reproduce the issue
Because I don't want to change the network config in host, I call
AddHTBClass
in Linux network namespace(ip nets add ns1
, BTW, I'm using Ubuntu20.04). I noticed thattc.Config
hasNetNS
attribute, but I'm not sure how to deal with it, so I use another way to make the func works in NS correctly. To make the ns environment, use the bash below:Here's my main func. in this function,
v-ns1
is one side of a veth pair where the other sideb-ns1
is set on an ovs in the host .after running createHTB(), I use
ip netns exec ns1 tc -s qdisc ls dev v-ns1
to checkv-ns1
, the result seems good:but when running createClass(), I get the err
err = netlink receive: invalid argument
.