diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 99ac747b7906..a97838c1c56d 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -692,6 +692,9 @@ struct tc_cls_u32_offload { static inline bool tc_can_offload(const struct net_device *dev) { + if (!net_eq(dev_net(dev), &init_net)) + return false; + return dev->features & NETIF_F_HW_TC; } diff --git a/net/netfilter/nf_flow_table_offload.c b/net/netfilter/nf_flow_table_offload.c index b1966b68c48a..c6d426052765 100644 --- a/net/netfilter/nf_flow_table_offload.c +++ b/net/netfilter/nf_flow_table_offload.c @@ -1173,6 +1173,9 @@ static int nf_flow_table_offload_cmd(struct flow_block_offload *bo, { int err; + if (!net_eq(dev_net(dev), &init_net)) + return -EOPNOTSUPP; + nf_flow_table_block_offload_init(bo, dev_net(dev), cmd, flowtable, extack); down_write(&flowtable->flow_block_lock); diff --git a/net/netfilter/nf_tables_offload.c b/net/netfilter/nf_tables_offload.c index fd30e205de84..048fa5f356d9 100644 --- a/net/netfilter/nf_tables_offload.c +++ b/net/netfilter/nf_tables_offload.c @@ -233,6 +233,9 @@ bool nft_chain_offload_support(const struct nft_base_chain *basechain) ops->hooknum != NF_NETDEV_INGRESS) return false; + if (!net_eq(dev_net(dev), &init_net)) + return false; + dev = ops->dev; if (!dev->netdev_ops->ndo_setup_tc && !flow_indr_dev_exists()) diff --git a/net/sched/sch_cbs.c b/net/sched/sch_cbs.c index 8c9a0400c862..6daa9f702a59 100644 --- a/net/sched/sch_cbs.c +++ b/net/sched/sch_cbs.c @@ -281,7 +281,7 @@ static int cbs_enable_offload(struct net_device *dev, struct cbs_sched_data *q, struct tc_cbs_qopt_offload cbs = { }; int err; - if (!ops->ndo_setup_tc) { + if (!tc_can_offload(dev) || !ops->ndo_setup_tc) { NL_SET_ERR_MSG(extack, "Specified device does not support cbs offload"); return -EOPNOTSUPP; } diff --git a/net/sched/sch_etf.c b/net/sched/sch_etf.c index c74d778c32a1..7801e009e025 100644 --- a/net/sched/sch_etf.c +++ b/net/sched/sch_etf.c @@ -323,7 +323,7 @@ static int etf_enable_offload(struct net_device *dev, struct etf_sched_data *q, struct tc_etf_qopt_offload etf = { }; int err; - if (!ops->ndo_setup_tc) { + if (!tc_can_offload(dev) || !ops->ndo_setup_tc) { NL_SET_ERR_MSG(extack, "Specified device does not support ETF offload"); return -EOPNOTSUPP; } diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index f3e5ef9a9592..d853f3b60121 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -410,7 +410,7 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt, * the queue mapping then run ndo_setup_tc otherwise use the * supplied and verified mapping */ - if (qopt->hw) { + if (qopt->hw && tc_can_offload(dev)) { err = mqprio_enable_offload(sch, qopt, extack); if (err) return err; diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 300d577b3286..7451d74af91f 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1522,7 +1522,7 @@ static int taprio_enable_offload(struct net_device *dev, struct tc_taprio_caps caps; int tc, err = 0; - if (!ops->ndo_setup_tc) { + if (!tc_can_offload(dev) || !ops->ndo_setup_tc) { NL_SET_ERR_MSG(extack, "Device does not support taprio offload"); return -EOPNOTSUPP;