Bug 273509 - TCP(4): Can not change loader tunable net.inet.tcp.fastopen.ccache_bucket_limit via /boot/loader.conf
Summary: TCP(4): Can not change loader tunable net.inet.tcp.fastopen.ccache_bucket_lim...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 15.0-CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Zhenlei Huang
URL: https://reviews.freebsd.org/D41691
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-02 04:41 UTC by Zhenlei Huang
Modified: 2023-09-06 04:57 UTC (History)
1 user (show)

See Also:
zlei: mfc-stable14+
zlei: mfc-stable13+
zlei: mfc-stable12+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zhenlei Huang freebsd_committer freebsd_triage 2023-09-02 04:41:14 UTC
Spot this while testing https://reviews.freebsd.org/D41525 .

As per the man page TCP(4):
>      fastopen.ccache_bucket_limit
>                            The maximum number of entries in a client cookie
>                            cache bucket.  The default value can be tuned with
>                            the TCP_FASTOPEN_CCACHE_BUCKET_LIMIT_DEFAULT
>                            kernel option or by setting
>                            net.inet.tcp.fastopen_ccache_bucket_limit in the
>                            loader(8).

the `net.inet.tcp.fastopen.ccache_bucket_limit` should be able to tuned the value.


Steps to repeat:

```
# echo "net.inet.tcp.fastopen.ccache_bucket_limit=32" >> /boot/loader.conf
# reboot
....
# sysctl net.inet.tcp.fastopen.ccache_bucket_limit
16
```

Expected value:
```
# sysctl net.inet.tcp.fastopen.ccache_bucket_limit
32
```
Comment 1 Herbert J. Skuhra 2023-09-02 05:31:47 UTC
Setting it in /etc/sysctl.conf works, right? The following should work too:

# sysctl net.inet.tcp.fastopen.ccache_bucket_limit=32
Comment 2 Zhenlei Huang freebsd_committer freebsd_triage 2023-09-02 05:57:54 UTC
(In reply to Herbert J. Skuhra from comment #1)
> Setting it in /etc/sysctl.conf works, right?

Yes.

> The following should work too:
> # sysctl net.inet.tcp.fastopen.ccache_bucket_limit=32

Yes.
Comment 3 Zhenlei Huang freebsd_committer freebsd_triage 2023-09-02 06:43:40 UTC
Proposed fix, quite simple. https://reviews.freebsd.org/D41691
Comment 4 commit-hook freebsd_committer freebsd_triage 2023-09-02 20:36:48 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=224aec05e732bb97a0d3c91142973b98a91238d1

commit 224aec05e732bb97a0d3c91142973b98a91238d1
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2023-09-02 20:34:07 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2023-09-02 20:34:07 +0000

    tcp: Initialize the maximum number of entries in a client cookie cache bucket

    This vnet loader tunable is defined with SYSCTL_PROC, thus will not be
    initialized by kernel on vnet creating and will always have the default
    value TCP_FASTOPEN_CCACHE_BUCKET_LIMIT_DEFAULT.

    Fix by fetching the value from the corresponding kernel environment during
    vnet constructing.

    PR:             273509
    Reviewed by:    #transport, tuexen
    Fixes:  c560df6f12f1 This is an implementation of the client side of TCP Fast Open (TFO) [RFC7413]
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D41691

 sys/netinet/tcp_fastopen.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2023-09-06 04:10:10 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=144851777edad9522390036d3073ea656d7b648d

commit 144851777edad9522390036d3073ea656d7b648d
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2023-09-02 20:34:07 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2023-09-06 04:07:49 +0000

    tcp: Initialize the maximum number of entries in a client cookie cache bucket

    This vnet loader tunable is defined with SYSCTL_PROC, thus will not be
    initialized by kernel on vnet creating and will always have the default
    value TCP_FASTOPEN_CCACHE_BUCKET_LIMIT_DEFAULT.

    Fix by fetching the value from the corresponding kernel environment during
    vnet constructing.

    PR:             273509
    Reviewed by:    #transport, tuexen
    Approved by:    re (gjb)
    Fixes:  c560df6f12f1 This is an implementation of the client side of TCP Fast Open (TFO) [RFC7413]
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D41691

    (cherry picked from commit 224aec05e732bb97a0d3c91142973b98a91238d1)

 sys/netinet/tcp_fastopen.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2023-09-06 04:20:16 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=3fc299d68897a0748d96510de5f191f5a8249216

commit 3fc299d68897a0748d96510de5f191f5a8249216
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2023-09-02 20:34:07 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2023-09-06 04:18:29 +0000

    tcp: Initialize the maximum number of entries in a client cookie cache bucket

    This vnet loader tunable is defined with SYSCTL_PROC, thus will not be
    initialized by kernel on vnet creating and will always have the default
    value TCP_FASTOPEN_CCACHE_BUCKET_LIMIT_DEFAULT.

    Fix by fetching the value from the corresponding kernel environment during
    vnet constructing.

    PR:             273509
    Reviewed by:    #transport, tuexen
    Fixes:  c560df6f12f1 This is an implementation of the client side of TCP Fast Open (TFO) [RFC7413]
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D41691

    (cherry picked from commit 224aec05e732bb97a0d3c91142973b98a91238d1)
    (cherry picked from commit 144851777edad9522390036d3073ea656d7b648d)

 sys/netinet/tcp_fastopen.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Comment 7 commit-hook freebsd_committer freebsd_triage 2023-09-06 04:53:27 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=aadedc5b3e4b360513f2a950135059ca01035202

commit aadedc5b3e4b360513f2a950135059ca01035202
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2023-09-02 20:34:07 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2023-09-06 04:32:56 +0000

    tcp: Initialize the maximum number of entries in a client cookie cache bucket

    This vnet loader tunable is defined with SYSCTL_PROC, thus will not be
    initialized by kernel on vnet creating and will always have the default
    value TCP_FASTOPEN_CCACHE_BUCKET_LIMIT_DEFAULT.

    Fix by fetching the value from the corresponding kernel environment during
    vnet constructing.

    PR:             273509
    Reviewed by:    #transport, tuexen
    Fixes:  c560df6f12f1 This is an implementation of the client side of TCP Fast Open (TFO) [RFC7413]
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D41691

    (cherry picked from commit 224aec05e732bb97a0d3c91142973b98a91238d1)
    (cherry picked from commit 144851777edad9522390036d3073ea656d7b648d)
    (cherry picked from commit 3fc299d68897a0748d96510de5f191f5a8249216)

 sys/netinet/tcp_fastopen.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Comment 8 Zhenlei Huang freebsd_committer freebsd_triage 2023-09-06 04:57:48 UTC
Fixed.