From patchwork Thu Sep 28 21:48:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 819762 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=quantonium-net.20150623.gappssmtp.com header.i=@quantonium-net.20150623.gappssmtp.com header.b="fLybAWvB"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3y37cQ29rLz9sP1 for ; Fri, 29 Sep 2017 07:48:54 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751840AbdI1Vsx (ORCPT ); Thu, 28 Sep 2017 17:48:53 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:55069 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751710AbdI1Vst (ORCPT ); Thu, 28 Sep 2017 17:48:49 -0400 Received: by mail-pf0-f174.google.com with SMTP id d187so1498296pfg.11 for ; Thu, 28 Sep 2017 14:48:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantonium-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0uhjiVHywnRmL0X2YEO7FxciPaRp6ZvKdyDBZAeROUc=; b=fLybAWvB5xWZzZbvs9nKr41jG3U4QN4LvnKAwoRdrnsFqOrA4n4uzPbMV6UObOCAJB 7odJxFXnTU5bhieF9EaF7p6U6azwgLO0YNgJHKabn5SgaLkHfBJuF8gf7ydU+XiZQ9MN Bnx5T0wlSTY8zuWkhsAwZCt4U0Ejzj7P89cIOH2X859EP1is5BikR7Al7v1x9KfeHwgq 6+drGhgc8hEoJMaaea5sVViyOEYGfGs7CgrKjII5EeW8Vw1Fg4UCQ+Vv+xrX10FuFIw0 kx3REID3L+dm5TIGAvHrrlGtVjmnmQuYC6FgLBZJzRjPWA/+yiAUPKJKBcX6RAo6kFAC 31mQ== 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=0uhjiVHywnRmL0X2YEO7FxciPaRp6ZvKdyDBZAeROUc=; b=cvTijBmgidy3miJ+2XkTk6EHkMIwOBUZD5HuDdgzM17rXoAaPvrI7aaQhTRI89Kx6E IatxZl70rbYwklgVCW3OCgzVKOFzJ9PD3zdtDSxb94Ojuw5jDzRkqa7LWrdUS6vK8oMd i6AOGrS5fO+DDGd+NDZGLQpbfjx0WA6M5/VaXi1pCehrutLDYuRkt8WHO9ZVn7oy6Qa/ UZVzOjNKpb9gnU1i2Eiscv7STeaXU4+8RZW4ekGXla8HCAd7hRc58yVVA2H75YfAlfEM cGh3997lzWOpBluUpCWiP180WD/3Qo1h/+4ufZW7cQR5x/n4UrX/a9vhQEO5qldJwcqB y1Sw== X-Gm-Message-State: AHPjjUhWdqb84aDX1UWpm3SCp1QogCUVSOZuT8JffgiDRZbS99bvFg/H MBlZn6DBqBdwhCaeMZAXP9OcXQ== X-Google-Smtp-Source: AOwi7QBt9JnU0M8yFUFxIxQFyUz6eAbhjDL8XtHwPFjnuihDLDpnJeEhoEFUiX2CLFOENk2YeM1g7w== X-Received: by 10.159.204.139 with SMTP id t11mr5000998plo.359.1506635329112; Thu, 28 Sep 2017 14:48:49 -0700 (PDT) Received: from localhost.localdomain (67-207-98-108.static.wiline.com. [67.207.98.108]) by smtp.gmail.com with ESMTPSA id f8sm3540310pgs.7.2017.09.28.14.48.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2017 14:48:48 -0700 (PDT) From: Tom Herbert To: davem@davemloft.net Cc: netdev@vger.kernel.org, rohit@quantonium.net, Tom Herbert Subject: [PATCH v3 net-next 5/8] ip: Add callbacks to flow dissection by IP protocol Date: Thu, 28 Sep 2017 14:48:20 -0700 Message-Id: <20170928214823.2426-5-tom@quantonium.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170928214823.2426-1-tom@quantonium.net> References: <20170928214823.2426-1-tom@quantonium.net> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Populate the proto_flow_dissect function for IPv4 and IPv6 packet offloads. This allows the caller to flow dissect a packet starting at the given IP protocol (as parsed to that point by flow dissector for instance). Signed-off-by: Tom Herbert --- net/ipv4/af_inet.c | 27 +++++++++++++++++++++++++++ net/ipv6/ip6_offload.c | 27 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index e31108e5ef79..18c1d884999a 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1440,6 +1440,32 @@ static struct sk_buff **ipip_gro_receive(struct sk_buff **head, return inet_gro_receive(head, skb); } +static enum flow_dissect_ret inet_proto_flow_dissect(struct sk_buff *skb, + u8 proto, + struct flow_dissector_key_control *key_control, + struct flow_dissector *flow_dissector, + void *target_container, void *data, + __be16 *p_proto, u8 *p_ip_proto, int *p_nhoff, + int *p_hlen, unsigned int flags) +{ + enum flow_dissect_ret ret = FLOW_DISSECT_RET_CONTINUE; + const struct net_offload *ops; + + rcu_read_lock(); + + ops = rcu_dereference(inet_offloads[proto]); + if (ops && ops->callbacks.flow_dissect) + ret = ops->callbacks.flow_dissect(skb, key_control, + flow_dissector, + target_container, + data, p_proto, p_ip_proto, + p_nhoff, p_hlen, flags); + + rcu_read_unlock(); + + return ret; +} + #define SECONDS_PER_DAY 86400 /* inet_current_timestamp - Return IP network timestamp @@ -1763,6 +1789,7 @@ static int ipv4_proc_init(void); static struct packet_offload ip_packet_offload __read_mostly = { .type = cpu_to_be16(ETH_P_IP), + .proto_flow_dissect = inet_proto_flow_dissect, .callbacks = { .gso_segment = inet_gso_segment, .gro_receive = inet_gro_receive, diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c index cdb3728faca7..a33a2b40b3d6 100644 --- a/net/ipv6/ip6_offload.c +++ b/net/ipv6/ip6_offload.c @@ -339,8 +339,35 @@ static int ip4ip6_gro_complete(struct sk_buff *skb, int nhoff) return inet_gro_complete(skb, nhoff); } +static enum flow_dissect_ret inet6_proto_flow_dissect(struct sk_buff *skb, + u8 proto, + struct flow_dissector_key_control *key_control, + struct flow_dissector *flow_dissector, + void *target_container, void *data, + __be16 *p_proto, u8 *p_ip_proto, int *p_nhoff, + int *p_hlen, unsigned int flags) +{ + enum flow_dissect_ret ret = FLOW_DISSECT_RET_CONTINUE; + const struct net_offload *ops; + + rcu_read_lock(); + + ops = rcu_dereference(inet6_offloads[proto]); + if (ops && ops->callbacks.flow_dissect) + ret = ops->callbacks.flow_dissect(skb, key_control, + flow_dissector, + target_container, data, + p_proto, p_ip_proto, p_nhoff, + p_hlen, flags); + + rcu_read_unlock(); + + return ret; +} + static struct packet_offload ipv6_packet_offload __read_mostly = { .type = cpu_to_be16(ETH_P_IPV6), + .proto_flow_dissect = inet6_proto_flow_dissect, .callbacks = { .gso_segment = ipv6_gso_segment, .gro_receive = ipv6_gro_receive,