aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2016-01-12 01:42:19 +0100
committerStephen Hemminger <stephen@networkplumber.org>2016-01-18 11:41:27 -0800
commit0d45c4b420375a5c71d5af08ca4374c9f775372e (patch)
treeee6245a2176bb1f2602934f5ffd1e51a07780ad7
parent7321b7db6f0648d231cb7b05671682d89f07aff8 (diff)
downloadiproute2-0d45c4b420375a5c71d5af08ca4374c9f775372e.tar.gz
tc, ingress: clean up ingress handling a bit
Clean it up a bit, we can also get rid of some ugly ifdefs as in our case TC_H_INGRESS is always defined. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rw-r--r--tc/q_ingress.c20
-rw-r--r--tc/tc_qdisc.c11
2 files changed, 8 insertions, 23 deletions
diff --git a/tc/q_ingress.c b/tc/q_ingress.c
index 30b24e7d..c3c9b403 100644
--- a/tc/q_ingress.c
+++ b/tc/q_ingress.c
@@ -1,5 +1,4 @@
/*
- *
* q_ingress.c INGRESS.
*
* This program is free software; you can redistribute it and/or
@@ -8,20 +7,9 @@
* 2 of the License, or (at your option) any later version.
*
* Authors: J Hadi Salim
- *
- * This is here just in case it is needed
- * useless right now; might be useful in the future
- *
*/
#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <syslog.h>
-#include <fcntl.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
#include <string.h>
#include "utils.h"
@@ -29,10 +17,11 @@
static void explain(void)
{
- fprintf(stderr, "Usage: ... ingress \n");
+ fprintf(stderr, "Usage: ... ingress\n");
}
-static int ingress_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
+static int ingress_parse_opt(struct qdisc_util *qu, int argc, char **argv,
+ struct nlmsghdr *n)
{
while (argc > 0) {
if (strcmp(*argv, "handle") == 0) {
@@ -49,7 +38,8 @@ static int ingress_parse_opt(struct qdisc_util *qu, int argc, char **argv, struc
return 0;
}
-static int ingress_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
+static int ingress_print_opt(struct qdisc_util *qu, FILE *f,
+ struct rtattr *opt)
{
fprintf(f, "---------------- ");
return 0;
diff --git a/tc/tc_qdisc.c b/tc/tc_qdisc.c
index c31ae8d2..96b80852 100644
--- a/tc/tc_qdisc.c
+++ b/tc/tc_qdisc.c
@@ -91,20 +91,17 @@ static int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv)
return -1;
}
req.t.tcm_parent = TC_H_ROOT;
-#ifdef TC_H_INGRESS
} else if (strcmp(*argv, "ingress") == 0) {
if (req.t.tcm_parent) {
fprintf(stderr, "Error: \"ingress\" is a duplicate parent ID\n");
return -1;
}
req.t.tcm_parent = TC_H_INGRESS;
- strncpy(k, "ingress", sizeof(k)-1);
+ strncpy(k, "ingress", sizeof(k) - 1);
q = get_qdisc_kind(k);
- req.t.tcm_handle = 0xffff0000;
-
- argc--; argv++;
+ req.t.tcm_handle = TC_H_MAKE(TC_H_INGRESS, 0);
+ NEXT_ARG_FWD();
break;
-#endif
} else if (strcmp(*argv, "parent") == 0) {
__u32 handle;
NEXT_ARG();
@@ -291,14 +288,12 @@ static int tc_qdisc_list(int argc, char **argv)
if (strcmp(*argv, "dev") == 0) {
NEXT_ARG();
strncpy(d, *argv, sizeof(d)-1);
-#ifdef TC_H_INGRESS
} else if (strcmp(*argv, "ingress") == 0) {
if (t.tcm_parent) {
fprintf(stderr, "Duplicate parent ID\n");
usage();
}
t.tcm_parent = TC_H_INGRESS;
-#endif
} else if (matches(*argv, "help") == 0) {
usage();
} else {