06 Jan, 2012

1 commit

  • nr_frags can be 8 bits since 256 is plenty of fragments. This allows it to be
    packed with tx_flags.

    Also by moving ip6_frag_id and dataref (both 4 bytes) next to each other we can
    avoid a hole between ip6_frag_id and frag_list on 64 bit systems.

    Signed-off-by: Ian Campbell
    Acked-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Ian Campbell
     

24 Dec, 2011

1 commit


05 Dec, 2011

1 commit

  • We discovered that TCP stack could retransmit misaligned skbs if a
    malicious peer acknowledged sub MSS frame. This currently can happen
    only if output interface is non SG enabled : If SG is enabled, tcp
    builds headless skbs (all payload is included in fragments), so the tcp
    trimming process only removes parts of skb fragments, header stay
    aligned.

    Some arches cant handle misalignments, so force a head reallocation and
    shrink headroom to MAX_TCP_HEADER.

    Dont care about misaligments on x86 and PPC (or other arches setting
    NET_IP_ALIGN to 0)

    This patch introduces __pskb_copy() which can specify the headroom of
    new head, and pskb_copy() becomes a wrapper on top of __pskb_copy()

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

    Eric Dumazet
     

23 Nov, 2011

1 commit

  • Given we dont use anymore the struct net_device *dev argument, and this
    interface brings litle benefit, remove netdev_{alloc|free}_page(), to
    debloat include/linux/skbuff.h a bit.

    (Some drivers used a mix of these interfaces and alloc_pages())

    When allocating a page given to device for DMA transfer (device to
    memory), it makes sense to use a cold one (__GFP_COLD)

    Signed-off-by: Eric Dumazet
    CC: Jeff Kirsher
    CC: Dimitris Michailidis
    Signed-off-by: David S. Miller

    Eric Dumazet
     

18 Nov, 2011

1 commit


17 Nov, 2011

2 commits


15 Nov, 2011

1 commit

  • One of the thing we discussed during netdev 2011 conference was the idea
    to change some network drivers to allocate/populate their skb at RX
    completion time, right before feeding the skb to network stack.

    In old days, we allocated skbs when populating the RX ring.

    This means bringing into cpu cache sk_buff and skb_shared_info cache
    lines (since we clear/initialize them), then 'queue' skb->data to NIC.

    By the time NIC fills a frame in skb->data buffer and host can process
    it, cpu probably threw away the cache lines from its caches, because lot
    of things happened between the allocation and final use.

    So the deal would be to allocate only the data buffer for the NIC to
    populate its RX ring buffer. And use build_skb() at RX completion to
    attach a data buffer (now filled with an ethernet frame) to a new skb,
    initialize the skb_shared_info portion, and give the hot skb to network
    stack.

    build_skb() is the function to allocate an skb, caller providing the
    data buffer that should be attached to it. Drivers are expected to call
    skb_reserve() right after build_skb() to adjust skb->data to the
    Ethernet frame (usually skipping NET_SKB_PAD and NET_IP_ALIGN, but some
    drivers might add a hardware provided alignment)

    Data provided to build_skb() MUST have been allocated by a prior
    kmalloc() call, with enough room to add SKB_DATA_ALIGN(sizeof(struct
    skb_shared_info)) bytes at the end of the data without corrupting
    incoming frame.

    data = kmalloc(NET_SKB_PAD + NET_IP_ALIGN + 1536 +
    SKB_DATA_ALIGN(sizeof(struct skb_shared_info)),
    GFP_ATOMIC);
    ...
    skb = build_skb(data);
    if (!skb) {
    recycle_data(data);
    } else {
    skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN);
    ...
    }

    Signed-off-by: Eric Dumazet
    CC: Eilon Greenstein
    CC: Ben Hutchings
    CC: Tom Herbert
    CC: Jamal Hadi Salim
    CC: Stephen Hemminger
    CC: Thomas Graf
    CC: Herbert Xu
    CC: Jeff Kirsher
    Signed-off-by: David S. Miller

    Eric Dumazet
     

10 Nov, 2011

