Skip to content

adding anycast address support to routes - #55416

Closed
bryceml wants to merge 2 commits into
saltstack:masterfrom
bryceml:add_anycast_route_support
Closed

bryceml wants to merge 2 commits into
saltstack:masterfrom
bryceml:add_anycast_route_support

Conversation

@bryceml

@bryceml bryceml commented Nov 23, 2019

Copy link
Copy Markdown
Contributor

What does this PR do?

It accounts for anycast address in the route table, which occurs when you are running docker and ipv6 at the same time, for example:

{
	"ipv6": true,
	"fixed-cidr-v6": "2001:0db8::11:0/124",
}

as /etc/docker/daemon.json

What issues does this PR fix or reference?

none yet

Previous Behavior

when running salt-call --local network.routes -l trace I would get this output:

[DEBUG   ] LazyLoaded network.default_route
[DEBUG   ] LazyLoaded direct_call.execute
[TRACE   ] 'netstat' could not be found in the following search path: '['/usr/local/sbin', '/usr/local/bin', '/usr/sbin', '/usr/bin', '/sbin', '/bin', '/usr/games', '/usr/local/games', '/snap/bin']'
[TRACE   ] Loaded cmdmod as virtual cmd
[DEBUG   ] LazyLoaded cmd.run
[INFO    ] Executing command 'ip -4 route show table main' in directory '/root'
[DEBUG   ] stdout: default via 192.168.90.1 dev enp5s0 proto dhcp metric 100 
172.18.0.0/16 dev docker0 proto kernel scope link src 172.18.0.1 linkdown 
192.168.90.0/24 dev enp5s0 proto kernel scope link src 192.168.90.117 metric 100 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown
[DEBUG   ] output: default via 192.168.90.1 dev enp5s0 proto dhcp metric 100 
172.18.0.0/16 dev docker0 proto kernel scope link src 172.18.0.1 linkdown 
192.168.90.0/24 dev enp5s0 proto kernel scope link src 192.168.90.117 metric 100 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown
[INFO    ] Executing command 'ip -6 route show table all' in directory '/root'
[DEBUG   ] stdout: ::1 dev lo proto kernel metric 256 pref medium
2001:0db8::ef dev enp5s0 proto kernel metric 100 pref medium
2001:0db8::11:0/124 dev docker0 proto kernel metric 256 linkdown pref medium
2001:0db8::11:0/124 dev docker0 metric 1024 linkdown pref medium
2001:0db8::/64 dev enp5s0 proto ra metric 100 pref medium
fe80::/64 dev enp5s0 proto kernel metric 100 pref medium
fe80::/64 dev docker0 proto kernel metric 256 linkdown pref medium
fe80::/64 dev veth7c176f3 proto kernel metric 256 linkdown pref medium
default via fe80::222:14ff:fe8a:7c14 dev enp5s0 proto ra metric 100 pref medium
local ::1 dev lo table local proto kernel metric 0 pref medium
anycast 2001:0db8:: dev enp5s0 table local proto kernel metric 0 pref medium
local 2001:0db8::ef dev enp5s0 table local proto kernel metric 0 pref medium
anycast 2001:0db8::11:0 dev docker0 table local proto kernel metric 0 pref medium
local 2001:0db8::11:1 dev docker0 table local proto kernel metric 0 pref medium
local 2001:0db8::e781:ee52:d246:3509 dev enp5s0 table local proto kernel metric 0 pref medium
anycast fe80:: dev enp5s0 table local proto kernel metric 0 pref medium
anycast fe80:: dev docker0 table local proto kernel metric 0 pref medium
anycast fe80:: dev veth7c176f3 table local proto kernel metric 0 pref medium
local fe80::1 dev docker0 table local proto kernel metric 0 pref medium
local fe80::42:78ff:fe57:37b7 dev docker0 table local proto kernel metric 0 pref medium
local fe80::3be9:e5c3:419b:c8ae dev enp5s0 table local proto kernel metric 0 pref medium
local fe80::d4dc:4dff:fe2b:e5c8 dev veth7c176f3 table local proto kernel metric 0 pref medium
ff00::/8 dev enp5s0 table local metric 256 pref medium
ff00::/8 dev docker0 table local metric 256 linkdown pref medium
ff00::/8 dev veth7c176f3 table local metric 256 linkdown pref medium
[DEBUG   ] output: ::1 dev lo proto kernel metric 256 pref medium
2001:0db8::ef dev enp5s0 proto kernel metric 100 pref medium
2001:0db8::11:0/124 dev docker0 proto kernel metric 256 linkdown pref medium
2001:0db8::11:0/124 dev docker0 metric 1024 linkdown pref medium
2001:0db8::/64 dev enp5s0 proto ra metric 100 pref medium
fe80::/64 dev enp5s0 proto kernel metric 100 pref medium
fe80::/64 dev docker0 proto kernel metric 256 linkdown pref medium
fe80::/64 dev veth7c176f3 proto kernel metric 256 linkdown pref medium
default via fe80::222:14ff:fe8a:7c14 dev enp5s0 proto ra metric 100 pref medium
local ::1 dev lo table local proto kernel metric 0 pref medium
anycast 2001:0db8:: dev enp5s0 table local proto kernel metric 0 pref medium
local 2001:0db8::ef dev enp5s0 table local proto kernel metric 0 pref medium
anycast 2001:0db8::11:0 dev docker0 table local proto kernel metric 0 pref medium
local 2001:0db8::11:1 dev docker0 table local proto kernel metric 0 pref medium
local 2001:0db8::e781:ee52:d246:3509 dev enp5s0 table local proto kernel metric 0 pref medium
anycast fe80:: dev enp5s0 table local proto kernel metric 0 pref medium
anycast fe80:: dev docker0 table local proto kernel metric 0 pref medium
anycast fe80:: dev veth7c176f3 table local proto kernel metric 0 pref medium
local fe80::1 dev docker0 table local proto kernel metric 0 pref medium
local fe80::42:78ff:fe57:37b7 dev docker0 table local proto kernel metric 0 pref medium
local fe80::3be9:e5c3:419b:c8ae dev enp5s0 table local proto kernel metric 0 pref medium
local fe80::d4dc:4dff:fe2b:e5c8 dev veth7c176f3 table local proto kernel metric 0 pref medium
ff00::/8 dev enp5s0 table local metric 256 pref medium
ff00::/8 dev docker0 table local metric 256 linkdown pref medium
ff00::/8 dev veth7c176f3 table local metric 256 linkdown pref medium
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
ValueError: 'anycast' does not appear to be an IPv4 or IPv6 network
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 11, in <module>
    salt_call()
  File "/usr/lib/python3/dist-packages/salt/scripts.py", line 431, in salt_call
    client.run()
  File "/usr/lib/python3/dist-packages/salt/cli/call.py", line 57, in run
    caller.run()
  File "/usr/lib/python3/dist-packages/salt/cli/caller.py", line 138, in run
    ret = self.call()
  File "/usr/lib/python3/dist-packages/salt/cli/caller.py", line 237, in call
    ret['return'] = self.minion.executors[fname](self.opts, data, func, args, kwargs)
  File "/usr/lib/python3/dist-packages/salt/executors/direct_call.py", line 12, in execute
    return func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/modules/network.py", line 1686, in default_route
    _routes = routes()
  File "/usr/lib/python3/dist-packages/salt/modules/network.py", line 1643, in routes
    routes_ = _ip_route_linux()
  File "/usr/lib/python3/dist-packages/salt/modules/network.py", line 565, in _ip_route_linux
    address_mask = convert_cidr(comps[0])
  File "/usr/lib/python3/dist-packages/salt/modules/network.py", line 1145, in convert_cidr
    cidr = calc_net(cidr)
  File "/usr/lib/python3/dist-packages/salt/modules/network.py", line 1167, in calc_net
    return salt.utils.network.calc_net(ip_addr, netmask)
  File "/usr/lib/python3/dist-packages/salt/utils/network.py", line 1087, in calc_net
    return six.text_type(ipaddress.ip_network(ipaddr, strict=False))
  File "/usr/lib/python3.7/ipaddress.py", line 84, in ip_network
    address)
