24 Jun, 2010

1 commit


11 Jun, 2010

1 commit

  • commit 66018506e15b (ip: Router Alert RCU conversion) introduced RCU
    lookups to ip_call_ra_chain(). It missed proper deinit phase :
    When ip_ra_control() deletes an ip_ra_chain, it should make sure
    ip_call_ra_chain() users can not start to use socket during the rcu
    grace period. It should also delay the sock_put() after the grace
    period, or we risk a premature socket freeing and corruptions, as
    raw sockets are not rcu protected yet.

    This delay avoids using expensive atomic_inc_not_zero() in
    ip_call_ra_chain().

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

    Eric Dumazet
     

08 Jun, 2010

1 commit


29 Apr, 2010

1 commit

  • When queueing a skb to socket, we can immediately release its dst if
    target socket do not use IP_CMSG_PKTINFO.

    tcp_data_queue() can drop dst too.

    This to benefit from a hot cache line and avoid the receiver, possibly
    on another cpu, to dirty this cache line himself.

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

    Eric Dumazet
     

12 Apr, 2010

1 commit


02 Apr, 2010

1 commit


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
     

12 Jan, 2010

1 commit

  • This patch adds the kernel portions needed to implement
    RFC 5082 Generalized TTL Security Mechanism (GTSM).
    It is a lightweight security measure against forged
    packets causing DoS attacks (for BGP).

    This is already implemented the same way in BSD kernels.
    For the necessary Quagga patch
    http://www.gossamer-threads.com/lists/quagga/dev/17389

    Description from Cisco
    http://www.cisco.com/en/US/docs/ios/12_3t/12_3t7/feature/guide/gt_btsh.html

    It does add one byte to each socket structure, but I did
    a little rearrangement to reuse a hole (on 64 bit), but it
    does grow the structure on 32 bit

    This should be documented on ip(4) man page and the Glibc in.h
    file also needs update. IPV6_MINHOPLIMIT should also be added
    (although BSD doesn't support that).

    Only TCP is supported, but could also be added to UDP, DCCP, SCTP
    if desired.

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

    Stephen Hemminger
     

29 Oct, 2009

1 commit


27 Oct, 2009

1 commit


20 Oct, 2009

2 commits

  • Use symbols instead of magic constants while checking PMTU discovery
    setsockopt.

    Remove redundant test in ip_rt_frag_needed() (done by caller).

    Signed-off-by: John Dykstra
    Signed-off-by: David S. Miller

    John Dykstra
     
  • ipv4/ipv6 setsockopt(IP_MULTICAST_IF) have dubious __dev_get_by_index() calls.

    This function should be called only with RTNL or dev_base_lock held, or reader
    could see a corrupt hash chain and eventually enter an endless loop.

    Fix is to call dev_get_by_index()/dev_put().

    If this happens to be performance critical, we could define a new dev_exist_by_index()
    function to avoid touching dev refcount.

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

    Eric Dumazet
     

19 Oct, 2009

1 commit

  • In order to have better cache layouts of struct sock (separate zones
    for rx/tx paths), we need this preliminary patch.

    Goal is to transfert fields used at lookup time in the first
    read-mostly cache line (inside struct sock_common) and move sk_refcnt
    to a separate cache line (only written by rx path)

    This patch adds inet_ prefix to daddr, rcv_saddr, dport, num, saddr,
    sport and id fields. This allows a future patch to define these
    fields as macros, like sk_refcnt, without name clashes.

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

    Eric Dumazet
     

01 Oct, 2009

1 commit

  • This provides safety against negative optlen at the type
    level instead of depending upon (sometimes non-trivial)
    checks against this sprinkled all over the the place, in
    each and every implementation.

    Based upon work done by Arjan van de Ven and feedback
    from Linus Torvalds.

    Signed-off-by: David S. Miller

    David S. Miller
     

25 Sep, 2009

1 commit

  • Due to man page of setsockopt, if optlen is not valid, kernel should return
    -EINVAL. But a simple testcase as following, errno is 0, which means setsockopt
    is successful.
    addr.s_addr = inet_addr("192.1.2.3");
    setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF, &addr, 1);
    printf("errno is %d\n", errno);

    Xiaotian Feng(dfeng@redhat.com) caught the bug. We fix it firstly checking
    the availability of optlen and then dealing with the logic like other options.

    Reported-by: Xiaotian Feng
    Signed-off-by: Shan Wei
    Acked-by: Alexey Kuznetsov
    Signed-off-by: David S. Miller

    Shan Wei
     

03 Jun, 2009

1 commit

  • Define skb_rtable(const struct sk_buff *skb) accessor to get rtable from skb

    Delete skb->rtable field

    Setting rtable is not allowed, just set dst instead as rtable is an alias.

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

    Eric Dumazet
     

02 Jun, 2009

2 commits

  • After some discussion offline with Christoph Lameter and David Stevens
    regarding multicast behaviour in Linux, I'm submitting a slightly
    modified patch from the one Christoph submitted earlier.

    This patch provides a new socket option IP_MULTICAST_ALL.

    In this case, default behaviour is _unchanged_ from the current
    Linux standard. The socket option is set by default to provide
    original behaviour. Sockets wishing to receive data only from
    multicast groups they join explicitly will need to clear this
    socket option.

    Signed-off-by: Nivedita Singhvi
    Signed-off-by: Christoph Lameter
    Acked-by: David Stevens
    Signed-off-by: David S. Miller

    Nivedita Singhvi
     
  • Pure cleanups

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

    Eric Dumazet
     

20 Nov, 2008

