Commit 0d45c4b4 authored by Daniel Borkmann's avatar Daniel Borkmann Committed by Stephen Hemminger

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: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent 7321b7db
/* /*
*
* q_ingress.c INGRESS. * q_ingress.c INGRESS.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -8,20 +7,9 @@ ...@@ -8,20 +7,9 @@
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
* *
* Authors: J Hadi Salim * 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 <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 <string.h>
#include "utils.h" #include "utils.h"
...@@ -29,10 +17,11 @@ ...@@ -29,10 +17,11 @@
static void explain(void) 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) { while (argc > 0) {
if (strcmp(*argv, "handle") == 0) { if (strcmp(*argv, "handle") == 0) {
...@@ -49,7 +38,8 @@ static int ingress_parse_opt(struct qdisc_util *qu, int argc, char **argv, struc ...@@ -49,7 +38,8 @@ static int ingress_parse_opt(struct qdisc_util *qu, int argc, char **argv, struc
return 0; 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, "---------------- "); fprintf(f, "---------------- ");
return 0; return 0;
......
...@@ -91,20 +91,17 @@ static int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv) ...@@ -91,20 +91,17 @@ static int tc_qdisc_modify(int cmd, unsigned flags, int argc, char **argv)
return -1; return -1;
} }
req.t.tcm_parent = TC_H_ROOT; req.t.tcm_parent = TC_H_ROOT;
#ifdef TC_H_INGRESS
} else if (strcmp(*argv, "ingress") == 0) { } else if (strcmp(*argv, "ingress") == 0) {
if (req.t.tcm_parent) { if (req.t.tcm_parent) {
fprintf(stderr, "Error: \"ingress\" is a duplicate parent ID\n"); fprintf(stderr, "Error: \"ingress\" is a duplicate parent ID\n");
return -1; return -1;
} }
req.t.tcm_parent = TC_H_INGRESS; req.t.tcm_parent = TC_H_INGRESS;
strncpy(k, "ingress", sizeof(k)-1); strncpy(k, "ingress", sizeof(k) - 1);
q = get_qdisc_kind(k); q = get_qdisc_kind(k);
req.t.tcm_handle = 0xffff0000; req.t.tcm_handle = TC_H_MAKE(TC_H_INGRESS, 0);
NEXT_ARG_FWD();
argc--; argv++;
break; break;
#endif
} else if (strcmp(*argv, "parent") == 0) { } else if (strcmp(*argv, "parent") == 0) {
__u32 handle; __u32 handle;
NEXT_ARG(); NEXT_ARG();
...@@ -291,14 +288,12 @@ static int tc_qdisc_list(int argc, char **argv) ...@@ -291,14 +288,12 @@ static int tc_qdisc_list(int argc, char **argv)
if (strcmp(*argv, "dev") == 0) { if (strcmp(*argv, "dev") == 0) {
NEXT_ARG(); NEXT_ARG();
strncpy(d, *argv, sizeof(d)-1); strncpy(d, *argv, sizeof(d)-1);
#ifdef TC_H_INGRESS
} else if (strcmp(*argv, "ingress") == 0) { } else if (strcmp(*argv, "ingress") == 0) {
if (t.tcm_parent) { if (t.tcm_parent) {
fprintf(stderr, "Duplicate parent ID\n"); fprintf(stderr, "Duplicate parent ID\n");
usage(); usage();
} }
t.tcm_parent = TC_H_INGRESS; t.tcm_parent = TC_H_INGRESS;
#endif
} else if (matches(*argv, "help") == 0) { } else if (matches(*argv, "help") == 0) {
usage(); usage();
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment