netlink.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. Copyright 2017 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package ipvs
  14. import (
  15. "k8s.io/apimachinery/pkg/util/sets"
  16. )
  17. // NetLinkHandle for revoke netlink interface
  18. type NetLinkHandle interface {
  19. // EnsureAddressBind checks if address is bound to the interface and, if not, binds it. If the address is already bound, return true.
  20. EnsureAddressBind(address, devName string) (exist bool, err error)
  21. // UnbindAddress unbind address from the interface
  22. UnbindAddress(address, devName string) error
  23. // EnsureDummyDevice checks if dummy device is exist and, if not, create one. If the dummy device is already exist, return true.
  24. EnsureDummyDevice(devName string) (exist bool, err error)
  25. // DeleteDummyDevice deletes the given dummy device by name.
  26. DeleteDummyDevice(devName string) error
  27. // ListBindAddress will list all IP addresses which are bound in a given interface
  28. ListBindAddress(devName string) ([]string, error)
  29. // GetLocalAddresses returns all unique local type IP addresses based on specified device and filter device
  30. // If device is not specified, it will list all unique local type addresses except filter device addresses
  31. GetLocalAddresses(dev, filterDev string) (sets.String, error)
  32. }