13 #include <netlink/cli/utils.h>
14 #include <netlink/cli/tc.h>
15 #include <netlink/route/qdisc/plug.h>
17 static void print_usage(
void)
20 "Usage: nl-qdisc-add [...] plug [OPTIONS]...\n"
23 " --help Show this help text.\n"
24 " --limit Maximum queue length in bytes.\n"
25 " --buffer create a new buffer(plug) and queue incoming traffic into it.\n"
26 " --release-one release traffic from previous buffer.\n"
27 " --release-indefinite stop buffering and release all (buffered and new) packets.\n"
30 " # Attach plug qdisc with 32KB queue size to ifb0\n"
31 " nl-qdisc-add --dev=ifb0 --parent=root plug --limit=32768\n"
32 " # Plug network traffic arriving at ifb0\n"
33 " nl-qdisc-add --dev=ifb0 --parent=root --update plug --buffer\n"
34 " # Unplug traffic arriving at ifb0 indefinitely\n"
35 " nl-qdisc-add --dev=ifb0 --parent=root --update plug --release-indefinite\n\n"
36 " # If operating in output buffering mode:\n"
37 " # at time t=t0, create a new output buffer b0 to hold network output\n"
38 " nl-qdisc-add --dev=ifb0 --parent=root --update plug --buffer\n\n"
39 " # at time t=t1, take a checkpoint c0, create a new output buffer b1\n"
40 " nl-qdisc-add --dev=ifb0 --parent=root --update plug --buffer\n"
41 " # at time t=t1+r, after c0 is committed, release b0\n"
42 " nl-qdisc-add --dev=ifb0 --parent=root --update plug --release-one\n\n"
43 " # at time t=t2, take a checkpoint c1, create a new output buffer b2\n"
44 " nl-qdisc-add --dev=ifb0 --parent=root --update plug --buffer\n"
45 " # at time t=t2+r, after c1 is committed, release b1\n"
46 " nl-qdisc-add --dev=ifb0 --parent=root --update plug --release-one\n");
49 static void plug_parse_argv(
struct rtnl_tc *tc,
int argc,
char **argv)
51 struct rtnl_qdisc *qdisc = (
struct rtnl_qdisc *) tc;
58 ARG_RELEASE_ONE = 259,
59 ARG_RELEASE_INDEFINITE = 260,
61 static struct option long_opts[] = {
62 {
"help", 0, 0,
'h' },
63 {
"limit", 1, 0, ARG_LIMIT },
64 {
"buffer", 0, 0, ARG_BUFFER },
65 {
"release-one", 0, 0, ARG_RELEASE_ONE },
66 {
"release-indefinite", 0, 0, ARG_RELEASE_INDEFINITE },
70 c = getopt_long(argc, argv,
"h", long_opts, &optidx);
91 case ARG_RELEASE_INDEFINITE:
101 .tm_type = RTNL_TC_TYPE_QDISC,
102 .tm_parse_argv = plug_parse_argv,
105 static void __init plug_init(
void)
107 nl_cli_tc_register(&plug_module);
110 static void __exit plug_exit(
void)
112 nl_cli_tc_unregister(&plug_module);