From: WANG Cong Date: Tue, 5 May 2015 22:30:20 +0000 (-0700) Subject: tc: fill in handle before checking argc X-Git-Tag: v4.1.0~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=285e7768e865a9061ee6a6a92e96a0ce041f5789;p=thirdparty%2Fiproute2.git tc: fill in handle before checking argc When deleting a specific basic filter with handle, tc command always ignores the 'handle' option, so tcm_handle is always 0 and kernel deletes all filters in the selected group. This is wrong, we should respect 'handle' in cmdline. Cc: Jamal Hadi Salim Cc: Stephen Hemminger Signed-off-by: Cong Wang --- diff --git a/tc/f_basic.c b/tc/f_basic.c index 1c33ca3d3..4adf1d220 100644 --- a/tc/f_basic.c +++ b/tc/f_basic.c @@ -43,9 +43,6 @@ static int basic_parse_opt(struct filter_util *qu, char *handle, struct rtattr *tail; long h = 0; - if (argc == 0) - return 0; - if (handle) { h = strtol(handle, NULL, 0); if (h == LONG_MIN || h == LONG_MAX) { @@ -54,9 +51,11 @@ static int basic_parse_opt(struct filter_util *qu, char *handle, return -1; } } - t->tcm_handle = h; + if (argc == 0) + return 0; + tail = (struct rtattr*)(((void*)n)+NLMSG_ALIGN(n->nlmsg_len)); addattr_l(n, MAX_MSG, TCA_OPTIONS, NULL, 0);