diff options
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/route.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index fafbe163e2b5..91867d3e6328 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -1514,13 +1514,17 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst) | |||
1514 | void ip_rt_send_redirect(struct sk_buff *skb) | 1514 | void ip_rt_send_redirect(struct sk_buff *skb) |
1515 | { | 1515 | { |
1516 | struct rtable *rt = skb_rtable(skb); | 1516 | struct rtable *rt = skb_rtable(skb); |
1517 | struct in_device *in_dev = in_dev_get(rt->u.dst.dev); | 1517 | struct in_device *in_dev; |
1518 | int log_martians; | ||
1518 | 1519 | ||
1519 | if (!in_dev) | 1520 | rcu_read_lock(); |
1521 | in_dev = __in_dev_get_rcu(rt->u.dst.dev); | ||
1522 | if (!in_dev || !IN_DEV_TX_REDIRECTS(in_dev)) { | ||
1523 | rcu_read_unlock(); | ||
1520 | return; | 1524 | return; |
1521 | 1525 | } | |
1522 | if (!IN_DEV_TX_REDIRECTS(in_dev)) | 1526 | log_martians = IN_DEV_LOG_MARTIANS(in_dev); |
1523 | goto out; | 1527 | rcu_read_unlock(); |
1524 | 1528 | ||
1525 | /* No redirected packets during ip_rt_redirect_silence; | 1529 | /* No redirected packets during ip_rt_redirect_silence; |
1526 | * reset the algorithm. | 1530 | * reset the algorithm. |
@@ -1533,7 +1537,7 @@ void ip_rt_send_redirect(struct sk_buff *skb) | |||
1533 | */ | 1537 | */ |
1534 | if (rt->u.dst.rate_tokens >= ip_rt_redirect_number) { | 1538 | if (rt->u.dst.rate_tokens >= ip_rt_redirect_number) { |
1535 | rt->u.dst.rate_last = jiffies; | 1539 | rt->u.dst.rate_last = jiffies; |
1536 | goto out; | 1540 | return; |
1537 | } | 1541 | } |
1538 | 1542 | ||
1539 | /* Check for load limit; set rate_last to the latest sent | 1543 | /* Check for load limit; set rate_last to the latest sent |
@@ -1547,7 +1551,7 @@ void ip_rt_send_redirect(struct sk_buff *skb) | |||
1547 | rt->u.dst.rate_last = jiffies; | 1551 | rt->u.dst.rate_last = jiffies; |
1548 | ++rt->u.dst.rate_tokens; | 1552 | ++rt->u.dst.rate_tokens; |
1549 | #ifdef CONFIG_IP_ROUTE_VERBOSE | 1553 | #ifdef CONFIG_IP_ROUTE_VERBOSE |
1550 | if (IN_DEV_LOG_MARTIANS(in_dev) && | 1554 | if (log_martians && |
1551 | rt->u.dst.rate_tokens == ip_rt_redirect_number && | 1555 | rt->u.dst.rate_tokens == ip_rt_redirect_number && |
1552 | net_ratelimit()) | 1556 | net_ratelimit()) |
1553 | printk(KERN_WARNING "host %pI4/if%d ignores redirects for %pI4 to %pI4.\n", | 1557 | printk(KERN_WARNING "host %pI4/if%d ignores redirects for %pI4 to %pI4.\n", |
@@ -1555,8 +1559,6 @@ void ip_rt_send_redirect(struct sk_buff *skb) | |||
1555 | &rt->rt_dst, &rt->rt_gateway); | 1559 | &rt->rt_dst, &rt->rt_gateway); |
1556 | #endif | 1560 | #endif |
1557 | } | 1561 | } |
1558 | out: | ||
1559 | in_dev_put(in_dev); | ||
1560 | } | 1562 | } |
1561 | 1563 | ||
1562 | static int ip_error(struct sk_buff *skb) | 1564 | static int ip_error(struct sk_buff *skb) |