05 Sep, 2018

1 commit


18 Nov, 2016

1 commit

  • 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: Alexey Dobriyan
    Signed-off-by: David S. Miller

    Alexey Dobriyan
     

19 Aug, 2015

1 commit


10 Feb, 2014

1 commit

  • Include appropriate header file net/caif/caif_dev.h in caif/caif_dev.c
    because it has prototype declarations of function defined in
    caif/caif_dev.c.

    This eliminates the following file in caif/caif_dev.c:
    net/caif/caif_dev.c:303:6: warning: no previous prototype for ‘caif_enroll_dev’ [-Wmissing-prototypes]

    Signed-off-by: Rashika Kheria
    Reviewed-by: Josh Triplett
    Signed-off-by: David S. Miller

    Rashika Kheria
     

29 May, 2013

1 commit

  • So far, only net_device * could be passed along with netdevice notifier
    event. This patch provides a possibility to pass custom structure
    able to provide info that event listener needs to know.

    Signed-off-by: Jiri Pirko

    v2->v3: fix typo on simeth
    shortened dev_getter
    shortened notifier_info struct name
    v1->v2: fix notifier_call parameter in call_netdevice_notifier()
    Signed-off-by: David S. Miller

    Jiri Pirko
     

24 Apr, 2013

1 commit


08 Mar, 2013

1 commit


03 Mar, 2013

1 commit


20 Jul, 2012

1 commit


17 Jul, 2012

1 commit

  • unregister_netdevice_notifier() must be called before
    unregister_pernet_subsys() to avoid accessing already freed
    pernet memory. This fixes the following oops when doing rmmod:

    Call Trace:
    [] caif_device_notify+0x4d/0x5a0 [caif]
    [] unregister_netdevice_notifier+0xb9/0x100
    [] caif_device_exit+0x1c/0x250 [caif]
    [] sys_delete_module+0x1a4/0x300
    [] ? trace_hardirqs_on_caller+0x15d/0x1e0
    [] ? trace_hardirqs_on_thunk+0x3a/0x3
    [] system_call_fastpath+0x1a/0x1f

    RIP
    [] caif_get+0x51/0xb0 [caif]

    Signed-off-by: Sjur Brændeland
    Acked-by: "Eric W. Biederman"
    Signed-off-by: David S. Miller

    Sjur Brændeland
     

26 Jun, 2012

2 commits


18 Jun, 2012

1 commit


06 Feb, 2012

1 commit


28 Jan, 2012

1 commit

  • caif is a subsystem and as such it needs to register with
    register_pernet_subsys instead of register_pernet_device.

    Among other problems using register_pernet_device was resulting in
    net_generic being called before the caif_net structure was allocated.
    Which has been causing net_generic to fail with either BUG_ON's or by
    return NULL pointers.

    A more ugly problem that could be caused is packets in flight why the
    subsystem is shutting down.

    To remove confusion also remove the cruft cause by inappropriately
    trying to fix this bug.

    With the aid of the previous patch I have tested this patch and
    confirmed that using register_pernet_subsys makes the failure go away as
    it should.

    Signed-off-by: Eric W. Biederman
    Acked-by: Sjur Brændeland
    Tested-by: Sasha Levin
    Signed-off-by: David S. Miller

    Eric W. Biederman
     

17 Jan, 2012

1 commit


10 Jan, 2012

1 commit


23 Dec, 2011

1 commit

  • We simply say that regular this_cpu use must be safe regardless of
    preemption and interrupt state. That has no material change for x86
    and s390 implementations of this_cpu operations. However, arches that
    do not provide their own implementation for this_cpu operations will
    now get code generated that disables interrupts instead of preemption.

    -tj: This is part of on-going percpu API cleanup. For detailed
    discussion of the subject, please refer to the following thread.

    http://thread.gmane.org/gmane.linux.kernel/1222078

    Signed-off-by: Christoph Lameter
    Signed-off-by: Tejun Heo
    LKML-Reference:

    Christoph Lameter
     

07 Dec, 2011

1 commit


06 Dec, 2011

