]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tc, ingress: clean up ingress handling a bit
authorDaniel Borkmann <daniel@iogearbox.net>
Tue, 12 Jan 2016 00:42:19 +0000 (01:42 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Mon, 18 Jan 2016 19:41:27 +0000 (11:41 -0800)
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>
tc/q_ingress.c
tc/tc_qdisc.c

index 30b24e7de417575791138a8acf97ad16a34bbf8f..c3c9b4031d548d7228976f4a454e4a01e43863ab 100644 (file)
@@ -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"
 
 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;
index c31ae8d296cedeec5435271e8f23fa7352940a2b..96b8085249232c9c7de64265bf816c45b510f574 100644 (file)
@@ -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 {