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 | |
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')
-rw-r--r-- | net/atm/clip.c | 4 | ||||
-rw-r--r-- | net/bridge/br_netfilter.c | 7 | ||||
-rw-r--r-- | net/ipv4/af_inet.c | 20 | ||||
-rw-r--r-- | net/ipv4/arp.c | 12 | ||||
-rw-r--r-- | net/ipv4/igmp.c | 34 | ||||
-rw-r--r-- | net/ipv4/ip_gre.c | 49 | ||||
-rw-r--r-- | net/ipv4/ip_output.c | 33 | ||||
-rw-r--r-- | net/ipv4/ipip.c | 36 | ||||
-rw-r--r-- | net/ipv4/ipmr.c | 24 | ||||
-rw-r--r-- | net/ipv6/ip6_tunnel.c | 19 | ||||
-rw-r--r-- | net/ipv6/sit.c | 31 | ||||
-rw-r--r-- | net/l2tp/l2tp_ip.c | 30 | ||||
-rw-r--r-- | net/netfilter/ipvs/ip_vs_xmit.c | 14 | ||||
-rw-r--r-- | net/rxrpc/ar-peer.c | 23 |
14 files changed, 118 insertions, 218 deletions
diff --git a/net/atm/clip.c b/net/atm/clip.c index 810a1294eddb..1d4be60e1390 100644 --- a/net/atm/clip.c +++ b/net/atm/clip.c | |||
@@ -502,8 +502,6 @@ static int clip_setentry(struct atm_vcc *vcc, __be32 ip) | |||
502 | struct atmarp_entry *entry; | 502 | struct atmarp_entry *entry; |
503 | int error; | 503 | int error; |
504 | struct clip_vcc *clip_vcc; | 504 | struct clip_vcc *clip_vcc; |
505 | struct flowi fl = { .fl4_dst = ip, | ||
506 | .fl4_tos = 1 }; | ||
507 | struct rtable *rt; | 505 | struct rtable *rt; |
508 | 506 | ||
509 | if (vcc->push != clip_push) { | 507 | if (vcc->push != clip_push) { |
@@ -520,7 +518,7 @@ static int clip_setentry(struct atm_vcc *vcc, __be32 ip) | |||
520 | unlink_clip_vcc(clip_vcc); | 518 | unlink_clip_vcc(clip_vcc); |
521 | return 0; | 519 | return 0; |
522 | } | 520 | } |
523 | rt = ip_route_output_key(&init_net, &fl); | 521 | rt = ip_route_output(&init_net, ip, 0, 1, 0); |
524 | if (IS_ERR(rt)) | 522 | if (IS_ERR(rt)) |
525 | return PTR_ERR(rt); | 523 | return PTR_ERR(rt); |
526 | neigh = __neigh_lookup(&clip_tbl, &ip, rt->dst.dev, 1); | 524 | neigh = __neigh_lookup(&clip_tbl, &ip, rt->dst.dev, 1); |
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c index 45b57b173f70..f97af5590ba1 100644 --- a/net/bridge/br_netfilter.c +++ b/net/bridge/br_netfilter.c | |||
@@ -412,10 +412,6 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb) | |||
412 | nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING; | 412 | nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING; |
413 | if (dnat_took_place(skb)) { | 413 | if (dnat_took_place(skb)) { |
414 | if ((err = ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev))) { | 414 | if ((err = ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev))) { |
415 | struct flowi fl = { | ||
416 | .fl4_dst = iph->daddr, | ||
417 | .fl4_tos = RT_TOS(iph->tos), | ||
418 | }; | ||
419 | struct in_device *in_dev = __in_dev_get_rcu(dev); | 415 | struct in_device *in_dev = __in_dev_get_rcu(dev); |
420 | 416 | ||
421 | /* If err equals -EHOSTUNREACH the error is due to a | 417 | /* If err equals -EHOSTUNREACH the error is due to a |
@@ -428,7 +424,8 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb) | |||
428 | if (err != -EHOSTUNREACH || !in_dev || IN_DEV_FORWARD(in_dev)) | 424 | if (err != -EHOSTUNREACH || !in_dev || IN_DEV_FORWARD(in_dev)) |
429 | goto free_skb; | 425 | goto free_skb; |
430 | 426 | ||
431 | rt = ip_route_output_key(dev_net(dev), &fl); | 427 | rt = ip_route_output(dev_net(dev), iph->daddr, 0, |
428 | RT_TOS(iph->tos), 0); | ||
432 | if (!IS_ERR(rt)) { | 429 | if (!IS_ERR(rt)) { |
433 | /* - Bridged-and-DNAT'ed traffic doesn't | 430 | /* - Bridged-and-DNAT'ed traffic doesn't |
434 | * require ip_forwarding. */ | 431 | * require ip_forwarding. */ |
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 35a502055018..807d83c02ef6 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -1157,22 +1157,10 @@ int inet_sk_rebuild_header(struct sock *sk) | |||
1157 | daddr = inet->inet_daddr; | 1157 | daddr = inet->inet_daddr; |
1158 | if (inet->opt && inet->opt->srr) | 1158 | if (inet->opt && inet->opt->srr) |
1159 | daddr = inet->opt->faddr; | 1159 | daddr = inet->opt->faddr; |
1160 | { | 1160 | rt = ip_route_output_ports(sock_net(sk), sk, daddr, inet->inet_saddr, |
1161 | struct flowi fl = { | 1161 | inet->inet_dport, inet->inet_sport, |
1162 | .oif = sk->sk_bound_dev_if, | 1162 | sk->sk_protocol, RT_CONN_FLAGS(sk), |
1163 | .mark = sk->sk_mark, | 1163 | sk->sk_bound_dev_if); |
1164 | .fl4_dst = daddr, | ||
1165 | .fl4_src = inet->inet_saddr, | ||
1166 | .fl4_tos = RT_CONN_FLAGS(sk), | ||
1167 | .proto = sk->sk_protocol, | ||
1168 | .flags = inet_sk_flowi_flags(sk), | ||
1169 | .fl_ip_sport = inet->inet_sport, | ||
1170 | .fl_ip_dport = inet->inet_dport, | ||
1171 | }; | ||
1172 | |||
1173 | security_sk_classify_flow(sk, &fl); | ||
1174 | rt = ip_route_output_flow(sock_net(sk), &fl, sk); | ||
1175 | } | ||
1176 | if (!IS_ERR(rt)) { | 1164 | if (!IS_ERR(rt)) { |
1177 | err = 0; | 1165 | err = 0; |
1178 | sk_setup_caps(sk, &rt->dst); | 1166 | sk_setup_caps(sk, &rt->dst); |
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index fa9988da1da4..090d273d7865 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c | |||
@@ -433,14 +433,12 @@ static int arp_ignore(struct in_device *in_dev, __be32 sip, __be32 tip) | |||
433 | 433 | ||
434 | static int arp_filter(__be32 sip, __be32 tip, struct net_device *dev) | 434 | static int arp_filter(__be32 sip, __be32 tip, struct net_device *dev) |
435 | { | 435 | { |
436 | struct flowi fl = { .fl4_dst = sip, | ||
437 | .fl4_src = tip }; | ||
438 | struct rtable *rt; | 436 | struct rtable *rt; |
439 | int flag = 0; | 437 | int flag = 0; |
440 | /*unsigned long now; */ | 438 | /*unsigned long now; */ |
441 | struct net *net = dev_net(dev); | 439 | struct net *net = dev_net(dev); |
442 | 440 | ||
443 | rt = ip_route_output_key(net, &fl); | 441 | rt = ip_route_output(net, sip, tip, 0, 0); |
444 | if (IS_ERR(rt)) | 442 | if (IS_ERR(rt)) |
445 | return 1; | 443 | return 1; |
446 | if (rt->dst.dev != dev) { | 444 | if (rt->dst.dev != dev) { |
@@ -1062,9 +1060,7 @@ static int arp_req_set(struct net *net, struct arpreq *r, | |||
1062 | if (r->arp_flags & ATF_PERM) | 1060 | if (r->arp_flags & ATF_PERM) |
1063 | r->arp_flags |= ATF_COM; | 1061 | r->arp_flags |= ATF_COM; |
1064 | if (dev == NULL) { | 1062 | if (dev == NULL) { |
1065 | struct flowi fl = { .fl4_dst = ip, | 1063 | struct rtable *rt = ip_route_output(net, ip, 0, RTO_ONLINK, 0); |
1066 | .fl4_tos = RTO_ONLINK }; | ||
1067 | struct rtable *rt = ip_route_output_key(net, &fl); | ||
1068 | 1064 | ||
1069 | if (IS_ERR(rt)) | 1065 | if (IS_ERR(rt)) |
1070 | return PTR_ERR(rt); | 1066 | return PTR_ERR(rt); |
@@ -1185,9 +1181,7 @@ static int arp_req_delete(struct net *net, struct arpreq *r, | |||
1185 | 1181 | ||
1186 | ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr; | 1182 | ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr; |
1187 | if (dev == NULL) { | 1183 | if (dev == NULL) { |
1188 | struct flowi fl = { .fl4_dst = ip, | 1184 | struct rtable *rt = ip_route_output(net, ip, 0, RTO_ONLINK, 0); |
1189 | .fl4_tos = RTO_ONLINK }; | ||
1190 | struct rtable *rt = ip_route_output_key(net, &fl); | ||
1191 | if (IS_ERR(rt)) | 1185 | if (IS_ERR(rt)) |
1192 | return PTR_ERR(rt); | 1186 | return PTR_ERR(rt); |
1193 | dev = rt->dst.dev; | 1187 | dev = rt->dst.dev; |
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 12b65ccca8e9..1fd3d9ce8398 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
@@ -321,15 +321,12 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size) | |||
321 | } | 321 | } |
322 | igmp_skb_size(skb) = size; | 322 | igmp_skb_size(skb) = size; |
323 | 323 | ||
324 | { | 324 | rt = ip_route_output_ports(net, NULL, IGMPV3_ALL_MCR, 0, |
325 | struct flowi fl = { .oif = dev->ifindex, | 325 | 0, 0, |
326 | .fl4_dst = IGMPV3_ALL_MCR, | 326 | IPPROTO_IGMP, 0, dev->ifindex); |
327 | .proto = IPPROTO_IGMP }; | 327 | if (IS_ERR(rt)) { |
328 | rt = ip_route_output_key(net, &fl); | 328 | kfree_skb(skb); |
329 | if (IS_ERR(rt)) { | 329 | return NULL; |
330 | kfree_skb(skb); | ||
331 | return NULL; | ||
332 | } | ||
333 | } | 330 | } |
334 | if (rt->rt_src == 0) { | 331 | if (rt->rt_src == 0) { |
335 | kfree_skb(skb); | 332 | kfree_skb(skb); |
@@ -667,14 +664,12 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc, | |||
667 | else | 664 | else |
668 | dst = group; | 665 | dst = group; |
669 | 666 | ||
670 | { | 667 | rt = ip_route_output_ports(net, NULL, dst, 0, |
671 | struct flowi fl = { .oif = dev->ifindex, | 668 | 0, 0, |
672 | .fl4_dst = dst, | 669 | IPPROTO_IGMP, 0, dev->ifindex); |
673 | .proto = IPPROTO_IGMP }; | 670 | if (IS_ERR(rt)) |
674 | rt = ip_route_output_key(net, &fl); | 671 | return -1; |
675 | if (IS_ERR(rt)) | 672 | |
676 | return -1; | ||
677 | } | ||
678 | if (rt->rt_src == 0) { | 673 | if (rt->rt_src == 0) { |
679 | ip_rt_put(rt); | 674 | ip_rt_put(rt); |
680 | return -1; | 675 | return -1; |
@@ -1441,7 +1436,6 @@ void ip_mc_destroy_dev(struct in_device *in_dev) | |||
1441 | /* RTNL is locked */ | 1436 | /* RTNL is locked */ |
1442 | static struct in_device *ip_mc_find_dev(struct net *net, struct ip_mreqn *imr) | 1437 | static struct in_device *ip_mc_find_dev(struct net *net, struct ip_mreqn *imr) |
1443 | { | 1438 | { |
1444 | struct flowi fl = { .fl4_dst = imr->imr_multiaddr.s_addr }; | ||
1445 | struct net_device *dev = NULL; | 1439 | struct net_device *dev = NULL; |
1446 | struct in_device *idev = NULL; | 1440 | struct in_device *idev = NULL; |
1447 | 1441 | ||
@@ -1456,7 +1450,9 @@ static struct in_device *ip_mc_find_dev(struct net *net, struct ip_mreqn *imr) | |||
1456 | } | 1450 | } |
1457 | 1451 | ||
1458 | if (!dev) { | 1452 | if (!dev) { |
1459 | struct rtable *rt = ip_route_output_key(net, &fl); | 1453 | struct rtable *rt = ip_route_output(net, |
1454 | imr->imr_multiaddr.s_addr, | ||
1455 | 0, 0, 0); | ||
1460 | if (!IS_ERR(rt)) { | 1456 | if (!IS_ERR(rt)) { |
1461 | dev = rt->dst.dev; | 1457 | dev = rt->dst.dev; |
1462 | ip_rt_put(rt); | 1458 | ip_rt_put(rt); |
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 71465955520b..da5941f18c3c 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -769,20 +769,12 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev | |||
769 | tos = ipv6_get_dsfield((struct ipv6hdr *)old_iph); | 769 | tos = ipv6_get_dsfield((struct ipv6hdr *)old_iph); |
770 | } | 770 | } |
771 | 771 | ||
772 | { | 772 | rt = ip_route_output_gre(dev_net(dev), dst, tiph->saddr, |
773 | struct flowi fl = { | 773 | tunnel->parms.o_key, RT_TOS(tos), |
774 | .oif = tunnel->parms.link, | 774 | tunnel->parms.link); |
775 | .fl4_dst = dst, | 775 | if (IS_ERR(rt)) { |
776 | .fl4_src = tiph->saddr, | 776 | dev->stats.tx_carrier_errors++; |
777 | .fl4_tos = RT_TOS(tos), | 777 | goto tx_error; |
778 | .proto = IPPROTO_GRE, | ||
779 | .fl_gre_key = tunnel->parms.o_key | ||
780 | }; | ||
781 | rt = ip_route_output_key(dev_net(dev), &fl); | ||
782 | if (IS_ERR(rt)) { | ||
783 | dev->stats.tx_carrier_errors++; | ||
784 | goto tx_error; | ||
785 | } | ||
786 | } | 778 | } |
787 | tdev = rt->dst.dev; | 779 | tdev = rt->dst.dev; |
788 | 780 | ||
@@ -946,15 +938,11 @@ static int ipgre_tunnel_bind_dev(struct net_device *dev) | |||
946 | /* Guess output device to choose reasonable mtu and needed_headroom */ | 938 | /* Guess output device to choose reasonable mtu and needed_headroom */ |
947 | 939 | ||
948 | if (iph->daddr) { | 940 | if (iph->daddr) { |
949 | struct flowi fl = { | 941 | struct rtable *rt = ip_route_output_gre(dev_net(dev), |
950 | .oif = tunnel->parms.link, | 942 | iph->daddr, iph->saddr, |
951 | .fl4_dst = iph->daddr, | 943 | tunnel->parms.o_key, |
952 | .fl4_src = iph->saddr, | 944 | RT_TOS(iph->tos), |
953 | .fl4_tos = RT_TOS(iph->tos), | 945 | tunnel->parms.link); |
954 | .proto = IPPROTO_GRE, | ||
955 | .fl_gre_key = tunnel->parms.o_key | ||
956 | }; | ||
957 | struct rtable *rt = ip_route_output_key(dev_net(dev), &fl); | ||
958 | 946 | ||
959 | if (!IS_ERR(rt)) { | 947 | if (!IS_ERR(rt)) { |
960 | tdev = rt->dst.dev; | 948 | tdev = rt->dst.dev; |
@@ -1208,15 +1196,12 @@ static int ipgre_open(struct net_device *dev) | |||
1208 | struct ip_tunnel *t = netdev_priv(dev); | 1196 | struct ip_tunnel *t = netdev_priv(dev); |
1209 | 1197 | ||
1210 | if (ipv4_is_multicast(t->parms.iph.daddr)) { | 1198 | if (ipv4_is_multicast(t->parms.iph.daddr)) { |
1211 | struct flowi fl = { | 1199 | struct rtable *rt = ip_route_output_gre(dev_net(dev), |
1212 | .oif = t->parms.link, | 1200 | t->parms.iph.daddr, |
1213 | .fl4_dst = t->parms.iph.daddr, | 1201 | t->parms.iph.saddr, |
1214 | .fl4_src = t->parms.iph.saddr, | 1202 | t->parms.o_key, |
1215 | .fl4_tos = RT_TOS(t->parms.iph.tos), | 1203 | RT_TOS(t->parms.iph.tos), |
1216 | .proto = IPPROTO_GRE, | 1204 | t->parms.link); |
1217 | .fl_gre_key = t->parms.o_key | ||
1218 | }; | ||
1219 | struct rtable *rt = ip_route_output_key(dev_net(dev), &fl); | ||
1220 | 1205 | ||
1221 | if (IS_ERR(rt)) | 1206 | if (IS_ERR(rt)) |
1222 | return -EADDRNOTAVAIL; | 1207 | return -EADDRNOTAVAIL; |
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 171f483b21d5..916152dbdce4 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c | |||
@@ -339,26 +339,19 @@ int ip_queue_xmit(struct sk_buff *skb) | |||
339 | if(opt && opt->srr) | 339 | if(opt && opt->srr) |
340 | daddr = opt->faddr; | 340 | daddr = opt->faddr; |
341 | 341 | ||
342 | { | 342 | /* If this fails, retransmit mechanism of transport layer will |
343 | struct flowi fl = { .oif = sk->sk_bound_dev_if, | 343 | * keep trying until route appears or the connection times |
344 | .mark = sk->sk_mark, | 344 | * itself out. |
345 | .fl4_dst = daddr, | 345 | */ |
346 | .fl4_src = inet->inet_saddr, | 346 | rt = ip_route_output_ports(sock_net(sk), sk, |
347 | .fl4_tos = RT_CONN_FLAGS(sk), | 347 | daddr, inet->inet_saddr, |
348 | .proto = sk->sk_protocol, | 348 | inet->inet_dport, |
349 | .flags = inet_sk_flowi_flags(sk), | 349 | inet->inet_sport, |
350 | .fl_ip_sport = inet->inet_sport, | 350 | sk->sk_protocol, |
351 | .fl_ip_dport = inet->inet_dport }; | 351 | RT_CONN_FLAGS(sk), |
352 | 352 | sk->sk_bound_dev_if); | |
353 | /* If this fails, retransmit mechanism of transport layer will | 353 | if (IS_ERR(rt)) |
354 | * keep trying until route appears or the connection times | 354 | goto no_route; |
355 | * itself out. | ||
356 | */ | ||
357 | security_sk_classify_flow(sk, &fl); | ||
358 | rt = ip_route_output_flow(sock_net(sk), &fl, sk); | ||
359 | if (IS_ERR(rt)) | ||
360 | goto no_route; | ||
361 | } | ||
362 | sk_setup_caps(sk, &rt->dst); | 355 | sk_setup_caps(sk, &rt->dst); |
363 | } | 356 | } |
364 | skb_dst_set_noref(skb, &rt->dst); | 357 | skb_dst_set_noref(skb, &rt->dst); |
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; |
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 74909bac8817..594a3004367b 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c | |||
@@ -1611,25 +1611,19 @@ static void ipmr_queue_xmit(struct net *net, struct mr_table *mrt, | |||
1611 | #endif | 1611 | #endif |
1612 | 1612 | ||
1613 | if (vif->flags & VIFF_TUNNEL) { | 1613 | if (vif->flags & VIFF_TUNNEL) { |
1614 | struct flowi fl = { | 1614 | rt = ip_route_output_ports(net, NULL, |
1615 | .oif = vif->link, | 1615 | vif->remote, vif->local, |
1616 | .fl4_dst = vif->remote, | 1616 | 0, 0, |
1617 | .fl4_src = vif->local, | 1617 | IPPROTO_IPIP, |
1618 | .fl4_tos = RT_TOS(iph->tos), | 1618 | RT_TOS(iph->tos), vif->link); |
1619 | .proto = IPPROTO_IPIP | ||
1620 | }; | ||
1621 | rt = ip_route_output_key(net, &fl); | ||
1622 | if (IS_ERR(rt)) | 1619 | if (IS_ERR(rt)) |
1623 | goto out_free; | 1620 | goto out_free; |
1624 | encap = sizeof(struct iphdr); | 1621 | encap = sizeof(struct iphdr); |
1625 | } else { | 1622 | } else { |
1626 | struct flowi fl = { | 1623 | rt = ip_route_output_ports(net, NULL, iph->daddr, 0, |
1627 | .oif = vif->link, | 1624 | 0, 0, |
1628 | .fl4_dst = iph->daddr, | 1625 | IPPROTO_IPIP, |
1629 | .fl4_tos = RT_TOS(iph->tos), | 1626 | RT_TOS(iph->tos), vif->link); |
1630 | .proto = IPPROTO_IPIP | ||
1631 | }; | ||
1632 | rt = ip_route_output_key(net, &fl); | ||
1633 | if (IS_ERR(rt)) | 1627 | if (IS_ERR(rt)) |
1634 | goto out_free; | 1628 | goto out_free; |
1635 | } | 1629 | } |
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; |
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c index 2a698ff89db6..fce9bd3bd3fe 100644 --- a/net/l2tp/l2tp_ip.c +++ b/net/l2tp/l2tp_ip.c | |||
@@ -475,25 +475,17 @@ static int l2tp_ip_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m | |||
475 | if (opt && opt->srr) | 475 | if (opt && opt->srr) |
476 | daddr = opt->faddr; | 476 | daddr = opt->faddr; |
477 | 477 | ||
478 | { | 478 | /* If this fails, retransmit mechanism of transport layer will |
479 | struct flowi fl = { .oif = sk->sk_bound_dev_if, | 479 | * keep trying until route appears or the connection times |
480 | .fl4_dst = daddr, | 480 | * itself out. |
481 | .fl4_src = inet->inet_saddr, | 481 | */ |
482 | .fl4_tos = RT_CONN_FLAGS(sk), | 482 | rt = ip_route_output_ports(sock_net(sk), sk, |
483 | .proto = sk->sk_protocol, | 483 | daddr, inet->inet_saddr, |
484 | .flags = inet_sk_flowi_flags(sk), | 484 | inet->inet_dport, inet->inet_sport, |
485 | .fl_ip_sport = inet->inet_sport, | 485 | sk->sk_protocol, RT_CONN_FLAGS(sk), |
486 | .fl_ip_dport = inet->inet_dport }; | 486 | sk->sk_bound_dev_if); |
487 | 487 | if (IS_ERR(rt)) | |
488 | /* If this fails, retransmit mechanism of transport layer will | 488 | goto no_route; |
489 | * keep trying until route appears or the connection times | ||
490 | * itself out. | ||
491 | */ | ||
492 | security_sk_classify_flow(sk, &fl); | ||
493 | rt = ip_route_output_flow(sock_net(sk), &fl, sk); | ||
494 | if (IS_ERR(rt)) | ||
495 | goto no_route; | ||
496 | } | ||
497 | sk_setup_caps(sk, &rt->dst); | 489 | sk_setup_caps(sk, &rt->dst); |
498 | } | 490 | } |
499 | skb_dst_set(skb, dst_clone(&rt->dst)); | 491 | skb_dst_set(skb, dst_clone(&rt->dst)); |
diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c index 878f6dd9dbad..faf381d9da7c 100644 --- a/net/netfilter/ipvs/ip_vs_xmit.c +++ b/net/netfilter/ipvs/ip_vs_xmit.c | |||
@@ -98,12 +98,7 @@ __ip_vs_get_out_rt(struct sk_buff *skb, struct ip_vs_dest *dest, | |||
98 | spin_lock(&dest->dst_lock); | 98 | spin_lock(&dest->dst_lock); |
99 | if (!(rt = (struct rtable *) | 99 | if (!(rt = (struct rtable *) |
100 | __ip_vs_dst_check(dest, rtos))) { | 100 | __ip_vs_dst_check(dest, rtos))) { |
101 | struct flowi fl = { | 101 | rt = ip_route_output(net, dest->addr.ip, 0, rtos, 0); |
102 | .fl4_dst = dest->addr.ip, | ||
103 | .fl4_tos = rtos, | ||
104 | }; | ||
105 | |||
106 | rt = ip_route_output_key(net, &fl); | ||
107 | if (IS_ERR(rt)) { | 102 | if (IS_ERR(rt)) { |
108 | spin_unlock(&dest->dst_lock); | 103 | spin_unlock(&dest->dst_lock); |
109 | IP_VS_DBG_RL("ip_route_output error, dest: %pI4\n", | 104 | IP_VS_DBG_RL("ip_route_output error, dest: %pI4\n", |
@@ -117,12 +112,7 @@ __ip_vs_get_out_rt(struct sk_buff *skb, struct ip_vs_dest *dest, | |||
117 | } | 112 | } |
118 | spin_unlock(&dest->dst_lock); | 113 | spin_unlock(&dest->dst_lock); |
119 | } else { | 114 | } else { |
120 | struct flowi fl = { | 115 | rt = ip_route_output(net, daddr, 0, rtos, 0); |
121 | .fl4_dst = daddr, | ||
122 | .fl4_tos = rtos, | ||
123 | }; | ||
124 | |||
125 | rt = ip_route_output_key(net, &fl); | ||
126 | if (IS_ERR(rt)) { | 116 | if (IS_ERR(rt)) { |
127 | IP_VS_DBG_RL("ip_route_output error, dest: %pI4\n", | 117 | IP_VS_DBG_RL("ip_route_output error, dest: %pI4\n", |
128 | &daddr); | 118 | &daddr); |
diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c index 3620c569275f..55b93dc60d0c 100644 --- a/net/rxrpc/ar-peer.c +++ b/net/rxrpc/ar-peer.c | |||
@@ -36,28 +36,13 @@ static void rxrpc_destroy_peer(struct work_struct *work); | |||
36 | static void rxrpc_assess_MTU_size(struct rxrpc_peer *peer) | 36 | static void rxrpc_assess_MTU_size(struct rxrpc_peer *peer) |
37 | { | 37 | { |
38 | struct rtable *rt; | 38 | struct rtable *rt; |
39 | struct flowi fl; | ||
40 | 39 | ||
41 | peer->if_mtu = 1500; | 40 | peer->if_mtu = 1500; |
42 | 41 | ||
43 | memset(&fl, 0, sizeof(fl)); | 42 | rt = ip_route_output_ports(&init_net, NULL, |
44 | 43 | peer->srx.transport.sin.sin_addr.s_addr, 0, | |
45 | switch (peer->srx.transport.family) { | 44 | htons(7000), htons(7001), |
46 | case AF_INET: | 45 | IPPROTO_UDP, 0, 0); |
47 | fl.oif = 0; | ||
48 | fl.proto = IPPROTO_UDP, | ||
49 | fl.fl4_dst = peer->srx.transport.sin.sin_addr.s_addr; | ||
50 | fl.fl4_src = 0; | ||
51 | fl.fl4_tos = 0; | ||
52 | /* assume AFS.CM talking to AFS.FS */ | ||
53 | fl.fl_ip_sport = htons(7001); | ||
54 | fl.fl_ip_dport = htons(7000); | ||
55 | break; | ||
56 | default: | ||
57 | BUG(); | ||
58 | } | ||
59 | |||
60 | rt = ip_route_output_key(&init_net, &fl); | ||
61 | if (IS_ERR(rt)) { | 46 | if (IS_ERR(rt)) { |
62 | _leave(" [route err %ld]", PTR_ERR(rt)); | 47 | _leave(" [route err %ld]", PTR_ERR(rt)); |
63 | return; | 48 | return; |