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 /drivers/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 'drivers/net')
-rw-r--r-- | drivers/net/bonding/bond_main.c | 12 | ||||
-rw-r--r-- | drivers/net/cnic.c | 16 | ||||
-rw-r--r-- | drivers/net/pptp.c | 45 |
3 files changed, 27 insertions, 46 deletions
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; |