 net: sched: cls_u32: Undo tcf_bind_filter if u32_replace_hw_knode · gregkh/linux@9cb36fa · 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 9cb36fa Browse files Browse files vbnogueira authored and davem330 committed net: sched: cls_u32: Undo tcf_bind_filter if u32_replace_hw_knode 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; 1 parent b3d0e04 commit 9cb36fa Copy full SHA for 9cb36fa 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 @@ -712,8 +712,23 @@ static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = { 712 712 [ TCA_U32_FLAGS ] = { . type = NLA_U32 }, 713 713 }; 714 714 715 + static void u32_unbind_filter ( struct tcf_proto * tp , struct tc_u_knode * n , 716 + struct nlattr * * tb ) 717 + { 718 + if ( tb [ TCA_U32_CLASSID ]) 719 + tcf_unbind_filter ( tp , &amp; n -&gt; res ); 720 + } 721 + 722 + static void u32_bind_filter ( struct tcf_proto * tp , struct tc_u_knode * n , 723 + unsigned long base , struct nlattr * * tb ) 724 + { 725 + if ( tb [ TCA_U32_CLASSID ]) { 726 + n -&gt; res . classid = nla_get_u32 ( tb [ TCA_U32_CLASSID ]); 727 + tcf_bind_filter ( tp , &amp; n -&gt; res , base ); 728 + } 729 + } 730 + 715 731 static int u32_set_parms ( struct net * net , struct tcf_proto * tp , 716 - unsigned long base , 717 732 struct tc_u_knode * n , struct nlattr * * tb , 718 733 struct nlattr * est , u32 flags , u32 fl_flags , 719 734 struct netlink_ext_ack * extack ) @@ -760,10 +775,6 @@ static int u32_set_parms(struct net *net, struct tcf_proto *tp, 760 775 if ( ht_old ) 761 776 ht_old -&gt; refcnt -- ; 762 777 } 763 - if ( tb [ TCA_U32_CLASSID ]) { 764 - n -&gt; res . classid = nla_get_u32 ( tb [ TCA_U32_CLASSID ]); 765 - tcf_bind_filter ( tp , &amp; n -&gt; res , base ); 766 - } 767 778 768 779 if ( ifindex &gt;= 0 ) 769 780 n -&gt; ifindex = ifindex ; @@ -903,17 +914,20 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, 903 914 if (! new ) 904 915 return - ENOMEM ; 905 916 906 - err = u32_set_parms ( net , tp , base , new , tb , 907 - tca [ TCA_RATE ], flags , new -&gt; flags , 908 - extack ); 917 + err = u32_set_parms ( net , tp , new , tb , tca [ TCA_RATE ], 918 + flags , new -&gt; flags , extack ); 909 919 910 920 if ( err ) { 911 921 __u32_destroy_key ( new ); 912 922 return err ; 913 923 } 914 924 925 + u32_bind_filter ( tp , new , base , tb ); 926 + 915 927 err = u32_replace_hw_knode ( tp , new , flags , extack ); 916 928 if ( err ) { 929 + u32_unbind_filter ( tp , new , tb ); 930 + 917 931 __u32_destroy_key ( new ); 918 932 return err ; 919 933 } @@ -1074,15 +1088,18 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, 1074 1088 } 1075 1089 #endif 1076 1090 1077 - err = u32_set_parms ( net , tp , base , n , tb , tca [ TCA_RATE ], 1091 + err = u32_set_parms ( net , tp , n , tb , tca [ TCA_RATE ], 1078 1092 flags , n -&gt; flags , extack ); 1093 + 1094 + u32_bind_filter ( tp , n , base , tb ); 1095 + 1079 1096 if ( err == 0 ) { 1080 1097 struct tc_u_knode __rcu * * ins ; 1081 1098 struct tc_u_knode * pins ; 1082 1099 1083 1100 err = u32_replace_hw_knode ( tp , n , flags , extack ); 1084 1101 if ( err ) 1085 - goto errhw ; 1102 + goto errunbind ; 1086 1103 1087 1104 if (! tc_in_hw ( n -&gt; flags )) 1088 1105 n -&gt; flags |= TCA_CLS_FLAGS_NOT_IN_HW ; @@ -1100,7 +1117,9 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, 1100 1117 return 0 ; 1101 1118 } 1102 1119 1103 - errhw : 1120 + errunbind : 1121 + u32_unbind_filter ( tp , n , tb ); 1122 + 1104 1123 #ifdef CONFIG_CLS_U32_MARK 1105 1124 free_percpu ( n -&gt; pcpu_success ); 1106 1125 #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. 