ValueError: 'anycast' does not appear to be an IPv4 or IPv6 network
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 11, in <module>
    salt_call()
  File "/usr/lib/python3/dist-packages/salt/scripts.py", line 431, in salt_call
    client.run()
  File "/usr/lib/python3/dist-packages/salt/cli/call.py", line 57, in run
    caller.run()
  File "/usr/lib/python3/dist-packages/salt/cli/caller.py", line 138, in run
    ret = self.call()
  File "/usr/lib/python3/dist-packages/salt/cli/caller.py", line 237, in call
    ret['return'] = self.minion.executors[fname](self.opts, data, func, args, kwargs)
  File "/usr/lib/python3/dist-packages/salt/executors/direct_call.py", line 12, in execute
    return func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/modules/network.py", line 1686, in default_route
    _routes = routes()
  File "/usr/lib/python3/dist-packages/salt/modules/network.py", line 1643, in routes
    routes_ = _ip_route_linux()
  File "/usr/lib/python3/dist-packages/salt/modules/network.py", line 565, in _ip_route_linux
    address_mask = convert_cidr(comps[0])
  File "/usr/lib/python3/dist-packages/salt/modules/network.py", line 1145, in convert_cidr
    cidr = calc_net(cidr)
  File "/usr/lib/python3/dist-packages/salt/modules/network.py", line 1167, in calc_net
    return salt.utils.network.calc_net(ip_addr, netmask)
  File "/usr/lib/python3/dist-packages/salt/utils/network.py", line 1087, in calc_net
    return six.text_type(ipaddress.ip_network(ipaddr, strict=False))
  File "/usr/lib/python3.7/ipaddress.py", line 84, in ip_network
    address)
