 net: sched: cls_u32: Undo tcf_bind_filter if u32_replace_hw_knode · gregkh/linux@a934579 · GitHub Skip to content Navigation Menu Toggle navigation Sign in Appearance settings Platform AI CODE CREATION GitHub Copilot Write better code with AI GitHub Spark Build and deploy intelligent apps GitHub Models Manage and compare prompts MCP Registry New Integrate external tools DEVELOPER WORKFLOWS Actions Automate any workflow Codespaces Instant dev environments Issues Plan and track work Code Review Manage code changes APPLICATION SECURITY GitHub Advanced Security Find and fix vulnerabilities Code security Secure your code as you build Secret protection  EXPLORE Why GitHub Documentation Blog Changelog Marketplace View all features Solutions BY COMPANY SIZE Enterprises Small and medium teams Startups Nonprofits BY USE CASE App Modernization DevSecOps DevOps CI/CD View all use cases BY INDUSTRY Healthcare Financial services Manufacturing Government View all industries View all solutions Resources EXPLORE BY TOPIC AI Software Development DevOps Security View all topics EXPLORE BY TYPE Customer stories Events &amp; webinars Ebooks &amp; reports Business insights GitHub Skills SUPPORT &amp; SERVICES Documentation Customer support Community forum Trust center Partners View all resources Open Source COMMUNITY GitHub Sponsors Fund open source developers PROGRAMS Security Lab Maintainer Community Accelerator GitHub Stars Archive Program REPOSITORIES Topics Trending Collections Enterprise ENTERPRISE SOLUTIONS Enterprise platform AI-powered developer platform AVAILABLE ADD-ONS GitHub Advanced Security Enterprise-grade security features Copilot for Business Enterprise-grade AI features Premium Support Enterprise-grade 24/7 support Pricing Search or jump to... Search code, repositories, users, issues, pull requests... --> Search Clear Search syntax tips Provide feedback --> We read every piece of feedback, and take your input very seriously.  Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly --> Name Query To see all available qualifiers, see our documentation . Cancel Create saved search Sign in Sign up Appearance settings Resetting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} gregkh / linux Public Notifications You must be signed in to change notification settings Fork 686 Star 644 Code Actions Security and quality 0 Insights Additional navigation options Code Actions Security and quality Insights Commit a934579 Browse files Browse files vbnogueira authored and gregkh committed net: sched: cls_u32: Undo tcf_bind_filter if u32_replace_hw_knode [ Upstream commit 9cb36fa ] When u32_replace_hw_knode fails, we need to undo the tcf_bind_filter operation done at u32_set_parms. Fixes: d34e3e1 ("net: cls_u32: Add support for skip-sw flag to tc u32 classifier.") Signed-off-by: Victor Nogueira &lt;victor@mojatatu.com&gt; Acked-by: Jamal Hadi Salim &lt;jhs@mojatatu.com&gt; Reviewed-by: Pedro Tammela &lt;pctammela@mojatatu.com&gt; Reviewed-by: Simon Horman &lt;simon.horman@corigine.com&gt; Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt; Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt; 1 parent fa753f8 commit a934579 Copy full SHA for a934579 1 file changed + 30 - 11 Lines changed: 30 additions &amp; 11 deletions File tree Expand file tree Collapse file tree Open diff view settings Filter options net/sched cls_u32.c Expand file tree Collapse file tree Open diff view settings Collapse file ‎ net/sched/cls_u32.c ‎ Copy file name to clipboard Expand all lines: net/sched/cls_u32.c + 30 - 11 Lines changed: 30 additions &amp; 11 deletions Original file line number Diff line number Diff line change @@ -710,8 +710,23 @@ static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = { 710 710 [ TCA_U32_FLAGS ] = { . type = NLA_U32 }, 711 711 }; 712 712 713 + static void u32_unbind_filter ( struct tcf_proto * tp , struct tc_u_knode * n , 714 + struct nlattr * * tb ) 715 + { 716 + if ( tb [ TCA_U32_CLASSID ]) 717 + tcf_unbind_filter ( tp , &amp; n -&gt; res ); 718 + } 719 + 720 + static void u32_bind_filter ( struct tcf_proto * tp , struct tc_u_knode * n , 721 + unsigned long base , struct nlattr * * tb ) 722 + { 723 + if ( tb [ TCA_U32_CLASSID ]) { 724 + n -&gt; res . classid = nla_get_u32 ( tb [ TCA_U32_CLASSID ]); 725 + tcf_bind_filter ( tp , &amp; n -&gt; res , base ); 726 + } 727 + } 728 + 713 729 static int u32_set_parms ( struct net * net , struct tcf_proto * tp , 714 - unsigned long base , 715 730 struct tc_u_knode * n , struct nlattr * * tb , 716 731 struct nlattr * est , u32 flags , u32 fl_flags , 717 732 struct netlink_ext_ack * extack ) @@ -758,10 +773,6 @@ static int u32_set_parms(struct net *net, struct tcf_proto *tp, 758 773 if ( ht_old ) 759 774 ht_old -&gt; refcnt -- ; 760 775 } 761 - if ( tb [ TCA_U32_CLASSID ]) { 762 - n -&gt; res . classid = nla_get_u32 ( tb [ TCA_U32_CLASSID ]); 763 - tcf_bind_filter ( tp , &amp; n -&gt; res , base ); 764 - } 765 776 766 777 if ( ifindex &gt;= 0 ) 767 778 n -&gt; ifindex = ifindex ; @@ -901,17 +912,20 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, 901 912 if (! new ) 902 913 return - ENOMEM ; 903 914 904 - err = u32_set_parms ( net , tp , base , new , tb , 905 - tca [ TCA_RATE ], flags , new -&gt; flags , 906 - extack ); 915 + err = u32_set_parms ( net , tp , new , tb , tca [ TCA_RATE ], 916 + flags , new -&gt; flags , extack ); 907 917 908 918 if ( err ) { 909 919 __u32_destroy_key ( new ); 910 920 return err ; 911 921 } 912 922 923 + u32_bind_filter ( tp , new , base , tb ); 924 + 913 925 err = u32_replace_hw_knode ( tp , new , flags , extack ); 914 926 if ( err ) { 927 + u32_unbind_filter ( tp , new , tb ); 928 + 915 929 __u32_destroy_key ( new ); 916 930 return err ; 917 931 } @@ -1072,15 +1086,18 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, 1072 1086 } 1073 1087 #endif 1074 1088 1075 - err = u32_set_parms ( net , tp , base , n , tb , tca [ TCA_RATE ], 1089 + err = u32_set_parms ( net , tp , n , tb , tca [ TCA_RATE ], 1076 1090 flags , n -&gt; flags , extack ); 1091 + 1092 + u32_bind_filter ( tp , n , base , tb ); 1093 + 1077 1094 if ( err == 0 ) { 1078 1095 struct tc_u_knode __rcu * * ins ; 1079 1096 struct tc_u_knode * pins ; 1080 1097 1081 1098 err = u32_replace_hw_knode ( tp , n , flags , extack ); 1082 1099 if ( err ) 1083 - goto errhw ; 1100 + goto errunbind ; 1084 1101 1085 1102 if (! tc_in_hw ( n -&gt; flags )) 1086 1103 n -&gt; flags |= TCA_CLS_FLAGS_NOT_IN_HW ; @@ -1098,7 +1115,9 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, 1098 1115 return 0 ; 1099 1116 } 1100 1117 1101 - errhw : 1118 + errunbind : 1119 + u32_unbind_filter ( tp , n , tb ); 1120 + 1102 1121 #ifdef CONFIG_CLS_U32_MARK 1103 1122 free_percpu ( n -&gt; pcpu_success ); 1104 1123 #endif 0 commit comments Comments 0 ( 0 ) Footer &copy; 2026 GitHub,&nbsp;Inc. Footer navigation Terms Privacy Security Status Community Docs Contact Manage cookies Do not share my personal information You can’t perform that action at this time. 