Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add package gluon-radv-filterd #838

Closed
wants to merge 51 commits into from
Closed

Add package gluon-radv-filterd #838

wants to merge 51 commits into from

Commits on Jan 3, 2018

  1. Add package gluon-radv-filterd

    This package drops all incoming router advertisements except for the
    default router with the best metric according to B.A.T.M.A.N. advanced.
    
    Note that advertisements originating from the node itself (for example
    via gluon-radvd) are not affected.
    jplitza committed Jan 3, 2018
    Copy the full SHA
    f963e05 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    e3b4dc5 View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    7d20a24 View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    615fb91 View commit details
    Browse the repository at this point in the history
  5. Copy the full SHA
    3667d60 View commit details
    Browse the repository at this point in the history
  6. Copy the full SHA
    e4457f2 View commit details
    Browse the repository at this point in the history
  7. Copy the full SHA
    2f8eed6 View commit details
    Browse the repository at this point in the history
  8. gluon-radv-filterd: Use fscanf() instead of getline() & sscanf() for …

    …BATMAN data
    
    This reduces the average CPU consumption (on a WDR4300) from 3% to 1%.
    
    Also, this commit adds error messages when the parsing fails and makes matching
    more flexible after all relevant fields have been found.
    jplitza committed Jan 3, 2018
    Copy the full SHA
    bd85e99 View commit details
    Browse the repository at this point in the history
  9. gluon-radv-filterd: Tweak constants

    As I have seen instances of ebtables being killed with a timeout of 100ms,
    increasing it to 500ms.
    
    Also, to ease the straint on the CPU, increasing minimum time between TQ checks
    to 15 seconds.
    jplitza committed Jan 3, 2018
    Copy the full SHA
    c887960 View commit details
    Browse the repository at this point in the history
  10. Copy the full SHA
    a313af7 View commit details
    Browse the repository at this point in the history
  11. Copy the full SHA
    43664bf View commit details
    Browse the repository at this point in the history
  12. Copy the full SHA
    5a4dc1f View commit details
    Browse the repository at this point in the history
  13. Copy the full SHA
    3bf4d12 View commit details
    Browse the repository at this point in the history
  14. Copy the full SHA
    a1fea71 View commit details
    Browse the repository at this point in the history
  15. gluon-radv-filterd: Fix and simplify originators parsing

    Previously, only one nexthop was recognized. The parsing of the whole file
    failed immediately when two or more hops were possible for *any* originator (not
    only for one with a router behind it).
    
    This makes the parser ignore most of the line in the originators table.
    jplitza committed Jan 3, 2018
    Copy the full SHA
    5f3f371 View commit details
    Browse the repository at this point in the history
  16. gluon-radv-filterd: Refactor packet checking

    Move more to BPF code and do not try to parse extension headers in C that
    wouldn't have made it through BPF anyway.
    jplitza committed Jan 3, 2018
    Copy the full SHA
    20d83bc View commit details
    Browse the repository at this point in the history
  17. Copy the full SHA
    66a26d0 View commit details
    Browse the repository at this point in the history
  18. Copy the full SHA
    ccfd102 View commit details
    Browse the repository at this point in the history
  19. Copy the full SHA
    31660c7 View commit details
    Browse the repository at this point in the history
  20. gluon-radv-filterd: Fix bug in BPF router lifetime filter

    The router lifetime field actually is 2 bytes long, but we only checked
    the first one, thus falsely discarding RAs with router lifetime < 256
    seconds.
    jplitza committed Jan 3, 2018
    Copy the full SHA
    5b34931 View commit details
    Browse the repository at this point in the history
  21. Copy the full SHA
    0aca838 View commit details
    Browse the repository at this point in the history
  22. Copy the full SHA
    93e2820 View commit details
    Browse the repository at this point in the history
  23. gluon-radv-filterd: Use _GNU_SOURCE by default

    Both source files require the _GNU_SOURCE preprocessor. But for one file it is
    defined in the source and for the other one in the Makefile. It is better
    to have it in the Makefile to avoid that different source files in the same
    project use different.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    c9eccb9 View commit details
    Browse the repository at this point in the history
  24. gluon-radv-filterd: Fix use-after-free in expire_routers

    The macro foreach is dereferencing router to get the next node in list.
    This even happens when the node was just freed in the last iteration (and
    thus could crash the program).
    
    To avoid this crash, the next pointer has to be saved before the node is
    freed.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    779f17a View commit details
    Browse the repository at this point in the history
  25. Copy the full SHA
    8d4a7bd View commit details
    Browse the repository at this point in the history
  26. gluon-radv-filterd: Remove unused variable

    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    87bf15e View commit details
    Browse the repository at this point in the history
  27. gluon-radv-filterd: Keep global variables static

    These variables are only used in the the same file. They can therefore be
    static and don't have to be exported by the executable.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    f9b3b24 View commit details
    Browse the repository at this point in the history
  28. gluon-radv-filterd: Handle bind errors

    The bind to an interface can fail and the socket then isn't working as
    expected. The daemon must therefore handle this problem.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    9d194c3 View commit details
    Browse the repository at this point in the history
  29. gluon-radv-filterd: Use existing type ether_addr for mac addresses

    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    86c3fa8 View commit details
    Browse the repository at this point in the history
  30. gluon-radv-filterd: Move router code to extra functions

    The router access code is spread throughout the program. It is easier to
    modify it when the common functionality is encapsulated in some helper
    functions.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    7014d9e View commit details
    Browse the repository at this point in the history
  31. gluon-radv-filterd: Handle malloc errors

    The allocation of a new router object can fail. It must therefore be
    handled to avoid segfaults.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    2d6cd71 View commit details
    Browse the repository at this point in the history
  32. gluon-radv-filterd: Fix byte order of nd_ra_router_lifetime

    The ICMPv6 packet is stored in network byte order. It must therefore always
    be converted to host byteorder before it can be used in calculations.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    07a7604 View commit details
    Browse the repository at this point in the history
  33. gluon-radv-filterd: Finish va_start with va_end

    All invocations of va_start must have a corresponding va_end.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    3c8b9fd View commit details
    Browse the repository at this point in the history
  34. gluon-radv-filterd: Check for recvfrom errors

    The recvfrom can fail and return -1. The caller must check for this error
    to avoid that it reads uninitialized data from pkt.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    1633c7c View commit details
    Browse the repository at this point in the history
  35. gluon-radv-filterd: Fix size argument of recvfrom

    The 6th argument to recvfrom is not an unsigned int pointer. This may work
    on systems where socklen_t and unsigned int are both 4 byte but other
    systems may use 8 byte for that (glibc uses size_t as type for socklen_t
    and size_t is 8 byte on amd64 and similar architectures).
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    a629849 View commit details
    Browse the repository at this point in the history
  36. gluon-radv-filterd: Move election prereq checks into function

    The check of prerequisitions is rather long and becomes unreadable. Having
    it in an extra function makes the code slightly more structured and better
    readable.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    c9f6617 View commit details
    Browse the repository at this point in the history
  37. gluon-radv-filterd: Fix integer underflow with low TQs

    The TQ of the best router can be lower than the hysteresis_thresh. The
    check could cause an integer underflow which then causes an election which
    is not necessary.
    
    This can be avoided by reordering the check slightly and only substracting
    values which will not cause underflows.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    8251de6 View commit details
    Browse the repository at this point in the history
  38. gluon-radv-filterd: Use monotonic time source

    The value returned by time is not monotonic. It can jump around because it
    depends on a user configurable clock. This can lead to hangs in the
    processing of routers.
    
    A monotonic clock must be used instead to avoid this problem.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    dc70f24 View commit details
    Browse the repository at this point in the history
  39. gluon-radv-filterd: Don't kill daemon when select is interrupted

    The select can be interrupted when it receives a signal. But the signal
    might be handled and thus it should not result in an kill.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    bc3b3e3 View commit details
    Browse the repository at this point in the history
  40. gluon-radv-filterd: Reset chain when daemon shuts down

    The daemon must make sure that it doesn't filter any incoming router
    advertisement when it was shut down. This can be achieved by flushing all
    current rules and/or adding an ACCEPT all rule at the end. When both
    commands work, the state of the chain will be the same as
    /lib/gluon/ebtables/400-radv-filter created it.
    
    This doesn't handle the problem that the daemon may have been crashed and
    thus the chain is in an undefined state.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    c39a62a View commit details
    Browse the repository at this point in the history
  41. gluon-radv-filterd: Initialize router->originator after alloc

    The memory returned after malloc is not initialized. It must be initialized
    before it is accessed in update_tqs and compared against 00:00:00:00:00:00.
    Otherwise the TQ retrievel could fail because the originator address is
    never updated.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    34daf35 View commit details
    Browse the repository at this point in the history
  42. gluon-radv-filterd: Use generic netlink to request batman-adv data

    The correct way to get the data from batman-adv is not to try to parse the
    freeform debugfs files. Instead, the generic netlink family "batadv" should
    be used to request the tables in binary form.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    b06f126 View commit details
    Browse the repository at this point in the history
  43. gluon-radv-filterd: Fix sock initialization check

    A socket with the value 0 is valid (and it the first opened socket). It is
    therefore a bad idea to check for 0 when wanting to find out whether a
    socket was initialized.
    
    Instead initialize it with -1 and check for < 0 to find out whether the
    socket was initialized or not.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    e3cb030 View commit details
    Browse the repository at this point in the history
  44. gluon-radv-filterd: Trigger config reload checks on interface.* events

    The init scripts adds the br-client as netdev for the daemon. The daemon
    will automatically be restarted when the netdev's ifindex is changed and
    the reload target of the init script is called. But something has to call
    this script first.
    
    This can be done the procd triggers interface which can simply wait for all
    events from type "interface.*". The reload target will always be called but
    the daemon will only be restarted when the br-client ifindex actually
    changed.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    2d3614c View commit details
    Browse the repository at this point in the history
  45. gluon-radv-filterd: Call cleanup when stopping daemon

    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    2394ad0 View commit details
    Browse the repository at this point in the history
  46. Copy the full SHA
    4cc2ba2 View commit details
    Browse the repository at this point in the history
  47. gluon-radv-filterd: Use ebtables locking

    This enables the ebtables internal locking mechanism which will avoid race
    conditions between multiple, concurrent ebtables calls.
    
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    ecsv authored and jplitza committed Jan 3, 2018
    Copy the full SHA
    9b3a2f2 View commit details
    Browse the repository at this point in the history
  48. Copy the full SHA
    f6f1ae9 View commit details
    Browse the repository at this point in the history
  49. Copy the full SHA
    f1a9196 View commit details
    Browse the repository at this point in the history

Commits on Jan 5, 2018

  1. Copy the full SHA
    32c1918 View commit details
    Browse the repository at this point in the history

Commits on Jan 13, 2018

  1. Copy the full SHA
    1c7ce32 View commit details
    Browse the repository at this point in the history