ValueError: 'anycast' does not appear to be an IPv4 or IPv6 network

New Behavior

I get the proper output,

local:
    |_
      ----------
      addr_family:
          inet
      destination:
          0.0.0.0
      flags:
          UG
      gateway:
          192.168.90.1
      interface:
          enp5s0
      netmask:
          0.0.0.0
    |_
      ----------
      addr_family:
          inet
      destination:
          172.18.0.0
      flags:
          U
      gateway:
          0.0.0.0
      interface:
          docker0
      netmask:
          255.255.0.0
    |_
      ----------
      addr_family:
          inet
      destination:
          192.168.90.0
      flags:
          U
      gateway:
          0.0.0.0
      interface:
          enp5s0
      netmask:
          255.255.255.0
    |_
      ----------
      addr_family:
          inet
      destination:
          192.168.122.0
      flags:
          U
      gateway:
          0.0.0.0
      interface:
          virbr0
      netmask:
          255.255.255.0
    |_
      ----------
      addr_family:
          inet6
      destination:
          ::1
      flags:
          U
      gateway:
          ::
      interface:
          lo
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          2001:0db8::ef
      flags:
          U
      gateway:
          ::
      interface:
          enp5s0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          2001:0db8::11:0/124
      flags:
          U
      gateway:
          ::
      interface:
          docker0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          2001:0db8::11:0/124
      flags:
          U
      gateway:
          ::
      interface:
          docker0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          2001:0db8::/64
      flags:
          U
      gateway:
          ::
      interface:
          enp5s0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          fe80::/64
      flags:
          U
      gateway:
          ::
      interface:
          enp5s0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          fe80::/64
      flags:
          U
      gateway:
          ::
      interface:
          docker0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          fe80::/64
      flags:
          U
      gateway:
          ::
      interface:
          veth7c176f3
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          ::/0
      flags:
          UG
      gateway:
          fe80::222:15ff:fe8a:7c15
      interface:
          enp5s0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          ::1/128
      flags:
          U
      gateway:
          ::
      interface:
          lo
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          2001:0db8::/128
      flags:
          U
      gateway:
          ::
      interface:
          enp5s0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          2001:0db8::ef/128
      flags:
          U
      gateway:
          ::
      interface:
          enp5s0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          2001:0db8::11:0/128
      flags:
          U
      gateway:
          ::
      interface:
          docker0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          2001:0db8::11:1/128
      flags:
          U
      gateway:
          ::
      interface:
          docker0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
         2001:0db8::e781:ee52:d246:3509/128
      flags:
          U
      gateway:
          ::
      interface:
          enp5s0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          fe80::/128
      flags:
          U
      gateway:
          ::
      interface:
          enp5s0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          fe80::/128
      flags:
          U
      gateway:
          ::
      interface:
          docker0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          fe80::/128
      flags:
          U
      gateway:
          ::
      interface:
          veth7c176f3
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          fe80::1/128
      flags:
          U
      gateway:
          ::
      interface:
          docker0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          fe80::42:78ff:fe57:37b7/128
      flags:
          U
      gateway:
          ::
      interface:
          docker0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          fe80::3be9:e5c3:419b:c8ae/128
      flags:
          U
      gateway:
          ::
      interface:
          enp5s0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          fe80::d4dc:4dff:fe2b:e5c8/128
      flags:
          U
      gateway:
          ::
      interface:
          veth7c176f3
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          ff00::/8
      flags:
          U
      gateway:
          ::
      interface:
          enp5s0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          ff00::/8
      flags:
          U
      gateway:
          ::
      interface:
          docker0
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          ff00::/8
      flags:
          U
      gateway:
          ::
      interface:
          veth7c176f3
      netmask:

