aboutsummaryrefslogtreecommitdiffstats
path: root/examples/simple/io_write_dumpfile.py
blob: be6e4121bebf46b5b91dcbce32e8acfa33235011 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""
This script how to generate a mitmproxy dump file,
as it would also be generated by passing `-w` to mitmproxy.
In contrast to `-w`, this gives you full control over which
flows should be saved and also allows you to rotate files or log
to multiple files in parallel.
"""
import random
import sys
from mitmproxy import io, http
import typing  # noqa


class Writer:
    def __init__(self, path: str) -> None:
        self.f = open(path, "wb")  # type: typing.IO[bytes]
        self.w = io.FlowWriter(self.f)

    def response(self, flow: http.HTTPFlow) -> None:
        if random.choice([True, False]):
            self.w.add(flow)

    def done(self):
        self.f.close()


addons = [Writer(sys.argv[1])]
re. Without this patch, the network driver crashes the kernel almost immediately on Armada XP platforms, if the network load is at least a little bit parallel (i.e several threads). [Thomas Petazzoni: reword commit message] Signed-off-by: Dmitri Epshtein <dima@marvell.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> --- This is 3.8-rc material. --- drivers/net/ethernet/marvell/mvneta.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c @@ -1310,6 +1310,17 @@ static u32 mvneta_skb_tx_csum(struct mvn return MVNETA_TX_L4_CSUM_NOT; } +static u16 mvneta_tx_policy(struct mvneta_port *pp, struct sk_buff *skb) +{ + return (u16)txq_def; +} + +static u16 mvneta_select_txq(struct net_device *dev, struct sk_buff *skb) +{ + struct mvneta_port *pp = netdev_priv(dev); + return mvneta_tx_policy(pp, skb); +} + /* Returns rx queue pointer (find last set bit) according to causeRxTx * value */ @@ -1476,7 +1487,8 @@ error: static int mvneta_tx(struct sk_buff *skb, struct net_device *dev) { struct mvneta_port *pp = netdev_priv(dev); - struct mvneta_tx_queue *txq = &pp->txqs[txq_def]; + u16 txq_id = mvneta_tx_policy(pp, skb); + struct mvneta_tx_queue *txq = &pp->txqs[txq_id]; struct mvneta_tx_desc *tx_desc; struct netdev_queue *nq; int frags = 0; @@ -1486,7 +1498,7 @@ static int mvneta_tx(struct sk_buff *skb goto out; frags = skb_shinfo(skb)->nr_frags + 1; - nq = netdev_get_tx_queue(dev, txq_def); + nq = netdev_get_tx_queue(dev, txq_id); /* Get a descriptor for the first part of the packet */ tx_desc = mvneta_txq_next_desc_get(txq); @@ -2550,6 +2562,7 @@ static const struct net_device_ops mvnet .ndo_change_mtu = mvneta_change_mtu, .ndo_tx_timeout = mvneta_tx_timeout, .ndo_get_stats64 = mvneta_get_stats64, + .ndo_select_queue = mvneta_select_txq, }; const struct ethtool_ops mvneta_eth_tool_ops = {