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: <87fv9clr3b.fsf@x220.int.ebiederm.org>
Date:	Tue, 10 Mar 2015 12:06:32 -0500
From:	ebiederm@...ssion.com (Eric W. Biederman)
To:	David Miller <davem@...emloft.net>
Cc:	ja@....bg, edumazet@...gle.com, netdev@...r.kernel.org,
	stephen@...workplumber.org, nicolas.dichtel@...nd.com,
	roopa@...ulusnetworks.com, hannes@...essinduktion.org,
	ddutt@...ulusnetworks.com, vipin@...ulusnetworks.com,
	shmulik.ladkani@...il.com, dsahern@...il.com
Subject: Re: [PATCH net-next 3/6] tcp_metrics: Add a field tcpm_net and verify it matches on lookup

David Miller <davem@...emloft.net> writes:

> From: ebiederm@...ssion.com (Eric W. Biederman)
> Date: Tue, 10 Mar 2015 01:59:48 -0500
>
>> If we actually really care about struct net going away it would be
>> much better to globally replace struct net with a typedef that looks
>> something like:
>> 
>> #ifdef CONFIG_NET_NS
>> struct net_ref {
>>        struct net *net;
>> };
>> #else
>> struct net_ref {
>> };
>> #endif
>> typedef struct net_ref net_t;
>> 
>> That would remove the need for write_pnet and read_pnet, make it
>> impossible to forget net_eq and make network namespace arguments to
>> functions also boil away at compile time if the network namespace code
>> was not enabled.
>> 
>> That was the original design and I forget why we didn't do that with
>> struct net.  But we did not.
>
> This keeps the ifdefs out of foo.c code, so I like it.

Alright.  It does wind up requiring things like:

static inline struct net *to_struct_net(net_t net)
{
#ifdef CONFIG_NET_NS
        return net.net;
#else
        return &init_net;
#endif        
}

static inline net_t to_net_t(struct net *net)
{
	net_t result;
#ifdef CONFIG_NET_NS
	result.net = net;
#endif        
	return result;
}

static inline struct struct net *ipv4_net(net_t net)
{
        return &to_struct_net(net)->ipv4;
}

But we are used to those from dealing with network devices,
so it should be no big deal.

I will start playing with it to see how much work that is to implement.

Any suggestions on a better name for to_struct_net()? Perhaps
global_net()?  Although arguably anything that to_struct_net feels
awkward for should it's own xxx_net type.

Eric

--
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