vti6: Remove dst_entry caching

Unlike ip6_tunnel, vti6 can lookup multiple different dst entries,
dependent of the configured xfrm states. Therefore it does not make
sense to cache a dst_entry.

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
This commit is contained in:
Steffen Klassert 2014-03-14 07:28:08 +01:00
parent 59b84351c0
commit 7c85258152
1 changed files with 18 additions and 24 deletions

View File

@ -278,7 +278,6 @@ static void vti6_dev_uninit(struct net_device *dev)
RCU_INIT_POINTER(ip6n->tnls_wc[0], NULL); RCU_INIT_POINTER(ip6n->tnls_wc[0], NULL);
else else
vti6_tnl_unlink(ip6n, t); vti6_tnl_unlink(ip6n, t);
ip6_tnl_dst_reset(t);
dev_put(dev); dev_put(dev);
} }
@ -356,11 +355,10 @@ vti6_addr_conflict(const struct ip6_tnl *t, const struct ipv6hdr *hdr)
**/ **/
static int vti6_xmit(struct sk_buff *skb, struct net_device *dev) static int vti6_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
struct net *net = dev_net(dev);
struct ip6_tnl *t = netdev_priv(dev); struct ip6_tnl *t = netdev_priv(dev);
struct net_device_stats *stats = &t->dev->stats; struct net_device_stats *stats = &t->dev->stats;
struct dst_entry *dst = NULL, *ndst = NULL; struct dst_entry *dst = skb_dst(skb);
struct flowi6 fl6; struct flowi fl;
struct ipv6hdr *ipv6h = ipv6_hdr(skb); struct ipv6hdr *ipv6h = ipv6_hdr(skb);
struct net_device *tdev; struct net_device *tdev;
int err = -1; int err = -1;
@ -369,21 +367,19 @@ static int vti6_xmit(struct sk_buff *skb, struct net_device *dev)
!ip6_tnl_xmit_ctl(t) || vti6_addr_conflict(t, ipv6h)) !ip6_tnl_xmit_ctl(t) || vti6_addr_conflict(t, ipv6h))
return err; return err;
dst = ip6_tnl_dst_check(t); memset(&fl, 0, sizeof(fl));
if (!dst) { skb->mark = be32_to_cpu(t->parms.o_key);
memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6)); xfrm_decode_session(skb, &fl, AF_INET6);
ndst = ip6_route_output(net, NULL, &fl6); if (!dst)
goto tx_err_link_failure;
if (ndst->error) dst_hold(dst);
goto tx_err_link_failure; dst = xfrm_lookup(t->net, dst, &fl, NULL, 0);
ndst = xfrm_lookup(net, ndst, flowi6_to_flowi(&fl6), NULL, 0); if (IS_ERR(dst)) {
if (IS_ERR(ndst)) { err = PTR_ERR(dst);
err = PTR_ERR(ndst); dst = NULL;
ndst = NULL; goto tx_err_link_failure;
goto tx_err_link_failure;
}
dst = ndst;
} }
if (!dst->xfrm || dst->xfrm->props.mode != XFRM_MODE_TUNNEL) if (!dst->xfrm || dst->xfrm->props.mode != XFRM_MODE_TUNNEL)
@ -399,21 +395,19 @@ static int vti6_xmit(struct sk_buff *skb, struct net_device *dev)
} }
skb_dst_drop(skb); memset(IP6CB(skb), 0, sizeof(*IP6CB(skb)));
skb_dst_set_noref(skb, dst); skb_scrub_packet(skb, !net_eq(t->net, dev_net(dev)));
skb_dst_set(skb, dst);
skb->dev = skb_dst(skb)->dev;
ip6tunnel_xmit(skb, dev); ip6tunnel_xmit(skb, dev);
if (ndst) {
dev->mtu = dst_mtu(ndst);
ip6_tnl_dst_store(t, ndst);
}
return 0; return 0;
tx_err_link_failure: tx_err_link_failure:
stats->tx_carrier_errors++; stats->tx_carrier_errors++;
dst_link_failure(skb); dst_link_failure(skb);
tx_err_dst_release: tx_err_dst_release:
dst_release(ndst); dst_release(dst);
return err; return err;
} }