13 Oct, 2015

1 commit

  • The can subsystem communicates with user space using a bcm_msg_head
    header, which contains two timestamps. This is problematic for
    multiple reasons:

    a) The structure layout is currently incompatible between 64-bit
    user space and 32-bit user space, and cannot work in compat
    mode (other than x32).

    b) The timeval structure layout will change in 32-bit user
    space when we fix the y2038 overflow problem by redefining
    time_t to 64-bit, making new 32-bit user space incompatible
    with the current kernel interface.
    Cars last a long time and often use old kernels, so the actual
    users of this code are the most likely ones to migrate to y2038
    safe user space.

    This tries to work around part of the problem by changing the
    publicly visible user interface in the header, but not the binary
    interface. Fortunately, the values passed around in the structure
    are relative times and do not actually suffer from the y2038
    overflow, so 32-bit is enough here.

    We replace the use of 'struct timeval' with a newly defined
    'struct bcm_timeval' that uses the exact same binary layout
    as before and that still suffers from problem a) but not problem
    b).

    The downside of this approach is that any user space program
    that currently assigns a timeval structure to these members
    rather than writing the tv_sec/tv_usec portions individually
    will suffer a compile-time error when built with an updated
    kernel header. Fixing this error makes it work fine with old
    and new headers though.

    We could address problem a) by using '__u32' or 'int' members
    rather than 'long', but that would have a more significant
    downside in also breaking support for all existing 64-bit user
    binaries that might be using this interface, which is likely
    not acceptable.

    Signed-off-by: Arnd Bergmann
    Acked-by: Oliver Hartkopp
    Cc: linux-can@vger.kernel.org
    Cc: linux-api@vger.kernel.org
    Signed-off-by: Marc Kleine-Budde

    Arnd Bergmann
     

13 Jul, 2015

1 commit

  • Commit 514ac99c64b "can: fix multiple delivery of a single CAN frame for
    overlapping CAN filters" requires the skb->tstamp to be set to check for
    identical CAN skbs.

    Without timestamping to be required by user space applications this timestamp
    was not generated which lead to commit 36c01245eb8 "can: fix loss of CAN frames
    in raw_rcv" - which forces the timestamp to be set in all CAN related skbuffs
    by introducing several __net_timestamp() calls.

    This forces e.g. out of tree drivers which are not using alloc_can{,fd}_skb()
    to add __net_timestamp() after skbuff creation to prevent the frame loss fixed
    in mainline Linux.

    This patch removes the timestamp dependency and uses an atomic counter to
    create an unique identifier together with the skbuff pointer.

    Btw: the new skbcnt element introduced in struct can_skb_priv has to be
    initialized with zero in out-of-tree drivers which are not using
    alloc_can{,fd}_skb() too.

    Signed-off-by: Oliver Hartkopp
    Cc: linux-stable
    Signed-off-by: Marc Kleine-Budde

    Oliver Hartkopp
     

24 Jun, 2015

1 commit


22 Jun, 2015

1 commit

  • As reported by Manfred Schlaegl here

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

    commit 514ac99c64b "can: fix multiple delivery of a single CAN frame for
    overlapping CAN filters" requires the skb->tstamp to be set to check for
    identical CAN skbs.

    As net timestamping is influenced by several players (netstamp_needed and
    netdev_tstamp_prequeue) Manfred missed a proper timestamp which leads to
    CAN frame loss.

    As skb timestamping became now mandatory for CAN related skbs this patch
    makes sure that received CAN skbs always have a proper timestamp set.
    Maybe there's a better solution in the future but this patch fixes the
    CAN frame loss so far.

    Reported-by: Manfred Schlaegl
    Signed-off-by: Oliver Hartkopp
    Cc: linux-stable
    Signed-off-by: Marc Kleine-Budde

    Oliver Hartkopp
     

09 Jun, 2015

