17 Dec, 2010

1 commit


11 Dec, 2010

1 commit


09 Dec, 2010

3 commits


07 Dec, 2010

2 commits

  • As we can check if an address is vmalloc address with is_vmalloc_addr(),
    we remove pgv.flags. Then we may get more pg_vecs.

    Signed-off-by: Changli Gao
    Signed-off-by: David S. Miller

    Changli Gao
     
  • The following commit causes the pgv->buffer may point to the memory
    returned by vmalloc(). And we can't use virt_to_page() for the vmalloc
    address.

    This patch introduces a new inline function pgv_to_page(), which calls
    vmalloc_to_page() for the vmalloc address, and virt_to_page() for the
    __get_free_pages address.

    We used to increase page pointer to get the next page at the next page
    address, after Neil's patch, it is wrong, as the physical address may
    be not continuous. This patch also fixes this issue.

    commit 0e3125c755445664f00ad036e4fc2cd32fd52877
    Author: Neil Horman
    Date: Tue Nov 16 10:26:47 2010 -0800

    packet: Enhance AF_PACKET implementation to not require high order contiguous memory allocation (v4)

    Signed-off-by: Changli Gao
    Signed-off-by: David S. Miller

    Changli Gao
     

22 Nov, 2010

1 commit

  • alloc_one_pg_vec_page() is supposed to return zeroed memory, so use
    vzalloc() instead of vmalloc()

    Signed-off-by: Eric Dumazet
    Cc: Neil Horman
    Acked-by: Neil Horman
    Signed-off-by: David S. Miller

    Eric Dumazet
     

20 Nov, 2010

1 commit

  • Remove pc variable to avoid arithmetic to compute fentry at each filter
    instruction. Jumps directly manipulate fentry pointer.

    As the last instruction of filter[] is guaranteed to be a RETURN, and
    all jumps are before the last instruction, we dont need to check filter
    bounds (number of instructions in filter array) at each iteration, so we
    remove it from sk_run_filter() params.

    On x86_32 remove f_k var introduced in commit 57fe93b374a6b871
    (filter: make sure filters dont read uninitialized memory)

    Note : We could use a CONFIG_ARCH_HAS_{FEW|MANY}_REGISTERS in order to
    avoid too many ifdefs in this code.

    This helps compiler to use cpu registers to hold fentry and A
    accumulator.

    On x86_32, this saves 401 bytes, and more important, sk_run_filter()
    runs much faster because less register pressure (One less conditional
    branch per BPF instruction)

    # size net/core/filter.o net/core/filter_pre.o
    text data bss dec hex filename
    2948 0 0 2948 b84 net/core/filter.o
    3349 0 0 3349 d15 net/core/filter_pre.o

    on x86_64 :
    # size net/core/filter.o net/core/filter_pre.o
    text data bss dec hex filename
    5173 0 0 5173 1435 net/core/filter.o
    5224 0 0 5224 1468 net/core/filter_pre.o

    Signed-off-by: Eric Dumazet
    Acked-by: Changli Gao
    Signed-off-by: David S. Miller

    Eric Dumazet
     

17 Nov, 2010

1 commit

  • MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    Version 4 of this patch.

    Change notes:
    1) Removed extra memset. Didn't think kcalloc added a GFP_ZERO the way kzalloc did :)

    Summary:
    It was shown to me recently that systems under high load were driven very deep
    into swap when tcpdump was run. The reason this happened was because the
    AF_PACKET protocol has a SET_RINGBUFFER socket option that allows the user space
    application to specify how many entries an AF_PACKET socket will have and how
    large each entry will be. It seems the default setting for tcpdump is to set
    the ring buffer to 32 entries of 64 Kb each, which implies 32 order 5
    allocation. Thats difficult under good circumstances, and horrid under memory
    pressure.

    I thought it would be good to make that a bit more usable. I was going to do a
    simple conversion of the ring buffer from contigous pages to iovecs, but
    unfortunately, the metadata which AF_PACKET places in these buffers can easily
    span a page boundary, and given that these buffers get mapped into user space,
    and the data layout doesn't easily allow for a change to padding between frames
    to avoid that, a simple iovec change is just going to break user space ABI
    consistency.

    So I've done this, I've added a three tiered mechanism to the af_packet set_ring
    socket option. It attempts to allocate memory in the following order:

    1) Using __get_free_pages with GFP_NORETRY set, so as to fail quickly without
    digging into swap

    2) Using vmalloc

    3) Using __get_free_pages with GFP_NORETRY clear, causing us to try as hard as
    needed to get the memory

    The effect is that we don't disturb the system as much when we're under load,
    while still being able to conduct tcpdumps effectively.

    Tested successfully by me.

    Signed-off-by: Neil Horman
    Acked-by: Eric Dumazet
    Acked-by: Maciej Żenczykowski
    Reported-by: Maciej Żenczykowski
    Signed-off-by: David S. Miller

    Neil Horman
     

13 Nov, 2010

