linux/net/core
Herbert Xu f845172531 cls_cgroup: Store classid in struct sock
Up until now cls_cgroup has relied on fetching the classid out of
the current executing thread.  This runs into trouble when a packet
processing is delayed in which case it may execute out of another
thread's context.

Furthermore, even when a packet is not delayed we may fail to
classify it if soft IRQs have been disabled, because this scenario
is indistinguishable from one where a packet unrelated to the
current thread is processed by a real soft IRQ.

In fact, the current semantics is inherently broken, as a single
skb may be constructed out of the writes of two different tasks.
A different manifestation of this problem is when the TCP stack
transmits in response of an incoming ACK.  This is currently
unclassified.

As we already have a concept of packet ownership for accounting
purposes in the skb->sk pointer, this is a natural place to store
the classid in a persistent manner.

This patch adds the cls_cgroup classid in struct sock, filling up
an existing hole on 64-bit :)

The value is set at socket creation time.  So all sockets created
via socket(2) automatically gains the ID of the thread creating it.
Whenever another process touches the socket by either reading or
writing to it, we will change the socket classid to that of the
process if it has a valid (non-zero) classid.

For sockets created on inbound connections through accept(2), we
inherit the classid of the original listening socket through
sk_clone, possibly preceding the actual accept(2) call.

In order to minimise risks, I have not made this the authoritative
classid.  For now it is only used as a backup when we execute
with soft IRQs disabled.  Once we're completely happy with its
semantics we can use it as the sole classid.

Footnote: I have rearranged the error path on cls_group module
creation.  If we didn't do this, then there is a window where
someone could create a tc rule using cls_group before the cgroup
subsystem has been registered.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
2010-05-24 00:12:34 -07:00
..
Makefile net: convert multicast list to list_head 2010-04-03 14:22:15 -07:00
datagram.c net: skb_free_datagram_locked() fix 2010-05-03 23:18:14 -07:00
dev.c net-2.6 : V2 - fix dev_get_valid_name 2010-05-23 23:24:36 -07:00
dev_addr_lists.c net: include linux/proc_fs.h in dev_addr_lists.c 2010-04-07 16:46:36 -07:00
drop_monitor.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
dst.c dst: don't inline dst_ifdown 2010-04-13 03:32:44 -07:00
ethtool.c net: Remove unnecessary semicolons after switch statements 2010-05-17 17:44:35 -07:00
fib_rules.c net: fib_rules: mark arguments to fib_rules_register const and __net_initdata 2010-04-26 16:02:04 +02:00
filter.c net: Socket filter ancilliary data access for skb->dev->type 2010-04-22 16:05:44 -07:00
flow.c flow: delayed deletion of flow cache entries 2010-04-07 03:43:20 -07:00
gen_estimator.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
gen_stats.c pkt_sched: gen_estimator: Dont report fake rate estimators 2009-10-07 01:07:42 -07:00
iovec.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
kmap_skb.h
link_watch.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
neighbour.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
net-sysfs.c rps: static functions 2010-04-19 14:40:57 -07:00
net-sysfs.h netns: Fix device renaming for sysfs 2008-05-02 17:00:58 -07:00
net-traces.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
net_namespace.c net: disallow to use net_assign_generic externally 2010-04-27 15:49:02 -07:00
netevent.c [NET]: net/core/netevent.c should #include <net/netevent.h> 2007-07-05 17:40:27 -07:00
netpoll.c netpoll: add generic support for bridge and bonding devices 2010-05-06 00:47:21 -07:00
pktgen.c pktgen node allocation 2010-03-21 20:33:36 -07:00
request_sock.c net: convert BUG_TRAP to generic WARN_ON 2008-07-25 21:43:18 -07:00
rtnetlink.c rtnetlink: Fix error handling in do_setlink() 2010-05-23 23:11:08 -07:00
scm.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
skbuff.c gro: Fix bogus gso_size on the first fraglist entry 2010-05-20 23:07:56 -07:00
sock.c cls_cgroup: Store classid in struct sock 2010-05-24 00:12:34 -07:00
stream.c net: sock_def_readable() and friends RCU conversion 2010-05-01 15:00:15 -07:00
sysctl_net_core.c net: Consistent skb timestamping 2010-05-15 23:57:10 -07:00
user_dma.c net/core/user_dma.c: Use frag list abstraction interfaces. 2009-06-09 00:19:10 -07:00
utils.c printk: Remove ratelimit.h from kernel.h 2009-09-22 16:18:09 +02:00