From: Tom Herbert <tom@herbertland.com>
To: <davem@davemloft.net>, <netdev@vger.kernel.org>
Cc: <kernel-team@fb.com>
Subject: [PATCH net-next 05/14] fou: Split out {fou,gue}_build_header
Date: Wed, 4 May 2016 18:02:35 -0700 [thread overview]
Message-ID: <1462410164-1953217-6-git-send-email-tom@herbertland.com> (raw)
In-Reply-To: <1462410164-1953217-1-git-send-email-tom@herbertland.com>
Create __fou_build_header and __gue_build_header. These implement the
protocol generic parts of building the fou and gue header.
fou_build_header and gue_build_header implement the IPv4 specific
functions and call the __*_build_header functions.
Signed-off-by: Tom Herbert <tom@herbertland.com>
---
include/net/fou.h | 8 ++++----
net/ipv4/fou.c | 47 +++++++++++++++++++++++++++++++++++++----------
2 files changed, 41 insertions(+), 14 deletions(-)
diff --git a/include/net/fou.h b/include/net/fou.h
index 19b8a0c..7d2fda2 100644
--- a/include/net/fou.h
+++ b/include/net/fou.h
@@ -11,9 +11,9 @@
size_t fou_encap_hlen(struct ip_tunnel_encap *e);
static size_t gue_encap_hlen(struct ip_tunnel_encap *e);
-int fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
- u8 *protocol, struct flowi4 *fl4);
-int gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
- u8 *protocol, struct flowi4 *fl4);
+int __fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
+ u8 *protocol, __be16 *sport, int type);
+int __gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
+ u8 *protocol, __be16 *sport, int type);
#endif
diff --git a/net/ipv4/fou.c b/net/ipv4/fou.c
index a8b5cbf..971c8c6 100644
--- a/net/ipv4/fou.c
+++ b/net/ipv4/fou.c
@@ -778,6 +778,22 @@ static void fou_build_udp(struct sk_buff *skb, struct ip_tunnel_encap *e,
*protocol = IPPROTO_UDP;
}
+int __fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
+ u8 *protocol, __be16 *sport, int type)
+{
+ int err;
+
+ err = iptunnel_handle_offloads(skb, type);
+ if (err)
+ return err;
+
+ *sport = e->sport ? : udp_flow_src_port(dev_net(skb->dev),
+ skb, 0, 0, false);
+
+ return 0;
+}
+EXPORT_SYMBOL(__fou_build_header);
+
int fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
u8 *protocol, struct flowi4 *fl4)
{
@@ -786,26 +802,21 @@ int fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
__be16 sport;
int err;
- err = iptunnel_handle_offloads(skb, type);
+ err = __fou_build_header(skb, e, protocol, &sport, type);
if (err)
return err;
- sport = e->sport ? : udp_flow_src_port(dev_net(skb->dev),
- skb, 0, 0, false);
fou_build_udp(skb, e, fl4, protocol, sport);
return 0;
}
EXPORT_SYMBOL(fou_build_header);
-int gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
- u8 *protocol, struct flowi4 *fl4)
+int __gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
+ u8 *protocol, __be16 *sport, int type)
{
- int type = e->flags & TUNNEL_ENCAP_FLAG_CSUM ? SKB_GSO_UDP_TUNNEL_CSUM :
- SKB_GSO_UDP_TUNNEL;
struct guehdr *guehdr;
size_t hdrlen, optlen = 0;
- __be16 sport;
void *data;
bool need_priv = false;
int err;
@@ -824,8 +835,8 @@ int gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
return err;
/* Get source port (based on flow hash) before skb_push */
- sport = e->sport ? : udp_flow_src_port(dev_net(skb->dev),
- skb, 0, 0, false);
+ *sport = e->sport ? : udp_flow_src_port(dev_net(skb->dev),
+ skb, 0, 0, false);
hdrlen = sizeof(struct guehdr) + optlen;
@@ -870,6 +881,22 @@ int gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
}
+ return 0;
+}
+EXPORT_SYMBOL(__gue_build_header);
+
+int gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
+ u8 *protocol, struct flowi4 *fl4)
+{
+ int type = e->flags & TUNNEL_ENCAP_FLAG_CSUM ? SKB_GSO_UDP_TUNNEL_CSUM :
+ SKB_GSO_UDP_TUNNEL;
+ __be16 sport;
+ int err;
+
+ err = __gue_build_header(skb, e, protocol, &sport, type);
+ if (err)
+ return err;
+
fou_build_udp(skb, e, fl4, protocol, sport);
return 0;
--
2.8.0.rc2
next prev parent reply other threads:[~2016-05-05 1:02 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-05 1:02 [PATCH net-next 00/14] ipv6: Enable GUEoIPv6 and more fixes for v6 tunneling Tom Herbert
2016-05-05 1:02 ` [PATCH net-next 01/14] gso: Remove arbitrary checks for unsupported GSO Tom Herbert
2016-05-05 2:59 ` Alexander Duyck
2016-05-05 16:09 ` Alexander Duyck
2016-05-05 16:11 ` Tom Herbert
2016-05-05 1:02 ` [PATCH net-next 02/14] gre6: Fix flag translations Tom Herbert
2016-05-05 1:02 ` [PATCH net-next 03/14] udp: Don't set skb->encapsulation with RCO Tom Herbert
2016-05-05 2:42 ` Alexander Duyck
2016-05-05 15:38 ` Tom Herbert
2016-05-05 15:44 ` Alexander Duyck
2016-05-05 1:02 ` [PATCH net-next 04/14] fou: Call setup_udp_tunnel_sock Tom Herbert
2016-05-05 1:02 ` Tom Herbert [this message]
2016-05-05 1:02 ` [PATCH net-next 06/14] fou: Add encap ops for IPv6 tunnels Tom Herbert
2016-05-05 1:02 ` [PATCH net-next 07/14] ipv6: Fix nexthdr for reinjection Tom Herbert
2016-05-05 1:02 ` [PATCH net-next 08/14] ipv6: Change "final" protocol processing for encapsulation Tom Herbert
2016-05-05 1:02 ` [PATCH net-next 09/14] fou: Support IPv6 in fou Tom Herbert
2016-05-05 1:02 ` [PATCH net-next 10/14] ip6_tun: Add infrastructure for doing encapsulation Tom Herbert
2016-05-05 1:02 ` [PATCH net-next 11/14] ip6_gre: Add support for fou/gue encapsulation Tom Herbert
2016-05-05 1:02 ` [PATCH net-next 12/14] ip6_tunnel: " Tom Herbert
2016-05-05 1:02 ` [PATCH net-next 13/14] ip6ip6: Support for GSO/GRO Tom Herbert
2016-05-05 1:02 ` [PATCH net-next 14/14] ip4ip6: " Tom Herbert
2016-05-05 1:20 ` Eric Dumazet
2016-05-05 3:26 ` Alexander Duyck
2016-05-05 16:48 ` Tom Herbert
2016-05-05 17:48 ` Alexander Duyck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462410164-1953217-6-git-send-email-tom@herbertland.com \
--to=tom@herbertland.com \
--cc=davem@davemloft.net \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).