From patchwork Thu Dec 3 13:32:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jamal X-Patchwork-Id: 40164 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.176.167]) by ozlabs.org (Postfix) with ESMTP id 471B2B6F1B for ; Fri, 4 Dec 2009 00:33:18 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756001AbZLCNcr (ORCPT ); Thu, 3 Dec 2009 08:32:47 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755970AbZLCNcq (ORCPT ); Thu, 3 Dec 2009 08:32:46 -0500 Received: from mail-vw0-f192.google.com ([209.85.212.192]:38180 "EHLO mail-vw0-f192.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755913AbZLCNco (ORCPT ); Thu, 3 Dec 2009 08:32:44 -0500 Received: by vws30 with SMTP id 30so600202vws.33 for ; Thu, 03 Dec 2009 05:32:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:subject:from:reply-to :to:cc:content-type:date:message-id:mime-version:x-mailer; bh=2vFhPrHSgU4aflsnd5C+u+pFosIqCempr6RP6GReZPg=; b=tz88JWIX1n1WUqrZZePWREhPLIg22AfH1Dngub0k+B0sUGQ6ClhT39S9Ng0MPVnRgb SD+Qo2vbKwqVc0CrDFri6OOhxBvz+5/BJPJ8iq00TIa++FbFKkQLxLDLsvg+Ff+vt3Bj 3EzbKnMlQ4znTzeiHYuq9hh7f4jvnFP3/S8cI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:subject:from:reply-to:to:cc:content-type:date:message-id :mime-version:x-mailer; b=VpizRiR8OcJGoyWX3DdgmHmiLXNI/uNby5jyN7odbJgGKG5Sd1L2FT4JbkuXs+B2aO Udo4IVTDuGq4Hur9ijKZ97d21qG6VBaQ+51Zt+V6r0xZVm4qLLroj18VL01HmJEBbWTP ObEOMP/fUgwxhAJKQPCv3Is5ukmr3q09p1X1I= Received: by 10.220.123.2 with SMTP id n2mr1935247vcr.11.1259847170518; Thu, 03 Dec 2009 05:32:50 -0800 (PST) Received: from ?10.0.0.26? (CPE0030ab124d2f-CM001bd7a7f1a0.cpe.net.cable.rogers.com [99.240.66.42]) by mx.google.com with ESMTPS id 21sm4316397vws.15.2009.12.03.05.32.49 (version=SSLv3 cipher=RC4-MD5); Thu, 03 Dec 2009 05:32:49 -0800 (PST) Subject: [PATCH 2/2] iproute2 skbedit: Add support to mark packets From: jamal Reply-To: hadi@cyberus.ca To: Stephen Hemminger Cc: netdev@vger.kernel.org, Alexander Duyck Date: Thu, 03 Dec 2009 08:32:48 -0500 Message-Id: <1259847168.3766.40.camel@bigi> Mime-Version: 1.0 X-Mailer: Evolution 2.26.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org I did this originally because i was getting too many support questions on ipt with mark. It still makes sense since skbedit seems to be the mother action of skb metadata (should probably have been called skbmeta). cheers, jamal commit 90afac29b6e8c62bc1b2a4da7c0dd4407ea9dd3f Author: Jamal Hadi Salim Date: Thu Dec 3 08:18:41 2009 -0500 skbedit: Add support to mark packets This adds support for setting the skb mark. Signed-off-by: Jamal Hadi Salim Signed-off-by: Alexander Duyck diff --git a/include/linux/tc_act/tc_skbedit.h b/include/linux/tc_act/tc_skbedit.h index a14e461..7a2e910 100644 --- a/include/linux/tc_act/tc_skbedit.h +++ b/include/linux/tc_act/tc_skbedit.h @@ -26,6 +26,7 @@ #define SKBEDIT_F_PRIORITY 0x1 #define SKBEDIT_F_QUEUE_MAPPING 0x2 +#define SKBEDIT_F_MARK 0x4 struct tc_skbedit { tc_gen; @@ -37,6 +38,7 @@ enum { TCA_SKBEDIT_PARMS, TCA_SKBEDIT_PRIORITY, TCA_SKBEDIT_QUEUE_MAPPING, + TCA_SKBEDIT_MARK, __TCA_SKBEDIT_MAX }; #define TCA_SKBEDIT_MAX (__TCA_SKBEDIT_MAX - 1) diff --git a/tc/m_skbedit.c b/tc/m_skbedit.c index ecb1f2d..623dc53 100644 --- a/tc/m_skbedit.c +++ b/tc/m_skbedit.c @@ -31,11 +31,13 @@ static void explain(void) { - fprintf(stderr, "Usage: ... skbedit <[QM] [PM]>\n" + fprintf(stderr, "Usage: ... skbedit <[QM] [PM] [MM]>\n" "QM = queue_mapping QUEUE_MAPPING\n" "PM = priority PRIORITY \n" + "MM = mark MARK \n" "QUEUE_MAPPING = device transmit queue to use\n" - "PRIORITY = classID to assign to priority field\n"); + "PRIORITY = classID to assign to priority field\n" + "MARK = firewall mark to set\n"); } static void @@ -55,7 +57,7 @@ parse_skbedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, struct rtattr *tail; unsigned int tmp; __u16 queue_mapping; - __u32 flags = 0, priority; + __u32 flags = 0, priority, mark; struct tc_skbedit sel = { 0 }; if (matches(*argv, "skbedit") != 0) @@ -81,6 +83,14 @@ parse_skbedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, return -1; } ok++; + } else if (matches(*argv, "mark") == 0) { + flags |= SKBEDIT_F_MARK; + NEXT_ARG(); + if (get_tc_classid(&mark, *argv)) { + fprintf(stderr, "Illegal mark\n"); + return -1; + } + ok++; } else if (matches(*argv, "help") == 0) { usage(); } else { @@ -138,6 +148,9 @@ parse_skbedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, if (flags & SKBEDIT_F_PRIORITY) addattr_l(n, MAX_MSG, TCA_SKBEDIT_PRIORITY, &priority, sizeof(priority)); + if (flags & SKBEDIT_F_MARK) + addattr_l(n, MAX_MSG, TCA_SKBEDIT_MARK, + &mark, sizeof(mark)); tail->rta_len = (char *)NLMSG_TAIL(n) - (char *)tail; *argc_p = argc; @@ -151,6 +164,7 @@ static int print_skbedit(struct action_util *au, FILE *f, struct rtattr *arg) struct rtattr *tb[TCA_SKBEDIT_MAX + 1]; SPRINT_BUF(b1); __u32 *priority; + __u32 *mark; __u16 *queue_mapping; if (arg == NULL) @@ -175,6 +189,10 @@ static int print_skbedit(struct action_util *au, FILE *f, struct rtattr *arg) priority = RTA_DATA(tb[TCA_SKBEDIT_PRIORITY]); fprintf(f, " priority %s", sprint_tc_classid(*priority, b1)); } + if (tb[TCA_SKBEDIT_MARK] != NULL) { + mark = RTA_DATA(tb[TCA_SKBEDIT_MARK]); + fprintf(f, " mark %d", *mark); + } if (show_stats) { if (tb[TCA_SKBEDIT_TM]) {