if ns.ExecuteCallCount() == 1 {
					Expect(netlinker.LinkByNameCallCount()).To(Equal(1))
				}
				return nil
			}

			inserter.HandleResolvedNeighbors(ready, ns, "some-vxlan-name", resolved)
			Eventually(ready).Should(BeClosed())

			Expect(ns.ExecuteCallCount()).To(Equal(2))
			Expect(netlinker.LinkByNameArgsForCall(0)).To(Equal("some-vxlan-name"))
		})

		Context("when the vxlan device cannot be found", func() {
			BeforeEach(func() {
				netlinker.LinkByNameReturns(nil, errors.New("boom-boom"))
			})

			It("returns a meaningful error", func() {
				inserter.HandleResolvedNeighbors(ready, ns, "some-vxlan-name", resolved)
				Eventually(ready).Should(Receive(MatchError(`namespace execute failed: find link "some-vxlan-name": boom-boom`)))
			})
		})

		It("sets a neighbor entry in the sandbox namespace", func() {
			ns.ExecuteStub = func(callback func(ns *os.File) error) error {
				Expect(netlinker.SetNeighCallCount()).To(Equal(0))
				callback(nil)
				if ns.ExecuteCallCount() == 2 {
					Expect(netlinker.SetNeighCallCount()).To(Equal(2))
				}
			Context("when adding the veth link fails", func() {
				BeforeEach(func() {
					netlinker.LinkAddReturns(errors.New("some error"))
				})

				It("returns the error", func() {
					err := factory.CreateVeth("host", "peer", 999)
					Expect(err).To(MatchError("link add: some error"))
				})
			})
		})

		Describe("FindLink", func() {
			Context("when a link is found", func() {
				BeforeEach(func() {
					netlinker.LinkByNameReturns(&netlink.Vxlan{VxlanId: 41}, nil)
				})

				It("should return the link", func() {
					link, err := factory.FindLink("some-device-name")
					Expect(err).NotTo(HaveOccurred())
					Expect(link).To(Equal(&netlink.Vxlan{VxlanId: 41}))
				})
			})

			Context("when the link does not exist", func() {
				BeforeEach(func() {
					netlinker.LinkByNameReturns(nil, errors.New("not found"))
				})

				It("should return nil", func() {
	})

	Describe("AddAddress", func() {
		var (
			link    netlink.Link
			address *net.IPNet
		)

		BeforeEach(func() {
			address = &net.IPNet{
				IP:   net.ParseIP("192.168.1.1"),
				Mask: net.CIDRMask(24, 32),
			}

			link = &netlink.Veth{}
			netlinker.LinkByNameReturns(link, nil)
		})

		It("finds the link by name", func() {
			err := addressManager.AddAddress("my-link", address)
			Expect(err).NotTo(HaveOccurred())

			Expect(netlinker.LinkByNameCallCount()).To(Equal(1))
			Expect(netlinker.LinkByNameArgsForCall(0)).To(Equal("my-link"))
		})

		Context("when finding the link fails", func() {
			BeforeEach(func() {
				netlinker.LinkByNameReturns(nil, errors.New("no link for you"))
			})