OpenVZ Forum


Home » Mailing lists » Devel » Re: [patch 1/2] net namespace : Add broadcasting
Re: [patch 1/2] net namespace : Add broadcasting [message #17077] Fri, 15 December 2006 19:33 Go to next message
Dave Hansen is currently offline  Dave Hansen
Messages: 240
Registered: October 2005
Senior Member
On Fri, 2006-12-15 at 18:20 +0100, dlezcano@fr.ibm.com wrote:
> 
> --- 2.6.19-mm1.orig/net/ipv4/udp.c
> +++ 2.6.19-mm1/net/ipv4/udp.c
> @@ -306,9 +306,12 @@ static inline struct sock *udp_v4_mcast_
>                     (inet->dport != rmt_port && inet->dport)            ||
>                     (inet->rcv_saddr && inet->rcv_saddr != loc_addr)    ||
>                     ipv6_only_sock(s)                                   ||
> -                   !net_ns_match(sk->sk_net_ns, ns)                    ||
>                     (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
>                         continue;
> +#ifdef CONFIG_NET_NS
> +               if (!net_ns_sock_is_visible(sk, ns))
> +                       continue;
> +#endif 

Why is this #ifdef needed?  Isn't the stub in the header good enough?

-- Dave


_______________________________________________
Containers mailing list
Containers@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/containers
Re: [patch 1/2] net namespace : Add broadcasting [message #17083 is a reply to message #17077] Fri, 15 December 2006 20:21 Go to previous messageGo to next message
Daniel Lezcano is currently offline  Daniel Lezcano
Messages: 417
Registered: June 2006
Senior Member
Dave Hansen wrote:
> On Fri, 2006-12-15 at 18:20 +0100, dlezcano@fr.ibm.com wrote:
>   
>> --- 2.6.19-mm1.orig/net/ipv4/udp.c
>> +++ 2.6.19-mm1/net/ipv4/udp.c
>> @@ -306,9 +306,12 @@ static inline struct sock *udp_v4_mcast_
>>                     (inet->dport != rmt_port && inet->dport)            ||
>>                     (inet->rcv_saddr && inet->rcv_saddr != loc_addr)    ||
>>                     ipv6_only_sock(s)                                   ||
>> -                   !net_ns_match(sk->sk_net_ns, ns)                    ||
>>                     (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
>>                         continue;
>> +#ifdef CONFIG_NET_NS
>> +               if (!net_ns_sock_is_visible(sk, ns))
>> +                       continue;
>> +#endif 
>>     
>
> Why is this #ifdef needed?  Isn't the stub in the header good enough?
>   
I don't know. What does the compiler ? Will it remove the "return 1" 
code from the stub if CONFIG_NET_NS is disabled because the test will be 
always true ?

_______________________________________________
Containers mailing list
Containers@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/containers
Re: [patch 1/2] net namespace : Add broadcasting [message #17086 is a reply to message #17083] Mon, 18 December 2006 23:45 Go to previous message
Dave Hansen is currently offline  Dave Hansen
Messages: 240
Registered: October 2005
Senior Member
On Fri, 2006-12-15 at 21:21 +0100, Daniel Lezcano wrote:
> Dave Hansen wrote:
> > On Fri, 2006-12-15 at 18:20 +0100, dlezcano@fr.ibm.com wrote:
> >
> >> --- 2.6.19-mm1.orig/net/ipv4/udp.c
> >> +++ 2.6.19-mm1/net/ipv4/udp.c
> >> @@ -306,9 +306,12 @@ static inline struct sock *udp_v4_mcast_
> >>                     (inet->dport != rmt_port && inet->dport)            ||
> >>                     (inet->rcv_saddr && inet->rcv_saddr != loc_addr)    ||
> >>                     ipv6_only_sock(s)                                   ||
> >> -                   !net_ns_match(sk->sk_net_ns, ns)                    ||
> >>                     (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
> >>                         continue;
> >> +#ifdef CONFIG_NET_NS
> >> +               if (!net_ns_sock_is_visible(sk, ns))
> >> +                       continue;
> >> +#endif
> >>
> >
> > Why is this #ifdef needed?  Isn't the stub in the header good enough?
> >
> I don't know

If you don't know, then you should stop writing code until you find
out!! :P

> What does the compiler ? Will it remove the "return 1"
> code from the stub if CONFIG_NET_NS is disabled because the test will be
> always true ?

Yes.  And if it is always false, it will kill the entire block of code.

Repeat after me:  I will not put #ifdefs in .c files.  I will not put
#ifdefs in .c files.  I will not put #ifdefs in .c files.

-- Dave

_______________________________________________
Containers mailing list
Containers@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/containers
Previous Topic: [PATCH] IA64: alignment bug in ldscript
Next Topic: seems to be a flaw in cfq
Goto Forum:
  


Current Time: Tue Sep 09 21:04:00 GMT 2025

Total time taken to generate the page: 0.10814 seconds