[openib-general] [PATCH RFC 1/31] net: Add net_namespace_type.h to allow for per network namespace variables.

ebiederm at xmission.com ebiederm at xmission.com
Thu Jan 25 12:53:11 PST 2007


Stephen Hemminger <shemminger at linux-foundation.org> writes:

> Can all this be a nop if a CONFIG option is not selected?

That is exactly what this infrastructure supports.
What you see is the version that comes into effect when
the CONFIG option is not selected.

>From using an empty structure to replace a pointer to make
that a NOP to most of the rest below.


>> diff --git a/include/linux/net_namespace_type.h
> b/include/linux/net_namespace_type.h
>> new file mode 100644
>> index 0000000..8173f59
>> --- /dev/null
>> +++ b/include/linux/net_namespace_type.h
>> @@ -0,0 +1,52 @@
>> +/* 
>> + * Definition of the network namespace reference type
>> + * And operations upon it.
>> + */
>> +#ifndef __LINUX_NET_NAMESPACE_TYPE_H
>> +#define __LINUX_NET_NAMESPACE_TYPE_H
>> +
>> +#define __pernetname(name) per_net__##name
>
> Code obfuscation, please don't do that

Single point of making the naming rules, better maintenance.
The basic point is that variables that come through this path
you should not access directly.  Tweaking the name enforces that
even in the compiled out state.

>> +typedef struct {} net_t;
>
> No typedef for this please.

Why.  That is conventially how we do opaque types in linux
when someone is doing something sophisticated.


You probably want to look down to patch 21 to see what the compiled
in version of these look like.

Eric




More information about the general mailing list