aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ipip.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-03-12 00:00:52 -0500
committerDavid S. Miller <davem@davemloft.net>2011-03-12 18:08:42 -0500
commit78fbfd8a653ca972afe479517a40661bfff6d8c3 (patch)
tree9dccc5c16bf269d53d8499064ec95a998e84c646 /net/ipv4/ipip.c
parent1561747ddf9d28185548687b11aae7074d6129c4 (diff)
ipv4: Create and use route lookup helpers.
The idea here is this minimizes the number of places one has to edit in order to make changes to how flows are defined and used. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ipip.c')
-rw-r--r--net/ipv4/ipip.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 65008f45addc..bfc17c5914e7 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -460,20 +460,14 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
460 goto tx_error_icmp; 460 goto tx_error_icmp;
461 } 461 }
462 462
463 { 463 rt = ip_route_output_ports(dev_net(dev), NULL,
464 struct flowi fl = { 464 dst, tiph->saddr,
465 .oif = tunnel->parms.link, 465 0, 0,
466 .fl4_dst = dst, 466 IPPROTO_IPIP, RT_TOS(tos),
467 .fl4_src= tiph->saddr, 467 tunnel->parms.link);
468 .fl4_tos = RT_TOS(tos), 468 if (IS_ERR(rt)) {
469 .proto = IPPROTO_IPIP 469 dev->stats.tx_carrier_errors++;
470 }; 470 goto tx_error_icmp;
471
472 rt = ip_route_output_key(dev_net(dev), &fl);
473 if (IS_ERR(rt)) {
474 dev->stats.tx_carrier_errors++;
475 goto tx_error_icmp;
476 }
477 } 471 }
478 tdev = rt->dst.dev; 472 tdev = rt->dst.dev;
479 473
@@ -584,14 +578,12 @@ static void ipip_tunnel_bind_dev(struct net_device *dev)
584 iph = &tunnel->parms.iph; 578 iph = &tunnel->parms.iph;
585 579
586 if (iph->daddr) { 580 if (iph->daddr) {
587 struct flowi fl = { 581 struct rtable *rt = ip_route_output_ports(dev_net(dev), NULL,
588 .oif = tunnel->parms.link, 582 iph->daddr, iph->saddr,
589 .fl4_dst = iph->daddr, 583 0, 0,
590 .fl4_src = iph->saddr, 584 IPPROTO_IPIP,
591 .fl4_tos = RT_TOS(iph->tos), 585 RT_TOS(iph->tos),
592 .proto = IPPROTO_IPIP 586 tunnel->parms.link);
593 };
594 struct rtable *rt = ip_route_output_key(dev_net(dev), &fl);
595 587
596 if (!IS_ERR(rt)) { 588 if (!IS_ERR(rt)) {
597 tdev = rt->dst.dev; 589 tdev = rt->dst.dev;