Dan Kenigsberg has submitted this change and it was merged.

Change subject: sourcerouting: fix _getRoute not to include local routes
......................................................................


sourcerouting: fix _getRoute not to include local routes

_getRoute, a method used to find the routes of a vdsm-created table
in Dynamic Source Routing was listing the routes of the table and
matching by device. The problem is that such matching would wrongly
include local scope routes. Having such route would generate an
IPRoute2 exception when removing routes and rules would never be
removed, thus leaving behind trash in the rule list.

After adding source routing for a bridged-network, the ip rules
would look like:

    0:      from all lookup local
    32764:  from all to 240.0.0.0/24 iif test-network lookup 4026531841
    32765:  from 240.0.0.0/24 lookup 4026531841
    32766:  from all lookup main
    32767:  from all lookup default

The ip routes (as they were selected with
'ip route show table 4026531841) would look like:

    toniel602 tests (db78758) # ip route show table 4026531841
    240.0.0.0/24 dev test-network  proto kernel  scope link  src 240.0.0.1
    10.34.60.0/22 dev eth1  proto kernel  scope link  src 10.34.60.31
    169.254.0.0/16 dev eth1  scope link  metric 1002
    default via 10.34.63.254 dev eth1
    240.0.0.0/24 via 240.0.0.1 dev test-network
    default via 240.0.0.254 dev test-network
    broadcast 127.255.255.255 dev lo  proto kernel  scope link  src 127.0.0.1
    broadcast 240.0.0.255 dev test-network  proto kernel  scope link  src 
240.0.0.1
    local 10.34.60.31 dev eth1  proto kernel  scope host  src 10.34.60.31
    local 240.0.0.1 dev test-network  proto kernel  scope host  src 240.0.0.1
    broadcast 240.0.0.0 dev test-network  proto kernel  scope link  src 
240.0.0.1
    broadcast 10.34.60.0 dev eth1  proto kernel  scope link  src 10.34.60.31
    broadcast 10.34.63.255 dev eth1  proto kernel  scope link  src 10.34.60.31
    broadcast 127.0.0.0 dev lo  proto kernel  scope link  src 127.0.0.1
    local 127.0.0.1 dev lo  proto kernel  scope host  src 127.0.0.1
    local 127.0.0.0/8 dev lo  proto kernel  scope host  src 127.0.0.1

As you can see, there is a local entry for dev test-network. This
entry is parsable with ip vdsm/network/sourcerouting.py:Route.fromText
and will match the correct device. The issue is that attempting to
remove such entry will fail on the iproute tool.

The fix is to call instead:
'ip route show table all' which makes the output of the iproute tool
to include table information:

    240.0.0.0/24 dev test-network  proto kernel  scope link  src 240.0.0.1
    10.34.60.0/22 dev eth1  proto kernel  scope link  src 10.34.60.31
    169.254.0.0/16 dev eth1  scope link  metric 1002
    default via 10.34.63.254 dev eth1
    240.0.0.0/24 via 240.0.0.1 dev test-network  table 4026531841
    default via 240.0.0.254 dev test-network  table 4026531841
    broadcast 127.255.255.255 dev lo  table local  proto kernel  scope link  src
    127.0.0.1
    broadcast 240.0.0.255 dev test-network  table local  proto kernel  scope 
link
    src 240.0.0.1
    local 10.34.60.31 dev eth1  table local  proto kernel  scope host  src
    10.34.60.31
    local 240.0.0.1 dev test-network  table local  proto kernel  scope host  src
    240.0.0.1
    broadcast 240.0.0.0 dev test-network  table local  proto kernel  scope link
    src 240.0.0.1
    broadcast 10.34.60.0 dev eth1  table local  proto kernel  scope link  src
    10.34.60.31
    broadcast 10.34.63.255 dev eth1  table local  proto kernel  scope link  src
    10.34.60.31
    broadcast 127.0.0.0 dev lo  table local  proto kernel  scope link  src
    127.0.0.1
    local 127.0.0.1 dev lo  table local  proto kernel  scope host  src 127.0.0.1
    local 127.0.0.0/8 dev lo  table local  proto kernel  scope host  src 
127.0.0.1
    unreachable ::/96 dev lo  metric 1024  error -101 mtu 16436 advmss 16376
    hoplimit 4294967295
    unreachable ::ffff:0.0.0.0/96 dev lo  metric 1024  error -101 mtu 16436 
advmss
    16376 hoplimit 4294967295
    unreachable 2002:a00::/24 dev lo  metric 1024  error -101 mtu 16436 advmss
    16376 hoplimit 4294967295
    unreachable 2002:7f00::/24 dev lo  metric 1024  error -101 mtu 16436 advmss
    16376 hoplimit 4294967295
    unreachable 2002:a9fe::/32 dev lo  metric 1024  error -101 mtu 16436 advmss
    16376 hoplimit 4294967295
    unreachable 2002:ac10::/28 dev lo  metric 1024  error -101 mtu 16436 advmss
    16376 hoplimit 4294967295
    unreachable 2002:c0a8::/32 dev lo  metric 1024  error -101 mtu 16436 advmss
    16376 hoplimit 4294967295
    unreachable 2002:e000::/19 dev lo  metric 1024  error -101 mtu 16436 advmss
    16376 hoplimit 4294967295
    unreachable 3ffe:ffff::/32 dev lo  metric 1024  error -101 mtu 16436 advmss
    16376 hoplimit 4294967295
    fe80::/64 dev eth1  proto kernel  metric 256  mtu 1500 advmss 1440 hoplimit
    4294967295
    fe80::/64 dev dummy_45  proto kernel  metric 256  mtu 1500 advmss 1440 
hoplimit
    4294967295
    fe80::/64 dev test-network  proto kernel  metric 256  mtu 1500 advmss 1440
    hoplimit 4294967295
    unreachable default dev lo  table unspec  proto kernel  metric -1  error 
-101
    hoplimit 255
    local ::1 via :: dev lo  table local  proto none  metric 0  mtu 16436 advmss
    16376 hoplimit 4294967295
    local fe80::201:a4ff:feac:8702 via :: dev lo  table local  proto none  
metric
    0  mtu 16436 advmss 16376 hoplimit 4294967295
    local fe80::bcca:7fff:fe35:44ca via :: dev lo  table local  proto none  
metric
    0  mtu 16436 advmss 16376 hoplimit 4294967295
    local fe80::bcca:7fff:fe35:44ca via :: dev lo  table local  proto none  
metric
    0  mtu 16436 advmss 16376 hoplimit 4294967295
    ff02::1 via ff02::1 dev eth1  metric 0
        cache  mtu 1500 advmss 1440 hoplimit 4294967295
        ff00::/8 dev eth1  table local  metric 256  mtu 1500 advmss 1440 
hoplimit
        4294967295
        ff00::/8 dev dummy_45  table local  metric 256  mtu 1500 advmss 1440
        hoplimit 4294967295
        ff00::/8 dev test-network  table local  metric 256  mtu 1500 advmss 1440
        hoplimit 4294967295
        unreachable default dev lo  table unspec  proto kernel  metric -1  error
        -101 hoplimit 255

Now we can just easily filter for those that have the vdsm-created table. The
old way of asking iproute2 for a specific table suffers of the bug
https://bugzilla.redhat.com/1094676 which makes querying from but dumping as
above right.

Change-Id: I5b3d43c8a2077e40b8b4314f02ea17bc3968c42b
Signed-off-by: Antoni S. Puimedon <[email protected]>
Reviewed-on: http://gerrit.ovirt.org/27262
Reviewed-by: Dan Kenigsberg <[email protected]>
---
A tests/ip_route_show_table_all.out
A tests/sourceroutingTests.py
M vdsm/network/sourceroute.py
3 files changed, 87 insertions(+), 8 deletions(-)

Approvals:
  Antoni Segura Puimedon: Verified
  Dan Kenigsberg: Looks good to me, approved



-- 
To view, visit http://gerrit.ovirt.org/27262
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5b3d43c8a2077e40b8b4314f02ea17bc3968c42b
Gerrit-PatchSet: 4
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <[email protected]>
Gerrit-Reviewer: Antoni Segura Puimedon <[email protected]>
Gerrit-Reviewer: Assaf Muller <[email protected]>
Gerrit-Reviewer: Dan Kenigsberg <[email protected]>
Gerrit-Reviewer: [email protected]
Gerrit-Reviewer: oVirt Jenkins CI Server
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to