1 commit


11 Nov, 2010

1 commit

  • packet_getname_spkt() doesn't initialize all members of sa_data field of
    sockaddr struct if strlen(dev->name) < 13. This structure is then copied
    to userland. It leads to leaking of contents of kernel stack memory.
    We have to fully fill sa_data with strncpy() instead of strlcpy().

    The same with packet_getname(): it doesn't initialize sll_pkttype field of
    sockaddr_ll. Set it to zero.

    Signed-off-by: Vasiliy Kulikov
    Signed-off-by: David S. Miller

    Vasiliy Kulikov
     

19 Aug, 2010

1 commit

  • This patch removes the abstraction introduced by the union skb_shared_tx in
    the shared skb data.

    The access of the different union elements at several places led to some
    confusion about accessing the shared tx_flags e.g. in skb_orphan_try().

    http://marc.info/?l=linux-netdev&m=128084897415886&w=2

    Signed-off-by: Oliver Hartkopp
    Signed-off-by: David S. Miller

    Oliver Hartkopp
     

02 Jun, 2010

1 commit

  • This patch adds a setting, PACKET_TIMESTAMP, to specify the packet
    timestamp source that is exported to capture utilities like tcpdump by
    packet_mmap.

    PACKET_TIMESTAMP accepts the same integer bit field as
    SO_TIMESTAMPING. However, only the SOF_TIMESTAMPING_SYS_HARDWARE and
    SOF_TIMESTAMPING_RAW_HARDWARE values are currently recognized by
    PACKET_TIMESTAMP. SOF_TIMESTAMPING_SYS_HARDWARE takes precedence over
    SOF_TIMESTAMPING_RAW_HARDWARE if both bits are set.

    If PACKET_TIMESTAMP is not set, a software timestamp generated inside
    the networking stack is used (the behavior before this setting was
    added).

    Signed-off-by: Scott McMillan
    Signed-off-by: David S. Miller

    Scott McMillan
     

21 Apr, 2010

1 commit


17 Apr, 2010

1 commit

  • The af_packet protocol is used by Perl to do ioctls as reported by
    Stephane Riviere:

    "Net::RawIP relies on SIOCGIFADDR et SIOCGIFHWADDR to get the IP and MAC
    addresses of the network interface."

    But in a new network namespace these ioctl fail because it is disabled for
    a namespace different from the init_net_ns.

    These two lines should not be there as af_inet and af_packet are
    namespace aware since a long time now. I suppose we forget to remove these
    lines because we sent the af_packet first, before af_inet was supported.

    Signed-off-by: Daniel Lezcano
    Reported-by: Stephane Riviere
    Signed-off-by: David S. Miller

    Daniel Lezcano
     

13 Apr, 2010

1 commit

  • Enable the SO_TIMESTAMPING socket infrastructure for raw packet sockets.
    We introduce PACKET_TX_TIMESTAMP for the control message cmsg_type.

    Similar support for UDP and CAN sockets was added in commit
    51f31cabe3ce5345b51e4a4f82138b38c4d5dc91

    Signed-off-by: Richard Cochran
    Signed-off-by: David S. Miller

    Richard Cochran
     

12 Apr, 2010

1 commit


04 Apr, 2010

2 commits

  • Converts the list and the core manipulating with it to be the same as uc_list.

    +uses two functions for adding/removing mc address (normal and "global"
    variant) instead of a function parameter.
    +removes dev_mcast.c completely.
    +exposes netdev_hw_addr_list_* macros along with __hw_addr_* functions for
    manipulation with lists on a sandbox (used in bonding and 80211 drivers)

    Signed-off-by: Jiri Pirko
    Signed-off-by: David S. Miller

    Jiri Pirko
     
  • +little renaming of unicast functions to be smooth with multicast ones

    Signed-off-by: Jiri Pirko
    Signed-off-by: David S. Miller

    Jiri Pirko
     

30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

03 Mar, 2010

1 commit

  • My previous patch 914c8ad2d18b62ad1420f518c0cab0b0b90ab308 incorrectly changed
    the length check in packet_mc_add to be more strict. The problem is that
    userspace is not filling this field (and it stays zeroed) in case of setting
    PACKET_MR_PROMISC or PACKET_MR_ALLMULTI. So move the strict check to the point
    in path where the addr_len must be set correctly.

    Signed-off-by: Jiri Pirko
    Reported-by: Pavel Roskin
    Signed-off-by: David S. Miller

    Jiri Pirko
     

01 Mar, 2010

1 commit


26 Feb, 2010

1 commit


25 Feb, 2010

