dtaht / sch_cake

Out of tree build for the new cake qdisc
100 stars 35 forks source link

build against 4.18 kernel fails #155

Closed dnwe closed 1 year ago

dnwe commented 1 year ago

RHEL 8 ships with a 4.18 kernel which pre-dates the in-kernel release in 4.19. However, this out-of-tree repo is missing a definition for TCQ_ETS_MAX_BANDS (previously raised under #139) and some changes to the method signatures:

make[1]: Entering directory '/usr/src/kernels/4.18.0-425.10.1.el8_7.x86_64'
  CC [M]  /tmp/sch_cake/sch_cake.o
In file included from /tmp/sch_cake/sch_cake.c:69:
./include/net/pkt_cls.h:967:22: error: 'TCQ_ETS_MAX_BANDS' undeclared here (not in a function); did you mean 'TCQ_MIN_PRIO_BANDS'?
  unsigned int quanta[TCQ_ETS_MAX_BANDS]; /* 0 for strict bands. */
                      ^~~~~~~~~~~~~~~~~
                      TCQ_MIN_PRIO_BANDS
/tmp/sch_cake/sch_cake.c: In function 'cake_classify':
/tmp/sch_cake/sch_cake.c:1779:29: error: passing argument 2 of 'tcf_classify' from incompatible pointer type [-Werror=incompatible-pointer-types]
  result = tcf_classify(skb, filter, &res, false);
                             ^~~~~~
In file included from /tmp/sch_cake/sch_cake.c:69:
./include/net/pkt_cls.h:80:28: note: expected 'const struct tcf_block *' but argument is of type 'struct tcf_proto *'
    const struct tcf_block *block,
    ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/tmp/sch_cake/sch_cake.c:1779:37: error: passing argument 3 of 'tcf_classify' from incompatible pointer type [-Werror=incompatible-pointer-types]
  result = tcf_classify(skb, filter, &res, false);
                                     ^~~~
In file included from /tmp/sch_cake/sch_cake.c:69:
./include/net/pkt_cls.h:81:28: note: expected 'const struct tcf_proto *' but argument is of type 'struct tcf_result *'
    const struct tcf_proto *tp, struct tcf_result *res,
    ~~~~~~~~~~~~~~~~~~~~~~~~^~
/tmp/sch_cake/sch_cake.c:1779:11: error: too few arguments to function 'tcf_classify'
  result = tcf_classify(skb, filter, &res, false);
           ^~~~~~~~~~~~
In file included from /tmp/sch_cake/sch_cake.c:69:
./include/net/pkt_cls.h:79:5: note: declared here
 int tcf_classify(struct sk_buff *skb,
     ^~~~~~~~~~~~
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:324: /tmp/sch_cake/sch_cake.o] Error 1
make[1]: *** [Makefile:1585: _module_/tmp/sch_cake] Error 2
make[1]: Leaving directory '/usr/src/kernels/4.18.0-425.10.1.el8_7.x86_64'
make: *** [Makefile:7: default] Error 2
dnwe commented 1 year ago

Ah I also just found https://github.com/dtaht/sch_cake/issues/152

dtaht commented 1 year ago

you good now?

dnwe commented 1 year ago

@dtaht yeah, I was musing around minimal change to make the out-of-tree repo trivial to build on RHEL8 — the oddness of the RHEL kernel is that it is nominally 4.18, but it has updates and changes (including sch_cake!) backported from as recent a version as 5.15, so it's not really a 4.18 kernel per se

This patch does work, but obviously the KERNEL_VERSION check isn't really true. I don't know if there's any well-known defines that RHEL surfaces that could be used as a conditional:

diff --git a/pkt_sched.h b/pkt_sched.h
index a2f570c..cbeb4f2 100644
--- a/pkt_sched.h
+++ b/pkt_sched.h
@@ -972,4 +972,8 @@ enum {
        CAKE_ATM_MAX
 };

+#ifndef TCQ_ETS_MAX_BANDS
+#define TCQ_ETS_MAX_BANDS 16
+#endif
+
 #endif
diff --git a/sch_cake.c b/sch_cake.c
index 0861c9b..94758aa 100644
--- a/sch_cake.c
+++ b/sch_cake.c
@@ -1776,7 +1776,11 @@ static u32 cake_classify(struct Qdisc *sch, struct cake_tin_data **t,
                goto hash;

        *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)
+       result = tcf_classify(skb, NULL, filter, &res, false);
+#else
        result = tcf_classify(skb, filter, &res, false);
+#endif

        if (result >= 0) {
 #ifdef CONFIG_NET_CLS_ACT

The alternative is to do what was done in https://github.com/dtaht/sch_cake/issues/152 and fetch sch_cake.c from the EL8 kernel source instead and compile that — but having this standalone repo is quite convenient