Skip to content

Commit 148721f

Browse files
Guillaume Naultkuba-moo
authored andcommitted
ipv4: Use inet_sk_init_flowi4() in __ip_queue_xmit().
Use inet_sk_init_flowi4() to automatically initialise the flowi4 structure in __ip_queue_xmit() instead of passing parameters manually to ip_route_output_ports(). Override ->flowi4_tos with the value passed as parameter since that's required by SCTP. Signed-off-by: Guillaume Nault <[email protected]> Link: https://patch.msgid.link/37e64ffbd9adac187b14aa9097b095f5c86e85be.1734357769.git.gnault@redhat.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 42e5ffc commit 148721f

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

net/ipv4/ip_output.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -478,24 +478,16 @@ int __ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
478478
/* Make sure we can route this packet. */
479479
rt = dst_rtable(__sk_dst_check(sk, 0));
480480
if (!rt) {
481-
__be32 daddr;
481+
inet_sk_init_flowi4(inet, fl4);
482482

483-
/* Use correct destination address if we have options. */
484-
daddr = inet->inet_daddr;
485-
if (inet_opt && inet_opt->opt.srr)
486-
daddr = inet_opt->opt.faddr;
483+
/* sctp_v4_xmit() uses its own DSCP value */
484+
fl4->flowi4_tos = tos & INET_DSCP_MASK;
487485

488486
/* If this fails, retransmit mechanism of transport layer will
489487
* keep trying until route appears or the connection times
490488
* itself out.
491489
*/
492-
rt = ip_route_output_ports(net, fl4, sk,
493-
daddr, inet->inet_saddr,
494-
inet->inet_dport,
495-
inet->inet_sport,
496-
sk->sk_protocol,
497-
tos & INET_DSCP_MASK,
498-
sk->sk_bound_dev_if);
490+
rt = ip_route_output_flow(net, fl4, sk);
499491
if (IS_ERR(rt))
500492
goto no_route;
501493
sk_setup_caps(sk, &rt->dst);

0 commit comments

Comments
 (0)