1 commit

  • The 802.1X EAPOL handshake hostapd does requires
    knowing whether the frame was ack'ed by the peer.
    Currently, we fudge this pretty badly by not even
    transmitting the frame as a normal data frame but
    injecting it with radiotap and getting the status
    out of radiotap monitor as well. This is rather
    complex, confuses users (mon.wlan0 presence) and
    doesn't work with all hardware.

    To get rid of that hack, introduce a real wifi TX
    status option for data frame transmissions.

    This works similar to the existing TX timestamping
    in that it reflects the SKB back to the socket's
    error queue with a SCM_WIFI_STATUS cmsg that has
    an int indicating ACK status (0/1).

    Since it is possible that at some point we will
    want to have TX timestamping and wifi status in a
    single errqueue SKB (there's little point in not
    doing that), redefine SO_EE_ORIGIN_TIMESTAMPING
    to SO_EE_ORIGIN_TXSTATUS which can collect more
    than just the timestamp; keep the old constant
    as an alias of course. Currently the internal APIs
    don't make that possible, but it wouldn't be hard
    to split them up in a way that makes it possible.

    Thanks to Neil Horman for helping me figure out
    the functions that add the control messages.

    Signed-off-by: Johannes Berg
    Signed-off-by: John W. Linville

    Johannes Berg
     

01 Nov, 2011

1 commit


25 Oct, 2011

1 commit


24 Oct, 2011

1 commit

  • The pair of functions,

    * skb_clone_tx_timestamp()
    * skb_complete_tx_timestamp()

    were designed to allow timestamping in PHY devices. The first
    function, called during the MAC driver's hard_xmit method, identifies
    PTP protocol packets, clones them, and gives them to the PHY device
    driver. The PHY driver may hold onto the packet and deliver it at a
    later time using the second function, which adds the packet to the
    socket's error queue.

    As pointed out by Johannes, nothing prevents the socket from
    disappearing while the cloned packet is sitting in the PHY driver
    awaiting a timestamp. This patch fixes the issue by taking a reference
    on the socket for each such packet. In addition, the comments
    regarding the usage of these function are expanded to highlight the
    rule that PHY drivers must use skb_complete_tx_timestamp() to release
    the packet, in order to release the socket reference, too.

    These functions first appeared in v2.6.36.

    Reported-by: Johannes Berg
    Signed-off-by: Richard Cochran
    Cc:
    Signed-off-by: Eric Dumazet
    Reviewed-by: Johannes Berg
    Signed-off-by: David S. Miller

    Richard Cochran
     

21 Oct, 2011

2 commits


20 Oct, 2011

2 commits

  • I audited all of the callers in the tree and only one of them (pktgen) expects
    it to do so. Taking this reference is pretty obviously confusing and error
    prone.

    In particular I looked at the following commits which switched callers of
    (__)skb_frag_set_page to the skb paged fragment api:

    6a930b9f163d7e6d9ef692e05616c4ede65038ec cxgb3: convert to SKB paged frag API.
    5dc3e196ea21e833128d51eb5b788a070fea1f28 myri10ge: convert to SKB paged frag API.
    0e0634d20dd670a89af19af2a686a6cce943ac14 vmxnet3: convert to SKB paged frag API.
    86ee8130a46769f73f8f423f99dbf782a09f9233 virtionet: convert to SKB paged frag API.
    4a22c4c919c201c2a7f4ee09e672435a3072d875 sfc: convert to SKB paged frag API.
    18324d690d6a5028e3c174fc1921447aedead2b8 cassini: convert to SKB paged frag API.
    b061b39e3ae18ad75466258cf2116e18fa5bbd80 benet: convert to SKB paged frag API.
    b7b6a688d217936459ff5cf1087b2361db952509 bnx2: convert to SKB paged frag API.
    804cf14ea5ceca46554d5801e2817bba8116b7e5 net: xfrm: convert to SKB frag APIs
    ea2ab69379a941c6f8884e290fdd28c93936a778 net: convert core to skb paged frag APIs

    Signed-off-by: Ian Campbell
    Acked-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Ian Campbell
     
  • skb_recycle_check resets the skb if it's eligible for recycling.
    However, there are times when a driver might want to optionally
    manipulate the skb data with the skb before resetting the skb,
    but after it has determined eligibility. We do this by splitting the
    eligibility check from the skb reset, creating two inline functions to
    accomplish that task.

    Signed-off-by: Andy Fleming
    Acked-by: David Daney
    Signed-off-by: David S. Miller

    Andy Fleming
     

