#22247: Cannot run multiple instances of n2n edge as a service - not supported 
by
current implementation in OPENWRT.
--------------------------+--------------------------------
 Reporter:  spam064@…     |      Owner:  developers
     Type:  defect        |     Status:  new
 Priority:  normal        |  Milestone:
Component:  packages      |    Version:  Chaos Calmer 15.05
 Keywords:  n2n edge vpn  |
--------------------------+--------------------------------
 Hello,


 == Problems description ==


   there are 2 issues which unable to start multiple (more than one)
 instances of n2n edge for 2 separate private networks on one router.


 == 1. it is not possible to define tap name in openwrt n2n config file ==
  which then would have to be propoerly handled by /etc/init.d/n2n then.

 According to man page it should be possible to set up multiple tap devices
 http://linux.die.net/man/8/edge
    Options

    -d <name>
        sets the TAP device name as seen in ifconfig. Only available on
 Linux.

 '''With current implementation in OPENWRT setting the TAP device name is
 not supported in/via n2n config file.'''

 Although edge application released for OPENWRT CC does support this
 option.


 == 2. For some reason it is not possible to run multiple instances of
 "edge" as a service. ==


 Once support for problem (1) is implemented, I realised that for some
 reason is not possible to run multiple instances of edge as a service.
 To enable to run multiple instances of n2n edge to set up multiple tap
 devices edge has to be run not as a service but as an regular process.


 == Proposed tested and working solution on CC to address issue (1) and (2)
 ==


 1. introduce additional parameter "tapname" in n2n config file

 example:

 uci show n2n

 n2n.@edge[0]=edge
 n2n.@edge[0].netmask='255.255.255.0'
 n2n.@edge[0].supernode='yoursupernode.com'
 n2n.@edge[0].port='86'
 n2n.@edge[0].community='community1'
 n2n.@edge[0].key='yourkey1'
 n2n.@edge[0].route='1'
 n2n.@edge[0].httptunnel='1'
 n2n.@edge[0].ipaddr='192.168.12.1'
 '''n2n.@edge[0].tapname='edge0''''
 n2n.@edge[1]=edge
 n2n.@edge[1].netmask='255.255.255.0'
 n2n.@edge[1].supernode='yoursupernode.com'
 n2n.@edge[1].port='86'
 n2n.@edge[1].community='yourcommunity2'
 n2n.@edge[1].key='yourkey2'
 n2n.@edge[1].route='1'
 n2n.@edge[1].httptunnel='1'
 n2n.@edge[1].ipaddr='10.10.10.1'
 '''n2n.@edge[1].tapname='edge1''''
 n2n.@supernode[0]=supernode
 n2n.@supernode[0].port='86'


 2. change the /etc/init.d/n2n the way to
    a. support additional parameter "tapname" in n2n config file
    b. change execution of edge as a process not a service to enable
 multiple instances it on 1 host.

 Here is a source of start_instance() function of '''/etc/init.d/n2n'''
 with bolded proposed changes:



 #!/bin/sh /etc/rc.common


 START=90

 start_instance() {
         local cfg="$1"

         config_get type "$cfg" TYPE

         case "$type" in
         edge)
                 config_get ipaddr "$cfg" 'ipaddr'
                 [ -n "$ipaddr" ] || return 1
                 config_get netmask "$cfg" 'netmask' '255.255.255.0'
                 config_get supernode "$cfg" 'supernode'
                 config_get port "$cfg" 'port'
                 config_get community "$cfg" 'community'
                 config_get key "$cfg" 'key'
                 config_get_bool route "$cfg" 'route' '0'
                 >'''config_get tapname "$cfg" 'tapname' 'edge0''''
                 [ "$route" = "1" ] && args='-r'
                 >'''#service_start /usr/sbin/edge $args -d $tapname -a
 $ipaddr -s $netmask -c $community -k $key -l ${supernode}:${port}
                 >/usr/sbin/edge $args -d $tapname -a $ipaddr -s $netmask
 -c $community -k $key -l ${supernode}:${port} &'''
                 ;;
         supernode)
                 [ -e /usr/sbin/supernode ] || return 1
                 config_get port "$cfg" port
                 [ -n "$port" ] || return 1
                 service_start /usr/sbin/supernode -l $port
                 ;;
         esac
 }


 [CUT]


 '''Above change has been successfuly tested on CC release.'''

 Thanks.

--
Ticket URL: <https://dev.openwrt.org/ticket/22247>
OpenWrt <http://openwrt.org>
Opensource Wireless Router Technology
_______________________________________________
openwrt-tickets mailing list
openwrt-tickets@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-tickets

Reply via email to