func (w *PrefixWatcher) getAssignedPrefixes() ([]string, error) {
	var ps []string
	f := func(ipVersion int) error {
		blockList, err := w.Client.Backend.List(
			context.Background(),
			model.BlockAffinityListOptions{Host: config.NodeName, IPVersion: ipVersion},
			"",
		)
		if err != nil {
			return err
		}
		for _, block := range blockList.KVPairs {
			w.log.Debugf("Found assigned prefix: %+v", block)
			key := block.Key.(model.BlockAffinityKey)
			value := block.Value.(*model.BlockAffinity)
			if value.State == model.StateConfirmed && !value.Deleted {
				ps = append(ps, key.CIDR.String())
			}
		}
		return nil
	}
	if w.Ipv4 != nil {
		if err := f(4); err != nil {
			return nil, err
		}
	}
	if w.Ipv6 != nil {
		if err := f(6); err != nil {
			return nil, err
		}
	}
	return ps, nil
}
getAssignedPrefixes retrives prefixes assigned to the node and returns them as a
list of BGP path.
using backend directly since libcalico-go doesn't seem to have a method to return
assigned prefixes yet.
package watchers
import (
	"fmt"
	"strconv"
	"strings"
	"time"
	"github.com/golang/protobuf/ptypes"
	bgpapi "github.com/osrg/gobgp/api"
	"github.com/pkg/errors"
	"github.com/projectcalico/libcalico-go/lib/backend/model"
	"github.com/projectcalico/vpp-dataplane/calico-vpp-agent/config"
	"github.com/projectcalico/vpp-dataplane/calico-vpp-agent/routing/common"
	"github.com/sirupsen/logrus"
	"golang.org/x/net/context"
)
type PrefixWatcher struct {
	*common.RoutingData
	log *logrus.Entry
}
const (
	prefixWatchInterval = 5 * time.Second
)
func (w *PrefixWatcher) WatchPrefix() error {
	assignedPrefixes := make(map[string]bool)
	for {
		w.log.Debugf("Reconciliating prefix affinities...")
		newPrefixes, err := w.getAssignedPrefixes()
		if err != nil {
			return errors.Wrap(err, "error getting assigned prefixes")
		}
		w.log.Debugf("Found %d assigned prefixes", len(newPrefixes))
		newAssignedPrefixes := make(map[string]bool)
		var toAdd []*bgpapi.Path
		for _, prefix := range newPrefixes {
			if _, found := assignedPrefixes[prefix]; found {
				w.log.Debugf("Prefix %s is still assigned to us", prefix)
				assignedPrefixes[prefix] = true      
				newAssignedPrefixes[prefix] = false  
			} else {
				w.log.Debugf("New assigned prefix: %s", prefix)
				newAssignedPrefixes[prefix] = false
				path, err := common.MakePath(prefix, false  , w.Ipv4, w.Ipv6)
				if err != nil {
					return errors.Wrap(err, "error making new path for assigned prefix")
				}
				toAdd = append(toAdd, path)
			}
		}
		if err = w.updateBGPPaths(toAdd); err != nil {
			return errors.Wrap(err, "error adding prefix announcements")
		}
		var toRemove []*bgpapi.Path
		for p, stillThere := range assignedPrefixes {
			if !stillThere {
				w.log.Infof("Prefix %s is not assigned to us anymore", p)
				path, err := common.MakePath(p, true  , w.Ipv4, w.Ipv6)
				if err != nil {
					return errors.Wrap(err, "error making new path for removed prefix")
				}
				toRemove = append(toRemove, path)
			}
		}
		if err = w.updateBGPPaths(toRemove); err != nil {
			return errors.Wrap(err, "error removing prefix announcements")
		}
		assignedPrefixes = newAssignedPrefixes
		time.Sleep(prefixWatchInterval)
	}
	return nil
}