1 commit

  • Similar to referencing iptables rules by their line number this UID allows to
    reference created routing jobs, e.g. to alter configured data modifications.

    The UID is an optional non-zero value which can be provided at routing job
    creation time. When the UID is set the UID replaces the data modification
    configuration as job identification attribute e.g. at job removal time.

    Signed-off-by: Oliver Hartkopp
    Signed-off-by: Marc Kleine-Budde

    Oliver Hartkopp
     

11 May, 2015

1 commit


01 Apr, 2015

2 commits

  • The CAN_RAW socket can set multiple CAN identifier specific filters that lead
    to multiple filters in the af_can.c filter processing. These filters are
    indenpendent from each other which leads to logical OR'ed filters when applied.

    This socket option joines the given CAN filters in the way that only CAN frames
    are passed to user space that matched *all* given CAN filters. The semantic for
    the applied filters is therefore changed to a logical AND.

    This is useful especially when the filterset is a combination of filters where
    the CAN_INV_FILTER flag is set in order to notch single CAN IDs or CAN ID
    ranges from the incoming traffic.

    As the raw_rcv() function is executed from NET_RX softirq the introduced
    variables are implemented as per-CPU variables to avoid extensive locking at
    CAN frame reception time.

    Signed-off-by: Oliver Hartkopp
    Signed-off-by: Marc Kleine-Budde

    Oliver Hartkopp
     
  • The CAN_RAW socket can set multiple CAN identifier specific filters that lead
    to multiple filters in the af_can.c filter processing. These filters are
    indenpendent from each other which leads to logical OR'ed filters when applied.

    This patch makes sure that every CAN frame which is filtered for a specific
    socket is only delivered once to the user space. This is independent from the
    number of matching CAN filters of this socket.

    As the raw_rcv() function is executed from NET_RX softirq the introduced
    variables are implemented as per-CPU variables to avoid extensive locking at
    CAN frame reception time.

    Signed-off-by: Oliver Hartkopp
    Signed-off-by: Marc Kleine-Budde

    Oliver Hartkopp
     

10 Mar, 2015

1 commit


09 Mar, 2015

1 commit

  • When accessing CAN network interfaces with AF_PACKET sockets e.g. by dhclient
    this can lead to a skb_under_panic due to missing skb initialisations.

    Add the missing initialisations at the CAN skbuff creation times on driver
    level (rx path) and in the network layer (tx path).

    Reported-by: Austin Schuh
    Reported-by: Daniel Steer
    Signed-off-by: Oliver Hartkopp
    Cc: linux-stable
    Signed-off-by: Marc Kleine-Budde

    Oliver Hartkopp
     

03 Mar, 2015

1 commit

  • After TIPC doesn't depend on iocb argument in its internal
    implementations of sendmsg() and recvmsg() hooks defined in proto
    structure, no any user is using iocb argument in them at all now.
    Then we can drop the redundant iocb argument completely from kinds of
    implementations of both sendmsg() and recvmsg() in the entire
    networking stack.

    Cc: Christoph Hellwig
    Suggested-by: Al Viro
    Signed-off-by: Ying Xue
    Signed-off-by: David S. Miller

    Ying Xue
     

02 Mar, 2015

1 commit


18 Jan, 2015

1 commit

  • Contrary to common expectations for an "int" return, these functions
    return only a positive value -- if used correctly they cannot even
    return 0 because the message header will necessarily be in the skb.

    This makes the very common pattern of

    if (genlmsg_end(...) < 0) { ... }

    be a whole bunch of dead code. Many places also simply do

    return nlmsg_end(...);

    and the caller is expected to deal with it.

    This also commonly (at least for me) causes errors, because it is very
    common to write

    if (my_function(...))
    /* error condition */

    and if my_function() does "return nlmsg_end()" this is of course wrong.

    Additionally, there's not a single place in the kernel that actually
    needs the message length returned, and if anyone needs it later then
    it'll be very easy to just use skb->len there.

    Remove this, and make the functions void. This removes a bunch of dead
    code as described above. The patch adds lines because I did

    - return nlmsg_end(...);
    + nlmsg_end(...);
    + return 0;

    I could have preserved all the function's return values by returning
    skb->len, but instead I've audited all the places calling the affected
    functions and found that none cared. A few places actually compared
    the return value with < 0 with no change in behaviour, so I opted for the more
    efficient version.

    One instance of the error I've made numerous times now is also present
    in net/phonet/pn_netlink.c in the route_dumpit() function - it didn't
    check for
    Signed-off-by: David S. Miller

    Johannes Berg
     