19 Oct, 2011

1 commit

  • To ease skb->truesize sanitization, its better to be able to localize
    all references to skb frags size.

    Define accessors : skb_frag_size() to fetch frag size, and
    skb_frag_size_{set|add|sub}() to manipulate it.

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

    Eric Dumazet
     

14 Oct, 2011

1 commit

  • skb truesize currently accounts for sk_buff struct and part of skb head.
    kmalloc() roundings are also ignored.

    Considering that skb_shared_info is larger than sk_buff, its time to
    take it into account for better memory accounting.

    This patch introduces SKB_TRUESIZE(X) macro to centralize various
    assumptions into a single place.

    At skb alloc phase, we put skb_shared_info struct at the exact end of
    skb head, to allow a better use of memory (lowering number of
    reallocations), since kmalloc() gives us power-of-two memory blocks.

    Unless SLUB/SLUB debug is active, both skb->head and skb_shared_info are
    aligned to cache lines, as before.

    Note: This patch might trigger performance regressions because of
    misconfigured protocol stacks, hitting per socket or global memory
    limits that were previously not reached. But its a necessary step for a
    more accurate memory accounting.

    Signed-off-by: Eric Dumazet
    CC: Andi Kleen
    CC: Ben Hutchings
    Signed-off-by: David S. Miller

    Eric Dumazet
     

22 Sep, 2011

1 commit

  • Conflicts:
    MAINTAINERS
    drivers/net/Kconfig
    drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
    drivers/net/ethernet/broadcom/tg3.c
    drivers/net/wireless/iwlwifi/iwl-pci.c
    drivers/net/wireless/iwlwifi/iwl-trans-tx-pcie.c
    drivers/net/wireless/rt2x00/rt2800usb.c
    drivers/net/wireless/wl12xx/main.c

    David S. Miller
     

16 Sep, 2011

1 commit

  • dev_forward_skb loops an skb back into host networking
    stack which might hang on the memory indefinitely.
    In particular, this can happen in macvtap in bridged mode.
    Copy the userspace fragments to avoid blocking the
    sender in that case.

    As this patch makes skb_copy_ubufs extern now,
    I also added some documentation and made it clear
    the SKBTX_DEV_ZEROCOPY flag automatically instead
    of doing it in all callers. This can be made into a separate
    patch if people feel it's worth it.

    Signed-off-by: Michael S. Tsirkin
    Signed-off-by: David S. Miller

    Michael S. Tsirkin
     

25 Aug, 2011

1 commit


23 Aug, 2011

1 commit

  • The primary aim is to add skb_frag_(ref|unref) in order to remove the use of
    bare get/put_page on SKB pages fragments and to isolate users from subsequent
    changes to the skb_frag_t data structure.

    Signed-off-by: Ian Campbell
    Cc: "David S. Miller"
    Cc: Eric Dumazet
    Cc: "Michał Mirosław"
    Cc: netdev@vger.kernel.org
    Signed-off-by: David S. Miller

    Ian Campbell
     

19 Aug, 2011

1 commit


18 Aug, 2011

1 commit

  • The l4_rxhash flag was added to the skb structure to indicate
    that the rxhash value was computed over the 4 tuple for the
    packet which includes the port information in the encapsulated
    transport packet. This is used by the stack to preserve the
    rxhash value in __skb_rx_tunnel.

    Signed-off-by: Tom Herbert
    Signed-off-by: David S. Miller

    Tom Herbert
     

27 Jul, 2011

1 commit

  • This allows us to move duplicated code in
    (atomic_inc_not_zero() for now) to

    Signed-off-by: Arun Sharma
    Reviewed-by: Eric Dumazet
    Cc: Ingo Molnar
    Cc: David Miller
    Cc: Eric Dumazet
    Acked-by: Mike Frysinger
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arun Sharma
     

12 Jul, 2011

1 commit


10 Jul, 2011

1 commit


07 Jul, 2011

