Commit Graph

29 Commits

Author SHA1 Message Date
Linux Build Service Account
7f40d91d85 Merge "net: rmnet_data: Check for context when freeing packing in TX path" 2018-03-06 21:37:46 -08:00
Tejaswi Tanikella
2a64094736 net: rmnet_data: compute rx hash before napi_gro_receive
GRO engine needs to identify the right flow to add incoming skb.
It does this by marking all flows, and unmarks flows as it identifies
differences. First a quick elimination is done by comparing rx hash.
All flows with unequal rx hashes are unmarked. It further eliminates
flows after comparing IP and TCP header contents.

The skb is added to the marked flow's gro_list. If all the flows
are unmarked, implying the skb is a unique flow, the skb
is initialized as the head to a new gro_list.

rmnet_data creates a skb and copies contents from QMAP packet.
since rx hash is uninitialized, GRO engine has to compare IP and TCP
headers with all the GROing flows. So set rx_hash before calling
napi_gro_receive, for easier flow elimination.

Change-Id: Iaa444d6c17a25da494a650ed6076b50fd9b99cc4
Signed-off-by: Tejaswi Tanikella <tejaswit@codeaurora.org>
2018-03-01 11:57:20 +05:30
Subash Abhinov Kasiviswanathan
4b5151f109 net: rmnet_data: Check for endpoint validity when demuxing
In case an invalid mux id is passed, an invalid device lookup is
done leading to passing on the packet to stack incorrectly rather
than consuming them.

CRs-Fixed: 2181180
Change-Id: Iad905e932b49eda00a7d91e906f0ac0ca44cdb59
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2018-01-25 23:19:57 -07:00
Subash Abhinov Kasiviswanathan
4c42be4f7c net: rmnet_data: Check for context when freeing packing in TX path
If conntrack information is associated with a packet in TX path,
bh is enabled later in the stack leading to invalid contexts in
case there is a packet redirected from RX path. A sample call stack
is as follows -

[ 6996.976781] WARNING: CPU: 3 PID: 0 at kernel/softirq.c:168
__local_bh_enable_ip+0xa8/0x114

[ 6997.357481] [ffffff82c82b183c] __local_bh_enable_ip+0xa8/0x114
[ 6997.363542] [ffffff82c91457d4] destroy_conntrack+0xf8/0x1a8
[ 6997.369337] [ffffff82c913d840] nf_conntrack_destroy+0x34/0x48
[ 6997.375313] [ffffff82c90d9130] skb_release_head_state+0xd0/0xe8
[ 6997.381451] [ffffff82c90d947c] skb_release_all+0x20/0x3c
[ 6997.386983] [ffffff82c90d9248] kfree_skb+0x50/0x118
[ 6997.392083] [ffffff82c93391f4] rmnet_kfree_skb+0x60/0x70
[ 6997.397618] [ffffff82c9338120] rmnet_map_aggregate+0x184/0x638
[ 6997.403677] [ffffff82c9336d2c] rmnet_egress_handler+0x2e4/0x4a0
[ 6997.409818] [ffffff82c93356a8] rmnet_vnd_start_xmit+0x68/0x1b0
[ 6997.415877] [ffffff82c90f57c8] dev_hard_start_xmit+0xc4/0x29c
[ 6997.421844] [ffffff82c912275c] sch_direct_xmit+0x100/0x1cc
[ 6997.427549] [ffffff82c912294c] __qdisc_run+0x124/0x25c
[ 6997.432903] [ffffff82c90f5fa0] __dev_queue_xmit+0x29c/0x704
[ 6997.438699] [ffffff82c90f6430] dev_queue_xmit+0x28/0x34
[ 6997.444140] [ffffff82c910163c] neigh_direct_output+0x20/0x28
[ 6997.450029] [ffffff82c9183650] ip_finish_output2+0x1b4/0x3dc
[ 6997.455914] [ffffff82c91852c8] ip_finish_output+0x190/0x280
[ 6997.461704] [ffffff82c9185f70] ip_output+0x140/0x190
[ 6997.466889] [ffffff82c91869d8] ip_send_skb+0x5c/0xf0
[ 6997.472076] [ffffff82c9186aac] ip_push_pending_frames+0x40/0x5c
[ 6997.478221] [ffffff82c9186edc] ip_send_unicast_reply+0x240/0x2b4
[ 6997.484449] [ffffff82c91a56ac] tcp_v4_send_reset+0x1c0/0x2c8
[ 6997.490333] [ffffff82c91a871c] tcp_v4_rcv+0x680/0xabc
[ 6997.495599] [ffffff82c917fb90] ip_local_deliver_finish+0x10c/0x278
[ 6997.502009] [ffffff82c91802d0] ip_local_deliver+0x108/0x114
[ 6997.507809] [ffffff82c917fee0] ip_rcv_finish+0x1e4/0x384
[ 6997.513338] [ffffff82c918061c] ip_rcv+0x340/0x444
[ 6997.518255] [ffffff82c90edaa0] __netif_receive_skb_core+0x268/0xb7c
[ 6997.524751] [ffffff82c90f06fc] __netif_receive_skb+0x38/0x84
[ 6997.530629] [ffffff82c90f1430] process_backlog+0xd0/0x19c
[ 6997.536248] [ffffff82c90f3254] net_rx_action+0x260/0x3d8
[ 6997.541784] [ffffff82c8281b64] __do_softirq+0x144/0x468
[ 6997.547233] [ffffff82c82b1a64] irq_exit+0x118/0x144
[ 6997.552331] [ffffff82c8291810] handle_IPI+0x234/0x3c4
[ 6997.557598] [ffffff82c8281a14] gic_handle_irq+0x1a8/0x1b4

