After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 730934 - [review] th/bgo730934_platform_route_lookup
[review] th/bgo730934_platform_route_lookup
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: NetworkManager maintainer(s)
NetworkManager maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-05-29 11:35 UTC by Thomas Haller
Modified: 2014-05-30 18:23 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Thomas Haller 2014-05-29 11:35:15 UTC
Please review branch th/bgo*_platform_route_lookup.


Quoting the commit message:

    platform: fix lookup of routes and deletion of IPv4 routes
    
    When doing a lookup for an libnl route, the cache comparison function
    for routes takes into account 'family', 'tos', 'table', 'dst', and 'prio'.
    
    In NetworkManager we don't use all of these properties for a route, so
    at several places when doing a cache lookup we don't have all identifying
    properties. Usually we only have 'family' and 'dst' ('table' is
    implicit 0, because NM does currently not care about any other tables).
    
    The problem is that NM sees routes with different 'tos', 'prio', but it
    cannot look them up in the cache. Add a hack to search the cache
    fuzzy.
    
    This is similar to the hack for link, where the identifying properties
    are 'family' and 'ifindex', but we only have 'ifindex' at hand. However,
    contrary to this hack, we coerce the 'family' to AF_UNSPEC for every link cache
    operation. This is not viable in this case, because we internally need
    the 'tos' field.
    
    We need the 'tos' field because when deleting an IPv4 route, the 'tos' field must
    match. See fib_table_delete(). This was already partially fixed by commit
    f0daf90298d1bd9cafac7b9c02dc905327e0b85a, but before the lookup to the
    cached object would fail for any non-zero 'tos'.
Comment 1 Dan Williams 2014-05-29 19:14:05 UTC
Branch looks OK to me, though I kinda wish libnl could get modified to help us out here, so less code in NM is necessary.
Comment 2 Dan Winship 2014-05-30 16:19:25 UTC
Agree with dcbw that this is becoming a total mess. We need to make this better somehow.


> platform: fix out-of-bound access in ip6_route_exists()

you could pass &in6addr_any instead?

(It's not really so much "out-of-bound access" as it is "completely broken code"... it's accidentally passing INADDR_ANY instead of a pointer to it, which only compiles because INADDR_ANY is 0, which gets silently cast to NULL. And even if it was passing a pointer-to-an-address rather than an address, it would still have the problem that the address was too short if family was AF_INET6.)


> platform: fix check_cache_items() to check items in two steps

A GSList would be more idiomatic, but this works
Comment 3 Thomas Haller 2014-05-30 16:51:22 UTC
(In reply to comment #2)
> Agree with dcbw that this is becoming a total mess. We need to make this better
> somehow.

I agree, the solution is IMO to cache our native NMPlatform* objects, so we have full control.


> > platform: fix out-of-bound access in ip6_route_exists()
> 
> you could pass &in6addr_any instead?
> 
> (It's not really so much "out-of-bound access" as it is "completely broken
> code"... it's accidentally passing INADDR_ANY instead of a pointer to it, which
> only compiles because INADDR_ANY is 0, which gets silently cast to NULL. And
> even if it was passing a pointer-to-an-address rather than an address, it would
> still have the problem that the address was too short if family was AF_INET6.)

Ah, I actually got that wrong. So, it was not a bug in behavior (but certainly not intended as such). Commit now fixes 
  platform/trivial: fix typo in ip6_route_exists()

Uppss... just now noticed a left-over typo in the commit message...


> > platform: fix check_cache_items() to check items in two steps
> 
> A GSList would be more idiomatic, but this works

I like the pointer array better (and it should perform better too!! :) )



Merged to master as:
http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=master
Comment 4 Thomas Haller 2014-05-30 18:22:12 UTC
Sorry, the merge broke something. Pushed additional fix

http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=253bfa5c4729d4a04d9f2331350bfed43da3585f
Comment 5 Thomas Haller 2014-05-30 18:23:55 UTC
(In reply to comment #3)
>
> Merged to master as:
> http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=master

I meant to say:

http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=98052255ba2c4b344646985a07c551014ef22c1a

hfff... 

[note to self: don't merge anything in the last hour before week end]