From patchwork Wed May 25 10:11:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jamal Hadi Salim X-Patchwork-Id: 626088 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3rF7PL2DDmz9ssM for ; Wed, 25 May 2016 20:12:22 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b=SHqTlabC; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752784AbcEYKMG (ORCPT ); Wed, 25 May 2016 06:12:06 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:34445 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752771AbcEYKMD (ORCPT ); Wed, 25 May 2016 06:12:03 -0400 Received: by mail-it0-f67.google.com with SMTP id k76so4857063ita.1 for ; Wed, 25 May 2016 03:12:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=Lx/BXKrxP1CoPixfoYODRafoO2FvQqlnbzQ+B+6JJ5U=; b=SHqTlabC+HHOy6RMhIph9Omw1UsMmvUiwllJxziN6BbX4oah7kh7+oXqmLex7jtT2D VjZ1xGfA2++0YeQUp/AG+Pe8wDs1KIw3b0KJsZ/bvPCJs/vzJO7yfn6BzWDldfv2KU/I dIRtQfiFp2m8wdhAFqozJIPT3PA+jr19i3s1X9ARqkHzuVd1xxd0rWuduqaFEdnIK0TS HCSHU7+IdRKpT+wFUNK33JPT9nymwsmyD4SYOnbiQ2EnsPf8zv2tZv7ZXBbFO0iKWAqG rD66T6EbBgz184gdHX5fjbJ/y6foLarbvbVy+M/f7FJ69jbKxKYwoV3IHOEpQnVcYg/B dXKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Lx/BXKrxP1CoPixfoYODRafoO2FvQqlnbzQ+B+6JJ5U=; b=it3FtNboYjUYYxp5lLKToQPTrzTrprpsfKa1AibF/Fi2uqHmxuvWFaTv31OOqf9+xK DfghkT4zF08tmrtuTiaKYlAcIQlSWT7W1cIcBD0gao98ub8EK+S1y1caBBKx7kFo0gvC kKQSbqOkwhliz0CgNarLcWyDtq4NGvuyh4czd6Nqgdc16eByguQ2YY5RBpQ/ldalYnn7 Ilg2ObK194AUPW/RENlyAcfIjOeKV4j6i6TvISbfKrP5R+t9W/wbShqKhKMNvOD2wsN0 NIslAfQvPyIVDUljPoCHsU15XR227j+7Lg0GtV9E8B5ORoYB4Ct5+lT44ua32qfcqN3F VxPw== X-Gm-Message-State: ALyK8tI4aYfbRXbbwP1efkui7cjC+XAKIpufkUlLhJ1EY2w4isCKmMgAHOgGG5Q+tWlJcg== X-Received: by 10.36.39.151 with SMTP id g145mr14461506ita.0.1464171122360; Wed, 25 May 2016 03:12:02 -0700 (PDT) Received: from localhost.localdomain ([23.233.30.50]) by smtp.gmail.com with ESMTPSA id q99sm2585345ioi.17.2016.05.25.03.12.01 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 May 2016 03:12:01 -0700 (PDT) From: Jamal Hadi Salim X-Google-Original-From: Jamal Hadi Salim To: stephen@networkplumber.org Cc: netdev@vger.kernel.org, daniel@iogearbox.net, xiyou.wangcong@gmail.com, Jamal Hadi Salim Subject: [iproute2 PATCH 1/1] tc filter u32: Coding style fixes Date: Wed, 25 May 2016 06:11:55 -0400 Message-Id: <1464171115-7770-1-git-send-email-jhs@emojatatu.com> X-Mailer: git-send-email 1.9.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jamal Hadi Salim "handle" was being used several times for different things. Fix the 80 character limit abuse and other little issues while at it. Signed-off-by: Jamal Hadi Salim --- tc/f_u32.c | 66 +++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/tc/f_u32.c b/tc/f_u32.c index 6299515..1962dfe 100644 --- a/tc/f_u32.c +++ b/tc/f_u32.c @@ -171,7 +171,8 @@ static int pack_key16(struct tc_u32_sel *sel, __u32 key, __u32 mask, return pack_key(sel, key, mask, off, offmask); } -static int pack_key8(struct tc_u32_sel *sel, __u32 key, __u32 mask, int off, int offmask) +static int pack_key8(struct tc_u32_sel *sel, __u32 key, __u32 mask, int off, + int offmask) { if (key > 0xFF || mask > 0xFF) return -1; @@ -835,16 +836,19 @@ static void print_ipv4(FILE *f, const struct tc_u32_key *key) case 0: switch (ntohl(key->mask)) { case 0x0f000000: - fprintf(f, "\n match IP ihl %u", ntohl(key->val) >> 24); + fprintf(f, "\n match IP ihl %u", + ntohl(key->val) >> 24); return; case 0x00ff0000: - fprintf(f, "\n match IP dsfield %#x", ntohl(key->val) >> 16); + fprintf(f, "\n match IP dsfield %#x", + ntohl(key->val) >> 16); return; } break; case 8: if (ntohl(key->mask) == 0x00ff0000) { - fprintf(f, "\n match IP protocol %d", ntohl(key->val) >> 16); + fprintf(f, "\n match IP protocol %d", + ntohl(key->val) >> 16); return; } break; @@ -892,16 +896,19 @@ static void print_ipv6(FILE *f, const struct tc_u32_key *key) case 0: switch (ntohl(key->mask)) { case 0x0f000000: - fprintf(f, "\n match IP ihl %u", ntohl(key->val) >> 24); + fprintf(f, "\n match IP ihl %u", + ntohl(key->val) >> 24); return; case 0x00ff0000: - fprintf(f, "\n match IP dsfield %#x", ntohl(key->val) >> 16); + fprintf(f, "\n match IP dsfield %#x", + ntohl(key->val) >> 16); return; } break; case 8: if (ntohl(key->mask) == 0x00ff0000) { - fprintf(f, "\n match IP protocol %d", ntohl(key->val) >> 16); + fprintf(f, "\n match IP protocol %d", + ntohl(key->val) >> 16); return; } break; @@ -1031,14 +1038,14 @@ static int u32_parse_opt(struct filter_util *qu, char *handle, continue; } else if (matches(*argv, "classid") == 0 || strcmp(*argv, "flowid") == 0) { - unsigned int handle; + unsigned int flowid; NEXT_ARG(); - if (get_tc_classid(&handle, *argv)) { + if (get_tc_classid(&flowid, *argv)) { fprintf(stderr, "Illegal \"classid\"\n"); return -1; } - addattr_l(n, MAX_MSG, TCA_U32_CLASSID, &handle, 4); + addattr_l(n, MAX_MSG, TCA_U32_CLASSID, &flowid, 4); sel.sel.flags |= TC_U32_TERMINAL; } else if (matches(*argv, "divisor") == 0) { unsigned int divisor; @@ -1058,34 +1065,34 @@ static int u32_parse_opt(struct filter_util *qu, char *handle, return -1; } } else if (strcmp(*argv, "link") == 0) { - unsigned int handle; + unsigned int linkid; NEXT_ARG(); - if (get_u32_handle(&handle, *argv)) { + if (get_u32_handle(&linkid, *argv)) { fprintf(stderr, "Illegal \"link\"\n"); return -1; } - if (handle && TC_U32_NODE(handle)) { + if (linkid && TC_U32_NODE(linkid)) { fprintf(stderr, "\"link\" must be a hash table.\n"); return -1; } addattr_l(n, MAX_MSG, TCA_U32_LINK, &handle, 4); } else if (strcmp(*argv, "ht") == 0) { - unsigned int handle; + unsigned int ht; NEXT_ARG(); - if (get_u32_handle(&handle, *argv)) { + if (get_u32_handle(&ht, *argv)) { fprintf(stderr, "Illegal \"ht\"\n"); return -1; } - if (handle && TC_U32_NODE(handle)) { + if (handle && TC_U32_NODE(ht)) { fprintf(stderr, "\"ht\" must be a hash table.\n"); return -1; } if (sample_ok) - htid = (htid & 0xFF000) | (handle & 0xFFF00000); + htid = (htid & 0xFF000) | (ht & 0xFFF00000); else - htid = (handle & 0xFFFFF000); + htid = (ht & 0xFFFFF000); } else if (strcmp(*argv, "sample") == 0) { __u32 hash; unsigned int divisor = 0x100; @@ -1106,8 +1113,9 @@ static int u32_parse_opt(struct filter_util *qu, char *handle, } if (*argv != 0 && strcmp(*argv, "divisor") == 0) { NEXT_ARG(); - if (get_unsigned(&divisor, *argv, 0) || divisor == 0 || - divisor > 0x100 || ((divisor - 1) & divisor)) { + if (get_unsigned(&divisor, *argv, 0) || + divisor == 0 || divisor > 0x100 || + ((divisor - 1) & divisor)) { fprintf(stderr, "Illegal sample \"divisor\"\n"); return -1; } @@ -1130,7 +1138,8 @@ static int u32_parse_opt(struct filter_util *qu, char *handle, return -1; } strncpy(ind, *argv, sizeof(ind) - 1); - addattr_l(n, MAX_MSG, TCA_U32_INDEV, ind, strlen(ind) + 1); + addattr_l(n, MAX_MSG, TCA_U32_INDEV, ind, + strlen(ind) + 1); } else if (matches(*argv, "action") == 0) { NEXT_ARG(); @@ -1165,7 +1174,8 @@ static int u32_parse_opt(struct filter_util *qu, char *handle, sel.sel.flags |= TC_U32_TERMINAL; if (order) { - if (TC_U32_NODE(t->tcm_handle) && order != TC_U32_NODE(t->tcm_handle)) { + if (TC_U32_NODE(t->tcm_handle) && + order != TC_U32_NODE(t->tcm_handle)) { fprintf(stderr, "\"order\" contradicts \"handle\"\n"); return -1; } @@ -1176,7 +1186,8 @@ static int u32_parse_opt(struct filter_util *qu, char *handle, addattr_l(n, MAX_MSG, TCA_U32_HASH, &htid, 4); if (sel_ok) addattr_l(n, MAX_MSG, TCA_U32_SEL, &sel, - sizeof(sel.sel) + sel.sel.nkeys * sizeof(struct tc_u32_key)); + sizeof(sel.sel) + + sel.sel.nkeys * sizeof(struct tc_u32_key)); tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; return 0; } @@ -1209,7 +1220,8 @@ static int u32_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, } if (tb[TCA_U32_DIVISOR]) { - fprintf(f, "ht divisor %d ", rta_getattr_u32(tb[TCA_U32_DIVISOR])); + fprintf(f, "ht divisor %d ", + rta_getattr_u32(tb[TCA_U32_DIVISOR])); } else if (tb[TCA_U32_HASH]) { __u32 htid = rta_getattr_u32(tb[TCA_U32_HASH]); @@ -1222,14 +1234,16 @@ static int u32_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, SPRINT_BUF(b1); fprintf(f, "%sflowid %s ", !sel || !(sel->flags & TC_U32_TERMINAL) ? "*" : "", - sprint_tc_classid(rta_getattr_u32(tb[TCA_U32_CLASSID]), b1)); + sprint_tc_classid(rta_getattr_u32(tb[TCA_U32_CLASSID]), + b1)); } else if (sel && sel->flags & TC_U32_TERMINAL) { fprintf(f, "terminal flowid ??? "); } if (tb[TCA_U32_LINK]) { SPRINT_BUF(b1); fprintf(f, "link %s ", - sprint_u32_handle(rta_getattr_u32(tb[TCA_U32_LINK]), b1)); + sprint_u32_handle(rta_getattr_u32(tb[TCA_U32_LINK]), + b1)); } if (tb[TCA_U32_PCNT]) {