Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1381192
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 4.5 043/124] ipv4: Dont do expensive useless work during inetdev destroy. |
| Date | 2016-04-18 05:40 +0200 |
| Message-ID | <rp8cz-78k-41@gated-at.bofh.it> (permalink) |
| References | <rp7gt-6ho-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
4.5-stable review patch. If anyone has any objections, please let me know.
------------------
From: "David S. Miller" <davem@davemloft.net>
[ Upstream commit fbd40ea0180a2d328c5adc61414dc8bab9335ce2 ]
When an inetdev is destroyed, every address assigned to the interface
is removed. And in this scenerio we do two pointless things which can
be very expensive if the number of assigned interfaces is large:
1) Address promotion. We are deleting all addresses, so there is no
point in doing this.
2) A full nf conntrack table purge for every address. We only need to
do this once, as is already caught by the existing
masq_dev_notifier so masq_inet_event() can skip this.
Reported-by: Solar Designer <solar@openwall.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Tested-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/ipv4/devinet.c | 4 ++++
net/ipv4/fib_frontend.c | 4 ++++
net/ipv4/netfilter/nf_nat_masquerade_ipv4.c | 12 ++++++++++--
3 files changed, 18 insertions(+), 2 deletions(-)
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -334,6 +334,9 @@ static void __inet_del_ifa(struct in_dev
ASSERT_RTNL();
+ if (in_dev->dead)
+ goto no_promotions;
+
/* 1. Deleting primary ifaddr forces deletion all secondaries
* unless alias promotion is set
**/
@@ -380,6 +383,7 @@ static void __inet_del_ifa(struct in_dev
fib_del_ifaddr(ifa, ifa1);
}
+no_promotions:
/* 2. Unlink it */
*ifap = ifa1->ifa_next;
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -922,6 +922,9 @@ void fib_del_ifaddr(struct in_ifaddr *if
subnet = 1;
}
+ if (in_dev->dead)
+ goto no_promotions;
+
/* Deletion is more complicated than add.
* We should take care of not to delete too much :-)
*
@@ -997,6 +1000,7 @@ void fib_del_ifaddr(struct in_ifaddr *if
}
}
+no_promotions:
if (!(ok & BRD_OK))
fib_magic(RTM_DELROUTE, RTN_BROADCAST, ifa->ifa_broadcast, 32, prim);
if (subnet && ifa->ifa_prefixlen < 31) {
--- a/net/ipv4/netfilter/nf_nat_masquerade_ipv4.c
+++ b/net/ipv4/netfilter/nf_nat_masquerade_ipv4.c
@@ -108,10 +108,18 @@ static int masq_inet_event(struct notifi
unsigned long event,
void *ptr)
{
- struct net_device *dev = ((struct in_ifaddr *)ptr)->ifa_dev->dev;
+ struct in_device *idev = ((struct in_ifaddr *)ptr)->ifa_dev;
struct netdev_notifier_info info;
- netdev_notifier_info_init(&info, dev);
+ /* The masq_dev_notifier will catch the case of the device going
+ * down. So if the inetdev is dead and being destroyed we have
+ * no work to do. Otherwise this is an individual address removal
+ * and we have to perform the flush.
+ */
+ if (idev->dead)
+ return NOTIFY_DONE;
+
+ netdev_notifier_info_init(&info, idev->dev);
return masq_device_event(this, event, &info);
}
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 4.5 000/124] 4.5.2-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:40 +0200
[PATCH 4.5 045/124] mlx4: add missing braces in verify_qp_parameters Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:40 +0200
[PATCH 4.5 007/124] parisc: Unbreak handling exceptions from kernel modules Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:40 +0200
[PATCH 4.5 047/124] ath9k: fix buffer overrun for ar9287 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:40 +0200
[PATCH 4.5 024/124] drm/radeon: add another R7 370 quirk Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:40 +0200
[PATCH 4.5 043/124] ipv4: Dont do expensive useless work during inetdev destroy. Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:40 +0200
[PATCH 4.5 041/124] rocker: set FDB cleanup timer according to lowest ageing time Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:40 +0200
[PATCH 4.5 054/124] ipv4: fix broadcast packets reception Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:40 +0200
[PATCH 4.5 052/124] net: bcmgenet: fix dma api length mismatch Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:40 +0200
[PATCH 4.5 035/124] sh_eth: fix NULL pointer dereference in sh_eth_ring_format() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:40 +0200
[PATCH 4.5 011/124] ALSA: hda - Apply fix for white noise on Asus N550JV, too Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:50 +0200
[PATCH 4.5 013/124] mm: fix invalid node in alloc_migrate_target() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:50 +0200
[PATCH 4.5 020/124] arm64: opcodes.h: Add arm big-endian config options before including arm header Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:50 +0200
[PATCH 4.5 010/124] ALSA: hda - Fix white noise on Asus N750JV headphone Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:50 +0200
[PATCH 4.5 015/124] s390/mm: handle PTE-mapped tail pages in fast gup Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:50 +0200
[PATCH 4.5 018/124] powerpc/process: Fix altivec SPR not being saved Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:50 +0200
[PATCH 4.5 003/124] parisc: Fix SIGSYS signals in compat case Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:50 +0200
[PATCH 4.5 006/124] parisc: Fix kernel crash with reversed copy_from_user() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:50 +0200
[PATCH 4.5 019/124] compiler-gcc: disable -ftracer for __noclone functions Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:50 +0200
[PATCH 4.5 016/124] libnvdimm: fix smart data retrieval Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-18 05:50 +0200
Re: [PATCH 4.5 000/124] 4.5.2-stable review Guenter Roeck <linux@roeck-us.net> - 2016-04-18 18:40 +0200
Re: [PATCH 4.5 000/124] 4.5.2-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-19 08:00 +0200
Re: [PATCH 4.5 000/124] 4.5.2-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2016-04-18 18:40 +0200
Re: [PATCH 4.5 000/124] 4.5.2-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-19 08:00 +0200
Re: [PATCH 4.5 000/124] 4.5.2-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-04-19 08:00 +0200
csiph-web