ASoC: dsp - BE disconnection after pending flag is clear

Currently we can disconnect a BE and have its update flag incorrectly
set after reparenting. Fix this so we always clear the update flag
before any disconnections and reparenting.

dsp_run_update_startup() also called disconnect but this was always
called anyway by its caller soc_dsp_runtime_update() before the update
flag was cleared.

Change-Id: If0cde4c9df845a7189188bb49e6fb4fd496a925d
Signed-off-by: Liam Girdwood <lrg@ti.com>
ASoC: DSP: Split runtime startup/shutdown updates

A FE->BE-1 link can transition to FE->BE-2 in a single widget/kcontrol
change (e.g. Muxes). Currently, DSP framework searches for new and old
paths of the FE, and then perform the startup/shutdown runtime updates.
The single-step FE->BE-1 to FE->BE-2 transition has both: new and old
paths to be updated, hence BE-1 and BE-2 will be marked for runtime
update. However, startup and shutdown updates will both be performed
on BE-1 and BE-2, which is incorect as it would be expected to run
startup update on BE-2 and shutdown update on BE-1.

In order to handle these scenarios, the path search (new and old) is
performed along with its runtime update (startup and shutdown).

Change-Id: I5a687d6fcc51a968d9b0ae52d749935a92f00ef7
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Signed-off-by: Liam Girdwood <lrg@ti.com>
ASoC: DSP: Clear BE runtime in startup unwind

Set BE's runtime to NULL when unwinding after startup errors.

Change-Id: I7fb11dff3e623b79334345e563bb3f0da0c6823c
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
ASoC: core: Query active DAI links

Query active DAI links (dynamic and legacy frontends) in a SoC card.

Change-Id: Ieaef958833feb40499e0d67f3217f00a19ade87e
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
ASoC: core: Promote DAI link startup

Promote DAI link startup to the beginning of SoC PCM open(),
required to:

- Prepare machine-level external environment (like clocks, power
  supplies) for CPU DAIs and CODECs
- Some CODECs add hw constraints (e.g. snd_pcm_hw_constraint_list
  for twl6040, wm8523, wm8988, etc) during their startup handler
  which can be dependent on machine level settings (e.g. sysclk).
  Currently, those constraints are honored until next stream
  activity takes place as the DAI link startup occurs after
  CODEC's.

Similarly, DAI link shutdown is now moved to the last position in
SoC PCM close().

Change-Id: Iabf4256be528d1d7befa2e03bfda89a9cafe959a
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
ASoC: core: Remove DAI link pre/post ops

Due to DAI link startup promotion in ASoC PCM open sequence, remove
DAI link pre/post ops sice they are now redundant.

Change-Id: I21b6b4ab9a91b351e6078b69c18b66cae1bf9014
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Revert audio-changes which do not fix hotword detection

Revert "ASoC: core: Remove DAI link pre/post ops"
This reverts commit d61bfb91bafe63f92aca504dc69b086772a02f19.

Revert "ASoC: core: Promote DAI link startup"
This reverts commit a256c522f09f91ed58034c6d4da850a0fd532f6d.

Revert "ASoC: core: Query active DAI links"
This reverts commit d83635ad1a775889509d03911501bee1f129ba1b.

Revert "ASoC: DSP: Clear BE runtime in startup unwind"
This reverts commit dc3ffd57992a90e84ea43d1b65654e12db91c90a.

Revert "ASoC: DSP: Split runtime startup/shutdown updates"
This reverts commit 697f614b91ec3100ceec725da89434df39035f4a.

Revert "ASoC: dsp - BE disconnection after pending flag is clear"
This reverts commit 0e113cf91a6e65b02000d2e7352d0600d1eb22dc.

Change-Id: I4f126acefcce0506d2ab912a61144a6465502672
ipv6: use a stronger hash for tcp

[ Upstream commit 08dcdbf6a7b9d14c2302c5bd0c5390ddf122f664 ]

It looks like its possible to open thousands of TCP IPv6
sessions on a server, all landing in a single slot of TCP hash
table. Incoming packets have to lookup sockets in a very
long list.

We should hash all bits from foreign IPv6 addresses, using
a salt and hash mix, not a simple XOR.

inet6_ehashfn() can also separately use the ports, instead
of xoring them.

Reported-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net: Don't proxy arp respond if iif == rt->dst.dev if private VLAN is disabled

[ Upstream commit 70620c46ac2b45c24b0f22002fdf5ddd1f7daf81 ]

Commit 653241 (net: RFC3069, private VLAN proxy arp support) changed
the behavior of arp proxy to send arp replies back out on the interface
the request came in even if the private VLAN feature is disabled.

Previously we checked rt->dst.dev != skb->dev for in scenarios, when
proxy arp is enabled on for the netdevice and also when individual proxy
neighbour entries have been added.

This patch adds the check back for the pneigh_lookup() scenario.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Acked-by: Jesper Dangaard Brouer <hawk@comx.dk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ipv4: flush route cache after change accept_local

[ Upstream commit d01ff0a049f749e0bf10a35bb23edd012718c8c2 ]

After reset ipv4_devconf->data[IPV4_DEVCONF_ACCEPT_LOCAL] to 0,
we should flush route cache, or it will continue receive packets with local
source address, which should be dropped.

Signed-off-by: Weiping Pan <panweiping3@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
ipv4: Skip calling fib_detect_death() if fib_dev is NULL

Change-Id: I1b8c6c7e79cb8a05b4b715ddb3299d74edef0e14
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
ipv4: Do not use dead fib_info entries.

[ Upstream commit dccd9ecc374462e5d6a5b8f8110415a86c2213d8 ]