1 commit

  • This patch adds userspace buffers support in skb shared info. A new
    struct skb_ubuf_info is needed to maintain the userspace buffers
    argument and index, a callback is used to notify userspace to release
    the buffers once lower device has done DMA (Last reference to that skb
    has gone).

    If there is any userspace apps to reference these userspace buffers,
    then these userspaces buffers will be copied into kernel. This way we
    can prevent userspace apps from holding these userspace buffers too long.

    Use destructor_arg to point to the userspace buffer info; a new tx flags
    SKBTX_DEV_ZEROCOPY is added for zero-copy buffer check.

    Signed-off-by: Shirley Ma
    Signed-off-by: David S. Miller

    Shirley Ma
     

21 Jun, 2011

1 commit


20 Jun, 2011

1 commit

  • The comment for the skb_tx_timestamp() function suggests calling it just
    after a buffer is released to the hardware for transmission. However,
    for drivers that free the buffer in an ISR, this produces a race between
    the time stamp code and the ISR. This commit changes the comment to advise
    placing the call just before handing the buffer over to the hardware.

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

    Richard Cochran
     

12 Jun, 2011

1 commit

  • Testing of VLAN_FLAG_REORDER_HDR does not belong in vlan_untag
    but rather in vlan_do_receive. Otherwise the vlan header
    will not be properly put on the packet in the case of
    vlan header accelleration.

    As we remove the check from vlan_check_reorder_header
    rename it vlan_reorder_header to keep the naming clean.

    Fix up the skb->pkt_type early so we don't look at the packet
    after adding the vlan tag, which guarantees we don't goof
    and look at the wrong field.

    Use a simple if statement instead of a complicated switch
    statement to decided that we need to increment rx_stats
    for a multicast packet.

    Hopefully at somepoint we will just declare the case where
    VLAN_FLAG_REORDER_HDR is cleared as unsupported and remove
    the code. Until then this keeps it working correctly.

    Signed-off-by: Eric W. Biederman
    Signed-off-by: Jiri Pirko
    Acked-by: Changli Gao
    Signed-off-by: David S. Miller

    Jiri Pirko
     

23 May, 2011

