当前位置: 首页>>代码示例>>Golang>>正文


Golang netlink.RouteDel函数代码示例

本文整理汇总了Golang中github.com/vishvananda/netlink.RouteDel函数的典型用法代码示例。如果您正苦于以下问题:Golang RouteDel函数的具体用法?Golang RouteDel怎么用?Golang RouteDel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了RouteDel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: delRouteIface

// delRouteIface clean up the required L3 mode default ns route
func delRouteIface(ipVlanL3Network *net.IPNet, iface netlink.Link) error {
	return netlink.RouteDel(&netlink.Route{
		LinkIndex: iface.Attrs().Index,
		Scope:     netlink.SCOPE_LINK,
		Dst:       ipVlanL3Network,
	})
}
开发者ID:zenvdeluca,项目名称:ipvlan-docker-plugin,代码行数:8,代码来源:driver.go

示例2: delRemoteRoute

// delRemoteRoute deletes a host-scoped route to a device.
func delRemoteRoute(neighborNetwork *net.IPNet, nextHop net.IP, iface netlink.Link) error {
	return netlink.RouteDel(&netlink.Route{
		Scope:     netlink.SCOPE_UNIVERSE,
		LinkIndex: iface.Attrs().Index,
		Dst:       neighborNetwork,
		Gw:        nextHop,
	})
}
开发者ID:jc-m,项目名称:ipvlan-docker-plugin,代码行数:9,代码来源:del_routes.go

示例3: delRoute

// delRoute deletes any netlink route
func delRoute(route netlink.Route, iface netlink.Link) error {
	return netlink.RouteDel(&netlink.Route{
		Scope:     route.Scope,
		LinkIndex: iface.Attrs().Index,
		Dst:       route.Dst,
		Gw:        route.Gw,
	})
}
开发者ID:jc-m,项目名称:ipvlan-docker-plugin,代码行数:9,代码来源:del_routes.go

示例4: DelRoute

func (dev *vxlanDevice) DelRoute(subnet ip.IP4Net) error {
	route := &netlink.Route{
		Scope: netlink.SCOPE_UNIVERSE,
		Dst:   subnet.ToIPNet(),
		Gw:    subnet.IP.ToIP(),
	}
	log.Infof("calling RouteDel: %s", subnet)
	return netlink.RouteDel(route)
}
开发者ID:ably-forks,项目名称:flynn,代码行数:9,代码来源:device.go

示例5: delRemoteRoute

// delRemoteRoute deletes a host-scoped route to a device.
func delRemoteRoute(neighborNetwork *net.IPNet, nextHop net.IP, iface netlink.Link) error {
	log.Debugf("Deleting route: IP Prefix: [ %s ] - Next Hop: [ %s ] - Source Interface: [ %s ]", neighborNetwork, nextHop, iface.Attrs().Name)
	return netlink.RouteDel(&netlink.Route{
		Scope:     netlink.SCOPE_UNIVERSE,
		LinkIndex: iface.Attrs().Index,
		Dst:       neighborNetwork,
		Gw:        nextHop,
	})
}
开发者ID:nerdalert,项目名称:bgp-ipvlan-docker,代码行数:10,代码来源:del_routes.go

示例6: delRoute

// delRoute deletes any netlink route
func delRoute(route netlink.Route, iface netlink.Link) error {
	log.Debugf("Deleting route in the default namespace for IPVlan L3 mode with the following:")
	log.Debugf("IP Prefix: [ %s ] - Next Hop: [ %s ] - Source Interface: [ %s ]", route.Dst, route.Gw, iface.Attrs().Name)

	return netlink.RouteDel(&netlink.Route{
		Scope:     route.Scope,
		LinkIndex: iface.Attrs().Index,
		Dst:       route.Dst,
		Gw:        route.Gw,
	})
}
开发者ID:nerdalert,项目名称:bgp-ipvlan-docker,代码行数:12,代码来源:del_routes.go

示例7: deleteHostRoute

func (t *AWSVPCTracker) deleteHostRoute(cidr string) error {
	dst, err := parseCIDR(cidr)
	if err != nil {
		return err
	}
	route := &netlink.Route{
		LinkIndex: t.linkIndex,
		Dst:       dst,
		Scope:     netlink.SCOPE_LINK,
	}
	return netlink.RouteDel(route)
}
开发者ID:n054,项目名称:weave,代码行数:12,代码来源:awsvpc.go

示例8: delDefaultRoute

//delete default routes
//FIXME all default routes will be erased
func delDefaultRoute() error {
	routes, _ := netlink.RouteList(nil, netlink.FAMILY_V4)

	for _, route := range routes {
		if route.Dst != nil || route.Src != nil {
			continue
		}
		if err := netlink.RouteDel(&route); err != nil {
			return err
		}
	}
	return nil
}
开发者ID:CMGS,项目名称:eru-agent,代码行数:15,代码来源:route_linux.go

示例9: delNetlinkRoute

// AddHostRoute adds a route to a device using netlink into the Linux default namespace.
func delNetlinkRoute(neighborNetwork *net.IPNet, nextHop net.IP, netIface string) error {
	iface, err := netlink.LinkByName(netIface)
	if err != nil {
		return err
	}
	log.Infof("IP Prefix: [ %s ] - Next Hop: [ %s ] - Source Interface: [ %s ]", neighborNetwork, nextHop, iface.Attrs().Name)
	return netlink.RouteDel(&netlink.Route{
		Scope:     netlink.SCOPE_UNIVERSE,
		LinkIndex: iface.Attrs().Index,
		Dst:       neighborNetwork,
		Gw:        nextHop,
	})
}
开发者ID:nerdalert,项目名称:ipvlan-docker-plugin,代码行数:14,代码来源:routes.go

