Commit 62748f32d501f5d3712a7c372bbb92abc7c62bc7
Committed by
David S. Miller
1 parent
4aa0a03f51
Exists in
master
and in
16 other branches
net: introduce SO_MAX_PACING_RATE
As mentioned in commit afe4fd062416b ("pkt_sched: fq: Fair Queue packet scheduler"), this patch adds a new socket option. SO_MAX_PACING_RATE offers the application the ability to cap the rate computed by transport layer. Value is in bytes per second. u32 val = 1000000; setsockopt(sockfd, SOL_SOCKET, SO_MAX_PACING_RATE, &val, sizeof(val)); To be effectively paced, a flow must use FQ packet scheduler. Note that a packet scheduler takes into account the headers for its computations. The effective payload rate depends on MSS and retransmits if any. I chose to make this pacing rate a SOL_SOCKET option instead of a TCP one because this can be used by other protocols. Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Steinar H. Gunderson <sesse@google.com> Cc: Michael Kerrisk <mtk.manpages@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 18 changed files with 45 additions and 2 deletions Side-by-side Diff
- arch/alpha/include/uapi/asm/socket.h
- arch/avr32/include/uapi/asm/socket.h
- arch/cris/include/uapi/asm/socket.h
- arch/frv/include/uapi/asm/socket.h
- arch/h8300/include/uapi/asm/socket.h
- arch/ia64/include/uapi/asm/socket.h
- arch/m32r/include/uapi/asm/socket.h
- arch/mips/include/uapi/asm/socket.h
- arch/mn10300/include/uapi/asm/socket.h
- arch/parisc/include/uapi/asm/socket.h
- arch/powerpc/include/uapi/asm/socket.h
- arch/s390/include/uapi/asm/socket.h
- arch/sparc/include/uapi/asm/socket.h
- arch/xtensa/include/uapi/asm/socket.h
- include/net/sock.h
- include/uapi/asm-generic/socket.h
- net/core/sock.c
- net/ipv4/tcp_input.c
arch/alpha/include/uapi/asm/socket.h
arch/avr32/include/uapi/asm/socket.h
arch/cris/include/uapi/asm/socket.h
arch/frv/include/uapi/asm/socket.h
arch/h8300/include/uapi/asm/socket.h
arch/ia64/include/uapi/asm/socket.h
arch/m32r/include/uapi/asm/socket.h
arch/mips/include/uapi/asm/socket.h
arch/mn10300/include/uapi/asm/socket.h
arch/parisc/include/uapi/asm/socket.h
arch/powerpc/include/uapi/asm/socket.h
arch/s390/include/uapi/asm/socket.h
arch/sparc/include/uapi/asm/socket.h
arch/xtensa/include/uapi/asm/socket.h
include/net/sock.h
include/uapi/asm-generic/socket.h
net/core/sock.c
... | ... | @@ -914,6 +914,13 @@ |
914 | 914 | } |
915 | 915 | break; |
916 | 916 | #endif |
917 | + | |
918 | + case SO_MAX_PACING_RATE: | |
919 | + sk->sk_max_pacing_rate = val; | |
920 | + sk->sk_pacing_rate = min(sk->sk_pacing_rate, | |
921 | + sk->sk_max_pacing_rate); | |
922 | + break; | |
923 | + | |
917 | 924 | default: |
918 | 925 | ret = -ENOPROTOOPT; |
919 | 926 | break; |
... | ... | @@ -1177,6 +1184,10 @@ |
1177 | 1184 | break; |
1178 | 1185 | #endif |
1179 | 1186 | |
1187 | + case SO_MAX_PACING_RATE: | |
1188 | + v.val = sk->sk_max_pacing_rate; | |
1189 | + break; | |
1190 | + | |
1180 | 1191 | default: |
1181 | 1192 | return -ENOPROTOOPT; |
1182 | 1193 | } |
... | ... | @@ -2319,6 +2330,7 @@ |
2319 | 2330 | sk->sk_ll_usec = sysctl_net_busy_read; |
2320 | 2331 | #endif |
2321 | 2332 | |
2333 | + sk->sk_max_pacing_rate = ~0U; | |
2322 | 2334 | /* |
2323 | 2335 | * Before updating sk_refcnt, we must commit prior changes to memory |
2324 | 2336 | * (Documentation/RCU/rculist_nulls.txt for details) |
net/ipv4/tcp_input.c
... | ... | @@ -735,7 +735,7 @@ |
735 | 735 | if (tp->srtt > 8 + 2) |
736 | 736 | do_div(rate, tp->srtt); |
737 | 737 | |
738 | - sk->sk_pacing_rate = min_t(u64, rate, ~0U); | |
738 | + sk->sk_pacing_rate = min_t(u64, rate, sk->sk_max_pacing_rate); | |
739 | 739 | } |
740 | 740 | |
741 | 741 | /* Calculate rto without backoff. This is the second half of Van Jacobson's |