diff options
author | David S. Miller <davem@davemloft.net> | 2011-03-12 00:00:52 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-03-12 18:08:42 -0500 |
commit | 78fbfd8a653ca972afe479517a40661bfff6d8c3 (patch) | |
tree | 9dccc5c16bf269d53d8499064ec95a998e84c646 /net/ipv6 | |
parent | 1561747ddf9d28185548687b11aae7074d6129c4 (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/ipv6')
-rw-r--r-- | net/ipv6/ip6_tunnel.c | 19 | ||||
-rw-r--r-- | net/ipv6/sit.c | 31 |
2 files changed, 23 insertions, 27 deletions
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index ea8d5e8128a9..f199b8486120 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
@@ -536,7 +536,6 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
536 | int err; | 536 | int err; |
537 | struct sk_buff *skb2; | 537 | struct sk_buff *skb2; |
538 | struct iphdr *eiph; | 538 | struct iphdr *eiph; |
539 | struct flowi fl; | ||
540 | struct rtable *rt; | 539 | struct rtable *rt; |
541 | 540 | ||
542 | err = ip6_tnl_err(skb, IPPROTO_IPIP, opt, &rel_type, &rel_code, | 541 | err = ip6_tnl_err(skb, IPPROTO_IPIP, opt, &rel_type, &rel_code, |
@@ -578,11 +577,10 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
578 | eiph = ip_hdr(skb2); | 577 | eiph = ip_hdr(skb2); |
579 | 578 | ||
580 | /* Try to guess incoming interface */ | 579 | /* Try to guess incoming interface */ |
581 | memset(&fl, 0, sizeof(fl)); | 580 | rt = ip_route_output_ports(dev_net(skb->dev), NULL, |
582 | fl.fl4_dst = eiph->saddr; | 581 | eiph->saddr, 0, |
583 | fl.fl4_tos = RT_TOS(eiph->tos); | 582 | 0, 0, |
584 | fl.proto = IPPROTO_IPIP; | 583 | IPPROTO_IPIP, RT_TOS(eiph->tos), 0); |
585 | rt = ip_route_output_key(dev_net(skb->dev), &fl); | ||
586 | if (IS_ERR(rt)) | 584 | if (IS_ERR(rt)) |
587 | goto out; | 585 | goto out; |
588 | 586 | ||
@@ -592,10 +590,11 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
592 | if (rt->rt_flags & RTCF_LOCAL) { | 590 | if (rt->rt_flags & RTCF_LOCAL) { |
593 | ip_rt_put(rt); | 591 | ip_rt_put(rt); |
594 | rt = NULL; | 592 | rt = NULL; |
595 | fl.fl4_dst = eiph->daddr; | 593 | rt = ip_route_output_ports(dev_net(skb->dev), NULL, |
596 | fl.fl4_src = eiph->saddr; | 594 | eiph->daddr, eiph->saddr, |
597 | fl.fl4_tos = eiph->tos; | 595 | 0, 0, |
598 | rt = ip_route_output_key(dev_net(skb->dev), &fl); | 596 | IPPROTO_IPIP, |
597 | RT_TOS(eiph->tos), 0); | ||
599 | if (IS_ERR(rt) || | 598 | if (IS_ERR(rt) || |
600 | rt->dst.dev->type != ARPHRD_TUNNEL) { | 599 | rt->dst.dev->type != ARPHRD_TUNNEL) { |
601 | if (!IS_ERR(rt)) | 600 | if (!IS_ERR(rt)) |
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 3534ceaa4fba..43b33373adb2 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c | |||
@@ -732,17 +732,14 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, | |||
732 | dst = addr6->s6_addr32[3]; | 732 | dst = addr6->s6_addr32[3]; |
733 | } | 733 | } |
734 | 734 | ||
735 | { | 735 | rt = ip_route_output_ports(dev_net(dev), NULL, |
736 | struct flowi fl = { .fl4_dst = dst, | 736 | dst, tiph->saddr, |
737 | .fl4_src = tiph->saddr, | 737 | 0, 0, |
738 | .fl4_tos = RT_TOS(tos), | 738 | IPPROTO_IPV6, RT_TOS(tos), |
739 | .oif = tunnel->parms.link, | 739 | tunnel->parms.link); |
740 | .proto = IPPROTO_IPV6 }; | 740 | if (IS_ERR(rt)) { |
741 | rt = ip_route_output_key(dev_net(dev), &fl); | 741 | dev->stats.tx_carrier_errors++; |
742 | if (IS_ERR(rt)) { | 742 | goto tx_error_icmp; |
743 | dev->stats.tx_carrier_errors++; | ||
744 | goto tx_error_icmp; | ||
745 | } | ||
746 | } | 743 | } |
747 | if (rt->rt_type != RTN_UNICAST) { | 744 | if (rt->rt_type != RTN_UNICAST) { |
748 | ip_rt_put(rt); | 745 | ip_rt_put(rt); |
@@ -858,12 +855,12 @@ static void ipip6_tunnel_bind_dev(struct net_device *dev) | |||
858 | iph = &tunnel->parms.iph; | 855 | iph = &tunnel->parms.iph; |
859 | 856 | ||
860 | if (iph->daddr) { | 857 | if (iph->daddr) { |
861 | struct flowi fl = { .fl4_dst = iph->daddr, | 858 | struct rtable *rt = ip_route_output_ports(dev_net(dev), NULL, |
862 | .fl4_src = iph->saddr, | 859 | iph->daddr, iph->saddr, |
863 | .fl4_tos = RT_TOS(iph->tos), | 860 | 0, 0, |
864 | .oif = tunnel->parms.link, | 861 | IPPROTO_IPV6, |
865 | .proto = IPPROTO_IPV6 }; | 862 | RT_TOS(iph->tos), |
866 | struct rtable *rt = ip_route_output_key(dev_net(dev), &fl); | 863 | tunnel->parms.link); |
867 | 864 | ||
868 | if (!IS_ERR(rt)) { | 865 | if (!IS_ERR(rt)) { |
869 | tdev = rt->dst.dev; | 866 | tdev = rt->dst.dev; |