• Thomas Haller's avatar
    platform: fix handling of default value for TCA_FQ_CODEL_CE_THRESHOLD · b252e20e
    Thomas Haller authored
    iproute2 uses the special value ~0u to indicate not to set
    TCA_FQ_CODEL_CE_THRESHOLD in RTM_NEWQDISC. When not explicitly
    setting the value, kernel treats the threshold as disabled.
    
    However note that 0xFFFFFFFFu is not an invalid threshold (as far as
    kernel is concerned). Thus, we should not use that as value to indicate
    that the value is unset. Note that iproute2 uses the special value ~0u
    only internally thereby making it impossible to set the threshold to
    0xFFFFFFFFu). But kernel does not have this limitation.
    
    Maybe the cleanest way would be to add another field to NMPlatformQDisc:
    
        guint32 ce_threshold;
        bool ce_threshold_set:1;
    
    that indicates whether the threshold is enable or not.
    But note that kernel does:
    
        static void codel_params_init(struct codel_params *params)
        {
        ...
                params->ce_threshold = CODEL_DISABLED_THRESHOLD;
    
        static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt,
                                   struct netlink_ext_ack *extack)
        {
        ...
                if (tb[TCA_FQ_CODEL_CE_THRESHOLD]) {
                        u64 val = nla_get_u32(tb[TCA_FQ_CODEL_CE_THRESHOLD]);
    
                        q->cparams.ce_threshold = (val * NSEC_PER_USEC) >> CODEL_SHIFT;
                }
    
        static int fq_codel_dump(struct Qdisc *sch, struct sk_buff *skb)
        {
        ...
                if (q->cparams.ce_threshold != CODEL_DISABLED_THRESHOLD &&
                    nla_put_u32(skb, TCA_FQ_CODEL_CE_THRESHOLD,
                                codel_time_to_us(q->cparams.ce_threshold)))
                        goto nla_put_failure;
    
    This means, kernel internally uses the special value 0x83126E97u to indicate
    that the threshold is disabled (WTF). That is because
    
      (((guint64) 0x83126E97u) * NSEC_PER_USEC) >> CODEL_SHIFT == CODEL_DISABLED_THRESHOLD
    
    So in kernel API this value is reserved (and has a special meaning
    to indicate that the threshold is disabled). So, instead of adding a
    ce_threshold_set flag, use the same value that kernel anyway uses.
    
    (cherry picked from commit 973db2d4)
    b252e20e
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...