Skip to content

Commit 0e3c82d

Browse files
committed
Merge branch 'ip6-tunnel-tx-fixes'
Tom Herbert says: ==================== ip6: Transmit tunneling fixes Several fixes suggested by Alexander. Tested: Running netperf TCP_STREAM with gretap and keyid configured. Visually verified that MTU is correctly being set. Did not test HW offload (Alexander plese try) ==================== Tested-by: Alexander Duyck <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2 parents bfca2eb + b45bd1d commit 0e3c82d

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed

net/ipv6/ip6_gre.c

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ static struct ip6_tnl *ip6gre_tunnel_locate(struct net *net,
343343
goto failed_free;
344344

345345
/* Can use a lockless transmit, unless we generate output sequences */
346-
if (!(nt->parms.o_flags & GRE_SEQ))
346+
if (!(nt->parms.o_flags & TUNNEL_SEQ))
347347
dev->features |= NETIF_F_LLTX;
348348

349349
dev_hold(dev);
@@ -519,7 +519,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
519519
gre_build_header(skb, tunnel->tun_hlen, tunnel->parms.o_flags,
520520
protocol, tunnel->parms.o_key, htonl(tunnel->o_seqno));
521521

522-
skb_set_inner_protocol(skb, proto);
522+
skb_set_inner_protocol(skb, protocol);
523523

524524
return ip6_tnl_xmit(skb, dev, dsfield, fl6, encap_limit, pmtu,
525525
NEXTHDR_GRE);
@@ -700,7 +700,7 @@ static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu)
700700
struct net_device *dev = t->dev;
701701
struct __ip6_tnl_parm *p = &t->parms;
702702
struct flowi6 *fl6 = &t->fl.u.ip6;
703-
int addend = sizeof(struct ipv6hdr) + 4;
703+
int t_hlen;
704704

705705
if (dev->type != ARPHRD_ETHER) {
706706
memcpy(dev->dev_addr, &p->laddr, sizeof(struct in6_addr));
@@ -727,16 +727,11 @@ static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu)
727727
else
728728
dev->flags &= ~IFF_POINTOPOINT;
729729

730-
/* Precalculate GRE options length */
731-
if (t->parms.o_flags&(GRE_CSUM|GRE_KEY|GRE_SEQ)) {
732-
if (t->parms.o_flags&GRE_CSUM)
733-
addend += 4;
734-
if (t->parms.o_flags&GRE_KEY)
735-
addend += 4;
736-
if (t->parms.o_flags&GRE_SEQ)
737-
addend += 4;
738-
}
739-
t->hlen = addend;
730+
t->tun_hlen = gre_calc_hlen(t->parms.o_flags);
731+
732+
t->hlen = t->tun_hlen;
733+
734+
t_hlen = t->hlen + sizeof(struct ipv6hdr);
740735

