]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
f_fw: fix compat mode
authorPatrick McHardy <kaber@trash.net>
Mon, 23 Nov 2009 11:03:41 +0000 (12:03 +0100)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Wed, 2 Dec 2009 00:20:01 +0000 (16:20 -0800)
The kernel takes a lack of options as indication that the fw classifier
should operate in compatibility mode, where marks are mapped directly to
classids.

Commit e22b42a (tc mask patch) broke this by adding an empty TCA_OPTIONS
attribute even if no handle is specified. Restore the old behaviour.

Signed-off-by: Patrick McHardy <kaber@trash.net>
tc/f_fw.c

index b511735671f440f65709bf54a6f8523a9266b9e2..cc8ea2d83e3972e240eef737462854773edf5c9e 100644 (file)
--- a/tc/f_fw.c
+++ b/tc/f_fw.c
@@ -38,15 +38,13 @@ static int fw_parse_opt(struct filter_util *qu, char *handle, int argc, char **a
        struct tc_police tp;
        struct tcmsg *t = NLMSG_DATA(n);
        struct rtattr *tail;
+       __u32 mask = 0;
+       int mask_set = 0;
 
        memset(&tp, 0, sizeof(tp));
 
-       tail = NLMSG_TAIL(n);
-       addattr_l(n, 4096, TCA_OPTIONS, NULL, 0);
-
        if (handle) {
                char *slash;
-               __u32 mask = 0;
                if ((slash = strchr(handle, '/')) != NULL)
                        *slash = '\0';
                if (get_u32(&t->tcm_handle, handle, 0)) {
@@ -58,13 +56,19 @@ static int fw_parse_opt(struct filter_util *qu, char *handle, int argc, char **a
                                fprintf(stderr, "Illegal \"handle\" mask\n");
                                return -1;
                        }
-                       addattr32(n, MAX_MSG, TCA_FW_MASK, mask);
+                       mask_set = 1;
                }
        }
 
        if (argc == 0)
                return 0;
 
+       tail = NLMSG_TAIL(n);
+       addattr_l(n, 4096, TCA_OPTIONS, NULL, 0);
+
+       if (mask_set)
+               addattr32(n, MAX_MSG, TCA_FW_MASK, mask);
+
        while (argc > 0) {
                if (matches(*argv, "classid") == 0 ||
                    matches(*argv, "flowid") == 0) {