CRs-Fixed: 2180767
Change-Id: Ie9bfd4c9f9dcf64f26109a7e3eafe08b89063369
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2018-01-23 08:06:25 -07:00
Subash Abhinov Kasiviswanathan
2698fe946b net: rmnet_data: Remove invalid error message
The worker thread can run even if the aggregation state machine
has moved on to an idle after processing packets. This results
in log spam with an invalid message.

CRs-Fixed: 2165883
Change-Id: I218ac9b20a41749adce45a0d787782d15f07c65b
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2018-01-02 12:06:10 -07:00
Subash Abhinov Kasiviswanathan
08fed02b9e net: rmnet_data: Use hrtimer for UL aggregation timer
The delay argument in schedule_delayed_work(struct delayed_work
*dwork, unsigned long delay) API is jiffies. The system tick for
seems to be 100Hz, so the minimum time resolution for the work to
be scheduled is 10ms.

Switch to hrtimer to achieve 3 ms granularity with a current timer
of 1ms for the flush thread. A workqueue is immediately scheduled
in the same context after this timer expiry to do the tx work.

CRs-Fixed: 2157214
Change-Id: I29cbbee417e84b101ed34c0d29c2731bd52c3ec5
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2017-12-18 12:19:16 -07:00
Subash Abhinov Kasiviswanathan
fe3dede6ad net: rmnet_data: Go back to worker thread for UL aggregation
A crash was seen when running the hrtimer solution, so revert the
change till it is resoloved. The crash occurs due to interrupts
being enabled by a later function in the call stack within
interrupt context.

[ffffff8cc22b157c] __local_bh_enable_ip+0xa8/0x114
[ffffff8cc33495d0] _raw_spin_unlock_bh+0x30/0x3c
[ffffff8cc2e57ed8] ipa3_send+0x2a0/0xaa0
[ffffff8cc2e5c544] ipa3_tx_dp+0x59c/0x990
[ffffff8cc2ea7ef0] ipa3_wwan_xmit+0x204/0x338
[ffffff8cc30f0160] dev_hard_start_xmit+0xc4/0x29c
[ffffff8cc311d0f4] sch_direct_xmit+0x100/0x1cc
[ffffff8cc30f0890] __dev_queue_xmit+0x1f4/0x704
[ffffff8cc30f0dc8] dev_queue_xmit+0x28/0x34
[ffffff8cc333285c] rmnet_map_flush_packet_queue+0xc0/0x218
[ffffff8cc2344f9c] __hrtimer_run_queues+0x158/0x36c
[ffffff8cc2345f38] hrtimer_interrupt+0xb0/0x1f4

CRs-fixed: 2147503
Change-Id: I7b3617577cbf5e166380d4361b73e2f57a4bd042
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2017-12-01 12:41:54 -07:00
Subash Abhinov Kasiviswanathan
855e50cbba net: rmnet_data: Switch aggregation from delayed work to hrtimer
The delay argument in schedule_delayed_work(struct delayed_work
*dwork, unsigned long delay) API is jiffies. The system tick for
seems to be 100Hz, so the minimum time resolution for the work to
be scheduled is 10ms.

Switch to hrtimer to achieve 1 ms granularity with a current timer
of 3ms for the flush thread.

CRs-fixed: 2147503
Change-Id: If33fea37146f91b2980e6637db71567fb5ca12a5
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2017-11-28 19:03:39 -07:00
Subash Abhinov Kasiviswanathan
54448f2b55 net: rmnet_data: Always try to linearize when UL aggregation is on
Skipping UL aggregation if the packet was linear was causing out
of order packets. If linearization fails, pass up the packet as is.
Also skip padding if using version 3 or v4 when using UL aggregation.