1 commit

  • Update rcu_dereference() primitives to use new lockdep-based
    checking. The rcu_dereference() in __in6_dev_get() may be
    protected either by rcu_read_lock() or RTNL, per Eric Dumazet.
    The rcu_dereference() in __sk_free() is protected by the fact
    that it is never reached if an update could change it. Check
    for this by using rcu_dereference_check() to verify that the
    struct sock's ->sk_wmem_alloc counter is zero.

    Acked-by: Eric Dumazet
    Acked-by: David S. Miller
    Signed-off-by: Paul E. McKenney
    Cc: laijs@cn.fujitsu.com
    Cc: dipankar@in.ibm.com
    Cc: mathieu.desnoyers@polymtl.ca
    Cc: josh@joshtriplett.org
    Cc: dvhltc@us.ibm.com
    Cc: niv@us.ibm.com
    Cc: peterz@infradead.org
    Cc: rostedt@goodmis.org
    Cc: Valdis.Kletnieks@vt.edu
    Cc: dhowells@redhat.com
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Paul E. McKenney
     

23 Feb, 2010

1 commit

  • Convert AF_PACKET to use RCU, eliminating one more reader/writer lock.

    There is no need for a real sk_del_node_init_rcu(), because sk_del_node_init
    is doing the equivalent thing to hlst_del_init_rcu already; but added
    some comments to try and make that obvious.

    Signed-off-by: Stephen Hemminger
    Signed-off-by: David S. Miller

    stephen hemminger
     

11 Feb, 2010

1 commit


06 Feb, 2010

1 commit

  • Early on this was an experimental facility that few
    people other than Alexey Kuznetsov played with.

    Now it's a pretty fundamental thing and as people add
    more features to AF_PACKET sockets this config options
    creates ifdef spaghetti.

    So kill it off.

    Signed-off-by: David S. Miller

    David S. Miller
     

05 Feb, 2010

1 commit

  • This patch adds GSO/checksum offload to af_packet sockets using
    virtio_net_hdr. Based on Rusty's patch to add this support to tun.
    It allows GSO/checksum offload to be enabled when using raw socket
    backend with virtio_net.
    Adds PACKET_VNET_HDR socket option to prepend virtio_net_hdr in the
    receive path and process/skip virtio_net_hdr in the send path. This
    option is only allowed with SOCK_RAW sockets attached to ethernet
    type devices.

    v2 updates
    ----------
    Michael's Comments
    - Perform length check in packet_snd() when GSO is off even when
    vnet_hdr is present.
    - Check for SKB_GSO_FCOE type and return -EINVAL
    - don't allow tx/rx ring when vnet_hdr is enabled.
    Herbert's Comments
    - Removed ethernet specific code.
    - protocol value is assumed to be passed in by the caller.

    Signed-off-by: Sridhar Samudrala
    Signed-off-by: David S. Miller

    Sridhar Samudrala
     

23 Jan, 2010

1 commit


18 Jan, 2010

1 commit


12 Jan, 2010

1 commit


16 Dec, 2009

1 commit

  • commit 654d1f8a019dfa06d (packet: less dev_put() calls)
    introduced a problem, calling potentially sleeping functions from a
    rcu_read_lock() protected section.

    Fix this by releasing lock before the sock_wmalloc()/memcpy_fromiovec() calls.

    After skb allocation and copy from user space, we redo device
    lookup and appropriate tests.

    Reported-and-tested-by: Frederic Weisbecker
    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

30 Nov, 2009

1 commit


26 Nov, 2009

1 commit

  • Generated with the following semantic patch

    @@
    struct net *n1;
    struct net *n2;
    @@
    - n1 == n2
    + net_eq(n1, n2)

    @@
    struct net *n1;
    struct net *n2;
    @@
    - n1 != n2
    + !net_eq(n1, n2)

    applied over {include,net,drivers/net}.

    Signed-off-by: Octavian Purdila
    Signed-off-by: David S. Miller

    Octavian Purdila
     

11 Nov, 2009

1 commit


06 Nov, 2009

1 commit

  • The generic __sock_create function has a kern argument which allows the
    security system to make decisions based on if a socket is being created by
    the kernel or by userspace. This patch passes that flag to the
    net_proto_family specific create function, so it can do the same thing.

    Signed-off-by: Eric Paris
    Acked-by: Arnaldo Carvalho de Melo
    Signed-off-by: David S. Miller

    Eric Paris
     

02 Nov, 2009

1 commit

  • - packet_sendmsg_spkt() can use dev_get_by_name_rcu() to avoid touching device refcount.

    - packet_getname_spkt() & packet_getname() can use dev_get_by_index_rcu() to
    avoid touching device refcount too.

    tpacket_snd() & packet_snd() can not use RCU yet because they can sleep when
    allocating skb.

    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

30 Oct, 2009

1 commit


29 Oct, 2009

1 commit

  • Currently PACKET_TX_RING forces certain amount of every frame to remain
    unused. This probably originates from an early version of the
    PACKET_TX_RING patch that in fact used the extra space when the (since
    removed) CONFIG_PACKET_MMAP_ZERO_COPY option was enabled. The current
    code does not make any use of this extra space.

    This patch removes the extra space reservation and lets userspace make
    use of the full frame size.

    Signed-off-by: Gabor Gombas
    Signed-off-by: David S. Miller

    Gabor Gombas