1 /* 2 Copyright 2017 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package ipvs 18 19 import ( 20 "k8s.io/apimachinery/pkg/util/sets" 21 ) 22 23 // NetLinkHandle for revoke netlink interface 24 type NetLinkHandle interface { 25 // EnsureAddressBind checks if address is bound to the interface and, if not, binds it. If the address is already bound, return true. 26 EnsureAddressBind(address, devName string) (exist bool, err error) 27 // UnbindAddress unbind address from the interface 28 UnbindAddress(address, devName string) error 29 // EnsureDummyDevice checks if dummy device is exist and, if not, create one. If the dummy device is already exist, return true. 30 EnsureDummyDevice(devName string) (exist bool, err error) 31 // DeleteDummyDevice deletes the given dummy device by name. 32 DeleteDummyDevice(devName string) error 33 // ListBindAddress will list all IP addresses which are bound in a given interface 34 ListBindAddress(devName string) ([]string, error) 35 // GetAllLocalAddresses return all local addresses on the node. 36 // Only the addresses of the current family are returned. 37 // IPv6 link-local and loopback addresses are excluded. 38 GetAllLocalAddresses() (sets.Set[string], error) 39 // GetLocalAddresses return all local addresses for an interface. 40 // Only the addresses of the current family are returned. 41 // IPv6 link-local and loopback addresses are excluded. 42 GetLocalAddresses(dev string) (sets.Set[string], error) 43 // GetAllLocalAddressesExcept return all local addresses on the node, except from the passed dev. 44 // This is not the same as to take the diff between GetAllLocalAddresses and GetLocalAddresses 45 // since an address can be assigned to many interfaces. This problem raised 46 // https://github.com/kubernetes/kubernetes/issues/114815 47 GetAllLocalAddressesExcept(dev string) (sets.Set[string], error) 48 } 49