1. 20 10月, 2017 1 次提交
    • D
      net: ipv6: Make inet6addr_validator a blocking notifier · ff7883ea
      David Ahern 提交于
      inet6addr_validator chain was added by commit 3ad7d246 ("Ipvlan
      should return an error when an address is already in use") to allow
      address validation before changes are committed and to be able to
      fail the address change with an error back to the user. The address
      validation is not done for addresses received from router
      advertisements.
      
      Handling RAs in softirq context is the only reason for the notifier
      chain to be atomic versus blocking. Since the only current user, ipvlan,
      of the validator chain ignores softirq context, the notifier can be made
      blocking and simply not invoked for softirq path.
      
      The blocking option is needed by spectrum for example to validate
      resources for an adding an address to an interface.
      Signed-off-by: NDavid Ahern <dsahern@gmail.com>
      Reviewed-by: NIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ff7883ea
  2. 13 10月, 2017 1 次提交
    • M
      ipvlan: always use the current L2 addr of the master · 32c10bbf
      Mahesh Bandewar 提交于
      If the underlying master ever changes its L2 (e.g. bonding device),
      then make sure that the IPvlan slaves always emit packets with the
      current L2 of the master instead of the stale mac addr which was
      copied during the device creation. The problem can be seen with
      following script -
      
        #!/bin/bash
        # Create a vEth pair
        ip link add dev veth0 type veth peer name veth1
        ip link set veth0 up
        ip link set veth1 up
        ip link show veth0
        ip link show veth1
        # Create an IPvlan device on one end of this vEth pair.
        ip link add link veth0 dev ipvl0 type ipvlan mode l2
        ip link show ipvl0
        # Change the mac-address of the vEth master.
        ip link set veth0 address 02:11:22:33:44:55
      
      Fixes: 2ad7bf36 ("ipvlan: Initial check-in of the IPVLAN driver.")
      Signed-off-by: NMahesh Bandewar <maheshb@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      32c10bbf
  3. 05 10月, 2017 1 次提交
  4. 02 8月, 2017 1 次提交
  5. 01 8月, 2017 1 次提交
  6. 18 7月, 2017 1 次提交
  7. 27 6月, 2017 3 次提交
  8. 10 6月, 2017 1 次提交
    • K
      Ipvlan should return an error when an address is already in use. · 3ad7d246
      Krister Johansen 提交于
      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: NKrister Johansen <kjlx@templeofstupid.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3ad7d246
  9. 08 6月, 2017 1 次提交
    • D
      net: Fix inconsistent teardown and release of private netdev state. · cf124db5
      David S. Miller 提交于
      Network devices can allocate reasources and private memory using
      netdev_ops->ndo_init().  However, the release of these resources
      can occur in one of two different places.
      
      Either netdev_ops->ndo_uninit() or netdev->destructor().
      
      The decision of which operation frees the resources depends upon
      whether it is necessary for all netdev refs to be released before it
      is safe to perform the freeing.
      
      netdev_ops->ndo_uninit() presumably can occur right after the
      NETDEV_UNREGISTER notifier completes and the unicast and multicast
      address lists are flushed.
      
      netdev->destructor(), on the other hand, does not run until the
      netdev references all go away.
      
      Further complicating the situation is that netdev->destructor()
      almost universally does also a free_netdev().
      
      This creates a problem for the logic in register_netdevice().
      Because all callers of register_netdevice() manage the freeing
      of the netdev, and invoke free_netdev(dev) if register_netdevice()
      fails.
      
      If netdev_ops->ndo_init() succeeds, but something else fails inside
      of register_netdevice(), it does call ndo_ops->ndo_uninit().  But
      it is not able to invoke netdev->destructor().
      
      This is because netdev->destructor() will do a free_netdev() and
      then the caller of register_netdevice() will do the same.
      
      However, this means that the resources that would normally be released
      by netdev->destructor() will not be.
      
      Over the years drivers have added local hacks to deal with this, by
      invoking their destructor parts by hand when register_netdevice()
      fails.
      
      Many drivers do not try to deal with this, and instead we have leaks.
      
      Let's close this hole by formalizing the distinction between what
      private things need to be freed up by netdev->destructor() and whether
      the driver needs unregister_netdevice() to perform the free_netdev().
      
      netdev->priv_destructor() performs all actions to free up the private
      resources that used to be freed by netdev->destructor(), except for
      free_netdev().
      
      netdev->needs_free_netdev is a boolean that indicates whether
      free_netdev() should be done at the end of unregister_netdevice().
      
      Now, register_netdevice() can sanely release all resources after
      ndo_ops->ndo_init() succeeds, by invoking both ndo_ops->ndo_uninit()
      and netdev->priv_destructor().
      
      And at the end of unregister_netdevice(), we invoke
      netdev->priv_destructor() and optionally call free_netdev().
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      cf124db5
  10. 25 4月, 2017 1 次提交
    • F
      ipvlan: use pernet operations and restrict l3s hooks to master netns · 3133822f
      Florian Westphal 提交于
      commit 4fbae7d8 ("ipvlan: Introduce l3s mode") added
      registration of netfilter hooks via nf_register_hooks().
      
      This API provides the illusion of 'global' netfilter hooks by placing the
      hooks in all current and future network namespaces.
      
      In case of ipvlan the hook appears to be only needed in the namespace
      that contains the ipvlan master device (i.e., usually init_net), so
      placing them in all namespaces is not needed.
      
      This switches ipvlan driver to pernet operations, and then only registers
      hooks in namespaces where a ipvlan master device is set to l3s mode.
      
      Extra care has to be taken when the master device is moved to another
      namespace, as we might have to 'move' the netfilter hooks too.
      
      This is done by storing the namespace the ipvlan port was created in.
      On REGISTER event, do (un)register operations in the old/new namespaces.
      
      This will also allow removal of the nf_register_hooks() in a future patch.
      
      Cc: Mahesh Bandewar <maheshb@google.com>
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3133822f
  11. 12 2月, 2017 1 次提交
  12. 21 1月, 2017 1 次提交
  13. 17 1月, 2017 1 次提交
    • M
      ipvlan: fix dev_id creation corner case. · 019ec003
      Mahesh Bandewar 提交于
      In the last patch da36e13c ("ipvlan: improvise dev_id generation
      logic in IPvlan") I missed some part of Dave's suggestion and because
      of that the dev_id creation could fail in a corner case scenario. This
      would happen when more or less 64k devices have been already created and
      several have been deleted. If the devices that are still sticking around
      are the last n bits from the bitmap. So in this scenario even if lower
      bits are available, the dev_id search is so narrow that it always fails.
      
      Fixes: da36e13c ("ipvlan: improvise dev_id generation logic in IPvlan")
      CC: David Miller <davem@davemloft.org>
      CC: Eric Dumazet <edumazet@google.com>
      Signed-off-by: NMahesh Bandewar <maheshb@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      019ec003
  14. 11 1月, 2017 1 次提交
    • M
      ipvlan: improvise dev_id generation logic in IPvlan · da36e13c
      Mahesh Bandewar 提交于
      The patch 009146d1 ("ipvlan: assign unique dev-id for each slave
      device.") used ida_simple_get() to generate dev_ids assigned to the
      slave devices. However (Eric has pointed out that) there is a shortcoming
      with that approach as it always uses the first available ID. This
      becomes a problem when a slave gets deleted and a new slave gets added.
      The ID gets reassigned causing the new slave to get the same link-local
      address. This side-effect is undesirable.
      
      This patch adds a per-port variable that keeps track of the IDs
      assigned and used as the stat-base for the IDR api. This base will be
      wrapped around when it reaches the MAX (0xFFFE) value possibly on a
      busy system where slaves are added and deleted routinely.
      
      Fixes: 009146d1 ("ipvlan: assign unique dev-id for each slave device.")
      Signed-off-by: NMahesh Bandewar <maheshb@google.com>
      CC: Eric Dumazet <edumazet@google.com>
      CC: David Miller <davem@davemloft.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      da36e13c
  15. 09 1月, 2017 1 次提交
  16. 05 1月, 2017 1 次提交
  17. 29 12月, 2016 1 次提交
  18. 24 12月, 2016 1 次提交
  19. 09 12月, 2016 1 次提交
  20. 08 12月, 2016 1 次提交
  21. 01 12月, 2016 1 次提交
  22. 28 11月, 2016 1 次提交
  23. 16 10月, 2016 1 次提交
    • J
      ipvlan: constify l3mdev_ops structure · ab530f63
      Julia Lawall 提交于
      This l3mdev_ops structure is only stored in the l3mdev_ops field of a
      net_device structure.  This field is declared const, so the l3mdev_ops
      structure can be declared as const also.  Additionally drop the
      __read_mostly annotation.
      
      The semantic patch that adds const is as follows:
      (http://coccinelle.lip6.fr/)
      
      // <smpl>
      @r disable optional_qualifier@
      identifier i;
      position p;
      @@
      static struct l3mdev_ops i@p = { ... };
      
      @ok@
      identifier r.i;
      struct net_device *e;
      position p;
      @@
      e->l3mdev_ops = &i@p;
      
      @bad@
      position p != {r.p,ok.p};
      identifier r.i;
      struct l3mdev_ops e;
      @@
      e@i@p
      
      @depends on !bad disable optional_qualifier@
      identifier r.i;
      @@
      static
      +const
       struct l3mdev_ops i = { ... };
      // </smpl>
      
      The effect on the layout of the .o file is shown by the following output
      of the size command, first before then after the transformation:
      
         text    data     bss     dec     hex filename
         7364     466      52    7882    1eca drivers/net/ipvlan/ipvlan_main.o
         7412     434      52    7898    1eda drivers/net/ipvlan/ipvlan_main.o
      Signed-off-by: NJulia Lawall <Julia.Lawall@lip6.fr>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ab530f63
  24. 19 9月, 2016 1 次提交
    • M
      ipvlan: Introduce l3s mode · 4fbae7d8
      Mahesh Bandewar 提交于
      In a typical IPvlan L3 setup where master is in default-ns and
      each slave is into different (slave) ns. In this setup egress
      packet processing for traffic originating from slave-ns will
      hit all NF_HOOKs in slave-ns as well as default-ns. However same
      is not true for ingress processing. All these NF_HOOKs are
      hit only in the slave-ns skipping them in the default-ns.
      IPvlan in L3 mode is restrictive and if admins want to deploy
      iptables rules in default-ns, this asymmetric data path makes it
      impossible to do so.
      
      This patch makes use of the l3_rcv() (added as part of l3mdev
      enhancements) to perform input route lookup on RX packets without
      changing the skb->dev and then uses nf_hook at NF_INET_LOCAL_IN
      to change the skb->dev just before handing over skb to L4.
      Signed-off-by: NMahesh Bandewar <maheshb@google.com>
      CC: David Ahern <dsa@cumulusnetworks.com>
      Reviewed-by: NDavid Ahern <dsa@cumulusnetworks.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4fbae7d8
  25. 10 6月, 2016 1 次提交
  26. 29 4月, 2016 1 次提交
  27. 18 3月, 2016 1 次提交
  28. 26 2月, 2016 1 次提交
  29. 22 2月, 2016 2 次提交
  30. 05 2月, 2016 1 次提交
    • M
      ipvlan: inherit MTU from master device · 296d4856
      Mahesh Bandewar 提交于
      When we create IPvlan slave; we use ether_setup() and that
      sets up default MTU to 1500 while the master device may have
      lower / different MTU. Any subsequent changes to the masters'
      MTU are reflected into the slaves' MTU setting. However if those
      don't happen (most likely scenario), the slaves' MTU stays at
      1500 which could be bad.
      
      This change adds code to inherit MTU from the master device
      instead of using the default value during the link initialization
      phase.
      Signed-off-by: NMahesh Bandewar <maheshb@google.com>
      CC: Eric Dumazet <eric.dumazet@gmail.com>
      CC: Tim Hockins <thockins@google.com>
      Acked-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      296d4856
  31. 16 12月, 2015 1 次提交
    • T
      net: Rename NETIF_F_ALL_CSUM to NETIF_F_CSUM_MASK · a188222b
      Tom Herbert 提交于
      The name NETIF_F_ALL_CSUM is a misnomer. This does not correspond to the
      set of features for offloading all checksums. This is a mask of the
      checksum offload related features bits. It is incorrect to set both
      NETIF_F_HW_CSUM and NETIF_F_IP_CSUM or NETIF_F_IPV6 at the same time for
      features of a device.
      
      This patch:
        - Changes instances of NETIF_F_ALL_CSUM to NETIF_F_CSUM_MASK (where
          NETIF_F_ALL_CSUM is being used as a mask).
        - Changes bonding, sfc/efx, ipvlan, macvlan, vlan, and team drivers to
          use NEITF_F_HW_CSUM in features list instead of NETIF_F_ALL_CSUM.
      Signed-off-by: NTom Herbert <tom@herbertland.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a188222b
  32. 19 8月, 2015 1 次提交
  33. 16 7月, 2015 4 次提交
  34. 06 5月, 2015 1 次提交