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/infiniband | |
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/infiniband')
-rw-r--r-- | drivers/infiniband/core/addr.c | 8 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb3/iwch_cm.c | 21 | ||||
-rw-r--r-- | drivers/infiniband/hw/cxgb4/cm.c | 21 | ||||
-rw-r--r-- | drivers/infiniband/hw/nes/nes_cm.c | 5 |
4 files changed, 10 insertions, 45 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, | |||
1104 | static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip, int arpindex) | 1104 | static 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); |