lkml.org 
[lkml]   [2013]   [Feb]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] hlist: drop the node parameter from iterators
On Wed, 30 Jan 2013 21:00:22 -0500
Sasha Levin <sasha.levin@oracle.com> wrote:

> I'm not sure why, but the hlist for each entry iterators were conceived
> differently from the list ones. While the list ones are nice and elegant:
>
> list_for_each_entry(pos, head, member)
>
> The hlist ones were greedy and wanted an extra parameter:
>
> hlist_for_each_entry(tpos, pos, head, member)
>
> Why did they need an extra pos parameter? I'm not quite sure. Not only
> they don't really need it, it also prevents the iterator from looking
> exactly like the list iterator, which is unfortunate.
>
> ...
>
> --- a/net/ipv4/raw.c
> +++ b/net/ipv4/raw.c
> @@ -111,9 +111,7 @@ EXPORT_SYMBOL_GPL(raw_unhash_sk);
> static struct sock *__raw_v4_lookup(struct net *net, struct sock *sk,
> unsigned short num, __be32 raddr, __be32 laddr, int dif)
> {
> - struct hlist_node *node;
> -
> - sk_for_each_from(sk, node) {
> + sk_for_each_from(sk) {
> struct inet_sock *inet = inet_sk(sk);
>
> if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
> @@ -122,6 +120,11 @@ static struct sock *__raw_v4_lookup(struct net *net, struct sock *sk,
> !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
> goto found; /* gotcha */
> }
> + sk_for_each_from (sk) {
> + struct inet_sock *inet=inet_sk(sk);
> + if (net_eq(sock_net(sk), net) && inet->inet_num == num && !(inet->inet_daddr && inet->inet_daddr != raddr) && !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) && !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
> + goto found;
> + }
> sk = NULL;
> found:
> return sk;

The second hunk is bogus and I dropped it. This didn't increase my
confidence in the patch :(



\
 
 \ /
  Last update: 2013-02-07 23:21    [W:0.378 / U:0.520 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site