08 Dec, 2014

2 commits

  • Fix various spelling errors in the comments of the CAN modules.

    Signed-off-by: Jeremiah Mahler
    Acked-by: Oliver Hartkopp
    Signed-off-by: Marc Kleine-Budde

    Jeremiah Mahler
     
  • Several CAN modules use a design pattern with a banner[] variable at the
    top which defines a string that is used once during init to print the
    banner. The string is also embedded with KERN_INFO which makes it
    printk() specific.

    Improve the code by eliminating the banner[] variable and moving the
    string to where it is printed. Then switch from printk(KERN_INFO to
    pr_info() for the lines that were changed.

    Signed-off-by: Jeremiah Mahler
    Acked-by: Oliver Hartkopp
    Signed-off-by: Marc Kleine-Budde

    Jeremiah Mahler
     

24 Nov, 2014

2 commits


19 May, 2014

2 commits


25 Apr, 2014

1 commit

  • It is possible by passing a netlink socket to a more privileged
    executable and then to fool that executable into writing to the socket
    data that happens to be valid netlink message to do something that
    privileged executable did not intend to do.

    To keep this from happening replace bare capable and ns_capable calls
    with netlink_capable, netlink_net_calls and netlink_ns_capable calls.
    Which act the same as the previous calls except they verify that the
    opener of the socket had the desired permissions as well.

    Reported-by: Andy Lutomirski
    Signed-off-by: "Eric W. Biederman"
    Signed-off-by: David S. Miller

    Eric W. Biederman
     

03 Mar, 2014

1 commit

  • In commit e2d265d3b587 (canfd: add support for CAN FD in CAN_RAW sockets)
    CAN FD frames with a payload length up to 8 byte are passed to legacy
    sockets where the CAN FD support was not enabled by the application.

    After some discussions with developers at a fair this well meant feature
    leads to confusion as no clean switch for CAN / CAN FD is provided to the
    application programmer. Additionally a compatibility like this for legacy
    CAN_RAW sockets requires some compatibility handling for the sending, e.g.
    make CAN2.0 frames a CAN FD frame with BRS at transmission time (?!?).

    This will become a mess when people start to develop applications with
    real CAN FD hardware. This patch reverts the bad compatibility code
    together with the documentation describing the removed feature.

    Acked-by: Stephane Grosjean
    Signed-off-by: Oliver Hartkopp
    Signed-off-by: Marc Kleine-Budde

    Oliver Hartkopp
     

31 Jan, 2014

2 commits

  • linux-can-fixes-for-3.14-20140129

    Marc Kleine-Budde says:

    ====================
    Arnd Bergmann provides a fix for the flexcan driver, enabling compilation on
    all combinations of big and little endian on ARM and PowerPc. A patch by Ira W.
    Snyder fixes uninitialized variable warnings in the janz-ican3 driver.
    Rostislav Lisovy contributes a patch to propagate the SO_PRIORITY of raw
    sockets to skbs.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     
  • Self generated skbuffs in net/can/bcm.c are setting a skb->sk reference but
    no explicit destructor which is enforced since Linux 3.11 with commit
    376c7311bdb6 (net: add a temporary sanity check in skb_orphan()).

    This patch adds some helper functions to make sure that a destructor is
    properly defined when a sock reference is assigned to a CAN related skb.
    To create an unshared skb owned by the original sock a common helper function
    has been introduced to replace open coded functions to create CAN echo skbs.

    Signed-off-by: Oliver Hartkopp
    Tested-by: Andre Naujoks
    Reviewed-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Oliver Hartkopp
     

30 Jan, 2014

1 commit

  • This allows controlling certain queueing disciplines by setting the
    socket's SO_PRIORITY option.

    For example, with the default pfifo_fast queueing discipline, which
    provides three priorities, socket priority TC_PRIO_CONTROL means
    higher than default and TC_PRIO_BULK means lower than default.

    Signed-off-by: Rostislav Lisovy
    Signed-off-by: Michal Sojka
    Acked-by: Oliver Hartkopp
    Signed-off-by: Marc Kleine-Budde

    Rostislav Lisovy
     

19 Jan, 2014

1 commit

  • This is a follow-up patch to f3d3342602f8bc ("net: rework recvmsg
    handler msg_name and msg_namelen logic").

    DECLARE_SOCKADDR validates that the structure we use for writing the
    name information to is not larger than the buffer which is reserved
    for msg->msg_name (which is 128 bytes). Also use DECLARE_SOCKADDR
    consistently in sendmsg code paths.

    Signed-off-by: Steffen Hurrle
    Suggested-by: Hannes Frederic Sowa
    Acked-by: Hannes Frederic Sowa
    Signed-off-by: David S. Miller

    Steffen Hurrle
     

15 Jan, 2014

1 commit


21 Dec, 2013

1 commit

  • In commit be286bafe1f4069094865264f29805854c5788bf ("can: gw: add a variable
    limit for CAN frame routings") the detection of the frame routing has been
    changed. The former solution required dev->header_ops to be unused (== NULL).

    I missed to remove the obsolete checks in the original commit - so here it is.

    Signed-off-by: Oliver Hartkopp
    Signed-off-by: Marc Kleine-Budde

    Oliver Hartkopp
     

16 Nov, 2013

1 commit

  • Pull trivial tree updates from Jiri Kosina:
    "Usual earth-shaking, news-breaking, rocket science pile from
    trivial.git"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (23 commits)
    doc: usb: Fix typo in Documentation/usb/gadget_configs.txt
    doc: add missing files to timers/00-INDEX
    timekeeping: Fix some trivial typos in comments
    mm: Fix some trivial typos in comments
    irq: Fix some trivial typos in comments
    NUMA: fix typos in Kconfig help text
    mm: update 00-INDEX
    doc: Documentation/DMA-attributes.txt fix typo
    DRM: comment: `halve' -> `half'
    Docs: Kconfig: `devlopers' -> `developers'
    doc: typo on word accounting in kprobes.c in mutliple architectures
    treewide: fix "usefull" typo
    treewide: fix "distingush" typo
    mm/Kconfig: Grammar s/an/a/
    kexec: Typo s/the/then/
    Documentation/kvm: Update cpuid documentation for steal time and pv eoi
    treewide: Fix common typo in "identify"
    __page_to_pfn: Fix typo in comment
    Correct some typos for word frequency
    clk: fixed-factor: Fix a trivial typo
    ...

    Linus Torvalds
     

20 Oct, 2013

1 commit


14 Oct, 2013

1 commit


30 Aug, 2013

1 commit

  • Usually the received CAN frames can be processed/routed as much as 'max_hops'
    times (which is given at module load time of the can-gw module).
    Introduce a new configuration option to reduce the number of possible hops
    for a specific gateway rule to a value smaller then max_hops.

    Signed-off-by: Oliver Hartkopp
    Signed-off-by: Marc Kleine-Budde

    Oliver Hartkopp
     

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
     

02 May, 2013

1 commit

  • Pull VFS updates from Al Viro,

    Misc cleanups all over the place, mainly wrt /proc interfaces (switch
    create_proc_entry to proc_create(), get rid of the deprecated
    create_proc_read_entry() in favor of using proc_create_data() and
    seq_file etc).

    7kloc removed.

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (204 commits)
    don't bother with deferred freeing of fdtables
    proc: Move non-public stuff from linux/proc_fs.h to fs/proc/internal.h
    proc: Make the PROC_I() and PDE() macros internal to procfs
    proc: Supply a function to remove a proc entry by PDE
    take cgroup_open() and cpuset_open() to fs/proc/base.c
    ppc: Clean up scanlog
    ppc: Clean up rtas_flash driver somewhat
    hostap: proc: Use remove_proc_subtree()
    drm: proc: Use remove_proc_subtree()
    drm: proc: Use minor->index to label things, not PDE->name
    drm: Constify drm_proc_list[]
    zoran: Don't print proc_dir_entry data in debug
    reiserfs: Don't access the proc_dir_entry in r_open(), r_start() r_show()
    proc: Supply an accessor for getting the data from a PDE's parent
    airo: Use remove_proc_subtree()
    rtl8192u: Don't need to save device proc dir PDE
    rtl8187se: Use a dir under /proc/net/r8180/
    proc: Add proc_mkdir_data()
    proc: Move some bits from linux/proc_fs.h to linux/{of.h,signal.h,tty.h}
    proc: Move PDE_NET() to fs/proc/proc_net.c
    ...

    Linus Torvalds
     

23 Apr, 2013

1 commit

  • Conflicts:
    drivers/net/ethernet/emulex/benet/be_main.c
    drivers/net/ethernet/intel/igb/igb_main.c
    drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
    include/net/scm.h
    net/batman-adv/routing.c
    net/ipv4/tcp_input.c

    The e{uid,gid} --> {uid,gid} credentials fix conflicted with the
    cleanup in net-next to now pass cred structs around.

    The be2net driver had a bug fix in 'net' that overlapped with the VLAN
    interface changes by Patrick McHardy in net-next.

    An IGB conflict existed because in 'net' the build_skb() support was
    reverted, and in 'net-next' there was a comment style fix within that
    code.

    Several batman-adv conflicts were resolved by making sure that all
    calls to batadv_is_my_mac() are changed to have a new bat_priv first
    argument.

    Eric Dumazet's TS ECR fix in TCP in 'net' conflicted with the F-RTO
    rewrite in 'net-next', mostly overlapping changes.

    Thanks to Stephen Rothwell and Antonio Quartulli for help with several
    of these merge resolutions.

    Signed-off-by: David S. Miller

    David S. Miller
     

15 Apr, 2013

1 commit

  • Currently, sock_tx_timestamp() always returns 0. The comment that
    describes the sock_tx_timestamp() function wrongly says that it
    returns an error when an invalid argument is passed (from commit
    20d4947353be, ``net: socket infrastructure for SO_TIMESTAMPING'').
    Make the function void, so that we can also remove all the unneeded
    if conditions that check for such a _non-existant_ error case in the
    output path.

    Signed-off-by: Daniel Borkmann
    Signed-off-by: David S. Miller

    Daniel Borkmann
     

10 Apr, 2013

1 commit

  • The only part of proc_dir_entry the code outside of fs/proc
    really cares about is PDE(inode)->data. Provide a helper
    for that; static inline for now, eventually will be moved
    to fs/proc, along with the knowledge of struct proc_dir_entry
    layout.

    Signed-off-by: Al Viro

    Al Viro
     

09 Apr, 2013

1 commit


22 Mar, 2013

1 commit


19 Mar, 2013

1 commit

  • The rework of the kernel hlist implementation "hlist: drop the node parameter
    from iterators" (b67bfe0d42cac56c512dd5da4b1b347a23f4b70a) created some
    fallout in the form of non matching comments and obsolete code.

    Additionally to the cleanup this patch adds a WARN() statement to catch the
    caller of the wrong filter removal request.

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

    Oliver Hartkopp
     

11 Mar, 2013

1 commit