From: Tom Herbert <therbert@google.com>
To: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH net-next 5/7] sit: TX path for sit/UDP foo-over-udp encapsulation
Date: Thu, 11 Sep 2014 13:07:34 -0700 [thread overview]
Message-ID: <1410466056-30239-6-git-send-email-therbert@google.com> (raw)
In-Reply-To: <1410466056-30239-1-git-send-email-therbert@google.com>
Signed-off-by: Tom Herbert <therbert@google.com>
---
net/ipv6/sit.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 74 insertions(+), 7 deletions(-)
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 86e3fa8..fc65b60f 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -822,6 +822,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
int addr_type;
u8 ttl;
int err;
+ u8 protocol = IPPROTO_IPV6;
if (skb->protocol != htons(ETH_P_IPV6))
goto tx_error;
@@ -905,6 +906,17 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
}
tdev = rt->dst.dev;
+ skb = iptunnel_handle_offloads(skb, false, SKB_GSO_SIT);
+ if (IS_ERR(skb)) {
+ ip_rt_put(rt);
+ goto tx_error;
+ }
+
+ if (ip_tunnel_encap(skb, tunnel, &protocol, &fl4) < 0) {
+ ip_rt_put(rt);
+ goto tx_error;
+ }
+
if (tdev == dev) {
ip_rt_put(rt);
dev->stats.collisions++;
@@ -969,14 +981,8 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
ttl = iph6->hop_limit;
tos = INET_ECN_encapsulate(tos, ipv6_get_dsfield(iph6));
- skb = iptunnel_handle_offloads(skb, false, SKB_GSO_SIT);
- if (IS_ERR(skb)) {
- ip_rt_put(rt);
- goto out;
- }
-
err = iptunnel_xmit(skb->sk, rt, skb, fl4.saddr, fl4.daddr,
- IPPROTO_IPV6, tos, ttl, df,
+ protocol, tos, ttl, df,
!net_eq(tunnel->net, dev_net(dev)));
iptunnel_xmit_stats(err, &dev->stats, dev->tstats);
return NETDEV_TX_OK;
@@ -1089,6 +1095,12 @@ static void ipip6_tunnel_update(struct ip_tunnel *t, struct ip_tunnel_parm *p)
netdev_state_change(t->dev);
}
+static int ipip6_tunnel_update_encap(struct ip_tunnel *t,
+ struct ip_tunnel_encap *ipencap)
+{
+ return 0;
+}
+
#ifdef CONFIG_IPV6_SIT_6RD
static int ipip6_tunnel_update_6rd(struct ip_tunnel *t,
struct ip_tunnel_6rd *ip6rd)
@@ -1135,6 +1147,12 @@ ipip6_tunnel_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
struct ip_tunnel_6rd ip6rd;
#endif
+ /* Try generic tunnel ioctls first */
+ err = __ip_tunnel_gen_ioctl(dev, sitn->fb_tunnel_dev, ifr, cmd);
+ if (err != -ENOIOCTLCMD)
+ return err;
+
+ err = 0;
switch (cmd) {
case SIOCGETTUNNEL:
#ifdef CONFIG_IPV6_SIT_6RD
@@ -1466,6 +1484,40 @@ static void ipip6_netlink_parms(struct nlattr *data[],
}
+/* This function returns true when ENCAP attributes are present in the nl msg */
+static bool ipip6_netlink_encap_parms(struct nlattr *data[],
+ struct ip_tunnel_encap *ipencap)
+{
+ bool ret = false;
+
+ memset(ipencap, 0, sizeof(*ipencap));
+
+ if (!data)
+ return ret;
+
+ if (data[IFLA_IPTUN_ENCAP_TYPE]) {
+ ret = true;
+ ipencap->type = nla_get_u16(data[IFLA_IPTUN_ENCAP_TYPE]);
+ }
+
+ if (data[IFLA_IPTUN_ENCAP_FLAGS]) {
+ ret = true;
+ ipencap->flags = nla_get_u16(data[IFLA_IPTUN_ENCAP_FLAGS]);
+ }
+
+ if (data[IFLA_IPTUN_ENCAP_SPORT]) {
+ ret = true;
+ ipencap->sport = nla_get_u16(data[IFLA_IPTUN_ENCAP_SPORT]);
+ }
+
+ if (data[IFLA_IPTUN_ENCAP_DPORT]) {
+ ret = true;
+ ipencap->dport = nla_get_u16(data[IFLA_IPTUN_ENCAP_DPORT]);
+ }
+
+ return ret;
+}
+
#ifdef CONFIG_IPV6_SIT_6RD
/* This function returns true when 6RD attributes are present in the nl msg */
static bool ipip6_netlink_6rd_parms(struct nlattr *data[],
@@ -1509,6 +1561,7 @@ static int ipip6_newlink(struct net *src_net, struct net_device *dev,
{
struct net *net = dev_net(dev);
struct ip_tunnel *nt;
+ struct ip_tunnel_encap ipencap;
#ifdef CONFIG_IPV6_SIT_6RD
struct ip_tunnel_6rd ip6rd;
#endif
@@ -1524,6 +1577,12 @@ static int ipip6_newlink(struct net *src_net, struct net_device *dev,
if (err < 0)
return err;
+ if (ipip6_netlink_encap_parms(data, &ipencap)) {
+ err = ipip6_tunnel_update_encap(nt, &ipencap);
+ if (err < 0)
+ return err;
+ }
+
#ifdef CONFIG_IPV6_SIT_6RD
if (ipip6_netlink_6rd_parms(data, &ip6rd))
err = ipip6_tunnel_update_6rd(nt, &ip6rd);
@@ -1537,11 +1596,13 @@ static int ipip6_changelink(struct net_device *dev, struct nlattr *tb[],
{
struct ip_tunnel *t = netdev_priv(dev);
struct ip_tunnel_parm p;
+ struct ip_tunnel_encap ipencap;
struct net *net = t->net;
struct sit_net *sitn = net_generic(net, sit_net_id);
#ifdef CONFIG_IPV6_SIT_6RD
struct ip_tunnel_6rd ip6rd;
#endif
+ int err;
if (dev == sitn->fb_tunnel_dev)
return -EINVAL;
@@ -1562,6 +1623,12 @@ static int ipip6_changelink(struct net_device *dev, struct nlattr *tb[],
ipip6_tunnel_update(t, &p);
+ if (ipip6_netlink_encap_parms(data, &ipencap)) {
+ err = ipip6_tunnel_update_encap(t, &ipencap);
+ if (err < 0)
+ return err;
+ }
+
#ifdef CONFIG_IPV6_SIT_6RD
if (ipip6_netlink_6rd_parms(data, &ip6rd))
return ipip6_tunnel_update_6rd(t, &ip6rd);
--
2.1.0.rc2.206.gedb03e5
next prev parent reply other threads:[~2014-09-11 20:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-11 20:07 [PATCH net-next 0/7] net: foo-over-udp (fou) Tom Herbert
2014-09-11 20:07 ` [PATCH net-next 1/7] net: Export inet_offloads and inet6_offloads Tom Herbert
2014-09-11 20:07 ` [PATCH net-next 2/7] fou: Support for foo-over-udp RX path Tom Herbert
2014-09-13 17:09 ` David Miller
2014-09-11 20:07 ` [PATCH net-next 3/7] fou: Add GRO support Tom Herbert
2014-09-11 20:07 ` [PATCH net-next 4/7] net: Changes to ip_tunnel to support foo-over-udp encapsulation Tom Herbert
2014-09-13 17:09 ` David Miller
2014-09-11 20:07 ` Tom Herbert [this message]
2014-09-11 20:07 ` [PATCH net-next 6/7] ipip: TX path for IPIP/UDP " Tom Herbert
2014-09-11 20:07 ` [PATCH net-next 7/7] gre: TX path for GRE/UDP " Tom Herbert
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=1410466056-30239-6-git-send-email-therbert@google.com \
--to=therbert@google.com \
--cc=davem@davemloft.net \
--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).