From patchwork Sun Sep 9 01:31:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 967677 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ZenIV.linux.org.uk Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 427DDn00vpz9s3C for ; Sun, 9 Sep 2018 11:32:08 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726597AbeIIGTr (ORCPT ); Sun, 9 Sep 2018 02:19:47 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:40796 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726152AbeIIGTr (ORCPT ); Sun, 9 Sep 2018 02:19:47 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fyoZY-0000qZ-8g; Sun, 09 Sep 2018 01:31:42 +0000 From: Al Viro To: netdev@vger.kernel.org Cc: Jamal Hadi Salim , Cong Wang , Jiri Pirko Subject: [PATCH net 00/13] cls_u32 cleanups and fixes. Date: Sun, 9 Sep 2018 02:31:19 +0100 Message-Id: <20180909013132.3222-1-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.9.5 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Al Viro A series of net/sched/cls_u32.c cleanups and fixes: 1) fix hnode refcounting. Refcounting for tc_u_hnode is broken; it's not hard to trigger oopsen (including one inside an interrupt handler, with resulting panic) as well as memory corruption. Definitely -stable fodder. 2) mark root hnode explicitly. Consistent errors on attempts to delete root hnodes. Less serious than 1/13. 3) disallow linking to root hnode. Prohibit creating links to root hnodes; not critical (nothing actually breaks if we do allow those), but gets rid of surprising cases. 4) make sure that divisor is a power of 2. Missing validation - divisor is documented as power of 2, but that's not actually enforced. Results are moderately bogus (i.e. the kernel doesn't break), but rather surprising. Those are fixes, or at least can be argued to be such. The rest are pure cleanups: 5) get rid of unused argument of u32_destroy_key() 6) get rid of tc_u_knode ->tp 7) get rid of tc_u_common ->rcu Eliminate some unused fields. 8) clean tc_u_common hashtable. Hash lookups are best done with minimum of calculations per chain element - comparing the field in each candidate with f(key) where f() is actually a pure function is not nice, especially when compiler doesn't see f() as such... Better calculate f(key) once, especially since we need its value to choose the hash chain in the first place. 9) pass tc_u_common to u32_set_parms() instead of tc_u_hnode 10) the tp_c argument of u32_set_parms() is always tp->data 11) get rid of hnode ->tp_c and tp_c argument of u32_set_parms() Massage that ends with getting rid of a redundant field. 12) keep track of knodes count in tc_u_common 13) simplify the hell out u32_delete() emptiness check Checking if a filter needs to be killed after u32_delete() can be done much easier - the test is equivalent to "filter doesn't have ->data shared with anyone else and it has no knodes left in it" and keeping track of the number of knodes is trivial.