add ingress qdisc
This patch adds ingress qdisc to libnl. Cc: Thomas Graf <tgraf@suug.ch> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
This commit is contained in:
parent
60ceeef964
commit
43e9438d9a
3 changed files with 132 additions and 1 deletions
|
@ -81,7 +81,7 @@ libnl_route_3_la_SOURCES = \
|
|||
route/qdisc/blackhole.c route/qdisc/cbq.c route/qdisc/dsmark.c \
|
||||
route/qdisc/fifo.c route/qdisc/htb.c route/qdisc/netem.c \
|
||||
route/qdisc/prio.c route/qdisc/red.c route/qdisc/sfq.c \
|
||||
route/qdisc/tbf.c route/qdisc/plug.c \
|
||||
route/qdisc/tbf.c route/qdisc/plug.c route/qdisc/ingress.c \
|
||||
\
|
||||
fib_lookup/lookup.c fib_lookup/request.c \
|
||||
\
|
||||
|
@ -112,6 +112,7 @@ nobase_pkglib_LTLIBRARIES = \
|
|||
cli/qdisc/pfifo.la \
|
||||
cli/qdisc/plug.la \
|
||||
cli/qdisc/bfifo.la \
|
||||
cli/qdisc/ingress.la \
|
||||
cli/cls/basic.la \
|
||||
cli/cls/cgroup.la
|
||||
|
||||
|
@ -120,6 +121,7 @@ cli_qdisc_blackhole_la_LDFLAGS = -module -avoid-version
|
|||
cli_qdisc_pfifo_la_LDFLAGS = -module -avoid-version
|
||||
cli_qdisc_plug_la_LDFLAGS = -module -avoid-version
|
||||
cli_qdisc_bfifo_la_LDFLAGS = -module -avoid-version
|
||||
cli_qdisc_ingress_la_LDFLAGS = -module -avoid-version
|
||||
cli_cls_basic_la_LDFLAGS = -module -avoid-version
|
||||
cli_cls_cgroup_la_LDFLAGS = -module -avoid-version
|
||||
endif
|
||||
|
|
65
lib/cli/qdisc/ingress.c
Normal file
65
lib/cli/qdisc/ingress.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
|
||||
/*
|
||||
* src/lib/ingress.c ingress module for CLI lib
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2013 Cong Wang <xiyou.wangcong@gmail.com>
|
||||
*/
|
||||
|
||||
#include <netlink/cli/utils.h>
|
||||
#include <netlink/cli/tc.h>
|
||||
|
||||
static void print_usage(void)
|
||||
{
|
||||
printf(
|
||||
"Usage: nl-qdisc-add [...] ingress\n"
|
||||
"\n"
|
||||
"OPTIONS\n"
|
||||
" --help Show this help text.\n"
|
||||
"\n"
|
||||
"EXAMPLE"
|
||||
" # Attach ingress to eth1\n"
|
||||
" nl-qdisc-add --dev=eth1 --parent=root ingress\n");
|
||||
}
|
||||
|
||||
static void ingress_parse_argv(struct rtnl_tc *tc, int argc, char **argv)
|
||||
{
|
||||
for (;;) {
|
||||
int c, optidx = 0;
|
||||
static struct option long_opts[] = {
|
||||
{ "help", 0, 0, 'h' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
c = getopt_long(argc, argv, "h", long_opts, &optidx);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c) {
|
||||
case 'h':
|
||||
print_usage();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static struct nl_cli_tc_module ingress_module =
|
||||
{
|
||||
.tm_name = "ingress",
|
||||
.tm_type = RTNL_TC_TYPE_QDISC,
|
||||
.tm_parse_argv = ingress_parse_argv,
|
||||
};
|
||||
|
||||
static void __init ingress_init(void)
|
||||
{
|
||||
nl_cli_tc_register(&ingress_module);
|
||||
}
|
||||
|
||||
static void __exit ingress_exit(void)
|
||||
{
|
||||
nl_cli_tc_unregister(&ingress_module);
|
||||
}
|
64
lib/route/qdisc/ingress.c
Normal file
64
lib/route/qdisc/ingress.c
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* lib/route/qdisc/ingress.c ingress
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* Copyright (c) 2013 Cong Wang <xiyou.wangcong@gmail.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup qdisc
|
||||
* @defgroup qdisc_ingress Ingress qdisc
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <netlink-private/netlink.h>
|
||||
#include <netlink-private/tc.h>
|
||||
#include <netlink/netlink.h>
|
||||
#include <netlink-private/route/tc-api.h>
|
||||
#include <netlink/route/qdisc.h>
|
||||
#include <netlink/utils.h>
|
||||
|
||||
struct dumb {
|
||||
uint32_t foo;
|
||||
};
|
||||
|
||||
static int dumb_msg_parser(struct rtnl_tc *tc, void *data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dumb_dump_line(struct rtnl_tc *tc, void *data,
|
||||
struct nl_dump_params *p)
|
||||
{
|
||||
}
|
||||
|
||||
static int dumb_msg_fill(struct rtnl_tc *tc, void *data, struct nl_msg *msg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct rtnl_tc_ops ingress_ops = {
|
||||
.to_kind = "ingress",
|
||||
.to_type = RTNL_TC_TYPE_QDISC,
|
||||
.to_size = sizeof(struct dumb),
|
||||
.to_msg_parser = dumb_msg_parser,
|
||||
.to_dump[NL_DUMP_LINE] = dumb_dump_line,
|
||||
.to_msg_fill = dumb_msg_fill,
|
||||
};
|
||||
|
||||
static void __init ingress_init(void)
|
||||
{
|
||||
rtnl_tc_register(&ingress_ops);
|
||||
}
|
||||
|
||||
static void __exit ingress_exit(void)
|
||||
{
|
||||
rtnl_tc_unregister(&ingress_ops);
|
||||
}
|
||||
|
||||
/** @} */
|
Loading…
Add table
Reference in a new issue