@@ -425,7 +425,6 @@ static int l2tp_ip_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
425
425
int rc ;
426
426
struct inet_sock * inet = inet_sk (sk );
427
427
struct rtable * rt = NULL ;
428
- struct flowi4 * fl4 ;
429
428
int connected = 0 ;
430
429
__be32 daddr ;
431
430
@@ -455,7 +454,6 @@ static int l2tp_ip_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
455
454
if (sk -> sk_state != TCP_ESTABLISHED )
456
455
goto out ;
457
456
458
- daddr = inet -> inet_daddr ;
459
457
connected = 1 ;
460
458
}
461
459
@@ -482,29 +480,24 @@ static int l2tp_ip_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
482
480
goto error ;
483
481
}
484
482
485
- fl4 = & inet -> cork .fl .u .ip4 ;
486
483
if (connected )
487
484
rt = dst_rtable (__sk_dst_check (sk , 0 ));
488
485
489
486
rcu_read_lock ();
490
487
if (!rt ) {
491
- const struct ip_options_rcu * inet_opt ;
488
+ struct flowi4 * fl4 = & inet -> cork . fl . u . ip4 ;
492
489
493
- inet_opt = rcu_dereference (inet -> inet_opt );
490
+ inet_sk_init_flowi4 (inet , fl4 );
494
491
495
- /* Use correct destination address if we have options. */
496
- if (inet_opt && inet_opt -> opt . srr )
497
- daddr = inet_opt -> opt . faddr ;
492
+ /* Overwrite ->daddr if msg->msg_name was provided */
493
+ if (! connected )
494
+ fl4 -> daddr = daddr ;
498
495
499
496
/* If this fails, retransmit mechanism of transport layer will
500
497
* keep trying until route appears or the connection times
501
498
* itself out.
502
499
*/
503
- rt = ip_route_output_ports (sock_net (sk ), fl4 , sk ,
504
- daddr , inet -> inet_saddr ,
505
- inet -> inet_dport , inet -> inet_sport ,
506
- sk -> sk_protocol , ip_sock_rt_tos (sk ),
507
- sk -> sk_bound_dev_if );
500
+ rt = ip_route_output_flow (sock_net (sk ), fl4 , sk );
508
501
if (IS_ERR (rt ))
509
502
goto no_route ;
510
503
if (connected ) {
0 commit comments