diff --git a/README.md b/README.md index a80b7092..aa2a5c8c 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Configure - NTP - Routing Policy Rule - Multiple default gateway with routing policy rules. - - Link's MAC, MTU. + - Link's MAC, MTU, ARP, Multicast, AllMulticast, Promiscuous, Unmanaged, Group, RequiredForOnline, RequiredFamilyForOnline, and ActivationPolicy. - Create netdevs, vlan, vxlan, bridge, bond, veth, macvlan/macvtap, ipvlap/ipvtap, veth, tunnels(ipip, sit, gre, sit, vti), wireguard. - Hostname. - DHCPv4 Server. diff --git a/src/manager/network-config-manager.c b/src/manager/network-config-manager.c index 0e28de3b..1e80cfde 100644 --- a/src/manager/network-config-manager.c +++ b/src/manager/network-config-manager.c @@ -579,7 +579,7 @@ _public_ int ncm_link_set_mode(int argc, char *argv[]) { } k = r; - r = manager_set_link_flag(p, k, "Unmanaged"); + r = manager_set_link_flag(p, !k, "Unmanaged"); if (r < 0) { printf("Failed to set link mode '%s': %s\n", p->ifname, g_strerror(-r)); return r; diff --git a/tests/network-config-manager-tests.py b/tests/network-config-manager-tests.py index a0e86fe6..df7cbeb7 100755 --- a/tests/network-config-manager-tests.py +++ b/tests/network-config-manager-tests.py @@ -332,6 +332,70 @@ def test_cli_set_mac(self): assert(parser.get('Match', 'Name') == 'test99') assert(parser.get('Link', 'MACAddress') == '00:0c:29:3a:bc:11') + + def test_cli_set_option(self): + assert(link_exist('test99') == True) + + subprocess.check_call(['nmctl', 'set-link-mode', 'test99', 'yes']) + assert(unit_exist('10-test99.network') == True) + + subprocess.check_call(['sleep', '5']) + subprocess.check_call(['nmctl', 'set-link-option', 'test99', 'arp', 'yes', 'mc', 'yes', 'amc', '0', 'pcs', 'false', 'rfo', 'no']) + + parser = configparser.ConfigParser() + parser.read(os.path.join(networkd_unit_file_path, '10-test99.network')) + + assert(parser.get('Match', 'Name') == 'test99') + assert(parser.get('Link', 'ARP') == 'true') + assert(parser.get('Link', 'Multicast') == 'true') + assert(parser.get('Link', 'AllMulticast') == 'false') + assert(parser.get('Link', 'Promiscuous') == 'false') + assert(parser.get('Link', 'RequiredForOnline') == 'false') + + def test_cli_set_group(self): + assert(link_exist('test99') == True) + + subprocess.check_call(['nmctl', 'set-link-mode', 'test99', 'yes']) + assert(unit_exist('10-test99.network') == True) + + subprocess.check_call(['sleep', '5']) + subprocess.check_call(['nmctl', 'set-link-group', 'test99', '2147483647']) + + parser = configparser.ConfigParser() + parser.read(os.path.join(networkd_unit_file_path, '10-test99.network')) + + assert(parser.get('Match', 'Name') == 'test99') + assert(parser.get('Link', 'Group') == '2147483647') + + def test_cli_set_rf_online(self): + assert(link_exist('test99') == True) + + subprocess.check_call(['nmctl', 'set-link-mode', 'test99', 'yes']) + assert(unit_exist('10-test99.network') == True) + + subprocess.check_call(['sleep', '5']) + subprocess.check_call(['nmctl', 'set-link-rf-online', 'test99', 'ipv4']) + + parser = configparser.ConfigParser() + parser.read(os.path.join(networkd_unit_file_path, '10-test99.network')) + + assert(parser.get('Match', 'Name') == 'test99') + assert(parser.get('Link', 'RequiredFamilyForOnline') == 'ipv4') + + def test_cli_set_act_policy(self): + assert(link_exist('test99') == True) + + subprocess.check_call(['nmctl', 'set-link-mode', 'test99', 'yes']) + assert(unit_exist('10-test99.network') == True) + + subprocess.check_call(['sleep', '5']) + subprocess.check_call(['nmctl', 'set-link-act-policy', 'test99', 'always-up']) + + parser = configparser.ConfigParser() + parser.read(os.path.join(networkd_unit_file_path, '10-test99.network')) + + assert(parser.get('Match', 'Name') == 'test99') + assert(parser.get('Link', 'ActivationPolicy') == 'always-up') def test_cli_set_dhcp_type(self): assert(link_exist('test99') == True)