As far as I could tell, the output of anycast and local seemed the same. It would be good to have that verified by someone else.

@bryceml
bryceml requested a review from a team as a code owner November 23, 2019 10:44
@ghost
ghost requested a review from Ch3LL November 23, 2019 10:44
@Akm0d Akm0d added the needs-testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases label Nov 26, 2019
@Akm0d Akm0d added this to the Approved milestone Nov 26, 2019
@Ch3LL
Ch3LL removed the request for review from a team April 15, 2020 14:32
@Ch3LL Ch3LL self-assigned this Apr 15, 2020
@sagetherage sagetherage assigned DmitryKuzmenko and unassigned Ch3LL May 5, 2020
@DmitryKuzmenko
DmitryKuzmenko requested review from DmitryKuzmenko and removed request for Ch3LL May 9, 2020 10:07
@sagetherage sagetherage assigned bryceml and unassigned DmitryKuzmenko Jun 1, 2020
@bryceml

bryceml commented Jun 4, 2020

Copy link
Copy Markdown
Contributor Author

There is a lot more to fix here than I initially thought, I don't know when I would have time to finish. This probably needs a bit of a refactor.

@sagetherage
sagetherage requested review from dwoz and removed request for DmitryKuzmenko November 18, 2020 18:55
@sagetherage sagetherage added the merge-conflict PR has a merge conflict label Nov 18, 2020
@sagetherage sagetherage removed this from the Approved milestone Nov 18, 2020
@bryceml

bryceml commented Nov 23, 2020

Copy link
Copy Markdown
Contributor Author

This will likely get taken care of by fixing #57541 or something similar, so I'm closing this as it's old and has merge conflicts and I don't have the time to fix it.

@bryceml bryceml closed this Nov 23, 2020
@bryceml
bryceml deleted the add_anycast_route_support branch November 23, 2020 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-conflict PR has a merge conflict needs-testcase PR needs test cases written, or the issue is about a bug/feature that needs test cases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants