From: <gregkh@linuxfoundation.org>
To: davem@davemloft.net, gorcunov@openvz.org,
gregkh@linuxfoundation.org, solar@openwall.com
Cc: <stable@vger.kernel.org>, <stable-commits@vger.kernel.org>
Subject: Patch "ipv4: Don't do expensive useless work during inetdev destroy." has been added to the 4.5-stable tree
Date: Sat, 16 Apr 2016 09:35:03 -0700 [thread overview]
Message-ID: <1460824503210124@kroah.com> (raw)
This is a note to let you know that I've just added the patch titled
ipv4: Don't do expensive useless work during inetdev destroy.
to the 4.5-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
ipv4-don-t-do-expensive-useless-work-during-inetdev-destroy.patch
and it can be found in the queue-4.5 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.
>From foo@baz Sat Apr 16 09:15:18 PDT 2016
From: "David S. Miller" <davem@davemloft.net>
Date: Sun, 13 Mar 2016 23:28:00 -0400
Subject: ipv4: Don't do expensive useless work during inetdev destroy.
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);
}
Patches currently in stable-queue which might be from davem@davemloft.net are
queue-4.5/tun-bpf-fix-suspicious-rcu-usage-in-tun_-attach-detach-_filter.patch
queue-4.5/mpls-find_outdev-check-for-err-ptr-in-addition-to-null-check.patch
queue-4.5/ipv4-fix-broadcast-packets-reception.patch
queue-4.5/bridge-allow-zero-ageing-time.patch
queue-4.5/qlge-fix-receive-packets-drop.patch
queue-4.5/net-dsa-fix-cleanup-resources-upon-module-removal.patch
queue-4.5/ppp-take-reference-on-channels-netns.patch
queue-4.5/rocker-set-fdb-cleanup-timer-according-to-lowest-ageing-time.patch
queue-4.5/bridge-allow-set-bridge-ageing-time-when-switchdev-disabled.patch
queue-4.5/ax25-add-link-layer-header-validation-function.patch
queue-4.5/net-validate-variable-length-ll-headers.patch
queue-4.5/xfrm-fix-crash-observed-during-device-unregistration-and-decryption.patch
queue-4.5/tcp-dccp-remove-obsolete-warn_on-in-icmp-handlers.patch
queue-4.5/ip6_tunnel-set-rtnl_link_ops-before-calling-register_netdevice.patch
queue-4.5/ppp-ensure-file-private_data-can-t-be-overridden.patch
queue-4.5/sh_eth-fix-null-pointer-dereference-in-sh_eth_ring_format.patch
queue-4.5/ipv4-don-t-do-expensive-useless-work-during-inetdev-destroy.patch
queue-4.5/packet-validate-variable-length-ll-headers.patch
queue-4.5/sh_eth-advance-rxdesc-later-in-sh_eth_ring_format.patch
queue-4.5/mlxsw-spectrum-check-requested-ageing-time-is-valid.patch
queue-4.5/farsync-fix-off-by-one-bug-in-fst_add_one.patch
queue-4.5/macvtap-always-pass-ethernet-header-in-linear.patch
queue-4.5/qmi_wwan-add-d-link-dwm-221-b1-device-id.patch
queue-4.5/ipv6-udp-fix-udp_mib_ignoredmulti-updates.patch
queue-4.5/ipv4-initialize-flowi4_flags-before-calling-fib_lookup.patch
queue-4.5/ipv6-count-in-extension-headers-in-skb-network_header.patch
queue-4.5/net-fix-use-after-free-in-the-recvmmsg-exit-path.patch
queue-4.5/ipv4-l2tp-fix-a-potential-issue-in-l2tp_ip_recv.patch
queue-4.5/ath9k-fix-buffer-overrun-for-ar9287.patch
queue-4.5/net-mvneta-fix-spinlock-usage.patch
queue-4.5/tuntap-restore-default-qdisc.patch
queue-4.5/ipv6-l2tp-fix-a-potential-issue-in-l2tp_ip6_recv.patch
queue-4.5/qlcnic-remove-unnecessary-usage-of-atomic_t.patch
queue-4.5/rtnl-fix-msg-size-calculation-in-if_nlmsg_size.patch
queue-4.5/bonding-fix-bond_get_stats.patch
queue-4.5/bpf-avoid-copying-junk-bytes-in-bpf_get_current_comm.patch
queue-4.5/net-bcmgenet-fix-dma-api-length-mismatch.patch
queue-4.5/qlcnic-fix-mailbox-completion-handling-during-spurious-interrupt.patch
queue-4.5/mlx4-add-missing-braces-in-verify_qp_parameters.patch
reply other threads:[~2016-04-16 16:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1460824503210124@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=davem@davemloft.net \
--cc=gorcunov@openvz.org \
--cc=solar@openwall.com \
--cc=stable-commits@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).