Hi Raúl,

thank you for your detailed investigations about the smcroute error.

Raúl Sánchez Siles wrote:
> This bug is closely related to http://bugs.debian.org/560154
> which is archived, but I'd say this it's the root 
> cause of that.

I tend to agree.

> When I try to manually start smcroute I get:
> $ smcroute -d
> ERRO: open(/proc/sys/net/ipv6/conf/all/mc_forwarding); Errno(13): Permission 
> denied
> 
> This error comes from mroute-api.c:277 in function enableMRouter6, excerpt:
> 275:
>   {
>     int    fd;
>     char * file = "/proc/sys/net/ipv6/conf/all/mc_forwarding";
>     
>     fd = open( file, O_WRONLY );
>     if ( fd < 0 )  
>       smclog( LOG_ERR, errno, "open(%s)", file);  
> 
>     (void) write( fd, "1", 1 );
>     (void) close( fd );
>   }
>   return 0;
> 287:

Probably more recent kernels don't need this code any more, because
initializing the multicast routing api by the call of
setsockopt(..., MRT6_INIT) in line 267 locks the API automatically
(leading "cat /proc/sys/net/ipv6/conf/all/mc_forwarding" to output "1").
But this is pure guessing.

Does it fix your problem if you skip the call to smclog() and execute
the write() and close() statements only when open() didn't change errno
to 13 (EACCES) as in the attached patch? If yes, this would also make
the code more tolerant regarding any changed kernel behaviour (which
probably is the reason for the problem), which may be caused in reaction
to https://kerneltrap.org/mailarchive/linux-netdev/2008/5/6/1740494
But again: This is pure guessing.

However, this needs some investigation about what happened to the IPv6
multicast code in the Linux kernel. Unfortunately I can't do it right
now, because I'm really busy with real life right now (and until end of
February 2010).

> This function has by the way, an unrelated minor bug, when fd is actually <0 
> it should return or skip execution of write and close with invalid fd.

No, for messages with severity LOG_ERR smclog() exits the program
entirely. See src/syslog.c, line 99:

  if( Serverity <= LOG_ERR )
    exit( -1 );

> $ ll /proc/sys/net/ipv6/conf/all/mc_forwarding
> -r--r--r-- 1 root root 0 ene 12 12:49 
> /proc/sys/net/ipv6/conf/all/mc_forwarding
> 
> $ cat /proc/sys/net/ipv6/conf/all/mc_forwarding
> 0
> 
> # echo "1" > /proc/sys/net/ipv6/conf/all/mc_forwarding
> bash: /proc/sys/net/ipv6/conf/all/mc_forwarding: Permission denied
> 
> # sysctl -w net.ipv6.conf.all.mc_forwarding=0
> error: permission denied on key 'net.ipv6.conf.all.mc_forwarding'
> 
> scmroute process is not running.

From how I understand the issue, writing to this specific proc file is
not allowed from processes that are not a multicast routing daemon (ie.
processes that did a MRT6_INIT via setsockopt() in advance as described
above). So, this is expected behaviour and is as it is by design and by
intention.

Regards
  Micha
Index: mroute-api.c
===================================================================
--- mroute-api.c	(Revision 66)
+++ mroute-api.c	(Arbeitskopie)
@@ -277,11 +277,13 @@
     char * file = "/proc/sys/net/ipv6/conf/all/mc_forwarding";
     
     fd = open( file, O_WRONLY );
-    if ( fd < 0 )  
-      smclog( LOG_ERR, errno, "open(%s)", file);  
+    if ( fd < 0 ) {
+      if ( errno != EACCES )
+        smclog( LOG_ERR, errno, "open(%s)", file);  
 
-    (void) write( fd, "1", 1 );
-    (void) close( fd );
+      (void) write( fd, "1", 1 );
+      (void) close( fd );
+    }
   }
   return 0;
 #endif /* HAVE_IPV6_MULTICAST_ROUTING */

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to