kernel-hacking-2024-linux-s.../net/sctp
Thomas Graf 4c3a5bdae2 sctp: Don't charge for data in sndbuf again when transmitting packet
SCTP charges wmem_alloc via sctp_set_owner_w() in sctp_sendmsg() and via
skb_set_owner_w() in sctp_packet_transmit(). If a sender runs out of
sndbuf it will sleep in sctp_wait_for_sndbuf() and expects to be waken up
by __sctp_write_space().

Buffer space charged via sctp_set_owner_w() is released in sctp_wfree()
which calls __sctp_write_space() directly.

Buffer space charged via skb_set_owner_w() is released via sock_wfree()
which calls sk->sk_write_space() _if_ SOCK_USE_WRITE_QUEUE is not set.
sctp_endpoint_init() sets SOCK_USE_WRITE_QUEUE on all sockets.

Therefore if sctp_packet_transmit() manages to queue up more than sndbuf
bytes, sctp_wait_for_sndbuf() will never be woken up again unless it is
interrupted by a signal.

This could be fixed by clearing the SOCK_USE_WRITE_QUEUE flag but ...

Charging for the data twice does not make sense in the first place, it
leads to overcharging sndbuf by a factor 2. Therefore this patch only
charges a single byte in wmem_alloc when transmitting an SCTP packet to
ensure that the socket stays alive until the packet has been released.

This means that control chunks are no longer accounted for in wmem_alloc
which I believe is not a problem as skb->truesize will typically lead
to overcharging anyway and thus compensates for any control overhead.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
CC: Vlad Yasevich <vyasevic@redhat.com>
CC: Neil Horman <nhorman@tuxdriver.com>
CC: David Miller <davem@davemloft.net>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-09-03 13:24:13 -04:00
..
associola.c sctp: Implement quick failover draft from tsvwg 2012-07-22 12:13:46 -07:00
auth.c
bind_addr.c
chunk.c
command.c
debug.c
endpointola.c
input.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2012-07-19 11:17:30 -07:00
inqueue.c
ipv6.c ipv6: Add redirect support to all protocol icmp error handlers. 2012-07-12 00:25:15 -07:00
Kconfig
Makefile
objcnt.c
output.c sctp: Don't charge for data in sndbuf again when transmitting packet 2012-09-03 13:24:13 -04:00
outqueue.c sctp: Implement quick failover draft from tsvwg 2012-07-22 12:13:46 -07:00
primitive.c
probe.c
proc.c
protocol.c ipv4: Prepare for change of rt->rt_iif encoding. 2012-07-23 16:36:26 -07:00
sm_make_chunk.c sctp: fix sparse warning for sctp_init_cause_fixed 2012-07-16 23:23:52 -07:00
sm_sideeffect.c sctp: Implement quick failover draft from tsvwg 2012-07-22 12:13:46 -07:00
sm_statefuns.c net: Convert net_ratelimit uses to net_<level>_ratelimited 2012-05-15 13:45:03 -04:00
sm_statetable.c
socket.c sctp: Implement quick failover draft from tsvwg 2012-07-22 12:13:46 -07:00
ssnmap.c
sysctl.c sctp: Implement quick failover draft from tsvwg 2012-07-22 12:13:46 -07:00
transport.c Merge branch 'kill_rtcache' 2012-07-22 17:04:15 -07:00
tsnmap.c sctp: be more restrictive in transport selection on bundled sacks 2012-06-30 22:44:35 -07:00
ulpevent.c netvm: prevent a stream-specific deadlock 2012-07-31 18:42:47 -07:00
ulpqueue.c sctp: be more restrictive in transport selection on bundled sacks 2012-06-30 22:44:35 -07:00