]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
f_bpf: fix filling of handle when no further arg is provided
authorDaniel Borkmann <daniel@iogearbox.net>
Wed, 18 May 2016 09:58:41 +0000 (11:58 +0200)
committerStephen Hemminger <shemming@brocade.com>
Mon, 23 May 2016 23:14:18 +0000 (16:14 -0700)
We need to fill handle when provided by the user, even if no further
argument is provided. Thus, move the test for arg to the correct location,
so that it works correctly:

  # tc filter show dev foo egress
  filter protocol all pref 1 bpf
  filter protocol all pref 1 bpf handle 0x1 bpf.o:[classifier] direct-action
  filter protocol all pref 1 bpf handle 0x2 bpf.o:[classifier] direct-action
  # tc filter del dev foo egress prio 1 handle 2 bpf
  # tc filter show dev foo egress
  filter protocol all pref 1 bpf
  filter protocol all pref 1 bpf handle 0x1 bpf.o:[classifier] direct-action

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tc/f_bpf.c

index afc2e582cd9acef4d16c91a02152a0d1a9b98730..5c97c863d15aa2ceefef9eafc2a317ad3e159826 100644 (file)
@@ -71,9 +71,6 @@ static int bpf_parse_opt(struct filter_util *qu, char *handle,
        struct rtattr *tail;
        int ret = 0;
 
-       if (argc == 0)
-               return 0;
-
        if (handle) {
                if (get_u32(&t->tcm_handle, handle, 0)) {
                        fprintf(stderr, "Illegal \"handle\"\n");
@@ -81,6 +78,9 @@ static int bpf_parse_opt(struct filter_util *qu, char *handle,
                }
        }
 
+       if (argc == 0)
+               return 0;
+
        tail = (struct rtattr *)(((void *)n) + NLMSG_ALIGN(n->nlmsg_len));
        addattr_l(n, MAX_MSG, TCA_OPTIONS, NULL, 0);