setInterfaceIP sets the IP address on the given interface. It automatically adds a /24 subnet mask.
(netNS *os.File, ifaceName, ip string)
| 721 | // setInterfaceIP sets the IP address on the given interface. It automatically |
| 722 | // adds a /24 subnet mask. |
| 723 | func setInterfaceIP(netNS *os.File, ifaceName, ip string) error { |
| 724 | _, err := commandInNetNS(netNS, "ip", []string{"addr", "add", ip + "/24", "dev", ifaceName}).Output() |
| 725 | if err != nil { |
| 726 | return xerrors.Errorf("set IP %q on interface %q in netns: %w", ip, ifaceName, wrapExitErr(err)) |
| 727 | } |
| 728 | |
| 729 | return nil |
| 730 | } |
| 731 | |
| 732 | // setInterfaceIP6 sets the IPv6 address on the given interface. It automatically |
| 733 | // adds a /64 subnet mask. |
no test coverage detected