示例10: removeAllRoutesOnLink

func removeAllRoutesOnLink(link netlink.Link) error {
	routes, err := netlink.RouteList(link, netlink.FAMILY_V4)
	if err != nil {
		return errwrap.Wrap(fmt.Errorf("cannot list routes on link %q", link.Attrs().Name), err)
	}

	for _, route := range routes {
		if err := netlink.RouteDel(&route); err != nil {
			return errwrap.Wrap(fmt.Errorf("error in time of route removal for route %q", route), err)
		}
	}

	return nil
}
开发者ID:nhlfr,项目名称:rkt,代码行数:14,代码来源:kvm.go

示例11: removeRoute

// Delete a route from the namespace routing table.
func removeRoute(path string, dest *net.IPNet, nh net.IP) error {
	return nsInvoke(path, func(nsFD int) error { return nil }, func(callerFD int) error {
		gwRoutes, err := netlink.RouteGet(nh)
		if err != nil {
			return fmt.Errorf("route for the next hop could not be found: %v", err)
		}

		return netlink.RouteDel(&netlink.Route{
			Scope:     netlink.SCOPE_UNIVERSE,
			LinkIndex: gwRoutes[0].LinkIndex,
			Gw:        gwRoutes[0].Gw,
			Dst:       dest,
		})
	})
}
开发者ID:MathewAniyan,项目名称:docker,代码行数:16,代码来源:route_linux.go

示例12: delAllRoutesVia

func delAllRoutesVia(s net.Addr) error {
	src := s.(*net.TCPAddr).IP

	routes, err := netlink.RouteList(nil, netlink.FAMILY_ALL)
	if err != nil {
		log.Error("Failed to get routes")
		log.Error(err)
		return err
	}
	for _, r := range routes {
		if r.Gw.Equal(src) {
			netlink.RouteDel(&r)
		}
	}
	return nil
}
开发者ID:clinta,项目名称:routeShare,代码行数:16,代码来源:processRoute.go

示例13: handleSubnetEvents

func (rb *HostgwBackend) handleSubnetEvents(batch subnet.EventBatch) {
	for _, evt := range batch {
		switch evt.Type {
		case subnet.SubnetAdded:
			log.Infof("Subnet added: %v via %v", evt.Lease.Network, evt.Lease.Attrs.PublicIP)

			if evt.Lease.Attrs.BackendType != "host-gw" {
				log.Warningf("Ignoring non-host-gw subnet: type=%v", evt.Lease.Attrs.BackendType)
				continue
			}

			route := netlink.Route{
				Dst:       evt.Lease.Network.ToIPNet(),
				Gw:        evt.Lease.Attrs.PublicIP.ToIP(),
				LinkIndex: rb.extIface.Index,
			}
			if err := netlink.RouteAdd(&route); err != nil {
				log.Errorf("Error adding route to %v via %v: %v", evt.Lease.Network, evt.Lease.Attrs.PublicIP, err)
				continue
			}

		case subnet.SubnetRemoved:
			log.Info("Subnet removed: ", evt.Lease.Network)

			if evt.Lease.Attrs.BackendType != "host-gw" {
				log.Warningf("Ignoring non-host-gw subnet: type=%v", evt.Lease.Attrs.BackendType)
				continue
			}

			route := netlink.Route{
				Dst:       evt.Lease.Network.ToIPNet(),
				Gw:        evt.Lease.Attrs.PublicIP.ToIP(),
				LinkIndex: rb.extIface.Index,
			}
			if err := netlink.RouteDel(&route); err != nil {
				log.Errorf("Error deleting route to %v: %v", evt.Lease.Network, err)
				continue
			}

		default:
			log.Error("Internal error: unknown event type: ", int(evt.Type))
		}
	}
}
开发者ID:ably-forks,项目名称:flynn,代码行数:44,代码来源:hostgw.go

示例14: routingDown

func routingDown() {
	veth, err := netlink.LinkByName("myveth1")
	if err != nil {
		panic(err)
	}

	routes := createRoutes(veth)

	for _, route := range routes {
		fmt.Println("Removing route", route)
		err := netlink.RouteDel(route)
		if err != nil {
			// panic(err)
			fmt.Println(err)
		}
	}

	err = netlink.LinkSetDown(veth)
	if err != nil {
		panic(err)
	}
}
开发者ID:mycroft,项目名称:go-snippets,代码行数:22,代码来源:main.go

示例15: programGateway

func programGateway(path string, gw net.IP, isAdd bool) error {
	return nsInvoke(path, func(nsFD int) error { return nil }, func(callerFD int) error {
		gwRoutes, err := netlink.RouteGet(gw)
		if err != nil {
			return fmt.Errorf("route for the gateway could not be found: %v", err)
		}

		if isAdd {
			return netlink.RouteAdd(&netlink.Route{
				Scope:     netlink.SCOPE_UNIVERSE,
				LinkIndex: gwRoutes[0].LinkIndex,
				Gw:        gw,
			})
		}

		return netlink.RouteDel(&netlink.Route{
			Scope:     netlink.SCOPE_UNIVERSE,
			LinkIndex: gwRoutes[0].LinkIndex,
			Gw:        gw,
		})
	})
}
开发者ID:MathewAniyan,项目名称:docker,代码行数:22,代码来源:route_linux.go


注:本文中的github.com/vishvananda/netlink.RouteDel函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。