Thread (30 messages) 30 messages, 3 authors, 2018-09-08

Re: [PATCH 2/7] mark root hnode explicitly

flat view

From: Jamal Hadi Salim <jhs@mojatatu.com>
Date: 2018-09-06 15:39:32

On 2018-09-06 6:59 a.m., Al Viro wrote:
On Thu, Sep 06, 2018 at 06:34:00AM -0400, Jamal Hadi Salim wrote:
quoted
On 2018-09-06 6:28 a.m., Jamal Hadi Salim wrote:
[..]
quoted hunk ↗ jump to hunk
Point, and that one is IMO enough to give up on using ->flags for
that.  How about simply
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 3f985f29ef30..d14048e38b5c 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -84,6 +84,7 @@ struct tc_u_hnode {
  	int			refcnt;
  	unsigned int		divisor;
  	struct idr		handle_idr;
+	bool			is_root;
  	struct rcu_head		rcu;
  	u32			flags;
  	/* The 'ht' field MUST be the last field in structure to allow for
@@ -377,6 +378,7 @@ static int u32_init(struct tcf_proto *tp)
  	root_ht->refcnt++;
  	root_ht->handle = tp_c ? gen_new_htid(tp_c, root_ht) : 0x80000000;
  	root_ht->prio = tp->prio;
+	root_ht->is_root = true;
  	idr_init(&root_ht->handle_idr);
  
  	if (tp_c == NULL) {
@@ -693,7 +695,7 @@ static int u32_delete(struct tcf_proto *tp, void *arg, bool *last,
  		goto out;
  	}
  
-	if (root_ht == ht) {
+	if (ht->is_root) {
  		NL_SET_ERR_MSG_MOD(extack, "Not allowed to delete root node");
  		return -EINVAL;
  	}
@@ -795,6 +797,10 @@ static int u32_set_parms(struct net *net, struct tcf_proto *tp,
  				NL_SET_ERR_MSG_MOD(extack, "Link hash table not found");
  				return -EINVAL;
  			}
+			if (ht_down->is_root) {
+				NL_SET_ERR_MSG_MOD(extack, "Not linking to root node");
+				return -EINVAL;
+			}
  			ht_down->refcnt++;

Looks good to me ;->

cheers,
jamal
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help