# Buggy code
def _netstat_route_linux():
    """
    Return netstat routing information for Linux distros
    """
    ret = []
    cmd = "netstat -A inet -rn | tail -n+3"
    out = __salt__["cmd.run"](cmd)
    for line in out.splitlines():
        comps = line.split()
        ret.append(
            {
                "addr_family": "inet",
                "destination": comps[0],
                "gateway": comps[1],
                "netmask": comps[2],
                "flags": comps[3],
                "interface": comps[7],
            }
        )
    cmd = "netstat -A inet6 -rn | tail -n+3"
    out = __salt__["cmd.run"](cmd)
    for line in out.splitlines():
        comps = line.split()
        if len(comps) == 6:
            ret.append(
                {
                    "addr_family": "inet6",
                    "destination": comps[0],
                    "gateway": comps[1],
                    "netmask": "",
                    "flags": comps[3],
                    "interface": comps[5],
                }
            )
        elif len(comps) == 7:
            ret.append(
                {
                    "addr_family": "inet6",
                    "destination": comps[0],
                    "gateway": comps[1],
                    "netmask": "",
                    "flags": comps[3],
                    "interface": comps[6],
                }
            )
        else:
            continue
    return ret


# Traceback (IndexError)
----------
retcode:
1
stderr:
Traceback (most recent call last):
File "/tmp/.root_8ed75c__salt/salt-call", line 4, in <module>
salt_call()
File "/tmp/.root_8ed75c__salt/salt/scripts.py", line 220, in salt_call
client.run()
File "/tmp/.root_8ed75c__salt/salt/cli/call.py", line 69, in run
caller.run()
File "/tmp/.root_8ed75c__salt/salt/cli/caller.py", line 236, in run
ret = self.call()
File "/tmp/.root_8ed75c__salt/salt/cli/caller.py", line 138, in call
ret['return'] = func(*args, **kwargs)
File "/tmp/.root_8ed75c__salt/salt/modules/network.py", line 1087, in default_route
_routes = routes()
File "/tmp/.root_8ed75c__salt/salt/modules/network.py", line 1058, in routes
routes_ = _netstat_route_linux()
File "/tmp/.root_8ed75c__salt/salt/modules/network.py", line 309, in _netstat_route_linux
'destination': comps[0],
IndexError: list index out of range
stdout:

# Fixed code
def _netstat_route_linux():
    """
    Return netstat routing information for Linux distros
    """
    ret = []
    cmd = "netstat -A inet -rn | tail -n+3"
    out = __salt__["cmd.run"](cmd, python_shell=True)
    for line in out.splitlines():
        comps = line.split()
        ret.append(
            {
                "addr_family": "inet",
                "destination": comps[0],
                "gateway": comps[1],
                "netmask": comps[2],
                "flags": comps[3],
                "interface": comps[7],
            }
        )
    cmd = "netstat -A inet6 -rn | tail -n+3"
    out = __salt__["cmd.run"](cmd, python_shell=True)
    for line in out.splitlines():
        comps = line.split()
        if len(comps) == 6:
            ret.append(
                {
                    "addr_family": "inet6",
                    "destination": comps[0],
                    "gateway": comps[1],
                    "netmask": "",
                    "flags": comps[3],
                    "interface": comps[5],
                }
            )
        elif len(comps) == 7:
            ret.append(
                {
                    "addr_family": "inet6",
                    "destination": comps[0],
                    "gateway": comps[1],
                    "netmask": "",
                    "flags": comps[3],
                    "interface": comps[6],
                }
            )
        else:
            continue
    return ret