Skip to content

Commit 415b333

Browse files
committed
icmp: Fix regression in nexthop resolution during replies.
icmp_route_lookup() uses the wrong flow parameters if the reverse session route lookup isn't used. So do not commit to the re-decoded flow until we actually make a final decision to use a real route saved in 'rt2'. Reported-by: Florian Westphal <fw@strlen.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ace62dd commit 415b333

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎net/ipv4/icmp.c‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ static struct rtable *icmp_route_lookup(struct net *net,
380380
struct icmp_bxm *param)
381381
{
382382
struct rtable *rt, *rt2;
383+
struct flowi4 fl4_dec;
383384
int err;
384385

385386
memset(fl4, 0, sizeof(*fl4));
@@ -408,27 +409,27 @@ static struct rtable *icmp_route_lookup(struct net *net,
408409
} else
409410
return rt;
410411

411-
err = xfrm_decode_session_reverse(skb_in, flowi4_to_flowi(fl4), AF_INET);
412+
err = xfrm_decode_session_reverse(skb_in, flowi4_to_flowi(&fl4_dec), AF_INET);
412413
if (err)
413414
goto relookup_failed;
414415

415-
if (inet_addr_type(net, fl4->saddr) == RTN_LOCAL) {
416-
rt2 = __ip_route_output_key(net, fl4);
416+
if (inet_addr_type(net, fl4_dec.saddr) == RTN_LOCAL) {
417+
rt2 = __ip_route_output_key(net, &fl4_dec);
417418
if (IS_ERR(rt2))
418419
err = PTR_ERR(rt2);
419420
} else {
420421
struct flowi4 fl4_2 = {};
421422
unsigned long orefdst;
422423

423-
fl4_2.daddr = fl4->saddr;
424+
fl4_2.daddr = fl4_dec.saddr;
424425
rt2 = ip_route_output_key(net, &fl4_2);
425426
if (IS_ERR(rt2)) {
426427
err = PTR_ERR(rt2);
427428
goto relookup_failed;
428429
}
429430
/* Ugh! */
430431
orefdst = skb_in->_skb_refdst; /* save old refdst */
431-
err = ip_route_input(skb_in, fl4->daddr, fl4->saddr,
432+
err = ip_route_input(skb_in, fl4_dec.daddr, fl4_dec.saddr,
432433
RT_TOS(tos), rt2->dst.dev);
433434

434435
dst_release(&rt2->dst);
@@ -440,10 +441,11 @@ static struct rtable *icmp_route_lookup(struct net *net,
440441
goto relookup_failed;
441442

442443
rt2 = (struct rtable *) xfrm_lookup(net, &rt2->dst,
443-
flowi4_to_flowi(fl4), NULL,
444+
flowi4_to_flowi(&fl4_dec), NULL,
444445
XFRM_LOOKUP_ICMP);
445446
if (!IS_ERR(rt2)) {
446447
dst_release(&rt->dst);
448+
memcpy(fl4, &fl4_dec, sizeof(*fl4));
447449
rt = rt2;
448450
} else if (PTR_ERR(rt2) == -EPERM) {
449451
if (rt)

0 commit comments

Comments
 (0)