utils

package

Documentation

Overview

* Tencent is pleased to support the open source community by making TKEStack available. * * Copyright (C) 2012-2019 Tencent. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use * this file except in compliance with the License. You may obtain a copy of the * License at * * https://opensource.org/licenses/Apache-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License.

* Tencent is pleased to support the open source community by making TKEStack available. * * Copyright (C) 2012-2019 Tencent. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use * this file except in compliance with the License. You may obtain a copy of the * License at * * https://opensource.org/licenses/Apache-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	UnderlayVethDeviceSuffix = "u"
	VlanDeviceSuffix         = "l"
)

Variables

View Source
var (
	ErrNoDefaultRoute = errors.New("no default route was found")
)

Functions

func AddHostRoute

func AddHostRoute(containerIP *net.IPNet, host netlink.Link, src net.IP) error

func AddToBridge

func AddToBridge(ifaceName, bridgeName string) error

func ChildLinkSize

func ChildLinkSize(masterIndex int) (int, error)

func ContainerVethName

func ContainerVethName(containerId string, suffix string) string

func CreateBridgeDevice

func CreateBridgeDevice(bridgeName string, hwAddr net.HardwareAddr) error

CreateBridgeDevice create a new bridge interface/

func CreateVeth

func CreateVeth(containerID string, mtu int, suffix string) (netlink.Link, netlink.Link, error)

func DeleteAllVeth

func DeleteAllVeth(netnsPath string) error

DeleteAllVeth deletes all veth device inside the container

func DeleteHostVeth

func DeleteHostVeth(containerId, suffix string) error

DeleteHostVeth deletes veth device in the host network namespace

func DeleteVeth

func DeleteVeth(netnsPath, ifName string) error

DeleteVeth deletes veth device inside the container

func DisableRpFilter

func DisableRpFilter(dev string) error

func EnableNonlocalBind

func EnableNonlocalBind() error

func GenerateIfaceName

func GenerateIfaceName(prefix string, len int) (string, error)

GenerateIfaceName returns an interface name using the passed in prefix and the length of random bytes. The api ensures that the there are is no interface which exists with that name.

func GenerateMACFromIP

func GenerateMACFromIP(ip net.IP) net.HardwareAddr

GenerateMACFromIP returns a locally administered MAC address where the 4 least significant bytes are derived from the IPv4 address.

func GenerateRandomMAC

func GenerateRandomMAC() net.HardwareAddr

GenerateRandomMAC returns a new 6-byte(48-bit) hardware address (MAC)

func GenerateRandomName

func GenerateRandomName(prefix string, size int) (string, error)

GenerateRandomName returns a new name joined with a prefix. This size specified is used to truncate the randomly generated value

func GetDefaultRoute

func GetDefaultRoute() (*netlink.Route, error)

GetDefaultRoute returns the default route.

func GetDefaultRouteGw

func GetDefaultRouteGw() (net.IP, error)

GetDefaultRouteGw returns the GW for the default route's interface.

func HostIPVlanName

func HostIPVlanName(containerId string) string

func HostMacVlanName

func HostMacVlanName(containerId string) string

func HostVethName

func HostVethName(containerId string, suffix string) string

func IPVlanConnectsHostWithContainer

func IPVlanConnectsHostWithContainer(result *t020.Result, args *skel.CmdArgs, parent int, mode netlink.IPVlanMode, mtu int) error

IPVlanConnectsHostWithContainer creates ipvlan device onto parent device and connects container with host

func MacVlanConnectsHostWithContainer

func MacVlanConnectsHostWithContainer(result *t020.Result, args *skel.CmdArgs, parent int, mtu int) error

MacVlanConnectsHostWithContainer creates macvlan device onto parent and connects container with host

func SendGratuitousARP

func SendGratuitousARP(dev, ip, nns string, useArpRequest bool) error

func SetProxyArp

func SetProxyArp(dev string) error

func UnSetArpIgnore

func UnSetArpIgnore(dev string) error

func VethConnectsHostWithContainer

func VethConnectsHostWithContainer(result *t020.Result, args *skel.CmdArgs, bridgeName string, suffix string, src net.IP) error

#lizard forgives VethConnectsHostWithContainer creates veth device pairs and connects container with host If bridgeName specified, it attaches host side veth device to the bridge

Types

This section is empty.

Directories

Path Synopsis
* Tencent is pleased to support the open source community by making TKEStack available.
* Tencent is pleased to support the open source community by making TKEStack available.
* Tencent is pleased to support the open source community by making TKEStack available.
* Tencent is pleased to support the open source community by making TKEStack available.
* Tencent is pleased to support the open source community by making TKEStack available.
* Tencent is pleased to support the open source community by making TKEStack available.
* Tencent is pleased to support the open source community by making TKEStack available.
* Tencent is pleased to support the open source community by making TKEStack available.
* Tencent is pleased to support the open source community by making TKEStack available.
* Tencent is pleased to support the open source community by making TKEStack available.
* Tencent is pleased to support the open source community by making TKEStack available.
* Tencent is pleased to support the open source community by making TKEStack available.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL