From patchwork Sun Oct 18 20:28:00 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jamal X-Patchwork-Id: 36343 X-Patchwork-Delegate: davem@davemloft.net 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 DB762B7B9D for ; Mon, 19 Oct 2009 07:31:22 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755209AbZJRUbE (ORCPT ); Sun, 18 Oct 2009 16:31:04 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755189AbZJRUbE (ORCPT ); Sun, 18 Oct 2009 16:31:04 -0400 Received: from mail-qy0-f194.google.com ([209.85.221.194]:58853 "EHLO mail-qy0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754949AbZJRUbC (ORCPT ); Sun, 18 Oct 2009 16:31:02 -0400 Received: by qyk32 with SMTP id 32so2601494qyk.4 for ; Sun, 18 Oct 2009 13:31:07 -0700 (PDT) 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:in-reply-to:references:content-type:date:message-id :mime-version:x-mailer; bh=tozFXvKWwlWKGt/IR+mQE8g5JzBEqdHpUQh2QTm56xo=; b=FmQ6YeOpNcWrSReFGTc/W2U2wAHae2pEAjG9UDAnW2ccCJJjeACvXkEm6EzDwERjKY +6Kb0FRRGgHwD1pJws0q3aVbHZ+bQwPGloOd13+oypu/4d3ke33KmBJYBPCdOVYaxO7L ONJOFE4AuFbjMWkNfWT+AWY52aop3XxaRgS6I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:subject:from:reply-to:to:cc:in-reply-to:references :content-type:date:message-id:mime-version:x-mailer; b=XyIRDNlm9AOkxTMczxa2PqobmmCva9kcy699n8sDWUwwSs20TEBpm4MuLR1w/99SfW yO+JRg5Z5zwUP+Z3atJ1GhRQjv7VyuzZ9OsK9jnRY9K6TLBWnj96O2P42Y/FEXyxeBJV Y1MrsrpaoI6ux6njomQHP5IgJcLiK6TVN7cDs= Received: by 10.224.7.133 with SMTP id d5mr2242301qad.45.1255897867268; Sun, 18 Oct 2009 13:31:07 -0700 (PDT) Received: from ?10.0.0.31? (CPE0030ab124d2f-CM001bd7a7f1a0.cpe.net.cable.rogers.com [99.240.75.67]) by mx.google.com with ESMTPS id 20sm2945167qyk.13.2009.10.18.13.31.05 (version=SSLv3 cipher=RC4-MD5); Sun, 18 Oct 2009 13:31:06 -0700 (PDT) Subject: Re: [PATCH][RFC]: ingress socket filter by mark From: jamal Reply-To: hadi@cyberus.ca To: Eric Dumazet Cc: netdev@vger.kernel.org, David Miller , Atis Elsts , "Maciej Z.enczykowski" In-Reply-To: <4ADB5043.7070707@gmail.com> References: <1255869758.4815.40.camel@dogo.mojatatu.com> <4ADB5043.7070707@gmail.com> Date: Sun, 18 Oct 2009 16:28:00 -0400 Message-Id: <1255897680.4815.63.camel@dogo.mojatatu.com> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Sun, 2009-10-18 at 19:28 +0200, Eric Dumazet wrote: > I vote for extending BPF, and not adding the price of a compare > for each packet. Only users wanting mark filtering should pay the price. To be honest it nagged me as well;-> So here's a basic patch stolen from a patch i just saw that you posted;-> I still havent tested. Let me know if it looks reasonable... cheers, jamal diff --git a/include/linux/filter.h b/include/linux/filter.h index 1354aaf..909193e 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -123,7 +123,8 @@ struct sock_fprog /* Required for SO_ATTACH_FILTER. */ #define SKF_AD_IFINDEX 8 #define SKF_AD_NLATTR 12 #define SKF_AD_NLATTR_NEST 16 -#define SKF_AD_MAX 20 +#define SKF_AD_MARK 20 +#define SKF_AD_MAX 24 #define SKF_NET_OFF (-0x100000) #define SKF_LL_OFF (-0x200000) diff --git a/net/core/filter.c b/net/core/filter.c index d1d779c..e3987e1 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -303,6 +303,9 @@ load_b: case SKF_AD_IFINDEX: A = skb->dev->ifindex; continue; + case SKF_AD_MARK: + A = skb->mark; + continue; case SKF_AD_NLATTR: { struct nlattr *nla;