1. 27 1月, 2017 2 次提交
  2. 07 1月, 2017 1 次提交
    • M
      ipv6: do not send RTM_DELADDR for tentative addresses · f784ad3d
      Mahesh Bandewar 提交于
      RTM_NEWADDR notification is sent when IFA_F_TENTATIVE is cleared from
      the address. So if the address is added and deleted before DAD probes
      completes, the RTM_DELADDR will be sent for which there was no
      RTM_NEWADDR causing asymmetry in notification. However if the same
      logic is used while sending RTM_DELADDR notification, this asymmetry
      can be avoided.
      Signed-off-by: NMahesh Bandewar <maheshb@google.com>
      CC: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
      CC: Patrick McHardy <kaber@trash.net>
      CC: Hannes Frederic Sowa <hannes@stressinduktion.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f784ad3d
  3. 04 12月, 2016 1 次提交
  4. 25 11月, 2016 1 次提交
    • P
      ipv6: bump genid when the IFA_F_TENTATIVE flag is clear · 764d3be6
      Paolo Abeni 提交于
      When an ipv6 address has the tentative flag set, it can't be
      used as source for egress traffic, while the associated route,
      if any, can be looked up and even stored into some dst_cache.
      
      In the latter scenario, the source ipv6 address selected and
      stored in the cache is most probably wrong (e.g. with
      link-local scope) and the entity using the dst_cache will
      experience lack of ipv6 connectivity until said cache is
      cleared or invalidated.
      
      Overall this may cause lack of connectivity over most IPv6 tunnels
      (comprising geneve and vxlan), if the first egress packet reaches
      the tunnel before the DaD is completed for the used ipv6
      address.
      
      This patch bumps a new genid after that the IFA_F_TENTATIVE flag
      is cleared, so that dst_cache will be invalidated on
      next lookup and ipv6 connectivity restored.
      
      Fixes: 0c1d70af ("net: use dst_cache for vxlan device")
      Fixes: 468dfffc ("geneve: add dst caching support")
      Acked-by: NHannes Frederic Sowa <hannes@stressinduktion.org>
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      764d3be6
  5. 10 11月, 2016 2 次提交
    • D
      ipv6: sr: add core files for SR HMAC support · bf355b8d
      David Lebrun 提交于
      This patch adds the necessary functions to compute and check the HMAC signature
      of an SR-enabled packet. Two HMAC algorithms are supported: hmac(sha1) and
      hmac(sha256).
      
      In order to avoid dynamic memory allocation for each HMAC computation,
      a per-cpu ring buffer is allocated for this purpose.
      
      A new per-interface sysctl called seg6_require_hmac is added, allowing a
      user-defined policy for processing HMAC-signed SR-enabled packets.
      A value of -1 means that the HMAC field will always be ignored.
      A value of 0 means that if an HMAC field is present, its validity will
      be enforced (the packet is dropped is the signature is incorrect).
      Finally, a value of 1 means that any SR-enabled packet that does not
      contain an HMAC signature or whose signature is incorrect will be dropped.
      Signed-off-by: NDavid Lebrun <david.lebrun@uclouvain.be>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      bf355b8d
    • D
      ipv6: implement dataplane support for rthdr type 4 (Segment Routing Header) · 1ababeba
      David Lebrun 提交于
      Implement minimal support for processing of SR-enabled packets
      as described in
      https://tools.ietf.org/html/draft-ietf-6man-segment-routing-header-02.
      
      This patch implements the following operations:
      - Intermediate segment endpoint: incrementation of active segment and rerouting.
      - Egress for SR-encapsulated packets: decapsulation of outer IPv6 header + SRH
        and routing of inner packet.
      - Cleanup flag support for SR-inlined packets: removal of SRH if we are the
        penultimate segment endpoint.
      
      A per-interface sysctl seg6_enabled is provided, to accept/deny SR-enabled
      packets. Default is deny.
      
      This patch does not provide support for HMAC-signed packets.
      Signed-off-by: NDavid Lebrun <david.lebrun@uclouvain.be>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1ababeba
  6. 21 10月, 2016 1 次提交
  7. 14 10月, 2016 3 次提交
    • J
      IPv6: fix DESYNC_FACTOR · 76506a98
      Jiri Bohac 提交于
      The IPv6 temporary address generation uses a variable called DESYNC_FACTOR
      to prevent hosts updating the addresses at the same time. Quoting RFC 4941:
      
         ... The value DESYNC_FACTOR is a random value (different for each
         client) that ensures that clients don't synchronize with each other and
         generate new addresses at exactly the same time ...
      
      DESYNC_FACTOR is defined as:
      
         DESYNC_FACTOR -- A random value within the range 0 - MAX_DESYNC_FACTOR.
         It is computed once at system start (rather than each time it is used)
         and must never be greater than (TEMP_VALID_LIFETIME - REGEN_ADVANCE).
      
      First, I believe the RFC has a typo in it and meant to say: "and must
      never be greater than (TEMP_PREFERRED_LIFETIME - REGEN_ADVANCE)"
      
      The reason is that at various places in the RFC, DESYNC_FACTOR is used in
      a calculation like (TEMP_PREFERRED_LIFETIME - DESYNC_FACTOR) or
      (TEMP_PREFERRED_LIFETIME - REGEN_ADVANCE - DESYNC_FACTOR). It needs to be
      smaller than (TEMP_PREFERRED_LIFETIME - REGEN_ADVANCE) for the result of
      these calculations to be larger than zero. It's never used in a
      calculation together with TEMP_VALID_LIFETIME.
      
      I already submitted an errata to the rfc-editor:
      https://www.rfc-editor.org/errata_search.php?rfc=4941
      
      The Linux implementation of DESYNC_FACTOR is very wrong:
      max_desync_factor is used in places DESYNC_FACTOR should be used.
      max_desync_factor is initialized to the RFC-recommended value for
      MAX_DESYNC_FACTOR (600) but the whole point is to get a _random_ value.
      
      And nothing ensures that the value used is not greater than
      (TEMP_PREFERRED_LIFETIME - REGEN_ADVANCE), which leads to underflows.  The
      effect can easily be observed when setting the temp_prefered_lft sysctl
      e.g. to 60. The preferred lifetime of the temporary addresses will be
      bogus.
      
      TEMP_PREFERRED_LIFETIME and REGEN_ADVANCE are not constants and can be
      influenced by these three sysctls: regen_max_retry, dad_transmits and
      temp_prefered_lft. Thus, the upper bound for desync_factor needs to be
      re-calculated each time a new address is generated and if desync_factor is
      larger than the new upper bound, a new random value needs to be
      re-generated.
      
      And since we already have max_desync_factor configurable per interface, we
      also need to calculate and store desync_factor per interface.
      Signed-off-by: NJiri Bohac <jbohac@suse.cz>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      76506a98
    • J
      IPv6: Drop the temporary address regen_timer · 9d6280da
      Jiri Bohac 提交于
      The randomized interface identifier (rndid) was periodically updated from
      the regen_timer timer. Simplify the code by updating the rndid only when
      needed by ipv6_try_regen_rndid().
      
      This makes the follow-up DESYNC_FACTOR fix much simpler.  Also it fixes a
      reference counting error in this error path, where an in6_dev_put was
      missing:
      		err = addrconf_sysctl_register(ndev);
      		if (err) {
      			ipv6_mc_destroy_dev(ndev);
      	-               del_timer(&ndev->regen_timer);
      			snmp6_unregister_dev(ndev);
      			goto err_release;
      Signed-off-by: NJiri Bohac <jbohac@suse.cz>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9d6280da
    • N
      ipv6: correctly add local routes when lo goes up · a220445f
      Nicolas Dichtel 提交于
      The goal of the patch is to fix this scenario:
       ip link add dummy1 type dummy
       ip link set dummy1 up
       ip link set lo down ; ip link set lo up
      
      After that sequence, the local route to the link layer address of dummy1 is
      not there anymore.
      
      When the loopback is set down, all local routes are deleted by
      addrconf_ifdown()/rt6_ifdown(). At this time, the rt6_info entry still
      exists, because the corresponding idev has a reference on it. After the rcu
      grace period, dst_rcu_free() is called, and thus ___dst_free(), which will
      set obsolete to DST_OBSOLETE_DEAD.
      
      In this case, init_loopback() is called before dst_rcu_free(), thus
      obsolete is still sets to something <= 0. So, the function doesn't add the
      route again. To avoid that race, let's check the rt6 refcnt instead.
      
      Fixes: 25fb6ca4 ("net IPv6 : Fix broken IPv6 routing table after loopback down-up")
      Fixes: a881ae1f ("ipv6: don't call addrconf_dst_alloc again when enable lo")
      Fixes: 33d99113 ("ipv6: reallocate addrconf router for ipv6 address when lo device up")
      Reported-by: NFrancesco Santoro <francesco.santoro@6wind.com>
      Reported-by: NSamuel Gauthier <samuel.gauthier@6wind.com>
      CC: Balakumaran Kannan <Balakumaran.Kannan@ap.sony.com>
      CC: Maruthi Thotad <Maruthi.Thotad@ap.sony.com>
      CC: Sabrina Dubroca <sd@queasysnail.net>
      CC: Hannes Frederic Sowa <hannes@stressinduktion.org>
      CC: Weilong Chen <chenweilong@huawei.com>
      CC: Gao feng <gaofeng@cn.fujitsu.com>
      Signed-off-by: NNicolas Dichtel <nicolas.dichtel@6wind.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a220445f
  8. 08 10月, 2016 1 次提交
  9. 03 10月, 2016 1 次提交
    • M
      ipv6 addrconf: remove addrconf_sysctl_hop_limit() · cb9e684e
      Maciej Żenczykowski 提交于
      This is an effective no-op in terms of user observable behaviour.
      
      By preventing the overwrite of non-null extra1/extra2 fields
      in addrconf_sysctl() we can enable the use of proc_dointvec_minmax().
      
      This allows us to eliminate the constant min/max (1..255) trampoline
      function that is addrconf_sysctl_hop_limit().
      
      This is nice because it simplifies the code, and allows future
      sysctls with constant min/max limits to also not require trampolines.
      
      We still can't eliminate the trampoline for mtu because it isn't
      actually a constant (it depends on other tunables of the device)
      and thus requires at-write-time logic to enforce range.
      Signed-off-by: NMaciej Żenczykowski <maze@google.com>
      Acked-by: NErik Kline <ek@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      cb9e684e
  10. 30 9月, 2016 2 次提交
  11. 07 9月, 2016 1 次提交
    • W
      ipv6: addrconf: fix dev refcont leak when DAD failed · 751eb6b6
      Wei Yongjun 提交于
      In general, when DAD detected IPv6 duplicate address, ifp->state
      will be set to INET6_IFADDR_STATE_ERRDAD and DAD is stopped by a
      delayed work, the call tree should be like this:
      
      ndisc_recv_ns
        -> addrconf_dad_failure        <- missing ifp put
           -> addrconf_mod_dad_work
             -> schedule addrconf_dad_work()
               -> addrconf_dad_stop()  <- missing ifp hold before call it
      
      addrconf_dad_failure() called with ifp refcont holding but not put.
      addrconf_dad_work() call addrconf_dad_stop() without extra holding
      refcount. This will not cause any issue normally.
      
      But the race between addrconf_dad_failure() and addrconf_dad_work()
      may cause ifp refcount leak and netdevice can not be unregister,
      dmesg show the following messages:
      
      IPv6: eth0: IPv6 duplicate address fe80::XX:XXXX:XXXX:XX detected!
      ...
      unregister_netdevice: waiting for eth0 to become free. Usage count = 1
      
      Cc: stable@vger.kernel.org
      Fixes: c15b1cca ("ipv6: move DAD and addrconf_verify processing
      to workqueue")
      Signed-off-by: NWei Yongjun <weiyongjun1@huawei.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      751eb6b6
  12. 02 9月, 2016 2 次提交
  13. 23 8月, 2016 1 次提交
    • M
      net: ipv6: Remove addresses for failures with strict DAD · 85b51b12
      Mike Manning 提交于
      If DAD fails with accept_dad set to 2, global addresses and host routes
      are incorrectly left in place. Even though disable_ipv6 is set,
      contrary to documentation, the addresses are not dynamically deleted
      from the interface. It is only on a subsequent link down/up that these
      are removed. The fix is not only to set the disable_ipv6 flag, but
      also to call addrconf_ifdown(), which is the action to carry out when
      disabling IPv6. This results in the addresses and routes being deleted
      immediately. The DAD failure for the LL addr is determined as before
      via netlink, or by the absence of the LL addr (which also previously
      would have had to be checked for in case of an intervening link down
      and up). As the call to addrconf_ifdown() requires an rtnl lock, the
      logic to disable IPv6 when DAD fails is moved to addrconf_dad_work().
      
      Previous behavior:
      
      root@vm1:/# sysctl net.ipv6.conf.eth3.accept_dad=2
      net.ipv6.conf.eth3.accept_dad = 2
      root@vm1:/# ip -6 addr add 2000::10/64 dev eth3
      root@vm1:/# ip link set up eth3
      root@vm1:/# ip -6 addr show dev eth3
      5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
          inet6 2000::10/64 scope global
             valid_lft forever preferred_lft forever
          inet6 fe80::5054:ff:fe43:dd5a/64 scope link tentative dadfailed
             valid_lft forever preferred_lft forever
      root@vm1:/# ip -6 route show dev eth3
      2000::/64  proto kernel  metric 256
      fe80::/64  proto kernel  metric 256
      root@vm1:/# ip link set down eth3
      root@vm1:/# ip link set up eth3
      root@vm1:/# ip -6 addr show dev eth3
      root@vm1:/# ip -6 route show dev eth3
      root@vm1:/#
      
      New behavior:
      
      root@vm1:/# sysctl net.ipv6.conf.eth3.accept_dad=2
      net.ipv6.conf.eth3.accept_dad = 2
      root@vm1:/# ip -6 addr add 2000::10/64 dev eth3
      root@vm1:/# ip link set up eth3
      root@vm1:/# ip -6 addr show dev eth3
      root@vm1:/# ip -6 route show dev eth3
      root@vm1:/#
      Signed-off-by: NMike Manning <mmanning@brocade.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      85b51b12
  14. 14 8月, 2016 1 次提交
  15. 31 7月, 2016 1 次提交
  16. 26 7月, 2016 1 次提交
  17. 10 7月, 2016 1 次提交
  18. 18 6月, 2016 1 次提交
  19. 16 6月, 2016 5 次提交
  20. 26 4月, 2016 3 次提交
    • D
      net: ipv6: Delete host routes on an ifdown · 38bd10c4
      David Ahern 提交于
      It was a simple idea -- save IPv6 configured addresses on a link down
      so that IPv6 behaves similar to IPv4. As always the devil is in the
      details and the IPv6 stack as too many behavioral differences from IPv4
      making the simple idea more complicated than it needs to be.
      
      The current implementation for keeping IPv6 addresses can panic or spit
      out a warning in one of many paths:
      
      1. IPv6 route gets an IPv4 route as its 'next' which causes a panic in
         rt6_fill_node while handling a route dump request.
      
      2. rt->dst.obsolete is set to DST_OBSOLETE_DEAD hitting the WARN_ON in
         fib6_del
      
      3. Panic in fib6_purge_rt because rt6i_ref count is not 1.
      
      The root cause of all these is references related to the host route for
      an address that is retained.
      
      So, this patch deletes the host route every time the ifdown loop runs.
      Since the host route is deleted and will be re-generated an up there is
      no longer a need for the l3mdev fix up. On the 'admin up' side move
      addrconf_permanent_addr into the NETDEV_UP event handling so that it
      runs only once versus on UP and CHANGE events.
      
      All of the current panics and warnings appear to be related to
      addresses on the loopback device, but given the catastrophic nature when
      a bug is triggered this patch takes the conservative approach and evicts
      all host routes rather than trying to determine when it can be re-used
      and when it can not. That can be a later optimizaton if desired.
      Signed-off-by: NDavid Ahern <dsa@cumulusnetworks.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      38bd10c4
    • D
      Revert "ipv6: Revert optional address flusing on ifdown." · 6a923934
      David S. Miller 提交于
      This reverts commit 841645b5.
      
      Ok, this puts the feature back.  I've decided to apply David A.'s
      bug fix and run with that rather than make everyone wait another
      whole release for this feature.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6a923934
    • D
      ipv6: Revert optional address flusing on ifdown. · 841645b5
      David S. Miller 提交于
      This reverts the following three commits:
      
      70af921d
      799977d9
      f1705ec1
      
      The feature was ill conceived, has terrible semantics, and has added
      nothing but regressions to the already fragile ipv6 stack.
      
      Fixes: f1705ec1 ("net: ipv6: Make address flushing on ifdown optional")
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      841645b5
  21. 20 4月, 2016 2 次提交
  22. 14 4月, 2016 2 次提交
  23. 12 4月, 2016 1 次提交
    • D
      net: vrf: Fix dev refcnt leak due to IPv6 prefix route · 4f7f34ea
      David Ahern 提交于
      ifupdown2 found a kernel bug with IPv6 routes and movement from the main
      table to the VRF table. Sequence of events:
      
      Create the interface and add addresses:
          ip link add dev eth4.105 link eth4 type vlan id 105
          ip addr add dev eth4.105 8.105.105.10/24
          ip -6 addr add dev eth4.105 2008:105:105::10/64
      
      At this point IPv6 has inserted a prefix route in the main table even
      though the interface is 'down'. From there the VRF device is created:
          ip link add dev vrf105 type vrf table 105
          ip addr add dev vrf105 9.9.105.10/32
          ip -6 addr add dev vrf105 2000:9:105::10/128
          ip link set vrf105 up
      
      Then the interface is enslaved, while still in the 'down' state:
          ip link set dev eth4.105 master vrf105
      
      Since the device is down the VRF driver cycling the device does not
      send the NETDEV_UP and NETDEV_DOWN but rather the NETDEV_CHANGE event
      which does not flush the routes inserted prior.
      
      When the link is brought up
          ip link set dev eth4.105 up
      
      the prefix route is added in the VRF table, but does not remove
      the route from the main table.
      
      Fix by handling the NETDEV_CHANGEUPPER event similar what was implemented
      for IPv4 in 7f49e7a3 ("net: Flush local routes when device changes vrf
      association")
      
      Fixes: 35402e31 ("net: Add IPv6 support to VRF device")
      Signed-off-by: NDavid Ahern <dsa@cumulusnetworks.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4f7f34ea
  24. 14 3月, 2016 1 次提交
  25. 04 3月, 2016 1 次提交
    • D
      net: ipv6: Fix refcnt on host routes · 799977d9
      David Ahern 提交于
      Andrew and Ying Huang's test robot both reported usage count problems that
      trace back to the 'keep address on ifdown' patch.
      
      >From Andrew:
      We execute CRIU test on linux-next. On the current linux-next kernel
      they hangs on creating a network namespace.
      
      The kernel log contains many massages like this:
      [ 1036.122108] unregister_netdevice: waiting for lo to become free.
      Usage count = 2
      [ 1046.165156] unregister_netdevice: waiting for lo to become free.
      Usage count = 2
      [ 1056.210287] unregister_netdevice: waiting for lo to become free.
      Usage count = 2
      
      I tried to revert this patch and the bug disappeared.
      
      Here is a set of commands to reproduce this bug:
      
      [root@linux-next-test linux-next]# uname -a
      Linux linux-next-test 4.5.0-rc6-next-20160301+ #3 SMP Wed Mar 2
      17:32:18 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
      
      [root@linux-next-test ~]# unshare -n
      [root@linux-next-test ~]# ip link set up dev lo
      [root@linux-next-test ~]# ip a
      1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
      group default qlen 1
          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
          inet 127.0.0.1/8 scope host lo
             valid_lft forever preferred_lft forever
          inet6 ::1/128 scope host
             valid_lft forever preferred_lft forever
      [root@linux-next-test ~]# logout
      [root@linux-next-test ~]# unshare -n
      
       -----
      
      The problem is a change made to RTM_DELADDR case in __ipv6_ifa_notify that
      was added in an early version of the offending patch and is no longer
      needed.
      
      Fixes: f1705ec1 ("net: ipv6: Make address flushing on ifdown optional")
      Cc: Andrey Wagin <avagin@gmail.com>
      Cc: Ying Huang <ying.huang@linux.intel.com>
      Signed-off-by: NDavid Ahern <dsa@cumulusnetworks.com>
      Tested-by: NJeremiah Mahler <jmmahler@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      799977d9
  26. 02 3月, 2016 1 次提交