1. 03 Nov, 2015 31 commits
    • Jarod Wilson's avatar
      net/core: fix for_each_netdev_feature · 5ba3f7d6
      Jarod Wilson authored
      As pointed out by Nikolay and further explained by Geert, the initial
      for_each_netdev_feature macro was broken, as feature would get set outside
      of the block of code it was intended to run in, thus only ever working for
      the first feature bit in the mask. While less pretty this way, this is
      tested and confirmed functional with multiple feature bits set in
      NETIF_F_UPPER_DISABLES.
      
      [root@dell-per730-01 ~]# ethtool -K bond0 lro off
      ...
      [  242.761394] bond0: Disabling feature 0x0000000000008000 on lower dev p5p2.
      [  243.552178] bnx2x 0000:06:00.1 p5p2: using MSI-X  IRQs: sp 74  fp[0] 76 ... fp[7] 83
      [  244.353978] bond0: Disabling feature 0x0000000000008000 on lower dev p5p1.
      [  245.147420] bnx2x 0000:06:00.0 p5p1: using MSI-X  IRQs: sp 62  fp[0] 64 ... fp[7] 71
      
      [root@dell-per730-01 ~]# ethtool -K bond0 gro off
      ...
      [  251.925645] bond0: Disabling feature 0x0000000000004000 on lower dev p5p2.
      [  252.713693] bnx2x 0000:06:00.1 p5p2: using MSI-X  IRQs: sp 74  fp[0] 76 ... fp[7] 83
      [  253.499085] bond0: Disabling feature 0x0000000000004000 on lower dev p5p1.
      [  254.290922] bnx2x 0000:06:00.0 p5p1: using MSI-X  IRQs: sp 62  fp[0] 64 ... fp[7] 71
      
      Fixes: fd867d51 ("net/core: generic support for disabling netdev features down stack")
      CC: "David S. Miller" <davem@davemloft.net>
      CC: Eric Dumazet <edumazet@google.com>
      CC: Jay Vosburgh <j.vosburgh@gmail.com>
      CC: Veaceslav Falico <vfalico@gmail.com>
      CC: Andy Gospodarek <gospo@cumulusnetworks.com>
      CC: Jiri Pirko <jiri@resnulli.us>
      CC: Nikolay Aleksandrov <razor@blackwall.org>
      CC: Michal Kubecek <mkubecek@suse.cz>
      CC: Alexander Duyck <alexander.duyck@gmail.com>
      CC: Geert Uytterhoeven <geert@linux-m68k.org>
      CC: netdev@vger.kernel.org
      Signed-off-by: default avatarJarod Wilson <jarod@redhat.com>
      Acked-by: default avatarNikolay Aleksandrov <nikolay@cumulusnetworks.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5ba3f7d6
    • Padmanabh Ratnakar's avatar
      vlan: Invoke driver vlan hooks only if device is present · 74f2d19c
      Padmanabh Ratnakar authored
      NIC drivers mark device as detached during error recovery.
      It expects no manangement hooks to be invoked in this state.
      Invoke driver vlan hooks only if device is present.
      Signed-off-by: default avatarPadmanabh Ratnakar <padmanabh.ratnakar@avagotech.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      74f2d19c
    • Arnd Bergmann's avatar
      arcnet/com20020: add LEDS_CLASS dependency · 754107e3
      Arnd Bergmann authored
      The newly added led trigger support in the com20020-pci driver causes
      build errors when CONFIG_LEDS_CLASS is disabled:
      
      drivers/built-in.o: In function `com20020pci_probe':
      (.text+0x185dc4): undefined reference to `devm_led_classdev_register'
      (.text+0x185dd8): undefined reference to `devm_led_classdev_register'
      
      This adds a Kconfig dependency to prevent the invalid configurations.
      Other drivers appear to be split 50:50 between 'select' and 'depends on'
      for this symbol, I picked 'depends on' as I could not find a common
      policy and it generally causes fewer problems.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Fixes: 8890624a ("arcnet: com20020-pci: add led trigger support")
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      754107e3
    • Daniel Borkmann's avatar
      bpf, verifier: annotate verbose printer with __printf · 1d056d9c
      Daniel Borkmann authored
      The verbose() printer dumps the verifier state to user space, so let gcc
      take care to check calls to verbose() for (future) errors. make with W=1
      correctly suggests: function might be possible candidate for 'gnu_printf'
      format attribute [-Wsuggest-attribute=format].
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1d056d9c
    • David S. Miller's avatar
      Merge branch 'dp83640-fixes' · 85013ab5
      David S. Miller authored
      Stefan Sørensen says:
      
      ====================
      dp83640 driver fixes
      
      This series fixes a number of minor bugs in the dp83640 driver.
      ====================
      Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      85013ab5
    • Stefan Sørensen's avatar
      dp83640: Only wait for timestamps for packets with timestamping enabled. · a1f8723f
      Stefan Sørensen authored
      In the packet timestamping function, check that the ptp version and
      protocol of the packet matches what we have configured the hardware to
      actually generate timestamps for, before looking/waiting for a timestamp.
      Signed-off-by: default avatarStefan Sørensen <stefan.sorensen@spectralink.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a1f8723f
    • Stefan Sørensen's avatar
      ptp: Change ptp_class to a proper bitmask · 5f94c943
      Stefan Sørensen authored
      Change the definition of PTP_CLASS_L2 to not have any bits overlapping with
      the other defined protocol values, allowing the PTP_CLASS_* definitions to
      be for simple filtering on packet type.
      Signed-off-by: default avatarStefan Sørensen <stefan.sorensen@spectralink.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5f94c943
    • Stefan Sørensen's avatar
      dp83640: Prune rx timestamp list before reading from it · ccf6ee9a
      Stefan Sørensen authored
      The list of rx timestamps are currently only pruned of old entries when a
      new entry is inserted. If no new entries are added, old timestamps may
      survive beyond their lifetime, possible causing them to be attached to
      packets with the same sequence number after a rollover.
      Signed-off-by: default avatarStefan Sørensen <stefan.sorensen@spectralink.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ccf6ee9a
    • Stefan Sørensen's avatar
      dp83640: Delay scheduled work. · 4b063258
      Stefan Sørensen authored
      Currently rx_timestamp_work reschedules itself as a regular workqueue item,
      effectively causing it run constantly as long as there are packets left in
      the queue. Fix by using delayed workqueue items, limiting it to run only
      every two jiffies.
      Signed-off-by: default avatarStefan Sørensen <stefan.sorensen@spectralink.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4b063258
    • Stefan Sørensen's avatar
      dp83640: Include hash in timestamp/packet matching · 539e44d2
      Stefan Sørensen authored
      Only using the message type and sequence id for matching timestamps
      with packets is error prone, as multiple clients may very well be
      sending packets with the same messagetype and timestamp at the same
      time. Fix by extending the check to include the hash of bytes 20-29
      (source id in PTPv2) that is provided with the timestamps.
      Signed-off-by: default avatarStefan Sørensen <stefan.sorensen@spectralink.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      539e44d2
    • David S. Miller's avatar
      Merge branch 'mlx5-fixes' · 0561e8e8
      David S. Miller authored
      Or Gerlitz says:
      
      ====================
      Mellanox mlx5e driver update, Nov 3 2015
      
      This series contains bunch of small fixes to the mlx5e driver from Achiad.
      
      Changes from V0:
        - removed the driver patch that dealt with IRQ affinity changes during
          NAPI poll, as this is a generic problem which needs generic solution.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0561e8e8
    • Achiad Shochat's avatar
      net/mlx5e: Fix LSO vlan insertion · 3ea4891d
      Achiad Shochat authored
      Consider vlan insertion impact on headers copy size also for LSO
      packets.
      Signed-off-by: default avatarAchiad Shochat <achiad@mellanox.com>
      Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3ea4891d
    • Achiad Shochat's avatar
      net/mlx5e: Re-eanble client vlan TX acceleration · e4cf27bd
      Achiad Shochat authored
      This reverts commit cd58c714 "net/mlx5e: Disable client vlan TX acceleration".
      
      Bring back client vlan insertion offload, the original
      performance issue was found and fixed in the next patch.
      Signed-off-by: default avatarAchiad Shochat <achiad@mellanox.com>
      Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e4cf27bd
    • Achiad Shochat's avatar
      net/mlx5e: Return error in case mlx5e_set_features() fails · fe9f4fe5
      Achiad Shochat authored
      In case mlx5e_set_features() fails, return the failure status rather
      than 0.
      Signed-off-by: default avatarAchiad Shochat <achiad@mellanox.com>
      Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      fe9f4fe5
    • Achiad Shochat's avatar
      net/mlx5e: Don't allow more than max supported channels · 3435ab59
      Achiad Shochat authored
      Consider MLX5E_MAX_NUM_CHANNELS @ethtool set/get_channels
      Signed-off-by: default avatarAchiad Shochat <achiad@mellanox.com>
      Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3435ab59
    • Achiad Shochat's avatar
      net/mlx5_core: Use the the real irqn in eq->irqn · 61d0e73e
      Achiad Shochat authored
      Instead of storing the msix array index in eq->irqn (vecidx),
      store the real irq number.
      Signed-off-by: default avatarAchiad Shochat <achiad@mellanox.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      61d0e73e
    • Achiad Shochat's avatar
      net/mlx5e: Wait for RX buffers initialization in a more proper manner · 01c196a2
      Achiad Shochat authored
      Use jiffies rather than wait loop with msleep().
      
      The wait loop didn't take into consideration time when the
      process was not executing.
      Signed-off-by: default avatarAchiad Shochat <achiad@mellanox.com>
      Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      01c196a2
    • Achiad Shochat's avatar
      net/mlx5e: Avoid NULL pointer access in case of configuration failure · a1985740
      Achiad Shochat authored
      In case a configuration operation that involves closing and re-opening
      resources (e.g RX/TX queue size change) fails at the re-opening stage
      these resources will remain closed.
      So when executing (following) configuration operations (e.g ifconfig
      down) we cannot assume that these resources are available.
      Signed-off-by: default avatarAchiad Shochat <achiad@mellanox.com>
      Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a1985740
    • Jarod Wilson's avatar
      net/core: generic support for disabling netdev features down stack · fd867d51
      Jarod Wilson authored
      There are some netdev features, which when disabled on an upper device,
      such as a bonding master or a bridge, must be disabled and cannot be
      re-enabled on underlying devices.
      
      This is a rework of an earlier more heavy-handed appraoch, which simply
      disables and prevents re-enabling of netdev features listed in a new
      define in include/net/netdev_features.h, NETIF_F_UPPER_DISABLES. Any upper
      device that disables a flag in that feature mask, the disabling will
      propagate down the stack, and any lower device that has any upper device
      with one of those flags disabled should not be able to enable said flag.
      
      Initially, only LRO is included for proof of concept, and because this
      code effectively does the same thing as dev_disable_lro(), though it will
      also activate from the ethtool path, which was one of the goals here.
      
      [root@dell-per730-01 ~]# ethtool -k bond0 |grep large
      large-receive-offload: on
      [root@dell-per730-01 ~]# ethtool -k p5p1 |grep large
      large-receive-offload: on
      [root@dell-per730-01 ~]# ethtool -K bond0 lro off
      [root@dell-per730-01 ~]# ethtool -k bond0 |grep large
      large-receive-offload: off
      [root@dell-per730-01 ~]# ethtool -k p5p1 |grep large
      large-receive-offload: off
      
      dmesg dump:
      
      [ 1033.277986] bond0: Disabling feature 0x0000000000008000 on lower dev p5p2.
      [ 1034.067949] bnx2x 0000:06:00.1 p5p2: using MSI-X  IRQs: sp 74  fp[0] 76 ... fp[7] 83
      [ 1034.753612] bond0: Disabling feature 0x0000000000008000 on lower dev p5p1.
      [ 1035.591019] bnx2x 0000:06:00.0 p5p1: using MSI-X  IRQs: sp 62  fp[0] 64 ... fp[7] 71
      
      This has been successfully tested with bnx2x, qlcnic and netxen network
      cards as slaves in a bond interface. Turning LRO on or off on the master
      also turns it on or off on each of the slaves, new slaves are added with
      LRO in the same state as the master, and LRO can't be toggled on the
      slaves.
      
      Also, this should largely remove the need for dev_disable_lro(), and most,
      if not all, of its call sites can be replaced by simply making sure
      NETIF_F_LRO isn't included in the relevant device's feature flags.
      
      Note that this patch is driven by bug reports from users saying it was
      confusing that bonds and slaves had different settings for the same
      features, and while it won't be 100% in sync if a lower device doesn't
      support a feature like LRO, I think this is a good step in the right
      direction.
      
      CC: "David S. Miller" <davem@davemloft.net>
      CC: Eric Dumazet <edumazet@google.com>
      CC: Jay Vosburgh <j.vosburgh@gmail.com>
      CC: Veaceslav Falico <vfalico@gmail.com>
      CC: Andy Gospodarek <gospo@cumulusnetworks.com>
      CC: Jiri Pirko <jiri@resnulli.us>
      CC: Nikolay Aleksandrov <razor@blackwall.org>
      CC: Michal Kubecek <mkubecek@suse.cz>
      CC: Alexander Duyck <alexander.duyck@gmail.com>
      CC: netdev@vger.kernel.org
      Signed-off-by: default avatarJarod Wilson <jarod@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      fd867d51
    • Sergei Shtylyov's avatar
      sh_eth: fix typo in RX descriptor bit name · c238041f
      Sergei Shtylyov authored
      The correct name of the RX descriptor 0 bit 30 is RDLE (receive descriptor
      list end),  not  RDEL.
      Signed-off-by: default avatarSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c238041f
    • David S. Miller's avatar
      Merge branch 'bonding-actor-updates' · a176ded3
      David S. Miller authored
      Mahesh Bandewar says:
      
      ====================
      re-org actor admin/oper key updates
      
      I was observing machines entering into weird LACP state when the
      partner is in passive mode. This issue is not because of the partners
      in passive state but probably because of some operational key update
      which is pushing the state-machine is that weird state. This was
      happening randomly on about 1% of the machine (when the sample size
      is a large set of machines with a variety of NICs/ports bonded).
      
      In this patch-series I'm attempting to unify the logic of actor-key
      / operational-key changes to one place to avoid possible errors in
      update. Also this eliminates the need for the event-handler to decide
      if the key needs update.
      
      After this patch-set none of the machines (from same sample set) were
      exhibiting LACP-weirdness that was observed earlier.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a176ded3
    • Mahesh Bandewar's avatar
      bonding: simplify / unify event handling code for 3ad mode. · 52bc6716
      Mahesh Bandewar authored
      Old logic of updating state-machine is not required since
      ad_update_actor_keys() does it implicitly. The only loss is
      the notification differentiation between speed vs. duplex
      change. Now only one unified notification is printed.
      Signed-off-by: default avatarMahesh Bandewar <maheshb@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      52bc6716
    • Mahesh Bandewar's avatar
      bonding: unify all places where actor-oper key needs to be updated. · 7bb11dc9
      Mahesh Bandewar authored
      actor_admin, and actor_oper key is changed at multiple locations in
      the code. This patch brings all those updates into one location in
      an attempt to avoid possible inconsistent updates causing LACP state
      machine to go in weird state.
      
      The unified place is ad_update_actor_key() with simple state-machine
      logic -
        (a) If port is "duplex" then only it can participate in LACP
        (b) Speed change reinitializes the LACP state-machine.
      Signed-off-by: default avatarMahesh Bandewar <maheshb@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7bb11dc9
    • Mahesh Bandewar's avatar
      bonding: Simplify __get_duplex function. · b25c2e7d
      Mahesh Bandewar authored
      Eliminate 'else' clause by simply initializing variable
      Signed-off-by: default avatarMahesh Bandewar <maheshb@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b25c2e7d
    • David S. Miller's avatar
      Merge branch 'bpf-persistent' · 12d43096
      David S. Miller authored
      Daniel Borkmann says:
      
      ====================
      BPF updates
      
      This set adds support for persistent maps/progs. Please see
      individual patches for further details. A man-page update
      to bpf(2) will be sent later on, also a iproute2 patch for
      support in tc.
      
      v1 -> v2:
        - Reworked most of patch 4 and 5
        - Rebased to latest net-next
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      12d43096
    • Daniel Borkmann's avatar
      bpf: add sample usages for persistent maps/progs · 42984d7c
      Daniel Borkmann authored
      This patch adds a couple of stand-alone examples on how BPF_OBJ_PIN
      and BPF_OBJ_GET commands can be used.
      
      Example with maps:
      
        # ./fds_example -F /sys/fs/bpf/m -P -m -k 1 -v 42
        bpf: map fd:3 (Success)
        bpf: pin ret:(0,Success)
        bpf: fd:3 u->(1:42) ret:(0,Success)
        # ./fds_example -F /sys/fs/bpf/m -G -m -k 1
        bpf: get fd:3 (Success)
        bpf: fd:3 l->(1):42 ret:(0,Success)
        # ./fds_example -F /sys/fs/bpf/m -G -m -k 1 -v 24
        bpf: get fd:3 (Success)
        bpf: fd:3 u->(1:24) ret:(0,Success)
        # ./fds_example -F /sys/fs/bpf/m -G -m -k 1
        bpf: get fd:3 (Success)
        bpf: fd:3 l->(1):24 ret:(0,Success)
      
        # ./fds_example -F /sys/fs/bpf/m2 -P -m
        bpf: map fd:3 (Success)
        bpf: pin ret:(0,Success)
        # ./fds_example -F /sys/fs/bpf/m2 -G -m -k 1
        bpf: get fd:3 (Success)
        bpf: fd:3 l->(1):0 ret:(0,Success)
        # ./fds_example -F /sys/fs/bpf/m2 -G -m
        bpf: get fd:3 (Success)
      
      Example with progs:
      
        # ./fds_example -F /sys/fs/bpf/p -P -p
        bpf: prog fd:3 (Success)
        bpf: pin ret:(0,Success)
        bpf sock:4 <- fd:3 attached ret:(0,Success)
        # ./fds_example -F /sys/fs/bpf/p -G -p
        bpf: get fd:3 (Success)
        bpf: sock:4 <- fd:3 attached ret:(0,Success)
      
        # ./fds_example -F /sys/fs/bpf/p2 -P -p -o ./sockex1_kern.o
        bpf: prog fd:5 (Success)
        bpf: pin ret:(0,Success)
        bpf: sock:3 <- fd:5 attached ret:(0,Success)
        # ./fds_example -F /sys/fs/bpf/p2 -G -p
        bpf: get fd:3 (Success)
        bpf: sock:4 <- fd:3 attached ret:(0,Success)
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      42984d7c
    • Daniel Borkmann's avatar
      bpf: add support for persistent maps/progs · b2197755
      Daniel Borkmann authored
      This work adds support for "persistent" eBPF maps/programs. The term
      "persistent" is to be understood that maps/programs have a facility
      that lets them survive process termination. This is desired by various
      eBPF subsystem users.
      
      Just to name one example: tc classifier/action. Whenever tc parses
      the ELF object, extracts and loads maps/progs into the kernel, these
      file descriptors will be out of reach after the tc instance exits.
      So a subsequent tc invocation won't be able to access/relocate on this
      resource, and therefore maps cannot easily be shared, f.e. between the
      ingress and egress networking data path.
      
      The current workaround is that Unix domain sockets (UDS) need to be
      instrumented in order to pass the created eBPF map/program file
      descriptors to a third party management daemon through UDS' socket
      passing facility. This makes it a bit complicated to deploy shared
      eBPF maps or programs (programs f.e. for tail calls) among various
      processes.
      
      We've been brainstorming on how we could tackle this issue and various
      approches have been tried out so far, which can be read up further in
      the below reference.
      
      The architecture we eventually ended up with is a minimal file system
      that can hold map/prog objects. The file system is a per mount namespace
      singleton, and the default mount point is /sys/fs/bpf/. Any subsequent
      mounts within a given namespace will point to the same instance. The
      file system allows for creating a user-defined directory structure.
      The objects for maps/progs are created/fetched through bpf(2) with
      two new commands (BPF_OBJ_PIN/BPF_OBJ_GET). I.e. a bpf file descriptor
      along with a pathname is being passed to bpf(2) that in turn creates
      (we call it eBPF object pinning) the file system nodes. Only the pathname
      is being passed to bpf(2) for getting a new BPF file descriptor to an
      existing node. The user can use that to access maps and progs later on,
      through bpf(2). Removal of file system nodes is being managed through
      normal VFS functions such as unlink(2), etc. The file system code is
      kept to a very minimum and can be further extended later on.
      
      The next step I'm working on is to add dump eBPF map/prog commands
      to bpf(2), so that a specification from a given file descriptor can
      be retrieved. This can be used by things like CRIU but also applications
      can inspect the meta data after calling BPF_OBJ_GET.
      
      Big thanks also to Alexei and Hannes who significantly contributed
      in the design discussion that eventually let us end up with this
      architecture here.
      
      Reference: https://lkml.org/lkml/2015/10/15/925Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarHannes Frederic Sowa <hannes@stressinduktion.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b2197755
    • Daniel Borkmann's avatar
      bpf: consolidate bpf_prog_put{, _rcu} dismantle paths · e9d8afa9
      Daniel Borkmann authored
      We currently have duplicated cleanup code in bpf_prog_put() and
      bpf_prog_put_rcu() cleanup paths. Back then we decided that it was
      not worth it to make it a common helper called by both, but with
      the recent addition of resource charging, we could have avoided
      the fix in commit ac00737f ("bpf: Need to call bpf_prog_uncharge_memlock
      from bpf_prog_put") if we would have had only a single, common path.
      We can simplify it further by assigning aux->prog only once during
      allocation time.
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e9d8afa9
    • Daniel Borkmann's avatar
      bpf: align and clean bpf_{map,prog}_get helpers · c2101297
      Daniel Borkmann authored
      Add a bpf_map_get() function that we're going to use later on and
      align/clean the remaining helpers a bit so that we have them a bit
      more consistent:
      
        - __bpf_map_get() and __bpf_prog_get() that both work on the fd
          struct, check whether the descriptor is eBPF and return the
          pointer to the map/prog stored in the private data.
      
          Also, we can return f.file->private_data directly, the function
          signature is enough of a documentation already.
      
        - bpf_map_get() and bpf_prog_get() that both work on u32 user fd,
          call their respective __bpf_map_get()/__bpf_prog_get() variants,
          and take a reference.
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c2101297
    • Daniel Borkmann's avatar
      bpf: abstract anon_inode_getfd invocations · aa79781b
      Daniel Borkmann authored
      Since we're going to use anon_inode_getfd() invocations in more than just
      the current places, make a helper function for both, so that we only need
      to pass a map/prog pointer to the helper itself in order to get a fd. The
      new helpers are called bpf_map_new_fd() and bpf_prog_new_fd().
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      aa79781b
    • Eric Dumazet's avatar
      net: fix percpu memory leaks · 1d6119ba
      Eric Dumazet authored
      This patch fixes following problems :
      
      1) percpu_counter_init() can return an error, therefore
        init_frag_mem_limit() must propagate this error so that
        inet_frags_init_net() can do the same up to its callers.
      
      2) If ip[46]_frags_ns_ctl_register() fail, we must unwind
         properly and free the percpu_counter.
      
      Without this fix, we leave freed object in percpu_counters
      global list (if CONFIG_HOTPLUG_CPU) leading to crashes.
      
      This bug was detected by KASAN and syzkaller tool
      (http://github.com/google/syzkaller)
      
      Fixes: 6d7b857d ("net: use lib/percpu_counter API for fragmentation mem accounting")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
      Cc: Jesper Dangaard Brouer <brouer@redhat.com>
      Acked-by: default avatarHannes Frederic Sowa <hannes@stressinduktion.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1d6119ba
  2. 02 Nov, 2015 9 commits