2 * src/nl-qdisc-delete.c Delete Qdiscs
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation version 2.1
9 * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
14 static void print_usage(void)
16 printf("Usage: nl-qdisc-delete <ifindex> <parent> <handle>\n");
20 int main(int argc, char *argv[])
22 struct nl_handle *nlh;
23 struct rtnl_qdisc *qdisc;
24 uint32_t handle, parent;
27 if (nltool_init(argc, argv) < 0)
30 if (argc < 3 || !strcmp(argv[1], "-h"))
33 nlh = nltool_alloc_handle();
37 qdisc = rtnl_qdisc_alloc();
39 goto errout_free_handle;
41 rtnl_qdisc_set_ifindex(qdisc, strtoul(argv[1], NULL, 0));
43 if (rtnl_tc_str2handle(argv[2], &parent) < 0) {
44 fprintf(stderr, "%s\n", nl_geterror());
45 goto errout_free_qdisc;
49 if (rtnl_tc_str2handle(argv[3], &handle) < 0) {
50 fprintf(stderr, "%s\n", nl_geterror());
51 goto errout_free_qdisc;
54 rtnl_qdisc_set_handle(qdisc, handle);
57 rtnl_qdisc_set_parent(qdisc, parent);
59 if (nltool_connect(nlh, NETLINK_ROUTE) < 0)
60 goto errout_free_qdisc;
62 if (rtnl_qdisc_delete(nlh, qdisc) < 0) {
63 fprintf(stderr, "Unable to delete Qdisc: %s\n", nl_geterror());
71 rtnl_qdisc_put(qdisc);
73 nl_handle_destroy(nlh);