lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1394473516.3607.48.camel@edumazet-glaptop2.roam.corp.google.com>
Date:	Mon, 10 Mar 2014 10:45:16 -0700
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	John Fastabend <john.fastabend@...il.com>
Cc:	xiyou.wangcong@...il.com, jhs@...atatu.com, netdev@...r.kernel.org,
	davem@...emloft.net
Subject: Re: [RCU PATCH 07/14] net: sched: RCU cls_route

On Mon, 2014-03-10 at 10:06 -0700, John Fastabend wrote:
> RCUify the route classifier. For now however spinlock's are used to
> protect fastmap cache.
> 
> The issue here is the fastmap may be read by one CPU while the
> cache is being updated by another. An array of pointers could be
> one possible solution.
> 
> Signed-off-by: John Fastabend <john.r.fastabend@...el.com>
> ---
>  net/sched/cls_route.c |  217 ++++++++++++++++++++++++++++---------------------
>  1 file changed, 124 insertions(+), 93 deletions(-)
> 
> diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c
> index 1ad3068..cd0abba 100644
> --- a/net/sched/cls_route.c
> +++ b/net/sched/cls_route.c
> @@ -29,25 +29,26 @@
>   *    are mutually  exclusive.
>   * 3. "to TAG from ANY" has higher priority, than "to ANY from XXX"
>   */
> -
>  struct route4_fastmap {
> -	struct route4_filter	*filter;
> -	u32			id;
> -	int			iif;
> +	struct route4_filter		*filter;
> +	u32				id;
> +	int				iif;
>  };
>  
>  struct route4_head {
> -	struct route4_fastmap	fastmap[16];
> -	struct route4_bucket	*table[256 + 1];
> +	struct route4_fastmap		fastmap[16];
> +	struct route4_bucket __rcu	*table[256 + 1];
> +	struct rcu_head			rcu;
>  };
>  
>  struct route4_bucket {
>  	/* 16 FROM buckets + 16 IIF buckets + 1 wildcard bucket */
> -	struct route4_filter	*ht[16 + 16 + 1];
> +	struct route4_filter __rcu	*ht[16 + 16 + 1];
> +	struct rcu_head			rcu;
>  };
>  
>  struct route4_filter {
> -	struct route4_filter	*next;
> +	struct route4_filter __rcu	*next;
>  	u32			id;
>  	int			iif;
>  
> @@ -55,6 +56,8 @@ struct route4_filter {
>  	struct tcf_exts		exts;
>  	u32			handle;
>  	struct route4_bucket	*bkt;
> +	struct tcf_proto	*tp;
> +	struct rcu_head		rcu;
>  };
>  
>  #define ROUTE4_FAILURE ((struct route4_filter *)(-1L))
> @@ -64,14 +67,13 @@ static inline int route4_fastmap_hash(u32 id, int iif)
>  	return id & 0xF;
>  }
>  
> +static DEFINE_SPINLOCK(fastmap_lock);
>  static void
> -route4_reset_fastmap(struct Qdisc *q, struct route4_head *head, u32 id)
> +route4_reset_fastmap(struct route4_head *head)
>  {
> -	spinlock_t *root_lock = qdisc_root_sleeping_lock(q);
> -
> -	spin_lock_bh(root_lock);
> +	spin_lock(&fastmap_lock);

Dont you need spin_lock_bh() ?

>  	memset(head->fastmap, 0, sizeof(head->fastmap));
> -	spin_unlock_bh(root_lock);
> +	spin_unlock(&fastmap_lock);
>  }
>  
>  static void
> @@ -80,9 +82,12 @@ route4_set_fastmap(struct route4_head *head, u32 id, int iif,
>  {
>  	int h = route4_fastmap_hash(id, iif);
>  
> +	/* fastmap updates must look atomic to aling id, iff, filter */
> +	spin_lock(&fastmap_lock);

same here

>  	head->fastmap[h].id = id;
>  	head->fastmap[h].iif = iif;
>  	head->fastmap[h].filter = f;
> +	spin_unlock(&fastmap_lock);
>  }
>  



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