CRs-Fixed: 2141234
Change-Id: I711668ecf2a3e6807f2270b4b107f4a2a3d21654
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2017-11-10 15:26:14 -07:00
Subash Abhinov Kasiviswanathan
b7500cc99f net: rmnet_data: Optimize the UL aggregation skip logic
Optimize for the IPv6 normal ping case instead of the
fragmentation scenario. Also, check for IPv6 explicitly
rather than directly disecting the packet.

CRs-Fixed: 2131879
Change-Id: Idee5c7d52972d06aee6ac6d71ebd5d1c3c875f9f
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2017-11-09 19:28:34 -07:00
Subash Abhinov Kasiviswanathan
bf783bade0 net: rmnet_data: Skip UL aggregation for ping packets
ICMP packets could be potentially stuck behind aggregated traffic
if UL aggregation is enabled on rmnet_data. This results in
increased latencies during ping tests as the workqueues for these
packets are scheduled at non deterministic times.

CRs-Fixed: 2131879
Change-Id: I19208301b5674749aa2f1dee65a9226eda364c85
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2017-11-08 18:53:37 -07:00
Conner Huff
a9112ff270 net: rmnet_data: Fix assignments, reads, and logic
Global variables are no longer assigned values. Instead
flush meta data is handled and tracked at per end
point basis.

Reduce the number of register reads for timer. Leverage
value which has already been read earlier in function.

Change-Id: If0f3362aff1f92c94d05367c4b6428b897ff6ede
Signed-off-by: Conner Huff <chuff@codeaurora.org>
2017-11-06 11:13:18 -08:00
Linux Build Service Account
14c7ab7005 Merge "net: rmnet_data: Fix comments on code review" 2017-10-27 18:19:27 -07:00
Subash Abhinov Kasiviswanathan
29e6452e14 net: rmnet_data: Fix comments on code review
- Remove redundant checks in tx / rx fixup.
- Remove debug aggregation counter
- Remove unused recycle handler
- Add CAP_NET_ADMIN checks for set IOCTLs
- Simplify the packet deliver code

CRs-Fixed: 2111801
Change-Id: I14c02462c27b319f7517caa178f25a8efa22abeb
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2017-10-27 13:09:14 -06:00
Ashwanth Goli
3965fbfac7 net: rmnet_data: validate csum in SW
Do SW checksum validation if rmnet_data checksum
validation fails.

Change-Id: Ifff229dc1e7eb592d58fc66ea278debb292b89aa
Signed-off-by: Ashwanth Goli <ashwanth@codeaurora.org>
Signed-off-by: Tejaswi Tanikella <tejaswit@codeaurora.org>
2017-10-24 15:18:41 +05:30
Subash Abhinov Kasiviswanathan
c64a7803e4 net: rmnet_data: Skip UL aggregation for non linear packets
Using UL aggregation for non linear data is not efficient since
we are copying data from a non linear segment to a linear buffer.
As a result, we lose the advantages of GSO and increase our RTT.

CRs-Fixed: 2117151
Change-Id: I7963c4a19531c53deaf5e50dc408ba3faea41c35
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2017-09-27 11:27:26 -07:00
Ashwanth Goli
c85bfbe2e8 net: rmnet_data: Unset logical end points in bridge mode
We clean up the logical end points only for the un-registering device
in bridge mode. However, the other physical end point's local end
point still points to the the un-registered device.

This may lead up to a crash if one of the physical devices in bridge
mode is un-registered. Fix this by unsetting the local endpoint.

It is still possible that packets in a different context across cores
might try to access this data. This usually manifests as packets
requesting a very large headroom. Handle this by dropping these stale
skb's.

CRs-Fixed: 1098513
Change-Id: I1ba4d877a6ed3eca66946fe056938f0927bcd9a5
Signed-off-by: Ashwanth Goli <ashwanth@codeaurora.org>
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2017-07-18 14:13:22 -06:00
Subash Abhinov Kasiviswanathan
58598631eb net: rmnet_data: Add support to configure custom device name
rmnet_data assigns device name by the order they are created.
This causes problems which multiple processes are trying to
create devices and leads to random device names.

Assign device name as specified by user.

CRs-Fixed: 2018785
Change-Id: Iab8e053c6ccacbeedaa7763e760d0c12e756b5d0
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2017-03-22 12:26:21 -06:00
Conner Huff
f90a250c4a net: rmnet_data: Optimized GRO for single flow
Port single flow dynamic GRO changes into rmnet driver. This
feature uses configurable parameters that determine when GRO
should be flushed based on both timing and receive byte count.
Although the parameters are initially set, they dynamically
fluctuate based on incoming traffic.