741736
if (p->flags & IP6_TNL_F_CAP_XMIT) {
742737
int strict = (ipv6_addr_type(&p->raddr) &
@@ -750,10 +745,11 @@ static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu)
750745
return;
751746

752747
if (rt->dst.dev) {
753-
dev->hard_header_len = rt->dst.dev->hard_header_len + addend;
748+
dev->hard_header_len = rt->dst.dev->hard_header_len +
749+
t_hlen;
754750

755751
if (set_mtu) {
756-
dev->mtu = rt->dst.dev->mtu - addend;
752+
dev->mtu = rt->dst.dev->mtu - t_hlen;
757753
if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
758754
dev->mtu -= 8;
759755
if (dev->type == ARPHRD_ETHER)
@@ -799,8 +795,8 @@ static void ip6gre_tnl_parm_from_user(struct __ip6_tnl_parm *p,
799795
p->link = u->link;
800796
p->i_key = u->i_key;
801797
p->o_key = u->o_key;
802-
p->i_flags = u->i_flags;
803-
p->o_flags = u->o_flags;
798+
p->i_flags = gre_flags_to_tnl_flags(u->i_flags);
799+
p->o_flags = gre_flags_to_tnl_flags(u->o_flags);
804800
memcpy(p->name, u->name, sizeof(u->name));
805801
}
806802

@@ -817,8 +813,8 @@ static void ip6gre_tnl_parm_to_user(struct ip6_tnl_parm2 *u,
817813
u->link = p->link;
818814
u->i_key = p->i_key;
819815
u->o_key = p->o_key;
820-
u->i_flags = p->i_flags;
821-
u->o_flags = p->o_flags;
816+
u->i_flags = gre_tnl_flags_to_gre_flags(p->i_flags);
817+
u->o_flags = gre_tnl_flags_to_gre_flags(p->o_flags);
822818
memcpy(u->name, p->name, sizeof(u->name));
823819
}
824820

@@ -1027,11 +1023,12 @@ static int ip6gre_tunnel_init_common(struct net_device *dev)
10271023

10281024
tunnel->tun_hlen = gre_calc_hlen(tunnel->parms.o_flags);
10291025

1030-
t_hlen = tunnel->hlen + sizeof(struct ipv6hdr);
1026+
tunnel->hlen = tunnel->tun_hlen;
10311027

1032-
dev->needed_headroom = LL_MAX_HEADER + t_hlen + 4;
1033-
dev->mtu = ETH_DATA_LEN - t_hlen - 4;
1028+
t_hlen = tunnel->hlen + sizeof(struct ipv6hdr);
10341029

1030+
dev->hard_header_len = LL_MAX_HEADER + t_hlen;
1031+
dev->mtu = ETH_DATA_LEN - t_hlen;
10351032
if (!(tunnel->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
10361033
dev->mtu -= 8;
10371034

@@ -1217,10 +1214,12 @@ static void ip6gre_netlink_parms(struct nlattr *data[],
12171214
parms->link = nla_get_u32(data[IFLA_GRE_LINK]);
12181215

12191216
if (data[IFLA_GRE_IFLAGS])
1220-
parms->i_flags = nla_get_be16(data[IFLA_GRE_IFLAGS]);
1217+
parms->i_flags = gre_flags_to_tnl_flags(
1218+
nla_get_be16(data[IFLA_GRE_IFLAGS]));
12211219

12221220
if (data[IFLA_GRE_OFLAGS])
1223-
parms->o_flags = nla_get_be16(data[IFLA_GRE_OFLAGS]);
1221+
parms->o_flags = gre_flags_to_tnl_flags(
1222+
nla_get_be16(data[IFLA_GRE_OFLAGS]));
12241223

12251224
if (data[IFLA_GRE_IKEY])
12261225
parms->i_key = nla_get_be32(data[IFLA_GRE_IKEY]);
@@ -1315,7 +1314,7 @@ static int ip6gre_newlink(struct net *src_net, struct net_device *dev,
13151314
dev->features |= GRE6_FEATURES;
13161315
dev->hw_features |= GRE6_FEATURES;
13171316

1318-
if (!(nt->parms.o_flags & GRE_SEQ)) {
1317+
if (!(nt->parms.o_flags & TUNNEL_SEQ)) {
13191318
/* TCP segmentation offload is not supported when we
13201319
* generate output sequences.
13211320
*/
@@ -1412,8 +1411,10 @@ static int ip6gre_fill_info(struct sk_buff *skb, const struct net_device *dev)
14121411
struct __ip6_tnl_parm *p = &t->parms;
14131412

14141413
if (nla_put_u32(skb, IFLA_GRE_LINK, p->link) ||
1415-
nla_put_be16(skb, IFLA_GRE_IFLAGS, p->i_flags) ||
1416-
nla_put_be16(skb, IFLA_GRE_OFLAGS, p->o_flags) ||
1414+
nla_put_be16(skb, IFLA_GRE_IFLAGS,
1415+
gre_tnl_flags_to_gre_flags(p->i_flags)) ||
1416+
nla_put_be16(skb, IFLA_GRE_OFLAGS,
1417+
gre_tnl_flags_to_gre_flags(p->o_flags)) ||
14171418
nla_put_be32(skb, IFLA_GRE_IKEY, p->i_key) ||
14181419
nla_put_be32(skb, IFLA_GRE_OKEY, p->o_key) ||
14191420
nla_put_in6_addr(skb, IFLA_GRE_LOCAL, &p->laddr) ||

net/ipv6/ip6_tunnel.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,8 +1114,6 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
11141114
dst_cache_set_ip6(&t->dst_cache, ndst, &fl6->saddr);
11151115
skb_dst_set(skb, dst);
11161116

1117-
skb->transport_header = skb->network_header;
1118-
11191117
if (encap_limit >= 0) {
11201118
init_tel_txopt(&opt, encap_limit);
11211119
ipv6_push_nfrag_opts(skb, &opt.ops, &proto, NULL);

0 commit comments

Comments
 (0)