示例#1
0
    def route_new(self, lvl, dst, gw, rem, event_wait=None):

        if not self.multipath and self.maproute.node_get(lvl, dst).nroutes_synced() >= 1:
                # We don't have multipath and we've already set one route.
                return

        nip = self.maproute.lvlid_to_nip(lvl, dst)
        ip  = self.maproute.nip_to_ip(nip)
        ipstr = ip_to_str(ip)
        neigh = self.neigh.id_to_neigh(gw)
        dev = neigh.bestdev[0]
        gwipstr = ip_to_str(neigh.ip)
        neigh_node = self.maproute.node_get(*self.maproute.routeneigh_get(neigh))

        if neigh_node.nroutes() > 1:
                # Let's wait to add the neighbour first
                while 1:
                        ev_neigh = event_wait[(self.neigh.events, 'NEIGH_NEW')]()
                        if neigh == ev_neigh[0]:
                                # found
                                break

        if neigh_node.routes_tobe_synced > 0:
                # The routes to neigh are still to be synced, let's wait
                while 1:
                        ev_neigh = event_wait[(self.events, 'KRNL_NEIGH_NEW')]()
                        if neigh == ev_neigh[0]:
                                # found
                                break

        # We can add the route in the kernel
        KRoute.add(ipstr, lvl_to_bits(lvl), dev, gwipstr)

        self.maproute.node_get(lvl, dst).routes_tobe_synced-=1
示例#2
0
    def neigh_new(self, neigh):
        ipstr = ip_to_str(neigh.ip)
        dev = neigh.bestdev[0]
        gwipstr = ipstr

        KRoute.add(ipstr, lvl_to_bits(0), dev, gwipstr)

        self.events.send('KRNL_NEIGH_NEW', (neigh, ))
示例#3
0
    def neigh_new(self, neigh):
        ipstr = ip_to_str(neigh.ip)
        dev = neigh.bestdev[0]
        gwipstr = ipstr

        KRoute.add(ipstr, lvl_to_bits(0), dev, gwipstr)

        self.events.send('KRNL_NEIGH_NEW', (neigh,))
示例#4
0
    def route_new(self, lvl, dst, gw, rem, event_wait=None):

        if not self.multipath and self.maproute.node_get(
                lvl, dst).nroutes_synced() >= 1:
            # We don't have multipath and we've already set one route.
            return

        nip = self.maproute.lvlid_to_nip(lvl, dst)
        ip = self.maproute.nip_to_ip(nip)
        ipstr = ip_to_str(ip)
        neigh = self.neigh.id_to_neigh(gw)
        dev = neigh.bestdev[0]
        gwipstr = ip_to_str(neigh.ip)
        neigh_node = self.maproute.node_get(
            *self.maproute.routeneigh_get(neigh))

        if neigh_node.nroutes() > 1:
            # Let's wait to add the neighbour first
            while 1:
                ev_neigh = event_wait[(self.neigh.events, 'NEIGH_NEW')]()
                if neigh == ev_neigh[0]:
                    # found
                    break

        if neigh_node.routes_tobe_synced > 0:
            # The routes to neigh are still to be synced, let's wait
            while 1:
                ev_neigh = event_wait[(self.events, 'KRNL_NEIGH_NEW')]()
                if neigh == ev_neigh[0]:
                    # found
                    break

        # We can add the route in the kernel
        KRoute.add(ipstr, lvl_to_bits(lvl), dev, gwipstr)

        self.maproute.node_get(lvl, dst).routes_tobe_synced -= 1
示例#5
0
 def testAddRoute(self):
     ''' Test add a new route '''
     Route.add(self.ip, self.cidr, dev='eth0')