Due to RCU lookups and RCU based release, fib_info objects can
be found during lookup which have fi->fib_dead set.

We must ignore these entries, otherwise we risk dereferencing
the parts of the entry which are being torn down.

Reported-by: Yevgen Pronenko <yevgen.pronenko@sonymobile.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fib_trie: remove potential out of bound access

[ Upstream commit aab515d7c32a34300312416c50314e755ea6f765 ]

AddressSanitizer [1] dynamic checker pointed a potential
out of bound access in leaf_walk_rcu()

We could allocate one more slot in tnode_new() to leave the prefetch()
in-place but it looks not worth the pain.

Bug added in commit 82cfbb008572b ("[IPV4] fib_trie: iterator recode")

[1] :
https://code.google.com/p/address-sanitizer/wiki/AddressSanitizerForKernel

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
igmp: Avoid zero delay when receiving odd mixture of IGMP queries

commit a8c1f65c79cbbb2f7da782d4c9d15639a9b94b27 upstream.

Commit 5b7c84066733c5dfb0e4016d939757b38de189e4 ('ipv4: correct IGMP
behavior on v3 query during v2-compatibility mode') added yet another
case for query parsing, which can result in max_delay = 0.  Substitute
a value of 1, as in the usual v3 case.

Reported-by: Simon McVittie <smcv@debian.org>
References: http://bugs.debian.org/654876
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
ip: generate unique IP identificator if local fragmentation is allowed

[ Upstream commit 703133de331a7a7df47f31fb9de51dc6f68a9de8 ]

If local fragmentation is allowed, then ip_select_ident() and
ip_select_ident_more() need to generate unique IDs to ensure
correct defragmentation on the peer.

For example, if IPsec (tunnel mode) has to encrypt large skbs
that have local_df bit set, then all IP fragments that belonged
to different ESP datagrams would have used the same identificator.
If one of these IP fragments would get lost or reordered, then
peer could possibly stitch together wrong IP fragments that did
not belong to the same datagram. This would lead to a packet loss
or data corruption.

Signed-off-by: Ansis Atteka <aatteka@nicira.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ipv4 igmp: use in_dev_put in timer handlers instead of __in_dev_put

[ Upstream commit e2401654dd0f5f3fb7a8d80dad9554d73d7ca394 ]

It is possible for the timer handlers to run after the call to
ip_mc_down so use in_dev_put instead of __in_dev_put in the handler
function in order to do proper cleanup when the refcnt reaches 0.
Otherwise, the refcnt can reach zero without the in_device being
destroyed and we end up leaking a reference to the net_device and
see messages like the following,

unregister_netdevice: waiting for eth0 to become free. Usage count = 1

Tested on linux-3.4.43.

Signed-off-by: Salam Noureddine <noureddine@aristanetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net: drop dst before queueing fragments

[ Upstream commit 97599dc792b45b1669c3cdb9a4b365aad0232f65 ]

Commit 4a94445c9a5c (net: Use ip_route_input_noref() in input path)
added a bug in IP defragmentation handling, as non refcounted
dst could escape an RCU protected section.

Commit 64f3b9e203bd068 (net: ip_expire() must revalidate route) fixed
the case of timeouts, but not the general problem.

Tom Parkin noticed crashes in UDP stack and provided a patch,
but further analysis permitted us to pinpoint the root cause.

Before queueing a packet into a frag list, we must drop its dst,
as this dst has limited lifetime (RCU protected)

When/if a packet is finally reassembled, we use the dst of the very
last skb, still protected by RCU and valid, as the dst of the
reassembled packet.

Use same logic in IPv6, as there is no need to hold dst references.

Reported-by: Tom Parkin <tparkin@katalix.com>
Tested-by: Tom Parkin <tparkin@katalix.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ip_tunnel: fix kernel panic with icmp_dest_unreach

[ Upstream commit a622260254ee481747cceaaa8609985b29a31565 ]

Daniel Petre reported crashes in icmp_dst_unreach() with following call
graph:

Daniel found a similar problem mentioned in
 http://lkml.indiana.edu/hypermail/linux/kernel/1007.0/00961.html

And indeed this is the root cause : skb->cb[] contains data fooling IP
stack.

We must clear IPCB in ip_tunnel_xmit() sooner in case dst_link_failure()
is called. Or else skb->cb[] might contain garbage from GSO segmentation
layer.

A similar fix was tested on linux-3.9, but gre code was refactored in
linux-3.10. I'll send patches for stable kernels as well.

Many thanks to Daniel for providing reports, patches and testing !

Reported-by: Daniel Petre <daniel.petre@rcs-rds.ro>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ipv4: fix for ip_options_rcv_srr() daddr update.

[ Upstream commit b12f62efb8ec0b9523bdb6c2d412c07193086de9 ]

When opt->srr_is_hit is set skb_rtable(skb) has been updated for
'nexthop' and iph->daddr should always equals to skb_rtable->rt_dst
holds, We need update iph->daddr either.

Signed-off-by: Li Wei <lw@cn.fujitsu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ipv4: Save nexthop address of LSRR/SSRR option to IPCB.

[ Upstream commit ac8a48106be49c422575ddc7531b776f8eb49610 ]

We can not update iph->daddr in ip_options_rcv_srr(), It is too early.
When some exception ocurred later (eg. in ip_forward() when goto
sr_failed) we need the ip header be identical to the original one as
ICMP need it.

Add a field 'nexthop' in struct ip_options to save nexthop of LSRR
or SSRR option.

Signed-off-by: Li Wei <lw@cn.fujitsu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>