--- iproute2-2.6.11/include/linux/pkt_sched.h.orig 2005-04-01 12:59:45.000000000 +0300 +++ iproute2-2.6.11/include/linux/pkt_sched.h 2005-04-01 13:00:21.000000000 +0300 @@ -451,4 +451,11 @@ struct tc_netem_corr #define NETEM_DIST_SCALE 8192 +struct tc_log_qopt +{ + __u32 limit; + __u32 idx; + __u32 flags; +}; + #endif --- iproute2-2.6.11/tc/Makefile.orig 2005-04-01 12:59:14.000000000 +0300 +++ iproute2-2.6.11/tc/Makefile 2005-04-01 12:59:55.000000000 +0300 @@ -43,6 +43,7 @@ TCSO += q_netem.so ifeq ($(TC_CONFIG_ATM),y) TCSO += q_atm.so endif +TCSO += q_log.so LDLIBS += -L. -ltc -lm -ldl --- iproute2-2.6.11/tc/tc_qdisc.c.orig 2005-04-01 12:59:24.000000000 +0300 +++ iproute2-2.6.11/tc/tc_qdisc.c 2005-04-01 12:59:55.000000000 +0300 @@ -36,7 +36,7 @@ static int usage(void) fprintf(stderr, "\n"); fprintf(stderr, " tc qdisc show [ dev STRING ] [ingress]\n"); fprintf(stderr, "Where:\n"); - fprintf(stderr, "QDISC_KIND := { [p|b]fifo | tbf | prio | cbq | red | etc. }\n"); + fprintf(stderr, "QDISC_KIND := { [p|b]fifo | tbf | prio | cbq | red | log | etc. }\n"); fprintf(stderr, "OPTIONS := ... try tc qdisc add help\n"); return -1; } --- iproute2-2.6.11/tc/q_log.c.orig 1970-01-01 02:00:00.000000000 +0200 +++ iproute2-2.6.11/tc/q_log.c 2005-04-01 14:20:34.000000000 +0300 @@ -0,0 +1,109 @@ +/* + * q_log.c Logging qdisc + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Authors: Catalin(ux aka Dino) + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "utils.h" +#include "tc_util.h" +#include "tc_common.h" + +static void explain(void) +{ + fprintf(stderr, "Usage: ... log [ limit PACKETS ] [idx INDEX]\n"); +} + +static void explain1(const char *arg) +{ + fprintf(stderr, "Illegal \"%s\"\n", arg); +} + +#define usage() return(-1) + + +static int log_parse_opt(struct qdisc_util *qu, int argc, char **argv, + struct nlmsghdr *n) +{ + struct tc_log_qopt opt; + int idx; + char *end; + + memset(&opt, 0, sizeof(opt)); + opt.limit = 1000; + opt.idx = 0; + opt.flags = 0; + + while (argc > 0) { + if (matches(*argv, "limit") == 0) { + NEXT_ARG(); + if (get_size(&opt.limit, *argv)) { + explain1("limit"); + return -1; + } + } else if (matches(*argv, "idx") == 0) { + NEXT_ARG(); + idx = strtoul(*argv, &end, 0); + if (*end) { + explain1("idx"); + return -1; + } + opt.idx = idx; + } else if (matches(*argv, "mark2dest") == 0) { + opt.flags |= 1; + } else if (matches(*argv, "q2src") == 0) { + opt.flags |= 2; + } else { + fprintf(stderr, "What is \"%s\"?\n", *argv); + explain(); + return -1; + } + argc--; argv++; + } + + addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt)); + return 0; +} + +static int log_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) +{ + struct tc_log_qopt qopt; + + if (opt == NULL) + return 0; + + if (RTA_PAYLOAD(opt) < sizeof(qopt)) { + fprintf(stderr, "options size error kernel=%d qopt=%d\n", + RTA_PAYLOAD(opt), sizeof(qopt)); + return -1; + } + memcpy(&qopt, RTA_DATA(opt), sizeof(qopt)); + + fprintf(f, "limit %d idx %d%s%s", qopt.limit, qopt.idx, + qopt.flags & 1 ? " mark2dest" : "", + qopt.flags & 2 ? " q2src" : ""); + + return 0; +} + +struct qdisc_util log_qdisc_util = { + .id = "log", + .parse_qopt = log_parse_opt, + .print_qopt = log_print_opt, +};