From patchwork Sat Feb 28 03:11:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 444571 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.180.67]) by ozlabs.org (Postfix) with ESMTP id D62281400B6 for ; Sat, 28 Feb 2015 14:13:13 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=google.com header.i=@google.com header.b=PTN7x5g+; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752383AbbB1DNH (ORCPT ); Fri, 27 Feb 2015 22:13:07 -0500 Received: from mail-ie0-f182.google.com ([209.85.223.182]:41977 "EHLO mail-ie0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752345AbbB1DNE (ORCPT ); Fri, 27 Feb 2015 22:13:04 -0500 Received: by iecrd18 with SMTP id rd18so35719645iec.8 for ; Fri, 27 Feb 2015 19:13:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=TbB5a7G0TqgFVZUHIpyjEU4+AU8Pm9FW26YbYKkX+uI=; b=PTN7x5g+whGWCLojOkbgjEh3ljGIpLP63I6VK2oJo/6J7piSwGDKt2pNI0b3FKQLeR T7p2dBGq0UuE2T3BWAZxlnJhCzkJ5lLr9rBDeBV48ILfNwio+kE2zIQQCqRbPneMQcs6 mNKMeiYqE0qvyBthdeH/k+wDJ3p6LFV70Zc4alM//bXAXh0/aOVe5zoaUCHGiu3wTW5b mrW+JfnU3NaFf5DLDN3vqZ1Kvx2KZ50DgLs/01a8FMiQMbbAuzj9cwv1CyEZcuZmcatd htzR81E7teuIkYB5v4KEoZUg1XLGzupCo0O4ZLyuRFbw9TesuiW4EVY9iyJaqWv5528y NQiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=TbB5a7G0TqgFVZUHIpyjEU4+AU8Pm9FW26YbYKkX+uI=; b=BrwTI4dblK09xzKizsHuQ37XiOaNtMU2bRXS53RY6PZA5rqZxOh717Md/DNMKA30dV q9NSg7AWR3Cxk6oNlRl1esjysw72GKGY8NXrki7Hf933My4Ap7U3TonYIY0g5GwnD+ig pXA9nIjL+X3CmQUXu1PGnkPS/a05NQrWylMthLgN2/bN6SSRV0LJSunLSCXM96XMJgO/ Rz/KBsa697HXJCu31Gy1CzHRUe+dyAxhdygo6BFZC5H/AvxRLV510tS/WiZpUZ/9hldM mwhNI9RFofml6SD6IIdgQCzmWOjjFK6ZpMIt5lSM1JVUSwtutv2l6OaQn4Aak5lc1IXL Suxg== X-Gm-Message-State: ALoCoQnDEPlRw2YHbSdHJR60XxslRQJk5rHT6QpfoPdaLRKhxunFR/GLg5z8ZAr4QOOLDEPvR+8Z X-Received: by 10.50.136.228 with SMTP id qd4mr7410093igb.13.1425093183580; Fri, 27 Feb 2015 19:13:03 -0800 (PST) Received: from tomh.mtv.corp.google.com ([172.18.117.126]) by mx.google.com with ESMTPSA id y142sm3530442iod.25.2015.02.27.19.13.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Feb 2015 19:13:03 -0800 (PST) From: Tom Herbert To: davem@davemloft.net, netdev@vger.kernel.org Subject: [PATCH net-next 6/6] flow_dissector: Include MPLS entropy label in hash computation Date: Fri, 27 Feb 2015 19:11:49 -0800 Message-Id: <1425093109-1077-7-git-send-email-therbert@google.com> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1425093109-1077-1-git-send-email-therbert@google.com> References: <1425093109-1077-1-git-send-email-therbert@google.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch add MPLS cases in flow dissection. If the top labels are entropy labels (entropy label next indicator label followed by an entropy label) the entropy value is extracted and used as a substitute for ports in flow keys. Entropy labels for MPLS are described in RFC 6790. Signed-off-by: Tom Herbert --- include/uapi/linux/in.h | 2 ++ include/uapi/linux/mpls.h | 3 +++ net/core/flow_dissector.c | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h index 589ced0..5f9bc1f 100644 --- a/include/uapi/linux/in.h +++ b/include/uapi/linux/in.h @@ -69,6 +69,8 @@ enum { #define IPPROTO_SCTP IPPROTO_SCTP IPPROTO_UDPLITE = 136, /* UDP-Lite (RFC 3828) */ #define IPPROTO_UDPLITE IPPROTO_UDPLITE + IPPROTO_MPLS = 137, /* MPLS (RFC 4023) */ +#define IPPROTO_MPLS IPPROTO_MPLS IPPROTO_RAW = 255, /* Raw IP packets */ #define IPPROTO_RAW IPPROTO_RAW IPPROTO_MAX diff --git a/include/uapi/linux/mpls.h b/include/uapi/linux/mpls.h index bc9abfe..3be9eb7 100644 --- a/include/uapi/linux/mpls.h +++ b/include/uapi/linux/mpls.h @@ -31,4 +31,7 @@ struct mpls_label { #define MPLS_LS_TTL_MASK 0x000000FF #define MPLS_LS_TTL_SHIFT 0 +/* Reserved labels */ +#define MPLS_LS_ENTROPY_IS_NEXT 7 + #endif /* _UAPI_MPLS_H */ diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index e04946f..c4c35cd 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -193,6 +194,26 @@ ipv6: flow->thoff = (u16)nhoff; return true; } + case htons(ETH_P_MPLS_UC): + case htons(ETH_P_MPLS_MC): { + struct mpls_label *hdr, _hdr[2]; +mpls: + hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data, + hlen, &_hdr); + if (!hdr) + return false; + if ((ntohl(hdr[0].entry) & MPLS_LS_LABEL_MASK) == + MPLS_LS_ENTROPY_IS_NEXT) { + flow->n_proto = proto; + flow->ip_proto = ip_proto; + flow->ports = ntohl(hdr[1].entry) & MPLS_LS_LABEL_MASK; + flow->thoff = (u16)nhoff; + + return true; + } else { + return false; + } + } case htons(ETH_P_FCOE): flow->thoff = (u16)(nhoff + FCOE_HEADER_LEN); /* fall through */ @@ -258,6 +279,9 @@ ipv6: case IPPROTO_IPV6: proto = htons(ETH_P_IPV6); goto ipv6; + case IPPROTO_MPLS: + proto = htons(ETH_P_MPLS_UC); + goto mpls; default: break; }