14 Mar, 2016

1 commit

  • This patch updates all instances of csum_tcpudp_magic and
    csum_tcpudp_nofold to reflect the types that are usually used as the source
    inputs. For example the protocol field is populated based on nexthdr which
    is actually an unsigned 8 bit value. The length is usually populated based
    on skb->len which is an unsigned integer.

    This addresses an issue in which the IPv6 function csum_ipv6_magic was
    generating a checksum using the full 32b of skb->len while
    csum_tcpudp_magic was only using the lower 16 bits. As a result we could
    run into issues when attempting to adjust the checksum as there was no
    protocol agnostic way to update it.

    With this change the value is still truncated as many architectures use
    "(len + proto) << 8", however this truncation only occurs for values
    greater than 16776960 in length and as such is unlikely to occur as we stop
    the inner headers at ~64K in size.

    I did have to make a few minor changes in the arm, mn10300, nios2, and
    score versions of the function in order to support these changes as they
    were either using things such as an OR to combine the protocol and length,
    or were using ntohs to convert the length which would have truncated the
    value.

    I also updated a few spots in terms of whitespace and type differences for
    the addresses. Most of this was just to make sure all of the definitions
    were in sync going forward.

    Signed-off-by: Alexander Duyck
    Signed-off-by: David S. Miller

    Alexander Duyck
     

30 Jan, 2015

1 commit

  • Fixed commit added from64to32 under _#ifndef do_csum_ but used it
    under _#ifndef csum_tcpudp_nofold_, breaking some builds (Fengguang's
    robot reported TILEGX's). Move from64to32 under the latter.

    Fixes: 150ae0e94634 ("lib/checksum.c: fix carry in csum_tcpudp_nofold")
    Reported-by: kbuild test robot
    Signed-off-by: Karl Beldan
    Cc: Eric Dumazet
    Cc: David S. Miller
    Signed-off-by: David S. Miller

    karl beldan
     

29 Jan, 2015

1 commit

  • The carry from the 64->32bits folding was dropped, e.g with:
    saddr=0xFFFFFFFF daddr=0xFF0000FF len=0xFFFF proto=0 sum=1,
    csum_tcpudp_nofold returned 0 instead of 1.

    Signed-off-by: Karl Beldan
    Cc: Al Viro
    Cc: Eric Dumazet
    Cc: Arnd Bergmann
    Cc: Mike Frysinger
    Cc: netdev@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Cc: stable@vger.kernel.org
    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    karl beldan
     

11 Feb, 2013

1 commit


08 Mar, 2012

1 commit


07 Jul, 2011

1 commit

  • Reduce the number of variables modified by the loop in do_csum() by 1,
    which seems like a good idea. On Nios II (a RISC CPU with 3-operand
    instruction set) it reduces the loop from 7 to 6 instructions, including
    the conditional branch.

    Signed-off-by: Ian Abbott
    Signed-off-by: David S. Miller

    Ian Abbott
     

03 Nov, 2009

3 commits

  • When do_csum gets unaligned data, we really need to treat
    the first byte as an even byte, not an odd byte, because
    we swap the two halves later.

    Found by Mike's checksum-selftest module.

    Reported-by: Mike Frysinger
    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     
  • Mike Frysinger suggested that do_csum should be optional
    so that an architecture can use the generic checksum code
    but still provide an optimized fast-path for the most
    critical function.

    This can mean an implementation using inline assembly,
    or in case of Alpha one using 64-bit arithmetic in C.

    Cc: Mike Frysinger
    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     
  • The use of 'unsigned long' variables in the 32-bit part of do_csum()
    is confusing at best, and potentially broken for long input on 64-bit
    machines.

    This changes the code to use 'unsigned int' instead, which makes
    the code behave in the same (correct) way on both 32 and 64 bit
    machines.

    Reported-by: Linus Torvalds
    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     

19 Jun, 2009

1 commit

  • The new generic checksum code has a small dependency on endianess and
    worked only on big-endian systems. I could not find a nice efficient
    way to express this, so I added an #ifdef. Using
    'result += le16_to_cpu(*buff);' would have worked as well, but
    would be slightly less efficient on big-endian systems and IMHO
    would not be clearer.

    Also fix a bug that prevents this from working on 64-bit machines.
    If you have a 64-bit CPU and want to use the generic checksum
    code, you should probably do some more optimizations anyway, but
    at least the code should not break.

    Reported-by: Mike Frysinger
    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     

12 Jun, 2009

1 commit

  • Add a generic (unoptimized) implementation of checksum.c in pure C
    for use by all architectures that cannot be bother with implementing
    their own version.

    Based on microblaze code by Michal Simek

    Cc: Michal Simek
    Signed-off-by: Remis Lima Baima
    Signed-off-by: Arnd Bergmann

    Arnd Bergmann