1 commit

  • Fixes sparse warnings:
    net/ipv4/ip_sockglue.c:146:15: warning: incorrect type in assignment (different base types)
    net/ipv4/ip_sockglue.c:146:15: expected restricted __be16 [assigned] [usertype] sin_port
    net/ipv4/ip_sockglue.c:146:15: got unsigned short [unsigned] [short] [usertype]
    net/ipv4/ip_sockglue.c:130:6: warning: symbol 'ip_cmsg_recv_dstaddr' was not declared. Should it be static?

    Signed-off-by: Harvey Harrison
    Signed-off-by: David S. Miller

    Harvey Harrison
     

17 Nov, 2008

1 commit

  • In case UDP traffic is redirected to a local UDP socket,
    the originally addressed destination address/port
    cannot be recovered with the in-kernel tproxy.

    This patch adds an IP_RECVORIGDSTADDR sockopt that enables
    a IP_ORIGDSTADDR ancillary message in recvmsg(). This
    ancillary message contains the original destination address/port
    of the packet being received.

    Signed-off-by: Balazs Scheidler
    Signed-off-by: David S. Miller

    Balazs Scheidler
     

03 Nov, 2008

1 commit


01 Oct, 2008

1 commit


12 Jun, 2008

1 commit


29 Apr, 2008

1 commit


28 Apr, 2008

1 commit


14 Apr, 2008

1 commit


10 Apr, 2008

1 commit

  • This fixes kernel bugzilla 10371.

    As reported by M.Piechaczek@osmosys.tv, if we try to grab a
    char sized socket option value, as in:

    unsigned char ttl = 255;
    socklen_t len = sizeof(ttl);
    setsockopt(socket, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, &len);

    getsockopt(socket, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, &len);

    The ttl returned will be wrong on big-endian, and on both little-
    endian and big-endian the next three bytes in userspace are written
    with garbage.

    It's because of this test in do_ip_getsockopt():

    if (len < sizeof(int) && len > 0 && val>=0 && val

    David S. Miller
     

26 Mar, 2008

1 commit


25 Mar, 2008

3 commits


18 Mar, 2008

2 commits


06 Mar, 2008

1 commit


13 Feb, 2008

1 commit

  • Various RFCs have all sorts of things to say about the CS field of the
    DSCP value. In particular they try to make the distinction between
    values that should be used by "user applications" and things like
    routing daemons.

    This seems to have influenced the CAP_NET_ADMIN check which exists for
    IP_TOS socket option settings, but in fact it has an off-by-one error
    so it wasn't allowing CS5 which is meant for "user applications" as
    well.

    Further adding to the inconsistency and brokenness here, IPV6 does not
    validate the DSCP values specified for the IPV6_TCLASS socket option.

    The real actual uses of these TOS values are system specific in the
    final analysis, and these RFC recommendations are just that, "a
    recommendation". In fact the standards very purposefully use
    "SHOULD" and "SHOULD NOT" when describing how these values can be
    used.

    In the final analysis the only clean way to provide consistency here
    is to remove the CAP_NET_ADMIN check. The alternatives just don't
    work out:

    1) If we add the CAP_NET_ADMIN check to ipv6, this can break existing
    setups.

    2) If we just fix the off-by-one error in the class comparison in
    IPV4, certain DSCP values can be used in IPV6 but not IPV4 by
    default. So people will just ask for a sysctl asking to
    override that.

    I checked several other freely available kernel trees and they
    do not make any privilege checks in this area like we do. For
    the BSD stacks, this goes back all the way to Stevens Volume 2
    and beyond.

    Signed-off-by: David S. Miller

    David S. Miller
     

29 Jan, 2008

1 commit


07 Nov, 2007

1 commit

  • The #idfed CONFIG_IP_MROUTE is sometimes places inside the if-s,
    which looks completely bad. Similar ifdefs inside the functions
    looks a bit better, but they are also not recommended to be used.

    Provide an ifdef-ed ip_mroute_opt() helper to cleanup the code.

    Signed-off-by: Pavel Emelyanov
    Signed-off-by: David S. Miller

    Pavel Emelyanov
     

11 Oct, 2007

2 commits

  • Fix a bunch of sparse warnings. Mostly about 0 used as
    NULL pointer, and shadowed variable declarations.
    One notable case was that hash size should have been unsigned.

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

    Stephen Hemminger
     
  • This patch makes most of the generic device layer network
    namespace safe. This patch makes dev_base_head a
    network namespace variable, and then it picks up
    a few associated variables. The functions:
    dev_getbyhwaddr
    dev_getfirsthwbytype
    dev_get_by_flags
    dev_get_by_name
    __dev_get_by_name
    dev_get_by_index
    __dev_get_by_index
    dev_ioctl
    dev_ethtool
    dev_load
    wireless_process_ioctl

    were modified to take a network namespace argument, and
    deal with it.

    vlan_ioctl_set and brioctl_set were modified so their
    hooks will receive a network namespace argument.

    So basically anthing in the core of the network stack that was
    affected to by the change of dev_base was modified to handle
    multiple network namespaces. The rest of the network stack was
    simply modified to explicitly use &init_net the initial network
    namespace. This can be fixed when those components of the network
    stack are modified to handle multiple network namespaces.

    For now the ifindex generator is left global.

    Fundametally ifindex numbers are per namespace, or else
    we will have corner case problems with migration when
    we get that far.

    At the same time there are assumptions in the network stack
    that the ifindex of a network device won't change. Making
    the ifindex number global seems a good compromise until
    the network stack can cope with ifindex changes when
    you change namespaces, and the like.

    Signed-off-by: Eric W. Biederman
    Signed-off-by: David S. Miller

    Eric W. Biederman
     

27 Aug, 2007

1 commit