Skip to content

Commit 31e4543

Browse files
committed
ipv4: Make caller provide on-stack flow key to ip_route_output_ports().
Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f139016 commit 31e4543

14 files changed

Lines changed: 48 additions & 31 deletions

File tree

‎drivers/infiniband/hw/cxgb3/iwch_cm.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,9 @@ static struct rtable *find_route(struct t3cdev *dev, __be32 local_ip,
338338
__be16 peer_port, u8 tos)
339339
{
340340
struct rtable *rt;
341+
struct flowi4 fl4;
341342

342-
rt = ip_route_output_ports(&init_net, NULL, peer_ip, local_ip,
343+
rt = ip_route_output_ports(&init_net, &fl4, NULL, peer_ip, local_ip,
343344
peer_port, local_port, IPPROTO_TCP,
344345
tos, 0);
345346
if (IS_ERR(rt))

‎drivers/infiniband/hw/cxgb4/cm.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,9 @@ static struct rtable *find_route(struct c4iw_dev *dev, __be32 local_ip,
315315
__be16 peer_port, u8 tos)
316316
{
317317
struct rtable *rt;
318+
struct flowi4 fl4;
318319

319-
rt = ip_route_output_ports(&init_net, NULL, peer_ip, local_ip,
320+
rt = ip_route_output_ports(&init_net, &fl4, NULL, peer_ip, local_ip,
320321
peer_port, local_port, IPPROTO_TCP,
321322
tos, 0);
322323
if (IS_ERR(rt))

‎drivers/net/pptp.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
175175
struct pptp_opt *opt = &po->proto.pptp;
176176
struct pptp_gre_header *hdr;
177177
unsigned int header_len = sizeof(*hdr);
178+
struct flowi4 fl4;
178179
int islcp;
179180
int len;
180181
unsigned char *data;
@@ -189,7 +190,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
189190
if (sk_pppox(po)->sk_state & PPPOX_DEAD)
190191
goto tx_error;
191192

192-
rt = ip_route_output_ports(&init_net, NULL,
193+
rt = ip_route_output_ports(&init_net, &fl4, NULL,
193194
opt->dst_addr.sin_addr.s_addr,
194195
opt->src_addr.sin_addr.s_addr,
195196
0, 0, IPPROTO_GRE,
@@ -434,6 +435,7 @@ static int pptp_connect(struct socket *sock, struct sockaddr *uservaddr,
434435
struct pppox_sock *po = pppox_sk(sk);
435436
struct pptp_opt *opt = &po->proto.pptp;
436437
struct rtable *rt;
438+
struct flowi4 fl4;
437439
int error = 0;
438440

439441
if (sp->sa_protocol != PX_PROTO_PPTP)
@@ -463,7 +465,7 @@ static int pptp_connect(struct socket *sock, struct sockaddr *uservaddr,
463465
po->chan.private = sk;
464466
po->chan.ops = &pptp_chan_ops;
465467

466-
rt = ip_route_output_ports(&init_net, sk,
468+
rt = ip_route_output_ports(&init_net, &fl4, sk,
467469
opt->dst_addr.sin_addr.s_addr,
468470
opt->src_addr.sin_addr.s_addr,
469471
0, 0,

‎drivers/scsi/cxgbi/libcxgbi.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,9 @@ static struct rtable *find_route_ipv4(__be32 saddr, __be32 daddr,
454454
__be16 sport, __be16 dport, u8 tos)
455455
{
456456
struct rtable *rt;
457+
struct flowi4 fl4;
457458

458-
rt = ip_route_output_ports(&init_net, NULL, daddr, saddr,
459+
rt = ip_route_output_ports(&init_net, &fl4, NULL, daddr, saddr,
459460
dport, sport, IPPROTO_TCP, tos, 0);
460461
if (IS_ERR(rt))
461462
return NULL;

‎include/net/route.h‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,19 @@ static inline struct rtable *ip_route_output(struct net *net, __be32 daddr,
137137
return ip_route_output_key(net, &fl4);
138138
}
139139

140-
static inline struct rtable *ip_route_output_ports(struct net *net, struct sock *sk,
140+
static inline struct rtable *ip_route_output_ports(struct net *net, struct flowi4 *fl4,
141+
struct sock *sk,
141142
__be32 daddr, __be32 saddr,
142143
__be16 dport, __be16 sport,
143144
__u8 proto, __u8 tos, int oif)
144145
{
145-
struct flowi4 fl4;
146-
147-
flowi4_init_output(&fl4, oif, sk ? sk->sk_mark : 0, tos,
146+
flowi4_init_output(fl4, oif, sk ? sk->sk_mark : 0, tos,
148147
RT_SCOPE_UNIVERSE, proto,
149148
sk ? inet_sk_flowi_flags(sk) : 0,
150149
daddr, saddr, dport, sport);
151150
if (sk)
152-
security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
153-
return ip_route_output_flow(net, &fl4, sk);
151+
security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
152+
return ip_route_output_flow(net, fl4, sk);
154153
}
155154

156155
static inline struct rtable *ip_route_output_gre(struct net *net,

‎net/ipv4/af_inet.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,7 @@ int inet_sk_rebuild_header(struct sock *sk)
11521152
struct rtable *rt = (struct rtable *)__sk_dst_check(sk, 0);
11531153
__be32 daddr;
11541154
struct ip_options_rcu *inet_opt;
1155+
struct flowi4 fl4;
11551156
int err;
11561157

11571158
/* Route is OK, nothing to do. */
@@ -1165,7 +1166,7 @@ int inet_sk_rebuild_header(struct sock *sk)
11651166
if (inet_opt && inet_opt->opt.srr)
11661167
daddr = inet_opt->opt.faddr;
11671168
rcu_read_unlock();
1168-
rt = ip_route_output_ports(sock_net(sk), sk, daddr, inet->inet_saddr,
1169+
rt = ip_route_output_ports(sock_net(sk), &fl4, sk, daddr, inet->inet_saddr,
11691170
inet->inet_dport, inet->inet_sport,
11701171
sk->sk_protocol, RT_CONN_FLAGS(sk),
11711172
sk->sk_bound_dev_if);

‎net/ipv4/igmp.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
309309
struct iphdr *pip;
310310
struct igmpv3_report *pig;
311311
struct net *net = dev_net(dev);
312+
struct flowi4 fl4;
312313

313314
while (1) {
314315
skb = alloc_skb(size + LL_ALLOCATED_SPACE(dev),
@@ -321,7 +322,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
321322
}
322323
igmp_skb_size(skb) = size;
323324

324-
rt = ip_route_output_ports(net, NULL, IGMPV3_ALL_MCR, 0,
325+
rt = ip_route_output_ports(net, &fl4, NULL, IGMPV3_ALL_MCR, 0,
325326
0, 0,
326327
IPPROTO_IGMP, 0, dev->ifindex);
327328
if (IS_ERR(rt)) {
@@ -650,6 +651,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
650651
struct net_device *dev = in_dev->dev;
651652
struct net *net = dev_net(dev);
652653
__be32 group = pmc ? pmc->multiaddr : 0;
654+
struct flowi4 fl4;
653655
__be32 dst;
654656

655657
if (type == IGMPV3_HOST_MEMBERSHIP_REPORT)
@@ -659,7 +661,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
659661
else
660662
dst = group;
661663

662-
rt = ip_route_output_ports(net, NULL, dst, 0,
664+
rt = ip_route_output_ports(net, &fl4, NULL, dst, 0,
663665
0, 0,
664666
IPPROTO_IGMP, 0, dev->ifindex);
665667
if (IS_ERR(rt))

‎net/ipv4/ip_output.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ int ip_queue_xmit(struct sk_buff *skb)
333333
/* Make sure we can route this packet. */
334334
rt = (struct rtable *)__sk_dst_check(sk, 0);
335335
if (rt == NULL) {
336+
struct flowi4 fl4;
336337
__be32 daddr;
337338

338339
/* Use correct destination address if we have options. */
@@ -344,7 +345,7 @@ int ip_queue_xmit(struct sk_buff *skb)
344345
* keep trying until route appears or the connection times
345346
* itself out.
346347
*/
347-
rt = ip_route_output_ports(sock_net(sk), sk,
348+
rt = ip_route_output_ports(sock_net(sk), &fl4, sk,
348349
daddr, inet->inet_saddr,
349350
inet->inet_dport,
350351
inet->inet_sport,

‎net/ipv4/ipip.c‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
442442
struct iphdr *iph; /* Our new IP header */
443443
unsigned int max_headroom; /* The extra header space needed */
444444
__be32 dst = tiph->daddr;
445+
struct flowi4 fl4;
445446
int mtu;
446447

447448
if (skb->protocol != htons(ETH_P_IP))
@@ -460,7 +461,7 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
460461
goto tx_error_icmp;
461462
}
462463

463-
rt = ip_route_output_ports(dev_net(dev), NULL,
464+
rt = ip_route_output_ports(dev_net(dev), &fl4, NULL,
464465
dst, tiph->saddr,
465466
0, 0,
466467
IPPROTO_IPIP, RT_TOS(tos),
@@ -578,13 +579,15 @@ static void ipip_tunnel_bind_dev(struct net_device *dev)
578579
iph = &tunnel->parms.iph;
579580

580581
if (iph->daddr) {
581-
struct rtable *rt = ip_route_output_ports(dev_net(dev), NULL,
582-
iph->daddr, iph->saddr,
583-
0, 0,
584-
IPPROTO_IPIP,
585-
RT_TOS(iph->tos),
586-
tunnel->parms.link);
587-
582+
struct rtable *rt;
583+
struct flowi4 fl4;
584+
585+
rt = ip_route_output_ports(dev_net(dev), &fl4, NULL,
586+
iph->daddr, iph->saddr,
587+
0, 0,
588+
IPPROTO_IPIP,
589+
RT_TOS(iph->tos),
590+
tunnel->parms.link);
588591
if (!IS_ERR(rt)) {
589592
tdev = rt->dst.dev;
590593
ip_rt_put(rt);

‎net/ipv4/ipmr.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,6 +1595,7 @@ static void ipmr_queue_xmit(struct net *net, struct mr_table *mrt,
15951595
struct vif_device *vif = &mrt->vif_table[vifi];
15961596
struct net_device *dev;
15971597
struct rtable *rt;
1598+
struct flowi4 fl4;
15981599
int encap = 0;
15991600

16001601
if (vif->dev == NULL)
@@ -1612,7 +1613,7 @@ static void ipmr_queue_xmit(struct net *net, struct mr_table *mrt,
16121613
#endif
16131614

16141615
if (vif->flags & VIFF_TUNNEL) {
1615-
rt = ip_route_output_ports(net, NULL,
1616+
rt = ip_route_output_ports(net, &fl4, NULL,
16161617
vif->remote, vif->local,
16171618
0, 0,
16181619
IPPROTO_IPIP,
@@ -1621,7 +1622,7 @@ static void ipmr_queue_xmit(struct net *net, struct mr_table *mrt,
16211622
goto out_free;
16221623
encap = sizeof(struct iphdr);
16231624
} else {
1624-
rt = ip_route_output_ports(net, NULL, iph->daddr, 0,
1625+
rt = ip_route_output_ports(net, &fl4, NULL, iph->daddr, 0,
16251626
0, 0,
16261627
IPPROTO_IPIP,
16271628
RT_TOS(iph->tos), vif->link);

0 commit comments

Comments
 (0)