6 commits

  • * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (27 commits)
    bnx2x: allow device properly initialize after hotplug
    bnx2x: fix DMAE timeout according to hw specifications
    bnx2x: properly handle CFC DEL in cnic flow
    bnx2x: call dev_kfree_skb_any instead of dev_kfree_skb
    net: filter: move forward declarations to avoid compile warnings
    pktgen: refactor pg_init() code
    pktgen: use vzalloc_node() instead of vmalloc_node() + memset()
    net: skb_trim explicitely check the linearity instead of data_len
    ipv4: Give backtrace in ip_rt_bug().
    net: avoid synchronize_rcu() in dev_deactivate_many
    net: remove synchronize_net() from netdev_set_master()
    rtnetlink: ignore NETDEV_RELEASE and NETDEV_JOIN event
    net: rename NETDEV_BONDING_DESLAVE to NETDEV_RELEASE
    bridge: call NETDEV_JOIN notifiers when add a slave
    netpoll: disable netpoll when enslave a device
    macvlan: Forward unicast frames in bridge mode to lowerdev
    net: Remove linux/prefetch.h include from linux/skbuff.h
    ipv4: Include linux/prefetch.h in fib_trie.c
    netlabel: Remove prefetches from list handlers.
    drivers/net: add prefetch header for prefetch users
    ...

    Fixed up prefetch parts: removed a few duplicate prefetch.h includes,
    fixed the location of the igb prefetch.h, took my version of the
    skbuff.h code without the extra parentheses etc.

    Linus Torvalds
     
  • Commit e66eed651fd1 ("list: remove prefetching from regular list
    iterators") removed the include of prefetch.h from list.h. The skbuff
    list traversal still had them.

    Quoth David Miller:
    "Please just remove the prefetches.

    Those are modelled after list.h as I intend to eventually convert
    SKB list handling to "struct list_head" but we're not there yet.

    Therefore if we kill prefetches from list.h we should kill it from
    these things in skbuff.h too."

    Requested-by: David Miller
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • The purpose of the check on data_len is to check linearity, so use the inline
    helper for this. No overhead and more explicit.

    Signed-off-by: Emmanuel Grumbach
    Signed-off-by: David S. Miller

    Emmanuel Grumbach
     
  • No longer needed.

    Signed-off-by: David S. Miller

    David S. Miller
     
  • Noticed by Linus.

    Signed-off-by: David S. Miller

    David S. Miller
     
  • Fixes build errors on s390 and probably other archs as well:

    In file included from net/ipv4/ip_forward.c:32:0:
    include/net/udp.h: In function 'udp_csum_outgoing':
    include/net/udp.h:141:2: error: implicit declaration of function 'prefetch'

    Signed-off-by: Heiko Carstens
    Signed-off-by: Linus Torvalds

    Heiko Carstens
     

28 Apr, 2011

1 commit

  • In order to speedup packet filtering, here is an implementation of a
    JIT compiler for x86_64

    It is disabled by default, and must be enabled by the admin.

    echo 1 >/proc/sys/net/core/bpf_jit_enable

    It uses module_alloc() and module_free() to get memory in the 2GB text
    kernel range since we call helpers functions from the generated code.

    EAX : BPF A accumulator
    EBX : BPF X accumulator
    RDI : pointer to skb (first argument given to JIT function)
    RBP : frame pointer (even if CONFIG_FRAME_POINTER=n)
    r9d : skb->len - skb->data_len (headlen)
    r8 : skb->data

    To get a trace of generated code, use :

    echo 2 >/proc/sys/net/core/bpf_jit_enable

    Example of generated code :

    # tcpdump -p -n -s 0 -i eth1 host 192.168.20.0/24

    flen=18 proglen=147 pass=3 image=ffffffffa00b5000
    JIT code: ffffffffa00b5000: 55 48 89 e5 48 83 ec 60 48 89 5d f8 44 8b 4f 60
    JIT code: ffffffffa00b5010: 44 2b 4f 64 4c 8b 87 b8 00 00 00 be 0c 00 00 00
    JIT code: ffffffffa00b5020: e8 24 7b f7 e0 3d 00 08 00 00 75 28 be 1a 00 00
    JIT code: ffffffffa00b5030: 00 e8 fe 7a f7 e0 24 00 3d 00 14 a8 c0 74 49 be
    JIT code: ffffffffa00b5040: 1e 00 00 00 e8 eb 7a f7 e0 24 00 3d 00 14 a8 c0
    JIT code: ffffffffa00b5050: 74 36 eb 3b 3d 06 08 00 00 74 07 3d 35 80 00 00
    JIT code: ffffffffa00b5060: 75 2d be 1c 00 00 00 e8 c8 7a f7 e0 24 00 3d 00
    JIT code: ffffffffa00b5070: 14 a8 c0 74 13 be 26 00 00 00 e8 b5 7a f7 e0 24
    JIT code: ffffffffa00b5080: 00 3d 00 14 a8 c0 75 07 b8 ff ff 00 00 eb 02 31
    JIT code: ffffffffa00b5090: c0 c9 c3

    BPF program is 144 bytes long, so native program is almost same size ;)

    (000) ldh [12]
    (001) jeq #0x800 jt 2 jf 8
    (002) ld [26]
    (003) and #0xffffff00
    (004) jeq #0xc0a81400 jt 16 jf 5
    (005) ld [30]
    (006) and #0xffffff00
    (007) jeq #0xc0a81400 jt 16 jf 17
    (008) jeq #0x806 jt 10 jf 9
    (009) jeq #0x8035 jt 10 jf 17
    (010) ld [28]
    (011) and #0xffffff00
    (012) jeq #0xc0a81400 jt 16 jf 13
    (013) ld [38]
    (014) and #0xffffff00
    (015) jeq #0xc0a81400 jt 16 jf 17
    (016) ret #65535
    (017) ret #0

    Signed-off-by: Eric Dumazet
    Cc: Arnaldo Carvalho de Melo
    Cc: Ben Hutchings
    Cc: Hagen Paul Pfeifer
    Signed-off-by: David S. Miller

    Eric Dumazet
     

08 Apr, 2011

1 commit


31 Mar, 2011

1 commit