3 commits

  • This patch adds functionality for avoiding orphaning SKB too early.
    The original skb is stashed away and the original destructor is called
    from the hi-jacked flow-on callback. If CAIF interface goes down and a
    hi-jacked SKB exists, the original skb->destructor is restored.

    Signed-off-by: Sjur Brændeland
    Signed-off-by: David S. Miller

    sjur.brandeland@stericsson.com
     
  • Flow control is implemented by inspecting the qdisc queue length
    in order to detect potential overflow on the TX queue. When a threshold
    is reached flow-off is sent upwards in the CAIF stack. At the same time
    the skb->destructor is hi-jacked by orphaning the SKB and the original
    destructor is replaced with a "flow-on" callback. When the "hi-jacked"
    SKB is consumed the queue should be empty, and the "flow-on" callback
    is called and xon is sent upwards in the CAIF stack.

    Signed-off-by: Sjur Brændeland
    Signed-off-by: David S. Miller

    sjur.brandeland@stericsson.com
     
  • NCM 1.0 does not support anything but Ethernet framing, hence
    CAIF payload will be put into Ethernet frames.

    Discovery is based on fixed USB vendor 0x04cc (ST-Ericsson),
    product-id 0x230f (NCM). In this variant only CAIF payload is sent over
    the NCM interface.

    The CAIF stack (cfusbl.c) will when USB interface register first check if
    we got a CDC NCM USB interface with the right VID, PID.
    It will then read the device's Ethernet address and create a 'template'
    Ethernet TX header, using a broadcast address as the destination address,
    and EthType 0x88b5 (802.1 Local Experimental - vendor specific).

    A protocol handler for 0x88b5 is setup for reception of CAIF frames from
    the CDC NCM USB interface.

    Signed-off-by: Sjur Brændeland
    Signed-off-by: David S. Miller

    sjur.brandeland@stericsson.com
     

01 Dec, 2011

2 commits


01 Nov, 2011

1 commit


26 Oct, 2011

1 commit

  • The caif code will register its own pernet_operations, and then register
    a netdevice_notifier. Each time the netdevice_notifier is triggered,
    it'll do some stuff... including a lookup of its own pernet stuff with
    net_generic().

    If the net_generic() call ever returns NULL, the caif code will BUG().
    That doesn't seem *so* unreasonable, I suppose — it does seem like it
    should never happen.

    However, it *does* happen. When we clone a network namespace,
    setup_net() runs through all the pernet_operations one at a time. It
    gets to loopback before it gets to caif. And loopback_net_init()
    registers a netdevice... while caif hasn't been initialised. So the caif
    netdevice notifier triggers, and immediately goes BUG().

    We could imagine a complex and overengineered solution to this generic
    class of problems, but this patch takes the simple approach. It just
    makes caif_device_notify() *not* go looking for its pernet data
    structures if the device it's being notified about isn't a caif device
    in the first place.

    Cc: stable@kernel.org
    Signed-off-by: David Woodhouse
    Acked-by: Sjur Brændeland
    Signed-off-by: David S. Miller

    David Woodhouse
     

17 Sep, 2011

1 commit

  • Commit bd30ce4bc0b7 (caif: Use RCU instead of spin-lock in caif_dev.c)
    added a potential NULL dereference in case alloc_percpu() fails.

    caif_device_alloc() can also use GFP_KERNEL instead of GFP_ATOMIC.

    Signed-off-by: Eric Dumazet
    CC: Sjur Brændeland
    Acked-by: Sjur Brændeland
    Signed-off-by: David S. Miller

    Eric Dumazet
     

22 Jun, 2011

1 commit

  • It was suggested by "make versioncheck" that the follwing includes of
    linux/version.h are redundant:

    /home/jj/src/linux-2.6/net/caif/caif_dev.c: 14 linux/version.h not needed.
    /home/jj/src/linux-2.6/net/caif/chnl_net.c: 10 linux/version.h not needed.
    /home/jj/src/linux-2.6/net/ipv4/gre.c: 19 linux/version.h not needed.
    /home/jj/src/linux-2.6/net/netfilter/ipset/ip_set_core.c: 20 linux/version.h not needed.
    /home/jj/src/linux-2.6/net/netfilter/xt_set.c: 16 linux/version.h not needed.

    and it seems that it is right.

    Beyond manually inspecting the source files I also did a few build
    tests with various configs to confirm that including the header in
    those files is indeed not needed.

    Here's a patch to remove the pointless includes.

    Signed-off-by: Jesper Juhl
    Acked-by: Jozsef Kadlecsik
    Signed-off-by: David S. Miller

    Jesper Juhl
     

