mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
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 <[email protected]>
This commit is contained in:
parent
1561747ddf
commit
78fbfd8a65
23 changed files with 206 additions and 326 deletions
|
|
@ -536,7 +536,6 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
|
|||
int err;
|
||||
struct sk_buff *skb2;
|
||||
struct iphdr *eiph;
|
||||
struct flowi fl;
|
||||
struct rtable *rt;
|
||||
|
||||
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,
|
|||
eiph = ip_hdr(skb2);
|
||||
|
||||
/* Try to guess incoming interface */
|
||||
memset(&fl, 0, sizeof(fl));
|
||||
fl.fl4_dst = eiph->saddr;
|
||||
fl.fl4_tos = RT_TOS(eiph->tos);
|
||||
fl.proto = IPPROTO_IPIP;
|
||||
rt = ip_route_output_key(dev_net(skb->dev), &fl);
|
||||
rt = ip_route_output_ports(dev_net(skb->dev), NULL,
|
||||
eiph->saddr, 0,
|
||||
0, 0,
|
||||
IPPROTO_IPIP, RT_TOS(eiph->tos), 0);
|
||||
if (IS_ERR(rt))
|
||||
goto out;
|
||||
|
||||
|
|
@ -592,10 +590,11 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
|
|||
if (rt->rt_flags & RTCF_LOCAL) {
|
||||
ip_rt_put(rt);
|
||||
rt = NULL;
|
||||
fl.fl4_dst = eiph->daddr;
|
||||
fl.fl4_src = eiph->saddr;
|
||||
fl.fl4_tos = eiph->tos;
|
||||
rt = ip_route_output_key(dev_net(skb->dev), &fl);
|
||||
rt = ip_route_output_ports(dev_net(skb->dev), NULL,
|
||||
eiph->daddr, eiph->saddr,
|
||||
0, 0,
|
||||
IPPROTO_IPIP,
|
||||
RT_TOS(eiph->tos), 0);
|
||||
if (IS_ERR(rt) ||
|
||||
rt->dst.dev->type != ARPHRD_TUNNEL) {
|
||||
if (!IS_ERR(rt))
|
||||
|
|
|
|||
|
|
@ -732,17 +732,14 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
|
|||
dst = addr6->s6_addr32[3];
|
||||
}
|
||||
|
||||
{
|
||||
struct flowi fl = { .fl4_dst = dst,
|
||||
.fl4_src = tiph->saddr,
|
||||
.fl4_tos = RT_TOS(tos),
|
||||
.oif = tunnel->parms.link,
|
||||
.proto = IPPROTO_IPV6 };
|
||||
rt = ip_route_output_key(dev_net(dev), &fl);
|
||||
if (IS_ERR(rt)) {
|
||||
dev->stats.tx_carrier_errors++;
|
||||
goto tx_error_icmp;
|
||||
}
|
||||
rt = ip_route_output_ports(dev_net(dev), NULL,
|
||||
dst, tiph->saddr,
|
||||
0, 0,
|
||||
IPPROTO_IPV6, RT_TOS(tos),
|
||||
tunnel->parms.link);
|
||||
if (IS_ERR(rt)) {
|
||||
dev->stats.tx_carrier_errors++;
|
||||
goto tx_error_icmp;
|
||||
}
|
||||
if (rt->rt_type != RTN_UNICAST) {
|
||||
ip_rt_put(rt);
|
||||
|
|
@ -858,12 +855,12 @@ static void ipip6_tunnel_bind_dev(struct net_device *dev)
|
|||
iph = &tunnel->parms.iph;
|
||||
|
||||
if (iph->daddr) {
|
||||
struct flowi fl = { .fl4_dst = iph->daddr,
|
||||
.fl4_src = iph->saddr,
|
||||
.fl4_tos = RT_TOS(iph->tos),
|
||||
.oif = tunnel->parms.link,
|
||||
.proto = IPPROTO_IPV6 };
|
||||
struct rtable *rt = ip_route_output_key(dev_net(dev), &fl);
|
||||
struct rtable *rt = ip_route_output_ports(dev_net(dev), NULL,
|
||||
iph->daddr, iph->saddr,
|
||||
0, 0,
|
||||
IPPROTO_IPV6,
|
||||
RT_TOS(iph->tos),
|
||||
tunnel->parms.link);
|
||||
|
||||
if (!IS_ERR(rt)) {
|
||||
tdev = rt->dst.dev;
|
||||
|
|
|
|||
Loading…
Reference in a new issue