CRs-Fixed: 1113125
Change-Id: I7469118d3108e0c9f71c4f50efd8ceebfb324a63
Signed-off-by: Conner Huff <chuff@codeaurora.org>
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2017-02-23 19:37:37 -07:00
Kyle Yan
347d9d9892 Merge "net: rmnet_data: Handle leaked packets when adding MAP fields in TX" into msm-4.8 2017-02-06 17:52:09 -08:00
Kyle Yan
cc6c4f152a Merge "net: rmnet_data: Handle buffer bloat for TCP scenarios" into msm-4.8 2017-02-06 17:52:07 -08:00
Kyle Yan
4fcb3b20aa Merge "rmnet_data: queue QMAP control packets if start_xmit fails" into msm-4.8 2017-02-06 17:52:06 -08:00
Kyle Yan
53a726ed83 Merge "net: rmnet_data: Fix incorrect netlink handling" into msm-4.8 2017-02-06 17:51:53 -08:00
Ashwanth Goli
b6baac1d6d rmnet_data: queue QMAP control packets if start_xmit fails
rmnet_data does not free skb's when phy netdev
fails to xmit a qmap control packet cauing memory leak.
To avoid this we queue the packet back into device queue
if start_xmit fails.

CRs-Fixed: 1089477
Change-Id: Id7efdd10ac76c989c086cb5f934a4b666b7c5939
Signed-off-by: Ashwanth Goli <ashwanth@codeaurora.org>
2017-02-03 16:19:41 -07:00
Subash Abhinov Kasiviswanathan
6a2d1dd02e net: rmnet_data: Handle buffer bloat for TCP scenarios
After commit 605ad7f184 ("tcp: refine TSO autosizing"), kernel
throttles uplink TCP data in case there is not sufficient amount
of socket buffer available due to delayed release of buffers
through TX completions in the physical net device.

Work around this by orphaning the socket buffer. This makes the
kernel assume that more packets can be sent in this scenario.
Out of band signaling and flow controlling at qdisc / HTB layer
should guarantee no issue for flow control.

Throughput difference for IPv4 TCP UL -

Before change : 143Mbps
After change  : 146Mbps

CRs-Fixed: 1088104
Change-Id: I251ed7938c29e08954d4c81d3041cb235a39d266
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2017-02-03 16:04:53 -07:00
Subash Abhinov Kasiviswanathan
991811c150 net: rmnet_data: Handle leaked packets when adding MAP fields in TX
Some creators of skb's may fail to set sufficient headroom or
tailroom to stamp the MAP header or tailroom respectively when
transmitting packets to rmnet_data.

In these cases, rmnet_data was failing to free these packets which
lead to out of memory scenarios in low memory targets. Free these
skb's in these scenarios.

CRs-Fixed: 1086873
Change-Id: I8bd2eb93393766bf9c301766e525354770577e0a
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2017-02-03 15:54:10 -07:00
Subash Abhinov Kasiviswanathan
5d8d66c676 net: rmnet_data: Disable generic receive offload by default
Generic receive offload is enabled by default on a net_device
whenever it is registered. In case of rmnet_data, a physical
device could theoretically pass cloned frames and rmnet_data
would pass on these cloned frames to GRO framework. This
would cause memory corruption or crashes since GRO modifies
the skb shared info which is shared across clones.

While cloned frames are usually not sent to rmnet_data, this
configuration actually requires userspace intervention. If
userspace does not makes appropriate calls to kernel, we will
run into crashes. Handle this scenario by disabling GRO by
default. Userspace will need to explicitly enable GRO if
required to do so.

CRs-Fixed: 1097389
Change-Id: I40d5ce940f4722b128c0138c07232c33d0b74e14
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2017-02-03 15:31:47 -07:00
Conner Huff
2357fa54b8 net: rmnet_data: Fix incorrect netlink handling
rmnet_data netlink handler currently does not check for the
incoming process pid and instead just loops back the pid.
A malicious root user could potentially send a message with
source pid 0 and this could cause rmnet_data to loop the message
back till an out of memory situation occurs.

rmnet_data also does not check for the message length of the
incoming netlink messages and instead casts the netlink message
without checking for the boundary.

Fix these two scenarios by adding the pid and message length checks
respectively

Bug: 31252965
CRs-Fixed: 1098801
Change-Id: I172c1a7112e67e82959b397af7ddfd963d819bdc
Signed-off-by: Conner Huff <chuff@codeaurora.org>
2017-02-03 12:52:30 -08:00
Subash Abhinov Kasiviswanathan
2139ce8a5c net: rmnet_data: Add snapshot of rmnet_data driver
This is a snapshot of the rmnet_data driver taken as of msm-4.4.
commit 5da00923b1544ba ("rmnet_data: Changing format specifier to
%pK").

Additionally, fix some style issues reported by checkpatch.

CRs-Fixed: 1078373
Change-Id: Idb2df22e61803e04a01db64ea5e9d1e93ae92e09
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2016-11-01 20:02:26 -06:00