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: <8738ukosar.fsf@nemi.mork.no>
Date:	Sun, 21 Apr 2013 16:46:20 +0200
From:	Bjørn Mork <bjorn@...k.no>
To:	Cong Wang <amwang@...hat.com>
Cc:	David Stevens <dlstevens@...ibm.com>,
	"David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org,
	Stephen Hemminger <stephen@...workplumber.org>
Subject: Re: [Patch net-next v4 4/5] vxlan: add scope_id support for ll addr

Cong Wang <amwang@...hat.com> writes:
> On Fri, 2013-04-19 at 07:14 -0400, David Stevens wrote:
>> 
>>         As I commented before, you're obscuring the types here,
>> which makes it less readable. "va_sin6" ought to be a sockaddr_in6,
>> not a sin6_addr, and the scope id ought to then be 
>> "va_sin6.sin6_scope_id",
>> without any other #define necessary for it.
>
> So finally you want something like:
>
> vxlan->default_dst.remote_ip.va_sin.sin_addr.s_addr
>
> and
>
> vxlan->default_dst.remote_ip.va_sin6.sin6_addr
>
> Enjoy the readable code! :)

There's nothing preventing you from using local variables and/or
functions to shorten those, without obscuring things on the way.
Readability depends on more than just "short".  Obviously correct type
is more important. But you can do both.  Most kernel code does. It's not
hard.



struct vxlan_addr {
	union {
		struct sockaddr_in	sin;
		struct sockaddr_in6	sin6;
		struct sockaddr		sa;
	} u;
#define va_sin  u.sin
#define va_sin6 u.sin6
#define va_sa   u.sa
};
 
struct vxlan_addr *rip = &vxlan->default_dst.remote_ip;

rip->va_sin.sin_addr.s_addr
rip->va_sin6.sin6_addr

etc.


Bjørn
--
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