• Thomas Haller's avatar
    platform: fix handling of fq_codel's memory limit default value · 509a1bc5
    Thomas Haller authored
    The memory-limit is an unsigned integer. It is ugly (if not wrong) to compare unsigned
    values with "-1". When comparing with the default value we must also use an u32 type.
    Instead add a define NM_PLATFORM_FQ_CODEL_MEMORY_LIMIT_UNSET.
    
    Note that like iproute2 we treat NM_PLATFORM_FQ_CODEL_MEMORY_LIMIT_UNSET
    to indicate to not set TCA_FQ_CODEL_MEMORY_LIMIT in RTM_NEWQDISC. This
    special value is entirely internal to NetworkManager (or iproute2) and
    kernel will then choose a default memory limit (of 32MB). So setting
    NM_PLATFORM_FQ_CODEL_MEMORY_LIMIT_UNSET means to leave it to kernel to
    choose a value (which then chooses 32MB).
    
    See kernel's net/sched/sch_fq_codel.c:
    
        static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt,
                                 struct netlink_ext_ack *extack)
        {
        ...
                q->memory_limit = 32 << 20; /* 32 MBytes */
    
        static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt,
                                   struct netlink_ext_ack *extack)
        ...
                if (tb[TCA_FQ_CODEL_MEMORY_LIMIT])
                        q->memory_limit = min(1U << 31, nla_get_u32(tb[TCA_FQ_CODEL_MEMORY_LIMIT]));
    
    Note that not having zero as default value is problematic. In fields like
    "NMPlatformIP4Route.table_coerced" and "NMPlatformRoutingRule.suppress_prefixlen_inverse"
    we avoid this problem by storing a coerced value in the structure so that zero is still
    the default. We don't do that here for memory-limit, so the caller must always explicitly
    set the value.
    
    (cherry picked from commit 46a90438)
    509a1bc5
Name
Last commit
Last update
clients Loading commit data...
contrib Loading commit data...
data Loading commit data...
dispatcher Loading commit data...
docs Loading commit data...
examples Loading commit data...
introspection Loading commit data...
libnm Loading commit data...
libnm-core Loading commit data...
libnm-glib Loading commit data...
libnm-util Loading commit data...
m4 Loading commit data...
man Loading commit data...
po Loading commit data...
shared Loading commit data...
src Loading commit data...
tools Loading commit data...
vapi Loading commit data...
.dir-locals.el Loading commit data...
.gitignore Loading commit data...
.gitlab-ci.yml Loading commit data...
.mailmap Loading commit data...
.travis.yml Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING Loading commit data...
COPYING Loading commit data...
ChangeLog Loading commit data...
MAINTAINERS Loading commit data...
Makefile.am Loading commit data...
Makefile.examples Loading commit data...
Makefile.glib Loading commit data...
Makefile.vapigen Loading commit data...
NEWS Loading commit data...
NetworkManager.pc.in Loading commit data...
README Loading commit data...
TODO Loading commit data...
autogen.sh Loading commit data...
config-extra.h.meson Loading commit data...
config.h.meson Loading commit data...
configure.ac Loading commit data...
linker-script-binary.ver Loading commit data...
linker-script-devices.ver Loading commit data...
linker-script-settings.ver Loading commit data...
meson.build Loading commit data...
meson_options.txt Loading commit data...
valgrind.suppressions Loading commit data...
zanata.xml Loading commit data...