From patchwork Mon Jun 14 13:36:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Lautrbach X-Patchwork-Id: 55531 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 B4BDDB7D1C for ; Mon, 14 Jun 2010 23:37:10 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751610Ab0FNNhB (ORCPT ); Mon, 14 Jun 2010 09:37:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11155 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751097Ab0FNNhB (ORCPT ); Mon, 14 Jun 2010 09:37:01 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5EDas9T022765 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 14 Jun 2010 09:36:54 -0400 Received: from 2x4b-523p.brq.redhat.com (2x4b-523p.brq.redhat.com [10.34.28.136]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5EDapSd023330; Mon, 14 Jun 2010 09:36:52 -0400 From: Petr Lautrbach To: shemminger@osdl.org Cc: netdev@vger.kernel.org, Petr Lautrbach Subject: [PATCH] iproute: fix tc generating ipv6 priority filter Date: Mon, 14 Jun 2010 15:36:28 +0200 Message-Id: <1276522588-23727-1-git-send-email-plautrba@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds ipv6 filter priority/traffic class function static int parse_ip6_class(int *argc_p, char ***argv_p, struct tc_u32_sel *sel) shifting filter value to 5th bit and ignoring "at" as header position is exactly given. Signed-off-by: Petr Lautrbach --- Hello, According to [1], tc doesn't generate right filters for IPv6 "priority". Priority or Traffic Classes is 8 bits starting at 5th bit based on RFC 2460 [2]. There is parse_u8(&argc, &argv, sel, 4, 0) function used in current version, which shifts filter by 4 bytes instead of 4 bits. [1] https://bugzilla.redhat.com/show_bug.cgi?id=584913 [2] http://www.faqs.org/rfcs/rfc2460.html tc/f_u32.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 files changed, 38 insertions(+), 1 deletions(-) diff --git a/tc/f_u32.c b/tc/f_u32.c index 4f5f74e..31e13b5 100644 --- a/tc/f_u32.c +++ b/tc/f_u32.c @@ -403,6 +403,43 @@ static int parse_ip6_addr(int *argc_p, char ***argv_p, return res; } +static int parse_ip6_class(int *argc_p, char ***argv_p, struct tc_u32_sel *sel) +{ + int res = -1; + int argc = *argc_p; + char **argv = *argv_p; + __u32 key; + __u32 mask; + int off = 0; + int offmask = 0; + + if (argc < 2) + return -1; + + if (get_u32(&key, *argv, 0)) + return -1; + argc--; argv++; + + if (get_u32(&mask, *argv, 16)) + return -1; + argc--; argv++; + + if (key > 0xFF || mask > 0xFF) + return -1; + + key <<= 20; + mask <<= 20; + key = htonl(key); + mask = htonl(mask); + + if (res = pack_key(sel, key, mask, off, offmask) < 0) + return -1; + + *argc_p = argc; + *argv_p = argv; + return 0; +} + static int parse_ether_addr(int *argc_p, char ***argv_p, struct tc_u32_sel *sel, int off) { @@ -522,7 +559,7 @@ static int parse_ip6(int *argc_p, char ***argv_p, struct tc_u32_sel *sel) res = parse_ip6_addr(&argc, &argv, sel, 24); } else if (strcmp(*argv, "priority") == 0) { NEXT_ARG(); - res = parse_u8(&argc, &argv, sel, 4, 0); + res = parse_ip6_class(&argc, &argv, sel); } else if (strcmp(*argv, "protocol") == 0) { NEXT_ARG(); res = parse_u8(&argc, &argv, sel, 6, 0);