[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130210184918.GB20897@order.stressinduktion.org>
Date: Sun, 10 Feb 2013 19:49:18 +0100
From: Hannes Frederic Sowa <hannes@...essinduktion.org>
To: YOSHIFUJI Hideaki <yoshfuji@...ux-ipv6.org>
Cc: Erik Hugne <erik.hugne@...csson.com>, netdev@...r.kernel.org
Subject: Re: [IPv6] interface-local multicast escapes the local node
On Mon, Feb 11, 2013 at 03:42:53AM +0900, YOSHIFUJI Hideaki wrote:
> Hannes Frederic Sowa wrote:
> > I was looking at getpeername et. al. where we should report the scope
> > back to the user. A common pattern is:
> >
> > if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)
> > sin->sin6_scope_id = IP6CB(skb)->iif;
> >
> > I propose to introduce something like 'bool ipv6_addr_intf_scoped(in6_addr)'
> > and let it check for ll addresses and interface scoped addresses.
>
> Hmm, maybe, we might want to say:
>
> __u32 __ipv6_iface_scope_id(int type, unsigned int iface)
> {
> if (type == IPV6_ADDR_ANY ||
> type & IPV6_ADDR_LOOPBACK ||
> __ipv6_addr_src_scope(type) > IPV6_ADDR_SCOPE_LINKLOCAL)
> return 0;
> return iface;
> }
>
> __u32 ipv6_iface_scope_id(const struct in6_addr *addr, unsigned int iface)
> {
> return __ipv6_iface_scope_id(__ipv6_addr_type(addr), iface);
> }
>
> And then,
> sin->sin6_scope_id = __ipv6_iface_scope_id(__ipv6_addr_type(&sin->sin6_addr),
> IP6CB(skb)->iif);
> or
> sin->sin6_scope_id = ipv6_iface_scope_id(&sin->sin6_addr, IP6CB(skb)->iif);
I like it. Will try to convert some checks and let you know how it turned out.
--
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