23 May, 2011

1 commit


16 May, 2011

3 commits

  • Do proper handling of dev_queue_xmit errors in order to
    avoid double free of skb and leaks in error conditions.
    In cfctrl pending requests are removed when CAIF Link layer goes down.

    Signed-off-by: Sjur Brændeland
    Signed-off-by: David S. Miller

    sjur.brandeland@stericsson.com
     
  • Use struct net to reference CAIF configuration object instead of static variables.
    Refactor functions caif_connect_client, caif_disconnect_client and squach
    files cfcnfg.c and caif_config_utils.

    Signed-off-by: Sjur Brændeland
    Signed-off-by: David S. Miller

    sjur.brandeland@stericsson.com
     
  • RCU read_lock and refcount is used to protect in-flight packets.

    Use RCU and counters to manage freeing lower part of the CAIF stack if
    CAIF-link layer is removed. Old solution based on delaying removal of
    device is removed.

    When CAIF link layer goes down the use of CAIF link layer is disabled
    (by calling caif_set_phy_state()), but removal and freeing of the
    lower part of the CAIF stack is done when Link layer is unregistered.

    Signed-off-by: Sjur Brændeland
    Signed-off-by: David S. Miller

    sjur.brandeland@stericsson.com
     

18 Apr, 2011

1 commit


12 Apr, 2011

2 commits

  • If CAIF Link Layer returns an error, we no longer try to re-build the
    CAIF packet and resend it. Instead, we simply return any transmission
    errors to the socket client.

    Signed-off-by: Sjur Brændeland
    Signed-off-by: David S. Miller

    Sjur Brændeland
     
  • Cleanup of new CAIF code.
    * make local functions static
    * remove code that is never used
    * expand get_caif_conf() since wrapper is no longer needed
    * make args to comparison functions const
    * rename connect_req_to_link_param to keep exported names
    consistent

    Compile tested only.

    Signed-off-by: Stephen Hemminger
    Acked-by: Sjur Brændeland
    Signed-off-by: David S. Miller

    Stephen Hemminger
     

04 Nov, 2010

1 commit

  • Changes:
    o Bugfix: SO_PRIORITY for SOL_SOCKET could not be handled
    in caif's setsockopt, using the struct sock attribute priority instead.

    o Bugfix: SO_BINDTODEVICE for SOL_SOCKET could not be handled
    in caif's setsockopt, using the struct sock attribute ifindex instead.

    o Wrong assert statement for RFM layer segmentation.

    o CAIF Debug channels was not working over SPI, caif_payload_info
    containing padding info must be initialized.

    o Check on pointer before dereferencing when unregister dev in caif_dev.c

    Signed-off-by: Sjur Braendeland
    Signed-off-by: David S. Miller

    André Carvalho de Matos
     

22 Sep, 2010

1 commit


07 Sep, 2010

2 commits

  • Convert pr_("%s" ..., (struct netdev *)->name ...)
    to netdev_((struct netdev *), ...)

    Signed-off-by: Joe Perches
    Signed-off-by: David S. Miller

    Joe Perches
     
  • This patch standardizes caif message logging prefixes.

    Add #define pr_fmt(fmt) KBUILD_MODNAME ":%s(): " fmt, __func__
    Add missing "\n"s to some logging messages
    Convert pr_warning to pr_warn

    This changes the logging message prefix from CAIF: to caif:
    for all uses but caif_socket.c and chnl_net.c. Those now use
    their filename without extension.

    Signed-off-by: Joe Perches
    Signed-off-by: David S. Miller

    Joe Perches
     

21 Jun, 2010

1 commit