On Wed, 30 Jan 2013 21:00:22 -0500
Sasha Levin <[email protected]> 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 :(

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to