aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--drivers/infiniband/core/addr.c8
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_cm.c21
-rw-r--r--drivers/infiniband/hw/cxgb4/cm.c21
-rw-r--r--drivers/infiniband/hw/nes/nes_cm.c5
-rw-r--r--drivers/net/bonding/bond_main.c12
-rw-r--r--drivers/net/cnic.c16
-rw-r--r--drivers/net/pptp.c45
-rw-r--r--drivers/scsi/cxgbi/libcxgbi.c20
-rw-r--r--include/net/route.h48
-rw-r--r--net/atm/clip.c4
-rw-r--r--net/bridge/br_netfilter.c7
-rw-r--r--net/ipv4/af_inet.c20
-rw-r--r--net/ipv4/arp.c12
-rw-r--r--net/ipv4/igmp.c34
-rw-r--r--net/ipv4/ip_gre.c49
-rw-r--r--net/ipv4/ip_output.c33
-rw-r--r--net/ipv4/ipip.c36
-rw-r--r--net/ipv4/ipmr.c24
-rw-r--r--net/ipv6/ip6_tunnel.c19
-rw-r--r--net/ipv6/sit.c31
-rw-r--r--net/l2tp/l2tp_ip.c30
-rw-r--r--net/netfilter/ipvs/ip_vs_xmit.c14
-rw-r--r--net/rxrpc/ar-peer.c23
23 files changed, 206 insertions, 326 deletions
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 2d749937a969..1742f72fbd57 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -183,17 +183,11 @@ static int addr4_resolve(struct sockaddr_in *src_in,
183{ 183{
184 __be32 src_ip = src_in->sin_addr.s_addr; 184 __be32 src_ip = src_in->sin_addr.s_addr;
185 __be32 dst_ip = dst_in->sin_addr.s_addr; 185 __be32 dst_ip = dst_in->sin_addr.s_addr;
186 struct flowi fl;
187 struct rtable *rt; 186 struct rtable *rt;
188 struct neighbour *neigh; 187 struct neighbour *neigh;
189 int ret; 188 int ret;
190 189
191 memset(&fl, 0, sizeof fl); 190 rt = ip_route_output(&init_net, dst_ip, src_ip, 0, addr->bound_dev_if);
192 fl.nl_u.ip4_u.daddr = dst_ip;
193 fl.nl_u.ip4_u.saddr = src_ip;
194 fl.oif = addr->bound_dev_if;
195
196 rt = ip_route_output_key(&init_net, &fl);
197 if (IS_ERR(rt)) { 191 if (IS_ERR(rt)) {
198 ret = PTR_ERR(rt); 192 ret = PTR_ERR(rt);
199 goto out; 193 goto out;
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c
index e0ccbc53fbcc..3216bcad7e82 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
@@ -338,23 +338,10 @@ static struct rtable *find_route(struct t3cdev *dev, __be32 local_ip,
338 __be16 peer_port, u8 tos) 338 __be16 peer_port, u8 tos)
339{ 339{
340 struct rtable *rt; 340 struct rtable *rt;
341 struct flowi fl = { 341
342 .oif = 0, 342 rt = ip_route_output_ports(&init_net, NULL, peer_ip, local_ip,
343 .nl_u = { 343 peer_port, local_port, IPPROTO_TCP,
344 .ip4_u = { 344 tos, 0);
345 .daddr = peer_ip,
346 .saddr = local_ip,
347 .tos = tos}
348 },
349 .proto = IPPROTO_TCP,
350 .uli_u = {
351 .ports = {
352 .sport = local_port,
353 .dport = peer_port}
354 }
355 };
356
357 rt = ip_route_output_flow(&init_net, &fl, NULL);
358 if (IS_ERR(rt)) 345 if (IS_ERR(rt))
359 return NULL; 346 return NULL;
360 return rt; 347 return rt;
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 77b0eef2aad9..97a876a0f20b 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -315,23 +315,10 @@ static struct rtable *find_route(struct c4iw_dev *dev, __be32 local_ip,
315 __be16 peer_port, u8 tos) 315 __be16 peer_port, u8 tos)
316{ 316{
317 struct rtable *rt; 317 struct rtable *rt;
318 struct flowi fl = { 318
319 .oif = 0, 319 rt = ip_route_output_ports(&init_net, NULL, peer_ip, local_ip,
320 .nl_u = { 320 peer_port, local_port, IPPROTO_TCP,
321 .ip4_u = { 321 tos, 0);
322 .daddr = peer_ip,
323 .saddr = local_ip,
324 .tos = tos}
325 },
326 .proto = IPPROTO_TCP,
327 .uli_u = {
328 .ports = {
329 .sport = local_port,
330 .dport = peer_port}
331 }
332 };
333
334 rt = ip_route_output_flow(&init_net, &fl, NULL);
335 if (IS_ERR(rt)) 322 if (IS_ERR(rt))
336 return NULL; 323 return NULL;
337 return rt; 324 return rt;
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index e81599cb1fe6..ef3291551bc6 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -1104,15 +1104,12 @@ static inline int mini_cm_accelerated(struct nes_cm_core *cm_core,
1104static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip, int arpindex) 1104static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip, int arpindex)
1105{ 1105{
1106 struct rtable *rt; 1106 struct rtable *rt;
1107 struct flowi fl;
1108 struct neighbour *neigh; 1107 struct neighbour *neigh;
1109 int rc = arpindex; 1108 int rc = arpindex;
1110 struct net_device *netdev; 1109 struct net_device *netdev;
1111 struct nes_adapter *nesadapter = nesvnic->nesdev->nesadapter; 1110 struct nes_adapter *nesadapter = nesvnic->nesdev->nesadapter;
1112 1111
1113 memset(&fl, 0, sizeof fl); 1112 rt = ip_route_output(&init_net, htonl(dst_ip), 0, 0, 0);
1114 fl.nl_u.ip4_u.daddr = htonl(dst_ip);
1115 rt = ip_route_output_key(&init_net, &fl);
1116 if (IS_ERR(rt)) { 1113 if (IS_ERR(rt)) {
1117 printk(KERN_ERR "%s: ip_route_output_key failed for 0x%08X\n", 1114 printk(KERN_ERR "%s: ip_route_output_key failed for 0x%08X\n",
1118 __func__, dst_ip); 1115 __func__, dst_ip);
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 68a5ce0a649f..3ad4f501949e 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2676,7 +2676,6 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
2676 __be32 *targets = bond->params.arp_targets; 2676 __be32 *targets = bond->params.arp_targets;
2677 struct vlan_entry *vlan; 2677 struct vlan_entry *vlan;
2678 struct net_device *vlan_dev; 2678 struct net_device *vlan_dev;
2679 struct flowi fl;
2680 struct rtable *rt; 2679 struct rtable *rt;
2681 2680
2682 for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) { 2681 for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) {
@@ -2695,15 +2694,12 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
2695 * determine which VLAN interface would be used, so we 2694 * determine which VLAN interface would be used, so we
2696 * can tag the ARP with the proper VLAN tag. 2695 * can tag the ARP with the proper VLAN tag.
2697 */ 2696 */
2698 memset(&fl, 0, sizeof(fl)); 2697 rt = ip_route_output(dev_net(bond->dev), targets[i], 0,
2699 fl.fl4_dst = targets[i]; 2698 RTO_ONLINK, 0);
2700 fl.fl4_tos = RTO_ONLINK;
2701
2702 rt = ip_route_output_key(dev_net(bond->dev), &fl);
2703 if (IS_ERR(rt)) { 2699 if (IS_ERR(rt)) {
2704 if (net_ratelimit()) { 2700 if (net_ratelimit()) {
2705 pr_warning("%s: no route to arp_ip_target %pI4\n", 2701 pr_warning("%s: no route to arp_ip_target %pI4\n",
2706 bond->dev->name, &fl.fl4_dst); 2702 bond->dev->name, &targets[i]);
2707 } 2703 }
2708 continue; 2704 continue;
2709 } 2705 }
@@ -2739,7 +2735,7 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
2739 2735
2740 if (net_ratelimit()) { 2736 if (net_ratelimit()) {
2741 pr_warning("%s: no path to arp_ip_target %pI4 via rt.dev %s\n", 2737 pr_warning("%s: no path to arp_ip_target %pI4 via rt.dev %s\n",
2742 bond->dev->name, &fl.fl4_dst, 2738 bond->dev->name, &targets[i],
2743 rt->dst.dev ? rt->dst.dev->name : "NULL"); 2739 rt->dst.dev ? rt->dst.dev->name : "NULL");
2744 } 2740 }
2745 ip_rt_put(rt); 2741 ip_rt_put(rt);
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index 271a1f00c224..65832951fe07 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -3407,20 +3407,14 @@ static int cnic_get_v4_route(struct sockaddr_in *dst_addr,
3407 struct dst_entry **dst) 3407 struct dst_entry **dst)
3408{ 3408{
3409#if defined(CONFIG_INET) 3409#if defined(CONFIG_INET)
3410 struct flowi fl;
3411 int err;
3412 struct rtable *rt; 3410 struct rtable *rt;
3413 3411
3414 memset(&fl, 0, sizeof(fl)); 3412 rt = ip_route_output(&init_net, dst_addr->sin_addr.s_addr, 0, 0, 0);
3415 fl.nl_u.ip4_u.daddr = dst_addr->sin_addr.s_addr; 3413 if (!IS_ERR(rt)) {
3416
3417 rt = ip_route_output_key(&init_net, &fl);
3418 err = 0;
3419 if (!IS_ERR(rt))
3420 *dst = &rt->dst; 3414 *dst = &rt->dst;
3421 else 3415 return 0;
3422 err = PTR_ERR(rt); 3416 }
3423 return err; 3417 return PTR_ERR(rt);
3424#else 3418#else
3425 return -ENETUNREACH; 3419 return -ENETUNREACH;
3426#endif 3420#endif
diff --git a/drivers/net/pptp.c b/drivers/net/pptp.c
index 1af549c89d51..51dfcf8023c7 100644
--- a/drivers/net/pptp.c
+++ b/drivers/net/pptp.c
@@ -189,18 +189,14 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
189 if (sk_pppox(po)->sk_state & PPPOX_DEAD) 189 if (sk_pppox(po)->sk_state & PPPOX_DEAD)
190 goto tx_error; 190 goto tx_error;
191 191
192 { 192 rt = ip_route_output_ports(&init_net, NULL,
193 struct flowi fl = { .oif = 0, 193 opt->dst_addr.sin_addr.s_addr,
194 .nl_u = { 194 opt->src_addr.sin_addr.s_addr,
195 .ip4_u = { 195 0, 0, IPPROTO_GRE,
196 .daddr = opt->dst_addr.sin_addr.s_addr, 196 RT_TOS(0), 0);
197 .saddr = opt->src_addr.sin_addr.s_addr, 197 if (IS_ERR(rt))
198 .tos = RT_TOS(0) } }, 198 goto tx_error;
199 .proto = IPPROTO_GRE }; 199
200 rt = ip_route_output_key(&init_net, &fl);
201 if (IS_ERR(rt))
202 goto tx_error;
203 }
204 tdev = rt->dst.dev; 200 tdev = rt->dst.dev;
205 201
206 max_headroom = LL_RESERVED_SPACE(tdev) + sizeof(*iph) + sizeof(*hdr) + 2; 202 max_headroom = LL_RESERVED_SPACE(tdev) + sizeof(*iph) + sizeof(*hdr) + 2;
@@ -467,22 +463,17 @@ static int pptp_connect(struct socket *sock, struct sockaddr *uservaddr,
467 po->chan.private = sk; 463 po->chan.private = sk;
468 po->chan.ops = &pptp_chan_ops; 464 po->chan.ops = &pptp_chan_ops;
469 465
470 { 466 rt = ip_route_output_ports(&init_net, sk,
471 struct flowi fl = { 467 opt->dst_addr.sin_addr.s_addr,
472 .nl_u = { 468 opt->src_addr.sin_addr.s_addr,
473 .ip4_u = { 469 0, 0,
474 .daddr = opt->dst_addr.sin_addr.s_addr, 470 IPPROTO_GRE, RT_CONN_FLAGS(sk), 0);
475 .saddr = opt->src_addr.sin_addr.s_addr, 471 if (IS_ERR(rt)) {
476 .tos = RT_CONN_FLAGS(sk) } }, 472 error = -EHOSTUNREACH;
477 .proto = IPPROTO_GRE }; 473 goto end;
478 security_sk_classify_flow(sk, &fl);
479 rt = ip_route_output_key(&init_net, &fl);
480 if (IS_ERR(rt)) {
481 error = -EHOSTUNREACH;
482 goto end;
483 }
484 sk_setup_caps(sk, &rt->dst);
485 } 474 }
475 sk_setup_caps(sk, &rt->dst);
476
486 po->chan.mtu = dst_mtu(&rt->dst); 477 po->chan.mtu = dst_mtu(&rt->dst);
487 if (!po->chan.mtu) 478 if (!po->chan.mtu)
488 po->chan.mtu = PPP_MTU; 479 po->chan.mtu = PPP_MTU;
diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index 889199aa1f5b..a24dff9f9163 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -451,26 +451,12 @@ static struct cxgbi_sock *cxgbi_sock_create(struct cxgbi_device *cdev)
451} 451}
452 452
453static struct rtable *find_route_ipv4(__be32 saddr, __be32 daddr, 453static struct rtable *find_route_ipv4(__be32 saddr, __be32 daddr,
454 __be16 sport, __be16 dport, u8 tos) 454 __be16 sport, __be16 dport, u8 tos)
455{ 455{
456 struct rtable *rt; 456 struct rtable *rt;
457 struct flowi fl = {
458 .oif = 0,
459 .nl_u = {
460 .ip4_u = {
461 .daddr = daddr,
462 .saddr = saddr,
463 .tos = tos }
464 },
465 .proto = IPPROTO_TCP,
466 .uli_u = {
467 .ports = {
468 .sport = sport,
469 .dport = dport }
470 }
471 };
472 457
473 rt = ip_route_output_flow(&init_net, &fl, NULL); 458 rt = ip_route_output_ports(&init_net, NULL, daddr, saddr,
459 dport, sport, IPPROTO_TCP, tos, 0);
474 if (IS_ERR(rt)) 460 if (IS_ERR(rt))
475 return NULL; 461 return NULL;
476 462
diff --git a/include/net/route.h b/include/net/route.h
index 9257f5f17337..f140f4130fea 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -132,6 +132,54 @@ static inline struct rtable *ip_route_output_key(struct net *net, struct flowi *
132 return ip_route_output_flow(net, flp, NULL); 132 return ip_route_output_flow(net, flp, NULL);
133} 133}
134 134
135static inline struct rtable *ip_route_output(struct net *net, __be32 daddr,
136 __be32 saddr, u8 tos, int oif)
137{
138 struct flowi fl = {
139 .oif = oif,
140 .fl4_dst = daddr,
141 .fl4_src = saddr,
142 .fl4_tos = tos,
143 };
144 return ip_route_output_key(net, &fl);
145}
146
147static inline struct rtable *ip_route_output_ports(struct net *net, struct sock *sk,
148 __be32 daddr, __be32 saddr,
149 __be16 dport, __be16 sport,
150 __u8 proto, __u8 tos, int oif)
151{
152 struct flowi fl = {
153 .oif = oif,
154 .flags = sk ? inet_sk_flowi_flags(sk) : 0,
155 .mark = sk ? sk->sk_mark : 0,
156 .fl4_dst = daddr,
157 .fl4_src = saddr,
158 .fl4_tos = tos,
159 .proto = proto,
160 .fl_ip_dport = dport,
161 .fl_ip_sport = sport,
162 };
163 if (sk)
164 security_sk_classify_flow(sk, &fl);
165 return ip_route_output_flow(net, &fl, sk);
166}
167
168static inline struct rtable *ip_route_output_gre(struct net *net,
169 __be32 daddr, __be32 saddr,
170 __be32 gre_key, __u8 tos, int oif)
171{
172 struct flowi fl = {
173 .oif = oif,
174 .fl4_dst = daddr,
175 .fl4_src = saddr,
176 .fl4_tos = tos,
177 .proto = IPPROTO_GRE,
178 .fl_gre_key = gre_key,
179 };
180 return ip_route_output_key(net, &fl);
181}
182
135extern int ip_route_input_common(struct sk_buff *skb, __be32 dst, __be32 src, 183extern int ip_route_input_common(struct sk_buff *skb, __be32 dst, __be32 src,
136 u8 tos, struct net_device *devin, bool noref); 184 u8 tos, struct net_device *devin, bool noref);
137 185
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
434static int arp_filter(__be32 sip, __be32 tip, struct net_device *dev) 434static 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 */
1442static struct in_device *ip_mc_find_dev(struct net *net, struct ip_mreqn *imr) 1437static 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);
36static void rxrpc_assess_MTU_size(struct rxrpc_peer *peer) 36static 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;