예제 #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_deleted(self, lvl, dst, gw):
        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)

        KRoute.delete(ipstr, lvl_to_bits(lvl), gateway=gwipstr)
예제 #5
0
    def testLevelToBits(self):
        ''' Test level to bits conversion '''

        levels = range(settings.LEVELS)
        bits = range(inet.ipbit[settings.IP_VERSION], 0,
                     -(settings.BITS_PER_LEVEL))

        for l in levels:
            self.assertEqual(inet.lvl_to_bits(l), bits[l])
예제 #6
0
    def route_deleted(self, lvl, dst, gw):
        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)

        KRoute.delete(ipstr, lvl_to_bits(lvl), gateway=gwipstr)
예제 #7
0
    def testLevelToBits(self):
        ''' Test level to bits conversion '''

        levels = range(settings.LEVELS)
        bits = range(inet.ipbit[settings.IP_VERSION],
                     0,
                     -(settings.BITS_PER_LEVEL))

        for l in levels:
            self.assertEqual(inet.lvl_to_bits(l), bits[l])
예제 #8
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
예제 #9
0
    def neigh_deleted(self, neigh):
        ipstr = ip_to_str(neigh.ip)

        KRoute.delete(ipstr, lvl_to_bits(0))
예제 #10
0
    def neigh_deleted(self, neigh):
        ipstr = ip_to_str(neigh.ip)

        KRoute.delete(ipstr, lvl_to_bits(0))