From patchwork Thu Dec 21 09:17:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 17245 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id E665281E9F; Thu, 21 Dec 2017 10:20:59 +0100 (CET) Authentication-Results: open-mesh.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=openmesh-com.20150623.gappssmtp.com header.i=@openmesh-com.20150623.gappssmtp.com header.b="oChTYOPV"; dkim-atps=neutral Received-SPF: None (mailfrom) identity=mailfrom; client-ip=2a00:1450:400c:c0c::243; helo=mail-wr0-x243.google.com; envelope-from=sven.eckelmann@openmesh.com; receiver= Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) by open-mesh.org (Postfix) with ESMTPS id 56E4F81E86 for ; Thu, 21 Dec 2017 10:20:32 +0100 (CET) Received: by mail-wr0-x243.google.com with SMTP id p69so15738977wrb.8 for ; Thu, 21 Dec 2017 01:20:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openmesh-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5kOv1wK/w2SLthrk7Ge75ryejoK0+1GLZfIJAFCEnVM=; b=oChTYOPVOX0oW7WlerI7r43vO0Tfqab9pceYONqN+wcTgiEC2s3r+Owy3J3xoMLglB bhnS1jZx0bJNlmIkdmPlAHqLZOw/oh35epow0SHB68kKjW4DpbaK32mrExddhRpgj9LN rfqBAVmvDNfVoMOIRpFrvsamvoWSKQLnSJYVK+Y+v5qbWGWKCBVsKL2ZrOGMSEkP2M82 xD3T/aFiwymu8mfsudq8YsNiNcQZj7prI4xNj1P540f/wZm1tnMAn3G0jqsjODw8LAkT utWDP+f2XeW+qIcRbuVnaliQIROSDmx4+Q1S3y+PGfhmTCn7Cbjvve9+GCK6xEkB1drB dA7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5kOv1wK/w2SLthrk7Ge75ryejoK0+1GLZfIJAFCEnVM=; b=V4YitFy0FHlxR3D9RCsNY41LJVtfEC+X+YxrC2DovzaT3+Bi+xVBh0xjq/XpgADG6H KDWVeaZJQxJBSshxiAaz0y2fp4F2935r42aVpYO1ZkMYQcLzkUliO7AWIYC2K094iqLc o7IBrdzkf0jRV5neXf9IfkhxtKAd0rVzig7pEbnUjVwJTU9sV9FzvCAJ6z2pypv2aB4I hhD8f6Af0/doyidkLNyYB3+dvRiknct8+dWhqsoLgxnSaKbPU9rl2Vp23cKuUJe8Wt5N DIiA2R6i2Nqe7bxa9tfU79jbqQctDtFlHBA1mupBttiJ1fbjGYapoPwxd9Qfr532MwMy M9mQ== X-Gm-Message-State: AKGB3mI7iQdeq0U8Bi6UqSl/GLNsANrnyu5oXI3OIcb4HOPaUUkrwy57 +fvMEmq2UrloFYcPLZQW/GOkzP4l8Rs= X-Google-Smtp-Source: ACJfBotTdM4eG/2RbcSM5oeQ713Nxhrsm50Ytmq9/ehfwwGjtxL1QsQElGxsRErE73/3J776W9kwZA== X-Received: by 10.223.171.207 with SMTP id s73mr1337765wrc.79.1513848031694; Thu, 21 Dec 2017 01:20:31 -0800 (PST) Received: from sven-desktop.home.narfation.org (p2003007C6F508A00A5003EEAB9F6E50C.dip0.t-ipconnect.de. [2003:7c:6f50:8a00:a500:3eea:b9f6:e50c]) by smtp.gmail.com with ESMTPSA id g92sm36171012wrd.72.2017.12.21.01.20.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Dec 2017 01:20:31 -0800 (PST) From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Thu, 21 Dec 2017 10:17:42 +0100 Message-Id: <20171221091742.8020-6-sven.eckelmann@openmesh.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171221091742.8020-1-sven.eckelmann@openmesh.com> References: <20171221091742.8020-1-sven.eckelmann@openmesh.com> Subject: [B.A.T.M.A.N.] [PATCH v4 5/5] flow_dissector: Parse batman-adv unicast headers X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Cc: Willem de Bruijn , netdev@vger.kernel.org, Sven Eckelmann , Jiri Pirko , linux-kernel@vger.kernel.org, Eric Dumazet , Tom Herbert Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" The batman-adv unicast packets contain a full layer 2 frame in encapsulated form. The flow dissector must therefore be able to parse the batman-adv unicast header to reach the layer 2+3 information. +--------------------+ | ip(v6)hdr | +--------------------+ | inner ethhdr | +--------------------+ | batadv unicast hdr | +--------------------+ | outer ethhdr | +--------------------+ The obtained information from the upper layer can then be used by RPS to schedule the processing on separate cores. This allows better distribution of multiple flows from the same neighbor to different cores. Signed-off-by: Sven Eckelmann Reviewed-by: Jiri Pirko Acked-by: Willem de Bruijn --- net/core/flow_dissector.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 15ce30063765..fa0a4879fb9d 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -24,6 +24,7 @@ #include #include #include +#include static void dissector_set_key(struct flow_dissector *flow_dissector, enum flow_dissector_key_id key_id) @@ -436,6 +437,57 @@ __skb_flow_dissect_gre(const struct sk_buff *skb, return FLOW_DISSECT_RET_PROTO_AGAIN; } +/** + * __skb_flow_dissect_batadv() - dissect batman-adv header + * @skb: sk_buff to with the batman-adv header + * @key_control: flow dissectors control key + * @data: raw buffer pointer to the packet, if NULL use skb->data + * @p_proto: pointer used to update the protocol to process next + * @p_nhoff: pointer used to update inner network header offset + * @hlen: packet header length + * @flags: any combination of FLOW_DISSECTOR_F_* + * + * ETH_P_BATMAN packets are tried to be dissected. Only + * &struct batadv_unicast packets are actually processed because they contain an + * inner ethernet header and are usually followed by actual network header. This + * allows the flow dissector to continue processing the packet. + * + * Return: FLOW_DISSECT_RET_PROTO_AGAIN when &struct batadv_unicast was found, + * FLOW_DISSECT_RET_OUT_GOOD when dissector should stop after encapsulation, + * otherwise FLOW_DISSECT_RET_OUT_BAD + */ +static enum flow_dissect_ret +__skb_flow_dissect_batadv(const struct sk_buff *skb, + struct flow_dissector_key_control *key_control, + void *data, __be16 *p_proto, int *p_nhoff, int hlen, + unsigned int flags) +{ + struct { + struct batadv_unicast_packet batadv_unicast; + struct ethhdr eth; + } *hdr, _hdr; + + hdr = __skb_header_pointer(skb, *p_nhoff, sizeof(_hdr), data, hlen, + &_hdr); + if (!hdr) + return FLOW_DISSECT_RET_OUT_BAD; + + if (hdr->batadv_unicast.version != BATADV_COMPAT_VERSION) + return FLOW_DISSECT_RET_OUT_BAD; + + if (hdr->batadv_unicast.packet_type != BATADV_UNICAST) + return FLOW_DISSECT_RET_OUT_BAD; + + *p_proto = hdr->eth.h_proto; + *p_nhoff += sizeof(*hdr); + + key_control->flags |= FLOW_DIS_ENCAPSULATION; + if (flags & FLOW_DISSECTOR_F_STOP_AT_ENCAP) + return FLOW_DISSECT_RET_OUT_GOOD; + + return FLOW_DISSECT_RET_PROTO_AGAIN; +} + static void __skb_flow_dissect_tcp(const struct sk_buff *skb, struct flow_dissector *flow_dissector, @@ -817,6 +869,11 @@ bool __skb_flow_dissect(const struct sk_buff *skb, nhoff, hlen); break; + case htons(ETH_P_BATMAN): + fdret = __skb_flow_dissect_batadv(skb, key_control, data, + &proto, &nhoff, hlen, flags); + break; + default: fdret = FLOW_DISSECT_RET_OUT_BAD; break;