Skip to content

Commit 44a949a

Browse files
committed
Merge branch 'net-sched-tc-block-ports-tracking'
Victor Nogueira says: ==================== net/sched: Introduce tc block ports tracking and use __context__ The "tc block" is a collection of netdevs/ports which allow qdiscs to share match-action block instances (as opposed to the traditional tc filter per netdev/port)[1]. Up to this point in the implementation, the block is unaware of its ports. This patch makes the tc block ports available to the datapath. For the datapath we provide a use case of the tc block in a mirred action in patch 3. For users can levarage mirred to do something like the following: $ tc qdisc add dev ens7 ingress_block 22 clsact $ tc qdisc add dev ens8 ingress_block 22 clsact $ tc qdisc add dev ens9 ingress_block 22 clsact $ tc filter add block 22 protocol ip pref 25 \ flower dst_ip 192.168.0.0/16 action mirred egress mirror blockid 22 In this case, if the packet arrives on ens8, it will be copied and sent to all ports in the block excluding ens8. Note that the packet is still in the pipeline at this point - meaning other actions could be added after the mirror because mirred copies/clones the skb. Example the following is valid: $ tc filter add block 22 protocol ip pref 25 flower dst_ip 192.168.0.0/16 \ action mirred egress mirror blockid 22 \ action vlan push id 123 \ action mirred egress redirect dev dummy0 redirect behavior always steals the packet from the pipeline and therefore the skb is no longer available for a subsequent action as illustrated above (in redirecting to dummy0). The behavior of redirecting to a tc block is therefore adapted to work in the same manner. So a setup as such: $ tc qdisc add dev ens7 ingress_block 22 $ tc qdisc add dev ens8 ingress_block 22 $ tc qdisc add dev ens9 ingress_block 22 $ tc filter add block 22 protocol ip pref 25 \ flower dst_ip 192.168.0.0/16 action mirred egress redirect blockid 22 for a matching packet arriving on ens7 will first send a copy/clone to ens8 (as in the "mirror" behavior) then to ens9 as in the redirect behavior above. Once this processing is done - no other actions are able to process this skb. i.e it is removed from the "pipeline". In this case, if the packet arrives on ens8, it will be copied and sent to all ports in the block excluding ens8. Patch 1 separates/exports mirror and redirect functions from act_mirred Patch 2 introduces the required infra. Patch 3 Allows mirred to blocks Subsequent patches will come with tdc test cases. __Acknowledgements__ Suggestions from Vlad Buslov and Marcelo Ricardo Leitner made this patchset better. The idea of integrating the ports into the tc block was suggested by Jiri Pirko. [1] See commit ca46abd ("Merge branch'net-sched-allow-qdiscs-to-share-filter-block-instances'") Changes in v2: - Remove RFC tag - Add more details in patch 0(Jiri) - When CONFIG_NET_TC_SKB_EXT is selected we have unused qdisc_cb Reported-by: kernel test robot <[email protected]> (and [email protected]) - Fix bad dev dereference in printk of blockcast action (Simon) Changes in v3: - Add missing xa_destroy (pointed out by Vlad) - Remove bugfix pointed by Vlad (will send in separate patch) - Removed ports from subject in patch #2 and typos (suggested by Marcelo) - Remove net_notice_ratelimited debug messages in error cases (suggested by Marcelo) - Minor changes to appease sparse's lock context warning Changes in v4: - Avoid code repetition using gotos in cast_one (suggested by Paolo) - Fix typo in cover letter (pointed out by Paolo) - Create a module description for act_blockcast (reported by Paolo and CI) Changes in v5: - Add new patch which separated mirred into mirror and redirect functions (suggested by Jiri) - Instead of repeating the code to mirror in blockcast use mirror exported function by patch1 (tcf_mirror_act) - Make Block ID into act_blockcast's parameter passed by user space instead of always getting it from SKB (suggested by Jiri) - Add tx_type parameter which will specify what transmission behaviour we want (as described earlier) Changes in v6: - Remove blockcast and make it a part of mirred (suggestd by Jiri) - Block ID is now a mirred parameter - We now allow redirecting and mirroring to either ingress or egress Changes in v7: - Remove set but not used variable in tcf_mirred_act (pointed out by Jakub) Changes in v8: - Fix uapi issues (pointed out by Jiri) - Separate last patch into 3 - two as preparations for adding block ID to mirred and one allowing mirred to block (suggested by Jiri) - Remove declaration initialisation of eg_block and in_block in qdisc_block_add_dev (suggested by Jiri) - Avoid unnecessary if guards in qdisc_block_add_dev (suggested by Jiri) - Remove unncessary block_index retrieval in __qdisc_destroy (suggested by Jiri) ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents b1dffcf + 42f3903 commit 44a949a

File tree

7 files changed

+269
-65
lines changed

7 files changed

+269
-65
lines changed

include/net/sch_generic.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <net/gen_stats.h>
2020
#include <net/rtnetlink.h>
2121
#include <net/flow_offload.h>
22+
#include <linux/xarray.h>
2223

2324
struct Qdisc_ops;
2425
struct qdisc_walker;
@@ -456,6 +457,7 @@ struct tcf_chain {
456457
};
457458

458459
struct tcf_block {
460+
struct xarray ports; /* datapath accessible */
459461
/* Lock protects tcf_block and lifetime-management data of chains
460462
* attached to the block (refcnt, action_refcnt, explicitly_created).
461463
*/
@@ -482,6 +484,8 @@ struct tcf_block {
482484
struct mutex proto_destroy_lock; /* Lock for proto_destroy hashtable. */
483485
};
484486

487+
struct tcf_block *tcf_block_lookup(struct net *net, u32 block_index);
488+
485489
static inline bool lockdep_tcf_chain_is_locked(struct tcf_chain *chain)
486490
{
487491
return lockdep_is_held(&chain->filter_chain_lock);

include/net/tc_act/tc_mirred.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
struct tcf_mirred {
99
struct tc_action common;
1010
int tcfm_eaction;
11+
u32 tcfm_blockid;
1112
bool tcfm_mac_header_xmit;
1213
struct net_device __rcu *tcfm_dev;
1314
netdevice_tracker tcfm_dev_tracker;

include/uapi/linux/tc_act/tc_mirred.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ enum {
2121
TCA_MIRRED_TM,
2222
TCA_MIRRED_PARMS,
2323
TCA_MIRRED_PAD,
24+
TCA_MIRRED_BLOCKID,
2425
__TCA_MIRRED_MAX
2526
};
2627
#define TCA_MIRRED_MAX (__TCA_MIRRED_MAX - 1)

0 commit comments

Comments
 (0)