本文整理汇总了Golang中github.com/coreos/rkt/Godeps/_workspace/src/github.com/vishvananda/netlink.Link类的典型用法代码示例。如果您正苦于以下问题:Golang Link类的具体用法?Golang Link怎么用?Golang Link使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Link类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: AddHostRoute
// AddHostRoute adds a host-scoped route to a device.
func AddHostRoute(ipn *net.IPNet, gw net.IP, dev netlink.Link) error {
return netlink.RouteAdd(&netlink.Route{
LinkIndex: dev.Attrs().Index,
Scope: netlink.SCOPE_HOST,
Dst: ipn,
Gw: gw,
})
}
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:9,代码来源:route.go
示例2: addRoute
func addRoute(link netlink.Link, podIP net.IP) error {
route := netlink.Route{
LinkIndex: link.Attrs().Index,
Scope: netlink.SCOPE_LINK,
Dst: &net.IPNet{
IP: podIP,
Mask: net.IPv4Mask(0xff, 0xff, 0xff, 0xff),
},
}
return netlink.RouteAdd(&route)
}
开发者ID:matomesc,项目名称:rkt,代码行数:11,代码来源:kvm.go
示例3: newDHCPClient
func newDHCPClient(link netlink.Link) (*dhcp4client.Client, error) {
pktsock, err := dhcp4client.NewPacketSock(link.Attrs().Index)
if err != nil {
return nil, err
}
return dhcp4client.New(
dhcp4client.HardwareAddr(link.Attrs().HardwareAddr),
dhcp4client.Timeout(5*time.Second),
dhcp4client.Broadcast(false),
dhcp4client.Connection(pktsock),
)
}
开发者ID:samarvin,项目名称:rkt,代码行数:13,代码来源:lease.go
示例4: removeAllRoutesOnLink
func removeAllRoutesOnLink(link netlink.Link) error {
routes, err := netlink.RouteList(link, netlink.FAMILY_V4)
if err != nil {
return fmt.Errorf("cannot list routes on link %q: %v", link.Attrs().Name, err)
}
for _, route := range routes {
if err := netlink.RouteDel(&route); err != nil {
return fmt.Errorf("error in time of route removal for route %q: %v", route, err)
}
}
return nil
}
开发者ID:matomesc,项目名称:rkt,代码行数:14,代码来源:kvm.go
示例5: ensureHasAddr
func ensureHasAddr(link netlink.Link, ipn *net.IPNet) error {
addrs, err := netlink.AddrList(link, syscall.AF_INET)
if err != nil && err != syscall.ENOENT {
return fmt.Errorf("could not get list of IP addresses: %v", err)
}
// if there're no addresses on the interface, it's ok -- we'll add one
if len(addrs) > 0 {
ipnStr := ipn.String()
for _, a := range addrs {
// string comp is actually easiest for doing IPNet comps
if a.IPNet.String() == ipnStr {
return nil
}
}
return fmt.Errorf("%q already has an IP address different from %v", link.Attrs().Name, ipn.String())
}
addr := &netlink.Addr{IPNet: ipn, Label: link.Attrs().Name}
if err := netlink.AddrAdd(link, addr); err != nil {
return fmt.Errorf("could not add IP address to %q: %v", link.Attrs().Name, err)
}
return nil
}
开发者ID:matomesc,项目名称:rkt,代码行数:24,代码来源:kvm.go
注:本文中的github.com/coreos/rkt/Godeps/_workspace/src/github.com/vishvananda/netlink.Link类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论