net_cls.go 820 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // +build linux
  2. package fs
  3. import (
  4. "github.com/opencontainers/runc/libcontainer/cgroups"
  5. "github.com/opencontainers/runc/libcontainer/configs"
  6. )
  7. type NetClsGroup struct {
  8. }
  9. func (s *NetClsGroup) Name() string {
  10. return "net_cls"
  11. }
  12. func (s *NetClsGroup) Apply(d *cgroupData) error {
  13. _, err := d.join("net_cls")
  14. if err != nil && !cgroups.IsNotFound(err) {
  15. return err
  16. }
  17. return nil
  18. }
  19. func (s *NetClsGroup) Set(path string, cgroup *configs.Cgroup) error {
  20. if cgroup.Resources.NetClsClassid != "" {
  21. if err := writeFile(path, "net_cls.classid", cgroup.Resources.NetClsClassid); err != nil {
  22. return err
  23. }
  24. }
  25. return nil
  26. }
  27. func (s *NetClsGroup) Remove(d *cgroupData) error {
  28. return removePath(d.path("net_cls"))
  29. }
  30. func (s *NetClsGroup) GetStats(path string, stats *cgroups.Stats) error {
  31. return nil
  32. }