os-net-config throwing error when applying routes to interface/VLAN
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
os-net-config |
Fix Released
|
Critical
|
Dan Sneddon |
Bug Description
Fairly recent changes to os-net-config allow simple changes like IP, MTU, netmask, or routes to be changed on the fly without restarting the interface. However, route updates to interfaces and VLANs are still causing interfaces to be restarted due to an error.
The error encountered is:
Object "route add 172.33.9.0/26 via 172.20.1.59 dev vlan100" is unknown, try "ip help".
This can be duplicated by calling 'ip' with the parameters above passed as a string, such as:
# ip "route add 172.33.9.0/26 via 172.20.1.59 dev vlan100"
This appears to be due to an incorrect call to self.execute() where the command parameters are being passed as a string:
self.execute(
Instead, if we split the commands and pass it as a pointer to the list of args, that should work:
args = command.split()
self.execute(
Changed in os-net-config: | |
importance: | Undecided → Critical |
status: | New → In Progress |
assignee: | nobody → Dan Sneddon (dsneddon) |
It turns out that this is a compound bug with two code errors. The first is the command-line parameters being passed as a string instead of a pointer to the args. The second is an incorrect filename in checking existing routes. This code:
for interface in apply_routes:
logger. debug(' Applying routes for interface %s' % interface[0])
commands = self.iproute2_ route_commands( interface[ 0], interface[1])
is passing an interface name where it should be passing a filename. Here is the corrected code:
for interface in apply_routes:
logger. debug(' Applying routes for interface %s' % interface[0])
filename = self.root_dir + route_config_ path(interface[ 1])
commands = self.iproute2_ route_commands( interface[ 0], filename)