Search Linux Wireless

Re: [COMPAT] Preventing namespace pollution

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Nov 21, 2010 at 5:29 PM, Arnaud Lacombe <lacombar@xxxxxxxxx> wrote:
> Hi folks,
>
> The second part of the changes I made as part of my work on the
> compatibility headers concerned namespace pollution.
>
> The problem was the following. My module is doing relatively high
> level stuff in the kernel. It interracts with the network stack,
> netfilter, the socket layer, etc. It does not deals with low-level
> driver stuff. The issue was that including <linux/compat.h> bring a
> _huge_ quantity of dependency with it, interrupt, thread, sysfs...
> This is problematic as for some compilation unit, I should include as
> few Linux header as possible (understand: if I don't include
> <linux/tcp.h>, I don't want it included behind my back).
>
> In order to workaround the problem, I simply wrapped every accessors
> and struct definition within #ifdef checking if the parent header is
> in use or not.
>
> Considering the following exemple:
>
> 2.6.22:
> Âstatic inline unsigned char *
> Âskb_network_header(const struct sk_buff *skb)
> Â{
> Â Â Â Âreturn skb->nh.raw;
> Â}
>
> Â[...]
>
> Âstatic inline struct iphdr *
> Âip_hdr(const struct sk_buff *skb)
> Â{
> Â Â Â Âreturn (struct iphdr *)skb_network_header(skb);
> Â}
>
> Âstatic inline unsigned int
> Âip_hdrlen(const struct sk_buff *skb)
> Â{
> Â Â Â Âreturn ip_hdr(skb)->ihl * 4;
> Â}
>
> Every compilation unit would need to have both <linux/skbuff.h>,
> <linux/ip.h> and <net/ip.h> included. If the useful code does not
> deals about networking, that's just pollution.
>
> The solution I propose would transform this to:
>
> 2.6.22:
> Â/* <linux/skbuff.h> */
> Â#ifdef _LINUX_SKBUFF_H
> Âstatic inline unsigned char *
> Âskb_network_header(const struct sk_buff *skb)
> Â{
> Â Â Â Âreturn skb->nh.raw;
> Â}
> Â#endif
>
> Â[...]
>
> Â/* <linux/ip.h> */
> Â#ifdef _LINUX_IP_H
> Âstatic inline struct iphdr *
> Âip_hdr(const struct sk_buff *skb)
> Â{
> Â Â Â Âreturn (struct iphdr *)skb_network_header(skb);
> Â}
> Â#endif
>
> Â/* <net/ip.h> */
> Â#ifdef _IP_H
> Âstatic inline unsigned int
> Âip_hdrlen(const struct sk_buff *skb)
> Â{
> Â Â Â Âreturn ip_hdr(skb)->ihl * 4;
> Â}
> Â#endif
>
> That way, if the original code did not include the headers, it will
> just not get the compat definition. The macro checked is the one used
> as re-inclusion guard from the parent header which should be stable,
> but even if it changes, supporting the new is trivial. With this
> solution, the compat headers no longer needs to import all the headers
> it is providing compatibililty to, but just let the original source
> tells it what it needs compatibility for.
>
> I will send as answer to mail a proof of concept for 2.6.22

I suspect we'll find a case where headers are required to be included
for some older kernel where it was not required for newer ones but we
can find out. Just please be sure to test compile your patches against
each supported kernel and I think we'll be good!

  Luis
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux