{"modulePath":"github.com/EMnify/vpp-agent","version":"v2.3.0+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package linuxcalls\n\nPackage linuxcalls contains wrappers over Netlink \u0026 OS APIs related to Linux namespaces.\n\n## Types\n\n```go\ntype FileSystemAPI interface {\n\t// FileExists checks whether the file exists.\n\tFileExists(name string) (bool, error)\n\t// OpenFile opens a file.\n\tOpenFile(name string, flag int, perm os.FileMode) (*os.File, error)\n\t// MkDirAll creates a directory with all parent directories.\n\tMkDirAll(path string, perm os.FileMode) error\n\t// Remove removes named file or directory.\n\tRemove(name string) error\n\t// Mount makes resources available.\n\tMount(source string, target string, fsType string, flags uintptr, data string) error\n\t// Unmount resources.\n\tUnmount(target string, flags int) (err error)\n}\n```\nFileSystemAPI defines all methods used to access file system.\n\n```go\ntype NamedNetNsAPI interface {\n\t// CreateNamedNetNs creates a new named Linux network namespace.\n\t// It does exactly the same thing as the command \"ip netns add NAMESPACE\".\n\tCreateNamedNetNs(ctx NamespaceMgmtCtx, nsName string) (netns.NsHandle, error)\n\t// DeleteNamedNetNs deletes an existing named Linux network namespace.\n\t// It does exactly the same thing as the command \"ip netns del NAMESPACE\".\n\tDeleteNamedNetNs(nsName string) error\n\t// NamedNetNsExists checks whether named namespace exists.\n\tNamedNetNsExists(nsName string) (bool, error)\n}\n```\nNamedNetNsAPI defines methods related to management of named network namespaces.\n\n```go\nfunc NewNamedNetNsHandler(sysHandler SystemAPI, log logging.Logger) NamedNetNsAPI\n```\nNewNamedNetNsHandler creates new instance of namespace handler\n\n```go\ntype NamespaceMgmtCtx interface {\n\t// LockOSThread wires the calling goroutine to its current operating system thread.\n\t// The method should implement re-entrant lock always called from a single go routine.\n\tLockOSThread()\n\t// UnlockOSThread unwires the calling goroutine from its fixed operating system thread.\n\t// The method should implement re-entrant lock always called from a single go routine.\n\tUnlockOSThread()\n}\n```\nNamespaceMgmtCtx represents context of an ongoing management of Linux namespaces. The same context should not be used concurrently.\n\n```go\nfunc NewNamespaceMgmtCtx() NamespaceMgmtCtx\n```\nNewNamespaceMgmtCtx creates and returns a new context for management of Linux namespaces.\n\n```go\ntype NetworkNamespaceAPI interface {\n\t// NewNetworkNamespace creates a new namespace and returns a handle to manage it further.\n\tNewNetworkNamespace() (ns netns.NsHandle, err error)\n\t// DuplicateNamespaceHandle duplicates network namespace handle.\n\tDuplicateNamespaceHandle(ns netns.NsHandle) (netns.NsHandle, error)\n\t// GetCurrentNamespace gets a handle to the current threads network namespace.\n\tGetCurrentNamespace() (ns netns.NsHandle, err error)\n\t// GetNamespaceFromPath gets a handle to a network namespace identified\n\t// by the path.\n\tGetNamespaceFromPath(path string) (ns netns.NsHandle, err error)\n\t// GetNamespaceFromPid gets a handle to the network namespace of a given pid.\n\tGetNamespaceFromPid(pid int) (ns netns.NsHandle, err error)\n\t// GetNamespaceFromName gets a handle to a named network namespace such as one\n\t// created by `ip netns add`.\n\tGetNamespaceFromName(name string) (ns netns.NsHandle, err error)\n\t// SetNamespace sets the current namespace to the namespace represented by the handle.\n\tSetNamespace(ns netns.NsHandle) (err error)\n}\n```\nNetworkNamespaceAPI defines methods for low-level handling of network namespaces.\n\n```go\ntype SystemAPI interface {\n\tFileSystemAPI\n\tNetworkNamespaceAPI\n}\n```\nSystemAPI defines all methods required for managing network namespaces on the system level.\n\n```go\nfunc NewSystemHandler() SystemAPI\n```\nNewSystemHandler returns new handler.\n\n","path":"github.com/EMnify/vpp-agent/plugins/linux/nsplugin/linuxcalls","name":"linuxcalls","synopsis":"Package linuxcalls contains wrappers over Netlink \u0026 OS APIs related to Linux namespaces.","isRedistributable":true}
