1. 18 11月, 2016 1 次提交
    • A
      netns: make struct pernet_operations::id unsigned int · c7d03a00
      Alexey Dobriyan 提交于
      Make struct pernet_operations::id unsigned.
      
      There are 2 reasons to do so:
      
      1)
      This field is really an index into an zero based array and
      thus is unsigned entity. Using negative value is out-of-bound
      access by definition.
      
      2)
      On x86_64 unsigned 32-bit data which are mixed with pointers
      via array indexing or offsets added or subtracted to pointers
      are preffered to signed 32-bit data.
      
      "int" being used as an array index needs to be sign-extended
      to 64-bit before being used.
      
      	void f(long *p, int i)
      	{
      		g(p[i]);
      	}
      
        roughly translates to
      
      	movsx	rsi, esi
      	mov	rdi, [rsi+...]
      	call 	g
      
      MOVSX is 3 byte instruction which isn't necessary if the variable is
      unsigned because x86_64 is zero extending by default.
      
      Now, there is net_generic() function which, you guessed it right, uses
      "int" as an array index:
      
      	static inline void *net_generic(const struct net *net, int id)
      	{
      		...
      		ptr = ng->ptr[id - 1];
      		...
      	}
      
      And this function is used a lot, so those sign extensions add up.
      
      Patch snipes ~1730 bytes on allyesconfig kernel (without all junk
      messing with code generation):
      
      	add/remove: 0/0 grow/shrink: 70/598 up/down: 396/-2126 (-1730)
      
      Unfortunately some functions actually grow bigger.
      This is a semmingly random artefact of code generation with register
      allocator being used differently. gcc decides that some variable
      needs to live in new r8+ registers and every access now requires REX
      prefix. Or it is shifted into r12, so [r12+0] addressing mode has to be
      used which is longer than [r8]
      
      However, overall balance is in negative direction:
      
      	add/remove: 0/0 grow/shrink: 70/598 up/down: 396/-2126 (-1730)
      	function                                     old     new   delta
      	nfsd4_lock                                  3886    3959     +73
      	tipc_link_build_proto_msg                   1096    1140     +44
      	mac80211_hwsim_new_radio                    2776    2808     +32
      	tipc_mon_rcv                                1032    1058     +26
      	svcauth_gss_legacy_init                     1413    1429     +16
      	tipc_bcbase_select_primary                   379     392     +13
      	nfsd4_exchange_id                           1247    1260     +13
      	nfsd4_setclientid_confirm                    782     793     +11
      		...
      	put_client_renew_locked                      494     480     -14
      	ip_set_sockfn_get                            730     716     -14
      	geneve_sock_add                              829     813     -16
      	nfsd4_sequence_done                          721     703     -18
      	nlmclnt_lookup_host                          708     686     -22
      	nfsd4_lockt                                 1085    1063     -22
      	nfs_get_client                              1077    1050     -27
      	tcf_bpf_init                                1106    1076     -30
      	nfsd4_encode_fattr                          5997    5930     -67
      	Total: Before=154856051, After=154854321, chg -0.00%
      Signed-off-by: NAlexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c7d03a00
  2. 15 11月, 2016 1 次提交
  3. 28 10月, 2016 3 次提交
    • J
      genetlink: mark families as __ro_after_init · 56989f6d
      Johannes Berg 提交于
      Now genl_register_family() is the only thing (other than the
      users themselves, perhaps, but I didn't find any doing that)
      writing to the family struct.
      
      In all families that I found, genl_register_family() is only
      called from __init functions (some indirectly, in which case
      I've add __init annotations to clarifly things), so all can
      actually be marked __ro_after_init.
      
      This protects the data structure from accidental corruption.
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      56989f6d
    • J
      genetlink: statically initialize families · 489111e5
      Johannes Berg 提交于
      Instead of providing macros/inline functions to initialize
      the families, make all users initialize them statically and
      get rid of the macros.
      
      This reduces the kernel code size by about 1.6k on x86-64
      (with allyesconfig).
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      489111e5
    • J
      genetlink: no longer support using static family IDs · a07ea4d9
      Johannes Berg 提交于
      Static family IDs have never really been used, the only
      use case was the workaround I introduced for those users
      that assumed their family ID was also their multicast
      group ID.
      
      Additionally, because static family IDs would never be
      reserved by the generic netlink code, using a relatively
      low ID would only work for built-in families that can be
      registered immediately after generic netlink is started,
      which is basically only the control family (apart from
      the workaround code, which I also had to add code for so
      it would reserve those IDs)
      
      Thus, anything other than GENL_ID_GENERATE is flawed and
      luckily not used except in the cases I mentioned. Move
      those workarounds into a few lines of code, and then get
      rid of GENL_ID_GENERATE entirely, making it more robust.
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a07ea4d9
  4. 13 10月, 2016 1 次提交
    • J
      net: deprecate eth_change_mtu, remove usage · a52ad514
      Jarod Wilson 提交于
      With centralized MTU checking, there's nothing productive done by
      eth_change_mtu that isn't already done in dev_set_mtu, so mark it as
      deprecated and remove all usage of it in the kernel. All callers have been
      audited for calls to alloc_etherdev* or ether_setup directly, which means
      they all have a valid dev->min_mtu and dev->max_mtu. Now eth_change_mtu
      prints out a netdev_warn about being deprecated, for the benefit of
      out-of-tree drivers that might be utilizing it.
      
      Of note, dvb_net.c actually had dev->mtu = 4096, while using
      eth_change_mtu, meaning that if you ever tried changing it's mtu, you
      couldn't set it above 1500 anymore. It's now getting dev->max_mtu also set
      to 4096 to remedy that.
      
      v2: fix up lantiq_etop, missed breakage due to drive not compiling on x86
      
      CC: netdev@vger.kernel.org
      Signed-off-by: NJarod Wilson <jarod@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a52ad514
  5. 12 10月, 2016 1 次提交
    • J
      mac80211_hwsim: make multi-channel ops const · 246ad56e
      Johannes Berg 提交于
      Instead of building the multi-channel ops at runtime, declare
      the common ops with a macro and build both that way, so that
      the multi-channel ops can also be const.
      
      As a side effect, due to the removed code, this decreases the
      size of the module (while shifting data from .bss to .text
      due to the newly added const).
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      246ad56e
  6. 16 9月, 2016 1 次提交
  7. 06 7月, 2016 3 次提交
  8. 30 6月, 2016 1 次提交
    • M
      mac80211_hwsim: Allow wmediumd to attach to radios created in its netns · f21e4d8e
      Martin Willi 提交于
      Registering wmediumd is currently limited to the initial network
      namespace. This patch enables wmediumd to attach from non-initial
      network namespaces using a user namespace having CAP_NET_ADMIN. A
      registered wmediumd can forward frames on radios that have been created
      in the same network namespace, even if they have been moved to other
      network namespaces.
      
      The wmediumd Netlink portid is tracked per net namespace. Additionally,
      the portid is stored on all radios created in that net namespace to
      simplify the portid lookup in the data path.
      Signed-off-by: NMartin Willi <martin@strongswan.org>
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      f21e4d8e
  9. 31 5月, 2016 2 次提交
    • M
      mac80211_hwsim: Add missing check for HWSIM_ATTR_SIGNAL · 62397da5
      Martin Willi 提交于
      A wmediumd that does not send this attribute causes a NULL pointer
      dereference, as the attribute is accessed even if it does not exist.
      
      The attribute was required but never checked ever since userspace frame
      forwarding has been introduced. The issue gets more problematic once we
      allow wmediumd registration from user namespaces.
      
      Cc: stable@vger.kernel.org
      Fixes: 7882513b ("mac80211_hwsim driver support userspace frame tx/rx")
      Signed-off-by: NMartin Willi <martin@strongswan.org>
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      62397da5
    • M
      mac80211_hwsim: Allow managing radios from non-initial namespaces · 100cb9ff
      Martin Willi 提交于
      While wiphys can be moved into network namespaces over nl80211, the
      creation and removal of hwsim radios is currently limited to the initial
      namespace. This patch allows management of namespaced radios from the
      owning namespace by setting genetlink netnsok.
      
      To prevent two arbitrary namespaces to communicate over the simulated
      shared medium, radios are separated by netgroups. Each radio created in
      the same namespace lives in the same netgroup and hence can communicate
      with other radios in that group. When moving radios to other namespaces,
      the netgroup is preserved, so two radios having the same netgroup can
      communicate even if not in the same namespace; This allows a controlling
      namespace to create radios and move them to other namespaces for
      communication.
      
      When a net namespace owning a radio exits, the radio is destroyed unless
      it was created in the initial network namespace. This keeps the previous
      behavior by returning them to the init namespace, but prevents unprivileged
      users from creating radios in the initial namespace.
      Signed-off-by: NMartin Willi <martin@strongswan.org>
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      100cb9ff
  10. 27 4月, 2016 1 次提交
  11. 12 4月, 2016 1 次提交
  12. 05 4月, 2016 1 次提交
  13. 05 3月, 2016 1 次提交
  14. 24 2月, 2016 1 次提交
  15. 14 1月, 2016 2 次提交
    • S
      mac80211: pass block ack session timeout to to driver · 50ea05ef
      Sara Sharon 提交于
      Currently mac80211 does not inform the driver of the session
      block ack timeout when starting a rx aggregation session.
      Drivers that manage the reorder buffer need to know this
      parameter.
      Seeing that there are now too many arguments for the
      drv_ampdu_action() function, wrap them inside a structure.
      Signed-off-by: NSara Sharon <sara.sharon@intel.com>
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      50ea05ef
    • B
      Revert "mac80211_hwsim: support any address in userspace" · 354210f8
      Bob Copeland 提交于
      This reverts commit cd37a90b.
      
      Different userspace programs interpreted HWSIM_ATTR_ADDR_TRANSMITTER
      and HWSIM_ATTR_ADDR_RECEIVER differently: some expected it to
      be an unchanging hardware address that is tied to the radio despite
      which address is configured on the interface, while others expected
      to be a copy of the address in the frame (the configured address).
      The intent of the original authors is unclear.
      
      The latter interpretation doesn't really work properly with multiple
      vifs and broadcast frames.  Also, as the TA is already in the
      frame, userspace programs can actually support configured addresses
      in the former interpretation by mapping between them and the supplied
      HWSIM_ATTR_ADDR_TRANSMITTER.
      
      So, in the interest of API stability, revert to the previous mode
      of operation and going forward use the former interpretation.
      Signed-off-by: NBob Copeland <me@bobcopeland.com>
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      354210f8
  16. 04 12月, 2015 7 次提交
  17. 10 11月, 2015 1 次提交
    • A
      remove abs64() · 79211c8e
      Andrew Morton 提交于
      Switch everything to the new and more capable implementation of abs().
      Mainly to give the new abs() a bit of a workout.
      
      Cc: Michal Nazarewicz <mina86@mina86.com>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      79211c8e
  18. 25 9月, 2015 1 次提交
  19. 22 9月, 2015 1 次提交
  20. 19 8月, 2015 1 次提交
  21. 14 8月, 2015 1 次提交
  22. 17 7月, 2015 1 次提交
  23. 10 6月, 2015 1 次提交
    • J
      mac80211: convert HW flags to unsigned long bitmap · 30686bf7
      Johannes Berg 提交于
      As we're running out of hardware capability flags pretty quickly,
      convert them to use the regular test_bit() style unsigned long
      bitmaps.
      
      This introduces a number of helper functions/macros to set and to
      test the bits, along with new debugfs code.
      
      The occurrences of an explicit __clear_bit() are intentional, the
      drivers were never supposed to change their supported bits on the
      fly. We should investigate changing this to be a per-frame flag.
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      30686bf7
  24. 06 5月, 2015 2 次提交
  25. 24 4月, 2015 1 次提交
    • J
      mac80211: remove support for IFF_PROMISC · df140465
      Johannes Berg 提交于
      This support is essentially useless as typically networks are encrypted,
      frames will be filtered by hardware, and rate scaling will be done with
      the intended recipient in mind. For real monitoring of the network, the
      monitor mode support should be used instead.
      
      Removing it removes a lot of corner cases.
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      df140465
  26. 22 4月, 2015 1 次提交
  27. 04 3月, 2015 1 次提交
    • J
      mac80211_hwsim: fix beacon timers · 56067628
      Johannes Berg 提交于
      Jouni reported that certain combinations of hwsim test cases failed,
      and we found that beaconing was erroneously enabled too early on any
      channel switch, which lead to the BI of 2000 TU from the first test
      case to leak into the second one, which then didn't beacon properly.
      
      To fix this, set data->beacon_int to zero when all stop beaconing so
      that beaconing cannot be started (which was intended as 'restarted')
      elsewhere.
      
      Additionally, Jouni found that due to this 'restart' and the beacon
      interval handling station interfaces would also have a needlessly
      running beacon timer all the time, of course not doing anything.
      
      To also fix the latter case only use the beacon interval when it's
      actually needed, i.e. when beaconing gets enabled.
      Reported-by: NJouni Malinen <j@w1.fi>
      Tested-by: NJouni Malinen <j@w1.fi>
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      56067628