1. 30 Oct, 2018 1 commit
    • Hangbin Liu's avatar
      ipv4/igmp: fix v1/v2 switchback timeout based on rfc3376, 8.12 · 966c37f2
      Hangbin Liu authored
      Similiar with ipv6 mcast commit 89225d1c ("net: ipv6: mld: fix v1/v2
      switchback timeout to rfc3810, 9.12.")
      i) RFC3376 8.12. Older Version Querier Present Timeout says:
         The Older Version Querier Interval is the time-out for transitioning
         a host back to IGMPv3 mode once an older version query is heard.
         When an older version query is received, hosts set their Older
         Version Querier Present Timer to Older Version Querier Interval.
         This value MUST be ((the Robustness Variable) times (the Query
         Interval in the last Query received)) plus (one Query Response
      Currently we only use a hardcode value IGMP_V1/v2_ROUTER_PRESENT_TIMEOUT.
      Fix it by adding two new items mr_qi(Query Interval) and mr_qri(Query Response
      Interval) in struct in_device.
      Now we can calculate the switchback time via (mr_qrv * mr_qi) + mr_qri.
      We need update these values when receive IGMPv3 queries.
      Reported-by: default avatarYing Xu <yinxu@redhat.com>
      Signed-off-by: Hangbin Liu's avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  2. 29 Jul, 2018 1 commit
    • Xin Long's avatar
      route: add support for directed broadcast forwarding · 5cbf777c
      Xin Long authored
      This patch implements the feature described in rfc1812#section-
      and rfc2644. It allows the router to forward directed broadcast when
      sysctl bc_forwarding is enabled.
      Note that this feature could be done by iptables -j TEE, but it would
      cause some problems:
        - target TEE's gateway param has to be set with a specific address,
          and it's not flexible especially when the route wants forward all
          directed broadcasts.
        - this duplicates the directed broadcasts so this may cause side
          effects to applications.
      Besides, to keep consistent with other os router like BSD, it's also
      necessary to implement it in the route rx path.
      Note that route cache needs to be flushed when bc_forwarding is
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  3. 29 May, 2018 1 commit
  4. 25 Jan, 2018 1 commit
  5. 02 Nov, 2017 1 commit
    • Greg Kroah-Hartman's avatar
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman authored
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      How this work was done:
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      Further patches will be generated in subsequent months to fix up cases
      where non-standard license headers were used, and references to license
      had to be inferred by heuristics based on keywords.
      The analysis to determine which SPDX License Identifier to be applied to
      a file was done in a spreadsheet of side by side results from of the
      output of two independent scanners (ScanCode & Windriver) producing SPDX
      tag:value files created by Philippe Ombredanne.  Philippe prepared the
      base worksheet, and did an initial spot review of a few 1000 files.
      The 4.13 kernel was the starting point of the analysis with 60,537 files
      assessed.  Kate Stewart did a file by file comparison of the scanner
      results in the spreadsheet to determine which SPDX license identifier(s)
      to be applied to the file. She confirmed any determination that was not
      immediately clear with lawyers working with the Linux Foundation.
      Criteria used to select files for SPDX license identifier tagging was:
       - Files considered eligible had to be source code files.
       - Make and config files were included as candidates if they contained >5
         lines of source
       - File already had some variant of a license header in it (even if <5
      All documentation files were explicitly excluded.
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
         For non */uapi/* files that summary was:
         SPDX license identifier                            # files
         GPL-2.0                                              11139
         and resulted in the first patch in this series.
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
         SPDX license identifier                            # files
         GPL-2.0 WITH Linux-syscall-note                        930
         and resulted in the second patch in this series.
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
         SPDX license identifier                            # files
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
         and that resulted in the third patch in this series.
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      Reviewed-by: default avatarKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: default avatarPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
  6. 20 Oct, 2017 1 commit
  7. 21 Sep, 2017 1 commit
    • Paolo Abeni's avatar
      net: avoid a full fib lookup when rp_filter is disabled. · 6e617de8
      Paolo Abeni authored
      Since commit 1dced6a8 ("ipv4: Restore accept_local behaviour
      in fib_validate_source()") a full fib lookup is needed even if
      the rp_filter is disabled, if accept_local is false - which is
      the default.
      What we really need in the above scenario is just checking
      that the source IP address is not local, and in most case we
      can do that is a cheaper way looking up the ifaddr hash table.
      This commit adds a helper for such lookup, and uses it to
      validate the src address when rp_filter is disabled and no
      'local' routes are created by the user space in the relevant
      A new ipv4 netns flag is added to account for such routes.
      We need that to preserve the same behavior we had before this
      It also drops the checks to bail early from __fib_validate_source,
      added by the commit 1dced6a8 ("ipv4: Restore accept_local
      behaviour in fib_validate_source()") they do not give any
      measurable performance improvement: if we do the lookup with are
      on a slower path.
      This improves UDP performances for unconnected sockets
      when rp_filter is disabled by 5% and also gives small but
      measurable performance improvement for TCP flood scenarios.
      v1 -> v2:
       - use the ifaddr lookup helper in __ip_dev_find(), as suggested
         by Eric
       - fall-back to full lookup if custom local routes are present
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  8. 01 Jul, 2017 1 commit
  9. 09 Jun, 2017 1 commit
    • Krister Johansen's avatar
      Ipvlan should return an error when an address is already in use. · 3ad7d246
      Krister Johansen authored
      The ipvlan code already knows how to detect when a duplicate address is
      about to be assigned to an ipvlan device.  However, that failure is not
      propogated outward and leads to a silent failure.
      Introduce a validation step at ip address creation time and allow device
      drivers to register to validate the incoming ip addresses.  The ipvlan
      code is the first consumer.  If it detects an address in use, we can
      return an error to the user before beginning to commit the new ifa in
      the networking code.
      This can be especially useful if it is necessary to provision many
      ipvlans in containers.  The provisioning software (or operator) can use
      this to detect situations where an ip address is unexpectedly in use.
      Signed-off-by: default avatarKrister Johansen <kjlx@templeofstupid.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  10. 29 Mar, 2017 1 commit
  11. 09 Oct, 2015 2 commits
  12. 24 Jun, 2015 1 commit
    • Andy Gospodarek's avatar
      net: ipv4 sysctl option to ignore routes when nexthop link is down · 0eeb075f
      Andy Gospodarek authored
      This feature is only enabled with the new per-interface or ipv4 global
      sysctls called 'ignore_routes_with_linkdown'.
      net.ipv4.conf.all.ignore_routes_with_linkdown = 0
      net.ipv4.conf.default.ignore_routes_with_linkdown = 0
      net.ipv4.conf.lo.ignore_routes_with_linkdown = 0
      When the above sysctls are set, will report to userspace that a route is
      dead and will no longer resolve to this nexthop when performing a fib
      lookup.  This will signal to userspace that the route will not be
      selected.  The signalling of a RTNH_F_DEAD is only passed to userspace
      if the sysctl is enabled and link is down.  This was done as without it
      the netlink listeners would have no idea whether or not a nexthop would
      be selected.   The kernel only sets RTNH_F_DEAD internally if the
      interface has IFF_UP cleared.
      With the new sysctl set, the following behavior can be observed
      (interface p8p1 is link-down):
      default via dev p9p1 dev p9p1  proto kernel  scope link  src dev p7p1  proto kernel  scope link  src dev p8p1  proto kernel  scope link  src dead linkdown via dev p8p1  metric 1 dead linkdown via dev p7p1  metric 2 via dev p7p1  src
      local dev lo  src
          cache <local> via dev p9p1  src
      While the route does remain in the table (so it can be modified if
      needed rather than being wiped away as it would be if IFF_UP was
      cleared), the proper next-hop is chosen automatically when the link is
      down.  Now interface p8p1 is linked-up:
      default via dev p9p1 dev p9p1  proto kernel  scope link  src dev p7p1  proto kernel  scope link  src dev p8p1  proto kernel  scope link  src via dev p8p1  metric 1 via dev p7p1  metric 2 dev p2p1  proto kernel  scope link  src via dev p8p1  src
      local dev lo  src
          cache <local> dev p8p1  src
      and the output changes to what one would expect.
      If the sysctl is not set, the following output would be expected when
      p8p1 is down:
      default via dev p9p1 dev p9p1  proto kernel  scope link  src dev p7p1  proto kernel  scope link  src dev p8p1  proto kernel  scope link  src linkdown via dev p8p1  metric 1 linkdown via dev p7p1  metric 2
      Since the dead flag does not appear, there should be no expectation that
      the kernel would skip using this route due to link being down.
      v2: Split kernel changes into 2 patches, this actually makes a
      behavioral change if the sysctl is set.  Also took suggestion from Alex
      to simplify code by only checking sysctl during fib lookup and
      suggestion from Scott to add a per-interface sysctl.
      v3: Code clean-ups to make it more readable and efficient as well as a
      reverse path check fix.
      v4: Drop binary sysctl
      v5: Whitespace fixups from Dave
      v6: Style changes from Dave and checkpatch suggestions
      v7: One more checkpatch fixup
      Signed-off-by: default avatarAndy Gospodarek <gospo@cumulusnetworks.com>
      Signed-off-by: default avatarDinesh Dutt <ddutt@cumulusnetworks.com>
      Acked-by: default avatarScott Feldman <sfeldma@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  13. 14 Nov, 2014 1 commit
  14. 11 Dec, 2013 2 commits
  15. 10 Dec, 2013 1 commit
    • Jiri Pirko's avatar
      neigh: restore old behaviour of default parms values · 1d4c8c29
      Jiri Pirko authored
      Previously inet devices were only constructed when addresses are added.
      Therefore the default neigh parms values they get are the ones at the
      time of these operations.
      Now that we're creating inet devices earlier, this changes the behaviour
      of default neigh parms values in an incompatible way (see bug #8519).
      This patch creates a compromise by setting the default values at the
      same point as before but only for those that have not been explicitly
      set by the user since the inet device's creation.
      Introduced by:
      commit 8030f544
      Author: Herbert Xu <herbert@gondor.apana.org.au>
      Date:   Thu Feb 22 01:53:47 2007 +0900
          [IPV4] devinet: Register inetdev earlier.
      Signed-off-by: default avatarJiri Pirko <jiri@resnulli.us>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  16. 26 Sep, 2013 1 commit
    • Joe Perches's avatar
      [networking]device.h: Remove extern from function prototypes · f629d208
      Joe Perches authored
      There are a mix of function prototypes with and without extern
      in the kernel sources.  Standardize on not using extern for
      function prototypes.
      Function prototypes don't need to be written with extern.
      extern is assumed by the compiler.  Its use is as unnecessary as
      using auto to declare automatic/local variables in a block.
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
  17. 23 Aug, 2013 1 commit
    • Stephen Hemminger's avatar
      ipv4: expose IPV4_DEVCONF · 4a5a8aa6
      Stephen Hemminger authored
      IP sends device configuration (see inet_fill_link_af) as an array
      in the netlink information, but the indices in that array are not
      exposed to userspace through any current santized header file.
      It was available back in 2.6.32 (in /usr/include/linux/sysctl.h)
      but was broken by:
        commit 02291680
        Author: Eric W. Biederman <ebiederm@xmission.com>
        Date:   Sun Feb 14 03:25:51 2010 +0000
          net ipv4: Decouple ipv4 interface parameters from binary sysctl numbers
      Eric was solving the sysctl problem but then the indices were re-exposed
      by a later addition of devconf support for IPV4
        commit 9f0f7272
        Author: Thomas Graf <tgraf@infradead.org>
        Date:   Tue Nov 16 04:32:48 2010 +0000
          ipv4: AF_INET link address family
      Putting them in /usr/include/linux/ip.h seemed the logical match
      for the DEVCONF_ definitions for IPV6 in /usr/include/linux/ip6.h
      Signed-off-by: Stephen Hemminger's avatarStephen Hemminger <stephen@networkplumber.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  18. 09 Aug, 2013 2 commits
  19. 12 Jun, 2013 1 commit
  20. 29 Jan, 2013 1 commit
    • Jiri Pirko's avatar
      ipv4: introduce address lifetime · 5c766d64
      Jiri Pirko authored
      There are some usecase when lifetime of ipv4 addresses might be helpful.
      For example:
      1) initramfs networkmanager uses a DHCP daemon to learn network
      configuration parameters
      2) initramfs networkmanager addresses, routes and DNS configuration
      3) initramfs networkmanager is requested to stop
      4) initramfs networkmanager stops all daemons including dhclient
      5) there are addresses and routes configured but no daemon running. If
      the system doesn't start networkmanager for some reason, addresses and
      routes will be used forever, which violates RFC 2131.
      This patch is essentially a backport of ivp6 address lifetime mechanism
      for ipv4 addresses.
      Current "ip" tool supports this without any patch (since it does not
      distinguish between ipv4 and ipv6 addresses in this perspective.
      Also, this should be back-compatible with all current netlink users.
      Reported-by: default avatarPavel Šimerda <psimerda@redhat.com>
      Signed-off-by: default avatarJiri Pirko <jiri@resnulli.us>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  21. 04 Dec, 2012 1 commit
  22. 04 Aug, 2012 1 commit
    • Eric Dumazet's avatar
      ipv4: Introduce IN_DEV_NET_ROUTE_LOCALNET · 9eb43e76
      Eric Dumazet authored
      performance profiles show a high cost in the IN_DEV_ROUTE_LOCALNET()
      call done in ip_route_input_slow(), because of multiple dereferences,
      even if cache lines are clean and available in cpu caches.
      Since we already have the 'net' pointer, introduce
      IN_DEV_NET_ROUTE_LOCALNET() macro avoiding two dereferences
      Also change the tests to use IN_DEV_NET_ROUTE_LOCALNET() only if saddr
      or/and daddr are loopback addresse.
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  23. 12 Jun, 2012 1 commit
    • Thomas Graf's avatar
      ipv4: Add interface option to enable routing of · d0daebc3
      Thomas Graf authored
      Routing of 127/8 is tradtionally forbidden, we consider
      packets from that address block martian when routing and do
      not process corresponding ARP requests.
      This is a sane default but renders a huge address space
      practically unuseable.
      The RFC states that no address within the 127/8 block should
      ever appear on any network anywhere but it does not forbid
      the use of such addresses outside of the loopback device in
      particular. For example to address a pool of virtual guests
      behind a load balancer.
      This patch adds a new interface option 'route_localnet'
      enabling routing of the 127/8 address block and processing
      of ARP requests on a specific interface.
      Note that for the feature to work, the default local route
      covering 127/8 dev lo needs to be removed.
        $ sysctl -w net.ipv4.conf.eth0.route_localnet=1
        $ ip route del dev lo table local
        $ ip addr add dev eth0
        $ ip route flush cache
      V2: Fix invalid check to auto flush cache (thanks davem)
      Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
      Acked-by: default avatarNeil Horman <nhorman@tuxdriver.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  24. 17 Mar, 2012 1 commit
    • Neil Horman's avatar
      arp: allow arp processing to honor per interface arp_accept sysctl · 124d37e9
      Neil Horman authored
      I found recently that the arp_process function which handles all of our received
      arp frames, is using IPV4_DEVCONF_ALL macro to check the state of the arp_process
      flag.  This seems wrong, as it implies that either none or all of the network
      interfaces accept gratuitous arps.  This patch corrects that, allowing
      per-interface arp_accept configuration to deviate from the all setting.  Note
      this also brings us into line with the way the arp_filter setting is handled
      during arp_process execution.
      Tested this myself on my home network, and confirmed it works as expected.
      Signed-off-by: default avatarNeil Horman <nhorman@tuxdriver.com>
      CC: "David S. Miller" <davem@davemloft.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  25. 18 Feb, 2011 1 commit
  26. 06 Dec, 2010 1 commit
  27. 17 Nov, 2010 1 commit
  28. 12 Nov, 2010 1 commit
  29. 01 Oct, 2010 1 commit
  30. 16 Sep, 2010 1 commit
  31. 16 Feb, 2010 1 commit
  32. 07 Jan, 2010 1 commit
    • Jesper Dangaard Brouer's avatar
      net: RFC3069, private VLAN proxy arp support · 65324144
      Jesper Dangaard Brouer authored
      This is to be used together with switch technologies, like RFC3069,
      that where the individual ports are not allowed to communicate with
      each other, but they are allowed to talk to the upstream router.  As
      described in RFC 3069, it is possible to allow these hosts to
      communicate through the upstream router by proxy_arp'ing.
      This patch basically allow proxy arp replies back to the same
      interface (from which the ARP request/solicitation was received).
      Tunable per device via proc "proxy_arp_pvlan":
      This switch technology is known by different vendor names:
       - In RFC 3069 it is called VLAN Aggregation.
       - Cisco and Allied Telesyn call it Private VLAN.
       - Hewlett-Packard call it Source-Port filtering or port-isolation.
       - Ericsson call it MAC-Forced Forwarding (RFC Draft).
      Signed-off-by: default avatarJesper Dangaard Brouer <hawk@comx.dk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  33. 26 Dec, 2009 1 commit
    • Jamal Hadi Salim's avatar
      net: restore ip source validation · 28f6aeea
      Jamal Hadi Salim authored
      when using policy routing and the skb mark:
      there are cases where a back path validation requires us
      to use a different routing table for src ip validation than
      the one used for mapping ingress dst ip.
      One such a case is transparent proxying where we pretend to be
      the destination system and therefore the local table
      is used for incoming packets but possibly a main table would
      be used on outbound.
      Make the default behavior to allow the above and if users
      need to turn on the symmetry via sysctl src_valid_mark
      Signed-off-by: default avatarJamal Hadi Salim <hadi@cyberus.ca>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  34. 03 Dec, 2009 1 commit
  35. 04 Nov, 2009 1 commit
  36. 28 Jul, 2009 1 commit
  37. 01 Feb, 2009 1 commit