From ba2c114db09c5d4f0a6ec57db219e4fa09590f5f Mon Sep 17 00:00:00 2001 From: Jesper Dangaard Brouer Date: Tue, 1 Feb 2022 13:28:20 +0100 Subject: [PATCH] tc-policy: Take into account locally generated traffic The BPF-prog "not_txq_zero" also needed to take into account that skb->queue_mapping usually isn't set for locally generated traffic. I worry that sockets can set another queue id that could override our (BPF choice) in netdev_pick_tx(). See sk_tx_queue_set() and sk_tx_queue_get(). Signed-off-by: Jesper Dangaard Brouer --- tc-policy/monitor_txq_usage.bt | 2 +- tc-policy/tc_txq_policy_kern.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tc-policy/monitor_txq_usage.bt b/tc-policy/monitor_txq_usage.bt index 5192996..c83c603 100755 --- a/tc-policy/monitor_txq_usage.bt +++ b/tc-policy/monitor_txq_usage.bt @@ -7,7 +7,7 @@ tracepoint:net:net_dev_start_xmit { $qm = args->queue_mapping; - $dev = str(args->name, 15); + $dev = str(args->name, 16); @stat_txq_usage[$dev] = lhist($qm, 0,32,1); } diff --git a/tc-policy/tc_txq_policy_kern.c b/tc-policy/tc_txq_policy_kern.c index 31dcf29..a207401 100644 --- a/tc-policy/tc_txq_policy_kern.c +++ b/tc-policy/tc_txq_policy_kern.c @@ -70,5 +70,11 @@ int not_txq_zero (struct __sk_buff *skb) if (skb->queue_mapping == 1) skb->queue_mapping = 4; + /* If queue_mapping was not set by skb_record_rx_queue(), + * e.g. locally generated traffic + */ + if (skb->queue_mapping == 0) + skb->queue_mapping = 3; + return TC_ACT_OK; }