c0bf07aaddc124202b1dc11ea1888aa1c9977576
[openwrt/staging/mkresin.git] / package / network / utils / iproute2 / patches / 210-add-act_connmark.patch
1 --- a/tc/Makefile
2 +++ b/tc/Makefile
3 @@ -39,6 +39,7 @@ TCMODULES += m_mirred.o
4 TCMODULES += m_nat.o
5 TCMODULES += m_pedit.o
6 TCMODULES += m_skbedit.o
7 +TCMODULES += m_connmark.o
8 TCMODULES += m_csum.o
9 TCMODULES += m_simple.o
10 TCMODULES += p_ip.o
11 --- /dev/null
12 +++ b/tc/m_connmark.c
13 @@ -0,0 +1,74 @@
14 +/*
15 + * m_connmark.c Connection tracking marking import
16 + *
17 + * Copyright (c) 2011 Felix Fietkau <nbd@openwrt.org>
18 + *
19 + * This program is free software; you can redistribute it and/or modify it
20 + * under the terms and conditions of the GNU General Public License,
21 + * version 2, as published by the Free Software Foundation.
22 + *
23 + * This program is distributed in the hope it will be useful, but WITHOUT
24 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
26 + * more details.
27 + *
28 + * You should have received a copy of the GNU General Public License along with
29 + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
30 + * Place - Suite 330, Boston, MA 02111-1307 USA.
31 + */
32 +
33 +#include <stdio.h>
34 +#include <stdlib.h>
35 +#include <unistd.h>
36 +#include <string.h>
37 +#include "utils.h"
38 +#include "tc_util.h"
39 +
40 +static void
41 +explain(void)
42 +{
43 + fprintf(stderr, "Usage: ... connmark\n");
44 +}
45 +
46 +static void
47 +usage(void)
48 +{
49 + explain();
50 + exit(-1);
51 +}
52 +
53 +static int
54 +parse_connmark(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
55 + struct nlmsghdr *n)
56 +{
57 + int argc = *argc_p;
58 + char **argv = *argv_p;
59 +
60 + if (matches(*argv, "connmark") != 0)
61 + return -1;
62 +
63 + NEXT_ARG();
64 +
65 + if (matches(*argv, "help") == 0)
66 + usage();
67 +
68 + *argc_p = argc;
69 + *argv_p = argv;
70 + return 0;
71 +}
72 +
73 +static int print_connmark(struct action_util *au, FILE *f, struct rtattr *arg)
74 +{
75 + if (arg == NULL)
76 + return -1;
77 +
78 + fprintf(f, " connmark");
79 +
80 + return 0;
81 +}
82 +
83 +struct action_util connmark_action_util = {
84 + .id = "connmark",
85 + .parse_aopt = parse_connmark,
86 + .print_aopt = print_connmark,
87 +};