From 88c227d90a6b7b388c5c85d72802a0ca8f05ed5c Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Thu, 13 Jan 2022 22:30:39 +0100 Subject: New upstream version 1.34.0 --- src/c-list/src/c-list.h | 98 +- src/contrib/nm-compat.h | 38 +- src/core/NetworkManagerUtils.c | 72 +- src/core/NetworkManagerUtils.h | 64 +- src/core/devices/adsl/nm-device-adsl.c | 2 +- src/core/devices/bluetooth/nm-bluez-manager.c | 163 +- src/core/devices/bluetooth/nm-bluez5-dun.c | 44 +- src/core/devices/bluetooth/nm-device-bt.c | 31 +- src/core/devices/bluetooth/tests/nm-bt-test.c | 2 - src/core/devices/nm-acd-manager.c | 8 +- src/core/devices/nm-device-6lowpan.c | 8 +- src/core/devices/nm-device-bond.c | 99 +- src/core/devices/nm-device-bridge.c | 22 +- src/core/devices/nm-device-dummy.c | 36 +- src/core/devices/nm-device-ethernet.c | 36 +- src/core/devices/nm-device-infiniband.c | 21 +- src/core/devices/nm-device-ip-tunnel.c | 13 +- src/core/devices/nm-device-logging.h | 12 +- src/core/devices/nm-device-macvlan.c | 13 +- src/core/devices/nm-device-ppp.c | 57 +- src/core/devices/nm-device-private.h | 2 +- src/core/devices/nm-device-tun.c | 7 +- src/core/devices/nm-device-utils.c | 27 +- src/core/devices/nm-device-utils.h | 16 +- src/core/devices/nm-device-vlan.c | 8 +- src/core/devices/nm-device-vrf.c | 8 +- src/core/devices/nm-device-vxlan.c | 12 +- src/core/devices/nm-device-wireguard.c | 11 +- src/core/devices/nm-device-wpan.c | 9 +- src/core/devices/nm-device.c | 776 ++-- src/core/devices/nm-device.h | 1 + src/core/devices/nm-lldp-listener.c | 42 +- src/core/devices/ovs/nm-ovsdb.c | 141 +- src/core/devices/team/nm-device-team.c | 22 +- src/core/devices/wifi/nm-device-iwd.c | 11 +- src/core/devices/wifi/nm-device-olpc-mesh.c | 7 +- src/core/devices/wifi/nm-device-wifi-p2p.c | 44 +- src/core/devices/wifi/nm-device-wifi.c | 23 +- src/core/devices/wifi/nm-wifi-ap.c | 2 +- src/core/devices/wifi/nm-wifi-common.c | 2 +- src/core/devices/wifi/nm-wifi-p2p-peer.c | 18 +- src/core/devices/wifi/nm-wifi-utils.c | 27 +- src/core/devices/wifi/tests/test-devices-wifi.c | 2 +- src/core/devices/wwan/nm-device-modem.c | 22 +- src/core/devices/wwan/nm-modem-broadband.c | 7 +- src/core/devices/wwan/nm-modem-manager.c | 6 +- src/core/devices/wwan/nm-modem.c | 49 +- src/core/devices/wwan/nm-modem.h | 2 +- src/core/dhcp/nm-dhcp-client.c | 112 +- src/core/dhcp/nm-dhcp-client.h | 34 +- src/core/dhcp/nm-dhcp-dhclient-utils.c | 10 +- src/core/dhcp/nm-dhcp-dhclient.c | 60 +- src/core/dhcp/nm-dhcp-dhcpcanon.c | 47 +- src/core/dhcp/nm-dhcp-dhcpcd.c | 47 +- src/core/dhcp/nm-dhcp-helper.c | 4 +- src/core/dhcp/nm-dhcp-listener.c | 3 +- src/core/dhcp/nm-dhcp-manager.c | 145 +- src/core/dhcp/nm-dhcp-nettools.c | 14 +- src/core/dhcp/nm-dhcp-systemd.c | 22 +- src/core/dhcp/nm-dhcp-utils.c | 20 +- src/core/dhcp/tests/test-dhcp-dhclient.c | 4 +- src/core/dns/nm-dns-manager.c | 32 +- src/core/dns/nm-dns-manager.h | 5 - src/core/dns/nm-dns-systemd-resolved.c | 103 +- src/core/main-utils.c | 1 - src/core/main.c | 4 +- src/core/meson.build | 2 + src/core/ndisc/nm-lndp-ndisc.c | 83 +- src/core/ndisc/nm-lndp-ndisc.h | 7 - src/core/ndisc/nm-ndisc.c | 238 +- src/core/ndisc/nm-ndisc.h | 15 +- src/core/ndisc/tests/test-ndisc-linux.c | 12 +- src/core/nm-active-connection.c | 14 +- src/core/nm-audit-manager.c | 2 +- src/core/nm-auth-utils.c | 8 +- src/core/nm-config-data.c | 35 +- src/core/nm-config-data.h | 20 +- src/core/nm-config.c | 19 +- src/core/nm-connectivity.c | 14 +- src/core/nm-core-utils.c | 193 +- src/core/nm-core-utils.h | 68 +- src/core/nm-dbus-manager.c | 2 +- src/core/nm-dbus-object.c | 2 +- src/core/nm-dbus-utils.c | 20 +- src/core/nm-dcb.c | 5 +- src/core/nm-dhcp-config.c | 2 +- src/core/nm-dispatcher.c | 22 +- src/core/nm-dispatcher.h | 7 +- src/core/nm-firewalld-manager.c | 2 +- src/core/nm-hostname-manager.c | 255 +- src/core/nm-hostname-manager.h | 4 - src/core/nm-iface-helper.c | 78 +- src/core/nm-ip4-config.c | 110 +- src/core/nm-ip4-config.h | 29 +- src/core/nm-ip6-config.c | 11 +- src/core/nm-ip6-config.h | 3 +- src/core/nm-l3-config-data.c | 701 ++-- src/core/nm-l3-config-data.h | 80 +- src/core/nm-l3-ipv4ll.c | 65 +- src/core/nm-l3-ipv6ll.c | 717 ++++ src/core/nm-l3-ipv6ll.h | 112 + src/core/nm-l3cfg.c | 1762 ++++++--- src/core/nm-l3cfg.h | 131 +- src/core/nm-manager.c | 100 +- src/core/nm-netns.c | 13 +- src/core/nm-policy.c | 48 +- src/core/nm-priv-helper-call.c | 101 + src/core/nm-priv-helper-call.h | 15 + src/core/nm-session-monitor.c | 10 +- src/core/nm-sleep-monitor.c | 40 +- src/core/nm-test-utils-core.h | 12 +- src/core/nm-types.h | 2 +- src/core/platform/tests/meson.build | 1 - src/core/platform/tests/test-common.c | 10 +- src/core/platform/tests/test-common.h | 6 +- src/core/platform/tests/test-link.c | 61 +- src/core/platform/tests/test-platform-general.c | 162 +- src/core/platform/tests/test-tc.c | 20 +- src/core/ppp/nm-ppp-manager.c | 4 +- src/core/settings/nm-settings-connection.c | 4 +- src/core/settings/nm-settings.c | 10 +- .../plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c | 2 +- .../plugins/ifcfg-rh/nms-ifcfg-rh-reader.c | 214 +- .../plugins/ifcfg-rh/nms-ifcfg-rh-storage.c | 2 +- .../settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c | 2 + .../settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h | 2 +- .../plugins/ifcfg-rh/nms-ifcfg-rh-writer.c | 111 +- ...System_test-wired-802-1X-subj-matches.cexpected | 2 + .../ifcfg-Test_Write_Bond_Main.cexpected | 3 + .../ifcfg-Test_Write_Permissions.cexpected | 3 + .../ifcfg-Test_Write_Wifi_LEAP.cexpected | 3 + .../ifcfg-Test_Write_Wifi_WEP_104_ASCII.cexpected | 3 + .../ifcfg-Test_Write_Wired_Static_Routes.cexpected | 2 + .../ifcfg-Test_Write_Wired_match.cexpected | 2 + .../ifcfg-Vlan_test-vlan-interface.cexpected | 2 + .../tests/network-scripts/ifcfg-dcb-test.cexpected | 1 - .../ifcfg-random_wifi_connection.cexpected | 2 + .../ifcfg-random_wifi_connection_2.cexpected | 2 + .../tests/network-scripts/ifcfg-test-bond-port | 9 + .../ifcfg-test-ip6-disabled.cexpected | 2 + .../ifcfg-test-sriov-write.cexpected | 3 + .../ifcfg-test-static-routes-legacy.cexpected | 2 + .../ifcfg-test-tc-write-empty.cexpected | 3 + .../network-scripts/ifcfg-test-tc-write.cexpected | 3 + .../ifcfg-test-vlan-vlanid-use.cexpected | 2 + .../plugins/ifcfg-rh/tests/test-ifcfg-rh.c | 3788 ++++++-------------- .../ifupdown/nms-ifupdown-interface-parser.c | 2 +- .../plugins/ifupdown/nms-ifupdown-parser.c | 8 +- .../plugins/ifupdown/nms-ifupdown-plugin.c | 6 +- .../settings/plugins/keyfile/nms-keyfile-plugin.c | 18 +- .../settings/plugins/keyfile/nms-keyfile-storage.c | 2 +- .../plugins/keyfile/tests/test-keyfile-settings.c | 8 +- src/core/supplicant/nm-supplicant-config.c | 2 +- src/core/supplicant/nm-supplicant-interface.c | 83 +- src/core/supplicant/nm-supplicant-interface.h | 4 + src/core/supplicant/nm-supplicant-manager.c | 3 +- .../supplicant/nm-supplicant-settings-verify.c | 2 +- src/core/supplicant/nm-supplicant-types.h | 4 +- src/core/tests/test-core.c | 168 +- src/core/tests/test-ip6-config.c | 12 +- src/core/tests/test-l3cfg.c | 317 +- src/core/tests/test-systemd.c | 8 +- src/core/tests/test-utils.c | 75 +- src/core/vpn/nm-vpn-connection.c | 1 + src/libnm-base/meson.build | 1 + src/libnm-base/nm-base.h | 7 + src/libnm-base/nm-priv-helper-utils.c | 56 + src/libnm-base/nm-priv-helper-utils.h | 23 + src/libnm-client-aux-extern/README.md | 11 +- src/libnm-client-impl/libnm.pc.in | 2 + src/libnm-client-impl/libnm.ver | 18 + src/libnm-client-impl/nm-client.c | 25 +- src/libnm-client-impl/nm-dbus-helpers.h | 2 +- src/libnm-client-impl/nm-device-bond.c | 34 +- src/libnm-client-impl/nm-device-bridge.c | 22 +- src/libnm-client-impl/nm-device-ovs-bridge.c | 44 +- src/libnm-client-impl/nm-device-ovs-port.c | 44 +- src/libnm-client-impl/nm-device-team.c | 24 +- src/libnm-client-impl/nm-device-wifi.c | 2 +- src/libnm-client-impl/nm-device.c | 120 +- src/libnm-client-impl/nm-dhcp4-config.h | 2 +- src/libnm-client-impl/nm-dhcp6-config.h | 2 +- src/libnm-client-impl/nm-dns-manager.h | 2 +- src/libnm-client-impl/nm-ip-config.c | 2 +- src/libnm-client-impl/nm-ip4-config.h | 2 +- src/libnm-client-impl/nm-ip6-config.h | 2 +- src/libnm-client-impl/nm-libnm-utils.c | 2 +- src/libnm-client-impl/nm-libnm-utils.h | 125 +- src/libnm-client-impl/nm-object-private.h | 2 +- src/libnm-client-impl/nm-object.c | 29 +- src/libnm-client-impl/nm-property-infos-dbus.xml | 2 + .../nm-property-infos-ifcfg-rh.xml | 4 + .../nm-property-infos-keyfile.xml | 2 + src/libnm-client-impl/nm-property-infos-nmcli.xml | 439 +++ .../nm-remote-connection-private.h | 2 +- src/libnm-client-impl/nm-settings-docs-gir.xml | 12 +- src/libnm-client-impl/tests/test-libnm.c | 13 +- src/libnm-client-impl/tests/test-nm-client.c | 20 +- src/libnm-client-public/NetworkManager.h | 11 +- src/libnm-client-public/nm-access-point.h | 2 +- src/libnm-client-public/nm-active-connection.h | 2 +- src/libnm-client-public/nm-autoptr.h | 1 + src/libnm-client-public/nm-checkpoint.h | 2 +- src/libnm-client-public/nm-client.h | 2 +- src/libnm-client-public/nm-device-6lowpan.h | 2 +- src/libnm-client-public/nm-device-adsl.h | 2 +- src/libnm-client-public/nm-device-bond.h | 6 +- src/libnm-client-public/nm-device-bridge.h | 6 +- src/libnm-client-public/nm-device-bt.h | 2 +- src/libnm-client-public/nm-device-dummy.h | 2 +- src/libnm-client-public/nm-device-ethernet.h | 2 +- src/libnm-client-public/nm-device-generic.h | 2 +- src/libnm-client-public/nm-device-infiniband.h | 2 +- src/libnm-client-public/nm-device-ip-tunnel.h | 2 +- src/libnm-client-public/nm-device-macsec.h | 2 +- src/libnm-client-public/nm-device-macvlan.h | 2 +- src/libnm-client-public/nm-device-modem.h | 2 +- src/libnm-client-public/nm-device-olpc-mesh.h | 2 +- src/libnm-client-public/nm-device-ovs-bridge.h | 2 +- src/libnm-client-public/nm-device-ovs-interface.h | 2 +- src/libnm-client-public/nm-device-ovs-port.h | 2 +- src/libnm-client-public/nm-device-ppp.h | 2 +- src/libnm-client-public/nm-device-team.h | 2 +- src/libnm-client-public/nm-device-tun.h | 2 +- src/libnm-client-public/nm-device-veth.h | 2 +- src/libnm-client-public/nm-device-vlan.h | 2 +- src/libnm-client-public/nm-device-vrf.h | 2 +- src/libnm-client-public/nm-device-vxlan.h | 2 +- src/libnm-client-public/nm-device-wifi-p2p.h | 2 +- src/libnm-client-public/nm-device-wifi.h | 2 +- src/libnm-client-public/nm-device-wimax.h | 2 +- src/libnm-client-public/nm-device-wireguard.h | 2 +- src/libnm-client-public/nm-device-wpan.h | 2 +- src/libnm-client-public/nm-device.h | 6 +- src/libnm-client-public/nm-dhcp-config.h | 2 +- src/libnm-client-public/nm-ip-config.h | 2 +- src/libnm-client-public/nm-object.h | 5 +- src/libnm-client-public/nm-remote-connection.h | 2 +- src/libnm-client-public/nm-vpn-connection.h | 2 +- src/libnm-client-public/nm-vpn-editor.h | 2 +- src/libnm-client-public/nm-vpn-service-plugin.h | 2 +- src/libnm-client-public/nm-wifi-p2p-peer.h | 2 +- src/libnm-client-public/nm-wimax-nsp.h | 2 +- src/libnm-client-test/nm-test-libnm-utils.h | 20 +- src/libnm-core-aux-extern/nm-libnm-core-aux.c | 41 + src/libnm-core-aux-extern/nm-libnm-core-aux.h | 4 + src/libnm-core-aux-intern/nm-libnm-core-utils.c | 22 +- src/libnm-core-aux-intern/nm-libnm-core-utils.h | 5 + src/libnm-core-impl/meson.build | 1 + src/libnm-core-impl/nm-connection-private.h | 2 +- src/libnm-core-impl/nm-connection.c | 78 +- src/libnm-core-impl/nm-crypto.c | 2 +- src/libnm-core-impl/nm-dbus-utils.c | 2 +- src/libnm-core-impl/nm-keyfile.c | 16 +- src/libnm-core-impl/nm-meta-setting-base-impl.c | 13 +- src/libnm-core-impl/nm-property-compare.h | 2 +- src/libnm-core-impl/nm-setting-6lowpan.c | 73 +- src/libnm-core-impl/nm-setting-8021x.c | 1077 ++---- src/libnm-core-impl/nm-setting-adsl.c | 217 +- src/libnm-core-impl/nm-setting-bluetooth.c | 97 +- src/libnm-core-impl/nm-setting-bond-port.c | 173 + src/libnm-core-impl/nm-setting-bond.c | 40 +- src/libnm-core-impl/nm-setting-bridge-port.c | 137 +- src/libnm-core-impl/nm-setting-bridge.c | 713 ++-- src/libnm-core-impl/nm-setting-cdma.c | 185 +- src/libnm-core-impl/nm-setting-connection.c | 722 ++-- src/libnm-core-impl/nm-setting-dcb.c | 297 +- src/libnm-core-impl/nm-setting-dummy.c | 2 +- src/libnm-core-impl/nm-setting-ethtool.c | 5 +- src/libnm-core-impl/nm-setting-generic.c | 2 +- src/libnm-core-impl/nm-setting-gsm.c | 43 +- src/libnm-core-impl/nm-setting-hostname.c | 136 +- src/libnm-core-impl/nm-setting-infiniband.c | 28 +- src/libnm-core-impl/nm-setting-ip-config.c | 361 +- src/libnm-core-impl/nm-setting-ip-tunnel.c | 113 +- src/libnm-core-impl/nm-setting-ip4-config.c | 193 +- src/libnm-core-impl/nm-setting-ip6-config.c | 172 +- src/libnm-core-impl/nm-setting-macsec.c | 45 +- src/libnm-core-impl/nm-setting-macvlan.c | 49 +- src/libnm-core-impl/nm-setting-match.c | 2 +- src/libnm-core-impl/nm-setting-olpc-mesh.c | 121 +- src/libnm-core-impl/nm-setting-ovs-bridge.c | 60 +- src/libnm-core-impl/nm-setting-ovs-dpdk.c | 2 +- src/libnm-core-impl/nm-setting-ovs-external-ids.c | 54 +- src/libnm-core-impl/nm-setting-ovs-interface.c | 2 +- src/libnm-core-impl/nm-setting-ovs-patch.c | 2 +- src/libnm-core-impl/nm-setting-ovs-port.c | 198 +- src/libnm-core-impl/nm-setting-ppp.c | 465 +-- src/libnm-core-impl/nm-setting-pppoe.c | 188 +- src/libnm-core-impl/nm-setting-private.h | 713 +++- src/libnm-core-impl/nm-setting-proxy.c | 147 +- src/libnm-core-impl/nm-setting-serial.c | 136 +- src/libnm-core-impl/nm-setting-sriov.c | 65 +- src/libnm-core-impl/nm-setting-tc-config.c | 481 ++- src/libnm-core-impl/nm-setting-team-port.c | 95 +- src/libnm-core-impl/nm-setting-team.c | 97 +- src/libnm-core-impl/nm-setting-tun.c | 198 +- src/libnm-core-impl/nm-setting-user.c | 74 +- src/libnm-core-impl/nm-setting-veth.c | 2 +- src/libnm-core-impl/nm-setting-vlan.c | 58 +- src/libnm-core-impl/nm-setting-vpn.c | 90 +- src/libnm-core-impl/nm-setting-vrf.c | 61 +- src/libnm-core-impl/nm-setting-vxlan.c | 96 +- src/libnm-core-impl/nm-setting-wifi-p2p.c | 128 +- src/libnm-core-impl/nm-setting-wimax.c | 27 +- src/libnm-core-impl/nm-setting-wired.c | 164 +- src/libnm-core-impl/nm-setting-wireguard.c | 91 +- src/libnm-core-impl/nm-setting-wireless-security.c | 43 +- src/libnm-core-impl/nm-setting-wireless.c | 198 +- src/libnm-core-impl/nm-setting-wpan.c | 191 +- src/libnm-core-impl/nm-setting.c | 2003 ++++++++--- src/libnm-core-impl/nm-simple-connection.c | 2 +- src/libnm-core-impl/nm-team-utils.c | 77 +- src/libnm-core-impl/nm-team-utils.h | 3 +- src/libnm-core-impl/nm-utils-private.h | 24 +- src/libnm-core-impl/nm-utils.c | 275 +- src/libnm-core-impl/nm-vpn-plugin-info.c | 8 +- src/libnm-core-impl/tests/test-crypto.c | 2 +- src/libnm-core-impl/tests/test-general.c | 618 ++-- src/libnm-core-impl/tests/test-keyfile.c | 4 +- src/libnm-core-impl/tests/test-setting.c | 504 ++- src/libnm-core-intern/nm-core-internal.h | 187 +- src/libnm-core-intern/nm-keyfile-internal.h | 2 +- src/libnm-core-intern/nm-keyfile-utils.h | 2 +- src/libnm-core-intern/nm-meta-setting-base-impl.h | 5 +- src/libnm-core-public/meson.build | 1 + src/libnm-core-public/nm-connection.h | 17 +- src/libnm-core-public/nm-core-types.h | 1 + src/libnm-core-public/nm-dbus-interface.h | 8 +- src/libnm-core-public/nm-keyfile.h | 2 +- src/libnm-core-public/nm-setting-6lowpan.h | 2 +- src/libnm-core-public/nm-setting-8021x.h | 2 +- src/libnm-core-public/nm-setting-adsl.h | 2 +- src/libnm-core-public/nm-setting-bluetooth.h | 2 +- src/libnm-core-public/nm-setting-bond-port.h | 46 + src/libnm-core-public/nm-setting-bond.h | 2 +- src/libnm-core-public/nm-setting-bridge-port.h | 2 +- src/libnm-core-public/nm-setting-bridge.h | 2 +- src/libnm-core-public/nm-setting-cdma.h | 2 +- src/libnm-core-public/nm-setting-connection.h | 23 +- src/libnm-core-public/nm-setting-dcb.h | 2 +- src/libnm-core-public/nm-setting-dummy.h | 2 +- src/libnm-core-public/nm-setting-ethtool.h | 2 +- src/libnm-core-public/nm-setting-generic.h | 2 +- src/libnm-core-public/nm-setting-gsm.h | 2 +- src/libnm-core-public/nm-setting-hostname.h | 2 +- src/libnm-core-public/nm-setting-infiniband.h | 2 +- src/libnm-core-public/nm-setting-ip-config.h | 8 +- src/libnm-core-public/nm-setting-ip-tunnel.h | 2 +- src/libnm-core-public/nm-setting-ip4-config.h | 2 +- src/libnm-core-public/nm-setting-ip6-config.h | 2 +- src/libnm-core-public/nm-setting-macsec.h | 2 +- src/libnm-core-public/nm-setting-macvlan.h | 2 +- src/libnm-core-public/nm-setting-match.h | 2 +- src/libnm-core-public/nm-setting-olpc-mesh.h | 2 +- src/libnm-core-public/nm-setting-ovs-bridge.h | 2 +- src/libnm-core-public/nm-setting-ovs-dpdk.h | 2 +- .../nm-setting-ovs-external-ids.h | 2 +- src/libnm-core-public/nm-setting-ovs-interface.h | 2 +- src/libnm-core-public/nm-setting-ovs-patch.h | 2 +- src/libnm-core-public/nm-setting-ovs-port.h | 2 +- src/libnm-core-public/nm-setting-ppp.h | 2 +- src/libnm-core-public/nm-setting-pppoe.h | 2 +- src/libnm-core-public/nm-setting-proxy.h | 2 +- src/libnm-core-public/nm-setting-serial.h | 2 +- src/libnm-core-public/nm-setting-sriov.h | 2 +- src/libnm-core-public/nm-setting-tc-config.h | 2 +- src/libnm-core-public/nm-setting-team-port.h | 2 +- src/libnm-core-public/nm-setting-team.h | 2 +- src/libnm-core-public/nm-setting-tun.h | 2 +- src/libnm-core-public/nm-setting-user.h | 2 +- src/libnm-core-public/nm-setting-veth.h | 2 +- src/libnm-core-public/nm-setting-vlan.h | 2 +- src/libnm-core-public/nm-setting-vpn.h | 2 +- src/libnm-core-public/nm-setting-vrf.h | 2 +- src/libnm-core-public/nm-setting-vxlan.h | 2 +- src/libnm-core-public/nm-setting-wifi-p2p.h | 2 +- src/libnm-core-public/nm-setting-wimax.h | 2 +- src/libnm-core-public/nm-setting-wired.h | 2 +- src/libnm-core-public/nm-setting-wireguard.h | 2 +- .../nm-setting-wireless-security.h | 2 +- src/libnm-core-public/nm-setting-wireless.h | 2 +- src/libnm-core-public/nm-setting-wpan.h | 2 +- src/libnm-core-public/nm-setting.h | 2 +- src/libnm-core-public/nm-simple-connection.h | 2 +- src/libnm-core-public/nm-utils.h | 2 +- src/libnm-core-public/nm-version-macros.h | 6 +- src/libnm-core-public/nm-version-macros.h.in | 2 +- src/libnm-core-public/nm-version.h | 244 +- src/libnm-core-public/nm-vpn-dbus-interface.h | 4 +- src/libnm-core-public/nm-vpn-editor-plugin.h | 2 +- src/libnm-glib-aux/nm-dbus-aux.c | 87 + src/libnm-glib-aux/nm-dbus-aux.h | 49 + src/libnm-glib-aux/nm-default-glib.h | 24 +- src/libnm-glib-aux/nm-gassert-patch.h | 68 +- src/libnm-glib-aux/nm-glib.h | 352 +- src/libnm-glib-aux/nm-hash-utils.c | 6 +- src/libnm-glib-aux/nm-hash-utils.h | 158 +- src/libnm-glib-aux/nm-io-utils.c | 99 +- src/libnm-glib-aux/nm-io-utils.h | 17 + src/libnm-glib-aux/nm-jansson.h | 24 +- src/libnm-glib-aux/nm-json-aux.c | 4 +- src/libnm-glib-aux/nm-json-aux.h | 61 + src/libnm-glib-aux/nm-logging-base.c | 60 + src/libnm-glib-aux/nm-logging-base.h | 16 + src/libnm-glib-aux/nm-logging-fwd.h | 126 +- src/libnm-glib-aux/nm-macros-internal.h | 602 +--- src/libnm-glib-aux/nm-random-utils.c | 14 +- src/libnm-glib-aux/nm-ref-string.h | 12 + src/libnm-glib-aux/nm-shared-utils.c | 359 +- src/libnm-glib-aux/nm-shared-utils.h | 532 ++- src/libnm-glib-aux/nm-test-utils.h | 584 +-- src/libnm-glib-aux/nm-uuid.c | 69 +- src/libnm-glib-aux/nm-uuid.h | 51 +- src/libnm-glib-aux/nm-value-type.h | 134 +- src/libnm-glib-aux/tests/test-shared-general.c | 47 +- src/libnm-log-core/nm-logging.c | 82 +- src/libnm-log-core/nm-logging.h | 2 +- src/libnm-platform/nm-linux-platform.c | 282 +- src/libnm-platform/nm-linux-platform.h | 2 +- src/libnm-platform/nm-netlink.c | 65 +- src/libnm-platform/nm-netlink.h | 52 +- src/libnm-platform/nm-platform-utils.c | 18 +- src/libnm-platform/nm-platform.c | 747 ++-- src/libnm-platform/nm-platform.h | 99 +- src/libnm-platform/nmp-netns.c | 20 +- src/libnm-platform/nmp-object.c | 93 +- src/libnm-platform/nmp-object.h | 99 +- src/libnm-platform/wifi/nm-wifi-utils-wext.c | 2 +- src/libnm-platform/wifi/nm-wifi-utils.c | 2 +- src/libnm-std-aux/nm-default-std.h | 18 +- src/libnm-std-aux/nm-linux-compat.h | 2 +- src/libnm-std-aux/nm-std-aux.h | 746 ++-- src/libnm-systemd-core/meson.build | 2 +- src/libnm-systemd-core/nm-sd.h | 3 +- .../sd-adapt-core/nm-sd-adapt-core.h | 92 +- .../src/libsystemd-network/arp-util.c | 92 +- .../src/libsystemd-network/arp-util.h | 28 +- .../src/libsystemd-network/dhcp-identifier.c | 51 +- .../src/libsystemd-network/dhcp-identifier.h | 2 +- .../src/libsystemd-network/dhcp-internal.h | 10 +- .../src/libsystemd-network/dhcp6-internal.h | 42 +- .../src/libsystemd-network/dhcp6-lease-internal.h | 14 +- .../src/libsystemd-network/dhcp6-option.c | 561 +-- .../src/libsystemd-network/lldp-internal.h | 48 - .../src/libsystemd-network/lldp-neighbor.c | 119 +- .../src/libsystemd-network/lldp-neighbor.h | 8 +- .../src/libsystemd-network/lldp-network.c | 3 + .../src/libsystemd-network/lldp-rx-internal.h | 48 + .../src/libsystemd-network/network-common.c | 15 +- .../src/libsystemd-network/network-common.h | 26 +- .../src/libsystemd-network/sd-dhcp-client.c | 206 +- .../src/libsystemd-network/sd-dhcp6-client.c | 235 +- .../src/libsystemd-network/sd-dhcp6-lease.c | 181 +- .../src/libsystemd-network/sd-ipv4acd.c | 189 +- .../src/libsystemd-network/sd-ipv4ll.c | 49 +- .../src/libsystemd-network/sd-lldp-rx.c | 525 +++ .../src/libsystemd-network/sd-lldp.c | 524 --- .../src/libsystemd/sd-event/event-source.h | 2 +- .../src/libsystemd/sd-event/sd-event.c | 156 +- .../src/libsystemd/sd-id128/id128-util.c | 7 +- .../src/libsystemd/sd-id128/id128-util.h | 2 + .../src/libsystemd/sd-id128/sd-id128.c | 29 +- .../src/systemd/sd-dhcp-client.h | 2 +- .../src/systemd/sd-dhcp6-client.h | 2 +- .../src/systemd/sd-dhcp6-lease.h | 10 +- src/libnm-systemd-core/src/systemd/sd-id128.h | 11 +- src/libnm-systemd-core/src/systemd/sd-ipv4acd.h | 4 +- src/libnm-systemd-core/src/systemd/sd-ipv4ll.h | 4 +- src/libnm-systemd-core/src/systemd/sd-lldp-rx.h | 109 + src/libnm-systemd-core/src/systemd/sd-lldp.h | 105 +- src/libnm-systemd-core/src/systemd/sd-ndisc.h | 2 +- src/libnm-systemd-shared/meson.build | 1 + .../sd-adapt-shared/chase-symlinks.h | 3 + .../sd-adapt-shared/missing_ioprio.h | 3 + .../sd-adapt-shared/nm-sd-adapt-shared.h | 116 +- .../sd-adapt-shared/sync-util.h | 3 + src/libnm-systemd-shared/src/basic/alloc-util.h | 24 +- src/libnm-systemd-shared/src/basic/cgroup-util.h | 6 +- src/libnm-systemd-shared/src/basic/env-util.c | 84 +- src/libnm-systemd-shared/src/basic/env-util.h | 6 +- src/libnm-systemd-shared/src/basic/escape.c | 53 +- src/libnm-systemd-shared/src/basic/escape.h | 10 +- .../src/basic/ether-addr-util.c | 27 +- .../src/basic/ether-addr-util.h | 36 +- src/libnm-systemd-shared/src/basic/extract-word.c | 56 +- src/libnm-systemd-shared/src/basic/extract-word.h | 8 +- src/libnm-systemd-shared/src/basic/fd-util.c | 509 +-- src/libnm-systemd-shared/src/basic/fd-util.h | 27 +- src/libnm-systemd-shared/src/basic/fileio.c | 211 +- src/libnm-systemd-shared/src/basic/fileio.h | 41 +- src/libnm-systemd-shared/src/basic/format-util.c | 62 +- src/libnm-systemd-shared/src/basic/format-util.h | 36 +- src/libnm-systemd-shared/src/basic/fs-util.c | 805 +---- src/libnm-systemd-shared/src/basic/fs-util.h | 45 - src/libnm-systemd-shared/src/basic/hashmap.c | 11 +- src/libnm-systemd-shared/src/basic/hashmap.h | 2 +- src/libnm-systemd-shared/src/basic/hexdecoct.c | 58 +- src/libnm-systemd-shared/src/basic/hexdecoct.h | 7 +- src/libnm-systemd-shared/src/basic/hostname-util.c | 71 +- src/libnm-systemd-shared/src/basic/hostname-util.h | 38 +- src/libnm-systemd-shared/src/basic/in-addr-util.c | 37 +- src/libnm-systemd-shared/src/basic/in-addr-util.h | 9 +- src/libnm-systemd-shared/src/basic/inotify-util.c | 31 + src/libnm-systemd-shared/src/basic/inotify-util.h | 22 + src/libnm-systemd-shared/src/basic/list.h | 7 +- src/libnm-systemd-shared/src/basic/log.h | 39 +- src/libnm-systemd-shared/src/basic/macro.h | 59 +- src/libnm-systemd-shared/src/basic/memory-util.c | 13 +- src/libnm-systemd-shared/src/basic/memory-util.h | 14 +- .../src/basic/missing_syscall.h | 20 + src/libnm-systemd-shared/src/basic/parse-util.c | 11 +- src/libnm-systemd-shared/src/basic/parse-util.h | 11 +- src/libnm-systemd-shared/src/basic/path-util.c | 110 +- src/libnm-systemd-shared/src/basic/path-util.h | 10 +- src/libnm-systemd-shared/src/basic/prioq.c | 10 + src/libnm-systemd-shared/src/basic/prioq.h | 1 + src/libnm-systemd-shared/src/basic/process-util.c | 155 +- src/libnm-systemd-shared/src/basic/process-util.h | 11 +- src/libnm-systemd-shared/src/basic/random-util.c | 2 +- src/libnm-systemd-shared/src/basic/set.h | 2 +- src/libnm-systemd-shared/src/basic/signal-util.c | 37 +- src/libnm-systemd-shared/src/basic/signal-util.h | 3 + src/libnm-systemd-shared/src/basic/socket-util.c | 58 +- src/libnm-systemd-shared/src/basic/socket-util.h | 34 +- src/libnm-systemd-shared/src/basic/stat-util.c | 5 +- src/libnm-systemd-shared/src/basic/stdio-util.h | 11 +- src/libnm-systemd-shared/src/basic/string-util.c | 16 + src/libnm-systemd-shared/src/basic/string-util.h | 18 +- src/libnm-systemd-shared/src/basic/strv.c | 20 + src/libnm-systemd-shared/src/basic/strv.h | 11 +- src/libnm-systemd-shared/src/basic/time-util.c | 281 +- src/libnm-systemd-shared/src/basic/time-util.h | 46 +- src/libnm-systemd-shared/src/basic/tmpfile-util.c | 6 +- .../src/fundamental/macro-fundamental.h | 54 +- .../src/fundamental/string-util-fundamental.c | 12 +- .../src/fundamental/string-util-fundamental.h | 17 + src/libnm-systemd-shared/src/shared/log-link.h | 18 - src/libnm-systemd-shared/src/shared/web-util.c | 17 +- src/libnm-systemd-shared/src/shared/web-util.h | 1 + src/libnmc-base/nm-vpn-helpers.c | 9 +- src/libnmc-base/qrcodegen.c | 4 +- src/libnmc-setting/nm-meta-setting-base-impl.c | 13 +- src/libnmc-setting/nm-meta-setting-base-impl.h | 5 +- src/libnmc-setting/nm-meta-setting-desc.c | 60 +- src/libnmc-setting/settings-docs-input.xml | 435 ++- src/libnmc-setting/settings-docs.h | 10 +- src/libnmc-setting/settings-docs.h.in | 10 +- src/libnmt-newt/nmt-newt-utils.c | 2 +- src/meson.build | 1 + src/n-acd/src/n-acd-probe.c | 8 +- src/nm-cloud-setup/nm-cloud-setup-utils.c | 63 - src/nm-cloud-setup/nm-cloud-setup-utils.h | 20 +- src/nm-cloud-setup/nmcs-provider-aliyun.c | 6 +- src/nm-cloud-setup/nmcs-provider-ec2.c | 6 +- .../tests/test-cloud-setup-general.c | 2 +- src/nm-daemon-helper/nm-daemon-helper.c | 2 +- src/nm-dispatcher/nm-dispatcher.c | 492 ++- src/nm-dispatcher/tests/test-dispatcher-envp.c | 8 +- src/nm-initrd-generator/nmi-cmdline-reader.c | 249 +- .../tests/test-cmdline-reader.c | 302 +- src/nm-priv-helper/meson.build | 36 + src/nm-priv-helper/nm-priv-helper.c | 696 ++++ src/nm-priv-helper/nm-priv-helper.conf | 13 + .../org.freedesktop.nm-priv-helper.service.in | 5 + src/nmcli/agent.c | 19 +- src/nmcli/common.c | 38 +- src/nmcli/common.h | 10 +- src/nmcli/connections.c | 212 +- src/nmcli/devices.c | 20 +- src/nmcli/general.c | 21 +- src/nmcli/generate-docs-nm-settings-nmcli.xml | 15 +- src/nmcli/generate-docs-nm-settings-nmcli.xml.in | 15 +- src/nmcli/nmcli.c | 9 +- src/nmcli/settings.c | 2 +- src/nmcli/utils.c | 2 +- src/nmtui/meson.build | 4 + src/nmtui/nm-editor-bindings.c | 223 ++ src/nmtui/nm-editor-bindings.h | 50 + src/nmtui/nm-editor-utils.c | 27 +- src/nmtui/nmt-connect-connection-list.c | 1 + src/nmtui/nmt-editor.c | 6 + src/nmtui/nmt-editor.h | 2 +- src/nmtui/nmt-page-bond-port.c | 64 + src/nmtui/nmt-page-bond-port.h | 36 + src/nmtui/nmt-page-bond.c | 15 +- src/nmtui/nmt-page-bridge-port.c | 8 +- src/nmtui/nmt-page-bridge.c | 7 +- src/nmtui/nmt-page-dsl.c | 8 +- src/nmtui/nmt-page-ethernet.c | 7 +- src/nmtui/nmt-page-infiniband.c | 8 +- src/nmtui/nmt-page-ip-tunnel.c | 7 +- src/nmtui/nmt-page-ip4.c | 11 +- src/nmtui/nmt-page-ip6.c | 11 +- src/nmtui/nmt-page-team-port.c | 10 +- src/nmtui/nmt-page-team.c | 9 +- src/nmtui/nmt-page-vlan.c | 19 +- src/nmtui/nmt-page-wifi.c | 13 +- src/nmtui/nmt-page-wireguard.c | 121 + src/nmtui/nmt-page-wireguard.h | 34 + src/nmtui/nmt-wireguard-peer-editor.c | 247 ++ src/nmtui/nmt-wireguard-peer-editor.h | 35 + src/nmtui/nmt-wireguard-peer-list.c | 451 +++ src/nmtui/nmt-wireguard-peer-list.h | 42 + src/nmtui/nmtui.c | 2 +- .../test-client.check-on-disk/test_002.expected | 10 +- .../test-client.check-on-disk/test_003.expected | 1336 +++---- .../test-client.check-on-disk/test_004.expected | 2562 ++++++------- src/tests/client/test-client.py | 49 +- 609 files changed, 28013 insertions(+), 21151 deletions(-) create mode 100644 src/core/nm-l3-ipv6ll.c create mode 100644 src/core/nm-l3-ipv6ll.h create mode 100644 src/core/nm-priv-helper-call.c create mode 100644 src/core/nm-priv-helper-call.h create mode 100644 src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bond-port create mode 100644 src/libnm-base/nm-priv-helper-utils.c create mode 100644 src/libnm-base/nm-priv-helper-utils.h create mode 100644 src/libnm-core-impl/nm-setting-bond-port.c create mode 100644 src/libnm-core-public/nm-setting-bond-port.h delete mode 100644 src/libnm-systemd-core/src/libsystemd-network/lldp-internal.h create mode 100644 src/libnm-systemd-core/src/libsystemd-network/lldp-rx-internal.h create mode 100644 src/libnm-systemd-core/src/libsystemd-network/sd-lldp-rx.c delete mode 100644 src/libnm-systemd-core/src/libsystemd-network/sd-lldp.c create mode 100644 src/libnm-systemd-core/src/systemd/sd-lldp-rx.h create mode 100644 src/libnm-systemd-shared/sd-adapt-shared/chase-symlinks.h create mode 100644 src/libnm-systemd-shared/sd-adapt-shared/missing_ioprio.h create mode 100644 src/libnm-systemd-shared/sd-adapt-shared/sync-util.h create mode 100644 src/libnm-systemd-shared/src/basic/inotify-util.c create mode 100644 src/libnm-systemd-shared/src/basic/inotify-util.h create mode 100644 src/nm-priv-helper/meson.build create mode 100644 src/nm-priv-helper/nm-priv-helper.c create mode 100644 src/nm-priv-helper/nm-priv-helper.conf create mode 100644 src/nm-priv-helper/org.freedesktop.nm-priv-helper.service.in create mode 100644 src/nmtui/nmt-page-bond-port.c create mode 100644 src/nmtui/nmt-page-bond-port.h create mode 100644 src/nmtui/nmt-page-wireguard.c create mode 100644 src/nmtui/nmt-page-wireguard.h create mode 100644 src/nmtui/nmt-wireguard-peer-editor.c create mode 100644 src/nmtui/nmt-wireguard-peer-editor.h create mode 100644 src/nmtui/nmt-wireguard-peer-list.c create mode 100644 src/nmtui/nmt-wireguard-peer-list.h (limited to 'src') diff --git a/src/c-list/src/c-list.h b/src/c-list/src/c-list.h index c92aa6f3..69de0b31 100644 --- a/src/c-list/src/c-list.h +++ b/src/c-list/src/c-list.h @@ -22,6 +22,7 @@ extern "C" { #endif #include +#include typedef struct CList CList; @@ -50,9 +51,42 @@ struct CList { /** * c_list_init() - initialize list entry * @what: list entry to initialize + * + * Return: @what is returned. */ -static inline void c_list_init(CList *what) { +static inline CList *c_list_init(CList *what) { *what = (CList)C_LIST_INIT(*what); + return what; +} + +/** + * c_list_entry_offset() - get parent container of list entry + * @what: list entry, or NULL + * @offset: offset of the list member in its surrounding type + * + * If the list entry @what is embedded into a surrounding structure, this will + * turn the list entry pointer @what into a pointer to the parent container + * (sometimes called container_of(3)). Use the `c_list_entry()` macro for an + * easier API. + * + * If @what is NULL, this will also return NULL. + * + * Return: Pointer to parent container, or NULL. + */ +static inline void *c_list_entry_offset(const CList *what, size_t offset) { + if (what) { + /* + * We allow calling "c_list_entry()" on the list head, which is + * commonly a plain CList struct. The returned entry pointer is + * thus invalid. For instance, this is used by the + * c_list_for_each_entry*() macros. Gcc correctly warns about that + * with "-Warray-bounds". However, as long as the value is never + * dereferenced, this is fine. We explicitly use integer arithmetic + * to circumvent the Gcc warning. + */ + return (void *)(((uintptr_t)(void *)what) - offset); + } + return NULL; } /** @@ -70,8 +104,7 @@ static inline void c_list_init(CList *what) { * Return: Pointer to parent container, or NULL. */ #define c_list_entry(_what, _t, _m) \ - ((_t *)(void *)(((unsigned long)(void *)(_what) ?: \ - offsetof(_t, _m)) - offsetof(_t, _m))) + ((_t *)c_list_entry_offset((_what), offsetof(_t, _m))) /** * c_list_is_linked() - check whether an entry is linked @@ -306,32 +339,47 @@ static inline CList *c_list_last(CList *list) { * state. */ +/* direct/raw iterators */ + #define c_list_for_each(_iter, _list) \ for (_iter = (_list)->next; \ (_iter) != (_list); \ _iter = (_iter)->next) -#define c_list_for_each_entry(_iter, _list, _m) \ - for (_iter = c_list_entry((_list)->next, __typeof__(*_iter), _m); \ - &(_iter)->_m != (_list); \ - _iter = c_list_entry((_iter)->_m.next, __typeof__(*_iter), _m)) - #define c_list_for_each_safe(_iter, _safe, _list) \ for (_iter = (_list)->next, _safe = (_iter)->next; \ (_iter) != (_list); \ _iter = (_safe), _safe = (_safe)->next) +#define c_list_for_each_continue(_iter, _list) \ + for (_iter = (_iter) ? (_iter)->next : (_list)->next; \ + (_iter) != (_list); \ + _iter = (_iter)->next) + +#define c_list_for_each_safe_continue(_iter, _safe, _list) \ + for (_iter = (_iter) ? (_iter)->next : (_list)->next, \ + _safe = (_iter)->next; \ + (_iter) != (_list); \ + _iter = (_safe), _safe = (_safe)->next) + +#define c_list_for_each_safe_unlink(_iter, _safe, _list) \ + for (_iter = (_list)->next, _safe = (_iter)->next; \ + c_list_init(_iter) != (_list); \ + _iter = (_safe), _safe = (_safe)->next) + +/* c_list_entry() based iterators */ + +#define c_list_for_each_entry(_iter, _list, _m) \ + for (_iter = c_list_entry((_list)->next, __typeof__(*_iter), _m); \ + &(_iter)->_m != (_list); \ + _iter = c_list_entry((_iter)->_m.next, __typeof__(*_iter), _m)) + #define c_list_for_each_entry_safe(_iter, _safe, _list, _m) \ for (_iter = c_list_entry((_list)->next, __typeof__(*_iter), _m), \ _safe = c_list_entry((_iter)->_m.next, __typeof__(*_iter), _m); \ &(_iter)->_m != (_list); \ _iter = (_safe), \ - _safe = c_list_entry((_safe)->_m.next, __typeof__(*_iter), _m)) \ - -#define c_list_for_each_continue(_iter, _list) \ - for (_iter = (_iter) ? (_iter)->next : (_list)->next; \ - (_iter) != (_list); \ - _iter = (_iter)->next) + _safe = c_list_entry((_safe)->_m.next, __typeof__(*_iter), _m)) #define c_list_for_each_entry_continue(_iter, _list, _m) \ for (_iter = c_list_entry((_iter) ? (_iter)->_m.next : (_list)->next, \ @@ -340,12 +388,6 @@ static inline CList *c_list_last(CList *list) { &(_iter)->_m != (_list); \ _iter = c_list_entry((_iter)->_m.next, __typeof__(*_iter), _m)) -#define c_list_for_each_safe_continue(_iter, _safe, _list) \ - for (_iter = (_iter) ? (_iter)->next : (_list)->next, \ - _safe = (_iter)->next; \ - (_iter) != (_list); \ - _iter = (_safe), _safe = (_safe)->next) - #define c_list_for_each_entry_safe_continue(_iter, _safe, _list, _m) \ for (_iter = c_list_entry((_iter) ? (_iter)->_m.next : (_list)->next, \ __typeof__(*_iter), \ @@ -353,20 +395,14 @@ static inline CList *c_list_last(CList *list) { _safe = c_list_entry((_iter)->_m.next, __typeof__(*_iter), _m); \ &(_iter)->_m != (_list); \ _iter = (_safe), \ - _safe = c_list_entry((_safe)->_m.next, __typeof__(*_iter), _m)) \ - -#define c_list_for_each_safe_unlink(_iter, _safe, _list) \ - for (_iter = (_list)->next, _safe = (_iter)->next; \ - ((*_iter = (CList)C_LIST_INIT(*_iter)), (_iter) != (_list)); \ - _iter = (_safe), _safe = (_safe)->next) + _safe = c_list_entry((_safe)->_m.next, __typeof__(*_iter), _m)) #define c_list_for_each_entry_safe_unlink(_iter, _safe, _list, _m) \ for (_iter = c_list_entry((_list)->next, __typeof__(*_iter), _m), \ _safe = c_list_entry((_iter)->_m.next, __typeof__(*_iter), _m); \ - (((_iter)->_m = (CList)C_LIST_INIT((_iter)->_m)), \ - &(_iter)->_m != (_list)); \ + c_list_init(&(_iter)->_m) != (_list); \ _iter = (_safe), \ - _safe = c_list_entry((_safe)->_m.next, __typeof__(*_iter), _m)) \ + _safe = c_list_entry((_safe)->_m.next, __typeof__(*_iter), _m)) /** * c_list_flush() - flush all entries from a list @@ -402,8 +438,8 @@ static inline void c_list_flush(CList *list) { * * Return: Number of items in @list. */ -static inline unsigned long c_list_length(const CList *list) { - unsigned long n = 0; +static inline size_t c_list_length(const CList *list) { + size_t n = 0; const CList *iter; c_list_for_each(iter, list) diff --git a/src/contrib/nm-compat.h b/src/contrib/nm-compat.h index 33eaec12..7614194f 100644 --- a/src/contrib/nm-compat.h +++ b/src/contrib/nm-compat.h @@ -15,23 +15,23 @@ const char **_nm_setting_vpn_get_data_keys(NMSettingVpn *setting, guint *out_len const char **_nm_setting_vpn_get_secret_keys(NMSettingVpn *setting, guint *out_length); #if NM_CHECK_VERSION(1, 11, 0) - #define nm_setting_vpn_get_data_keys(setting, out_length) \ - ({ \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - nm_setting_vpn_get_data_keys(setting, out_length); \ - G_GNUC_END_IGNORE_DEPRECATIONS \ - }) - #define nm_setting_vpn_get_secret_keys(setting, out_length) \ - ({ \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - nm_setting_vpn_get_secret_keys(setting, out_length); \ - G_GNUC_END_IGNORE_DEPRECATIONS \ - }) +#define nm_setting_vpn_get_data_keys(setting, out_length) \ + ({ \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + nm_setting_vpn_get_data_keys(setting, out_length); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + }) +#define nm_setting_vpn_get_secret_keys(setting, out_length) \ + ({ \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + nm_setting_vpn_get_secret_keys(setting, out_length); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + }) #else - #define nm_setting_vpn_get_data_keys(setting, out_length) \ - _nm_setting_vpn_get_data_keys(setting, out_length) - #define nm_setting_vpn_get_secret_keys(setting, out_length) \ - _nm_setting_vpn_get_secret_keys(setting, out_length) +#define nm_setting_vpn_get_data_keys(setting, out_length) \ + _nm_setting_vpn_get_data_keys(setting, out_length) +#define nm_setting_vpn_get_secret_keys(setting, out_length) \ + _nm_setting_vpn_get_secret_keys(setting, out_length) #endif /*****************************************************************************/ @@ -39,15 +39,15 @@ const char **_nm_setting_vpn_get_secret_keys(NMSettingVpn *setting, guint *out_l /* possibly missing defines from newer libnm API. */ #ifndef NM_VPN_PLUGIN_CONFIG_PROXY_PAC - #define NM_VPN_PLUGIN_CONFIG_PROXY_PAC "pac" +#define NM_VPN_PLUGIN_CONFIG_PROXY_PAC "pac" #endif #ifndef NM_VPN_PLUGIN_IP4_CONFIG_PRESERVE_ROUTES - #define NM_VPN_PLUGIN_IP4_CONFIG_PRESERVE_ROUTES "preserve-routes" +#define NM_VPN_PLUGIN_IP4_CONFIG_PRESERVE_ROUTES "preserve-routes" #endif #ifndef NM_VPN_PLUGIN_IP6_CONFIG_PRESERVE_ROUTES - #define NM_VPN_PLUGIN_IP6_CONFIG_PRESERVE_ROUTES "preserve-routes" +#define NM_VPN_PLUGIN_IP6_CONFIG_PRESERVE_ROUTES "preserve-routes" #endif /*****************************************************************************/ diff --git a/src/core/NetworkManagerUtils.c b/src/core/NetworkManagerUtils.c index 7d3e80be..0da8e0a9 100644 --- a/src/core/NetworkManagerUtils.c +++ b/src/core/NetworkManagerUtils.c @@ -17,6 +17,7 @@ #include "libnm-glib-aux/nm-uuid.h" #include "libnm-glib-aux/nm-str-buf.h" #include "libnm-base/nm-net-aux.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-aux-intern/nm-common-macros.h" #include "nm-utils.h" #include "nm-setting-connection.h" @@ -112,7 +113,7 @@ get_new_connection_name(NMConnection *const *existing_connections, * connection id. */ temp = g_strdup_printf(C_("connection id fallback", "%s %u"), fallback_prefix, i); - if (nm_utils_strv_find_first((char **) existing_names, existing_len, temp) < 0) + if (nm_strv_find_first(existing_names, existing_len, temp) < 0) return temp; g_free(temp); @@ -227,28 +228,28 @@ out: /*****************************************************************************/ void -nm_utils_complete_generic(NMPlatform * platform, - NMConnection * connection, - const char * ctype, - NMConnection *const *existing_connections, - const char * preferred_id, - const char * fallback_id_prefix, - const char * ifname_prefix, - const char * ifname, - gboolean default_enable_ipv6) +_nm_utils_complete_generic_with_params(NMPlatform * platform, + NMConnection * connection, + const char * ctype, + NMConnection *const *existing_connections, + const char * preferred_id, + const char * fallback_id_prefix, + const char * ifname_prefix, + const char * ifname, + ...) { NMSettingConnection *s_con; - char * id, *generated_ifname; - GHashTable * parameters; + char * id; + char * generated_ifname; + gs_unref_hashtable GHashTable *parameters = NULL; + va_list ap; + const char * p_val; + const char * p_key; g_assert(fallback_id_prefix); g_return_if_fail(ifname_prefix == NULL || ifname == NULL); - s_con = nm_connection_get_setting_connection(connection); - if (!s_con) { - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - } + s_con = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(G_OBJECT(s_con), NM_SETTING_CONNECTION_TYPE, ctype, NULL); if (!nm_setting_connection_get_uuid(s_con)) { @@ -268,7 +269,9 @@ nm_utils_complete_generic(NMPlatform * platform, } /* Add an interface name, if requested */ - if (ifname) { + if (nm_setting_connection_get_interface_name(s_con)) { + /* pass */ + } else if (ifname) { g_object_set(G_OBJECT(s_con), NM_SETTING_CONNECTION_INTERFACE_NAME, ifname, NULL); } else if (ifname_prefix && !nm_setting_connection_get_interface_name(s_con)) { generated_ifname = get_new_connection_ifname(platform, existing_connections, ifname_prefix); @@ -277,13 +280,20 @@ nm_utils_complete_generic(NMPlatform * platform, } /* Normalize */ - parameters = g_hash_table_new(nm_str_hash, g_str_equal); - g_hash_table_insert(parameters, - NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD, - default_enable_ipv6 ? NM_SETTING_IP6_CONFIG_METHOD_AUTO - : NM_SETTING_IP6_CONFIG_METHOD_IGNORE); + va_start(ap, ifname); + while ((p_key = va_arg(ap, const char *))) { + p_val = va_arg(ap, const char *); + if (!p_val) { + if (parameters) + g_hash_table_remove(parameters, p_key); + continue; + } + if (!parameters) + parameters = g_hash_table_new(nm_str_hash, g_str_equal); + g_hash_table_insert(parameters, (char *) p_key, (char *) p_val); + } + va_end(ap); nm_connection_normalize(connection, parameters, NULL, NULL); - g_hash_table_destroy(parameters); } /*****************************************************************************/ @@ -1051,6 +1061,12 @@ nm_shutdown_wait_obj_register_full(gpointer watched_obj, if (G_UNLIKELY(!_shutdown_waitobj_lst_head.next)) c_list_init(&_shutdown_waitobj_lst_head); + /* Beware: there are callers with g_main_context_get_thread_default() + * not being g_main_context_get_default(). For example _fw_nft_call(). + * + * If you schedule any sources or async operations, you probably need to + * make sure to use the default context. */ + handle = g_slice_new(NMShutdownWaitObjHandle); *handle = (NMShutdownWaitObjHandle){ /* depending on @free_msg_reason, we take ownership of @msg_reason. @@ -1693,5 +1709,11 @@ nm_platform_get() void nm_linux_platform_setup(void) { - nm_platform_setup(nm_linux_platform_new(FALSE, FALSE)); + nm_platform_setup(nm_linux_platform_new(FALSE, FALSE, FALSE)); +} + +void +nm_linux_platform_setup_with_tc_cache(void) +{ + nm_platform_setup(nm_linux_platform_new(FALSE, FALSE, TRUE)); } diff --git a/src/core/NetworkManagerUtils.h b/src/core/NetworkManagerUtils.h index 1c86387c..a2ac732e 100644 --- a/src/core/NetworkManagerUtils.h +++ b/src/core/NetworkManagerUtils.h @@ -19,15 +19,60 @@ const char *nm_utils_get_ip_config_method(NMConnection *connection, int addr_fam const char *nm_utils_get_shared_wifi_permission(NMConnection *connection); -void nm_utils_complete_generic(NMPlatform * platform, - NMConnection * connection, - const char * ctype, - NMConnection *const *existing_connections, - const char * preferred_id, - const char * fallback_id_prefix, - const char * ifname_prefix, - const char * ifname, - gboolean default_enable_ipv6); +void _nm_utils_complete_generic_with_params(NMPlatform * platform, + NMConnection * connection, + const char * ctype, + NMConnection *const *existing_connections, + const char * preferred_id, + const char * fallback_id_prefix, + const char * ifname_prefix, + const char * ifname, + ...) G_GNUC_NULL_TERMINATED; + +#define nm_utils_complete_generic_with_params(platform, \ + connection, \ + ctype, \ + existing_connections, \ + preferred_id, \ + fallback_id_prefix, \ + ifname_prefix, \ + ifname, \ + ...) \ + _nm_utils_complete_generic_with_params(platform, \ + connection, \ + ctype, \ + existing_connections, \ + preferred_id, \ + fallback_id_prefix, \ + ifname_prefix, \ + ifname, \ + ##__VA_ARGS__, \ + NULL) + +static inline void +nm_utils_complete_generic(NMPlatform * platform, + NMConnection * connection, + const char * ctype, + NMConnection *const *existing_connections, + const char * preferred_id, + const char * fallback_id_prefix, + const char * ifname_prefix, + const char * ifname, + gboolean default_enable_ipv6) +{ + nm_utils_complete_generic_with_params(platform, + connection, + ctype, + existing_connections, + preferred_id, + fallback_id_prefix, + ifname_prefix, + ifname, + NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD, + default_enable_ipv6 + ? NM_SETTING_IP6_CONFIG_METHOD_AUTO + : NM_SETTING_IP6_CONFIG_METHOD_IGNORE); +} typedef gboolean(NMUtilsMatchFilterFunc)(NMConnection *connection, gpointer user_data); @@ -232,6 +277,7 @@ NMPlatform *nm_platform_get(void); #define NM_PLATFORM_GET (nm_platform_get()) void nm_linux_platform_setup(void); +void nm_linux_platform_setup_with_tc_cache(void); /*****************************************************************************/ diff --git a/src/core/devices/adsl/nm-device-adsl.c b/src/core/devices/adsl/nm-device-adsl.c index 4e4c9dcc..adcf8785 100644 --- a/src/core/devices/adsl/nm-device-adsl.c +++ b/src/core/devices/adsl/nm-device-adsl.c @@ -356,7 +356,7 @@ br2684_create_iface(NMDeviceAdsl *self) return FALSE; } - nm_utils_strdup_reset(&priv->nas_ifname, ni.ifname); + nm_strdup_reset(&priv->nas_ifname, ni.ifname); _LOGD(LOGD_ADSL, "waiting for br2684 iface '%s' to appear", priv->nas_ifname); priv->nas_update_count = 0; priv->nas_update_id = g_timeout_add(100, nas_update_cb, self); diff --git a/src/core/devices/bluetooth/nm-bluez-manager.c b/src/core/devices/bluetooth/nm-bluez-manager.c index fc081580..36e442ad 100644 --- a/src/core/devices/bluetooth/nm-bluez-manager.c +++ b/src/core/devices/bluetooth/nm-bluez-manager.c @@ -31,9 +31,9 @@ /*****************************************************************************/ #if WITH_BLUEZ5_DUN - #define _NM_BT_CAPABILITY_SUPPORTED_DUN NM_BT_CAPABILITY_DUN +#define _NM_BT_CAPABILITY_SUPPORTED_DUN NM_BT_CAPABILITY_DUN #else - #define _NM_BT_CAPABILITY_SUPPORTED_DUN NM_BT_CAPABILITY_NONE +#define _NM_BT_CAPABILITY_SUPPORTED_DUN NM_BT_CAPABILITY_NONE #endif #define _NM_BT_CAPABILITY_SUPPORTED (NM_BT_CAPABILITY_NAP | _NM_BT_CAPABILITY_SUPPORTED_DUN) @@ -382,64 +382,56 @@ _bzobj_to_string(const BzDBusObj *bzobj, char *buf, gsize len) buf[0] = '\0'; if (bzobj->d_has_adapter_iface) { - nm_utils_strbuf_append_str(&buf, &len, prefix); + nm_strbuf_append_str(&buf, &len, prefix); prefix = ", "; - nm_utils_strbuf_append_str(&buf, &len, "Adapter1 {"); + nm_strbuf_append_str(&buf, &len, "Adapter1 {"); if (bzobj->d_adapter.address) { - nm_utils_strbuf_append(&buf, &len, " d.address: \"%s\"", bzobj->d_adapter.address); + nm_strbuf_append(&buf, &len, " d.address: \"%s\"", bzobj->d_adapter.address); if (bzobj->d_adapter_powered) - nm_utils_strbuf_append_str(&buf, &len, ","); + nm_strbuf_append_str(&buf, &len, ","); } if (bzobj->d_adapter_powered) - nm_utils_strbuf_append(&buf, &len, " d.powered: 1"); - nm_utils_strbuf_append_str(&buf, &len, " }"); + nm_strbuf_append(&buf, &len, " d.powered: 1"); + nm_strbuf_append_str(&buf, &len, " }"); } if (bzobj->d_has_device_iface) { const char *prefix1 = ""; - nm_utils_strbuf_append_str(&buf, &len, prefix); + nm_strbuf_append_str(&buf, &len, prefix); prefix = ", "; - nm_utils_strbuf_append_str(&buf, &len, "Device1 {"); + nm_strbuf_append_str(&buf, &len, "Device1 {"); if (bzobj->d_device.address) { - nm_utils_strbuf_append(&buf, - &len, - "%s d.address: \"%s\"", - prefix1, - bzobj->d_device.address); + nm_strbuf_append(&buf, &len, "%s d.address: \"%s\"", prefix1, bzobj->d_device.address); prefix1 = ","; } if (bzobj->d_device.name) { - nm_utils_strbuf_append(&buf, &len, "%s d.name: \"%s\"", prefix1, bzobj->d_device.name); + nm_strbuf_append(&buf, &len, "%s d.name: \"%s\"", prefix1, bzobj->d_device.name); prefix1 = ","; } if (bzobj->d_device.adapter) { - nm_utils_strbuf_append(&buf, - &len, - "%s d.adapter: \"%s\"", - prefix1, - bzobj->d_device.adapter); + nm_strbuf_append(&buf, &len, "%s d.adapter: \"%s\"", prefix1, bzobj->d_device.adapter); prefix1 = ","; } if (bzobj->d_device_capabilities != NM_BT_CAPABILITY_NONE) { - nm_utils_strbuf_append(&buf, - &len, - "%s d.capabilities: \"%s\"", - prefix1, - nm_bluetooth_capability_to_string(bzobj->d_device_capabilities, - sbuf_cap, - sizeof(sbuf_cap))); + nm_strbuf_append(&buf, + &len, + "%s d.capabilities: \"%s\"", + prefix1, + nm_bluetooth_capability_to_string(bzobj->d_device_capabilities, + sbuf_cap, + sizeof(sbuf_cap))); prefix1 = ","; } if (bzobj->d_device_connected) { - nm_utils_strbuf_append(&buf, &len, "%s d.connected: 1", prefix1); + nm_strbuf_append(&buf, &len, "%s d.connected: 1", prefix1); prefix1 = ","; } if (bzobj->d_device_paired) { - nm_utils_strbuf_append(&buf, &len, "%s d.paired: 1", prefix1); + nm_strbuf_append(&buf, &len, "%s d.paired: 1", prefix1); prefix1 = ","; } - nm_utils_strbuf_append_str(&buf, &len, " }"); + nm_strbuf_append_str(&buf, &len, " }"); } network_server_is_usable = _bzobjs_network_server_is_usable(bzobj, TRUE); @@ -450,43 +442,43 @@ _bzobj_to_string(const BzDBusObj *bzobj, char *buf, gsize len) || !nm_streq0(bzobj->d_has_adapter_iface ? bzobj->d_adapter.address : NULL, bzobj->x_network_server.adapter_address) || bzobj->x_network_server.device_br || bzobj->x_network_server.r_req_data) { - nm_utils_strbuf_append_str(&buf, &len, prefix); + nm_strbuf_append_str(&buf, &len, prefix); prefix = ", "; - nm_utils_strbuf_append(&buf, &len, "NetworkServer1 { "); + nm_strbuf_append(&buf, &len, "NetworkServer1 { "); if (!bzobj->d_has_network_server_iface) - nm_utils_strbuf_append(&buf, &len, " has-d-iface: 0, "); + nm_strbuf_append(&buf, &len, " has-d-iface: 0, "); if (network_server_is_usable != (!c_list_is_empty(&bzobj->x_network_server.lst))) - nm_utils_strbuf_append(&buf, - &len, - "usable: %d, used: %d", - !!network_server_is_usable, - !network_server_is_usable); + nm_strbuf_append(&buf, + &len, + "usable: %d, used: %d", + !!network_server_is_usable, + !network_server_is_usable); else if (network_server_is_usable) - nm_utils_strbuf_append(&buf, &len, "used: 1"); + nm_strbuf_append(&buf, &len, "used: 1"); else - nm_utils_strbuf_append(&buf, &len, "usable: 0"); + nm_strbuf_append(&buf, &len, "usable: 0"); if (!nm_streq0(bzobj->d_has_adapter_iface ? bzobj->d_adapter.address : NULL, bzobj->x_network_server.adapter_address)) { if (bzobj->x_network_server.adapter_address) - nm_utils_strbuf_append(&buf, - &len, - ", adapter-address: \"%s\"", - bzobj->x_network_server.adapter_address); + nm_strbuf_append(&buf, + &len, + ", adapter-address: \"%s\"", + bzobj->x_network_server.adapter_address); else - nm_utils_strbuf_append(&buf, &len, ", adapter-address: "); + nm_strbuf_append(&buf, &len, ", adapter-address: "); } if (bzobj->x_network_server.device_br) - nm_utils_strbuf_append(&buf, &len, ", bridge-device: 1"); + nm_strbuf_append(&buf, &len, ", bridge-device: 1"); if (bzobj->x_network_server.r_req_data) - nm_utils_strbuf_append(&buf, &len, ", register-in-progress: 1"); + nm_strbuf_append(&buf, &len, ", register-in-progress: 1"); - nm_utils_strbuf_append_str(&buf, &len, " }"); + nm_strbuf_append_str(&buf, &len, " }"); } device_is_usable = _bzobjs_device_is_usable(bzobj, NULL, &create_panu_connection); @@ -497,76 +489,72 @@ _bzobj_to_string(const BzDBusObj *bzobj, char *buf, gsize len) || bzobj->x_device_connect_bt_type != NM_BT_CAPABILITY_NONE || bzobj->x_device.connect_dun_context || bzobj->x_device.c_req_data || bzobj->x_device_is_connected != bzobj->d_network_connected) { - nm_utils_strbuf_append_str(&buf, &len, prefix); + nm_strbuf_append_str(&buf, &len, prefix); prefix = ", "; - nm_utils_strbuf_append_str(&buf, &len, "Network1 {"); + nm_strbuf_append_str(&buf, &len, "Network1 {"); if (bzobj->d_network.interface) - nm_utils_strbuf_append(&buf, - &len, - " d.interface: \"%s\", ", - bzobj->d_network.interface); + nm_strbuf_append(&buf, &len, " d.interface: \"%s\", ", bzobj->d_network.interface); if (bzobj->d_network_connected) - nm_utils_strbuf_append(&buf, &len, " d.connected: %d, ", !!bzobj->d_network_connected); + nm_strbuf_append(&buf, &len, " d.connected: %d, ", !!bzobj->d_network_connected); if (!bzobj->d_has_network_iface) - nm_utils_strbuf_append(&buf, &len, " has-d-iface: 0, "); + nm_strbuf_append(&buf, &len, " has-d-iface: 0, "); if (device_is_usable != bzobj->x_device_is_usable) - nm_utils_strbuf_append(&buf, - &len, - " usable: %d, used: %d", - !!device_is_usable, - !device_is_usable); + nm_strbuf_append(&buf, + &len, + " usable: %d, used: %d", + !!device_is_usable, + !device_is_usable); else if (device_is_usable) - nm_utils_strbuf_append(&buf, &len, " used: 1"); + nm_strbuf_append(&buf, &len, " used: 1"); else - nm_utils_strbuf_append(&buf, &len, " usable: 0"); + nm_strbuf_append(&buf, &len, " usable: 0"); if (create_panu_connection) - nm_utils_strbuf_append(&buf, &len, ", create-panu-connection: 1"); + nm_strbuf_append(&buf, &len, ", create-panu-connection: 1"); if (bzobj->x_device.panu_connection) - nm_utils_strbuf_append(&buf, &len, ", has-panu-connection: 1"); + nm_strbuf_append(&buf, &len, ", has-panu-connection: 1"); if (bzobj->x_device.device_bt) - nm_utils_strbuf_append(&buf, &len, ", has-device: 1"); + nm_strbuf_append(&buf, &len, ", has-device: 1"); if (bzobj->x_device_connect_bt_type != NM_BT_CAPABILITY_NONE || bzobj->x_device.connect_dun_context) { - nm_utils_strbuf_append( - &buf, - &len, - ", connect: %s%s", - nm_bluetooth_capability_to_string(bzobj->x_device_connect_bt_type, - sbuf_cap, - sizeof(sbuf_cap)), - bzobj->x_device.connect_dun_context ? ",with-dun-context" : ""); + nm_strbuf_append(&buf, + &len, + ", connect: %s%s", + nm_bluetooth_capability_to_string(bzobj->x_device_connect_bt_type, + sbuf_cap, + sizeof(sbuf_cap)), + bzobj->x_device.connect_dun_context ? ",with-dun-context" : ""); } if (bzobj->x_device.c_req_data) - nm_utils_strbuf_append(&buf, &len, ", connecting: 1"); + nm_strbuf_append(&buf, &len, ", connecting: 1"); if (bzobj->x_device_is_connected != bzobj->d_network_connected) - nm_utils_strbuf_append(&buf, &len, ", connected: %d", !!bzobj->x_device_is_connected); + nm_strbuf_append(&buf, &len, ", connected: %d", !!bzobj->x_device_is_connected); - nm_utils_strbuf_append_str(&buf, &len, " }"); + nm_strbuf_append_str(&buf, &len, " }"); } if (_bzobjs_is_dead(bzobj)) { - nm_utils_strbuf_append_str(&buf, &len, prefix); + nm_strbuf_append_str(&buf, &len, prefix); prefix = ", "; - nm_utils_strbuf_append_str(&buf, &len, "dead: 1"); + nm_strbuf_append_str(&buf, &len, "dead: 1"); } if (!c_list_is_empty(&bzobj->process_change_lst)) { - nm_utils_strbuf_append_str(&buf, &len, prefix); + nm_strbuf_append_str(&buf, &len, prefix); prefix = ", "; - nm_utils_strbuf_append(&buf, &len, "change-pending-on-idle: 1"); + nm_strbuf_append(&buf, &len, "change-pending-on-idle: 1"); } if (_bzobjs_adapter_is_usable_for_device(bzobj) != bzobj->was_usable_adapter_for_device_before) { - nm_utils_strbuf_append_str(&buf, &len, prefix); + nm_strbuf_append_str(&buf, &len, prefix); prefix = ", "; - nm_utils_strbuf_append(&buf, &len, "change-usable-adapter-for-device: 1"); + nm_strbuf_append(&buf, &len, "change-usable-adapter-for-device: 1"); } return buf0; @@ -2864,9 +2852,7 @@ dispose(GObject *object) * BzDBusObj instances and do necessary cleanup actions (like disconnecting devices * or deleting panu_connection). */ - nm_assert(c_list_is_empty(&priv->network_server_lst_head)); - nm_assert(c_list_is_empty(&priv->process_change_lst_head)); - nm_assert(priv->process_change_idle_id == 0); + nm_clear_g_source(&priv->process_change_idle_id); g_atomic_pointer_compare_and_exchange(&nm_bt_vtable_network_server, &priv->vtable_network_server, @@ -2883,6 +2869,9 @@ dispose(GObject *object) nm_clear_pointer(&priv->bzobjs, g_hash_table_destroy); nm_clear_pointer(&priv->conn_data_heads, g_hash_table_destroy); nm_clear_pointer(&priv->conn_data_elems, g_hash_table_destroy); + + nm_assert(c_list_is_empty(&priv->network_server_lst_head)); + nm_assert(c_list_is_empty(&priv->process_change_lst_head)); } static void diff --git a/src/core/devices/bluetooth/nm-bluez5-dun.c b/src/core/devices/bluetooth/nm-bluez5-dun.c index e29884d8..7efbfaf4 100644 --- a/src/core/devices/bluetooth/nm-bluez5-dun.c +++ b/src/core/devices/bluetooth/nm-bluez5-dun.c @@ -182,25 +182,18 @@ _connect_open_tty(NMBluez5DunContext *context) nm_strerror_native(errsv), errsv); context->cdat->connect_open_tty_started_at = nm_utils_get_monotonic_timestamp_nsec(); - context->cdat->source = nm_g_timeout_source_new(100, - G_PRIORITY_DEFAULT, - _connect_open_tty_retry_cb, - context, - NULL); - g_source_attach(context->cdat->source, NULL); + context->cdat->source = + nm_g_timeout_add_source(100, _connect_open_tty_retry_cb, context); } return -errsv; } context->rfcomm_tty_fd = fd; - context->rfcomm_tty_poll_source = nm_g_unix_fd_source_new(context->rfcomm_tty_fd, + context->rfcomm_tty_poll_source = nm_g_unix_fd_add_source(context->rfcomm_tty_fd, G_IO_ERR | G_IO_HUP, - G_PRIORITY_DEFAULT, _rfcomm_tty_poll_cb, - context, - NULL); - g_source_attach(context->rfcomm_tty_poll_source, NULL); + context); _context_invoke_callback_success(context); return 0; @@ -369,13 +362,10 @@ _connect_socket_connect(NMBluez5DunContext *context) context->dst_str, context->rfcomm_channel); - context->cdat->source = nm_g_unix_fd_source_new(context->rfcomm_sock_fd, + context->cdat->source = nm_g_unix_fd_add_source(context->rfcomm_sock_fd, G_IO_OUT, - G_PRIORITY_DEFAULT, _connect_socket_connect_cb, - context, - NULL); - g_source_attach(context->cdat->source, NULL); + context); return; } @@ -567,12 +557,8 @@ _connect_sdp_io_cb(int fd, GIOCondition condition, gpointer user_data) nm_strerror_native(errsv), errsv); nm_clear_g_source_inst(&context->cdat->source); - context->cdat->source = nm_g_timeout_source_new(1000, - G_PRIORITY_DEFAULT, - _connect_sdp_session_start_on_idle_cb, - context, - NULL); - g_source_attach(context->cdat->source, NULL); + context->cdat->source = + nm_g_timeout_add_source(1000, _connect_sdp_session_start_on_idle_cb, context); return G_SOURCE_REMOVE; } @@ -616,13 +602,10 @@ _connect_sdp_io_cb(int fd, GIOCondition condition, gpointer user_data) } /* Set callback responsible for update the internal SDP transaction */ - context->cdat->source = nm_g_unix_fd_source_new(fd, + context->cdat->source = nm_g_unix_fd_add_source(fd, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, - G_PRIORITY_DEFAULT, _connect_sdp_search_io_cb, - context, - NULL); - g_source_attach(context->cdat->source, NULL); + context); done: if (error) @@ -664,13 +647,10 @@ _connect_sdp_session_start(NMBluez5DunContext *context, GError **error) return FALSE; } - context->cdat->source = nm_g_unix_fd_source_new(sdp_get_socket(context->cdat->sdp_session), + context->cdat->source = nm_g_unix_fd_add_source(sdp_get_socket(context->cdat->sdp_session), G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL, - G_PRIORITY_DEFAULT, _connect_sdp_io_cb, - context, - NULL); - g_source_attach(context->cdat->source, NULL); + context); return TRUE; } diff --git a/src/core/devices/bluetooth/nm-device-bt.c b/src/core/devices/bluetooth/nm-device-bt.c index 8f4ceba7..3dbfbbe0 100644 --- a/src/core/devices/bluetooth/nm-device-bt.c +++ b/src/core/devices/bluetooth/nm-device-bt.c @@ -10,6 +10,7 @@ #include #include +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" #include "nm-bluez-common.h" #include "nm-bluez-manager.h" @@ -273,11 +274,7 @@ complete_connection(NMDevice * device, s_serial = nm_connection_get_setting_serial(connection); s_ppp = nm_connection_get_setting_ppp(connection); - s_bt = nm_connection_get_setting_bluetooth(connection); - if (!s_bt) { - s_bt = (NMSettingBluetooth *) nm_setting_bluetooth_new(); - nm_connection_add_setting(connection, NM_SETTING(s_bt)); - } + s_bt = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_BLUETOOTH); ctype = nm_setting_bluetooth_get_connection_type(s_bt); if (ctype) { @@ -1007,21 +1004,21 @@ act_stage3_ip_config_start(NMDevice * device, gpointer * out_config, NMDeviceStateReason *out_failure_reason) { - NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(device); + NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE(device); + gboolean autoip4 = FALSE; + NMActStageReturn ret; - nm_assert_addr_family(addr_family); + if (priv->connect_bt_type != NM_BT_CAPABILITY_DUN) + goto out_chain_up; - if (priv->connect_bt_type == NM_BT_CAPABILITY_DUN) { - if (addr_family == AF_INET) { - return nm_modem_stage3_ip4_config_start(priv->modem, - device, - NM_DEVICE_CLASS(nm_device_bt_parent_class), - out_failure_reason); - } else { - return nm_modem_stage3_ip6_config_start(priv->modem, device, out_failure_reason); - } - } + if (!NM_IS_IPv4(addr_family)) + return nm_modem_stage3_ip6_config_start(priv->modem, device, out_failure_reason); + + ret = nm_modem_stage3_ip4_config_start(priv->modem, device, &autoip4, out_failure_reason); + if (ret != NM_ACT_STAGE_RETURN_SUCCESS || !autoip4) + return ret; +out_chain_up: return NM_DEVICE_CLASS(nm_device_bt_parent_class) ->act_stage3_ip_config_start(device, addr_family, out_config, out_failure_reason); } diff --git a/src/core/devices/bluetooth/tests/nm-bt-test.c b/src/core/devices/bluetooth/tests/nm-bt-test.c index 0fc8aa87..548e7249 100644 --- a/src/core/devices/bluetooth/tests/nm-bt-test.c +++ b/src/core/devices/bluetooth/tests/nm-bt-test.c @@ -2,8 +2,6 @@ #include "src/core/nm-default-daemon.h" -#include - #include "devices/bluetooth/nm-bluez5-dun.h" #include "nm-test-utils-core.h" diff --git a/src/core/devices/nm-acd-manager.c b/src/core/devices/nm-acd-manager.c index 145947bb..c041163e 100644 --- a/src/core/devices/nm-acd-manager.c +++ b/src/core/devices/nm-acd-manager.c @@ -349,9 +349,7 @@ nm_acd_manager_start_probe(NMAcdManager *self, guint timeout) nm_assert(!self->event_source); n_acd_get_fd(self->acd, &fd); - self->event_source = - nm_g_unix_fd_source_new(fd, G_IO_IN, G_PRIORITY_DEFAULT, acd_event, self, NULL); - g_source_attach(self->event_source, NULL); + self->event_source = nm_g_unix_fd_add_source(fd, G_IO_IN, acd_event, self); return success ? 0 : -NME_UNSPEC; } @@ -439,9 +437,7 @@ nm_acd_manager_announce_addresses(NMAcdManager *self) if (!self->event_source) { n_acd_get_fd(self->acd, &fd); - self->event_source = - nm_g_unix_fd_source_new(fd, G_IO_IN, G_PRIORITY_DEFAULT, acd_event, self, NULL); - g_source_attach(self->event_source, NULL); + self->event_source = nm_g_unix_fd_add_source(fd, G_IO_IN, acd_event, self); } return success ? 0 : -NME_UNSPEC; diff --git a/src/core/devices/nm-device-6lowpan.c b/src/core/devices/nm-device-6lowpan.c index 96218658..8b77c22c 100644 --- a/src/core/devices/nm-device-6lowpan.c +++ b/src/core/devices/nm-device-6lowpan.c @@ -9,6 +9,7 @@ #include "nm-device-private.h" #include "settings/nm-settings.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-setting-6lowpan.h" @@ -221,12 +222,7 @@ static void update_connection(NMDevice *device, NMConnection *connection) { NMSetting6Lowpan *s_6lowpan = - NM_SETTING_6LOWPAN(nm_connection_get_setting(connection, NM_TYPE_SETTING_6LOWPAN)); - - if (!s_6lowpan) { - s_6lowpan = (NMSetting6Lowpan *) nm_setting_6lowpan_new(); - nm_connection_add_setting(connection, (NMSetting *) s_6lowpan); - } + _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_6LOWPAN); g_object_set( s_6lowpan, diff --git a/src/core/devices/nm-device-bond.c b/src/core/devices/nm-device-bond.c index b208e2c0..f7d78f57 100644 --- a/src/core/devices/nm-device-bond.c +++ b/src/core/devices/nm-device-bond.c @@ -14,8 +14,10 @@ #include "nm-device-private.h" #include "libnm-platform/nm-platform.h" #include "nm-device-factory.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" #include "nm-ip4-config.h" +#include "nm-setting-bond-port.h" #define _NMLOG_DEVICE_TYPE NMDeviceBond #include "nm-device-logging.h" @@ -79,8 +81,6 @@ complete_connection(NMDevice * device, NMConnection *const *existing_connections, GError ** error) { - NMSettingBond *s_bond; - nm_utils_complete_generic(nm_device_get_platform(device), connection, NM_SETTING_BOND_SETTING_NAME, @@ -91,11 +91,7 @@ complete_connection(NMDevice * device, NULL, TRUE); - s_bond = nm_connection_get_setting_bond(connection); - if (!s_bond) { - s_bond = (NMSettingBond *) nm_setting_bond_new(); - nm_connection_add_setting(connection, NM_SETTING(s_bond)); - } + _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_BOND); return TRUE; } @@ -168,16 +164,11 @@ static void update_connection(NMDevice *device, NMConnection *connection) { NMDeviceBond * self = NM_DEVICE_BOND(device); - NMSettingBond *s_bond = nm_connection_get_setting_bond(connection); + NMSettingBond *s_bond = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_BOND); int ifindex = nm_device_get_ifindex(device); NMBondMode mode = NM_BOND_MODE_UNKNOWN; const char ** options; - if (!s_bond) { - s_bond = (NMSettingBond *) nm_setting_bond_new(); - nm_connection_add_setting(connection, (NMSetting *) s_bond); - } - /* Read bond options from sysfs and update the Bond setting to match */ options = nm_setting_bond_get_valid_options(NULL); for (; options[0]; options++) { @@ -225,11 +216,29 @@ update_connection(NMDevice *device, NMConnection *connection) } static gboolean -master_update_slave_connection(NMDevice * self, - NMDevice * slave, - NMConnection *connection, - GError ** error) +controller_update_port_connection(NMDevice * self, + NMDevice * port, + NMConnection *connection, + GError ** error) { + NMSettingBondPort *s_port; + int ifindex_port = nm_device_get_ifindex(port); + uint queue_id = NM_BOND_PORT_QUEUE_ID_DEF; + gs_free char * queue_id_str = NULL; + + g_return_val_if_fail(ifindex_port > 0, FALSE); + + s_port = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_BOND_PORT); + + queue_id_str = + nm_platform_sysctl_slave_get_option(nm_device_get_platform(self), ifindex_port, "queue_id"); + if (queue_id_str) { + queue_id = + _nm_utils_ascii_str_to_int64(queue_id_str, 10, 0, 65535, NM_BOND_PORT_QUEUE_ID_DEF); + g_object_set(s_port, NM_SETTING_BOND_PORT_QUEUE_ID, queue_id, NULL); + } else + _LOGW(LOGD_BOND, "failed to read bond port setting '%s'", NM_SETTING_BOND_PORT_QUEUE_ID); + g_object_set(nm_connection_get_setting_connection(connection), NM_SETTING_CONNECTION_MASTER, nm_device_get_iface(self), @@ -250,9 +259,8 @@ set_arp_targets(NMDevice *device, const char *cur_arp_ip_target, const char *new gsize i; gsize j; - cur_strv = nm_utils_strsplit_set_full(cur_arp_ip_target, - NM_ASCII_SPACES, - NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP); + cur_strv = + nm_strsplit_set_full(cur_arp_ip_target, NM_ASCII_SPACES, NM_STRSPLIT_SET_FLAGS_STRSTRIP); new_strv = nm_utils_bond_option_arp_ip_targets_split(new_arp_ip_target); cur_len = NM_PTRARRAY_LEN(cur_strv); @@ -276,7 +284,7 @@ set_arp_targets(NMDevice *device, const char *cur_arp_ip_target, const char *new } } - if (nm_utils_strv_find_first((char **) new_strv, i, s) < 0) + if (nm_strv_find_first(new_strv, i, s) < 0) new_strv[j++] = s; } new_strv[j] = NULL; @@ -286,7 +294,7 @@ set_arp_targets(NMDevice *device, const char *cur_arp_ip_target, const char *new if (cur_len == 0 && new_len == 0) return; - if (nm_utils_strv_equal(cur_strv, new_strv)) + if (nm_strv_equal(cur_strv, new_strv)) return; for (i = 0; i < cur_len; i++) @@ -395,30 +403,57 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) return ret; } +static void +commit_port_options(NMDevice *bond_device, NMDevice *port, NMSettingBondPort *s_port) +{ + char queue_id_str[IFNAMSIZ + NM_STRLEN(":") + 5 + 100]; + + /* + * The queue-id of bond port is read only, we should modify bond interface using: + * echo "eth1:2" > /sys/class/net/bond0/bonding/queue_id + * Kernel allows parital editing, so no need to care about other bond ports. + */ + g_snprintf(queue_id_str, + sizeof(queue_id_str), + "%s:%" G_GUINT32_FORMAT, + nm_device_get_iface(port), + s_port ? nm_setting_bond_port_get_queue_id(s_port) : NM_BOND_PORT_QUEUE_ID_DEF); + + nm_platform_sysctl_master_set_option(nm_device_get_platform(bond_device), + nm_device_get_ifindex(bond_device), + "queue_id", + queue_id_str); +} + static gboolean -enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gboolean configure) +enslave_slave(NMDevice *device, NMDevice *port, NMConnection *connection, gboolean configure) { - NMDeviceBond *self = NM_DEVICE_BOND(device); + NMDeviceBond * self = NM_DEVICE_BOND(device); + NMSettingBondPort *s_port; - nm_device_master_check_slave_physical_port(device, slave, LOGD_BOND); + nm_device_master_check_slave_physical_port(device, port, LOGD_BOND); if (configure) { gboolean success; - nm_device_take_down(slave, TRUE); + nm_device_take_down(port, TRUE); success = nm_platform_link_enslave(nm_device_get_platform(device), nm_device_get_ip_ifindex(device), - nm_device_get_ip_ifindex(slave)); - nm_device_bring_up(slave, TRUE, NULL); + nm_device_get_ip_ifindex(port)); + nm_device_bring_up(port, TRUE, NULL); if (!success) { - _LOGI(LOGD_BOND, "enslaved bond slave %s: failed", nm_device_get_ip_iface(slave)); + _LOGI(LOGD_BOND, "assigning bond port %s: failed", nm_device_get_ip_iface(port)); return FALSE; } - _LOGI(LOGD_BOND, "enslaved bond slave %s", nm_device_get_ip_iface(slave)); + s_port = _nm_connection_get_setting(connection, NM_TYPE_SETTING_BOND_PORT); + + commit_port_options(device, port, s_port); + + _LOGI(LOGD_BOND, "assigned bond port %s", nm_device_get_ip_iface(port)); } else - _LOGI(LOGD_BOND, "bond slave %s was enslaved", nm_device_get_ip_iface(slave)); + _LOGI(LOGD_BOND, "bond port %s was assigned", nm_device_get_ip_iface(port)); return TRUE; } @@ -624,7 +659,7 @@ nm_device_bond_class_init(NMDeviceBondClass *klass) device_class->complete_connection = complete_connection; device_class->update_connection = update_connection; - device_class->master_update_slave_connection = master_update_slave_connection; + device_class->master_update_slave_connection = controller_update_port_connection; device_class->create_and_realize = create_and_realize; device_class->act_stage1_prepare = act_stage1_prepare; diff --git a/src/core/devices/nm-device-bridge.c b/src/core/devices/nm-device-bridge.c index a095dc3e..36a73978 100644 --- a/src/core/devices/nm-device-bridge.c +++ b/src/core/devices/nm-device-bridge.c @@ -14,6 +14,7 @@ #include "nm-device-private.h" #include "libnm-platform/nm-platform.h" #include "nm-device-factory.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" #define _NMLOG_DEVICE_TYPE NMDeviceBridge @@ -145,8 +146,6 @@ complete_connection(NMDevice * device, NMConnection *const *existing_connections, GError ** error) { - NMSettingBridge *s_bridge; - nm_utils_complete_generic(nm_device_get_platform(device), connection, NM_SETTING_BRIDGE_SETTING_NAME, @@ -157,11 +156,7 @@ complete_connection(NMDevice * device, NULL, TRUE); - s_bridge = nm_connection_get_setting_bridge(connection); - if (!s_bridge) { - s_bridge = (NMSettingBridge *) nm_setting_bridge_new(); - nm_connection_add_setting(connection, NM_SETTING(s_bridge)); - } + _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_BRIDGE); return TRUE; } @@ -576,17 +571,12 @@ static void update_connection(NMDevice *device, NMConnection *connection) { NMDeviceBridge * self = NM_DEVICE_BRIDGE(device); - NMSettingBridge *s_bridge = nm_connection_get_setting_bridge(connection); + NMSettingBridge *s_bridge = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_BRIDGE); int ifindex = nm_device_get_ifindex(device); const Option * option; gs_free char * stp = NULL; int stp_value; - if (!s_bridge) { - s_bridge = (NMSettingBridge *) nm_setting_bridge_new(); - nm_connection_add_setting(connection, (NMSetting *) s_bridge); - } - option = master_options; nm_assert(nm_streq(option->sysname, "stp_state")); @@ -690,11 +680,7 @@ master_update_slave_connection(NMDevice * device, g_return_val_if_fail(ifindex_slave > 0, FALSE); s_con = nm_connection_get_setting_connection(connection); - s_port = nm_connection_get_setting_bridge_port(connection); - if (!s_port) { - s_port = (NMSettingBridgePort *) nm_setting_bridge_port_new(); - nm_connection_add_setting(connection, NM_SETTING(s_port)); - } + s_port = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_BRIDGE_PORT); for (option = slave_options; option->name; option++) { gs_free char *str = nm_platform_sysctl_slave_get_option(nm_device_get_platform(device), diff --git a/src/core/devices/nm-device-dummy.c b/src/core/devices/nm-device-dummy.c index 488f0ba0..4c12648f 100644 --- a/src/core/devices/nm-device-dummy.c +++ b/src/core/devices/nm-device-dummy.c @@ -16,6 +16,7 @@ #include "libnm-platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-setting-dummy.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" #define _NMLOG_DEVICE_TYPE NMDeviceDummy @@ -48,26 +49,16 @@ complete_connection(NMDevice * device, NMConnection *const *existing_connections, GError ** error) { - NMSettingDummy *s_dummy; + nm_utils_complete_generic_with_params(nm_device_get_platform(device), + connection, + NM_SETTING_DUMMY_SETTING_NAME, + existing_connections, + NULL, + _("Dummy connection"), + NULL, + nm_device_get_ip_iface(device)); - nm_utils_complete_generic(nm_device_get_platform(device), - connection, - NM_SETTING_DUMMY_SETTING_NAME, - existing_connections, - NULL, - _("Dummy connection"), - NULL, - NULL, - TRUE); - - s_dummy = nm_connection_get_setting_dummy(connection); - if (!s_dummy) { - g_set_error_literal(error, - NM_DEVICE_ERROR, - NM_DEVICE_ERROR_INVALID_CONNECTION, - "A 'dummy' setting is required."); - return FALSE; - } + _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_DUMMY); return TRUE; } @@ -75,12 +66,7 @@ complete_connection(NMDevice * device, static void update_connection(NMDevice *device, NMConnection *connection) { - NMSettingDummy *s_dummy = nm_connection_get_setting_dummy(connection); - - if (!s_dummy) { - s_dummy = (NMSettingDummy *) nm_setting_dummy_new(); - nm_connection_add_setting(connection, (NMSetting *) s_dummy); - } + _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_DUMMY); } static gboolean diff --git a/src/core/devices/nm-device-ethernet.c b/src/core/devices/nm-device-ethernet.c index 95336c7a..667ea9b9 100644 --- a/src/core/devices/nm-device-ethernet.c +++ b/src/core/devices/nm-device-ethernet.c @@ -33,6 +33,7 @@ #include "nm-device-ethernet-utils.h" #include "settings/nm-settings.h" #include "nm-device-factory.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" #include "NetworkManagerUtils.h" #include "libnm-udev-aux/nm-udev-utils.h" @@ -1618,11 +1619,7 @@ complete_connection(NMDevice * device, NULL, TRUE); - s_veth = _nm_connection_get_setting(connection, NM_TYPE_SETTING_VETH); - if (!s_veth) { - s_veth = (NMSettingVeth *) nm_setting_veth_new(); - nm_connection_add_setting(connection, NM_SETTING(s_veth)); - } + s_veth = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_VETH); ifindex = nm_device_get_ip_ifindex(device); if (ifindex > 0) { @@ -1664,11 +1661,7 @@ complete_connection(NMDevice * device, if (s_pppoe && !nm_setting_verify(NM_SETTING(s_pppoe), NULL, error)) return FALSE; - s_wired = nm_connection_get_setting_wired(connection); - if (!s_wired) { - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - } + s_wired = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_WIRED); /* Default to an ethernet-only connection, but if a PPPoE setting was given * then PPPoE should be our connection type. @@ -1782,20 +1775,15 @@ get_s390_subchannels(NMDevice *device) static void update_connection(NMDevice *device, NMConnection *connection) { - NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(device); - NMSettingWired * s_wired = nm_connection_get_setting_wired(connection); - gboolean perm_hw_addr_is_fake; - const char * perm_hw_addr; - const char * mac = nm_device_get_hw_address(device); - const char * mac_prop = NM_SETTING_WIRED_MAC_ADDRESS; - GHashTableIter iter; - const char * key; - const char * value; - - if (!s_wired) { - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, (NMSetting *) s_wired); - } + NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(device); + NMSettingWired *s_wired = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_WIRED); + gboolean perm_hw_addr_is_fake; + const char * perm_hw_addr; + const char * mac = nm_device_get_hw_address(device); + const char * mac_prop = NM_SETTING_WIRED_MAC_ADDRESS; + GHashTableIter iter; + const char * key; + const char * value; g_object_set(nm_connection_get_setting_connection(connection), NM_SETTING_CONNECTION_TYPE, diff --git a/src/core/devices/nm-device-infiniband.c b/src/core/devices/nm-device-infiniband.c index 37065bc8..df14dfa8 100644 --- a/src/core/devices/nm-device-infiniband.c +++ b/src/core/devices/nm-device-infiniband.c @@ -16,6 +16,7 @@ #include "nm-ip4-config.h" #include "libnm-platform/nm-platform.h" #include "nm-device-factory.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" #define NM_DEVICE_INFINIBAND_IS_PARTITION "is-partition" @@ -146,11 +147,7 @@ complete_connection(NMDevice * device, { NMSettingInfiniband *s_infiniband; - s_infiniband = nm_connection_get_setting_infiniband(connection); - if (!s_infiniband) { - s_infiniband = (NMSettingInfiniband *) nm_setting_infiniband_new(); - nm_connection_add_setting(connection, NM_SETTING(s_infiniband)); - } + s_infiniband = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_INFINIBAND); nm_utils_complete_generic( nm_device_get_platform(device), @@ -175,15 +172,11 @@ complete_connection(NMDevice * device, static void update_connection(NMDevice *device, NMConnection *connection) { - NMSettingInfiniband *s_infiniband = nm_connection_get_setting_infiniband(connection); - const char * mac = nm_device_get_permanent_hw_address(device); - const char * transport_mode = "datagram"; - int ifindex; - - if (!s_infiniband) { - s_infiniband = (NMSettingInfiniband *) nm_setting_infiniband_new(); - nm_connection_add_setting(connection, (NMSetting *) s_infiniband); - } + NMSettingInfiniband *s_infiniband = + _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_INFINIBAND); + const char *mac = nm_device_get_permanent_hw_address(device); + const char *transport_mode = "datagram"; + int ifindex; if (mac && !nm_utils_hwaddr_matches(mac, -1, NULL, INFINIBAND_ALEN)) g_object_set(s_infiniband, NM_SETTING_INFINIBAND_MAC_ADDRESS, mac, NULL); diff --git a/src/core/devices/nm-device-ip-tunnel.c b/src/core/devices/nm-device-ip-tunnel.c index c55dd9f6..fe2e2023 100644 --- a/src/core/devices/nm-device-ip-tunnel.c +++ b/src/core/devices/nm-device-ip-tunnel.c @@ -18,6 +18,7 @@ #include "nm-manager.h" #include "libnm-platform/nm-platform.h" #include "nm-device-factory.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" #include "settings/nm-settings.h" #include "nm-act-request.h" @@ -416,14 +417,10 @@ complete_connection(NMDevice * device, static void update_connection(NMDevice *device, NMConnection *connection) { - NMDeviceIPTunnel * self = NM_DEVICE_IP_TUNNEL(device); - NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE(self); - NMSettingIPTunnel * s_ip_tunnel = nm_connection_get_setting_ip_tunnel(connection); - - if (!s_ip_tunnel) { - s_ip_tunnel = (NMSettingIPTunnel *) nm_setting_ip_tunnel_new(); - nm_connection_add_setting(connection, (NMSetting *) s_ip_tunnel); - } + NMDeviceIPTunnel * self = NM_DEVICE_IP_TUNNEL(device); + NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE(self); + NMSettingIPTunnel * s_ip_tunnel = + _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_IP_TUNNEL); if (nm_setting_ip_tunnel_get_mode(s_ip_tunnel) != priv->mode) g_object_set(G_OBJECT(s_ip_tunnel), NM_SETTING_IP_TUNNEL_MODE, priv->mode, NULL); diff --git a/src/core/devices/nm-device-logging.h b/src/core/devices/nm-device-logging.h index 844e9949..c2602189 100644 --- a/src/core/devices/nm-device-logging.h +++ b/src/core/devices/nm-device-logging.h @@ -9,15 +9,13 @@ #include "nm-device.h" #if !_NM_CC_SUPPORT_GENERIC - #define _NM_DEVICE_CAST(self) ((NMDevice *) (self)) +#define _NM_DEVICE_CAST(self) ((NMDevice *) (self)) #elif !defined(_NMLOG_DEVICE_TYPE) - #define _NM_DEVICE_CAST(self) \ - _Generic((self), NMDevice * \ - : ((NMDevice *) (self)), NMDevice *const \ - : ((NMDevice *) (self))) +#define _NM_DEVICE_CAST(self) \ + _Generic((self), NMDevice * : ((NMDevice *) (self)), NMDevice *const : ((NMDevice *) (self))) #else - #define _NM_DEVICE_CAST(self) \ - _Generic((self), \ +#define _NM_DEVICE_CAST(self) \ + _Generic((self), \ _NMLOG_DEVICE_TYPE * : ((NMDevice *) (self)), \ _NMLOG_DEVICE_TYPE * const: ((NMDevice *) (self)), \ NMDevice * : ((NMDevice *) (self)), \ diff --git a/src/core/devices/nm-device-macvlan.c b/src/core/devices/nm-device-macvlan.c index 7302ecdf..937ba9e4 100644 --- a/src/core/devices/nm-device-macvlan.c +++ b/src/core/devices/nm-device-macvlan.c @@ -13,6 +13,7 @@ #include "settings/nm-settings.h" #include "nm-act-request.h" #include "nm-manager.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-setting-macvlan.h" @@ -419,14 +420,10 @@ complete_connection(NMDevice * device, static void update_connection(NMDevice *device, NMConnection *connection) { - NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE(device); - NMSettingMacvlan * s_macvlan = nm_connection_get_setting_macvlan(connection); - int new_mode; - - if (!s_macvlan) { - s_macvlan = (NMSettingMacvlan *) nm_setting_macvlan_new(); - nm_connection_add_setting(connection, (NMSetting *) s_macvlan); - } + NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE(device); + NMSettingMacvlan * s_macvlan = + _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_MACVLAN); + int new_mode; new_mode = platform_mode_to_setting(priv->props.mode); if (new_mode != nm_setting_macvlan_get_mode(s_macvlan)) diff --git a/src/core/devices/nm-device-ppp.c b/src/core/devices/nm-device-ppp.c index 8df245bb..04051bec 100644 --- a/src/core/devices/nm-device-ppp.c +++ b/src/core/devices/nm-device-ppp.c @@ -93,28 +93,35 @@ ppp_ifindex_set(NMPPPManager *ppp_manager, int ifindex, const char *iface, gpoin } static void -ppp_ip4_config(NMPPPManager *ppp_manager, NMIP4Config *config, gpointer user_data) +_ppp_ip4_config_handle(NMDevicePpp *self) { - NMDevice * device = NM_DEVICE(user_data); - NMDevicePpp * self = NM_DEVICE_PPP(device); + NMDevice * device = NM_DEVICE(self); NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE(self); - _LOGT(LOGD_DEVICE | LOGD_PPP, "received IPv4 config from pppd"); + if (!priv->ip4_config) + return; - if (nm_device_get_state(device) == NM_DEVICE_STATE_IP_CONFIG) { - if (nm_device_activate_ip4_state_in_conf(device)) { - nm_device_activate_schedule_ip_config_result(device, - AF_INET, - NM_IP_CONFIG_CAST(config)); - return; - } - } else { - if (priv->ip4_config) - g_object_unref(priv->ip4_config); - priv->ip4_config = g_object_ref(config); + if (nm_device_get_state(device) == NM_DEVICE_STATE_IP_CONFIG + && nm_device_activate_ip4_state_in_conf(device)) { + nm_device_activate_schedule_ip_config_result( + device, + AF_INET, + NM_IP_CONFIG_CAST(g_steal_pointer(&priv->ip4_config))); + return; } } +static void +ppp_ip4_config(NMPPPManager *ppp_manager, NMIP4Config *config, gpointer user_data) +{ + NMDevicePpp * self = NM_DEVICE_PPP(user_data); + NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE(self); + + _LOGT(LOGD_DEVICE | LOGD_PPP, "received IPv4 config from pppd"); + nm_g_object_ref_set(&priv->ip4_config, config); + _ppp_ip4_config_handle(self); +} + static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { @@ -193,6 +200,15 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) return NM_ACT_STAGE_RETURN_POSTPONE; } +static gboolean +_schedule_ip_config_result(gpointer user_data) +{ + gs_unref_object NMDevicePpp *self = user_data; + + _ppp_ip4_config_handle(self); + return G_SOURCE_REMOVE; +} + static NMActStageReturn act_stage3_ip_config_start(NMDevice * device, int addr_family, @@ -203,13 +219,8 @@ act_stage3_ip_config_start(NMDevice * device, NMDevicePpp * self = NM_DEVICE_PPP(device); NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE(self); - if (priv->ip4_config) { - if (out_config) - *out_config = g_steal_pointer(&priv->ip4_config); - else - g_clear_object(&priv->ip4_config); - return NM_ACT_STAGE_RETURN_SUCCESS; - } + if (priv->ip4_config) + nm_g_idle_add(_schedule_ip_config_result, g_object_ref(self)); /* Wait IPCP termination */ return NM_ACT_STAGE_RETURN_POSTPONE; @@ -256,6 +267,8 @@ deactivate(NMDevice *device) nm_ppp_manager_stop(priv->ppp_manager, NULL, NULL, NULL); g_clear_object(&priv->ppp_manager); } + + g_clear_object(&priv->ip4_config); } static void diff --git a/src/core/devices/nm-device-private.h b/src/core/devices/nm-device-private.h index eb37b14f..b55e8b43 100644 --- a/src/core/devices/nm-device-private.h +++ b/src/core/devices/nm-device-private.h @@ -143,7 +143,7 @@ NMIP6Config *nm_device_ip6_config_new(NMDevice *self); NMIPConfig *nm_device_ip_config_new(NMDevice *self, int addr_family); -NML3ConfigData *nm_device_create_l3_config_data(NMDevice *self); +NML3ConfigData *nm_device_create_l3_config_data(NMDevice *self, NMIPConfigSource source); /*****************************************************************************/ diff --git a/src/core/devices/nm-device-tun.c b/src/core/devices/nm-device-tun.c index ebccddfc..0ab08f65 100644 --- a/src/core/devices/nm-device-tun.c +++ b/src/core/devices/nm-device-tun.c @@ -17,6 +17,7 @@ #include "libnm-platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-setting-tun.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" #define _NMLOG_DEVICE_TYPE NMDeviceTun @@ -186,11 +187,7 @@ update_connection(NMDevice *device, NMConnection *connection) return; } - s_tun = nm_connection_get_setting_tun(connection); - if (!s_tun) { - s_tun = (NMSettingTun *) nm_setting_tun_new(); - nm_connection_add_setting(connection, (NMSetting *) s_tun); - } + s_tun = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_TUN); if (mode != nm_setting_tun_get_mode(s_tun)) g_object_set(G_OBJECT(s_tun), NM_SETTING_TUN_MODE, (guint) mode, NULL); diff --git a/src/core/devices/nm-device-utils.c b/src/core/devices/nm-device-utils.c index f40ca570..2a6ab04e 100644 --- a/src/core/devices/nm-device-utils.c +++ b/src/core/devices/nm-device-utils.c @@ -10,7 +10,7 @@ /*****************************************************************************/ NM_UTILS_LOOKUP_STR_DEFINE( - nm_device_state_queued_state_to_str, + nm_device_state_queued_state_to_string, NMDeviceState, NM_UTILS_LOOKUP_DEFAULT(NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "???"), NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_STATE_UNKNOWN, @@ -41,14 +41,14 @@ NM_UTILS_LOOKUP_STR_DEFINE( NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "failed"), ); const char * -nm_device_state_to_str(NMDeviceState state) +nm_device_state_to_string(NMDeviceState state) { - return nm_device_state_queued_state_to_str(state) + return nm_device_state_queued_state_to_string(state) + NM_STRLEN(NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE); } NM_UTILS_LOOKUP_STR_DEFINE( - nm_device_state_reason_to_str, + nm_device_state_reason_to_string, NMDeviceStateReason, NM_UTILS_LOOKUP_DEFAULT(NULL), NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_STATE_REASON_UNKNOWN, "unknown"), @@ -129,7 +129,7 @@ NM_UTILS_LOOKUP_STR_DEFINE( "sriov-configuration-failed"), NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_STATE_REASON_PEER_NOT_FOUND, "peer-not-found"), ); -NM_UTILS_LOOKUP_STR_DEFINE(nm_device_mtu_source_to_str, +NM_UTILS_LOOKUP_STR_DEFINE(nm_device_mtu_source_to_string, NMDeviceMtuSource, NM_UTILS_LOOKUP_DEFAULT_NM_ASSERT("unknown"), NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_MTU_SOURCE_NONE, "none"), @@ -138,7 +138,7 @@ NM_UTILS_LOOKUP_STR_DEFINE(nm_device_mtu_source_to_str, NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_MTU_SOURCE_CONNECTION, "connection"), ); -NM_UTILS_LOOKUP_STR_DEFINE(nm_device_sys_iface_state_to_str, +NM_UTILS_LOOKUP_STR_DEFINE(nm_device_sys_iface_state_to_string, NMDeviceSysIfaceState, NM_UTILS_LOOKUP_DEFAULT_NM_ASSERT("unknown"), NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_SYS_IFACE_STATE_EXTERNAL, "external"), @@ -147,7 +147,7 @@ NM_UTILS_LOOKUP_STR_DEFINE(nm_device_sys_iface_state_to_str, NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_SYS_IFACE_STATE_REMOVED, "removed"), ); -NM_UTILS_LOOKUP_STR_DEFINE(nm_device_ip_state_to_str, +NM_UTILS_LOOKUP_STR_DEFINE(nm_device_ip_state_to_string, NMDeviceIPState, NM_UTILS_LOOKUP_DEFAULT_WARN("unknown"), NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_IP_STATE_NONE, "none"), @@ -267,7 +267,18 @@ resolve_addr_resolved_cb(NMDnsSystemdResolved * resolved, _LOG2D(info, "error resolving via systemd-resolved: %s", error->message); dbus_error = g_dbus_error_get_remote_error(error); - if (nm_streq0(dbus_error, "org.freedesktop.resolve1.DnsError.NXDOMAIN")) { + if (NM_STR_HAS_PREFIX(dbus_error, "org.freedesktop.resolve1.")) { + /* systemd-resolved is enabled but it couldn't resolve the + * address via DNS. Don't fall back to spawning the helper, + * because the helper will possibly ask again to + * systemd-resolved (via /etc/resolv.conf), potentially using + * other protocols than DNS or returning synthetic results. + * + * Consider the error as the final indication that the address + * can't be resolved. + * + * See: https://www.freedesktop.org/wiki/Software/systemd/resolved/#commonerrors + */ resolve_addr_complete(info, NULL, g_error_copy(error)); return; } diff --git a/src/core/devices/nm-device-utils.h b/src/core/devices/nm-device-utils.h index 8bc957a4..7200b0ea 100644 --- a/src/core/devices/nm-device-utils.h +++ b/src/core/devices/nm-device-utils.h @@ -5,11 +5,11 @@ /*****************************************************************************/ -const char *nm_device_state_to_str(NMDeviceState state); -const char *nm_device_state_reason_to_str(NMDeviceStateReason reason); +const char *nm_device_state_to_string(NMDeviceState state); +const char *nm_device_state_reason_to_string(NMDeviceStateReason reason); -#define nm_device_state_reason_to_str_a(reason) \ - NM_UTILS_LOOKUP_STR_A(nm_device_state_reason_to_str, reason) +#define nm_device_state_reason_to_string_a(reason) \ + NM_UTILS_LOOKUP_STR_A(nm_device_state_reason_to_string, reason) static inline NMDeviceStateReason nm_device_state_reason_check(NMDeviceStateReason reason) @@ -41,7 +41,7 @@ nm_device_state_reason_check(NMDeviceStateReason reason) #define NM_PENDING_ACTIONPREFIX_QUEUED_STATE_CHANGE "queued-state-change-" #define NM_PENDING_ACTIONPREFIX_ACTIVATION "activation-" -const char *nm_device_state_queued_state_to_str(NMDeviceState state); +const char *nm_device_state_queued_state_to_string(NMDeviceState state); /*****************************************************************************/ @@ -52,7 +52,7 @@ typedef enum { NM_DEVICE_MTU_SOURCE_CONNECTION, } NMDeviceMtuSource; -const char *nm_device_mtu_source_to_str(NMDeviceMtuSource mtu_source); +const char *nm_device_mtu_source_to_string(NMDeviceMtuSource mtu_source); /*****************************************************************************/ @@ -69,7 +69,7 @@ typedef enum _nm_packed { NM_DEVICE_SYS_IFACE_STATE_REMOVED, } NMDeviceSysIfaceState; -const char *nm_device_sys_iface_state_to_str(NMDeviceSysIfaceState sys_iface_state); +const char *nm_device_sys_iface_state_to_string(NMDeviceSysIfaceState sys_iface_state); /*****************************************************************************/ @@ -81,7 +81,7 @@ typedef enum { NM_DEVICE_IP_STATE_FAIL, } NMDeviceIPState; -const char *nm_device_ip_state_to_str(NMDeviceIPState ip_state); +const char *nm_device_ip_state_to_string(NMDeviceIPState ip_state); /*****************************************************************************/ diff --git a/src/core/devices/nm-device-vlan.c b/src/core/devices/nm-device-vlan.c index 548245f8..d1e57411 100644 --- a/src/core/devices/nm-device-vlan.c +++ b/src/core/devices/nm-device-vlan.c @@ -19,6 +19,7 @@ #include "libnm-platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-manager.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" #include "libnm-platform/nmp-object.h" #include "libnm-platform/nm-platform-utils.h" @@ -432,18 +433,13 @@ static void update_connection(NMDevice *device, NMConnection *connection) { NMDeviceVlanPrivate * priv = NM_DEVICE_VLAN_GET_PRIVATE(device); - NMSettingVlan * s_vlan = nm_connection_get_setting_vlan(connection); + NMSettingVlan * s_vlan = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_VLAN); int ifindex = nm_device_get_ifindex(device); const NMPlatformLink *plink; const NMPObject * polnk; guint vlan_id; _NMVlanFlags vlan_flags; - if (!s_vlan) { - s_vlan = (NMSettingVlan *) nm_setting_vlan_new(); - nm_connection_add_setting(connection, (NMSetting *) s_vlan); - } - polnk = nm_platform_link_get_lnk(nm_device_get_platform(device), ifindex, NM_LINK_TYPE_VLAN, diff --git a/src/core/devices/nm-device-vrf.c b/src/core/devices/nm-device-vrf.c index 2a1f42c6..c752fa0a 100644 --- a/src/core/devices/nm-device-vrf.c +++ b/src/core/devices/nm-device-vrf.c @@ -9,6 +9,7 @@ #include "nm-device-private.h" #include "nm-manager.h" #include "nm-setting-vrf.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-platform/nm-platform.h" #include "settings/nm-settings.h" @@ -199,12 +200,7 @@ static void update_connection(NMDevice *device, NMConnection *connection) { NMDeviceVrfPrivate *priv = NM_DEVICE_VRF_GET_PRIVATE(device); - NMSettingVrf * s_vrf = _nm_connection_get_setting(connection, NM_TYPE_SETTING_VRF); - - if (!s_vrf) { - s_vrf = (NMSettingVrf *) nm_setting_vrf_new(); - nm_connection_add_setting(connection, (NMSetting *) s_vrf); - } + NMSettingVrf * s_vrf = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_VRF); if (priv->props.table != nm_setting_vrf_get_table(s_vrf)) g_object_set(G_OBJECT(s_vrf), NM_SETTING_VRF_TABLE, priv->props.table, NULL); diff --git a/src/core/devices/nm-device-vxlan.c b/src/core/devices/nm-device-vxlan.c index f9dfad2a..fcd6950b 100644 --- a/src/core/devices/nm-device-vxlan.c +++ b/src/core/devices/nm-device-vxlan.c @@ -17,6 +17,7 @@ #include "settings/nm-settings.h" #include "nm-act-request.h" #include "nm-ip4-config.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" #define _NMLOG_DEVICE_TYPE NMDeviceVxlan @@ -399,14 +400,9 @@ complete_connection(NMDevice * device, static void update_connection(NMDevice *device, NMConnection *connection) { - NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE(device); - NMSettingVxlan * s_vxlan = nm_connection_get_setting_vxlan(connection); - char sbuf[NM_UTILS_INET_ADDRSTRLEN]; - - if (!s_vxlan) { - s_vxlan = (NMSettingVxlan *) nm_setting_vxlan_new(); - nm_connection_add_setting(connection, (NMSetting *) s_vxlan); - } + NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE(device); + NMSettingVxlan *s_vxlan = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_VXLAN); + char sbuf[NM_UTILS_INET_ADDRSTRLEN]; if (priv->props.id != nm_setting_vxlan_get_id(s_vxlan)) g_object_set(G_OBJECT(s_vxlan), NM_SETTING_VXLAN_ID, priv->props.id, NULL); diff --git a/src/core/devices/nm-device-wireguard.c b/src/core/devices/nm-device-wireguard.c index aa9c46eb..f129478f 100644 --- a/src/core/devices/nm-device-wireguard.c +++ b/src/core/devices/nm-device-wireguard.c @@ -11,6 +11,7 @@ #include #include "nm-setting-wireguard.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" #include "libnm-glib-aux/nm-secret-utils.h" #include "nm-device-private.h" @@ -1891,17 +1892,11 @@ static void update_connection(NMDevice *device, NMConnection *connection) { NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(device); - NMSettingWireGuard * s_wg = - NM_SETTING_WIREGUARD(nm_connection_get_setting(connection, NM_TYPE_SETTING_WIREGUARD)); - const NMPObject * obj_wg; + NMSettingWireGuard *s_wg = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_WIREGUARD); + const NMPObject * obj_wg; const NMPObjectLnkWireGuard *olnk_wg; guint i; - if (!s_wg) { - s_wg = NM_SETTING_WIREGUARD(nm_setting_wireguard_new()); - nm_connection_add_setting(connection, NM_SETTING(s_wg)); - } - g_object_set(s_wg, NM_SETTING_WIREGUARD_FWMARK, (guint) priv->lnk_curr.fwmark, diff --git a/src/core/devices/nm-device-wpan.c b/src/core/devices/nm-device-wpan.c index 73d79410..9bc43a85 100644 --- a/src/core/devices/nm-device-wpan.c +++ b/src/core/devices/nm-device-wpan.c @@ -18,6 +18,7 @@ #include "libnm-platform/nm-platform.h" #include "nm-device-factory.h" #include "nm-setting-wpan.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" #define _NMLOG_DEVICE_TYPE NMDeviceWpan @@ -71,13 +72,7 @@ complete_connection(NMDevice * device, static void update_connection(NMDevice *device, NMConnection *connection) { - NMSettingWpan *s_wpan = - NM_SETTING_WPAN(nm_connection_get_setting(connection, NM_TYPE_SETTING_WPAN)); - - if (!s_wpan) { - s_wpan = (NMSettingWpan *) nm_setting_wpan_new(); - nm_connection_add_setting(connection, (NMSetting *) s_wpan); - } + _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_WPAN); } static gboolean diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 50386d00..ea1b9647 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -185,7 +185,7 @@ typedef struct { typedef struct { NMDhcpClient *client; NMDhcpConfig *config; - gulong state_sigid; + gulong notify_sigid; guint grace_id; bool grace_pending : 1; bool was_active : 1; @@ -290,7 +290,8 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMDevice, PROP_STATISTICS_RX_BYTES, PROP_IP4_CONNECTIVITY, PROP_IP6_CONNECTIVITY, - PROP_INTERFACE_FLAGS, ); + PROP_INTERFACE_FLAGS, + PROP_PORTS, ); typedef struct _NMDevicePrivate { bool in_state_changed; @@ -316,7 +317,12 @@ typedef struct _NMDevicePrivate { guint queued_ip_config_id_x[2]; }; - GSList *pending_actions; + struct { + const char **arr; + guint len; + guint alloc; + } pending_actions; + GSList *dad6_failed_addrs; NMDBusTrackObjPath parent_device; @@ -500,6 +506,7 @@ typedef struct _NMDevicePrivate { NMDeviceStageState stage1_sriov_state : 3; bool ip_config_started : 1; + bool tc_committed : 1; char *current_stable_id; @@ -574,7 +581,6 @@ typedef struct _NMDevicePrivate { AppliedConfig ip6_config; /* Event ID of the current IP6 config from DHCP */ char * event_id; - gulong prefix_sigid; NMNDiscDHCPLevel mode; guint needed_prefixes; } dhcp6; @@ -696,15 +702,17 @@ typedef struct _NMDevicePrivate { guint sriov_reset_pending; struct { - guint timeout_id; - guint refresh_rate_ms; - guint64 tx_bytes; - guint64 rx_bytes; + GSource *timeout_source; + guint refresh_rate_ms; + guint64 tx_bytes; + guint64 rx_bytes; } stats; bool mtu_force_set_done : 1; NMOptionBool promisc_reset; + + GVariant *ports_variant; /* Array of port devices D-Bus path */ } NMDevicePrivate; G_DEFINE_ABSTRACT_TYPE(NMDevice, nm_device, NM_TYPE_DBUS_OBJECT) @@ -1190,6 +1198,29 @@ _prop_get_connection_llmnr(NMDevice *self) NM_SETTING_CONNECTION_LLMNR_DEFAULT); } +static NMSettingConnectionDnsOverTls +_prop_get_connection_dns_over_tls(NMDevice *self) +{ + NMConnection * connection; + NMSettingConnectionDnsOverTls dns_over_tls = NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT; + + g_return_val_if_fail(NM_IS_DEVICE(self), NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT); + + connection = nm_device_get_applied_connection(self); + if (connection) + dns_over_tls = nm_setting_connection_get_dns_over_tls( + nm_connection_get_setting_connection(connection)); + if (dns_over_tls != NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT) + return dns_over_tls; + + return nm_config_data_get_connection_default_int64(NM_CONFIG_GET_DATA, + NM_CON_DEFAULT("connection.dns-over-tls"), + self, + NM_SETTING_CONNECTION_DNS_OVER_TLS_NO, + NM_SETTING_CONNECTION_DNS_OVER_TLS_YES, + NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT); +} + static guint32 _prop_get_ipvx_route_table(NMDevice *self, int addr_family) { @@ -2407,7 +2438,7 @@ nm_device_ip_config_new(NMDevice *self, int addr_family) } NML3ConfigData * -nm_device_create_l3_config_data(NMDevice *self) +nm_device_create_l3_config_data(NMDevice *self, NMIPConfigSource source) { int ifindex; @@ -2417,7 +2448,7 @@ nm_device_create_l3_config_data(NMDevice *self) if (ifindex <= 0) g_return_val_if_reached(NULL); - return nm_l3_config_data_new(nm_device_get_multi_index(self), ifindex); + return nm_l3_config_data_new(nm_device_get_multi_index(self), ifindex, source); } static void @@ -2554,8 +2585,8 @@ nm_device_sys_iface_state_set(NMDevice *self, NMDeviceSysIfaceState sys_iface_st if (priv->sys_iface_state != sys_iface_state) { _LOGT(LOGD_DEVICE, "sys-iface-state: %s -> %s", - nm_device_sys_iface_state_to_str(priv->sys_iface_state), - nm_device_sys_iface_state_to_str(sys_iface_state)); + nm_device_sys_iface_state_to_string(priv->sys_iface_state), + nm_device_sys_iface_state_to_string(sys_iface_state)); priv->sys_iface_state_ = sys_iface_state; } @@ -2741,7 +2772,7 @@ nm_device_sysctl_ip_conf_get_int_checked(NMDevice * self, } static void -set_ipv6_token(NMDevice *self, NMUtilsIPv6IfaceId iid, const char *token_str) +set_ipv6_token(NMDevice *self, const NMUtilsIPv6IfaceId *iid, const char *token_str) { NMPlatform * platform; int ifindex; @@ -2757,7 +2788,7 @@ set_ipv6_token(NMDevice *self, NMUtilsIPv6IfaceId iid, const char *token_str) ifindex = nm_device_get_ip_ifindex(self); link = nm_platform_link_get(platform, ifindex); - if (link && link->inet6_token.id == iid.id) { + if (link && link->inet6_token.id == iid->id) { _LOGT(LOGD_DEVICE | LOGD_IP6, "token %s already set", token_str); return; } @@ -2905,7 +2936,7 @@ _set_ip_state(NMDevice *self, int addr_family, NMDeviceIPState new_state) "ip%c-state: set to %d (%s)", nm_utils_addr_family_to_char(addr_family), (int) new_state, - nm_device_ip_state_to_str(new_state)); + nm_device_ip_state_to_string(new_state)); priv->ip_state_x_[IS_IPv4] = new_state; @@ -3141,8 +3172,9 @@ _set_ip_ifindex(NMDevice *self, int ifindex, const char *ifname) nm_platform_process_events_ensure_link(platform, priv->ip_ifindex, priv->ip_iface); - if (nm_platform_kernel_support_get(NM_PLATFORM_KERNEL_SUPPORT_TYPE_USER_IPV6LL)) - nm_platform_link_set_user_ipv6ll_enabled(platform, priv->ip_ifindex, TRUE); + nm_platform_link_set_inet6_addr_gen_mode(platform, + priv->ip_ifindex, + NM_IN6_ADDR_GEN_MODE_NONE); if (!nm_platform_link_is_up(platform, priv->ip_ifindex)) nm_platform_link_change_flags(platform, priv->ip_ifindex, IFF_UP, TRUE); @@ -3444,7 +3476,7 @@ _stats_set_refresh_rate(NMDevice *self, guint refresh_rate_ms) if (_stats_refresh_rate_real(old_rate) == refresh_rate_ms) return; - nm_clear_g_source(&priv->stats.timeout_id); + nm_clear_g_source_inst(&priv->stats.timeout_source); if (!refresh_rate_ms) return; @@ -3456,7 +3488,7 @@ _stats_set_refresh_rate(NMDevice *self, guint refresh_rate_ms) if (ifindex > 0) nm_platform_link_refresh(nm_device_get_platform(self), ifindex); - priv->stats.timeout_id = g_timeout_add(refresh_rate_ms, _stats_timeout_cb, self); + priv->stats.timeout_source = nm_g_timeout_add_source(refresh_rate_ms, _stats_timeout_cb, self); } /*****************************************************************************/ @@ -4509,7 +4541,7 @@ concheck_cb(NMConnectivity * connectivity, seq = handle->seq; _LOGT(LOGD_CONCHECK, - "connectivity: [Ipv%c] complete check (seq:%llu, state:%s)", + "connectivity: [IPv%c] complete check (seq:%llu, state:%s)", nm_utils_addr_family_to_char(handle->addr_family), (long long unsigned) handle->seq, nm_connectivity_state_to_string(state)); @@ -5803,7 +5835,7 @@ nm_device_update_from_platform_link(NMDevice *self, const NMPlatformLink *plink) _notify(self, PROP_PATH); } - if (plink && !nm_str_is_empty(plink->name) && nm_utils_strdup_reset(&priv->iface_, plink->name)) + if (plink && !nm_str_is_empty(plink->name) && nm_strdup_reset(&priv->iface_, plink->name)) _notify(self, PROP_IFACE); str = plink ? plink->driver : NULL; @@ -5976,9 +6008,10 @@ config_changed(NMConfig * config, { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - if (priv->state <= NM_DEVICE_STATE_DISCONNECTED || priv->state > NM_DEVICE_STATE_ACTIVATED) { + if (priv->state <= NM_DEVICE_STATE_DISCONNECTED || priv->state >= NM_DEVICE_STATE_ACTIVATED) { priv->ignore_carrier = nm_config_data_get_ignore_carrier(config_data, self); - if (NM_FLAGS_HAS(changes, NM_CONFIG_CHANGE_VALUES)) + if (NM_FLAGS_HAS(changes, NM_CONFIG_CHANGE_VALUES) + && !nm_device_get_applied_setting(self, NM_TYPE_SETTING_SRIOV)) device_init_static_sriov_num_vfs(self); } } @@ -6023,7 +6056,7 @@ realize_start_setup(NMDevice * self, NMPlatform * platform; NMDeviceCapabilities capabilities = 0; NMConfig * config; - guint real_rate; + guint refresh_rate_ms; gboolean unmanaged; /* plink is a NMPlatformLink type, however, we require it to come from the platform @@ -6087,8 +6120,8 @@ realize_start_setup(NMDevice * self, if (priv->firmware_version) _notify(self, PROP_FIRMWARE_VERSION); - if (nm_platform_kernel_support_get(NM_PLATFORM_KERNEL_SUPPORT_TYPE_USER_IPV6LL)) - priv->ipv6ll_handle = nm_platform_link_get_user_ipv6ll_enabled(platform, priv->ifindex); + priv->ipv6ll_handle = (nm_platform_link_get_inet6_addr_gen_mode(platform, priv->ifindex) + == NM_IN6_ADDR_GEN_MODE_NONE); if (nm_platform_link_supports_sriov(platform, priv->ifindex)) capabilities |= NM_DEVICE_CAP_SRIOV; @@ -6131,10 +6164,12 @@ realize_start_setup(NMDevice * self, nm_device_set_carrier_from_platform(self); - nm_assert(!priv->stats.timeout_id); - real_rate = _stats_refresh_rate_real(priv->stats.refresh_rate_ms); - if (real_rate) - priv->stats.timeout_id = g_timeout_add(real_rate, _stats_timeout_cb, self); + nm_assert(!priv->stats.timeout_source); + refresh_rate_ms = _stats_refresh_rate_real(priv->stats.refresh_rate_ms); + if (refresh_rate_ms > 0) { + priv->stats.timeout_source = + nm_g_timeout_add_source(refresh_rate_ms, _stats_timeout_cb, self); + } klass->realize_start_notify(self, plink); @@ -6320,7 +6355,7 @@ nm_device_unrealize(NMDevice *self, gboolean remove_resources, GError **error) _notify(self, PROP_PHYSICAL_PORT_ID); } - nm_clear_g_source(&priv->stats.timeout_id); + nm_clear_g_source_inst(&priv->stats.timeout_source); _stats_update_counters(self, 0, 0); priv->hw_addr_len_ = 0; @@ -6442,9 +6477,9 @@ slave_state_changed(NMDevice * slave, "slave %s state change %d (%s) -> %d (%s)", nm_device_get_iface(slave), slave_old_state, - nm_device_state_to_str(slave_old_state), + nm_device_state_to_string(slave_old_state), slave_new_state, - nm_device_state_to_str(slave_new_state)); + nm_device_state_to_string(slave_new_state)); /* Don't try to enslave slaves until the master is ready */ if (priv->state < NM_DEVICE_STATE_CONFIG) @@ -6788,7 +6823,9 @@ nm_device_slave_notify_enslave(NMDevice *self, gboolean success) priv->is_enslaved = TRUE; _notify(self, PROP_MASTER); - _notify(priv->master, PROP_SLAVES); + + nm_clear_pointer(&NM_DEVICE_GET_PRIVATE(priv->master)->ports_variant, g_variant_unref); + nm_gobject_notify_together(priv->master, PROP_PORTS, PROP_SLAVES); } else if (activating) { _LOGW(LOGD_DEVICE, "Activation: connection '%s' could not be enslaved", @@ -6852,8 +6889,11 @@ nm_device_slave_notify_release(NMDevice *self, NMDeviceStateReason reason) if (priv->is_enslaved) { priv->is_enslaved = FALSE; + _notify(self, PROP_MASTER); - _notify(priv->master, PROP_SLAVES); + + nm_clear_pointer(&NM_DEVICE_GET_PRIVATE(priv->master)->ports_variant, g_variant_unref); + nm_gobject_notify_together(priv->master, PROP_PORTS, PROP_SLAVES); } } @@ -7339,7 +7379,7 @@ nm_device_generate_connection(NMDevice *self, NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, NM_IN6_ADDR_GEN_MODE_EUI64, NM_SETTING_IP6_CONFIG_TOKEN, - nm_utils_inet6_interface_identifier_to_token(pllink->inet6_token, sbuf), + nm_utils_inet6_interface_identifier_to_token(&pllink->inet6_token, sbuf), NULL); } } @@ -7756,7 +7796,8 @@ recheck_available(gpointer user_data) now_available ? "" : "not ", new_state == NM_DEVICE_STATE_UNAVAILABLE ? "no change required for" : "will transition to", - nm_device_state_to_str(new_state == NM_DEVICE_STATE_UNAVAILABLE ? state : new_state)); + nm_device_state_to_string(new_state == NM_DEVICE_STATE_UNAVAILABLE ? state + : new_state)); priv->recheck_available.available_reason = NM_DEVICE_STATE_REASON_NONE; priv->recheck_available.unavailable_reason = NM_DEVICE_STATE_REASON_NONE; @@ -8259,7 +8300,7 @@ activate_stage1_device_prepare(NMDevice *self) priv->master_ready_id = g_signal_connect(active, "notify::" NM_ACTIVE_CONNECTION_INT_MASTER_READY, - (GCallback) master_ready_cb, + G_CALLBACK(master_ready_cb), self); } return; @@ -8478,10 +8519,7 @@ tc_commit(NMDevice *self) qdiscs = nm_utils_qdiscs_from_tc_setting(platform, s_tc, ip_ifindex); tfilters = nm_utils_tfilters_from_tc_setting(platform, s_tc, ip_ifindex); - if (!nm_platform_qdisc_sync(platform, ip_ifindex, qdiscs)) - return FALSE; - - if (!nm_platform_tfilter_sync(platform, ip_ifindex, tfilters)) + if (!nm_platform_tc_sync(platform, ip_ifindex, qdiscs, tfilters)) return FALSE; return TRUE; @@ -8511,13 +8549,14 @@ activate_stage2_device_config(NMDevice *self) _ethtool_state_set(self); if (!nm_device_sys_iface_state_is_external_or_assume(self)) { - if (!tc_commit(self)) { - _LOGW(LOGD_IP6, "failed applying traffic control rules"); + if (!priv->tc_committed && !tc_commit(self)) { + _LOGW(LOGD_DEVICE, "failed applying traffic control rules"); nm_device_state_changed(self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_CONFIG_FAILED); return; } + priv->tc_committed = TRUE; } _routing_rules_sync(self, NM_TERNARY_TRUE); @@ -8981,6 +9020,7 @@ ensure_con_ip_config(NMDevice *self, int addr_family) nm_connection_get_setting_ip4_config(connection), _prop_get_connection_mdns(self), _prop_get_connection_llmnr(self), + _prop_get_connection_dns_over_tls(self), nm_device_get_route_table(self, addr_family), nm_device_get_route_metric(self, addr_family)); } else { @@ -9028,7 +9068,7 @@ dhcp4_cleanup(NMDevice *self, CleanupType cleanup_type, gboolean release) if (priv->dhcp_data_4.client) { /* Stop any ongoing DHCP transaction on this device */ - nm_clear_g_signal_handler(priv->dhcp_data_4.client, &priv->dhcp_data_4.state_sigid); + nm_clear_g_signal_handler(priv->dhcp_data_4.client, &priv->dhcp_data_4.notify_sigid); if (cleanup_type == CLEANUP_TYPE_DECONFIGURE || cleanup_type == CLEANUP_TYPE_REMOVED) nm_dhcp_client_stop(priv->dhcp_data_4.client, release); @@ -9251,7 +9291,7 @@ ip_config_merge_and_apply(NMDevice *self, int addr_family, gboolean commit) if (commit && priv->ndisc_started && ip6_addr_gen_token && nm_utils_ipv6_interface_identifier_get_from_token(&iid, ip6_addr_gen_token)) { - set_ipv6_token(self, iid, ip6_addr_gen_token); + set_ipv6_token(self, &iid, ip6_addr_gen_token); } } @@ -9291,7 +9331,7 @@ dhcp4_lease_change(NMDevice *self, NMIP4Config *config, gboolean bound) return FALSE; } - nm_dispatcher_call_device(NM_DISPATCHER_ACTION_DHCP4_CHANGE, self, NULL, NULL, NULL, NULL); + nm_dispatcher_call_device(NM_DISPATCHER_ACTION_DHCP_CHANGE_4, self, NULL, NULL, NULL, NULL); return TRUE; } @@ -9373,7 +9413,7 @@ dhcp4_fail(NMDevice *self, NMDhcpState dhcp_state) _LOGD(LOGD_DHCP4, "DHCPv4 failed (ip_state %s, was_active %d)", - nm_device_ip_state_to_str(priv->ip_state_4), + nm_device_ip_state_to_string(priv->ip_state_4), priv->dhcp_data_4.was_active); /* The client is always left running after a failure. */ @@ -9429,21 +9469,27 @@ dhcp4_dad_cb(NMDevice *self, NMIP4Config **configs, gboolean success) } static void -dhcp4_state_changed(NMDhcpClient *client, - NMDhcpState state, - NMIP4Config * ip4_config, - GHashTable * options, - gpointer user_data) +dhcp4_notify(NMDhcpClient *client, const NMDhcpClientNotifyData *notify_data, NMDevice *self) { - NMDevice * self = NM_DEVICE(user_data); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMIP4Config * manual, **configs; + NMIP4Config * manual; + NMIP4Config ** configs; NMConnection * connection; + NMDhcpState state; + NMIP4Config * ip4_config; + GHashTable * options; + + nm_assert(nm_dhcp_client_get_addr_family(client) == AF_INET); + nm_assert(notify_data); + nm_assert(notify_data->notify_type == NM_DHCP_CLIENT_NOTIFY_TYPE_STATE_CHANGED); - g_return_if_fail(nm_dhcp_client_get_addr_family(client) == AF_INET); - g_return_if_fail(!ip4_config || NM_IS_IP4_CONFIG(ip4_config)); + state = notify_data->state_changed.dhcp_state; + ip4_config = NM_IP4_CONFIG(notify_data->state_changed.ip_config); + options = notify_data->state_changed.options; - _LOGD(LOGD_DHCP4, "new DHCPv4 client state %d", state); + nm_assert(!ip4_config || NM_IS_IP4_CONFIG(ip4_config)); + + _LOGD(LOGD_DHCP4, "new DHCPv4 client state %d", (int) state); switch (state) { case NM_DHCP_STATE_BOUND: @@ -9479,6 +9525,7 @@ dhcp4_state_changed(NMDhcpClient *client, nm_connection_get_setting_ip4_config(connection), NM_SETTING_CONNECTION_MDNS_DEFAULT, NM_SETTING_CONNECTION_LLMNR_DEFAULT, + NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT, nm_device_get_route_table(self, AF_INET), nm_device_get_route_metric(self, AF_INET)); @@ -9594,10 +9641,10 @@ dhcp4_start(NMDevice *self) return NM_ACT_STAGE_RETURN_FAILURE; } - priv->dhcp_data_4.state_sigid = g_signal_connect(priv->dhcp_data_4.client, - NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED, - G_CALLBACK(dhcp4_state_changed), - self); + priv->dhcp_data_4.notify_sigid = g_signal_connect(priv->dhcp_data_4.client, + NM_DHCP_CLIENT_NOTIFY, + G_CALLBACK(dhcp4_notify), + self); if (nm_device_sys_iface_state_is_external_or_assume(self)) priv->dhcp_data_4.was_active = TRUE; @@ -9768,8 +9815,7 @@ dhcp6_cleanup(NMDevice *self, CleanupType cleanup_type, gboolean release) priv->dhcp_data_6.grace_pending = FALSE; if (priv->dhcp_data_6.client) { - nm_clear_g_signal_handler(priv->dhcp_data_6.client, &priv->dhcp_data_6.state_sigid); - nm_clear_g_signal_handler(priv->dhcp_data_6.client, &priv->dhcp6.prefix_sigid); + nm_clear_g_signal_handler(priv->dhcp_data_6.client, &priv->dhcp_data_6.notify_sigid); if (cleanup_type == CLEANUP_TYPE_DECONFIGURE || cleanup_type == CLEANUP_TYPE_REMOVED) nm_dhcp_client_stop(priv->dhcp_data_6.client, release); @@ -9805,7 +9851,7 @@ dhcp6_lease_change(NMDevice *self) return FALSE; } - nm_dispatcher_call_device(NM_DISPATCHER_ACTION_DHCP6_CHANGE, self, NULL, NULL, NULL, NULL); + nm_dispatcher_call_device(NM_DISPATCHER_ACTION_DHCP_CHANGE_6, self, NULL, NULL, NULL, NULL); return TRUE; } @@ -9818,7 +9864,7 @@ dhcp6_fail(NMDevice *self, NMDhcpState dhcp_state) _LOGD(LOGD_DHCP6, "DHCPv6 failed (ip_state %s, was_active %d)", - nm_device_ip_state_to_str(priv->ip_state_6), + nm_device_ip_state_to_string(priv->ip_state_6), priv->dhcp_data_6.was_active); /* The client is always left running after a failure. */ @@ -9869,20 +9915,34 @@ clear_config: } static void -dhcp6_state_changed(NMDhcpClient *client, - NMDhcpState state, - NMIP6Config * ip6_config, - GHashTable * options, - gpointer user_data) +dhcp6_notify(NMDhcpClient *client, const NMDhcpClientNotifyData *notify_data, NMDevice *self) { - NMDevice * self = NM_DEVICE(user_data); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); gs_free char * event_id = NULL; + NMDhcpState state; + NMIP6Config * ip6_config; + GHashTable * options; + + nm_assert(nm_dhcp_client_get_addr_family(client) == AF_INET6); + nm_assert(notify_data); + + if (notify_data->notify_type == NM_DHCP_CLIENT_NOTIFY_TYPE_PREFIX_DELEGATED) { + /* Just re-emit. The device just contributes the prefix to the + * pool in NMPolicy, which decides about subnet allocation + * on the shared devices. */ + g_signal_emit(self, signals[IP6_PREFIX_DELEGATED], 0, notify_data->prefix_delegated.prefix); + return; + } + + nm_assert(notify_data->notify_type == NM_DHCP_CLIENT_NOTIFY_TYPE_STATE_CHANGED); - g_return_if_fail(nm_dhcp_client_get_addr_family(client) == AF_INET6); - g_return_if_fail(!ip6_config || NM_IS_IP6_CONFIG(ip6_config)); + state = notify_data->state_changed.dhcp_state; + ip6_config = NM_IP6_CONFIG(notify_data->state_changed.ip_config); + options = notify_data->state_changed.options; - _LOGD(LOGD_DHCP6, "new DHCPv6 client state %d", state); + nm_assert(!ip6_config || NM_IS_IP6_CONFIG(ip6_config)); + + _LOGD(LOGD_DHCP6, "new DHCPv6 client state %d", (int) state); switch (state) { case NM_DHCP_STATE_BOUND: @@ -9962,17 +10022,6 @@ dhcp6_state_changed(NMDhcpClient *client, } } -static void -dhcp6_prefix_delegated(NMDhcpClient *client, NMPlatformIP6Address *prefix, gpointer user_data) -{ - NMDevice *self = NM_DEVICE(user_data); - - /* Just re-emit. The device just contributes the prefix to the - * pool in NMPolicy, which decides about subnet allocation - * on the shared devices. */ - g_signal_emit(self, signals[IP6_PREFIX_DELEGATED], 0, prefix); -} - /*****************************************************************************/ static gboolean @@ -10054,14 +10103,10 @@ dhcp6_start_with_link_ready(NMDevice *self, NMConnection *connection) return FALSE; } - priv->dhcp_data_6.state_sigid = g_signal_connect(priv->dhcp_data_6.client, - NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED, - G_CALLBACK(dhcp6_state_changed), - self); - priv->dhcp6.prefix_sigid = g_signal_connect(priv->dhcp_data_6.client, - NM_DHCP_CLIENT_SIGNAL_PREFIX_DELEGATED, - G_CALLBACK(dhcp6_prefix_delegated), - self); + priv->dhcp_data_6.notify_sigid = g_signal_connect(priv->dhcp_data_6.client, + NM_DHCP_CLIENT_NOTIFY, + G_CALLBACK(dhcp6_notify), + self); if (nm_device_sys_iface_state_is_external_or_assume(self)) priv->dhcp_data_6.was_active = TRUE; @@ -10321,12 +10366,12 @@ check_and_add_ipv6ll_addr(NMDevice *self) const char * stable_id; stable_id = _prop_get_connection_stable_id(self, connection, &stable_type); - if (!nm_utils_ipv6_addr_set_stable_privacy(stable_type, - &lladdr, - nm_device_get_iface(self), - stable_id, - priv->linklocal6_dad_counter++, - &error)) { + if (!nm_utils_ipv6_addr_set_stable_privacy_may_fail(stable_type, + &lladdr, + nm_device_get_iface(self), + stable_id, + priv->linklocal6_dad_counter++, + &error)) { _LOGW(LOGD_IP6, "linklocal6: failed to generate an address: %s", error->message); g_clear_error(&error); linklocal6_failed(self); @@ -10348,7 +10393,7 @@ check_and_add_ipv6ll_addr(NMDevice *self) _LOGW(LOGD_IP6, "linklocal6: failed to get interface identifier; IPv6 cannot continue"); return; } - nm_utils_ipv6_addr_set_interface_identifier(&lladdr, iid); + nm_utils_ipv6_addr_set_interface_identifier(&lladdr, &iid); addr_type = "EUI-64"; } @@ -10616,9 +10661,9 @@ _commit_mtu(NMDevice *self, const NMIP4Config *config) _LOGT(LOGD_DEVICE, "mtu: value %u from source '%s' (%u), current source '%s' (%u)%s", (guint) mtu, - nm_device_mtu_source_to_str(source), + nm_device_mtu_source_to_string(source), (guint) source, - nm_device_mtu_source_to_str(priv->mtu_source), + nm_device_mtu_source_to_string(priv->mtu_source), (guint) priv->mtu_source, force ? " (forced)" : ""); } @@ -10801,7 +10846,7 @@ nm_device_commit_mtu(NMDevice *self) } else _LOGT(LOGD_DEVICE, "mtu: commit-mtu... skip due to state %s", - nm_device_state_to_str(state)); + nm_device_state_to_string(state)); } static void @@ -10809,66 +10854,68 @@ ndisc_config_changed(NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_int { NMNDiscConfigMap changed = changed_int; NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); + int ifindex; guint i; g_return_if_fail(priv->act_request.obj); + ifindex = nm_device_get_ip_ifindex(self); + + if (ifindex <= 0 + || (applied_config_get_current(&priv->ac_ip6_config) + && ifindex + != nm_ip_config_get_ifindex(applied_config_get_current(&priv->ac_ip6_config)))) + applied_config_clear(&priv->ac_ip6_config); + + if (ifindex <= 0) + return; + if (!applied_config_get_current(&priv->ac_ip6_config)) applied_config_init_new(&priv->ac_ip6_config, self, AF_INET6); if (changed & NM_NDISC_CONFIG_ADDRESSES) { - guint8 plen; guint32 ifa_flags; /* Check, whether kernel is recent enough to help user space handling RA. * If it's not supported, we have no ipv6-privacy and must add autoconf * addresses as /128. The reason for the /128 is to prevent the kernel * from adding a prefix route for this address. */ - ifa_flags = 0; - if (nm_platform_kernel_support_get(NM_PLATFORM_KERNEL_SUPPORT_TYPE_EXTENDED_IFA_FLAGS)) { - ifa_flags |= IFA_F_NOPREFIXROUTE; - if (NM_IN_SET(priv->ndisc_use_tempaddr, - NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, - NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR)) - ifa_flags |= IFA_F_MANAGETEMPADDR; - plen = 64; - } else - plen = 128; + ifa_flags = IFA_F_NOPREFIXROUTE; + if (NM_IN_SET(priv->ndisc_use_tempaddr, + NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, + NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR)) + ifa_flags |= IFA_F_MANAGETEMPADDR; nm_ip6_config_reset_addresses_ndisc((NMIP6Config *) priv->ac_ip6_config.orig, rdata->addresses, rdata->addresses_n, - plen, + 64, ifa_flags); if (priv->ac_ip6_config.current) { nm_ip6_config_reset_addresses_ndisc((NMIP6Config *) priv->ac_ip6_config.current, rdata->addresses, rdata->addresses_n, - plen, + 64, ifa_flags); } } if (NM_FLAGS_ANY(changed, NM_NDISC_CONFIG_ROUTES | NM_NDISC_CONFIG_GATEWAYS)) { - nm_ip6_config_reset_routes_ndisc( - (NMIP6Config *) priv->ac_ip6_config.orig, - rdata->gateways, - rdata->gateways_n, - rdata->routes, - rdata->routes_n, - nm_device_get_route_table(self, AF_INET6), - nm_device_get_route_metric(self, AF_INET6), - nm_platform_kernel_support_get(NM_PLATFORM_KERNEL_SUPPORT_TYPE_RTA_PREF)); + nm_ip6_config_reset_routes_ndisc((NMIP6Config *) priv->ac_ip6_config.orig, + rdata->gateways, + rdata->gateways_n, + rdata->routes, + rdata->routes_n, + nm_device_get_route_table(self, AF_INET6), + nm_device_get_route_metric(self, AF_INET6)); if (priv->ac_ip6_config.current) { - nm_ip6_config_reset_routes_ndisc( - (NMIP6Config *) priv->ac_ip6_config.current, - rdata->gateways, - rdata->gateways_n, - rdata->routes, - rdata->routes_n, - nm_device_get_route_table(self, AF_INET6), - nm_device_get_route_metric(self, AF_INET6), - nm_platform_kernel_support_get(NM_PLATFORM_KERNEL_SUPPORT_TYPE_RTA_PREF)); + nm_ip6_config_reset_routes_ndisc((NMIP6Config *) priv->ac_ip6_config.current, + rdata->gateways, + rdata->gateways_n, + rdata->routes, + rdata->routes_n, + nm_device_get_route_table(self, AF_INET6), + nm_device_get_route_metric(self, AF_INET6)); } } @@ -11024,6 +11071,11 @@ addrconf6_start(NMDevice *self, NMSettingIP6ConfigPrivacy use_tempaddr) guint32 ra_timeout; guint32 default_ra_timeout; + if (!g_file_test("/proc/sys/net/ipv6", G_FILE_TEST_IS_DIR)) { + _LOGI(LOGD_IP6, "addrconf6: kernel does not support IPv6"); + return FALSE; + } + connection = nm_device_get_applied_connection(self); g_assert(connection); @@ -11037,17 +11089,17 @@ addrconf6_start(NMDevice *self, NMSettingIP6ConfigPrivacy use_tempaddr) g_assert(s_ip6); if (nm_streq(nm_device_get_effective_ip_config_method(self, AF_INET6), - NM_SETTING_IP4_CONFIG_METHOD_SHARED)) + NM_SETTING_IP6_CONFIG_METHOD_SHARED)) node_type = NM_NDISC_NODE_TYPE_ROUTER; else node_type = NM_NDISC_NODE_TYPE_HOST; - nm_lndp_ndisc_get_sysctl(nm_device_get_platform(self), - nm_device_get_ip_iface(self), - &max_addresses, - &router_solicitations, - &router_solicitation_interval, - &default_ra_timeout); + nm_ndisc_get_sysctl(nm_device_get_platform(self), + nm_device_get_ip_iface(self), + &max_addresses, + &router_solicitations, + &router_solicitation_interval, + &default_ra_timeout); if (node_type == NM_NDISC_NODE_TYPE_ROUTER) ra_timeout = 0u; @@ -11078,15 +11130,6 @@ addrconf6_start(NMDevice *self, NMSettingIP6ConfigPrivacy use_tempaddr) priv->ndisc_use_tempaddr = use_tempaddr; - if (NM_IN_SET(use_tempaddr, - NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, - NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR) - && !nm_platform_kernel_support_get(NM_PLATFORM_KERNEL_SUPPORT_TYPE_EXTENDED_IFA_FLAGS)) { - _LOGW(LOGD_IP6, - "The kernel does not support extended IFA_FLAGS needed by NM for " - "IPv6 private addresses. This feature is not available"); - } - /* ensure link local is ready... */ if (!linklocal6_start(self)) { /* wait for the LL address to show up */ @@ -11181,21 +11224,20 @@ set_nm_ipv6ll(NMDevice *self, gboolean enable) NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); int ifindex = nm_device_get_ip_ifindex(self); - if (!nm_platform_kernel_support_get(NM_PLATFORM_KERNEL_SUPPORT_TYPE_USER_IPV6LL)) - return; - priv->ipv6ll_handle = enable; if (ifindex > 0) { - const char *detail = enable ? "enable" : "disable"; - int r; + int r; - _LOGD(LOGD_IP6, "will %s userland IPv6LL", detail); - r = nm_platform_link_set_user_ipv6ll_enabled(nm_device_get_platform(self), ifindex, enable); + _LOGD(LOGD_IP6, "will %s userland IPv6LL", enable ? "enable" : "disable"); + r = nm_platform_link_set_inet6_addr_gen_mode(nm_device_get_platform(self), + ifindex, + enable ? NM_IN6_ADDR_GEN_MODE_NONE + : NM_IN6_ADDR_GEN_MODE_EUI64); if (r < 0) { _NMLOG(NM_IN_SET(r, -NME_PL_NOT_FOUND, -NME_PL_OPNOTSUPP) ? LOGL_DEBUG : LOGL_WARN, LOGD_IP6, "failed to %s userspace IPv6LL address handling (%s)", - detail, + enable ? "enable" : "disable", nm_strerror(r)); } @@ -11310,6 +11352,7 @@ act_stage3_ip_config_start(NMDevice * self, nm_connection_get_setting_ip4_config(connection), NM_SETTING_CONNECTION_MDNS_DEFAULT, NM_SETTING_CONNECTION_LLMNR_DEFAULT, + NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT, nm_device_get_route_table(self, AF_INET), nm_device_get_route_metric(self, AF_INET)); configs = g_new0(NMIP4Config *, 2); @@ -11521,45 +11564,6 @@ nm_device_activate_stage3_ip_start(NMDevice *self, int addr_family) return TRUE; } -/* - * activate_stage3_ip_config_start - * - * Begin automatic/manual IP configuration - * - */ -static void -activate_stage3_ip_config_start(NMDevice *self) -{ - int ifindex; - - _set_ip_state(self, AF_INET, NM_DEVICE_IP_STATE_WAIT); - _set_ip_state(self, AF_INET6, NM_DEVICE_IP_STATE_WAIT); - - _active_connection_set_state_flags(self, NM_ACTIVATION_STATE_FLAG_LAYER2_READY); - - nm_device_state_changed(self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE); - - /* Device should be up before we can do anything with it */ - if ((ifindex = nm_device_get_ip_ifindex(self)) > 0 - && !nm_platform_link_is_up(nm_device_get_platform(self), ifindex)) - _LOGW(LOGD_DEVICE, - "interface %s not up for IP configuration", - nm_device_get_ip_iface(self)); - - if (nm_device_activate_ip4_state_in_wait(self) - && !nm_device_activate_stage3_ip_start(self, AF_INET)) - return; - - if (nm_device_activate_ip6_state_in_wait(self) - && !nm_device_activate_stage3_ip_start(self, AF_INET6)) - return; - - /* Proxy */ - nm_device_set_proxy_config(self, NULL); - - check_ip_state(self, TRUE, TRUE); -} - static void fw_change_zone_cb(NMFirewalldManager * firewalld_manager, NMFirewalldManagerCallId *call_id, @@ -11642,20 +11646,19 @@ fw_change_zone(NMDevice *self) } /* - * nm_device_activate_schedule_stage3_ip_config_start + * activate_stage3_ip_config_start + * + * Begin automatic/manual IP configuration * - * Schedule IP configuration start */ -void -nm_device_activate_schedule_stage3_ip_config_start(NMDevice *self) +static void +activate_stage3_ip_config_start(NMDevice *self) { - NMDevicePrivate *priv; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); int ifindex; - g_return_if_fail(NM_IS_DEVICE(self)); - - priv = NM_DEVICE_GET_PRIVATE(self); g_return_if_fail(priv->act_request.obj); + ifindex = nm_device_get_ip_ifindex(self); /* Add the interface to the specified firewall zone */ @@ -11676,6 +11679,51 @@ nm_device_activate_schedule_stage3_ip_config_start(NMDevice *self) nm_assert(ifindex <= 0 || priv->fw_state == FIREWALL_STATE_INITIALIZED); + _set_ip_state(self, AF_INET, NM_DEVICE_IP_STATE_WAIT); + _set_ip_state(self, AF_INET6, NM_DEVICE_IP_STATE_WAIT); + + _active_connection_set_state_flags(self, NM_ACTIVATION_STATE_FLAG_LAYER2_READY); + + nm_device_state_changed(self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE); + + /* Device should be up before we can do anything with it */ + if (!nm_device_sys_iface_state_is_external(self) + && (ifindex = nm_device_get_ip_ifindex(self)) > 0 + && !nm_platform_link_is_up(nm_device_get_platform(self), ifindex)) + _LOGW(LOGD_DEVICE, + "interface %s not up for IP configuration", + nm_device_get_ip_iface(self)); + + if (nm_device_activate_ip4_state_in_wait(self) + && !nm_device_activate_stage3_ip_start(self, AF_INET)) + return; + + if (nm_device_activate_ip6_state_in_wait(self) + && !nm_device_activate_stage3_ip_start(self, AF_INET6)) + return; + + /* Proxy */ + nm_device_set_proxy_config(self, NULL); + + check_ip_state(self, TRUE, TRUE); +} + +/* + * nm_device_activate_schedule_stage3_ip_config_start + * + * Schedule IP configuration start + */ +void +nm_device_activate_schedule_stage3_ip_config_start(NMDevice *self) +{ + NMDevicePrivate *priv; + + g_return_if_fail(NM_IS_DEVICE(self)); + + priv = NM_DEVICE_GET_PRIVATE(self); + + g_return_if_fail(priv->act_request.obj); + activation_source_schedule(self, activate_stage3_ip_config_start, AF_INET); } @@ -11728,22 +11776,23 @@ activate_stage4_ip_config_timeout_6(NMDevice *self) activate_stage4_ip_config_timeout_x(self, AF_INET6); } +#define activate_stage4_ip_config_timeout_x_fcn(addr_family) \ + (NM_IS_IPv4(addr_family) ? activate_stage4_ip_config_timeout_4 \ + : activate_stage4_ip_config_timeout_6) + void nm_device_activate_schedule_ip_config_timeout(NMDevice *self, int addr_family) { NMDevicePrivate *priv; - const int IS_IPv4 = NM_IS_IPv4(addr_family); g_return_if_fail(NM_IS_DEVICE(self)); - g_return_if_fail(NM_IN_SET(addr_family, AF_INET, AF_INET6)); priv = NM_DEVICE_GET_PRIVATE(self); g_return_if_fail(priv->act_request.obj); activation_source_schedule(self, - IS_IPv4 ? activate_stage4_ip_config_timeout_4 - : activate_stage4_ip_config_timeout_6, + activate_stage4_ip_config_timeout_x_fcn(addr_family), addr_family); } @@ -11963,7 +12012,7 @@ activate_stage5_ip_config_result_x(NMDevice *self, int addr_family) g_return_if_fail(ip_ifindex); if (!nm_platform_link_is_up(nm_device_get_platform(self), ip_ifindex) - && !nm_device_sys_iface_state_is_external_or_assume(self)) { + && !nm_device_sys_iface_state_is_external(self)) { nm_platform_link_change_flags(nm_device_get_platform(self), ip_ifindex, IFF_UP, TRUE); if (!nm_platform_link_is_up(nm_device_get_platform(self), ip_ifindex)) _LOGW(LOGD_DEVICE, @@ -11986,7 +12035,7 @@ activate_stage5_ip_config_result_x(NMDevice *self, int addr_family) /* If IPv6 wasn't the first IP to complete, and DHCP was used, * then ensure dispatcher scripts get the DHCP lease information. */ - nm_dispatcher_call_device(NM_DISPATCHER_ACTION_DHCP6_CHANGE, + nm_dispatcher_call_device(NM_DISPATCHER_ACTION_DHCP_CHANGE_6, self, NULL, NULL, @@ -12052,7 +12101,7 @@ activate_stage5_ip_config_result_x(NMDevice *self, int addr_family) */ if (priv->dhcp_data_4.client && nm_device_activate_ip4_state_in_conf(self) && (nm_device_get_state(self) > NM_DEVICE_STATE_IP_CONFIG)) { - nm_dispatcher_call_device(NM_DISPATCHER_ACTION_DHCP4_CHANGE, + nm_dispatcher_call_device(NM_DISPATCHER_ACTION_DHCP_CHANGE_4, self, NULL, NULL, @@ -12425,7 +12474,7 @@ _nm_device_hash_check_invalid_keys(GHashTable * hash, g_hash_table_iter_init(&iter, hash); while (g_hash_table_iter_next(&iter, (gpointer *) &k, NULL)) { - if (nm_utils_strv_find_first((char **) whitelist, -1, k) < 0) { + if (nm_strv_find_first(whitelist, -1, k) < 0) { first_invalid_key = k; break; } @@ -12490,6 +12539,7 @@ nm_device_reactivate_ip_config(NMDevice * self, s_ip_new, _prop_get_connection_mdns(self), _prop_get_connection_llmnr(self), + _prop_get_connection_dns_over_tls(self), nm_device_get_route_table(self, AF_INET), nm_device_get_route_metric(self, AF_INET)); } else { @@ -12623,7 +12673,8 @@ can_reapply_change(NMDevice * self, NM_SETTING_CONNECTION_METERED, NM_SETTING_CONNECTION_LLDP, NM_SETTING_CONNECTION_MDNS, - NM_SETTING_CONNECTION_LLMNR); + NM_SETTING_CONNECTION_LLMNR, + NM_SETTING_CONNECTION_DNS_OVER_TLS); } if (NM_IN_STRSET(setting_name, @@ -12912,12 +12963,12 @@ reapply_cb(NMDevice * self, audit_args, subject, local->message); - g_dbus_method_invocation_take_error(context, local); - local = NULL; - } else { - nm_audit_log_device_op(NM_AUDIT_OP_DEVICE_REAPPLY, self, TRUE, audit_args, subject, NULL); - g_dbus_method_invocation_return_value(context, NULL); + g_dbus_method_invocation_take_error(context, g_steal_pointer(&local)); + return; } + + nm_audit_log_device_op(NM_AUDIT_OP_DEVICE_REAPPLY, self, TRUE, audit_args, subject, NULL); + g_dbus_method_invocation_return_value(context, NULL); } static void @@ -14737,15 +14788,15 @@ _unmanaged_flags2str(NMUnmanagedFlags flags, NMUnmanagedFlags mask, char *buf, g tmp = buf2; while (TRUE) { if (add_separator) - nm_utils_strbuf_append_c(&b, &len, ','); + nm_strbuf_append_c(&b, &len, ','); add_separator = TRUE; tmp2 = strchr(tmp, ','); if (tmp2) tmp2[0] = '\0'; - nm_utils_strbuf_append_c(&b, &len, '!'); - nm_utils_strbuf_append_str(&b, &len, tmp); + nm_strbuf_append_c(&b, &len, '!'); + nm_strbuf_append_str(&b, &len, tmp); if (!tmp2) break; @@ -14950,7 +15001,7 @@ _set_unmanaged_flags(NMDevice * self, priv->queued_ip_config_id_4 = g_idle_add(queued_ip4_config_change, self); priv->queued_ip_config_id_6 = g_idle_add(queued_ip6_config_change, self); - if (!priv->pending_actions) { + if (priv->pending_actions.len == 0) { do_notify_has_pending_actions = TRUE; had_pending_actions = nm_device_has_pending_action(self); } @@ -15004,7 +15055,7 @@ _set_unmanaged_flags(NMDevice * self, flags, NM_PRINT_FMT_QUOTED(allow_state_transition, ", reason ", - nm_device_state_reason_to_str_a(reason), + nm_device_state_reason_to_string_a(reason), transition_state ? ", transition-state" : "", "")); @@ -15744,37 +15795,39 @@ gboolean nm_device_add_pending_action(NMDevice *self, const char *action, gboolean assert_not_yet_pending) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - GSList * iter; - guint count = 0; + gssize idx; g_return_val_if_fail(action, FALSE); - /* Check if the action is already pending. Cannot add duplicate actions */ - for (iter = priv->pending_actions; iter; iter = iter->next) { - if (nm_streq(action, iter->data)) { - if (assert_not_yet_pending) { - _LOGW(LOGD_DEVICE, - "add_pending_action (%d): '%s' already pending", - count + g_slist_length(iter), - action); - g_return_val_if_reached(FALSE); - } else { - _LOGT(LOGD_DEVICE, - "add_pending_action (%d): '%s' already pending (expected)", - count + g_slist_length(iter), - action); - } - return FALSE; + idx = nm_strv_find_binary_search(priv->pending_actions.arr, priv->pending_actions.len, action); + if (idx >= 0) { + if (assert_not_yet_pending) { + _LOGW(LOGD_DEVICE, + "add_pending_action (%u): '%s' already pending", + priv->pending_actions.len, + action); + g_return_val_if_reached(FALSE); + } else { + _LOGT(LOGD_DEVICE, + "add_pending_action (%u): '%s' already pending (expected)", + priv->pending_actions.len, + action); } - count++; + return FALSE; } - priv->pending_actions = g_slist_prepend(priv->pending_actions, (char *) action); - count++; + if (priv->pending_actions.len == priv->pending_actions.alloc) { + nm_assert(priv->pending_actions.alloc < G_MAXUINT / 2u); + priv->pending_actions.alloc = NM_MAX(priv->pending_actions.alloc * 2u, 4u); + priv->pending_actions.arr = + g_renew(const char *, priv->pending_actions.arr, priv->pending_actions.alloc); + } + nm_arr_insert_at(priv->pending_actions.arr, priv->pending_actions.len, ~idx, action); + priv->pending_actions.len++; - _LOGD(LOGD_DEVICE, "add_pending_action (%d): '%s'", count, action); + _LOGD(LOGD_DEVICE, "add_pending_action (%u): '%s'", priv->pending_actions.len, action); - if (count == 1) + if (priv->pending_actions.len == 1) _notify(self, PROP_HAS_PENDING_ACTION); return TRUE; @@ -15796,37 +15849,38 @@ gboolean nm_device_remove_pending_action(NMDevice *self, const char *action, gboolean assert_is_pending) { NMDevicePrivate *priv; - GSList * iter, *next; - guint count = 0; + gssize idx; g_return_val_if_fail(self, FALSE); g_return_val_if_fail(action, FALSE); priv = NM_DEVICE_GET_PRIVATE(self); - for (iter = priv->pending_actions; iter; iter = next) { - next = iter->next; - if (nm_streq(action, iter->data)) { - _LOGD(LOGD_DEVICE, - "remove_pending_action (%d): '%s'", - count + g_slist_length(iter->next), /* length excluding 'iter' */ - action); - priv->pending_actions = g_slist_delete_link(priv->pending_actions, iter); - if (priv->pending_actions == NULL) - _notify(self, PROP_HAS_PENDING_ACTION); - return TRUE; - } - count++; + idx = nm_strv_find_binary_search(priv->pending_actions.arr, priv->pending_actions.len, action); + if (idx >= 0) { + _LOGD(LOGD_DEVICE, + "remove_pending_action (%u): '%s'", + priv->pending_actions.len - 1u, + action); + nm_arr_remove_at(priv->pending_actions.arr, priv->pending_actions.len, idx); + priv->pending_actions.len--; + if (priv->pending_actions.len == 0) + _notify(self, PROP_HAS_PENDING_ACTION); + return TRUE; } if (assert_is_pending) { - _LOGW(LOGD_DEVICE, "remove_pending_action (%d): '%s' not pending", count, action); + _LOGW(LOGD_DEVICE, + "remove_pending_action (%u): '%s' not pending", + priv->pending_actions.len, + action); g_return_val_if_reached(FALSE); - } else + } else { _LOGT(LOGD_DEVICE, - "remove_pending_action (%d): '%s' not pending (expected)", - count, + "remove_pending_action (%u): '%s' not pending (expected)", + priv->pending_actions.len, action); + } return FALSE; } @@ -15836,15 +15890,15 @@ nm_device_has_pending_action_reason(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - if (priv->pending_actions) { - if (!priv->pending_actions->next && nm_device_get_state(self) == NM_DEVICE_STATE_ACTIVATED - && nm_streq(priv->pending_actions->data, NM_PENDING_ACTION_CARRIER_WAIT)) { + if (priv->pending_actions.len > 0) { + if (priv->pending_actions.len == 1 && nm_device_get_state(self) == NM_DEVICE_STATE_ACTIVATED + && nm_streq(priv->pending_actions.arr[0], NM_PENDING_ACTION_CARRIER_WAIT)) { /* if the device is already in activated state, and the only reason * why it appears still busy is "carrier-wait", then we are already complete. */ return NULL; } - return priv->pending_actions->data; + return priv->pending_actions.arr[0]; } if (nm_device_is_real(self) @@ -16014,7 +16068,7 @@ nm_device_cleanup(NMDevice *self, NMDeviceStateReason reason, CleanupType cleanu else _LOGD(LOGD_DEVICE, "deactivating device (reason '%s') [%d]", - nm_device_state_reason_to_str_a(reason), + nm_device_state_reason_to_string_a(reason), reason); /* Save whether or not we tried IPv6 for later */ @@ -16045,15 +16099,16 @@ nm_device_cleanup(NMDevice *self, NMDeviceStateReason reason, CleanupType cleanu nm_platform_ip_route_flush(platform, AF_UNSPEC, ifindex); nm_platform_ip_address_flush(platform, AF_UNSPEC, ifindex); - set_ipv6_token(self, iid, "::"); + set_ipv6_token(self, &iid, "::"); if (nm_device_get_applied_setting(self, NM_TYPE_SETTING_TC_CONFIG)) { - nm_platform_tfilter_sync(platform, ifindex, NULL); - nm_platform_qdisc_sync(platform, ifindex, NULL); + nm_platform_tc_sync(platform, ifindex, NULL, NULL); } } } + priv->tc_committed = FALSE; + _routing_rules_sync(self, cleanup_type == CLEANUP_TYPE_KEEP ? NM_TERNARY_DEFAULT : NM_TERNARY_FALSE); @@ -16508,20 +16563,20 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, && (state != NM_DEVICE_STATE_UNAVAILABLE || !priv->firmware_missing)) { _LOGD(LOGD_DEVICE, "state change: %s -> %s (reason '%s', sys-iface-state: '%s'%s)", - nm_device_state_to_str(old_state), - nm_device_state_to_str(state), - nm_device_state_reason_to_str_a(reason), - nm_device_sys_iface_state_to_str(priv->sys_iface_state), + nm_device_state_to_string(old_state), + nm_device_state_to_string(state), + nm_device_state_reason_to_string_a(reason), + nm_device_sys_iface_state_to_string(priv->sys_iface_state), priv->firmware_missing ? ", missing firmware" : ""); return; } _LOGI(LOGD_DEVICE, "state change: %s -> %s (reason '%s', sys-iface-state: '%s')", - nm_device_state_to_str(old_state), - nm_device_state_to_str(state), - nm_device_state_reason_to_str_a(reason), - nm_device_sys_iface_state_to_str(priv->sys_iface_state)); + nm_device_state_to_string(old_state), + nm_device_state_to_string(state), + nm_device_state_reason_to_string_a(reason), + nm_device_sys_iface_state_to_string(priv->sys_iface_state)); /* in order to prevent triggering any callback caused * by the device not having any pending action anymore @@ -16866,8 +16921,8 @@ queued_state_set(gpointer user_data) _LOGD(LOGD_DEVICE, "queue-state[%s, reason:%s, id:%u]: %s", - nm_device_state_to_str(priv->queued_state.state), - nm_device_state_reason_to_str_a(priv->queued_state.reason), + nm_device_state_to_string(priv->queued_state.state), + nm_device_state_reason_to_string_a(priv->queued_state.reason), priv->queued_state.id, "change state"); @@ -16879,7 +16934,7 @@ queued_state_set(gpointer user_data) new_reason = priv->queued_state.reason; nm_device_state_changed(self, new_state, new_reason); - nm_device_remove_pending_action(self, nm_device_state_queued_state_to_str(new_state), TRUE); + nm_device_remove_pending_action(self, nm_device_state_queued_state_to_string(new_state), TRUE); return G_SOURCE_REMOVE; } @@ -16896,13 +16951,13 @@ nm_device_queue_state(NMDevice *self, NMDeviceState state, NMDeviceStateReason r if (priv->queued_state.id && priv->queued_state.state == state) { _LOGD(LOGD_DEVICE, "queue-state[%s, reason:%s, id:%u]: %s%s%s%s", - nm_device_state_to_str(priv->queued_state.state), - nm_device_state_reason_to_str_a(priv->queued_state.reason), + nm_device_state_to_string(priv->queued_state.state), + nm_device_state_reason_to_string_a(priv->queued_state.reason), priv->queued_state.id, "ignore queuing same state change", NM_PRINT_FMT_QUOTED(priv->queued_state.reason != reason, " (reason differs: ", - nm_device_state_reason_to_str_a(reason), + nm_device_state_reason_to_string_a(reason), ")", "")); return; @@ -16910,20 +16965,20 @@ nm_device_queue_state(NMDevice *self, NMDeviceState state, NMDeviceStateReason r /* Add pending action for the new state before clearing the queued states, so * that we don't accidentally pop all pending states and reach 'startup complete' */ - nm_device_add_pending_action(self, nm_device_state_queued_state_to_str(state), TRUE); + nm_device_add_pending_action(self, nm_device_state_queued_state_to_string(state), TRUE); /* We should only ever have one delayed state transition at a time */ if (priv->queued_state.id) { _LOGW(LOGD_DEVICE, "queue-state[%s, reason:%s, id:%u]: %s", - nm_device_state_to_str(priv->queued_state.state), - nm_device_state_reason_to_str_a(priv->queued_state.reason), + nm_device_state_to_string(priv->queued_state.state), + nm_device_state_reason_to_string_a(priv->queued_state.reason), priv->queued_state.id, "replace previously queued state change"); nm_clear_g_source(&priv->queued_state.id); nm_device_remove_pending_action( self, - nm_device_state_queued_state_to_str(priv->queued_state.state), + nm_device_state_queued_state_to_string(priv->queued_state.state), TRUE); } @@ -16933,8 +16988,8 @@ nm_device_queue_state(NMDevice *self, NMDeviceState state, NMDeviceStateReason r _LOGD(LOGD_DEVICE, "queue-state[%s, reason:%s, id:%u]: %s", - nm_device_state_to_str(state), - nm_device_state_reason_to_str_a(reason), + nm_device_state_to_string(state), + nm_device_state_reason_to_string_a(reason), priv->queued_state.id, "queue state change"); } @@ -16949,14 +17004,15 @@ queued_state_clear(NMDevice *self) _LOGD(LOGD_DEVICE, "queue-state[%s, reason:%s, id:%u]: %s", - nm_device_state_to_str(priv->queued_state.state), - nm_device_state_reason_to_str_a(priv->queued_state.reason), + nm_device_state_to_string(priv->queued_state.state), + nm_device_state_reason_to_string_a(priv->queued_state.reason), priv->queued_state.id, "clear queued state change"); nm_clear_g_source(&priv->queued_state.id); - nm_device_remove_pending_action(self, - nm_device_state_queued_state_to_str(priv->queued_state.state), - TRUE); + nm_device_remove_pending_action( + self, + nm_device_state_queued_state_to_string(priv->queued_state.state), + TRUE); } NMDeviceState @@ -17069,11 +17125,11 @@ nm_device_update_permanent_hw_address(NMDevice *self, gboolean force_freeze) { NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); guint8 buf[_NM_UTILS_HWADDR_LEN_MAX]; - size_t len = 0; gboolean success_read; int ifindex; const NMPlatformLink * pllink; const NMConfigDeviceStateData *dev_state; + NMPLinkAddress cached_hw_addr_perm; if (priv->hw_addr_perm) { /* the permanent hardware address is only read once and not @@ -17112,11 +17168,13 @@ nm_device_update_permanent_hw_address(NMDevice *self, gboolean force_freeze) return; } - success_read = - nm_platform_link_get_permanent_address(nm_device_get_platform(self), ifindex, buf, &len); - if (success_read && priv->hw_addr_len == len) { + success_read = nm_platform_link_get_permanent_address(nm_device_get_platform(self), + pllink, + &cached_hw_addr_perm); + if (success_read && priv->hw_addr_len == cached_hw_addr_perm.len) { priv->hw_addr_perm_fake = FALSE; - priv->hw_addr_perm = nm_utils_hwaddr_ntoa(buf, len); + priv->hw_addr_perm = + nm_utils_hwaddr_ntoa(cached_hw_addr_perm.data, cached_hw_addr_perm.len); _LOGD(LOGD_DEVICE, "hw-addr: read permanent MAC address '%s'", priv->hw_addr_perm); goto notify_and_out; } @@ -17791,7 +17849,7 @@ hostname_dns_lookup_callback(GObject *source, GAsyncResult *result, gpointer use gboolean valid; resolver->hostname = g_steal_pointer(&output); - valid = nm_hostname_manager_validate_hostname(resolver->hostname); + valid = nm_utils_validate_hostname(resolver->hostname); _LOGD(LOGD_DNS, "hostname-from-dns: lookup done for %s, result %s%s%s%s", @@ -17800,7 +17858,7 @@ hostname_dns_lookup_callback(GObject *source, GAsyncResult *result, gpointer use valid ? "" : " (invalid)"); if (!valid) - g_clear_pointer(&resolver->hostname, g_free); + nm_clear_g_free(&resolver->hostname); } nm_clear_g_cancellable(&resolver->cancellable); @@ -18022,6 +18080,37 @@ _activation_func_to_string(ActivationHandleFunc func) g_return_val_if_reached("unknown"); } +static GVariant * +_device_get_ports_variant(NMDevice *device) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(device); + SlaveInfo * info; + GVariantBuilder builder; + gboolean any = FALSE; + + if (priv->ports_variant) + return priv->ports_variant; + + c_list_for_each_entry (info, &priv->slaves, lst_slave) { + const char *path; + + if (!NM_DEVICE_GET_PRIVATE(info->slave)->is_enslaved) + continue; + path = nm_dbus_object_get_path(NM_DBUS_OBJECT(info->slave)); + if (!path) + continue; + if (!any) { + any = TRUE; + g_variant_builder_init(&builder, G_VARIANT_TYPE("ao")); + } + g_variant_builder_add(&builder, "o", path); + } + priv->ports_variant = any ? g_variant_ref_sink(g_variant_builder_end(&builder)) + : g_variant_ref(nm_g_variant_singleton_ao()); + + return priv->ports_variant; +} + /*****************************************************************************/ static void @@ -18188,29 +18277,9 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) g_value_set_boolean(value, nm_device_is_real(self)); break; case PROP_SLAVES: - { - CList *slave_iter; - char **slave_list; - gsize i, n; - - n = c_list_length(&priv->slaves); - slave_list = g_new(char *, n + 1); - i = 0; - c_list_for_each (slave_iter, &priv->slaves) { - SlaveInfo * info = c_list_entry(slave_iter, SlaveInfo, lst_slave); - const char *path; - - if (!NM_DEVICE_GET_PRIVATE(info->slave)->is_enslaved) - continue; - path = nm_dbus_object_get_path(NM_DBUS_OBJECT(info->slave)); - if (path) - slave_list[i++] = g_strdup(path); - } - nm_assert(i <= n); - slave_list[i] = NULL; - g_value_take_boxed(value, slave_list); + case PROP_PORTS: + g_value_set_variant(value, _device_get_ports_variant(self)); break; - } case PROP_STATISTICS_REFRESH_RATE_MS: g_value_set_uint(value, priv->stats.refresh_rate_ms); break; @@ -18518,7 +18587,7 @@ dispose(GObject *object) nm_clear_g_source(&priv->check_delete_unrealized_id); - nm_clear_g_source(&priv->stats.timeout_id); + nm_clear_g_source_inst(&priv->stats.timeout_source); carrier_disconnected_action_cancel(self); @@ -18573,7 +18642,7 @@ finalize(GObject *object) g_free(priv->hw_addr); g_free(priv->hw_addr_perm); g_free(priv->hw_addr_initial); - g_slist_free(priv->pending_actions); + g_free(priv->pending_actions.arr); g_slist_free_full(priv->dad6_failed_addrs, (GDestroyNotify) nmp_object_unref); nm_clear_g_free(&priv->physical_port_id); g_free(priv->udi); @@ -18592,6 +18661,8 @@ finalize(GObject *object) nm_dbus_track_obj_path_deinit(&priv->parent_device); nm_dbus_track_obj_path_deinit(&priv->act_request); + nm_g_variant_unref(priv->ports_variant); + G_OBJECT_CLASS(nm_device_parent_class)->finalize(object); /* for testing, NMDeviceTest does not invoke NMDevice::constructed, @@ -18710,9 +18781,8 @@ static const NMDBusInterfaceInfoExtended interface_info_device = { NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("InterfaceFlags", "u", NM_DEVICE_INTERFACE_FLAGS), - NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("HwAddress", - "s", - NM_DEVICE_HW_ADDRESS), ), ), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("HwAddress", "s", NM_DEVICE_HW_ADDRESS), + NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE("Ports", "ao", NM_DEVICE_PORTS), ), ), }; static const NMDBusInterfaceInfoExtended interface_info_device_statistics = { @@ -19007,11 +19077,18 @@ nm_device_class_init(NMDeviceClass *klass) "", FALSE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_SLAVES] = g_param_spec_boxed(NM_DEVICE_SLAVES, - "", - "", - G_TYPE_STRV, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_SLAVES] = g_param_spec_variant(NM_DEVICE_SLAVES, + "", + "", + G_VARIANT_TYPE("ao"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_PORTS] = g_param_spec_variant(NM_DEVICE_PORTS, + "", + "", + G_VARIANT_TYPE("ao"), + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); obj_properties[PROP_STATISTICS_REFRESH_RATE_MS] = g_param_spec_uint(NM_DEVICE_STATISTICS_REFRESH_RATE_MS, @@ -19113,16 +19190,17 @@ nm_device_class_init(NMDeviceClass *klass) G_TYPE_OBJECT, G_TYPE_OBJECT); - signals[IP6_PREFIX_DELEGATED] = g_signal_new(NM_DEVICE_IP6_PREFIX_DELEGATED, - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, - NULL, - NULL, - G_TYPE_NONE, - 1, - G_TYPE_POINTER); + signals[IP6_PREFIX_DELEGATED] = + g_signal_new(NM_DEVICE_IP6_PREFIX_DELEGATED, + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, + NULL, + NULL, + G_TYPE_NONE, + 1, + G_TYPE_POINTER /* const NMPlatformIP6Address *prefix */); signals[IP6_SUBNET_NEEDED] = g_signal_new(NM_DEVICE_IP6_SUBNET_NEEDED, G_OBJECT_CLASS_TYPE(object_class), diff --git a/src/core/devices/nm-device.h b/src/core/devices/nm-device.h index f59b6fa8..d967bcb2 100644 --- a/src/core/devices/nm-device.h +++ b/src/core/devices/nm-device.h @@ -45,6 +45,7 @@ #define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id" #define NM_DEVICE_MTU "mtu" #define NM_DEVICE_HW_ADDRESS "hw-address" +#define NM_DEVICE_PORTS "ports" /* "perm-hw-address" is exposed on D-Bus both for NMDeviceEthernet * and NMDeviceWifi. */ diff --git a/src/core/devices/nm-lldp-listener.c b/src/core/devices/nm-lldp-listener.c index aba972ae..4e178491 100644 --- a/src/core/devices/nm-lldp-listener.c +++ b/src/core/devices/nm-lldp-listener.c @@ -32,7 +32,7 @@ /*****************************************************************************/ struct _NMLldpListener { - sd_lldp * lldp_handle; + sd_lldp_rx *lldp_handle; GHashTable *lldp_neighbors; GVariant * variant; @@ -711,9 +711,9 @@ lldp_neighbor_to_variant(LldpNeighbor *neigh) g_variant_new_uint32(unaligned_read_be16(data8)); break; } - } else if (memcmp(oui, SD_LLDP_OUI_MUD, sizeof(oui)) == 0) { + } else if (memcmp(oui, SD_LLDP_OUI_IANA, sizeof(oui)) == 0) { switch (subtype) { - case SD_LLDP_OUI_SUBTYPE_MUD_USAGE_DESCRIPTION: + case SD_LLDP_OUI_IANA_SUBTYPE_MUD: if (!v_mud_url) { gs_free char *s_free = NULL; const char * s; @@ -884,12 +884,14 @@ handle_changed: } static void -lldp_event_handler(sd_lldp *lldp, sd_lldp_event_t event, sd_lldp_neighbor *n, void *userdata) +lldp_event_handler(sd_lldp_rx *lldp, sd_lldp_rx_event_t event, sd_lldp_neighbor *n, void *userdata) { - process_lldp_neighbor( - userdata, - n, - !NM_IN_SET(event, SD_LLDP_EVENT_ADDED, SD_LLDP_EVENT_UPDATED, SD_LLDP_EVENT_REFRESHED)); + process_lldp_neighbor(userdata, + n, + !NM_IN_SET(event, + SD_LLDP_RX_EVENT_ADDED, + SD_LLDP_RX_EVENT_UPDATED, + SD_LLDP_RX_EVENT_REFRESHED)); } /*****************************************************************************/ @@ -934,14 +936,14 @@ nm_lldp_listener_new(int ifindex, GError ** error) { NMLldpListener *self = NULL; - sd_lldp * lldp_handle; + sd_lldp_rx * lldp_handle; int r; g_return_val_if_fail(ifindex > 0, FALSE); g_return_val_if_fail(!error || !*error, FALSE); g_return_val_if_fail(notify_callback, FALSE); - r = sd_lldp_new(&lldp_handle); + r = sd_lldp_rx_new(&lldp_handle); if (r < 0) { g_set_error_literal(error, NM_DEVICE_ERROR, @@ -950,7 +952,7 @@ nm_lldp_listener_new(int ifindex, return FALSE; } - r = sd_lldp_set_ifindex(lldp_handle, ifindex); + r = sd_lldp_rx_set_ifindex(lldp_handle, ifindex); if (r < 0) { g_set_error_literal(error, NM_DEVICE_ERROR, @@ -959,7 +961,7 @@ nm_lldp_listener_new(int ifindex, goto fail_handle; } - r = sd_lldp_set_neighbors_max(lldp_handle, MAX_NEIGHBORS); + r = sd_lldp_rx_set_neighbors_max(lldp_handle, MAX_NEIGHBORS); nm_assert(r == 0); self = g_slice_new(NMLldpListener); @@ -969,19 +971,19 @@ nm_lldp_listener_new(int ifindex, .notify_user_data = notify_user_data, }; - r = sd_lldp_set_callback(lldp_handle, lldp_event_handler, self); + r = sd_lldp_rx_set_callback(lldp_handle, lldp_event_handler, self); if (r < 0) { g_set_error_literal(error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, "set callback failed"); goto fail_handle; } - r = sd_lldp_attach_event(lldp_handle, NULL, 0); + r = sd_lldp_rx_attach_event(lldp_handle, NULL, 0); if (r < 0) { g_set_error_literal(error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, "attach event failed"); goto fail_attached; } - r = sd_lldp_start(lldp_handle); + r = sd_lldp_rx_start(lldp_handle); if (r < 0) { g_set_error_literal(error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, "start failed"); goto fail_attached; @@ -997,11 +999,11 @@ nm_lldp_listener_new(int ifindex, return self; fail_attached: - sd_lldp_detach_event(lldp_handle); + sd_lldp_rx_detach_event(lldp_handle); fail_handle: if (self) nm_g_slice_free(self); - sd_lldp_unref(lldp_handle); + sd_lldp_rx_unref(lldp_handle); return NULL; } @@ -1010,9 +1012,9 @@ nm_lldp_listener_destroy(NMLldpListener *self) { g_return_if_fail(self); - sd_lldp_stop(self->lldp_handle); - sd_lldp_detach_event(self->lldp_handle); - sd_lldp_unref(self->lldp_handle); + sd_lldp_rx_stop(self->lldp_handle); + sd_lldp_rx_detach_event(self->lldp_handle); + sd_lldp_rx_unref(self->lldp_handle); nm_clear_g_source_inst(&self->ratelimit_source); diff --git a/src/core/devices/ovs/nm-ovsdb.c b/src/core/devices/ovs/nm-ovsdb.c index b8d5311a..e5673347 100644 --- a/src/core/devices/ovs/nm-ovsdb.c +++ b/src/core/devices/ovs/nm-ovsdb.c @@ -17,6 +17,7 @@ #include "devices/nm-device.h" #include "nm-manager.h" #include "nm-setting-ovs-external-ids.h" +#include "nm-priv-helper-call.h" /*****************************************************************************/ @@ -25,7 +26,7 @@ /*****************************************************************************/ #if JANSSON_VERSION_HEX < 0x020400 - #warning "requires at least libjansson 2.4" +#warning "requires at least libjansson 2.4" #endif typedef struct { @@ -118,9 +119,8 @@ enum { static guint signals[LAST_SIGNAL] = {0}; typedef struct { - GSocketClient * client; GSocketConnection *conn; - GCancellable * cancellable; + GCancellable * conn_cancellable; char buf[4096]; /* Input buffer */ size_t bufp; /* Last decoded byte in the input buffer. */ GString * input; /* JSON stream waiting for decoding. */ @@ -753,6 +753,7 @@ _insert_interface(json_t * params, NMSettingOvsInterface *s_ovs_iface; NMSettingOvsDpdk * s_ovs_dpdk; NMSettingOvsPatch * s_ovs_patch; + const char * dpdk_devargs; json_t * options = json_array(); json_t * row; guint32 mtu = 0; @@ -777,9 +778,11 @@ _insert_interface(json_t * params, s_ovs_patch = nm_connection_get_setting_ovs_patch(interface); if (s_ovs_dpdk) { - json_array_append_new( - options, - json_pack("[[s, s]]", "dpdk-devargs", nm_setting_ovs_dpdk_get_devargs(s_ovs_dpdk))); + dpdk_devargs = nm_setting_ovs_dpdk_get_devargs(s_ovs_dpdk); + if (dpdk_devargs) + json_array_append_new(options, json_pack("[[s, s]]", "dpdk-devargs", dpdk_devargs)); + else + json_array_append_new(options, json_array()); } else if (s_ovs_patch) { json_array_append_new( options, @@ -1595,7 +1598,7 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg) iter = json_object_iter(ovs); s = json_object_iter_key(iter); if (s) - nm_utils_strdup_reset(&priv->db_uuid, s); + nm_strdup_reset(&priv->db_uuid, s); } json_object_foreach (interface, key, value) { @@ -1665,8 +1668,8 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg) nm_assert(nm_streq0(ovs_interface->name, name)); - changed |= nm_utils_strdup_reset(&ovs_interface->type, type); - changed |= nm_utils_strdup_reset(&ovs_interface->connection_uuid, connection_uuid); + changed |= nm_strdup_reset(&ovs_interface->type, type); + changed |= nm_strdup_reset(&ovs_interface->connection_uuid, connection_uuid); if (!_external_ids_equal(ovs_interface->external_ids, external_ids_arr)) { NM_SWAP(&ovs_interface->external_ids, &external_ids_arr); changed = TRUE; @@ -1776,8 +1779,8 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg) nm_assert(nm_streq0(ovs_port->name, name)); - changed |= nm_utils_strdup_reset(&ovs_port->name, name); - changed |= nm_utils_strdup_reset(&ovs_port->connection_uuid, connection_uuid); + changed |= nm_strdup_reset(&ovs_port->name, name); + changed |= nm_strdup_reset(&ovs_port->connection_uuid, connection_uuid); if (nm_strv_ptrarray_cmp(ovs_port->interfaces, interfaces) != 0) { NM_SWAP(&ovs_port->interfaces, &interfaces); changed = TRUE; @@ -1881,8 +1884,8 @@ ovsdb_got_update(NMOvsdb *self, json_t *msg) nm_assert(nm_streq0(ovs_bridge->name, name)); - changed = nm_utils_strdup_reset(&ovs_bridge->name, name); - changed = nm_utils_strdup_reset(&ovs_bridge->connection_uuid, connection_uuid); + changed = nm_strdup_reset(&ovs_bridge->name, name); + changed = nm_strdup_reset(&ovs_bridge->connection_uuid, connection_uuid); if (nm_strv_ptrarray_cmp(ovs_bridge->ports, ports) != 0) { NM_SWAP(&ovs_bridge->ports, &ports); changed = TRUE; @@ -2223,7 +2226,7 @@ ovsdb_disconnect(NMOvsdb *self, gboolean retry, gboolean is_disposing) nm_assert(!retry || !is_disposing); - if (!priv->client) + if (!priv->conn && !priv->conn_cancellable) return; _LOGD("disconnecting from ovsdb, retry %d", retry); @@ -2250,10 +2253,9 @@ ovsdb_disconnect(NMOvsdb *self, gboolean retry, gboolean is_disposing) priv->bufp = 0; g_string_truncate(priv->input, 0); g_string_truncate(priv->output, 0); - g_clear_object(&priv->client); g_clear_object(&priv->conn); nm_clear_g_free(&priv->db_uuid); - nm_clear_g_cancellable(&priv->cancellable); + nm_clear_g_cancellable(&priv->conn_cancellable); if (retry) ovsdb_try_connect(self); @@ -2348,32 +2350,82 @@ _monitor_bridges_cb(NMOvsdb *self, json_t *result, GError *error, gpointer user_ } static void -_client_connect_cb(GObject *source_object, GAsyncResult *res, gpointer user_data) +_ovsdb_connect_complete_with_fd(NMOvsdb *self, int fd_take) { - GSocketClient * client = G_SOCKET_CLIENT(source_object); - NMOvsdb * self = NM_OVSDB(user_data); - NMOvsdbPrivate * priv; - GError * error = NULL; - GSocketConnection *conn; - - conn = g_socket_client_connect_finish(client, res, &error); - if (conn == NULL) { - if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - _LOGI("%s", error->message); + NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE(self); + gs_unref_object GSocket *socket = NULL; + gs_free_error GError *error = NULL; + socket = g_socket_new_from_fd(nm_steal_fd(&fd_take), &error); + if (!socket) { + _LOGT("connect: failure to open socket for new FD: %s", error->message); ovsdb_disconnect(self, FALSE, FALSE); - g_clear_error(&error); return; } - priv = NM_OVSDB_GET_PRIVATE(self); - priv->conn = conn; - g_clear_object(&priv->cancellable); + priv->conn = g_socket_connection_factory_create_connection(socket); + g_clear_object(&priv->conn_cancellable); ovsdb_read(self); ovsdb_next_command(self); } +static void +_ovsdb_connect_priv_helper_cb(int fd_take, GError *error, gpointer user_data) +{ + nm_auto_close int fd = fd_take; + NMOvsdb * self; + + if (nm_utils_error_is_cancelled(error)) + return; + + self = user_data; + + if (error) { + _LOGT("connect: failure to get FD from nm-priv-helper: %s", error->message); + ovsdb_disconnect(self, FALSE, FALSE); + return; + } + + _LOGT("connect: connected successfully with FD from nm-priv-helper"); + _ovsdb_connect_complete_with_fd(self, nm_steal_fd(&fd)); +} + +static void +_ovsdb_connect_idle(gpointer user_data, GCancellable *cancellable) +{ + NMOvsdb * self; + NMOvsdbPrivate * priv; + nm_auto_close int fd = -1; + gs_free_error GError *error = NULL; + + if (g_cancellable_is_cancelled(cancellable)) + return; + + self = user_data; + priv = NM_OVSDB_GET_PRIVATE(self); + + fd = nm_priv_helper_utils_open_fd(NM_PRIV_HELPER_GET_FD_TYPE_OVSDB_SOCKET, &error); + if (fd == -ENOENT) { + _LOGT("connect: opening %s failed (\"%s\")", NM_OVSDB_SOCKET, error->message); + ovsdb_disconnect(self, FALSE, FALSE); + return; + } + if (fd < 0) { + _LOGT("connect: opening %s failed (\"%s\"). Retry with nm-priv-helper", + NM_OVSDB_SOCKET, + error->message); + nm_priv_helper_call_get_fd(NM_PRIV_HELPER_GET_FD_TYPE_OVSDB_SOCKET, + priv->conn_cancellable, + _ovsdb_connect_priv_helper_cb, + self); + return; + } + + _LOGT("connect: opening %s succeeded", NM_OVSDB_SOCKET); + _ovsdb_connect_complete_with_fd(self, nm_steal_fd(&fd)); +} + /** * ovsdb_try_connect: * @@ -2385,22 +2437,13 @@ static void ovsdb_try_connect(NMOvsdb *self) { NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE(self); - GSocketAddress *addr; - if (priv->client) + if (priv->conn || priv->conn_cancellable) return; - /* TODO: This should probably be made configurable via NetworkManager.conf */ - addr = g_unix_socket_address_new(RUNSTATEDIR "/openvswitch/db.sock"); - - priv->client = g_socket_client_new(); - priv->cancellable = g_cancellable_new(); - g_socket_client_connect_async(priv->client, - G_SOCKET_CONNECTABLE(addr), - priv->cancellable, - _client_connect_cb, - self); - g_object_unref(addr); + _LOGT("connect: start connecting socket %s on idle", NM_OVSDB_SOCKET); + priv->conn_cancellable = g_cancellable_new(); + nm_utils_invoke_on_idle(priv->conn_cancellable, _ovsdb_connect_idle, self); /* Queue a monitor call before any other command, ensuring that we have an up * to date view of existing bridged that we need for add and remove ops. */ @@ -2534,12 +2577,10 @@ nm_ovsdb_set_external_ids(NMOvsdb * self, gs_unref_hashtable GHashTable *exid_old = NULL; gs_unref_hashtable GHashTable *exid_new = NULL; - exid_old = s_exid_old - ? nm_utils_strdict_clone(_nm_setting_ovs_external_ids_get_data(s_exid_old)) - : NULL; - exid_new = s_exid_new - ? nm_utils_strdict_clone(_nm_setting_ovs_external_ids_get_data(s_exid_new)) - : NULL; + exid_old = + s_exid_old ? nm_strdict_clone(_nm_setting_ovs_external_ids_get_data(s_exid_old)) : NULL; + exid_new = + s_exid_new ? nm_strdict_clone(_nm_setting_ovs_external_ids_get_data(s_exid_new)) : NULL; ovsdb_call_method(self, NULL, diff --git a/src/core/devices/team/nm-device-team.c b/src/core/devices/team/nm-device-team.c index 0f1a8c4c..3398e467 100644 --- a/src/core/devices/team/nm-device-team.c +++ b/src/core/devices/team/nm-device-team.c @@ -20,6 +20,7 @@ #include "devices/nm-device-private.h" #include "libnm-platform/nm-platform.h" #include "nm-config.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" #include "nm-dbus-manager.h" #include "nm-ip4-config.h" @@ -78,8 +79,6 @@ complete_connection(NMDevice * device, NMConnection *const *existing_connections, GError ** error) { - NMSettingTeam *s_team; - nm_utils_complete_generic(nm_device_get_platform(device), connection, NM_SETTING_TEAM_SETTING_NAME, @@ -90,11 +89,7 @@ complete_connection(NMDevice * device, NULL, TRUE); - s_team = nm_connection_get_setting_team(connection); - if (!s_team) { - s_team = (NMSettingTeam *) nm_setting_team_new(); - nm_connection_add_setting(connection, NM_SETTING(s_team)); - } + _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_TEAM); return TRUE; } @@ -168,15 +163,10 @@ static void update_connection(NMDevice *device, NMConnection *connection) { NMDeviceTeam * self = NM_DEVICE_TEAM(device); - NMSettingTeam * s_team = nm_connection_get_setting_team(connection); + NMSettingTeam * s_team = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_TEAM); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); struct teamdctl * tdc = priv->tdc; - if (!s_team) { - s_team = (NMSettingTeam *) nm_setting_team_new(); - nm_connection_add_setting(connection, (NMSetting *) s_team); - } - /* Read the configuration only if not already set */ if (!priv->config && ensure_teamd_connection(device)) teamd_read_config(self); @@ -250,11 +240,7 @@ master_update_slave_connection(NMDevice * self, return FALSE; } - s_port = nm_connection_get_setting_team_port(connection); - if (!s_port) { - s_port = (NMSettingTeamPort *) nm_setting_team_port_new(); - nm_connection_add_setting(connection, NM_SETTING(s_port)); - } + s_port = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_TEAM_PORT); g_object_set(G_OBJECT(s_port), NM_SETTING_TEAM_PORT_CONFIG, port_config, NULL); g_free(port_config); diff --git a/src/core/devices/wifi/nm-device-iwd.c b/src/core/devices/wifi/nm-device-iwd.c index 56338743..27a3188b 100644 --- a/src/core/devices/wifi/nm-device-iwd.c +++ b/src/core/devices/wifi/nm-device-iwd.c @@ -18,6 +18,7 @@ #include "libnm-glib-aux/nm-ref-string.h" #include "nm-iwd-manager.h" #include "libnm-core-aux-intern/nm-common-macros.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "nm-setting-8021x.h" #include "nm-setting-connection.h" #include "nm-setting-wireless-security.h" @@ -966,7 +967,7 @@ complete_connection(NMDevice * device, gboolean hidden = FALSE; const char * mode; - s_wifi = nm_connection_get_setting_wireless(connection); + s_wifi = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_WIRELESS); mode = s_wifi ? nm_setting_wireless_get_mode(s_wifi) : NULL; @@ -1031,12 +1032,6 @@ complete_connection(NMDevice * device, } ssid = nm_wifi_ap_get_ssid(ap); - - /* Add a wifi setting if one doesn't exist yet */ - if (!s_wifi) { - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - } } if (ap) { @@ -2651,7 +2646,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) break; case PROP_ACCESS_POINTS: list = nm_wifi_aps_get_paths(&priv->aps_lst_head, TRUE); - g_value_take_boxed(value, nm_utils_strv_make_deep_copied(list)); + g_value_take_boxed(value, nm_strv_make_deep_copied(list)); break; case PROP_ACTIVE_ACCESS_POINT: nm_dbus_utils_g_value_set_object_path(value, priv->current_ap); diff --git a/src/core/devices/wifi/nm-device-olpc-mesh.c b/src/core/devices/wifi/nm-device-olpc-mesh.c index 040350d5..d829f9ae 100644 --- a/src/core/devices/wifi/nm-device-olpc-mesh.c +++ b/src/core/devices/wifi/nm-device-olpc-mesh.c @@ -28,6 +28,7 @@ #include "nm-setting-connection.h" #include "nm-setting-olpc-mesh.h" #include "nm-manager.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-platform/nm-platform.h" #define _NMLOG_DEVICE_TYPE NMDeviceOlpcMesh @@ -88,11 +89,7 @@ complete_connection(NMDevice * device, { NMSettingOlpcMesh *s_mesh; - s_mesh = nm_connection_get_setting_olpc_mesh(connection); - if (!s_mesh) { - s_mesh = (NMSettingOlpcMesh *) nm_setting_olpc_mesh_new(); - nm_connection_add_setting(connection, NM_SETTING(s_mesh)); - } + s_mesh = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_OLPC_MESH); if (!nm_setting_olpc_mesh_get_ssid(s_mesh)) { gs_unref_bytes GBytes *ssid = NULL; diff --git a/src/core/devices/wifi/nm-device-wifi-p2p.c b/src/core/devices/wifi/nm-device-wifi-p2p.c index a8ea2ed7..67202a67 100644 --- a/src/core/devices/wifi/nm-device-wifi-p2p.c +++ b/src/core/devices/wifi/nm-device-wifi-p2p.c @@ -15,6 +15,7 @@ #include "NetworkManagerUtils.h" #include "devices/nm-device-private.h" #include "nm-act-request.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" #include "libnm-glib-aux/nm-ref-string.h" #include "nm-ip4-config.h" @@ -302,10 +303,7 @@ complete_connection(NMDevice * device, } /* Add a Wi-Fi P2P setting if one doesn't exist yet */ - if (!s_wifi_p2p) { - s_wifi_p2p = NM_SETTING_WIFI_P2P(nm_setting_wifi_p2p_new()); - nm_connection_add_setting(connection, NM_SETTING(s_wifi_p2p)); - } + s_wifi_p2p = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_WIFI_P2P); g_object_set(G_OBJECT(s_wifi_p2p), NM_SETTING_WIFI_P2P_PEER, setting_peer, NULL); @@ -560,14 +558,39 @@ act_stage3_ip_config_start(NMDevice * device, gpointer * out_config, NMDeviceStateReason *out_failure_reason) { - gboolean indicate_addressing_running; - NMConnection *connection; - const char * method; + NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(device); + gboolean indicate_addressing_running; + NMConnection * connection; + const char * method; connection = nm_device_get_applied_connection(device); method = nm_utils_get_ip_config_method(connection, addr_family); + /* We may have an address assigned by the group owner */ + if (NM_IN_STRSET(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) && priv->group_iface + && !nm_supplicant_interface_get_p2p_group_owner(priv->group_iface)) { + in_addr_t addr; + guint8 plen; + + if (nm_supplicant_interface_get_p2p_assigned_addr(priv->group_iface, &addr, &plen)) { + NMPlatformIP4Address address = { + .addr_source = NM_IP_CONFIG_SOURCE_DHCP, + }; + gs_unref_object NMIP4Config *ip4_config = NULL; + + nm_platform_ip4_address_set_addr(&address, addr, plen); + + ip4_config = nm_device_ip4_config_new(device); + nm_ip4_config_add_address(ip4_config, &address); + + nm_device_set_dev2_ip_config(device, AF_INET, NM_IP_CONFIG(ip4_config)); + + /* This just disables the addressing indicator. */ + method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED; + } + } + if (addr_family == AF_INET) indicate_addressing_running = NM_IN_STRSET(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO); else { @@ -622,6 +645,11 @@ get_auto_ip_config_method(NMDevice *device, int addr_family) NMDeviceWifiP2P * self = NM_DEVICE_WIFI_P2P(device); NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); + if (addr_family == AF_INET && priv->group_iface + && !nm_supplicant_interface_get_p2p_group_owner(priv->group_iface) + && nm_supplicant_interface_get_p2p_assigned_addr(priv->group_iface, NULL, NULL)) + return NM_SETTING_IP4_CONFIG_METHOD_DISABLED; + /* Override the AUTO method to mean shared if we are group owner. */ if (priv->group_iface && nm_supplicant_interface_get_p2p_group_owner(priv->group_iface)) { if (addr_family == AF_INET) @@ -1163,7 +1191,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) switch (prop_id) { case PROP_PEERS: list = nm_wifi_p2p_peers_get_paths(&priv->peers_lst_head); - g_value_take_boxed(value, nm_utils_strv_make_deep_copied(list)); + g_value_take_boxed(value, nm_strv_make_deep_copied(list)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); diff --git a/src/core/devices/wifi/nm-device-wifi.c b/src/core/devices/wifi/nm-device-wifi.c index fca2fde5..82896c77 100644 --- a/src/core/devices/wifi/nm-device-wifi.c +++ b/src/core/devices/wifi/nm-device-wifi.c @@ -17,6 +17,7 @@ #include "nm-device-wifi-p2p.h" #include "nm-wifi-ap.h" #include "libnm-core-aux-intern/nm-common-macros.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "devices/nm-device.h" #include "devices/nm-device-private.h" #include "nm-dbus-manager.h" @@ -321,7 +322,7 @@ _scan_request_ssids_track(NMDeviceWifiPrivate *priv, const GPtrArray *ssids) now_msec = nm_utils_get_monotonic_timestamp_msec(); if (!priv->scan_request_ssids_hash) - priv->scan_request_ssids_hash = g_hash_table_new(nm_pgbytes_hash, nm_pgbytes_equal); + priv->scan_request_ssids_hash = g_hash_table_new(nm_pg_bytes_hash, nm_pg_bytes_equal); /* Do a little dance. New elements shall keep their order as in @ssids, but all * new elements should be sorted in the list preexisting elements of the list. @@ -1205,10 +1206,7 @@ complete_connection(NMDevice * device, } /* Add a wifi setting if one doesn't exist yet */ - if (!s_wifi) { - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - } + s_wifi = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_WIRELESS); if (ap) ssid = nm_wifi_ap_get_ssid(ap); @@ -1571,7 +1569,7 @@ _scan_request_ssids_build_hidden(NMDeviceWifi *self, if (ssids) { if (ssids->len < max_scan_ssids) { /* Add wildcard SSID using a static wildcard SSID used for every scan */ - g_ptr_array_insert(ssids, 0, g_bytes_ref(nm_gbytes_get_empty())); + g_ptr_array_insert(ssids, 0, g_bytes_ref(nm_g_bytes_get_empty())); } if (ssids->len >= max_scan_ssids) { /* there is no more space. Use what we have. */ @@ -1592,10 +1590,10 @@ _scan_request_ssids_build_hidden(NMDeviceWifi *self, if (!ssids) { ssids = g_ptr_array_new_full(max_scan_ssids, (GDestroyNotify) g_bytes_unref); /* Add wildcard SSID using a static wildcard SSID used for every scan */ - g_ptr_array_insert(ssids, 0, g_bytes_ref(nm_gbytes_get_empty())); + g_ptr_array_insert(ssids, 0, g_bytes_ref(nm_g_bytes_get_empty())); } - unique_ssids = g_hash_table_new(nm_gbytes_hash, nm_gbytes_equal); + unique_ssids = g_hash_table_new(nm_g_bytes_hash, nm_g_bytes_equal); for (i = 1; i < ssids->len; i++) { if (!g_hash_table_add(unique_ssids, ssids->pdata[i])) nm_assert_not_reached(); @@ -1673,12 +1671,7 @@ _scan_supplicant_request_scan_cb(NMSupplicantInterface *supp_iface, * Artificially keep the scanning state on, for another SCAN_EXTRA_DELAY_MSEC msec. */ nm_clear_g_source_inst(&priv->scan_request_delay_source); priv->scan_request_delay_source = - nm_g_source_attach(nm_g_timeout_source_new(SCAN_EXTRA_DELAY_MSEC, - G_PRIORITY_DEFAULT, - _scan_request_delay_cb, - self, - NULL), - NULL); + nm_g_timeout_add_source(SCAN_EXTRA_DELAY_MSEC, _scan_request_delay_cb, self); g_clear_object(&priv->scan_request_cancellable); _scan_notify_is_scanning(self); @@ -3646,7 +3639,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) break; case PROP_ACCESS_POINTS: list = nm_wifi_aps_get_paths(&priv->aps_lst_head, TRUE); - g_value_take_boxed(value, nm_utils_strv_make_deep_copied(list)); + g_value_take_boxed(value, nm_strv_make_deep_copied(list)); break; case PROP_ACTIVE_ACCESS_POINT: nm_dbus_utils_g_value_set_object_path(value, priv->current_ap); diff --git a/src/core/devices/wifi/nm-wifi-ap.c b/src/core/devices/wifi/nm-wifi-ap.c index 20ed6833..72a60885 100644 --- a/src/core/devices/wifi/nm-wifi-ap.c +++ b/src/core/devices/wifi/nm-wifi-ap.c @@ -669,7 +669,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) g_value_set_uint(value, priv->rsn_flags); break; case PROP_SSID: - g_value_take_variant(value, nm_utils_gbytes_to_variant_ay(priv->ssid)); + g_value_take_variant(value, nm_g_bytes_to_variant_ay(priv->ssid)); break; case PROP_FREQUENCY: g_value_set_uint(value, priv->freq); diff --git a/src/core/devices/wifi/nm-wifi-common.c b/src/core/devices/wifi/nm-wifi-common.c index b98ef222..d029ce7f 100644 --- a/src/core/devices/wifi/nm-wifi-common.c +++ b/src/core/devices/wifi/nm-wifi-common.c @@ -13,7 +13,7 @@ #include "nm-dbus-manager.h" #if WITH_IWD - #include "nm-device-iwd.h" +#include "nm-device-iwd.h" #endif /*****************************************************************************/ diff --git a/src/core/devices/wifi/nm-wifi-p2p-peer.c b/src/core/devices/wifi/nm-wifi-p2p-peer.c index 433c2833..ac13952d 100644 --- a/src/core/devices/wifi/nm-wifi-p2p-peer.c +++ b/src/core/devices/wifi/nm-wifi-p2p-peer.c @@ -168,7 +168,7 @@ nm_wifi_p2p_peer_set_name(NMWifiP2PPeer *peer, const char *str) { NMWifiP2PPeerPrivate *priv = NM_WIFI_P2P_PEER_GET_PRIVATE(peer); - if (!nm_utils_strdup_reset(&priv->name, str)) + if (!nm_strdup_reset(&priv->name, str)) return FALSE; _notify(peer, PROP_NAME); return TRUE; @@ -187,7 +187,7 @@ nm_wifi_p2p_peer_set_manufacturer(NMWifiP2PPeer *peer, const char *str) { NMWifiP2PPeerPrivate *priv = NM_WIFI_P2P_PEER_GET_PRIVATE(peer); - if (!nm_utils_strdup_reset(&priv->manufacturer, str)) + if (!nm_strdup_reset(&priv->manufacturer, str)) return FALSE; _notify(peer, PROP_MANUFACTURER); return TRUE; @@ -206,7 +206,7 @@ nm_wifi_p2p_peer_set_model(NMWifiP2PPeer *peer, const char *str) { NMWifiP2PPeerPrivate *priv = NM_WIFI_P2P_PEER_GET_PRIVATE(peer); - if (!nm_utils_strdup_reset(&priv->model, str)) + if (!nm_strdup_reset(&priv->model, str)) return FALSE; _notify(peer, PROP_MODEL); return TRUE; @@ -225,7 +225,7 @@ nm_wifi_p2p_peer_set_model_number(NMWifiP2PPeer *peer, const char *str) { NMWifiP2PPeerPrivate *priv = NM_WIFI_P2P_PEER_GET_PRIVATE(peer); - if (!nm_utils_strdup_reset(&priv->model_number, str)) + if (!nm_strdup_reset(&priv->model_number, str)) return FALSE; _notify(peer, PROP_MODEL_NUMBER); return TRUE; @@ -244,7 +244,7 @@ nm_wifi_p2p_peer_set_serial(NMWifiP2PPeer *peer, const char *str) { NMWifiP2PPeerPrivate *priv = NM_WIFI_P2P_PEER_GET_PRIVATE(peer); - if (!nm_utils_strdup_reset(&priv->serial, str)) + if (!nm_strdup_reset(&priv->serial, str)) return FALSE; _notify(peer, PROP_SERIAL); return TRUE; @@ -268,7 +268,7 @@ nm_wifi_p2p_peer_set_wfd_ies(NMWifiP2PPeer *peer, GBytes *wfd_ies) priv = NM_WIFI_P2P_PEER_GET_PRIVATE(peer); - if (nm_gbytes_equal0(priv->wfd_ies, wfd_ies)) + if (nm_g_bytes_equal0(priv->wfd_ies, wfd_ies)) return FALSE; wfd_ies_old = g_steal_pointer(&priv->wfd_ies); @@ -408,9 +408,9 @@ nm_wifi_p2p_peer_update_from_properties(NMWifiP2PPeer *peer, const NMSupplicantP /* We currently only use the groups information internally to check if * the peer is still joined. */ - if (!nm_utils_strv_equal(priv->groups, peer_info->groups)) { + if (!nm_strv_equal(priv->groups, peer_info->groups)) { g_free(priv->groups); - priv->groups = nm_utils_strv_dup_packed(peer_info->groups, -1); + priv->groups = nm_strv_dup_packed(peer_info->groups, -1); changed |= TRUE; } @@ -509,7 +509,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) g_value_set_string(value, priv->serial); break; case PROP_WFD_IES: - g_value_take_variant(value, nm_utils_gbytes_to_variant_ay(priv->wfd_ies)); + g_value_take_variant(value, nm_g_bytes_to_variant_ay(priv->wfd_ies)); break; case PROP_HW_ADDRESS: g_value_set_string(value, priv->address); diff --git a/src/core/devices/wifi/nm-wifi-utils.c b/src/core/devices/wifi/nm-wifi-utils.c index 15ced990..4939e786 100644 --- a/src/core/devices/wifi/nm-wifi-utils.c +++ b/src/core/devices/wifi/nm-wifi-utils.c @@ -13,6 +13,7 @@ #include "nm-utils.h" #include "libnm-core-intern/nm-core-internal.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-aux-intern/nm-common-macros.h" #include "libnm-base/nm-config-base.h" @@ -679,10 +680,7 @@ nm_wifi_utils_complete_connection(GBytes * ap_ssid, } /* Everything else requires security */ - if (!s_wsec) { - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wsec)); - } + s_wsec = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); key_mgmt = nm_setting_wireless_security_get_key_mgmt(s_wsec); auth_alg = nm_setting_wireless_security_get_auth_alg(s_wsec); @@ -825,21 +823,11 @@ nm_wifi_utils_complete_connection(GBytes * ap_ssid, "open", NULL); } else if (nm_streq0(key_mgmt, "sae") || (ap_rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_SAE)) { - g_object_set(s_wsec, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, - "sae", - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, - "open", - NULL); + g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "sae", NULL); } else if (nm_streq0(key_mgmt, "owe") || NM_FLAGS_ANY(ap_rsn_flags, NM_802_11_AP_SEC_KEY_MGMT_OWE | NM_802_11_AP_SEC_KEY_MGMT_OWE_TM)) { - g_object_set(s_wsec, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, - "owe", - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, - "open", - NULL); + g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "owe", NULL); } else if (ap_wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK || ap_rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK) { g_object_set(s_wsec, @@ -853,12 +841,7 @@ nm_wifi_utils_complete_connection(GBytes * ap_ssid, */ } else if (nm_streq0(key_mgmt, "wpa-eap-suite-b-192") || (ap_rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_EAP_SUITE_B_192)) { - g_object_set(s_wsec, - NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, - "wpa-eap-suite-b-192", - NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, - "open", - NULL); + g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap-suite-b-192", NULL); } else { g_set_error_literal(error, NM_CONNECTION_ERROR, diff --git a/src/core/devices/wifi/tests/test-devices-wifi.c b/src/core/devices/wifi/tests/test-devices-wifi.c index dc278c94..5d1167cf 100644 --- a/src/core/devices/wifi/tests/test-devices-wifi.c +++ b/src/core/devices/wifi/tests/test-devices-wifi.c @@ -1445,7 +1445,7 @@ do_test_ssids_options_to_ptrarray(const char *const *ssids) const char *ssid = ssids[i]; GBytes * bytes = ssids_arr->pdata[i]; - g_assert(nm_utils_gbytes_equal_mem(bytes, ssid, strlen(ssid))); + g_assert(nm_g_bytes_equal_mem(bytes, ssid, strlen(ssid))); } } diff --git a/src/core/devices/wwan/nm-device-modem.c b/src/core/devices/wwan/nm-device-modem.c index 4d892e6f..1b285469 100644 --- a/src/core/devices/wwan/nm-device-modem.c +++ b/src/core/devices/wwan/nm-device-modem.c @@ -616,18 +616,20 @@ act_stage3_ip_config_start(NMDevice * device, gpointer * out_config, NMDeviceStateReason *out_failure_reason) { - NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(device); - - nm_assert_addr_family(addr_family); + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(device); + gboolean autoip4 = FALSE; + NMActStageReturn ret; - if (addr_family == AF_INET) { - return nm_modem_stage3_ip4_config_start(priv->modem, - device, - NM_DEVICE_CLASS(nm_device_modem_parent_class), - out_failure_reason); - } else { + if (!NM_IS_IPv4(addr_family)) return nm_modem_stage3_ip6_config_start(priv->modem, device, out_failure_reason); - } + + ret = nm_modem_stage3_ip4_config_start(priv->modem, device, &autoip4, out_failure_reason); + + if (ret != NM_ACT_STAGE_RETURN_SUCCESS || !autoip4) + return ret; + + return NM_DEVICE_CLASS(nm_device_modem_parent_class) + ->act_stage3_ip_config_start(device, addr_family, out_config, out_failure_reason); } static void diff --git a/src/core/devices/wwan/nm-modem-broadband.c b/src/core/devices/wwan/nm-modem-broadband.c index 0872a8a1..a5139f08 100644 --- a/src/core/devices/wwan/nm-modem-broadband.c +++ b/src/core/devices/wwan/nm-modem-broadband.c @@ -11,6 +11,7 @@ #include #include +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" #include "NetworkManagerUtils.h" #include "devices/nm-device-private.h" @@ -829,11 +830,7 @@ complete_connection(NMModem * modem, if (MODEM_CAPS_3GPP2(modem_caps)) { NMSettingCdma *s_cdma; - s_cdma = nm_connection_get_setting_cdma(connection); - if (!s_cdma) { - s_cdma = (NMSettingCdma *) nm_setting_cdma_new(); - nm_connection_add_setting(connection, NM_SETTING(s_cdma)); - } + s_cdma = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_CDMA); if (!nm_setting_cdma_get_number(s_cdma)) g_object_set(G_OBJECT(s_cdma), NM_SETTING_CDMA_NUMBER, "#777", NULL); diff --git a/src/core/devices/wwan/nm-modem-manager.c b/src/core/devices/wwan/nm-modem-manager.c index 4fb9a378..8d087d13 100644 --- a/src/core/devices/wwan/nm-modem-manager.c +++ b/src/core/devices/wwan/nm-modem-manager.c @@ -12,9 +12,9 @@ #include #if HAVE_LIBSYSTEMD - #include +#include #else - #define sd_booted() FALSE +#define sd_booted() FALSE #endif #include "libnm-std-aux/nm-dbus-compat.h" @@ -22,7 +22,7 @@ #include "nm-modem-broadband.h" #if WITH_OFONO - #include "nm-modem-ofono.h" +#include "nm-modem-ofono.h" #endif #define MODEM_POKE_INTERVAL 120 diff --git a/src/core/devices/wwan/nm-modem.c b/src/core/devices/wwan/nm-modem.c index 15baa677..ccea69db 100644 --- a/src/core/devices/wwan/nm-modem.c +++ b/src/core/devices/wwan/nm-modem.c @@ -526,48 +526,6 @@ static void ppp_ip4_config(NMPPPManager *ppp_manager, NMIP4Config *config, gpointer user_data) { NMModem *self = NM_MODEM(user_data); - guint32 i, num; - guint32 bad_dns1 = htonl(0x0A0B0C0D); - guint32 good_dns1 = htonl(0x04020201); /* GTE nameserver */ - guint32 bad_dns2 = htonl(0x0A0B0C0E); - guint32 good_dns2 = htonl(0x04020202); /* GTE nameserver */ - gboolean dns_workaround = FALSE; - - /* Work around a PPP bug (#1732) which causes many mobile broadband - * providers to return 10.11.12.13 and 10.11.12.14 for the DNS servers. - * Apparently fixed in ppp-2.4.5 but we've had some reports that this is - * not the case. - * - * http://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=2e09ef6886bbf00bc5a9a641110f801e372ffde6 - * http://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=f8191bf07df374f119a07910a79217c7618f113e - */ - - num = nm_ip4_config_get_num_nameservers(config); - if (num == 2) { - gboolean found1 = FALSE, found2 = FALSE; - - for (i = 0; i < num; i++) { - guint32 ns = nm_ip4_config_get_nameserver(config, i); - - if (ns == bad_dns1) - found1 = TRUE; - else if (ns == bad_dns2) - found2 = TRUE; - } - - /* Be somewhat conservative about substitutions; the "bad" nameservers - * could actually be valid in some cases, so only substitute if ppp - * returns *only* the two bad nameservers. - */ - dns_workaround = (found1 && found2); - } - - if (!num || dns_workaround) { - _LOGW("compensating for invalid PPP-provided nameservers"); - nm_ip4_config_reset_nameservers(config); - nm_ip4_config_add_nameserver(config, good_dns1); - nm_ip4_config_add_nameserver(config, good_dns2); - } g_signal_emit(self, signals[IP4_CONFIG_RESULT], 0, config, NULL); } @@ -727,7 +685,7 @@ ppp_stage3_ip_config_start(NMModem * self, NMActStageReturn nm_modem_stage3_ip4_config_start(NMModem * self, NMDevice * device, - NMDeviceClass * device_class, + gboolean * out_autoip4, NMDeviceStateReason *out_failure_reason) { NMModemPrivate * priv; @@ -740,7 +698,7 @@ nm_modem_stage3_ip4_config_start(NMModem * self, g_return_val_if_fail(NM_IS_MODEM(self), NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail(NM_IS_DEVICE(device), NM_ACT_STAGE_RETURN_FAILURE); - g_return_val_if_fail(NM_IS_DEVICE_CLASS(device_class), NM_ACT_STAGE_RETURN_FAILURE); + nm_assert(out_autoip4 && !*out_autoip4); req = nm_device_get_act_request(device); g_return_val_if_fail(req, NM_ACT_STAGE_RETURN_FAILURE); @@ -774,7 +732,8 @@ nm_modem_stage3_ip4_config_start(NMModem * self, break; case NM_MODEM_IP_METHOD_AUTO: _LOGD("MODEM_IP_METHOD_AUTO"); - ret = device_class->act_stage3_ip_config_start(device, AF_INET, NULL, out_failure_reason); + *out_autoip4 = TRUE; + ret = NM_ACT_STAGE_RETURN_SUCCESS; break; default: _LOGI("IPv4 configuration disabled"); diff --git a/src/core/devices/wwan/nm-modem.h b/src/core/devices/wwan/nm-modem.h index 87162cfc..4bc81ff8 100644 --- a/src/core/devices/wwan/nm-modem.h +++ b/src/core/devices/wwan/nm-modem.h @@ -210,7 +210,7 @@ void nm_modem_act_stage2_config(NMModem *modem); NMActStageReturn nm_modem_stage3_ip4_config_start(NMModem * modem, NMDevice * device, - NMDeviceClass * device_class, + gboolean * out_autoip4, NMDeviceStateReason *out_failure_reason); NMActStageReturn nm_modem_stage3_ip6_config_start(NMModem * modem, diff --git a/src/core/dhcp/nm-dhcp-client.c b/src/core/dhcp/nm-dhcp-client.c index ab8243d0..f88c79c0 100644 --- a/src/core/dhcp/nm-dhcp-client.c +++ b/src/core/dhcp/nm-dhcp-client.c @@ -28,7 +28,7 @@ /*****************************************************************************/ -enum { SIGNAL_STATE_CHANGED, SIGNAL_PREFIX_DELEGATED, LAST_SIGNAL }; +enum { SIGNAL_NOTIFY, LAST_SIGNAL }; static guint signals[LAST_SIGNAL] = {0}; @@ -78,6 +78,7 @@ typedef struct _NMDhcpClientPrivate { NMDhcpHostnameFlags hostname_flags; NMDhcpClientFlags client_flags; bool iaid_explicit : 1; + bool is_stopped : 1; } NMDhcpClientPrivate; G_DEFINE_ABSTRACT_TYPE(NMDhcpClient, nm_dhcp_client, G_TYPE_OBJECT) @@ -91,6 +92,33 @@ G_STATIC_ASSERT(!(((pid_t) -1) > 0)); /*****************************************************************************/ +static void +_emit_notify(NMDhcpClient *self, const NMDhcpClientNotifyData *notify_data) +{ + g_signal_emit(G_OBJECT(self), signals[SIGNAL_NOTIFY], 0, notify_data); +} + +static void +_emit_notify_state_changed(NMDhcpClient *self, + NMDhcpState dhcp_state, + NMIPConfig * ip_config, + GHashTable * options) +{ + const NMDhcpClientNotifyData notify_data = { + .notify_type = NM_DHCP_CLIENT_NOTIFY_TYPE_STATE_CHANGED, + .state_changed = + { + .dhcp_state = dhcp_state, + .ip_config = ip_config, + .options = options, + }, + }; + + _emit_notify(self, ¬ify_data); +} + +/*****************************************************************************/ + pid_t nm_dhcp_client_get_pid(NMDhcpClient *self) { @@ -352,8 +380,7 @@ NM_UTILS_LOOKUP_STR_DEFINE(nm_dhcp_state_to_string, NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_NOOP, "noop"), NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_TERMINATED, "terminated"), NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_TIMEOUT, "timeout"), - NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_UNKNOWN, "unknown"), - NM_UTILS_LOOKUP_ITEM_IGNORE(__NM_DHCP_STATE_MAX), ); + NM_UTILS_LOOKUP_STR_ITEM(NM_DHCP_STATE_UNKNOWN, "unknown"), ); static NMDhcpState reason_to_state(NMDhcpClient *self, const char *iface, const char *reason) @@ -469,7 +496,7 @@ nm_dhcp_client_set_state(NMDhcpClient *self, gs_free const char **keys = NULL; guint i, nkeys; - keys = nm_utils_strdict_get_keys(options, TRUE, &nkeys); + keys = nm_strdict_get_keys(options, TRUE, &nkeys); for (i = 0; i < nkeys; i++) { _LOGD("option %-20s => '%s'", keys[i], (char *) g_hash_table_lookup(options, keys[i])); } @@ -497,7 +524,8 @@ nm_dhcp_client_set_state(NMDhcpClient *self, } priv->state = new_state; - g_signal_emit(G_OBJECT(self), signals[SIGNAL_STATE_CHANGED], 0, new_state, ip_config, options); + + _emit_notify_state_changed(self, new_state, ip_config, options); } static gboolean @@ -607,6 +635,20 @@ nm_dhcp_client_accept(NMDhcpClient *self, GError **error) return TRUE; } +gboolean +nm_dhcp_client_can_accept(NMDhcpClient *self) +{ + gboolean can_accept; + + g_return_val_if_fail(NM_IS_DHCP_CLIENT(self), FALSE); + + can_accept = !!(NM_DHCP_CLIENT_GET_CLASS(self)->accept); + + nm_assert(can_accept == (!!(NM_DHCP_CLIENT_GET_CLASS(self)->decline))); + + return can_accept; +} + gboolean nm_dhcp_client_decline(NMDhcpClient *self, const char *error_message, GError **error) { @@ -733,6 +775,11 @@ nm_dhcp_client_stop(NMDhcpClient *self, gboolean release) priv = NM_DHCP_CLIENT_GET_PRIVATE(self); + if (priv->is_stopped) + return; + + priv->is_stopped = TRUE; + /* Kill the DHCP client */ old_pid = priv->pid; NM_DHCP_CLIENT_GET_CLASS(self)->stop(self, release); @@ -855,7 +902,15 @@ maybe_add_option(NMDhcpClient *self, GHashTable *hash, const char *key, GVariant void nm_dhcp_client_emit_ipv6_prefix_delegated(NMDhcpClient *self, const NMPlatformIP6Address *prefix) { - g_signal_emit(G_OBJECT(self), signals[SIGNAL_PREFIX_DELEGATED], 0, prefix); + const NMDhcpClientNotifyData notify_data = { + .notify_type = NM_DHCP_CLIENT_NOTIFY_TYPE_PREFIX_DELEGATED, + .prefix_delegated = + { + .prefix = prefix, + }, + }; + + _emit_notify(self, ¬ify_data); } gboolean @@ -1124,7 +1179,7 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps break; case PROP_REJECT_SERVERS: /* construct-only */ - priv->reject_servers = nm_utils_strv_dup_packed(g_value_get_boxed(value), -1); + priv->reject_servers = nm_strv_dup_packed(g_value_get_boxed(value), -1); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -1142,8 +1197,6 @@ nm_dhcp_client_init(NMDhcpClient *self) priv = G_TYPE_INSTANCE_GET_PRIVATE(self, NM_TYPE_DHCP_CLIENT, NMDhcpClientPrivate); self->_priv = priv; - c_list_init(&self->dhcp_client_lst); - priv->pid = -1; } @@ -1175,12 +1228,7 @@ dispose(GObject *object) NMDhcpClient * self = NM_DHCP_CLIENT(object); NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self); - /* Stopping the client is left up to the controlling device - * explicitly since we may want to quit NetworkManager but not terminate - * the DHCP client. - */ - - nm_assert(c_list_is_empty(&self->dhcp_client_lst)); + nm_dhcp_client_stop(self, FALSE); watch_cleanup(self); timeout_cleanup(self); @@ -1369,27 +1417,15 @@ nm_dhcp_client_class_init(NMDhcpClientClass *client_class) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - signals[SIGNAL_STATE_CHANGED] = g_signal_new(NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED, - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, - NULL, - NULL, - G_TYPE_NONE, - 3, - G_TYPE_UINT, - G_TYPE_OBJECT, - G_TYPE_HASH_TABLE); - - signals[SIGNAL_PREFIX_DELEGATED] = g_signal_new(NM_DHCP_CLIENT_SIGNAL_PREFIX_DELEGATED, - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, - NULL, - NULL, - G_TYPE_NONE, - 1, - G_TYPE_POINTER); + signals[SIGNAL_NOTIFY] = + g_signal_new(NM_DHCP_CLIENT_NOTIFY, + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_FIRST, + 0, + NULL, + NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, + 1, + G_TYPE_POINTER /* const NMDhcpClientNotifyData *notify_data */); } diff --git a/src/core/dhcp/nm-dhcp-client.h b/src/core/dhcp/nm-dhcp-client.h index 3fe1b34e..2e7e0216 100644 --- a/src/core/dhcp/nm-dhcp-client.h +++ b/src/core/dhcp/nm-dhcp-client.h @@ -44,8 +44,7 @@ #define NM_DHCP_CLIENT_VENDOR_CLASS_IDENTIFIER "vendor-class-identifier" #define NM_DHCP_CLIENT_REJECT_SERVERS "reject-servers" -#define NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED "state-changed" -#define NM_DHCP_CLIENT_SIGNAL_PREFIX_DELEGATED "prefix-delegated" +#define NM_DHCP_CLIENT_NOTIFY "dhcp-notify" typedef enum { NM_DHCP_STATE_UNKNOWN = 0, @@ -57,10 +56,27 @@ typedef enum { NM_DHCP_STATE_FAIL, /* failed for some reason */ NM_DHCP_STATE_TERMINATED, /* client is no longer running */ NM_DHCP_STATE_NOOP, /* state is a non operation for NetworkManager */ - __NM_DHCP_STATE_MAX, - NM_DHCP_STATE_MAX = __NM_DHCP_STATE_MAX - 1, } NMDhcpState; +typedef enum _nm_packed { + NM_DHCP_CLIENT_NOTIFY_TYPE_STATE_CHANGED, + NM_DHCP_CLIENT_NOTIFY_TYPE_PREFIX_DELEGATED, +} NMDhcpClientNotifyType; + +typedef struct { + NMDhcpClientNotifyType notify_type; + union { + struct { + NMIPConfig *ip_config; + GHashTable *options; + NMDhcpState dhcp_state; + } state_changed; + struct { + const NMPlatformIP6Address *prefix; + } prefix_delegated; + }; +} NMDhcpClientNotifyData; + const char *nm_dhcp_state_to_string(NMDhcpState state); struct _NMDhcpClientPrivate; @@ -68,7 +84,6 @@ struct _NMDhcpClientPrivate; typedef struct { GObject parent; struct _NMDhcpClientPrivate *_priv; - CList dhcp_client_lst; } NMDhcpClient; typedef enum _nm_packed { @@ -173,6 +188,7 @@ gboolean nm_dhcp_client_start_ip6(NMDhcpClient * self, GError ** error); gboolean nm_dhcp_client_accept(NMDhcpClient *self, GError **error); +gboolean nm_dhcp_client_can_accept(NMDhcpClient *self); gboolean nm_dhcp_client_decline(NMDhcpClient *self, const char *error_message, GError **error); @@ -217,11 +233,13 @@ gboolean nm_dhcp_client_server_id_is_rejected(NMDhcpClient *self, gconstpointer *****************************************************************************/ typedef struct { - GType (*get_type)(void); - GType (*get_type_per_addr_family)(int addr_family); + GType (*get_type_4)(void); + GType (*get_type_6)(void); const char *name; const char *(*get_path)(void); - bool experimental : 1; + + /* whether this plugin is an undocumented, internal plugin. */ + bool undocumented : 1; } NMDhcpClientFactory; GType nm_dhcp_nettools_get_type(void); diff --git a/src/core/dhcp/nm-dhcp-dhclient-utils.c b/src/core/dhcp/nm-dhcp-dhclient-utils.c index 4284a852..341ac7b2 100644 --- a/src/core/dhcp/nm-dhcp-dhclient-utils.c +++ b/src/core/dhcp/nm-dhcp-dhclient-utils.c @@ -59,7 +59,7 @@ grab_request_options(GPtrArray *store, const char *line) gsize i; /* Grab each 'request' or 'also request' option and save for later */ - line_v = nm_utils_strsplit_set(line, "\t ,"); + line_v = nm_strsplit_set(line, "\t ,"); for (i = 0; line_v && line_v[i]; i++) { const char *ss = nm_str_skip_leading_spaces(line_v[i]); gsize l; @@ -282,7 +282,7 @@ read_interface(const char *line, char *interface, guint size) if (ptr[0] == '\0' || strlen(ptr) + 1 > size) return FALSE; - snprintf(interface, size, "%s", ptr); + g_snprintf(interface, size, "%s", ptr); return TRUE; } @@ -330,7 +330,7 @@ nm_dhcp_dhclient_create_config(const char * interface, g_string_append_printf(new_contents, _("# Merged from %s\n\n"), orig_path); intf[0] = '\0'; - lines = nm_utils_strsplit_set(orig_contents, "\n\r"); + lines = nm_strsplit_set(orig_contents, "\n\r"); for (line_i = 0; lines && lines[line_i]; line_i++) { const char *line = nm_str_skip_leading_spaces(lines[line_i]); const char *p; @@ -620,7 +620,7 @@ nm_dhcp_dhclient_read_duid(const char *leasefile, GError **error) if (!g_file_get_contents(leasefile, &contents, NULL, error)) return NULL; - contents_v = nm_utils_strsplit_set(contents, "\n\r"); + contents_v = nm_strsplit_set(contents, "\n\r"); for (i = 0; contents_v && contents_v[i]; i++) { const char *p = nm_str_skip_leading_spaces(contents_v[i]); GBytes * duid; @@ -671,7 +671,7 @@ nm_dhcp_dhclient_save_duid(const char *leasefile, GBytes *duid, GError **error) return FALSE; } - lines = nm_utils_strsplit_set_with_empty(contents, "\n\r"); + lines = nm_strsplit_set_with_empty(contents, "\n\r"); } s = g_string_sized_new(len + 50); diff --git a/src/core/dhcp/nm-dhcp-dhclient.c b/src/core/dhcp/nm-dhcp-dhclient.c index 4a11250f..970a51f5 100644 --- a/src/core/dhcp/nm-dhcp-dhclient.c +++ b/src/core/dhcp/nm-dhcp-dhclient.c @@ -14,21 +14,21 @@ #if WITH_DHCLIENT - #include - #include - #include - #include - #include - #include - - #include "libnm-glib-aux/nm-dedup-multi.h" - - #include "nm-utils.h" - #include "nm-dhcp-dhclient-utils.h" - #include "nm-dhcp-manager.h" - #include "NetworkManagerUtils.h" - #include "nm-dhcp-listener.h" - #include "nm-dhcp-client-logging.h" +#include +#include +#include +#include +#include +#include + +#include "libnm-glib-aux/nm-dedup-multi.h" + +#include "nm-utils.h" +#include "nm-dhcp-dhclient-utils.h" +#include "nm-dhcp-manager.h" +#include "NetworkManagerUtils.h" +#include "nm-dhcp-listener.h" +#include "nm-dhcp-client-logging.h" /*****************************************************************************/ @@ -41,16 +41,15 @@ _addr_family_to_path_part(int addr_family) /*****************************************************************************/ - #define NM_TYPE_DHCP_DHCLIENT (nm_dhcp_dhclient_get_type()) - #define NM_DHCP_DHCLIENT(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_DHCP_DHCLIENT, NMDhcpDhclient)) - #define NM_DHCP_DHCLIENT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_DHCP_DHCLIENT, NMDhcpDhclientClass)) - #define NM_IS_DHCP_DHCLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_DHCP_DHCLIENT)) - #define NM_IS_DHCP_DHCLIENT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_DHCP_DHCLIENT)) - #define NM_DHCP_DHCLIENT_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_DHCP_DHCLIENT, NMDhcpDhclientClass)) +#define NM_TYPE_DHCP_DHCLIENT (nm_dhcp_dhclient_get_type()) +#define NM_DHCP_DHCLIENT(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_DHCP_DHCLIENT, NMDhcpDhclient)) +#define NM_DHCP_DHCLIENT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_DHCP_DHCLIENT, NMDhcpDhclientClass)) +#define NM_IS_DHCP_DHCLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_DHCP_DHCLIENT)) +#define NM_IS_DHCP_DHCLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_DHCP_DHCLIENT)) +#define NM_DHCP_DHCLIENT_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_DHCP_DHCLIENT, NMDhcpDhclientClass)) typedef struct _NMDhcpDhclient NMDhcpDhclient; typedef struct _NMDhcpDhclientClass NMDhcpDhclientClass; @@ -78,8 +77,8 @@ struct _NMDhcpDhclientClass { G_DEFINE_TYPE(NMDhcpDhclient, nm_dhcp_dhclient, NM_TYPE_DHCP_CLIENT) - #define NM_DHCP_DHCLIENT_GET_PRIVATE(self) \ - _NM_GET_PRIVATE(self, NMDhcpDhclient, NM_IS_DHCP_DHCLIENT) +#define NM_DHCP_DHCLIENT_GET_PRIVATE(self) \ + _NM_GET_PRIVATE(self, NMDhcpDhclient, NM_IS_DHCP_DHCLIENT) /*****************************************************************************/ @@ -731,9 +730,10 @@ nm_dhcp_dhclient_class_init(NMDhcpDhclientClass *dhclient_class) } const NMDhcpClientFactory _nm_dhcp_client_factory_dhclient = { - .name = "dhclient", - .get_type = nm_dhcp_dhclient_get_type, - .get_path = nm_dhcp_dhclient_get_path, + .name = "dhclient", + .get_type_4 = nm_dhcp_dhclient_get_type, + .get_type_6 = nm_dhcp_dhclient_get_type, + .get_path = nm_dhcp_dhclient_get_path, }; #endif /* WITH_DHCLIENT */ diff --git a/src/core/dhcp/nm-dhcp-dhcpcanon.c b/src/core/dhcp/nm-dhcp-dhcpcanon.c index f3a52ea9..f993ffb9 100644 --- a/src/core/dhcp/nm-dhcp-dhcpcanon.c +++ b/src/core/dhcp/nm-dhcp-dhcpcanon.c @@ -7,25 +7,24 @@ #if WITH_DHCPCANON - #include - #include - - #include "nm-utils.h" - #include "nm-dhcp-manager.h" - #include "NetworkManagerUtils.h" - #include "nm-dhcp-listener.h" - #include "nm-dhcp-client-logging.h" - - #define NM_TYPE_DHCP_DHCPCANON (nm_dhcp_dhcpcanon_get_type()) - #define NM_DHCP_DHCPCANON(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_DHCP_DHCPCANON, NMDhcpDhcpcanon)) - #define NM_DHCP_DHCPCANON_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_DHCP_DHCPCANON, NMDhcpDhcpcanonClass)) - #define NM_IS_DHCP_DHCPCANON(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_DHCP_DHCPCANON)) - #define NM_IS_DHCP_DHCPCANON_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_DHCP_DHCPCANON)) - #define NM_DHCP_DHCPCANON_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_DHCP_DHCPCANON, NMDhcpDhcpcanonClass)) +#include +#include + +#include "nm-utils.h" +#include "nm-dhcp-manager.h" +#include "NetworkManagerUtils.h" +#include "nm-dhcp-listener.h" +#include "nm-dhcp-client-logging.h" + +#define NM_TYPE_DHCP_DHCPCANON (nm_dhcp_dhcpcanon_get_type()) +#define NM_DHCP_DHCPCANON(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_DHCP_DHCPCANON, NMDhcpDhcpcanon)) +#define NM_DHCP_DHCPCANON_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_DHCP_DHCPCANON, NMDhcpDhcpcanonClass)) +#define NM_IS_DHCP_DHCPCANON(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_DHCP_DHCPCANON)) +#define NM_IS_DHCP_DHCPCANON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_DHCP_DHCPCANON)) +#define NM_DHCP_DHCPCANON_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_DHCP_DHCPCANON, NMDhcpDhcpcanonClass)) typedef struct _NMDhcpDhcpcanon NMDhcpDhcpcanon; typedef struct _NMDhcpDhcpcanonClass NMDhcpDhcpcanonClass; @@ -53,8 +52,8 @@ struct _NMDhcpDhcpcanonClass { G_DEFINE_TYPE(NMDhcpDhcpcanon, nm_dhcp_dhcpcanon, NM_TYPE_DHCP_CLIENT) - #define NM_DHCP_DHCPCANON_GET_PRIVATE(self) \ - _NM_GET_PRIVATE(self, NMDhcpDhcpcanon, NM_IS_DHCP_DHCPCANON) +#define NM_DHCP_DHCPCANON_GET_PRIVATE(self) \ + _NM_GET_PRIVATE(self, NMDhcpDhcpcanon, NM_IS_DHCP_DHCPCANON) /*****************************************************************************/ @@ -232,9 +231,9 @@ nm_dhcp_dhcpcanon_class_init(NMDhcpDhcpcanonClass *dhcpcanon_class) } const NMDhcpClientFactory _nm_dhcp_client_factory_dhcpcanon = { - .name = "dhcpcanon", - .get_type = nm_dhcp_dhcpcanon_get_type, - .get_path = nm_dhcp_dhcpcanon_get_path, + .name = "dhcpcanon", + .get_type_4 = nm_dhcp_dhcpcanon_get_type, + .get_path = nm_dhcp_dhcpcanon_get_path, }; #endif /* WITH_DHCPCANON */ diff --git a/src/core/dhcp/nm-dhcp-dhcpcd.c b/src/core/dhcp/nm-dhcp-dhcpcd.c index 605fb84d..7522156b 100644 --- a/src/core/dhcp/nm-dhcp-dhcpcd.c +++ b/src/core/dhcp/nm-dhcp-dhcpcd.c @@ -8,29 +8,28 @@ #if WITH_DHCPCD - #include - #include - #include - #include - #include - - #include "nm-dhcp-manager.h" - #include "nm-utils.h" - #include "NetworkManagerUtils.h" - #include "nm-dhcp-listener.h" - #include "nm-dhcp-client-logging.h" +#include +#include +#include +#include +#include + +#include "nm-dhcp-manager.h" +#include "nm-utils.h" +#include "NetworkManagerUtils.h" +#include "nm-dhcp-listener.h" +#include "nm-dhcp-client-logging.h" /*****************************************************************************/ - #define NM_TYPE_DHCP_DHCPCD (nm_dhcp_dhcpcd_get_type()) - #define NM_DHCP_DHCPCD(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_DHCP_DHCPCD, NMDhcpDhcpcd)) - #define NM_DHCP_DHCPCD_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_DHCP_DHCPCD, NMDhcpDhcpcdClass)) - #define NM_IS_DHCP_DHCPCD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_DHCP_DHCPCD)) - #define NM_IS_DHCP_DHCPCD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_DHCP_DHCPCD)) - #define NM_DHCP_DHCPCD_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_DHCP_DHCPCD, NMDhcpDhcpcdClass)) +#define NM_TYPE_DHCP_DHCPCD (nm_dhcp_dhcpcd_get_type()) +#define NM_DHCP_DHCPCD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_DHCP_DHCPCD, NMDhcpDhcpcd)) +#define NM_DHCP_DHCPCD_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_DHCP_DHCPCD, NMDhcpDhcpcdClass)) +#define NM_IS_DHCP_DHCPCD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_DHCP_DHCPCD)) +#define NM_IS_DHCP_DHCPCD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_DHCP_DHCPCD)) +#define NM_DHCP_DHCPCD_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_DHCP_DHCPCD, NMDhcpDhcpcdClass)) typedef struct _NMDhcpDhcpcd NMDhcpDhcpcd; typedef struct _NMDhcpDhcpcdClass NMDhcpDhcpcdClass; @@ -54,7 +53,7 @@ struct _NMDhcpDhcpcdClass { G_DEFINE_TYPE(NMDhcpDhcpcd, nm_dhcp_dhcpcd, NM_TYPE_DHCP_CLIENT) - #define NM_DHCP_DHCPCD_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDhcpDhcpcd, NM_IS_DHCP_DHCPCD) +#define NM_DHCP_DHCPCD_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDhcpDhcpcd, NM_IS_DHCP_DHCPCD) /*****************************************************************************/ @@ -233,9 +232,9 @@ nm_dhcp_dhcpcd_class_init(NMDhcpDhcpcdClass *dhcpcd_class) } const NMDhcpClientFactory _nm_dhcp_client_factory_dhcpcd = { - .name = "dhcpcd", - .get_type = nm_dhcp_dhcpcd_get_type, - .get_path = nm_dhcp_dhcpcd_get_path, + .name = "dhcpcd", + .get_type_4 = nm_dhcp_dhcpcd_get_type, + .get_path = nm_dhcp_dhcpcd_get_path, }; #endif /* WITH_DHCPCD */ diff --git a/src/core/dhcp/nm-dhcp-helper.c b/src/core/dhcp/nm-dhcp-helper.c index 56d20101..fd666676 100644 --- a/src/core/dhcp/nm-dhcp-helper.c +++ b/src/core/dhcp/nm-dhcp-helper.c @@ -16,9 +16,9 @@ /*****************************************************************************/ #if NM_MORE_LOGGING - #define _NMLOG_ENABLED(level) TRUE +#define _NMLOG_ENABLED(level) TRUE #else - #define _NMLOG_ENABLED(level) ((level) <= LOG_ERR) +#define _NMLOG_ENABLED(level) ((level) <= LOG_ERR) #endif #define _NMLOG(always_enabled, level, ...) \ diff --git a/src/core/dhcp/nm-dhcp-listener.c b/src/core/dhcp/nm-dhcp-listener.c index b8bb3c33..ae2c40f1 100644 --- a/src/core/dhcp/nm-dhcp-listener.c +++ b/src/core/dhcp/nm-dhcp-listener.c @@ -26,8 +26,9 @@ /*****************************************************************************/ const NMDhcpClientFactory *const _nm_dhcp_manager_factories[6] = { + /* the order here matters, as we will try the plugins in this order to find - * the first available plugin. */ + * the first available plugin. */ #if WITH_DHCPCANON &_nm_dhcp_client_factory_dhcpcanon, diff --git a/src/core/dhcp/nm-dhcp-manager.c b/src/core/dhcp/nm-dhcp-manager.c index 44b8ede2..3cb89393 100644 --- a/src/core/dhcp/nm-dhcp-manager.c +++ b/src/core/dhcp/nm-dhcp-manager.c @@ -27,7 +27,6 @@ typedef struct { const NMDhcpClientFactory *client_factory; char * default_hostname; - CList dhcp_client_lst_head; } NMDhcpManagerPrivate; struct _NMDhcpManager { @@ -45,14 +44,6 @@ G_DEFINE_TYPE(NMDhcpManager, nm_dhcp_manager, G_TYPE_OBJECT) /*****************************************************************************/ -static void client_state_changed(NMDhcpClient * client, - NMDhcpState state, - GObject * ip_config, - GVariant * options, - NMDhcpManager *self); - -/*****************************************************************************/ - /* default to installed helper, but can be modified for testing */ const char *nm_dhcp_helper_path = LIBEXECDIR "/nm-dhcp-helper"; @@ -63,9 +54,9 @@ _client_factory_find_by_name(const char *name) { int i; - g_return_val_if_fail(name, NULL); + nm_assert(name); - for (i = 0; i < G_N_ELEMENTS(_nm_dhcp_manager_factories); i++) { + for (i = 0; i < (int) G_N_ELEMENTS(_nm_dhcp_manager_factories); i++) { const NMDhcpClientFactory *f = _nm_dhcp_manager_factories[i]; if (f && nm_streq(f->name, name)) @@ -85,11 +76,10 @@ _client_factory_available(const NMDhcpClientFactory *client_factory) static GType _client_factory_get_gtype(const NMDhcpClientFactory *client_factory, int addr_family) { - GType gtype; - nm_auto_unref_gtypeclass NMDhcpClientClass *klass = NULL; + GType gtype; + GType (*get_type_fcn)(void); nm_assert(client_factory); - nm_assert_addr_family(addr_family); /* currently, the chosen DHCP plugin for IPv4 and IPv6 is configured in NetworkManager.conf * and cannot be reloaded. It would be nice to configure the plugin per address family @@ -111,29 +101,22 @@ _client_factory_get_gtype(const NMDhcpClientFactory *client_factory, int addr_fa * to those plugins. But we don't intend to do so. The internal plugin is the way forward and * not extending other plugins. */ - if (client_factory->get_type_per_addr_family) - gtype = client_factory->get_type_per_addr_family(addr_family); + if (NM_IS_IPv4(addr_family)) + get_type_fcn = client_factory->get_type_4; else - gtype = client_factory->get_type(); - - if (client_factory == &_nm_dhcp_client_factory_internal) { - /* we are already using the internal plugin. Nothing to do. */ - goto out; + get_type_fcn = client_factory->get_type_6; + + if (!get_type_fcn) { + /* If the factory does not support the address family, we always + * fallback to the internal. */ + if (NM_IS_IPv4(addr_family)) + get_type_fcn = _nm_dhcp_client_factory_internal.get_type_4; + else + get_type_fcn = _nm_dhcp_client_factory_internal.get_type_6; } - klass = g_type_class_ref(gtype); - - nm_assert(NM_IS_DHCP_CLIENT_CLASS(klass)); + gtype = get_type_fcn(); - if (addr_family == AF_INET6) { - if (!klass->ip6_start) - gtype = _client_factory_get_gtype(&_nm_dhcp_client_factory_internal, addr_family); - } else { - if (!klass->ip4_start) - gtype = _client_factory_get_gtype(&_nm_dhcp_client_factory_internal, addr_family); - } - -out: nm_assert(g_type_is_a(gtype, NM_TYPE_DHCP_CLIENT)); nm_assert(({ nm_auto_unref_gtypeclass NMDhcpClientClass *k = g_type_class_ref(gtype); @@ -146,56 +129,6 @@ out: /*****************************************************************************/ -static NMDhcpClient * -get_client_for_ifindex(NMDhcpManager *manager, int addr_family, int ifindex) -{ - NMDhcpManagerPrivate *priv; - NMDhcpClient * client; - - g_return_val_if_fail(NM_IS_DHCP_MANAGER(manager), NULL); - g_return_val_if_fail(ifindex > 0, NULL); - - priv = NM_DHCP_MANAGER_GET_PRIVATE(manager); - - c_list_for_each_entry (client, &priv->dhcp_client_lst_head, dhcp_client_lst) { - if (nm_dhcp_client_get_ifindex(client) == ifindex - && nm_dhcp_client_get_addr_family(client) == addr_family) - return client; - } - - return NULL; -} - -static void -remove_client(NMDhcpManager *self, NMDhcpClient *client) -{ - g_signal_handlers_disconnect_by_func(client, client_state_changed, self); - c_list_unlink(&client->dhcp_client_lst); - - /* Stopping the client is left up to the controlling device - * explicitly since we may want to quit NetworkManager but not terminate - * the DHCP client. - */ -} - -static void -remove_client_unref(NMDhcpManager *self, NMDhcpClient *client) -{ - remove_client(self, client); - g_object_unref(client); -} - -static void -client_state_changed(NMDhcpClient * client, - NMDhcpState state, - GObject * ip_config, - GVariant * options, - NMDhcpManager *self) -{ - if (state >= NM_DHCP_STATE_TIMEOUT) - remove_client_unref(self, client); -} - static NMDhcpClient * client_start(NMDhcpManager * self, int addr_family, @@ -226,10 +159,10 @@ client_start(NMDhcpManager * self, GError ** error) { NMDhcpManagerPrivate *priv; - NMDhcpClient * client; - gboolean success = FALSE; - gsize hwaddr_len; - GType gtype; + gs_unref_object NMDhcpClient *client = NULL; + gboolean success = FALSE; + gsize hwaddr_len; + GType gtype; g_return_val_if_fail(NM_IS_DHCP_MANAGER(self), NULL); g_return_val_if_fail(iface, NULL); @@ -278,20 +211,6 @@ client_start(NMDhcpManager * self, priv = NM_DHCP_MANAGER_GET_PRIVATE(self); - /* Kill any old client instance */ - client = get_client_for_ifindex(self, addr_family, ifindex); - if (client) { - /* FIXME: we cannot just call synchronously "stop()" and forget about the client. - * We need to wait for the client to be fully stopped because most/all clients - * cannot quit right away. - * - * FIXME(shutdown): also fix this during shutdown, to wait for all DHCP clients - * to be fully stopped. */ - remove_client(self, client); - nm_dhcp_client_stop(client, FALSE); - g_object_unref(client); - } - gtype = _client_factory_get_gtype(priv->client_factory, addr_family); nm_log_trace(LOGD_DHCP, @@ -340,12 +259,6 @@ client_start(NMDhcpManager * self, NM_DHCP_CLIENT_ANYCAST_ADDRESS, anycast_address, NULL); - nm_assert(client && c_list_is_empty(&client->dhcp_client_lst)); - c_list_link_tail(&priv->dhcp_client_lst_head, &client->dhcp_client_lst); - g_signal_connect(client, - NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED, - G_CALLBACK(client_state_changed), - self); /* unfortunately, our implementations work differently per address-family regarding client-id/DUID. * @@ -385,12 +298,10 @@ client_start(NMDhcpManager * self, error); } - if (!success) { - remove_client_unref(self, client); + if (!success) return NULL; - } - return g_object_ref(client); + return g_steal_pointer(&client); } /* Caller owns a reference to the NMDhcpClient on return */ @@ -596,9 +507,7 @@ nm_dhcp_manager_init(NMDhcpManager *self) int i; const NMDhcpClientFactory *client_factory = NULL; - c_list_init(&priv->dhcp_client_lst_head); - - for (i = 0; i < G_N_ELEMENTS(_nm_dhcp_manager_factories); i++) { + for (i = 0; i < (int) G_N_ELEMENTS(_nm_dhcp_manager_factories); i++) { const NMDhcpClientFactory *f = _nm_dhcp_manager_factories[i]; if (!f) @@ -608,7 +517,7 @@ nm_dhcp_manager_init(NMDhcpManager *self) "dhcp-init: enabled DHCP client '%s'%s%s", f->name, _client_factory_available(f) ? "" : " (not available)", - f->experimental ? " (undocumented internal plugin)" : ""); + f->undocumented ? " (undocumented internal plugin)" : ""); } /* Client-specific setup */ @@ -644,7 +553,7 @@ nm_dhcp_manager_init(NMDhcpManager *self) } } if (!client_factory) { - for (i = 0; i < G_N_ELEMENTS(_nm_dhcp_manager_factories); i++) { + for (i = 0; i < (int) G_N_ELEMENTS(_nm_dhcp_manager_factories); i++) { client_factory = _client_factory_available(_nm_dhcp_manager_factories[i]); if (client_factory) break; @@ -668,10 +577,6 @@ dispose(GObject *object) { NMDhcpManager * self = NM_DHCP_MANAGER(object); NMDhcpManagerPrivate *priv = NM_DHCP_MANAGER_GET_PRIVATE(self); - NMDhcpClient * client, *client_safe; - - c_list_for_each_entry_safe (client, client_safe, &priv->dhcp_client_lst_head, dhcp_client_lst) - remove_client_unref(self, client); G_OBJECT_CLASS(nm_dhcp_manager_parent_class)->dispose(object); diff --git a/src/core/dhcp/nm-dhcp-nettools.c b/src/core/dhcp/nm-dhcp-nettools.c index 4bb6c833..56b485dd 100644 --- a/src/core/dhcp/nm-dhcp-nettools.c +++ b/src/core/dhcp/nm-dhcp-nettools.c @@ -601,7 +601,7 @@ lease_to_ip4_config(NMDedupMultiIndex *multi_idx, nm_str_buf_append_len0(&sbuf, (const char *) l_data, l_data_len); /* Multiple domains sometimes stuffed into option 15 "Domain Name". */ - domains = nm_utils_strsplit_set(nm_str_buf_get_str(&sbuf), " "); + domains = nm_strsplit_set(nm_str_buf_get_str(&sbuf), " "); nm_str_buf_reset(&sbuf); if (domains) { @@ -997,9 +997,7 @@ nettools_create(NMDhcpNettools *self, GError **error) n_dhcp4_client_get_fd(priv->client, &fd); - priv->event_source = - nm_g_unix_fd_source_new(fd, G_IO_IN, G_PRIORITY_DEFAULT, dhcp4_event_cb, self, NULL); - g_source_attach(priv->event_source, NULL); + priv->event_source = nm_g_unix_fd_add_source(fd, G_IO_IN, dhcp4_event_cb, self); return TRUE; } @@ -1221,7 +1219,7 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) return FALSE; } - _LOGT("dhcp-client4: start %p", (gpointer) priv->client); + _LOGT("dhcp-client4: start " NM_HASH_OBFUSCATE_PTR_FMT, NM_HASH_OBFUSCATE_PTR(priv->client)); nm_dhcp_client_start_timeout(client); return TRUE; @@ -1235,7 +1233,7 @@ stop(NMDhcpClient *client, gboolean release) NM_DHCP_CLIENT_CLASS(nm_dhcp_nettools_parent_class)->stop(client, release); - _LOGT("dhcp-client4: stop %p", (gpointer) priv->client); + _LOGT("dhcp-client4: stop " NM_HASH_OBFUSCATE_PTR_FMT, NM_HASH_OBFUSCATE_PTR(priv->client)); priv->probe = n_dhcp4_client_probe_free(priv->probe); } @@ -1276,6 +1274,6 @@ nm_dhcp_nettools_class_init(NMDhcpNettoolsClass *class) const NMDhcpClientFactory _nm_dhcp_client_factory_nettools = { .name = "nettools", - .get_type = nm_dhcp_nettools_get_type, - .experimental = TRUE, + .get_type_4 = nm_dhcp_nettools_get_type, + .undocumented = TRUE, }; diff --git a/src/core/dhcp/nm-dhcp-systemd.c b/src/core/dhcp/nm-dhcp-systemd.c index c789aaee..af1d2238 100644 --- a/src/core/dhcp/nm-dhcp-systemd.c +++ b/src/core/dhcp/nm-dhcp-systemd.c @@ -592,7 +592,7 @@ ip4_start(NMDhcpClient *client, const char *last_ip4_address, GError **error) return FALSE; } - _LOGT("dhcp-client4: set %p", sd_client); + _LOGT("dhcp-client4: set " NM_HASH_OBFUSCATE_PTR_FMT, NM_HASH_OBFUSCATE_PTR(sd_client)); r = sd_dhcp_client_attach_event(sd_client, NULL, 0); if (r < 0) { @@ -1124,23 +1124,15 @@ nm_dhcp_systemd_class_init(NMDhcpSystemdClass *sdhcp_class) const NMDhcpClientFactory _nm_dhcp_client_factory_systemd = { .name = "systemd", - .get_type = nm_dhcp_systemd_get_type, - .experimental = TRUE, + .get_type_4 = nm_dhcp_systemd_get_type, + .get_type_6 = nm_dhcp_systemd_get_type, + .undocumented = TRUE, }; /*****************************************************************************/ -static GType -_get_type_per_addr_family(int addr_family) -{ - nm_assert_addr_family(addr_family); - - if (addr_family == AF_INET) - return nm_dhcp_nettools_get_type(); - return nm_dhcp_systemd_get_type(); -} - const NMDhcpClientFactory _nm_dhcp_client_factory_internal = { - .name = "internal", - .get_type_per_addr_family = _get_type_per_addr_family, + .name = "internal", + .get_type_4 = nm_dhcp_nettools_get_type, + .get_type_6 = nm_dhcp_systemd_get_type, }; diff --git a/src/core/dhcp/nm-dhcp-utils.c b/src/core/dhcp/nm-dhcp-utils.c index 7fd18b0a..3cc6987a 100644 --- a/src/core/dhcp/nm-dhcp-utils.c +++ b/src/core/dhcp/nm-dhcp-utils.c @@ -35,7 +35,7 @@ ip4_process_dhcpcd_rfc3442_routes(const char * iface, const char ** r; gboolean have_routes = FALSE; - routes = nm_utils_strsplit_set(str, " "); + routes = nm_strsplit_set(str, " "); if (!routes) return FALSE; @@ -164,7 +164,7 @@ ip4_process_dhclient_rfc3442_routes(const char * iface, const char *const * o; gboolean have_routes = FALSE; - octets = nm_utils_strsplit_set_with_empty(str, " ."); + octets = nm_strsplit_set_with_empty(str, " ."); if (NM_PTRARRAY_LEN(octets) < 5) { _LOG2W(LOGD_DHCP4, iface, "ignoring invalid classless static routes '%s'", str); return FALSE; @@ -296,7 +296,7 @@ process_classful_routes(const char * iface, if (!str) return; - searches = nm_utils_strsplit_set(str, " "); + searches = nm_strsplit_set(str, " "); if (!searches) return; @@ -376,7 +376,7 @@ process_domain_search(const char *iface, const char *str, GFunc add_func, gpoint return; } - searches = nm_utils_strsplit_set(unescaped, " "); + searches = nm_strsplit_set(unescaped, " "); for (s = searches; searches && *s; s++) { _LOG2I(LOGD_DHCP, iface, " domain search '%s'", *s); add_func((gpointer) *s, user_data); @@ -450,7 +450,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, */ str = g_hash_table_lookup(options, "routers"); if (str) { - gs_free const char **routers = nm_utils_strsplit_set(str, " "); + gs_free const char **routers = nm_strsplit_set(str, " "); const char ** s; for (s = routers; routers && *s; s++) { @@ -491,7 +491,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, str = g_hash_table_lookup(options, "domain_name_servers"); if (str) { - gs_free const char **dns = nm_utils_strsplit_set(str, " "); + gs_free const char **dns = nm_strsplit_set(str, " "); const char ** s; for (s = dns; dns && *s; s++) { @@ -507,7 +507,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, str = g_hash_table_lookup(options, "domain_name"); if (str) { - gs_free const char **domains = nm_utils_strsplit_set(str, " "); + gs_free const char **domains = nm_strsplit_set(str, " "); const char ** s; for (s = domains; domains && *s; s++) { @@ -522,7 +522,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, str = g_hash_table_lookup(options, "netbios_name_servers"); if (str) { - gs_free const char **nbns = nm_utils_strsplit_set(str, " "); + gs_free const char **nbns = nm_strsplit_set(str, " "); const char ** s; for (s = nbns; nbns && *s; s++) { @@ -557,7 +557,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx, str = g_hash_table_lookup(options, "nis_servers"); if (str) { - gs_free const char **nis = nm_utils_strsplit_set(str, " "); + gs_free const char **nis = nm_strsplit_set(str, " "); const char ** s; for (s = nis; nis && *s; s++) { @@ -689,7 +689,7 @@ nm_dhcp_utils_ip6_config_from_options(NMDedupMultiIndex *multi_idx, str = g_hash_table_lookup(options, "dhcp6_name_servers"); if (str) { - gs_free const char **dns = nm_utils_strsplit_set(str, " "); + gs_free const char **dns = nm_strsplit_set(str, " "); const char ** s; for (s = dns; dns && *s; s++) { diff --git a/src/core/dhcp/tests/test-dhcp-dhclient.c b/src/core/dhcp/tests/test-dhcp-dhclient.c index e9a62096..9c6865cc 100644 --- a/src/core/dhcp/tests/test-dhcp-dhclient.c +++ b/src/core/dhcp/tests/test-dhcp-dhclient.c @@ -830,7 +830,7 @@ test_one_duid(const char *escaped, const guint8 *unescaped, guint len) t1 = nm_dhcp_dhclient_unescape_duid(escaped); g_assert(t1); - g_assert(nm_utils_gbytes_equal_mem(t1, unescaped, len)); + g_assert(nm_g_bytes_equal_mem(t1, unescaped, len)); t2 = g_bytes_new(unescaped, len); w = nm_dhcp_dhclient_escape_duid(t2); @@ -879,7 +879,7 @@ test_read_duid_from_leasefile(void) duid = nm_dhcp_dhclient_read_duid(TEST_DIR "/test-dhclient-duid.leases", &error); nmtst_assert_success(duid, error); - g_assert(nm_utils_gbytes_equal_mem(duid, expected, G_N_ELEMENTS(expected))); + g_assert(nm_g_bytes_equal_mem(duid, expected, G_N_ELEMENTS(expected))); } static void diff --git a/src/core/dns/nm-dns-manager.c b/src/core/dns/nm-dns-manager.c index 4c498c82..f0ec0c89 100644 --- a/src/core/dns/nm-dns-manager.c +++ b/src/core/dns/nm-dns-manager.c @@ -19,7 +19,7 @@ #include #if WITH_LIBPSL - #include +#include #endif #include "libnm-glib-aux/nm-str-buf.h" @@ -42,17 +42,17 @@ #define HASH_LEN NM_UTILS_CHECKSUM_LENGTH_SHA1 #ifndef RESOLVCONF_PATH - #define RESOLVCONF_PATH "/sbin/resolvconf" - #define HAS_RESOLVCONF 0 +#define RESOLVCONF_PATH "/sbin/resolvconf" +#define HAS_RESOLVCONF 0 #else - #define HAS_RESOLVCONF 1 +#define HAS_RESOLVCONF 1 #endif #ifndef NETCONFIG_PATH - #define NETCONFIG_PATH "/sbin/netconfig" - #define HAS_NETCONFIG 0 +#define NETCONFIG_PATH "/sbin/netconfig" +#define HAS_NETCONFIG 0 #else - #define HAS_NETCONFIG 1 +#define HAS_NETCONFIG 1 #endif /*****************************************************************************/ @@ -272,7 +272,7 @@ _dns_config_ip_data_new(NMDnsConfigData * data, g_signal_connect(ip_config, NM_IS_IP4_CONFIG(ip_config) ? "notify::" NM_IP4_CONFIG_DNS_PRIORITY : "notify::" NM_IP6_CONFIG_DNS_PRIORITY, - (GCallback) _ip_config_dns_priority_changed, + G_CALLBACK(_ip_config_dns_priority_changed), ip_data); _ASSERT_dns_config_ip_data(ip_data); @@ -1327,7 +1327,7 @@ get_ip_rdns_domains(NMIPConfig *ip_config) /* Free the array and return NULL if the only element was the ending NULL */ strv = (char **) g_ptr_array_free(domains, (domains->len == 1)); - return _nm_utils_strv_cleanup(strv, FALSE, FALSE, TRUE); + return nm_strv_cleanup(strv, FALSE, FALSE, TRUE); } static gboolean @@ -1744,8 +1744,8 @@ plugin_skip:; nameservers = g_new0(char *, 2); nameservers[0] = g_strdup(lladdr); - need_edns0 = nm_utils_strv_find_first(options, -1, NM_SETTING_DNS_OPTION_EDNS0) < 0; - need_trust = nm_utils_strv_find_first(options, -1, NM_SETTING_DNS_OPTION_TRUST_AD) < 0; + need_edns0 = nm_strv_find_first(options, -1, NM_SETTING_DNS_OPTION_EDNS0) < 0; + need_trust = nm_strv_find_first(options, -1, NM_SETTING_DNS_OPTION_TRUST_AD) < 0; if (need_edns0 || need_trust) { gsize len; @@ -2128,10 +2128,7 @@ _resolvconf_resolved_managed(void) * We want to handle that, because systemd-resolved might not * have started yet. */ full_path = g_file_read_link(_PATH_RESCONF, NULL); - if (nm_utils_strv_find_first((char **) RESOLVED_PATHS, - G_N_ELEMENTS(RESOLVED_PATHS), - full_path) - >= 0) + if (nm_strv_find_first(RESOLVED_PATHS, G_N_ELEMENTS(RESOLVED_PATHS), full_path) >= 0) return TRUE; /* see if resolv.conf is a symlink that resolves exactly one @@ -2143,10 +2140,7 @@ _resolvconf_resolved_managed(void) * We want to handle that, because systemd-resolved might not * have started yet. */ real_path = realpath(_PATH_RESCONF, NULL); - if (nm_utils_strv_find_first((char **) RESOLVED_PATHS, - G_N_ELEMENTS(RESOLVED_PATHS), - real_path) - >= 0) + if (nm_strv_find_first(RESOLVED_PATHS, G_N_ELEMENTS(RESOLVED_PATHS), real_path) >= 0) return TRUE; /* fall-through and resolve the symlink, to check the file diff --git a/src/core/dns/nm-dns-manager.h b/src/core/dns/nm-dns-manager.h index 501085f7..1972a5dd 100644 --- a/src/core/dns/nm-dns-manager.h +++ b/src/core/dns/nm-dns-manager.h @@ -21,11 +21,6 @@ typedef enum { NM_DNS_IP_CONFIG_TYPE_VPN, } NMDnsIPConfigType; -enum { - NM_DNS_PRIORITY_DEFAULT_NORMAL = 100, - NM_DNS_PRIORITY_DEFAULT_VPN = 50, -}; - /*****************************************************************************/ struct _NMDnsConfigData; diff --git a/src/core/dns/nm-dns-systemd-resolved.c b/src/core/dns/nm-dns-systemd-resolved.c index 4b8c4f94..445f8498 100644 --- a/src/core/dns/nm-dns-systemd-resolved.c +++ b/src/core/dns/nm-dns-systemd-resolved.c @@ -36,6 +36,7 @@ /* define a variable, so that we can compare the operation with pointer equality. */ static const char *const DBUS_OP_SET_LINK_DEFAULT_ROUTE = "SetLinkDefaultRoute"; +static const char *const DBUS_OP_SET_LINK_DNS_OVER_TLS = "SetLinkDNSOverTLS"; /*****************************************************************************/ @@ -86,7 +87,12 @@ typedef struct { bool try_start_blocked : 1; bool dbus_initied : 1; bool send_updates_waiting : 1; - NMTernary has_link_default_route : 3; + /* These two variables ensure that the log is not spammed with + * API (not) supported messages. + * They can be removed when no distro uses systemd-resolved < v240 anymore + */ + NMTernary has_link_default_route : 3; + NMTernary has_link_dns_over_tls : 3; } NMDnsSystemdResolvedPrivate; struct _NMDnsSystemdResolved { @@ -201,16 +207,26 @@ call_done(GObject *source, GAsyncResult *r, gpointer user_data) priv->has_link_default_route = NM_TERNARY_TRUE; _LOGD("systemd-resolved support for SetLinkDefaultRoute(): API supported"); } + if (request_item->operation == DBUS_OP_SET_LINK_DNS_OVER_TLS + && priv->has_link_dns_over_tls == NM_TERNARY_DEFAULT) { + priv->has_link_dns_over_tls = NM_TERNARY_TRUE; + _LOGD("systemd-resolved support for SetLinkDNSOverTLS(): API supported"); + } priv->send_updates_warn_ratelimited = FALSE; return; } - if (request_item->operation == DBUS_OP_SET_LINK_DEFAULT_ROUTE - && nm_g_error_matches(error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD)) { - if (priv->has_link_default_route == NM_TERNARY_DEFAULT) { + if (nm_g_error_matches(error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD)) { + if (priv->has_link_default_route == NM_TERNARY_DEFAULT + && request_item->operation == DBUS_OP_SET_LINK_DEFAULT_ROUTE) { priv->has_link_default_route = NM_TERNARY_FALSE; _LOGD("systemd-resolved support for SetLinkDefaultRoute(): API not supported"); } + if (priv->has_link_dns_over_tls == NM_TERNARY_DEFAULT + && request_item->operation == DBUS_OP_SET_LINK_DNS_OVER_TLS) { + priv->has_link_dns_over_tls = NM_TERNARY_FALSE; + _LOGD("systemd-resolved support for SetLinkDNSOverTLS(): API not supported"); + } return; } @@ -286,14 +302,15 @@ free_pending_updates(NMDnsSystemdResolved *self) static gboolean prepare_one_interface(NMDnsSystemdResolved *self, InterfaceConfig *ic) { - GVariantBuilder dns; - GVariantBuilder domains; - NMCListElem * elem; - NMSettingConnectionMdns mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT; - NMSettingConnectionLlmnr llmnr = NM_SETTING_CONNECTION_LLMNR_DEFAULT; - const char * mdns_arg = NULL, *llmnr_arg = NULL; - gboolean has_config = FALSE; - gboolean has_default_route = FALSE; + GVariantBuilder dns; + GVariantBuilder domains; + NMCListElem * elem; + NMSettingConnectionMdns mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT; + NMSettingConnectionLlmnr llmnr = NM_SETTING_CONNECTION_LLMNR_DEFAULT; + NMSettingConnectionDnsOverTls dns_over_tls = NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT; + const char * mdns_arg = NULL, *llmnr_arg = NULL, *dns_over_tls_arg = NULL; + gboolean has_config = FALSE; + gboolean has_default_route = FALSE; g_variant_builder_init(&dns, G_VARIANT_TYPE("(ia(iay))")); g_variant_builder_add(&dns, "i", ic->ifindex); @@ -315,6 +332,8 @@ prepare_one_interface(NMDnsSystemdResolved *self, InterfaceConfig *ic) if (NM_IS_IP4_CONFIG(ip_config)) { mdns = NM_MAX(mdns, nm_ip4_config_mdns_get(NM_IP4_CONFIG(ip_config))); llmnr = NM_MAX(llmnr, nm_ip4_config_llmnr_get(NM_IP4_CONFIG(ip_config))); + dns_over_tls = + NM_MAX(dns_over_tls, nm_ip4_config_dns_over_tls_get(NM_IP4_CONFIG(ip_config))); } } @@ -353,7 +372,24 @@ prepare_one_interface(NMDnsSystemdResolved *self, InterfaceConfig *ic) } nm_assert(llmnr_arg); - if (!nm_str_is_empty(mdns_arg) || !nm_str_is_empty(llmnr_arg)) + switch (dns_over_tls) { + case NM_SETTING_CONNECTION_DNS_OVER_TLS_NO: + dns_over_tls_arg = "no"; + break; + case NM_SETTING_CONNECTION_DNS_OVER_TLS_OPPORTUNISTIC: + dns_over_tls_arg = "opportunistic"; + break; + case NM_SETTING_CONNECTION_DNS_OVER_TLS_YES: + dns_over_tls_arg = "yes"; + break; + case NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT: + dns_over_tls_arg = ""; + break; + } + nm_assert(dns_over_tls_arg); + + if (!nm_str_is_empty(mdns_arg) || !nm_str_is_empty(llmnr_arg) + || !nm_str_is_empty(dns_over_tls_arg)) has_config = TRUE; _request_item_append(self, "SetLinkDomains", ic->ifindex, g_variant_builder_end(&domains)); @@ -370,6 +406,10 @@ prepare_one_interface(NMDnsSystemdResolved *self, InterfaceConfig *ic) ic->ifindex, g_variant_new("(is)", ic->ifindex, llmnr_arg ?: "")); _request_item_append(self, "SetLinkDNS", ic->ifindex, g_variant_builder_end(&dns)); + _request_item_append(self, + DBUS_OP_SET_LINK_DNS_OVER_TLS, + ic->ifindex, + g_variant_new("(is)", ic->ifindex, dns_over_tls_arg ?: "")); return has_config; } @@ -422,12 +462,7 @@ ensure_resolved_running(NMDnsSystemdResolved *self) priv->try_start_blocked = TRUE; priv->try_start_timeout_source = - nm_g_source_attach(nm_g_timeout_source_new(4000, - G_PRIORITY_DEFAULT, - _ensure_resolved_running_timeout, - self, - NULL), - NULL); + nm_g_timeout_add_source(4000, _ensure_resolved_running_timeout, self); nm_dbus_connection_call_start_service_by_name(priv->dbus_connection, SYSTEMD_RESOLVED_DBUS_SERVICE, @@ -468,15 +503,18 @@ send_updates(NMDnsSystemdResolved *self) priv->send_updates_waiting = FALSE; - _LOGT("send-updates: start %lu requests", c_list_length(&priv->request_queue_lst_head)); + _LOGT("send-updates: start %zu requests", c_list_length(&priv->request_queue_lst_head)); c_list_for_each_entry (request_item, &priv->request_queue_lst_head, request_queue_lst) { gs_free char *ss = NULL; - if (request_item->operation == DBUS_OP_SET_LINK_DEFAULT_ROUTE - && priv->has_link_default_route == NM_TERNARY_FALSE) { + if ((request_item->operation == DBUS_OP_SET_LINK_DEFAULT_ROUTE + && priv->has_link_default_route == NM_TERNARY_FALSE) + || (request_item->operation == DBUS_OP_SET_LINK_DNS_OVER_TLS + && priv->has_link_dns_over_tls == NM_TERNARY_FALSE)) { /* The "SetLinkDefaultRoute" API is only supported since v240. - * We detected that it is not supported, and skip the call. There + * The "SetLinkDNSOverTLS" API is only supported since v239. + * We detected whether they are supported, and skip the calls. There * is no special workaround, because in this case we rely on systemd-resolved * to do the right thing automatically. */ continue; @@ -601,13 +639,15 @@ name_owner_changed(NMDnsSystemdResolved *self, const char *owner) nm_clear_g_source_inst(&priv->try_start_timeout_source); - nm_utils_strdup_reset(&priv->dbus_owner, owner); + nm_strdup_reset(&priv->dbus_owner, owner); if (owner) { priv->try_start_blocked = FALSE; priv->send_updates_waiting = TRUE; - } else + } else { priv->has_link_default_route = NM_TERNARY_DEFAULT; + priv->has_link_dns_over_tls = NM_TERNARY_DEFAULT; + } send_updates(self); } @@ -821,19 +861,13 @@ _resolve_start(NMDnsSystemdResolved *self, NMDnsSystemdResolvedResolveHandle *ha _LOG2T(handle, "systemd-resolved not running. Failing on idle..."); nm_assert(!handle->timeout_source); handle->is_failing_on_idle = TRUE; - handle->timeout_source = nm_g_source_attach( - nm_g_idle_source_new(G_PRIORITY_DEFAULT, _resolve_failing_on_idle, handle, NULL), - NULL); + handle->timeout_source = nm_g_idle_add_source(_resolve_failing_on_idle, handle); return; } if (!handle->timeout_source) { - handle->timeout_source = nm_g_source_attach(nm_g_timeout_source_new(handle->timeout_msec, - G_PRIORITY_DEFAULT, - _resolve_handle_timeout, - handle, - NULL), - NULL); + handle->timeout_source = + nm_g_timeout_add_source(handle->timeout_msec, _resolve_handle_timeout, handle); } if (is_running == NM_TERNARY_DEFAULT) { @@ -929,6 +963,7 @@ nm_dns_systemd_resolved_init(NMDnsSystemdResolved *self) NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE(self); priv->has_link_default_route = NM_TERNARY_DEFAULT; + priv->has_link_dns_over_tls = NM_TERNARY_DEFAULT; c_list_init(&priv->request_queue_lst_head); c_list_init(&priv->handle_lst_head); diff --git a/src/core/main-utils.c b/src/core/main-utils.c index 9bc497ca..48f143c3 100644 --- a/src/core/main-utils.c +++ b/src/core/main-utils.c @@ -14,7 +14,6 @@ #include #include -#include #include "main-utils.h" #include "NetworkManagerUtils.h" diff --git a/src/core/main.c b/src/core/main.c index 3cb5c07f..7d448a59 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -38,7 +38,7 @@ #include "nm-netns.h" #if !defined(NM_DIST_VERSION) - #define NM_DIST_VERSION VERSION +#define NM_DIST_VERSION VERSION #endif #define NM_DEFAULT_PID_FILE NMRUNDIR "/NetworkManager.pid" @@ -326,6 +326,7 @@ main(int argc, char *argv[]) if (global_opt.show_version) { fprintf(stdout, NM_DIST_VERSION "\n"); + nm_config_cmd_line_options_free(config_cli); exit(0); } @@ -374,6 +375,7 @@ main(int argc, char *argv[]) fprintf(stderr, _("%s. Please use --help to see a list of valid options.\n"), error->message); + nm_config_cmd_line_options_free(config_cli); exit(1); } diff --git a/src/core/meson.build b/src/core/meson.build index f4d7af64..6e00928e 100644 --- a/src/core/meson.build +++ b/src/core/meson.build @@ -51,6 +51,7 @@ libNetworkManagerBase = static_library( 'nm-netns.c', 'nm-l3-config-data.c', 'nm-l3-ipv4ll.c', + 'nm-l3-ipv6ll.c', 'nm-l3cfg.c', 'nm-ip-config.c', 'nm-ip4-config.c', @@ -172,6 +173,7 @@ libNetworkManager = static_library( 'nm-rfkill-manager.c', 'nm-session-monitor.c', 'nm-sleep-monitor.c', + 'nm-priv-helper-call.c', ), dependencies: nm_deps, link_with: [ diff --git a/src/core/ndisc/nm-lndp-ndisc.c b/src/core/ndisc/nm-lndp-ndisc.c index f11178f8..552b0e4b 100644 --- a/src/core/ndisc/nm-lndp-ndisc.c +++ b/src/core/ndisc/nm-lndp-ndisc.c @@ -85,14 +85,14 @@ send_rs(NMNDisc *ndisc, GError **error) static NMIcmpv6RouterPref _route_preference_coerce(enum ndp_route_preference pref) { -#define _ASSERT_ENUM(v1, v2) \ - G_STMT_START \ - { \ - G_STATIC_ASSERT((NMIcmpv6RouterPref) (v1) == (v2)); \ - G_STATIC_ASSERT((enum ndp_route_preference) (v2) == (v1)); \ - G_STATIC_ASSERT((gint64) (v1) == (v2)); \ - G_STATIC_ASSERT((gint64) (v2) == (v1)); \ - } \ +#define _ASSERT_ENUM(v1, v2) \ + G_STMT_START \ + { \ + G_STATIC_ASSERT((NMIcmpv6RouterPref) (v1) == (v2)); \ + G_STATIC_ASSERT((enum ndp_route_preference)(v2) == (v1)); \ + G_STATIC_ASSERT((gint64) (v1) == (v2)); \ + G_STATIC_ASSERT((gint64) (v2) == (v1)); \ + } \ G_STMT_END switch (pref) { @@ -599,9 +599,7 @@ start(NMNDisc *ndisc) fd = ndp_get_eventfd(priv->ndp); - priv->event_source = - nm_g_unix_fd_source_new(fd, G_IO_IN, G_PRIORITY_DEFAULT, event_ready, ndisc, NULL); - g_source_attach(priv->event_source, NULL); + priv->event_source = nm_g_unix_fd_add_source(fd, G_IO_IN, event_ready, ndisc); /* Flush any pending messages to avoid using obsolete information */ event_ready(fd, 0, ndisc); @@ -666,69 +664,6 @@ stop(NMNDisc *ndisc) /*****************************************************************************/ -static int -ipv6_sysctl_get(NMPlatform *platform, - const char *ifname, - const char *property, - int min, - int max, - int defval) -{ - return nm_platform_sysctl_ip_conf_get_int_checked(platform, - AF_INET6, - ifname, - property, - 10, - min, - max, - defval); -} - -void -nm_lndp_ndisc_get_sysctl(NMPlatform *platform, - const char *ifname, - int * out_max_addresses, - int * out_router_solicitations, - int * out_router_solicitation_interval, - guint32 * out_default_ra_timeout) -{ - int router_solicitation_interval = 0; - int router_solicitations = 0; - - if (out_max_addresses) { - *out_max_addresses = ipv6_sysctl_get(platform, - ifname, - "max_addresses", - 0, - G_MAXINT32, - NM_NDISC_MAX_ADDRESSES_DEFAULT); - } - if (out_router_solicitations || out_default_ra_timeout) { - router_solicitations = ipv6_sysctl_get(platform, - ifname, - "router_solicitations", - 1, - G_MAXINT32, - NM_NDISC_ROUTER_SOLICITATIONS_DEFAULT); - NM_SET_OUT(out_router_solicitations, router_solicitations); - } - if (out_router_solicitation_interval || out_default_ra_timeout) { - router_solicitation_interval = ipv6_sysctl_get(platform, - ifname, - "router_solicitation_interval", - 1, - G_MAXINT32, - NM_NDISC_RFC4861_RTR_SOLICITATION_INTERVAL); - NM_SET_OUT(out_router_solicitation_interval, router_solicitation_interval); - } - if (out_default_ra_timeout) { - *out_default_ra_timeout = - NM_MAX((((gint64) router_solicitations) * router_solicitation_interval) + 1, 30); - } -} - -/*****************************************************************************/ - static void nm_lndp_ndisc_init(NMLndpNDisc *lndp_ndisc) {} diff --git a/src/core/ndisc/nm-lndp-ndisc.h b/src/core/ndisc/nm-lndp-ndisc.h index 96fc9737..151f4bf7 100644 --- a/src/core/ndisc/nm-lndp-ndisc.h +++ b/src/core/ndisc/nm-lndp-ndisc.h @@ -36,11 +36,4 @@ NMNDisc *nm_lndp_ndisc_new(NMPlatform * platform, guint32 ra_timeout, GError ** error); -void nm_lndp_ndisc_get_sysctl(NMPlatform *platform, - const char *ifname, - int * out_max_addresses, - int * out_router_solicitations, - int * out_router_solicitation_interval, - guint32 * out_default_ra_timeout); - #endif /* __NETWORKMANAGER_LNDP_NDISC_H__ */ diff --git a/src/core/ndisc/nm-ndisc.c b/src/core/ndisc/nm-ndisc.c index cf1b58ec..d7b1a2e1 100644 --- a/src/core/ndisc/nm-ndisc.c +++ b/src/core/ndisc/nm-ndisc.c @@ -23,6 +23,9 @@ #define RFC7559_IRT ((gint32) 4) /* RFC7559, Initial Retransmission Time, in seconds */ #define RFC7559_MRT ((gint32) 3600) /* RFC7559, Maximum Retransmission Time, in seconds */ +#define NM_NDISC_PRE_EXPIRY_TIME_MSEC 60000 +#define NM_NDISC_PRE_EXPIRY_MIN_LIFETIME_MSEC 120000 + #define _SIZE_MAX_GATEWAYS 100u #define _SIZE_MAX_ADDRESSES 100u #define _SIZE_MAX_ROUTES 1000u @@ -44,6 +47,7 @@ struct _NMNDiscPrivate { gint32 last_ra; gint32 solicit_retransmit_time_msec; + gint64 last_rs_msec; GSource *solicit_timer_source; @@ -96,6 +100,16 @@ static gboolean timeout_expire_cb(gpointer user_data); /*****************************************************************************/ +NM_UTILS_LOOKUP_STR_DEFINE(nm_ndisc_dhcp_level_to_string, + NMNDiscDHCPLevel, + NM_UTILS_LOOKUP_DEFAULT("INVALID"), + NM_UTILS_LOOKUP_STR_ITEM(NM_NDISC_DHCP_LEVEL_UNKNOWN, "unknown"), + NM_UTILS_LOOKUP_STR_ITEM(NM_NDISC_DHCP_LEVEL_NONE, "none"), + NM_UTILS_LOOKUP_STR_ITEM(NM_NDISC_DHCP_LEVEL_OTHERCONF, "otherconf"), + NM_UTILS_LOOKUP_STR_ITEM(NM_NDISC_DHCP_LEVEL_MANAGED, "managed"), ); + +/*****************************************************************************/ + NML3ConfigData * nm_ndisc_data_to_l3cd(NMDedupMultiIndex * multi_idx, int ifindex, @@ -112,9 +126,7 @@ nm_ndisc_data_to_l3cd(NMDedupMultiIndex * multi_idx, guint i; const gint32 now_sec = nm_utils_get_monotonic_timestamp_sec(); - l3cd = nm_l3_config_data_new(multi_idx, ifindex); - - nm_l3_config_data_set_source(l3cd, NM_IP_CONFIG_SOURCE_NDISC); + l3cd = nm_l3_config_data_new(multi_idx, ifindex, NM_IP_CONFIG_SOURCE_NDISC); nm_l3_config_data_set_ip6_privacy(l3cd, ip6_privacy); @@ -468,12 +480,12 @@ complete_address(NMNDisc *ndisc, NMNDiscAddress *addr) priv = NM_NDISC_GET_PRIVATE(ndisc); if (priv->addr_gen_mode == NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY) { - if (!nm_utils_ipv6_addr_set_stable_privacy(priv->stable_type, - &addr->address, - priv->ifname, - priv->network_id, - addr->dad_counter++, - &error)) { + if (!nm_utils_ipv6_addr_set_stable_privacy_may_fail(priv->stable_type, + &addr->address, + priv->ifname, + priv->network_id, + addr->dad_counter++, + &error)) { _LOGW("complete-address: failed to generate an stable-privacy address: %s", error->message); g_clear_error(&error); @@ -490,7 +502,7 @@ complete_address(NMNDisc *ndisc, NMNDiscAddress *addr) if (addr->address.s6_addr32[2] == 0x0 && addr->address.s6_addr32[3] == 0x0) { _LOGD("complete-address: adding an EUI-64 address"); - nm_utils_ipv6_addr_set_interface_identifier(&addr->address, priv->iid); + nm_utils_ipv6_addr_set_interface_identifier(&addr->address, &priv->iid); return TRUE; } @@ -832,6 +844,8 @@ solicit_timer_cb(gpointer user_data) else { _LOGT("solicit: router solicitation sent"); nm_clear_g_free(&priv->last_error); + + priv->last_rs_msec = nm_utils_get_monotonic_timestamp_msec(); } /* https://tools.ietf.org/html/rfc4861#section-6.3.7 describes how to send solicitations: @@ -1213,21 +1227,6 @@ config_map_to_string(NMNDiscConfigMap map, char *p) *p = '\0'; } -static const char * -dhcp_level_to_string(NMNDiscDHCPLevel dhcp_level) -{ - switch (dhcp_level) { - case NM_NDISC_DHCP_LEVEL_NONE: - return "none"; - case NM_NDISC_DHCP_LEVEL_OTHERCONF: - return "otherconf"; - case NM_NDISC_DHCP_LEVEL_MANAGED: - return "managed"; - default: - return "INVALID"; - } -} - static void _config_changed_log(NMNDisc *ndisc, NMNDiscConfigMap changed) { @@ -1250,7 +1249,7 @@ _config_changed_log(NMNDisc *ndisc, NMNDiscConfigMap changed) config_map_to_string(changed, changedstr); _LOGD("neighbor discovery configuration changed [%s]:", changedstr); - _LOGD(" dhcp-level %s", dhcp_level_to_string(priv->rdata.public.dhcp_level)); + _LOGD(" dhcp-level %s", nm_ndisc_dhcp_level_to_string(priv->rdata.public.dhcp_level)); if (rdata->public.hop_limit) _LOGD(" hop limit : %d", rdata->public.hop_limit); @@ -1508,33 +1507,6 @@ check_timestamps(NMNDisc *ndisc, gint64 now_msec, NMNDiscConfigMap changed) ndisc); } - /* When we receive an RA, we don't disable solicitations entirely. Instead, - * we set the interval the maximum (RFC7559_MRT). - * - * This contradicts https://tools.ietf.org/html/rfc7559#section-2.1, which says - * that we SHOULD stop sending RS if we receive an RA -- but only on a multicast - * capable link and if the RA has a valid router lifetime. - * - * But we really want to recover from a dead router on the network, so we - * don't want to cease sending RS entirely. - * - * But we only re-schedule the timer if the current interval is not already - * "RFC7559_MRT * 1000". Otherwise, we already have a slow interval counter - * pending. */ - if (priv->solicit_retransmit_time_msec != RFC7559_MRT * 1000) { - gint32 timeout_msec; - - priv->solicit_retransmit_time_msec = RFC7559_MRT * 1000; - timeout_msec = solicit_retransmit_time_jitter(priv->solicit_retransmit_time_msec); - - _LOGD("solicit: schedule sending next (slow) solicitation in about %.3f seconds", - ((double) timeout_msec) / 1000); - - nm_clear_g_source_inst(&priv->solicit_timer_source); - priv->solicit_timer_source = - nm_g_timeout_add_source_approx(timeout_msec, 0, solicit_timer_cb, ndisc); - } - if (changed != NM_NDISC_CONFIG_NONE) nm_ndisc_emit_config_change(ndisc, changed); } @@ -1546,14 +1518,111 @@ timeout_expire_cb(gpointer user_data) return G_SOURCE_CONTINUE; } +/* Calculate the earliest time where some part of the advertised data is about + * to expire. + * + * Entities are considered about to expire NM_NDISC_PRE_EXPIRY_TIME_MSEC before + * their expiration time. + * + * However, data which has a lifetime (as calculated from the time the last + * RS has been sent) shorter than NM_NDISC_PRE_EXPIRY_MIN_LIFETIME_MSEC, is + * ignored. This is because when we send out RSs because some data is about + * to expire, and the received RAs neither extend the lifetime nor remove + * the offending data, the data would be considered about to expire again, + * triggering more RS in an endless loop until it expired for good. + */ + +static void +_calc_pre_expiry_rs_msec_worker(gint64 *earliest_expiry_msec, + gint64 last_rs_msec, + gint64 expiry_msec) +{ + if (expiry_msec == NM_NDISC_EXPIRY_INFINITY) + return; + + if (expiry_msec < last_rs_msec + NM_NDISC_PRE_EXPIRY_MIN_LIFETIME_MSEC) + return; + + *earliest_expiry_msec = NM_MIN(*earliest_expiry_msec, expiry_msec); +} + +static gint64 +calc_pre_expiry_rs_msec(NMNDisc *ndisc) +{ + NMNDiscPrivate * priv = NM_NDISC_GET_PRIVATE(ndisc); + NMNDiscDataInternal *rdata = &priv->rdata; + gint64 expiry_msec = NM_NDISC_EXPIRY_INFINITY; + guint i; + + for (i = 0; i < rdata->gateways->len; i++) { + _calc_pre_expiry_rs_msec_worker( + &expiry_msec, + priv->last_rs_msec, + g_array_index(rdata->gateways, NMNDiscGateway, i).expiry_msec); + } + + for (i = 0; i < rdata->addresses->len; i++) { + _calc_pre_expiry_rs_msec_worker( + &expiry_msec, + priv->last_rs_msec, + g_array_index(rdata->addresses, NMNDiscAddress, 0).expiry_msec); + } + + for (i = 0; i < rdata->routes->len; i++) { + _calc_pre_expiry_rs_msec_worker(&expiry_msec, + priv->last_rs_msec, + g_array_index(rdata->routes, NMNDiscRoute, 0).expiry_msec); + } + + for (i = 0; i < rdata->dns_servers->len; i++) { + _calc_pre_expiry_rs_msec_worker( + &expiry_msec, + priv->last_rs_msec, + g_array_index(rdata->dns_servers, NMNDiscDNSServer, 0).expiry_msec); + } + + for (i = 0; i < rdata->dns_domains->len; i++) { + _calc_pre_expiry_rs_msec_worker( + &expiry_msec, + priv->last_rs_msec, + g_array_index(rdata->dns_domains, NMNDiscDNSDomain, 0).expiry_msec); + } + + return expiry_msec - solicit_retransmit_time_jitter(NM_NDISC_PRE_EXPIRY_TIME_MSEC); +} + void nm_ndisc_ra_received(NMNDisc *ndisc, gint64 now_msec, NMNDiscConfigMap changed) { NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE(ndisc); + gint64 pre_expiry_msec; + gint32 timeout_msec; nm_clear_g_source_inst(&priv->ra_timeout_source); nm_clear_g_free(&priv->last_error); check_timestamps(ndisc, now_msec, changed); + + /* When we receive an RA, we don't disable solicitations. + * + * This contradicts https://tools.ietf.org/html/rfc7559#section-2.1, which + * says that we SHOULD stop sending RS if we receive an RA -- but only on + * a multicast capable link and if the RA has a valid router lifetime. + * + * But there are routers out in the wild that won't send unsolicited RAs. + * So we begin sending out RS again when entities are about to expire. + */ + pre_expiry_msec = NM_CLAMP(calc_pre_expiry_rs_msec(ndisc), + priv->last_rs_msec + RFC7559_IRT * 1000, + priv->last_rs_msec + RFC7559_MRT * 1000); + timeout_msec = NM_CLAMP(pre_expiry_msec - now_msec, (gint64) 0, (gint64) G_MAXINT32); + + _LOGD("solicit: schedule sending next (slow) solicitation in about %.3f seconds", + ((double) timeout_msec) / 1000); + + priv->solicit_retransmit_time_msec = 0; + nm_clear_g_source_inst(&priv->solicit_timer_source); + priv->solicit_timer_source = + nm_g_timeout_add_source_approx(timeout_msec, 0, solicit_timer_cb, ndisc); } void @@ -1567,6 +1636,69 @@ nm_ndisc_rs_received(NMNDisc *ndisc) /*****************************************************************************/ +static int +ipv6_sysctl_get(NMPlatform *platform, + const char *ifname, + const char *property, + int min, + int max, + int defval) +{ + return nm_platform_sysctl_ip_conf_get_int_checked(platform, + AF_INET6, + ifname, + property, + 10, + min, + max, + defval); +} + +void +nm_ndisc_get_sysctl(NMPlatform *platform, + const char *ifname, + int * out_max_addresses, + int * out_router_solicitations, + int * out_router_solicitation_interval, + guint32 * out_default_ra_timeout) +{ + int router_solicitation_interval = 0; + int router_solicitations = 0; + + if (out_max_addresses) { + *out_max_addresses = ipv6_sysctl_get(platform, + ifname, + "max_addresses", + 0, + G_MAXINT32, + NM_NDISC_MAX_ADDRESSES_DEFAULT); + } + if (out_router_solicitations || out_default_ra_timeout) { + router_solicitations = ipv6_sysctl_get(platform, + ifname, + "router_solicitations", + 1, + G_MAXINT32, + NM_NDISC_ROUTER_SOLICITATIONS_DEFAULT); + NM_SET_OUT(out_router_solicitations, router_solicitations); + } + if (out_router_solicitation_interval || out_default_ra_timeout) { + router_solicitation_interval = ipv6_sysctl_get(platform, + ifname, + "router_solicitation_interval", + 1, + G_MAXINT32, + NM_NDISC_RFC4861_RTR_SOLICITATION_INTERVAL); + NM_SET_OUT(out_router_solicitation_interval, router_solicitation_interval); + } + if (out_default_ra_timeout) { + *out_default_ra_timeout = + NM_MAX((((gint64) router_solicitations) * router_solicitation_interval) + 1, 30); + } +} + +/*****************************************************************************/ + static void dns_domain_free(gpointer data) { diff --git a/src/core/ndisc/nm-ndisc.h b/src/core/ndisc/nm-ndisc.h index 15f95d20..5b827528 100644 --- a/src/core/ndisc/nm-ndisc.h +++ b/src/core/ndisc/nm-ndisc.h @@ -48,6 +48,8 @@ typedef enum { NM_NDISC_DHCP_LEVEL_MANAGED } NMNDiscDHCPLevel; +const char *nm_ndisc_dhcp_level_to_string(NMNDiscDHCPLevel level); + #define NM_NDISC_INFINITY_U32 ((uint32_t) -1) /* It's important that this is G_MAXINT64, so that we can meaningfully do @@ -239,7 +241,7 @@ static inline gboolean nm_ndisc_dad_addr_is_fail_candidate_event(NMPlatformSignalChangeType change_type, const NMPlatformIP6Address *addr) { - return !NM_FLAGS_HAS(addr->n_ifa_flags, IFA_F_TEMPORARY) + return !NM_FLAGS_HAS(addr->n_ifa_flags, IFA_F_SECONDARY) && ((change_type == NM_PLATFORM_SIGNAL_CHANGED && addr->n_ifa_flags & IFA_F_DADFAILED) || (change_type == NM_PLATFORM_SIGNAL_REMOVED && addr->n_ifa_flags & IFA_F_TENTATIVE)); @@ -253,7 +255,7 @@ nm_ndisc_dad_addr_is_fail_candidate(NMPlatform *platform, const NMPObject *obj) addr = NMP_OBJECT_CAST_IP6_ADDRESS( nm_platform_lookup_obj(platform, NMP_CACHE_ID_TYPE_OBJECT_TYPE, obj)); if (addr - && (NM_FLAGS_HAS(addr->n_ifa_flags, IFA_F_TEMPORARY) + && (NM_FLAGS_HAS(addr->n_ifa_flags, IFA_F_SECONDARY) || !NM_FLAGS_HAS(addr->n_ifa_flags, IFA_F_DADFAILED))) { /* the address still/again exists and is not in DADFAILED state. Skip it. */ return FALSE; @@ -264,6 +266,15 @@ nm_ndisc_dad_addr_is_fail_candidate(NMPlatform *platform, const NMPObject *obj) /*****************************************************************************/ +void nm_ndisc_get_sysctl(NMPlatform *platform, + const char *ifname, + int * out_max_addresses, + int * out_router_solicitations, + int * out_router_solicitation_interval, + guint32 * out_default_ra_timeout); + +/*****************************************************************************/ + struct _NML3ConfigData; struct _NML3ConfigData *nm_ndisc_data_to_l3cd(NMDedupMultiIndex * multi_idx, diff --git a/src/core/ndisc/tests/test-ndisc-linux.c b/src/core/ndisc/tests/test-ndisc-linux.c index c84ee142..57021606 100644 --- a/src/core/ndisc/tests/test-ndisc-linux.c +++ b/src/core/ndisc/tests/test-ndisc-linux.c @@ -49,12 +49,12 @@ main(int argc, char **argv) return EXIT_FAILURE; } - nm_lndp_ndisc_get_sysctl(NM_PLATFORM_GET, - ifname, - &max_addresses, - &router_solicitations, - &router_solicitation_interval, - &ra_timeout); + nm_ndisc_get_sysctl(NM_PLATFORM_GET, + ifname, + &max_addresses, + &router_solicitations, + &router_solicitation_interval, + &ra_timeout); ndisc = nm_lndp_ndisc_new(NM_PLATFORM_GET, ifindex, diff --git a/src/core/nm-active-connection.c b/src/core/nm-active-connection.c index 40fe3c96..4cd6d488 100644 --- a/src/core/nm-active-connection.c +++ b/src/core/nm-active-connection.c @@ -208,12 +208,12 @@ _set_settings_connection(NMActiveConnection *self, NMSettingsConnection *sett_co if (sett_conn) { g_signal_connect(sett_conn, NM_SETTINGS_CONNECTION_UPDATED_INTERNAL, - (GCallback) _settings_connection_updated, + G_CALLBACK(_settings_connection_updated), self); if (nm_active_connection_get_activation_type(self) == NM_ACTIVATION_TYPE_EXTERNAL) g_signal_connect(sett_conn, NM_SETTINGS_CONNECTION_FLAGS_CHANGED, - (GCallback) _settings_connection_flags_changed, + G_CALLBACK(_settings_connection_flags_changed), self); } @@ -858,7 +858,7 @@ nm_active_connection_set_master(NMActiveConnection *self, NMActiveConnection *ma priv->master = g_object_ref(master); g_signal_connect(priv->master, "notify::" NM_ACTIVE_CONNECTION_STATE, - (GCallback) master_state_cb, + G_CALLBACK(master_state_cb), self); check_master_ready(self); @@ -890,7 +890,7 @@ _set_activation_type(NMActiveConnection *self, NMActivationType activation_type) if (activation_type == NM_ACTIVATION_TYPE_EXTERNAL) g_signal_connect(priv->settings_connection.obj, NM_SETTINGS_CONNECTION_FLAGS_CHANGED, - (GCallback) _settings_connection_flags_changed, + G_CALLBACK(_settings_connection_flags_changed), self); else g_signal_handlers_disconnect_by_func(priv->settings_connection.obj, @@ -1025,7 +1025,7 @@ unwatch_parent(NMActiveConnection *self, gboolean unref) { NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE(self); - g_signal_handlers_disconnect_by_func(priv->parent, (GCallback) parent_state_cb, self); + g_signal_handlers_disconnect_by_func(priv->parent, G_CALLBACK(parent_state_cb), self); if (unref) g_object_weak_unref((GObject *) priv->parent, parent_destroyed, self); priv->parent = NULL; @@ -1049,7 +1049,7 @@ nm_active_connection_set_parent(NMActiveConnection *self, NMActiveConnection *pa priv->parent = parent; g_signal_connect(priv->parent, "notify::" NM_ACTIVE_CONNECTION_STATE, - (GCallback) parent_state_cb, + G_CALLBACK(parent_state_cb), self); g_object_weak_ref((GObject *) priv->parent, parent_destroyed, self); } @@ -1529,7 +1529,7 @@ dispose(GObject *object) _device_cleanup(self); if (priv->master) { - g_signal_handlers_disconnect_by_func(priv->master, (GCallback) master_state_cb, self); + g_signal_handlers_disconnect_by_func(priv->master, G_CALLBACK(master_state_cb), self); } g_clear_object(&priv->master); diff --git a/src/core/nm-audit-manager.c b/src/core/nm-audit-manager.c index 2ef5d860..477e1798 100644 --- a/src/core/nm-audit-manager.c +++ b/src/core/nm-audit-manager.c @@ -8,7 +8,7 @@ #include "nm-audit-manager.h" #if HAVE_LIBAUDIT - #include +#include #endif #define NM_VALUE_TYPE_DEFINE_FUNCTIONS diff --git a/src/core/nm-auth-utils.c b/src/core/nm-auth-utils.c index 006264dd..da17b1a4 100644 --- a/src/core/nm-auth-utils.c +++ b/src/core/nm-auth-utils.c @@ -124,12 +124,8 @@ _cancellable_idle_cb(gpointer user_data) static void _cancellable_on_idle(NMAuthChain *self) { - if (self->cancellable_idle_source) - return; - - self->cancellable_idle_source = - nm_g_idle_source_new(G_PRIORITY_DEFAULT, _cancellable_idle_cb, self, NULL); - g_source_attach(self->cancellable_idle_source, NULL); + if (!self->cancellable_idle_source) + self->cancellable_idle_source = nm_g_idle_add_source(_cancellable_idle_cb, self); } GCancellable * diff --git a/src/core/nm-config-data.c b/src/core/nm-config-data.c index 0cbff027..1cb8a43c 100644 --- a/src/core/nm-config-data.c +++ b/src/core/nm-config-data.c @@ -271,7 +271,7 @@ nm_config_data_get_plugins(const NMConfigData *self, gboolean allow_default) NM_CONFIG_DEFAULT_MAIN_PLUGINS); list = g_key_file_get_string_list(kf, NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", NULL, NULL); } - return _nm_utils_strv_cleanup(list, TRUE, TRUE, TRUE); + return nm_strv_cleanup(list, TRUE, TRUE, TRUE); } gboolean @@ -1026,7 +1026,7 @@ global_dns_config_seal_domains(NMGlobalDnsConfig *dns_config) if (g_hash_table_size(dns_config->domains) == 0) nm_clear_pointer(&dns_config->domains, g_hash_table_unref); else - dns_config->domain_list = nm_utils_strdict_get_keys(dns_config->domains, TRUE, NULL); + dns_config->domain_list = nm_strdict_get_keys(dns_config->domains, TRUE, NULL); } static NMGlobalDnsConfig * @@ -1060,7 +1060,7 @@ load_global_dns(GKeyFile *keyfile, gboolean internal) NULL, NULL); if (strv) { - _nm_utils_strv_cleanup(strv, TRUE, TRUE, TRUE); + nm_strv_cleanup(strv, TRUE, TRUE, TRUE); if (!strv[0]) g_free(strv); else @@ -1073,7 +1073,7 @@ load_global_dns(GKeyFile *keyfile, gboolean internal) NULL, NULL); if (strv) { - _nm_utils_strv_cleanup(strv, TRUE, TRUE, TRUE); + nm_strv_cleanup(strv, TRUE, TRUE, TRUE); for (i = 0, j = 0; strv[i]; i++) { if (_nm_utils_dns_option_validate(strv[i], NULL, NULL, TRUE, NULL)) strv[j++] = strv[i]; @@ -1103,7 +1103,7 @@ load_global_dns(GKeyFile *keyfile, gboolean internal) NULL, NULL); if (strv) { - _nm_utils_strv_cleanup(strv, TRUE, TRUE, TRUE); + nm_strv_cleanup(strv, TRUE, TRUE, TRUE); for (i = 0, j = 0; strv[i]; i++) { if (nm_utils_ipaddr_is_valid(AF_INET, strv[i]) || nm_utils_ipaddr_is_valid(AF_INET6, strv[i])) @@ -1128,7 +1128,7 @@ load_global_dns(GKeyFile *keyfile, gboolean internal) NULL, NULL); if (strv) { - options = _nm_utils_strv_cleanup(strv, TRUE, TRUE, TRUE); + options = nm_strv_cleanup(strv, TRUE, TRUE, TRUE); if (!options[0]) nm_clear_g_free(&options); } @@ -1240,7 +1240,7 @@ global_dns_domain_from_dbus(char *name, GVariant *variant) while (g_variant_iter_next(&iter, "{&sv}", &key, &val)) { if (nm_streq0(key, "servers") && g_variant_is_of_type(val, G_VARIANT_TYPE("as"))) { strv = g_variant_dup_strv(val, NULL); - _nm_utils_strv_cleanup(strv, TRUE, TRUE, TRUE); + nm_strv_cleanup(strv, TRUE, TRUE, TRUE); for (i = 0, j = 0; strv && strv[i]; i++) { if (nm_utils_ipaddr_is_valid(AF_INET, strv[i]) || nm_utils_ipaddr_is_valid(AF_INET6, strv[i])) @@ -1258,7 +1258,7 @@ global_dns_domain_from_dbus(char *name, GVariant *variant) } else if (nm_streq0(key, "options") && g_variant_is_of_type(val, G_VARIANT_TYPE("as"))) { strv = g_variant_dup_strv(val, NULL); g_strfreev(domain->options); - domain->options = _nm_utils_strv_cleanup(strv, TRUE, TRUE, TRUE); + domain->options = nm_strv_cleanup(strv, TRUE, TRUE, TRUE); if (!domain->options[0]) nm_clear_g_free(&domain->options); } @@ -1305,10 +1305,10 @@ nm_global_dns_config_from_dbus(const GValue *value, GError **error) while (g_variant_iter_next(&iter, "{&sv}", &key, &val)) { if (nm_streq0(key, "searches") && g_variant_is_of_type(val, G_VARIANT_TYPE("as"))) { strv = g_variant_dup_strv(val, NULL); - dns_config->searches = _nm_utils_strv_cleanup(strv, TRUE, TRUE, TRUE); + dns_config->searches = nm_strv_cleanup(strv, TRUE, TRUE, TRUE); } else if (nm_streq0(key, "options") && g_variant_is_of_type(val, G_VARIANT_TYPE("as"))) { strv = g_variant_dup_strv(val, NULL); - _nm_utils_strv_cleanup(strv, TRUE, TRUE, TRUE); + nm_strv_cleanup(strv, TRUE, TRUE, TRUE); for (i = 0, j = 0; strv && strv[i]; i++) { if (_nm_utils_dns_option_validate(strv[i], NULL, NULL, TRUE, NULL)) @@ -1370,8 +1370,7 @@ global_dns_equal(NMGlobalDnsConfig *old, NMGlobalDnsConfig *new) if (!old || !new) return FALSE; - if (!nm_utils_strv_equal(old->options, new->options) - || !nm_utils_strv_equal(old->searches, new->searches)) + if (!nm_strv_equal(old->options, new->options) || !nm_strv_equal(old->searches, new->searches)) return FALSE; if ((!old->domains || !new->domains) && old->domains != new->domains) @@ -1389,8 +1388,8 @@ global_dns_equal(NMGlobalDnsConfig *old, NMGlobalDnsConfig *new) domain_old = value_old; domain_new = value_new; - if (!nm_utils_strv_equal(domain_old->options, domain_new->options) - || !nm_utils_strv_equal(domain_old->servers, domain_new->servers)) + if (!nm_strv_equal(domain_old->options, domain_new->options) + || !nm_strv_equal(domain_old->servers, domain_new->servers)) return FALSE; } @@ -1681,7 +1680,7 @@ _match_section_info_init(MatchSectionInfo *connection_info, } keys = g_key_file_get_keys(keyfile, group, &n_keys, NULL); - nm_utils_strv_sort(keys, n_keys); + nm_strv_sort(keys, n_keys); vals = g_new(NMUtilsNamedValue, n_keys); @@ -1963,8 +1962,8 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps /* sort entries, remove duplicates and empty words. */ value_arr = len == 0 ? NULL : nm_memdup(value_arr_orig, sizeof(const char *) * (len + 1)); - nm_utils_strv_sort(value_arr, len); - _nm_utils_strv_cleanup((char **) value_arr, FALSE, TRUE, TRUE); + nm_strv_sort(value_arr, len); + nm_strv_cleanup((char **) value_arr, FALSE, TRUE, TRUE); len = NM_PTRARRAY_LEN(value_arr); j = 0; @@ -1988,7 +1987,7 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps specs = g_slist_prepend(specs, spec); } - priv->no_auto_default.arr = nm_utils_strv_dup(value_arr, j, TRUE); + priv->no_auto_default.arr = nm_strv_dup(value_arr, j, TRUE); priv->no_auto_default.specs = g_slist_reverse(specs); } break; diff --git a/src/core/nm-config-data.h b/src/core/nm-config-data.h index fa58d869..92a7cb5c 100644 --- a/src/core/nm-config-data.h +++ b/src/core/nm-config-data.h @@ -195,16 +195,16 @@ const char *nm_config_data_get_iwd_config_path(const NMConfigData *self); extern const char *__start_connection_defaults[]; extern const char *__stop_connection_defaults[]; -#define NM_CON_DEFAULT_NOP(name) \ - static const char *NM_UNIQ_T(connection_default, NM_UNIQ) \ - _nm_used _nm_section("connection_defaults") = "" name - -#define NM_CON_DEFAULT(name) \ - ({ \ - static const char *__con_default_prop _nm_used _nm_section("connection_defaults") = \ - "" name; \ - \ - name; \ +#define NM_CON_DEFAULT_NOP(name) \ + static const char * NM_UNIQ_T(connection_default, NM_UNIQ) \ + _nm_used _nm_retain _nm_section("connection_defaults") = "" name + +#define NM_CON_DEFAULT(name) \ + ({ \ + static const char *__con_default_prop _nm_used _nm_retain _nm_section( \ + "connection_defaults") = "" name; \ + \ + name; \ }) const char *nm_config_data_get_connection_default(const NMConfigData *self, diff --git a/src/core/nm-config.c b/src/core/nm-config.c index 817368d1..c41f5823 100644 --- a/src/core/nm-config.c +++ b/src/core/nm-config.c @@ -336,7 +336,7 @@ no_auto_default_from_file(const char *no_auto_default_file) gsize i; if (no_auto_default_file && g_file_get_contents(no_auto_default_file, &data, NULL, NULL)) - list = nm_utils_strsplit_set(data, "\n"); + list = nm_strsplit_set(data, "\n"); if (list) { for (i = 0; list[i]; i++) @@ -433,7 +433,7 @@ nm_config_set_no_auto_default_for_device(NMConfig *self, NMDevice *device) len = NM_PTRARRAY_LEN(no_auto_default_current); - idx = nm_utils_strv_find_binary_search(no_auto_default_current, len, spec); + idx = nm_strv_find_binary_search(no_auto_default_current, len, spec); if (idx >= 0) { /* @spec is already blocked. We don't have to update our in-memory representation. * Maybe we should write to no_auto_default_file anew, but let's save that too. */ @@ -1122,14 +1122,12 @@ read_config(GKeyFile * keyfile, /* merge the string lists, by omitting duplicates. */ for (iter_val = old_val; iter_val && *iter_val; iter_val++) { - if (last_char != '-' - || nm_utils_strv_find_first(new_val, -1, *iter_val) < 0) + if (last_char != '-' || nm_strv_find_first(new_val, -1, *iter_val) < 0) g_ptr_array_add(new, g_strdup(*iter_val)); } for (iter_val = new_val; iter_val && *iter_val; iter_val++) { /* don't add duplicates. That means an "option=a,b"; "option+=a,c" results in "option=a,b,c" */ - if (last_char == '+' - && nm_utils_strv_find_first(old_val, -1, *iter_val) < 0) + if (last_char == '+' && nm_strv_find_first(old_val, -1, *iter_val) < 0) g_ptr_array_add(new, *iter_val); else g_free(*iter_val); @@ -1147,7 +1145,7 @@ read_config(GKeyFile * keyfile, gs_free char * specs_joined = NULL; g_ptr_array_add(new, NULL); - specs = _nm_utils_strv_to_slist((char **) new->pdata, FALSE); + specs = nm_strv_to_gslist((char **) new->pdata, FALSE); specs_joined = nm_match_spec_join(specs); @@ -1333,9 +1331,8 @@ read_entire_config(const NMConfigCmdLineOptions *cli, const char *filename = system_confs->pdata[i]; /* if a same named file exists in config_dir or run_config_dir, skip it. */ - if (nm_utils_strv_find_first((char **) confs->pdata, confs->len, filename) >= 0 - || nm_utils_strv_find_first((char **) run_confs->pdata, run_confs->len, filename) - >= 0) { + if (nm_strv_ptrarray_find_first(confs, filename) >= 0 + || nm_strv_ptrarray_find_first(run_confs, filename) >= 0) { g_ptr_array_remove_index(system_confs, i); continue; } @@ -1349,7 +1346,7 @@ read_entire_config(const NMConfigCmdLineOptions *cli, const char *filename = run_confs->pdata[i]; /* if a same named file exists in config_dir, skip it. */ - if (nm_utils_strv_find_first((char **) confs->pdata, confs->len, filename) >= 0) { + if (nm_strv_ptrarray_find_first(confs, filename) >= 0) { g_ptr_array_remove_index(run_confs, i); continue; } diff --git a/src/core/nm-connectivity.c b/src/core/nm-connectivity.c index 85d41b49..13fb0265 100644 --- a/src/core/nm-connectivity.c +++ b/src/core/nm-connectivity.c @@ -10,10 +10,9 @@ #include "nm-connectivity.h" #if WITH_CONCHECK - #include +#include #endif #include -#include #include "c-list/src/c-list.h" #include "libnm-core-intern/nm-core-internal.h" @@ -509,15 +508,8 @@ multi_socket_cb(CURL *e_handle, curl_socket_t fd, int what, void *userdata, void else condition = 0; - if (condition) { - fdp->source = nm_g_unix_fd_source_new(fd, - condition, - G_PRIORITY_DEFAULT, - _con_curl_socketevent_cb, - fdp, - NULL); - g_source_attach(fdp->source, NULL); - } + if (condition) + fdp->source = nm_g_unix_fd_add_source(fd, condition, _con_curl_socketevent_cb, fdp); } return CURLM_OK; diff --git a/src/core/nm-core-utils.c b/src/core/nm-core-utils.c index 8fdc7379..747e1c09 100644 --- a/src/core/nm-core-utils.c +++ b/src/core/nm-core-utils.c @@ -39,8 +39,8 @@ #include "nm-setting-wireless-security.h" #ifdef __NM_SD_UTILS_H__ - #error \ - "nm-core-utils.c should stay independent of systemd utils. Are you looking for NetworkMangerUtils.c? " +#error \ + "nm-core-utils.c should stay independent of systemd utils. Are you looking for NetworkMangerUtils.c? " #endif G_STATIC_ASSERT(sizeof(NMUtilsTestFlags) <= sizeof(int)); @@ -458,7 +458,7 @@ _kc_invoke_callback(pid_t pid, data->sync.success = success; data->sync.child_status = child_status; - g_idle_add(_kc_invoke_callback_idle, data); + nm_g_idle_add(_kc_invoke_callback_idle, data); } /* nm_utils_kill_child_async: @@ -2484,8 +2484,6 @@ out: typedef struct { NMUuid bin; - char - _nul_sentinel; /* just for safety, if somebody accidentally uses the binary in a string context. */ /* depending on whether the string is packed or not (with/without hyphens), * it's 32 or 36 characters long (plus the trailing NUL). @@ -2503,9 +2501,8 @@ _uuid_data_init(UuidData *uuid_data, gboolean packed, gboolean is_fake, const NM nm_assert(uuid_data); nm_assert(uuid); - uuid_data->bin = *uuid; - uuid_data->_nul_sentinel = '\0'; - uuid_data->is_fake = is_fake; + uuid_data->bin = *uuid; + uuid_data->is_fake = is_fake; if (packed) { G_STATIC_ASSERT_EXPR(sizeof(uuid_data->str) >= (sizeof(*uuid) * 2 + 1)); nm_utils_bin2hexstr_full(uuid, sizeof(*uuid), '\0', FALSE, uuid_data->str); @@ -2573,7 +2570,7 @@ again: if (is_fake) { const guint8 *seed_bin; - const char * hash_seed; + const NMUuid *hash_seed; gsize seed_len; if (!allow_fake) { @@ -2583,6 +2580,9 @@ again: } if (nm_utils_host_id_get(&seed_bin, &seed_len)) { + static const NMUuid u = + NM_UUID_INIT(ab, 08, 5f, 06, b6, 29, 46, d1, a5, 53, 84, ee, ba, 56, 83, b6); + /* We have no valid machine-id but we have a valid secrey_key. * Generate a fake machine ID by hashing the secret-key. The secret_key * is commonly persisted, so it should be stable across reboots (despite @@ -2595,8 +2595,11 @@ again: * will call _machine_id_get(FALSE), so it won't allow accessing a fake * machine-id, thus avoiding the problem. */ fake_type = "secret-key"; - hash_seed = "ab085f06-b629-46d1-a553-84eeba5683b6"; + hash_seed = &u; } else { + static const NMUuid u = + NM_UUID_INIT(7f, f0, c8, f5, 53, 99, 49, 01, ab, 63, 61, bf, 59, 4a, be, 8b); + /* the secret-key is not valid/persistent either. That happens when we fail * to read/write the secret-key to disk. Fallback to boot-id. The boot-id * itself may be fake and randomly generated ad-hoc, but that is as best @@ -2604,7 +2607,7 @@ again: seed_bin = (const guint8 *) nm_utils_boot_id_bin(); seed_len = sizeof(NMUuid); fake_type = "boot-id"; - hash_seed = "7ff0c8f5-5399-4901-ab63-61bf594abe8b"; + hash_seed = &u; } /* the fake machine-id is based on secret-key/boot-id, but we hash it @@ -2613,7 +2616,7 @@ again: (const char *) seed_bin, seed_len, NM_UUID_TYPE_VERSION5, - (gpointer) hash_seed); + hash_seed); } if (!g_once_init_enter(&lock)) @@ -2874,10 +2877,11 @@ typedef struct { bool timestamp_is_good : 1; } HostIdData; +static const HostIdData *volatile host_id_static; + static const HostIdData * _host_id_get(void) { - static const HostIdData *volatile host_id_static; const HostIdData *host_id; again: @@ -2938,6 +2942,78 @@ nm_utils_host_id_get_timestamp_ns(void) return _host_id_get()->timestamp_ns; } +static GArray * nmtst_host_id_stack = NULL; +static GMutex nmtst_host_id_lock; +const HostIdData *nmtst_host_id_static_0 = NULL; + +void +nmtst_utils_host_id_push(const guint8 *host_id, + gssize host_id_len, + gboolean is_good, + const gint64 *timestamp_ns) +{ + NM_G_MUTEX_LOCKED(&nmtst_host_id_lock); + gs_free char *str1_to_free = NULL; + HostIdData * h; + + g_assert(host_id_len >= -1); + + if (host_id_len < 0) + host_id_len = host_id ? strlen((const char *) host_id) : 0; + + nm_log_dbg(LOGD_CORE, + "nmtst: host-id push: \"%s\" (%zu), is-good=%d, timestamp=%" G_GINT64_FORMAT "%s", + nm_utils_buf_utf8safe_escape(host_id, + host_id_len, + NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_CTRL, + &str1_to_free), + (gsize) host_id_len, + !!is_good, + timestamp_ns ? *timestamp_ns : 0, + timestamp_ns ? "" : " (not-good)"); + + if (!nmtst_host_id_stack) { + nmtst_host_id_stack = g_array_new(FALSE, FALSE, sizeof(HostIdData)); + nmtst_host_id_static_0 = g_atomic_pointer_get(&host_id_static); + } + + h = nm_g_array_append_new(nmtst_host_id_stack, HostIdData); + + *h = (HostIdData){ + .host_id = nm_memdup(host_id, host_id_len), + .host_id_len = host_id_len, + .timestamp_ns = timestamp_ns ? *timestamp_ns : 0, + .is_good = is_good, + .timestamp_is_good = !!timestamp_ns, + }; + + g_atomic_pointer_set(&host_id_static, h); +} + +void +nmtst_utils_host_id_pop(void) +{ + NM_G_MUTEX_LOCKED(&nmtst_host_id_lock); + HostIdData *h; + + g_assert(nmtst_host_id_stack); + g_assert(nmtst_host_id_stack->len > 0); + + nm_log_dbg(LOGD_CORE, "nmtst: host-id pop"); + + h = &g_array_index(nmtst_host_id_stack, HostIdData, nmtst_host_id_stack->len - 1); + + g_free((char *) h->host_id); + g_array_set_size(nmtst_host_id_stack, nmtst_host_id_stack->len - 1u); + + if (!g_atomic_pointer_compare_and_exchange( + &host_id_static, + h, + nmtst_host_id_stack->len == 0u ? nmtst_host_id_static_0 + : nm_g_array_last(nmtst_host_id_stack, HostIdData))) + g_assert_not_reached(); +} + /*****************************************************************************/ static const UuidData * @@ -3423,15 +3499,14 @@ _is_reserved_ipv6_iid(const guint8 *iid) return FALSE; } -static gboolean -_set_stable_privacy(NMUtilsStableType stable_type, - struct in6_addr * addr, - const char * ifname, - const char * network_id, - guint32 dad_counter, - const guint8 * host_id, - gsize host_id_len, - GError ** error) +void +nm_utils_ipv6_addr_set_stable_privacy_with_host_id(NMUtilsStableType stable_type, + struct in6_addr * addr, + const char * ifname, + const char * network_id, + guint32 dad_counter, + const guint8 * host_id, + gsize host_id_len) { nm_auto_free_checksum GChecksum *sum = NULL; guint8 digest[NM_UTILS_CHECKSUM_LENGTH_SHA256]; @@ -3480,30 +3555,29 @@ _set_stable_privacy(NMUtilsStableType stable_type, } memcpy(addr->s6_addr + 8, &digest[0], 8); - return TRUE; } -gboolean -nm_utils_ipv6_addr_set_stable_privacy_impl(NMUtilsStableType stable_type, - struct in6_addr * addr, - const char * ifname, - const char * network_id, - guint32 dad_counter, - guint8 * host_id, - gsize host_id_len, - GError ** error) +void +nm_utils_ipv6_addr_set_stable_privacy(NMUtilsStableType stable_type, + struct in6_addr * addr, + const char * ifname, + const char * network_id, + guint32 dad_counter) { - return _set_stable_privacy(stable_type, - addr, - ifname, - network_id, - dad_counter, - host_id, - host_id_len, - error); + const guint8 *host_id; + gsize host_id_len; + + nm_utils_host_id_get(&host_id, &host_id_len); + + nm_utils_ipv6_addr_set_stable_privacy_with_host_id(stable_type, + addr, + ifname, + network_id, + dad_counter, + host_id, + host_id_len); } -#define RFC7217_IDGEN_RETRIES 3 /** * nm_utils_ipv6_addr_set_stable_privacy: * @@ -3513,19 +3587,16 @@ nm_utils_ipv6_addr_set_stable_privacy_impl(NMUtilsStableType stable_type, * Returns: %TRUE on success, %FALSE if the address could not be generated. */ gboolean -nm_utils_ipv6_addr_set_stable_privacy(NMUtilsStableType stable_type, - struct in6_addr * addr, - const char * ifname, - const char * network_id, - guint32 dad_counter, - GError ** error) +nm_utils_ipv6_addr_set_stable_privacy_may_fail(NMUtilsStableType stable_type, + struct in6_addr * addr, + const char * ifname, + const char * network_id, + guint32 dad_counter, + GError ** error) { - const guint8 *host_id; - gsize host_id_len; - g_return_val_if_fail(network_id, FALSE); - if (dad_counter >= RFC7217_IDGEN_RETRIES) { + if (dad_counter >= NM_STABLE_PRIVACY_RFC7217_IDGEN_RETRIES) { g_set_error_literal(error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN, @@ -3533,16 +3604,8 @@ nm_utils_ipv6_addr_set_stable_privacy(NMUtilsStableType stable_type, return FALSE; } - nm_utils_host_id_get(&host_id, &host_id_len); - - return _set_stable_privacy(stable_type, - addr, - ifname, - network_id, - dad_counter, - host_id, - host_id_len, - error); + nm_utils_ipv6_addr_set_stable_privacy(stable_type, addr, ifname, network_id, dad_counter); + return TRUE; } /*****************************************************************************/ @@ -4069,8 +4132,8 @@ nm_utils_get_reverse_dns_domains_ip_4(guint32 addr, guint8 plen, GPtrArray *doma len = len0; str = s = g_malloc(len); for (i = octets; i > 0; i--) - nm_utils_strbuf_append(&s, &len, "%u.", p[i - 1] & 0xff); - nm_utils_strbuf_append_str(&s, &len, "in-addr.arpa"); + nm_strbuf_append(&s, &len, "%u.", p[i - 1] & 0xff); + nm_strbuf_append_str(&s, &len, "in-addr.arpa"); g_ptr_array_add(domains, str); @@ -4121,8 +4184,8 @@ nm_utils_get_reverse_dns_domains_ip_6(const struct in6_addr *ip, guint8 plen, GP str = s = g_malloc(len); for (j = nibbles - 1; j >= 0; j--) - nm_utils_strbuf_append(&s, &len, "%x.", (addr.s6_addr[j / 2] >> N_SHIFT(j)) & 0xf); - nm_utils_strbuf_append_str(&s, &len, "ip6.arpa"); + nm_strbuf_append(&s, &len, "%x.", (addr.s6_addr[j / 2] >> N_SHIFT(j)) & 0xf); + nm_strbuf_append_str(&s, &len, "ip6.arpa"); g_ptr_array_add(domains, str); diff --git a/src/core/nm-core-utils.h b/src/core/nm-core-utils.h index 76c340d1..38f56adc 100644 --- a/src/core/nm-core-utils.h +++ b/src/core/nm-core-utils.h @@ -40,7 +40,7 @@ void _nm_singleton_instance_register_destruction(GObject *instance); /* By default, the getter will assert that the singleton will be created only once. You can * change this by redefining NM_DEFINE_SINGLETON_ALLOW_MULTIPLE. */ #ifndef NM_DEFINE_SINGLETON_ALLOW_MULTIPLE - #define NM_DEFINE_SINGLETON_ALLOW_MULTIPLE FALSE +#define NM_DEFINE_SINGLETON_ALLOW_MULTIPLE FALSE #endif #define NM_DEFINE_SINGLETON_GETTER(TYPE, GETTER, GTYPE, ...) \ @@ -247,6 +247,33 @@ const char *const * nm_utils_proc_cmdline_split(void); gboolean nm_utils_host_id_get(const guint8 **out_host_id, gsize *out_host_id_len); gint64 nm_utils_host_id_get_timestamp_ns(void); +void nmtst_utils_host_id_push(const guint8 *host_id, + gssize host_id_len, + gboolean is_good, + const gint64 *timestamp_ns); + +void nmtst_utils_host_id_pop(void); + +static inline void +_nmtst_auto_utils_host_id_context_pop(const char *const *unused) +{ + nmtst_utils_host_id_pop(); +} + +#define _NMTST_UTILS_HOST_ID_CONTEXT(uniq, host_id) \ + _nm_unused nm_auto(_nmtst_auto_utils_host_id_context_pop) \ + const char *const NM_UNIQ_T(_host_id_context_, uniq) = ({ \ + const gint64 _timestamp_ns = 1631000672; \ + \ + nmtst_utils_host_id_push((const guint8 *) "" host_id "", \ + NM_STRLEN(host_id), \ + TRUE, \ + &_timestamp_ns); \ + "" host_id ""; \ + }) + +#define NMTST_UTILS_HOST_ID_CONTEXT(host_id) _NMTST_UTILS_HOST_ID_CONTEXT(NM_UNIQ, host_id) + /*****************************************************************************/ int nm_utils_arp_type_detect_from_hwaddrlen(gsize hwaddr_len); @@ -271,6 +298,8 @@ typedef enum { NM_UTILS_STABLE_TYPE_RANDOM = 3, } NMUtilsStableType; +#define NM_UTILS_STABLE_TYPE_NONE ((NMUtilsStableType) -1) + NMUtilsStableType nm_utils_stable_id_parse(const char *stable_id, const char *deviceid, const char *hwaddr, @@ -281,21 +310,28 @@ NMUtilsStableType nm_utils_stable_id_parse(const char *stable_id, char *nm_utils_stable_id_random(void); char *nm_utils_stable_id_generated_complete(const char *msg); -gboolean nm_utils_ipv6_addr_set_stable_privacy_impl(NMUtilsStableType stable_type, - struct in6_addr * addr, - const char * ifname, - const char * network_id, - guint32 dad_counter, - guint8 * host_id, - gsize host_id_len, - GError ** error); - -gboolean nm_utils_ipv6_addr_set_stable_privacy(NMUtilsStableType id_type, - struct in6_addr * addr, - const char * ifname, - const char * network_id, - guint32 dad_counter, - GError ** error); +#define NM_STABLE_PRIVACY_RFC7217_IDGEN_RETRIES 3 + +void nm_utils_ipv6_addr_set_stable_privacy_with_host_id(NMUtilsStableType stable_type, + struct in6_addr * addr, + const char * ifname, + const char * network_id, + guint32 dad_counter, + const guint8 * host_id, + gsize host_id_len); + +void nm_utils_ipv6_addr_set_stable_privacy(NMUtilsStableType stable_type, + struct in6_addr * addr, + const char * ifname, + const char * network_id, + guint32 dad_counter); + +gboolean nm_utils_ipv6_addr_set_stable_privacy_may_fail(NMUtilsStableType stable_type, + struct in6_addr * addr, + const char * ifname, + const char * network_id, + guint32 dad_counter, + GError ** error); char *nm_utils_hw_addr_gen_random_eth(const char *current_mac_address, const char *generate_mac_address_mask); diff --git a/src/core/nm-dbus-manager.c b/src/core/nm-dbus-manager.c index c47d4dbf..323d0a19 100644 --- a/src/core/nm-dbus-manager.c +++ b/src/core/nm-dbus-manager.c @@ -262,7 +262,7 @@ private_server_closed_connection(GDBusConnection *conn, /* Delay the close of connection to ensure that D-Bus signals * are handled */ - g_idle_add(close_connection_in_idle, info); + nm_g_idle_add(close_connection_in_idle, info); } static gboolean diff --git a/src/core/nm-dbus-object.c b/src/core/nm-dbus-object.c index 04149739..95077626 100644 --- a/src/core/nm-dbus-object.c +++ b/src/core/nm-dbus-object.c @@ -178,7 +178,7 @@ nm_dbus_object_unexport_on_idle(gpointer /* (NMDBusObject *) */ self_take) nm_shutdown_wait_obj_register_object(self, "unexport-dbus-obj-on-idle"); /* pass on ownership. */ - g_idle_add(_unexport_on_idle_cb, g_steal_pointer(&self)); + nm_g_idle_add(_unexport_on_idle_cb, g_steal_pointer(&self)); } /*****************************************************************************/ diff --git a/src/core/nm-dbus-utils.c b/src/core/nm-dbus-utils.c index d3e5612d..7f7b9fb9 100644 --- a/src/core/nm-dbus-utils.c +++ b/src/core/nm-dbus-utils.c @@ -97,27 +97,13 @@ nm_dbus_utils_get_property(GObject *obj, const char *signature, const char *prop void nm_dbus_utils_g_value_set_object_path(GValue *value, gpointer object) { - const char *path; - - g_return_if_fail(!object || NM_IS_DBUS_OBJECT(object)); - - if (object && (path = nm_dbus_object_get_path(object))) - g_value_set_string(value, path); - else - g_value_set_string(value, NULL); + g_value_set_string(value, object ? nm_dbus_object_get_path(object) : NULL); } void nm_dbus_utils_g_value_set_object_path_still_exported(GValue *value, gpointer object) { - const char *path; - - g_return_if_fail(!object || NM_IS_DBUS_OBJECT(object)); - - if (object && (path = nm_dbus_object_get_path_still_exported(object))) - g_value_set_string(value, path); - else - g_value_set_string(value, "/"); + g_value_set_string(value, object ? nm_dbus_object_get_path_still_exported(object) : "/"); } void @@ -152,7 +138,7 @@ nm_dbus_utils_g_value_set_object_path_from_hash( strv[i] = NULL; /* sort the names, to give a well-defined, stable order. */ - nm_utils_strv_sort(strv, i); + nm_strv_sort(strv, i); g_value_take_boxed(value, strv); } diff --git a/src/core/nm-dcb.c b/src/core/nm-dcb.c index 930a1023..f048d999 100644 --- a/src/core/nm-dcb.c +++ b/src/core/nm-dcb.c @@ -35,7 +35,7 @@ do_helper(const char *iface, cmdline = g_strdup_vprintf(fmt, args); va_end(args); - split = nm_utils_strsplit_set_with_empty(cmdline, " "); + split = nm_strsplit_set_with_empty(cmdline, " "); if (!split) { g_set_error(error, NM_MANAGER_ERROR, @@ -258,7 +258,8 @@ _fcoe_setup(const char * iface, flags = nm_setting_dcb_get_app_fcoe_flags(s_dcb); if (flags & NM_SETTING_DCB_FLAG_ENABLE) { - const char *mode = nm_setting_dcb_get_app_fcoe_mode(s_dcb); + const char *mode = + nm_setting_dcb_get_app_fcoe_mode(s_dcb) ?: NM_SETTING_DCB_FCOE_MODE_FABRIC; if (!do_helper(NULL, FCOEADM, run_func, user_data, error, "-m %s -c %s", mode, iface)) return FALSE; diff --git a/src/core/nm-dhcp-config.c b/src/core/nm-dhcp-config.c index 1cbad49e..8a029119 100644 --- a/src/core/nm-dhcp-config.c +++ b/src/core/nm-dhcp-config.c @@ -87,7 +87,7 @@ nm_dhcp_config_set_options(NMDhcpConfig *self, GHashTable *options) priv = NM_DHCP_CONFIG_GET_PRIVATE(self); nm_g_variant_unref(priv->options); - priv->options = g_variant_ref_sink(nm_utils_strdict_to_variant_asv(options)); + priv->options = g_variant_ref_sink(nm_strdict_to_variant_asv(options)); _notify(self, PROP_OPTIONS); } diff --git a/src/core/nm-dispatcher.c b/src/core/nm-dispatcher.c index 32c9db62..b7719786 100644 --- a/src/core/nm-dispatcher.c +++ b/src/core/nm-dispatcher.c @@ -448,17 +448,17 @@ dispatcher_done_cb(GObject *source, GAsyncResult *result, gpointer user_data) dispatcher_call_id_free(call_id); } -static const char *action_table[] = {[NM_DISPATCHER_ACTION_HOSTNAME] = NMD_ACTION_HOSTNAME, - [NM_DISPATCHER_ACTION_PRE_UP] = NMD_ACTION_PRE_UP, - [NM_DISPATCHER_ACTION_UP] = NMD_ACTION_UP, - [NM_DISPATCHER_ACTION_PRE_DOWN] = NMD_ACTION_PRE_DOWN, - [NM_DISPATCHER_ACTION_DOWN] = NMD_ACTION_DOWN, - [NM_DISPATCHER_ACTION_VPN_PRE_UP] = NMD_ACTION_VPN_PRE_UP, - [NM_DISPATCHER_ACTION_VPN_UP] = NMD_ACTION_VPN_UP, - [NM_DISPATCHER_ACTION_VPN_PRE_DOWN] = NMD_ACTION_VPN_PRE_DOWN, - [NM_DISPATCHER_ACTION_VPN_DOWN] = NMD_ACTION_VPN_DOWN, - [NM_DISPATCHER_ACTION_DHCP4_CHANGE] = NMD_ACTION_DHCP4_CHANGE, - [NM_DISPATCHER_ACTION_DHCP6_CHANGE] = NMD_ACTION_DHCP6_CHANGE, +static const char *action_table[] = {[NM_DISPATCHER_ACTION_HOSTNAME] = NMD_ACTION_HOSTNAME, + [NM_DISPATCHER_ACTION_PRE_UP] = NMD_ACTION_PRE_UP, + [NM_DISPATCHER_ACTION_UP] = NMD_ACTION_UP, + [NM_DISPATCHER_ACTION_PRE_DOWN] = NMD_ACTION_PRE_DOWN, + [NM_DISPATCHER_ACTION_DOWN] = NMD_ACTION_DOWN, + [NM_DISPATCHER_ACTION_VPN_PRE_UP] = NMD_ACTION_VPN_PRE_UP, + [NM_DISPATCHER_ACTION_VPN_UP] = NMD_ACTION_VPN_UP, + [NM_DISPATCHER_ACTION_VPN_PRE_DOWN] = NMD_ACTION_VPN_PRE_DOWN, + [NM_DISPATCHER_ACTION_VPN_DOWN] = NMD_ACTION_VPN_DOWN, + [NM_DISPATCHER_ACTION_DHCP_CHANGE_4] = NMD_ACTION_DHCP4_CHANGE, + [NM_DISPATCHER_ACTION_DHCP_CHANGE_6] = NMD_ACTION_DHCP6_CHANGE, [NM_DISPATCHER_ACTION_CONNECTIVITY_CHANGE] = NMD_ACTION_CONNECTIVITY_CHANGE}; diff --git a/src/core/nm-dispatcher.h b/src/core/nm-dispatcher.h index d588de4e..8e4f01cb 100644 --- a/src/core/nm-dispatcher.h +++ b/src/core/nm-dispatcher.h @@ -19,11 +19,14 @@ typedef enum { NM_DISPATCHER_ACTION_VPN_UP, NM_DISPATCHER_ACTION_VPN_PRE_DOWN, NM_DISPATCHER_ACTION_VPN_DOWN, - NM_DISPATCHER_ACTION_DHCP4_CHANGE, - NM_DISPATCHER_ACTION_DHCP6_CHANGE, + NM_DISPATCHER_ACTION_DHCP_CHANGE_4, + NM_DISPATCHER_ACTION_DHCP_CHANGE_6, NM_DISPATCHER_ACTION_CONNECTIVITY_CHANGE } NMDispatcherAction; +#define NM_DISPATCHER_ACTION_DHCP_CHANGE_X(IS_IPv4) \ + ((IS_IPv4) ? NM_DISPATCHER_ACTION_DHCP_CHANGE_4 : NM_DISPATCHER_ACTION_DHCP_CHANGE_6) + typedef struct NMDispatcherCallId NMDispatcherCallId; typedef void (*NMDispatcherFunc)(NMDispatcherCallId *call_id, gpointer user_data); diff --git a/src/core/nm-firewalld-manager.c b/src/core/nm-firewalld-manager.c index 7866894a..43ab278a 100644 --- a/src/core/nm-firewalld-manager.c +++ b/src/core/nm-firewalld-manager.c @@ -487,7 +487,7 @@ name_owner_changed(NMFirewalldManager *self, const char *owner) just_initied = !priv->dbus_inited; priv->dbus_inited = TRUE; - name_owner_changed = nm_utils_strdup_reset(&priv->name_owner, owner); + name_owner_changed = nm_strdup_reset(&priv->name_owner, owner); now_running = _get_running(priv); diff --git a/src/core/nm-hostname-manager.c b/src/core/nm-hostname-manager.c index 91e9baaa..32dc2db9 100644 --- a/src/core/nm-hostname-manager.c +++ b/src/core/nm-hostname-manager.c @@ -10,8 +10,8 @@ #include #if HAVE_SELINUX - #include - #include +#include +#include #endif #include "libnm-core-aux-intern/nm-common-macros.h" @@ -37,17 +37,17 @@ #if (defined(HOSTNAME_PERSIST_SUSE) + defined(HOSTNAME_PERSIST_SLACKWARE) \ + defined(HOSTNAME_PERSIST_GENTOO)) \ > 1 - #error "Can only define one of HOSTNAME_PERSIST_*" +#error "Can only define one of HOSTNAME_PERSIST_*" #endif #if defined(HOSTNAME_PERSIST_SUSE) - #define HOSTNAME_FILE HOSTNAME_FILE_UCASE_HOSTNAME +#define HOSTNAME_FILE HOSTNAME_FILE_UCASE_HOSTNAME #elif defined(HOSTNAME_PERSIST_SLACKWARE) - #define HOSTNAME_FILE HOSTNAME_FILE_UCASE_HOSTNAME +#define HOSTNAME_FILE HOSTNAME_FILE_UCASE_HOSTNAME #elif defined(HOSTNAME_PERSIST_GENTOO) - #define HOSTNAME_FILE HOSTNAME_FILE_GENTOO +#define HOSTNAME_FILE HOSTNAME_FILE_GENTOO #else - #define HOSTNAME_FILE HOSTNAME_FILE_DEFAULT +#define HOSTNAME_FILE HOSTNAME_FILE_DEFAULT #endif /*****************************************************************************/ @@ -86,6 +86,19 @@ NM_DEFINE_SINGLETON_GETTER(NMHostnameManager, nm_hostname_manager_get, NM_TYPE_H /*****************************************************************************/ +static inline GFileMonitor * +_file_monitor_new(const char *path) +{ + gs_unref_object GFile *file = NULL; + + nm_assert(path); + + file = g_file_new_for_path(path); + return g_file_monitor_file(file, G_FILE_MONITOR_NONE, NULL, NULL); +} + +/*****************************************************************************/ + #if defined(HOSTNAME_PERSIST_GENTOO) static char * read_hostname_gentoo(const char *path) @@ -162,41 +175,6 @@ hostname_is_dynamic(void) } #endif -/* Returns an allocated string which the caller owns and must eventually free */ -char * -nm_hostname_manager_read_hostname(NMHostnameManager *self) -{ - NMHostnameManagerPrivate *priv = NM_HOSTNAME_MANAGER_GET_PRIVATE(self); - char * hostname = NULL; - - if (priv->hostnamed_proxy) { - hostname = g_strdup(priv->current_hostname); - goto out; - } - -#if defined(HOSTNAME_PERSIST_SUSE) - if (priv->dhcp_monitor_id && hostname_is_dynamic()) - return NULL; -#endif - -#if defined(HOSTNAME_PERSIST_GENTOO) - hostname = read_hostname_gentoo(HOSTNAME_FILE); -#elif defined(HOSTNAME_PERSIST_SLACKWARE) - hostname = read_hostname_slackware(HOSTNAME_FILE); -#else - if (g_file_get_contents(HOSTNAME_FILE, &hostname, NULL, NULL)) - g_strchomp(hostname); -#endif - -out: - if (hostname && !hostname[0]) { - g_free(hostname); - return NULL; - } - - return hostname; -} - /*****************************************************************************/ const char * @@ -207,76 +185,78 @@ nm_hostname_manager_get_hostname(NMHostnameManager *self) } static void -_set_hostname_take(NMHostnameManager *self, char *hostname) +_set_hostname(NMHostnameManager *self, const char *hostname) { NMHostnameManagerPrivate *priv = NM_HOSTNAME_MANAGER_GET_PRIVATE(self); + char * old_hostname; + + hostname = nm_str_not_empty(hostname); + + if (nm_streq0(hostname, priv->current_hostname)) + return; _LOGI("hostname changed from %s%s%s to %s%s%s", NM_PRINT_FMT_QUOTED(priv->current_hostname, "\"", priv->current_hostname, "\"", "(none)"), NM_PRINT_FMT_QUOTED(hostname, "\"", hostname, "\"", "(none)")); - g_free(priv->current_hostname); - priv->current_hostname = hostname; - _notify(self, PROP_HOSTNAME); -} - -static void -_set_hostname(NMHostnameManager *self, const char *hostname) -{ - NMHostnameManagerPrivate *priv = NM_HOSTNAME_MANAGER_GET_PRIVATE(self); + old_hostname = priv->current_hostname; + priv->current_hostname = g_strdup(hostname); + g_free(old_hostname); - hostname = nm_str_not_empty(hostname); - if (!nm_streq0(hostname, priv->current_hostname)) - _set_hostname_take(self, g_strdup(hostname)); + _notify(self, PROP_HOSTNAME); } static void -_set_hostname_read(NMHostnameManager *self) +_set_hostname_read_file(NMHostnameManager *self) { - NMHostnameManagerPrivate *priv = NM_HOSTNAME_MANAGER_GET_PRIVATE(self); - char * hostname; + NMHostnameManagerPrivate *priv = NM_HOSTNAME_MANAGER_GET_PRIVATE(self); + gs_free char * hostname = NULL; if (priv->hostnamed_proxy) { /* read-hostname returns the current hostname with hostnamed. */ return; } - hostname = nm_hostname_manager_read_hostname(self); - - if (nm_streq0(hostname, priv->current_hostname)) { - g_free(hostname); +#if defined(HOSTNAME_PERSIST_SUSE) + if (priv->dhcp_monitor_id && hostname_is_dynamic()) return; - } +#endif + +#if defined(HOSTNAME_PERSIST_GENTOO) + hostname = read_hostname_gentoo(HOSTNAME_FILE); +#elif defined(HOSTNAME_PERSIST_SLACKWARE) + hostname = read_hostname_slackware(HOSTNAME_FILE); +#else + if (g_file_get_contents(HOSTNAME_FILE, &hostname, NULL, NULL)) + g_strchomp(hostname); +#endif - _set_hostname_take(self, hostname); + _set_hostname(self, hostname); } /*****************************************************************************/ -typedef struct { - char * hostname; - NMHostnameManagerSetHostnameCb cb; - gpointer user_data; -} SetHostnameInfo; - static void set_transient_hostname_done(GObject *object, GAsyncResult *res, gpointer user_data) { - GDBusProxy *proxy = G_DBUS_PROXY(object); - gs_free SetHostnameInfo *info = user_data; - gs_unref_variant GVariant *result = NULL; - gs_free_error GError *error = NULL; + GDBusProxy * proxy = G_DBUS_PROXY(object); + gs_unref_variant GVariant *result = NULL; + gs_free_error GError * error = NULL; + gs_free char * hostname = NULL; + NMHostnameManagerSetHostnameCb cb; + gpointer cb_user_data; + + nm_utils_user_data_unpack(user_data, &hostname, &cb, &cb_user_data); result = g_dbus_proxy_call_finish(proxy, res, &error); if (error) { _LOGW("couldn't set the system hostname to '%s' using hostnamed: %s", - info->hostname, + hostname, error->message); } - info->cb(info->hostname, !error, info->user_data); - g_free(info->hostname); + cb(hostname, !error, cb_user_data); } void @@ -286,7 +266,6 @@ nm_hostname_manager_set_transient_hostname(NMHostnameManager * self, gpointer user_data) { NMHostnameManagerPrivate *priv; - SetHostnameInfo * info; g_return_if_fail(NM_IS_HOSTNAME_MANAGER(self)); @@ -297,11 +276,6 @@ nm_hostname_manager_set_transient_hostname(NMHostnameManager * self, return; } - info = g_new0(SetHostnameInfo, 1); - info->hostname = g_strdup(hostname); - info->cb = cb; - info->user_data = user_data; - g_dbus_proxy_call(priv->hostnamed_proxy, "SetHostname", g_variant_new("(sb)", hostname, FALSE), @@ -309,7 +283,7 @@ nm_hostname_manager_set_transient_hostname(NMHostnameManager * self, -1, NULL, set_transient_hostname_done, - info); + nm_utils_user_data_pack(g_strdup(hostname), cb, user_data)); } gboolean @@ -428,71 +402,63 @@ nm_hostname_manager_write_hostname(NMHostnameManager *self, const char *hostname return TRUE; } -gboolean -nm_hostname_manager_validate_hostname(const char *hostname) -{ - const char *p; - gboolean dot = TRUE; - - if (!hostname || !hostname[0]) - return FALSE; - - for (p = hostname; *p; p++) { - if (*p == '.') { - if (dot) - return FALSE; - dot = TRUE; - } else { - if (!g_ascii_isalnum(*p) && (*p != '-') && (*p != '_')) - return FALSE; - dot = FALSE; - } - } +/*****************************************************************************/ - if (dot) - return FALSE; +static void +hostnamed_properties_changed(GDBusProxy *proxy, + GVariant * changed_properties, + char ** invalidated_properties, + gpointer user_data) +{ + NMHostnameManager * self = user_data; + NMHostnameManagerPrivate *priv = NM_HOSTNAME_MANAGER_GET_PRIVATE(self); + gs_unref_variant GVariant *variant = NULL; - return (p - hostname <= HOST_NAME_MAX); + variant = g_dbus_proxy_get_cached_property(priv->hostnamed_proxy, "StaticHostname"); + if (variant && g_variant_is_of_type(variant, G_VARIANT_TYPE_STRING)) + _set_hostname(self, g_variant_get_string(variant, NULL)); } +/*****************************************************************************/ + static void -hostname_file_changed_cb(GFileMonitor * monitor, - GFile * file, - GFile * other_file, - GFileMonitorEvent event_type, - gpointer user_data) +_file_monitors_file_changed_cb(GFileMonitor * monitor, + GFile * file, + GFile * other_file, + GFileMonitorEvent event_type, + gpointer user_data) { - _set_hostname_read(user_data); + _set_hostname_read_file(user_data); } -/*****************************************************************************/ - static void -hostnamed_properties_changed(GDBusProxy *proxy, - GVariant * changed_properties, - char ** invalidated_properties, - gpointer user_data) +_file_monitors_clear(NMHostnameManager *self) { - NMHostnameManager * self = user_data; NMHostnameManagerPrivate *priv = NM_HOSTNAME_MANAGER_GET_PRIVATE(self); - GVariant * v_hostname; - v_hostname = g_dbus_proxy_get_cached_property(priv->hostnamed_proxy, "StaticHostname"); - if (v_hostname) { - _set_hostname(self, g_variant_get_string(v_hostname, NULL)); - g_variant_unref(v_hostname); + if (priv->monitor) { + nm_clear_g_signal_handler(priv->monitor, &priv->monitor_id); + g_file_monitor_cancel(priv->monitor); + g_clear_object(&priv->monitor); + } + + if (priv->dhcp_monitor) { + nm_clear_g_signal_handler(priv->dhcp_monitor, &priv->dhcp_monitor_id); + g_file_monitor_cancel(priv->dhcp_monitor); + g_clear_object(&priv->dhcp_monitor); } } static void -setup_hostname_file_monitors(NMHostnameManager *self) +_file_monitors_setup(NMHostnameManager *self) { NMHostnameManagerPrivate *priv = NM_HOSTNAME_MANAGER_GET_PRIVATE(self); GFileMonitor * monitor; const char * path = HOSTNAME_FILE; - char * link_path = NULL; + gs_free char * link_path = NULL; struct stat file_stat; - GFile * file; + + _file_monitors_clear(self); /* resolve the path to the hostname file if it is a symbolic link */ if (lstat(path, &file_stat) == 0 && S_ISLNK(file_stat.st_mode) @@ -505,29 +471,24 @@ setup_hostname_file_monitors(NMHostnameManager *self) } /* monitor changes to hostname file */ - file = g_file_new_for_path(path); - monitor = g_file_monitor_file(file, G_FILE_MONITOR_NONE, NULL, NULL); - g_object_unref(file); - g_free(link_path); + monitor = _file_monitor_new(path); if (monitor) { priv->monitor_id = - g_signal_connect(monitor, "changed", G_CALLBACK(hostname_file_changed_cb), self); + g_signal_connect(monitor, "changed", G_CALLBACK(_file_monitors_file_changed_cb), self); priv->monitor = monitor; } #if defined(HOSTNAME_PERSIST_SUSE) /* monitor changes to dhcp file to know whether the hostname is valid */ - file = g_file_new_for_path(CONF_DHCP); - monitor = g_file_monitor_file(file, G_FILE_MONITOR_NONE, NULL, NULL); - g_object_unref(file); + monitor = _file_monitor_new(CONF_DHCP); if (monitor) { priv->dhcp_monitor_id = - g_signal_connect(monitor, "changed", G_CALLBACK(hostname_file_changed_cb), self); + g_signal_connect(monitor, "changed", G_CALLBACK(_file_monitors_file_changed_cb), self); priv->dhcp_monitor = monitor; } #endif - _set_hostname_read(self); + _set_hostname_read_file(self); } /*****************************************************************************/ @@ -591,7 +552,7 @@ constructed(GObject *object) } if (!priv->hostnamed_proxy) - setup_hostname_file_monitors(self); + _file_monitors_setup(self); G_OBJECT_CLASS(nm_hostname_manager_parent_class)->constructed(object); } @@ -609,21 +570,7 @@ dispose(GObject *object) g_clear_object(&priv->hostnamed_proxy); } - if (priv->monitor) { - if (priv->monitor_id) - g_signal_handler_disconnect(priv->monitor, priv->monitor_id); - - g_file_monitor_cancel(priv->monitor); - g_clear_object(&priv->monitor); - } - - if (priv->dhcp_monitor) { - if (priv->dhcp_monitor_id) - g_signal_handler_disconnect(priv->dhcp_monitor, priv->dhcp_monitor_id); - - g_file_monitor_cancel(priv->dhcp_monitor); - g_clear_object(&priv->dhcp_monitor); - } + _file_monitors_clear(self); nm_clear_g_free(&priv->current_hostname); diff --git a/src/core/nm-hostname-manager.h b/src/core/nm-hostname-manager.h index 0fa13771..ff109e7e 100644 --- a/src/core/nm-hostname-manager.h +++ b/src/core/nm-hostname-manager.h @@ -36,8 +36,6 @@ NMHostnameManager *nm_hostname_manager_get(void); const char *nm_hostname_manager_get_hostname(NMHostnameManager *self); -char *nm_hostname_manager_read_hostname(NMHostnameManager *self); - gboolean nm_hostname_manager_write_hostname(NMHostnameManager *self, const char *hostname); void nm_hostname_manager_set_transient_hostname(NMHostnameManager * self, @@ -47,6 +45,4 @@ void nm_hostname_manager_set_transient_hostname(NMHostnameManager * s gboolean nm_hostname_manager_get_transient_hostname(NMHostnameManager *self, char **hostname); -gboolean nm_hostname_manager_validate_hostname(const char *hostname); - #endif /* __NM_HOSTNAME_MANAGER_H__ */ diff --git a/src/core/nm-iface-helper.c b/src/core/nm-iface-helper.c index 296bf091..83ae1b54 100644 --- a/src/core/nm-iface-helper.c +++ b/src/core/nm-iface-helper.c @@ -5,7 +5,6 @@ #include "src/core/nm-default-daemon.h" -#include #include #include #include @@ -31,7 +30,7 @@ #include "libnm-systemd-core/nm-sd.h" #if !defined(NM_DIST_VERSION) - #define NM_DIST_VERSION VERSION +#define NM_DIST_VERSION VERSION #endif #define NMIH_PID_FILE_FMT NMRUNDIR "/nm-iface-helper-%d.pid" @@ -93,24 +92,29 @@ static struct { /*****************************************************************************/ static void -dhcp4_state_changed(NMDhcpClient *client, - NMDhcpState state, - NMIP4Config * ip4_config, - GHashTable * options, - gpointer user_data) +_dhcp_client_notify_cb(NMDhcpClient * client, + const NMDhcpClientNotifyData *notify_data, + gpointer user_data) { static NMIP4Config *last_config = NULL; NMIP4Config * existing; gs_unref_ptrarray GPtrArray *ip4_dev_route_blacklist = NULL; gs_free_error GError *error = NULL; + NMIP4Config * ip4_config; - g_return_if_fail(!ip4_config || NM_IS_IP4_CONFIG(ip4_config)); + if (!notify_data || notify_data->notify_type != NM_DHCP_CLIENT_NOTIFY_TYPE_STATE_CHANGED) + g_return_if_reached(); - _LOGD(LOGD_DHCP4, "new DHCPv4 client state %d", state); + nm_assert(!notify_data->state_changed.ip_config + || NM_IS_IP4_CONFIG(notify_data->state_changed.ip_config)); - switch (state) { + _LOGD(LOGD_DHCP4, "new DHCPv4 client state %d", (int) notify_data->state_changed.dhcp_state); + + switch (notify_data->state_changed.dhcp_state) { case NM_DHCP_STATE_BOUND: case NM_DHCP_STATE_EXTENDED: + ip4_config = NM_IP4_CONFIG(notify_data->state_changed.ip_config); + g_assert(ip4_config); g_assert(nm_ip4_config_get_ifindex(ip4_config) == gl.ifindex); @@ -177,41 +181,33 @@ ndisc_config_changed(NMNDisc * ndisc, } if (changed & NM_NDISC_CONFIG_ADDRESSES) { - guint8 plen; guint32 ifa_flags; /* Check, whether kernel is recent enough to help user space handling RA. * If it's not supported, we have no ipv6-privacy and must add autoconf * addresses as /128. The reason for the /128 is to prevent the kernel * from adding a prefix route for this address. */ - ifa_flags = 0; - if (nm_platform_kernel_support_get(NM_PLATFORM_KERNEL_SUPPORT_TYPE_EXTENDED_IFA_FLAGS)) { - ifa_flags |= IFA_F_NOPREFIXROUTE; - if (NM_IN_SET(global_opt.tempaddr, - NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, - NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR)) - ifa_flags |= IFA_F_MANAGETEMPADDR; - plen = 64; - } else - plen = 128; + ifa_flags = IFA_F_NOPREFIXROUTE; + if (NM_IN_SET(global_opt.tempaddr, + NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR, + NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR)) + ifa_flags |= IFA_F_MANAGETEMPADDR; nm_ip6_config_reset_addresses_ndisc(ndisc_config, rdata->addresses, rdata->addresses_n, - plen, + 64, ifa_flags); } if (NM_FLAGS_ANY(changed, NM_NDISC_CONFIG_ROUTES | NM_NDISC_CONFIG_GATEWAYS)) { - nm_ip6_config_reset_routes_ndisc( - ndisc_config, - rdata->gateways, - rdata->gateways_n, - rdata->routes, - rdata->routes_n, - RT_TABLE_MAIN, - global_opt.priority_v6, - nm_platform_kernel_support_get(NM_PLATFORM_KERNEL_SUPPORT_TYPE_RTA_PREF)); + nm_ip6_config_reset_routes_ndisc(ndisc_config, + rdata->gateways, + rdata->gateways_n, + rdata->routes, + rdata->routes_n, + RT_TABLE_MAIN, + global_opt.priority_v6); } if (changed & NM_NDISC_CONFIG_DHCP_LEVEL) { @@ -685,8 +681,8 @@ main(int argc, char *argv[]) g_error("failure to start DHCP: %s", error->message); g_signal_connect(dhcp4_client, - NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED, - G_CALLBACK(dhcp4_state_changed), + NM_DHCP_CLIENT_NOTIFY, + G_CALLBACK(_dhcp_client_notify_cb), NULL); } @@ -698,7 +694,9 @@ main(int argc, char *argv[]) guint32 default_ra_timeout; int max_addresses; - nm_platform_link_set_user_ipv6ll_enabled(NM_PLATFORM_GET, gl.ifindex, TRUE); + nm_platform_link_set_inet6_addr_gen_mode(NM_PLATFORM_GET, + gl.ifindex, + NM_IN6_ADDR_GEN_MODE_NONE); if (global_opt.stable_id && (global_opt.stable_id[0] >= '0' && global_opt.stable_id[0] <= '9') @@ -710,12 +708,12 @@ main(int argc, char *argv[]) stable_id = &global_opt.stable_id[2]; } - nm_lndp_ndisc_get_sysctl(NM_PLATFORM_GET, - global_opt.ifname, - &max_addresses, - &router_solicitations, - &router_solicitation_interval, - &default_ra_timeout); + nm_ndisc_get_sysctl(NM_PLATFORM_GET, + global_opt.ifname, + &max_addresses, + &router_solicitations, + &router_solicitation_interval, + &default_ra_timeout); ndisc = nm_lndp_ndisc_new(NM_PLATFORM_GET, gl.ifindex, diff --git a/src/core/nm-ip4-config.c b/src/core/nm-ip4-config.c index 52a8faa7..90398dcc 100644 --- a/src/core/nm-ip4-config.c +++ b/src/core/nm-ip4-config.c @@ -287,27 +287,28 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMIP4Config, PROP_DNS_PRIORITY, ); typedef struct { - bool metered : 1; - bool never_default : 1; - guint32 mtu; - int ifindex; - NMIPConfigSource mtu_source; - int dns_priority; - NMSettingConnectionMdns mdns; - NMSettingConnectionLlmnr llmnr; - GArray * nameservers; - GPtrArray * domains; - GPtrArray * searches; - GPtrArray * dns_options; - GArray * nis; - char * nis_domain; - GArray * wins; - GVariant * address_data_variant; - GVariant * addresses_variant; - GVariant * route_data_variant; - GVariant * routes_variant; - NMDedupMultiIndex * multi_idx; - const NMPObject * best_default_route; + bool metered : 1; + bool never_default : 1; + guint32 mtu; + int ifindex; + NMIPConfigSource mtu_source; + int dns_priority; + NMSettingConnectionMdns mdns; + NMSettingConnectionLlmnr llmnr; + NMSettingConnectionDnsOverTls dns_over_tls; + GArray * nameservers; + GPtrArray * domains; + GPtrArray * searches; + GPtrArray * dns_options; + GArray * nis; + char * nis_domain; + GArray * wins; + GVariant * address_data_variant; + GVariant * addresses_variant; + GVariant * route_data_variant; + GVariant * routes_variant; + NMDedupMultiIndex * multi_idx; + const NMPObject * best_default_route; union { NMIPConfigDedupMultiIdxType idx_ip4_addresses_; NMDedupMultiIdxType idx_ip4_addresses; @@ -408,11 +409,11 @@ _nm_ip_config_best_default_route_find_better(const NMPObject *obj_cur, const NMP NMP_OBJECT_TYPE_IP4_ROUTE, NMP_OBJECT_TYPE_IP6_ROUTE)) || NMP_OBJECT_GET_TYPE(obj_cur) == NMP_OBJECT_GET_TYPE(obj_cmp)); - nm_assert(!obj_cur || nmp_object_ip_route_is_best_defaut_route(obj_cur)); + nm_assert(!obj_cur || nmp_object_ip_route_is_best_default_route(obj_cur)); /* assumes that @obj_cur is already the best default route (or NULL). It checks whether * @obj_cmp is also a default route and returns the best of both. */ - if (obj_cmp && nmp_object_ip_route_is_best_defaut_route(obj_cmp)) { + if (obj_cmp && nmp_object_ip_route_is_best_default_route(obj_cmp)) { guint32 metric_cur, metric_cmp; if (!obj_cur) @@ -747,12 +748,13 @@ nm_ip4_config_commit(const NMIP4Config * self, } void -nm_ip4_config_merge_setting(NMIP4Config * self, - NMSettingIPConfig * setting, - NMSettingConnectionMdns mdns, - NMSettingConnectionLlmnr llmnr, - guint32 route_table, - guint32 route_metric) +nm_ip4_config_merge_setting(NMIP4Config * self, + NMSettingIPConfig * setting, + NMSettingConnectionMdns mdns, + NMSettingConnectionLlmnr llmnr, + NMSettingConnectionDnsOverTls dns_over_tls, + guint32 route_table, + guint32 route_metric) { guint naddresses, nroutes, nnameservers, nsearches; int i, priority; @@ -868,6 +870,7 @@ nm_ip4_config_merge_setting(NMIP4Config * self, nm_ip4_config_mdns_set(self, mdns); nm_ip4_config_llmnr_set(self, llmnr); + nm_ip4_config_dns_over_tls_set(self, dns_over_tls); nm_ip4_config_set_never_default(self, nm_setting_ip_config_get_never_default(setting)); @@ -1112,6 +1115,10 @@ nm_ip4_config_merge(NMIP4Config * dst, /* LLMNR */ nm_ip4_config_llmnr_set(dst, NM_MAX(nm_ip4_config_llmnr_get(src), nm_ip4_config_llmnr_get(dst))); + /* dns_over_tls */ + nm_ip4_config_dns_over_tls_set( + dst, + NM_MAX(nm_ip4_config_dns_over_tls_get(src), nm_ip4_config_dns_over_tls_get(dst))); g_object_thaw_notify(G_OBJECT(dst)); } @@ -1357,6 +1364,10 @@ nm_ip4_config_subtract(NMIP4Config * dst, if (nm_ip4_config_llmnr_get(src) == nm_ip4_config_llmnr_get(dst)) nm_ip4_config_llmnr_set(dst, NM_SETTING_CONNECTION_LLMNR_DEFAULT); + /* dns_over_tls */ + if (nm_ip4_config_dns_over_tls_get(src) == nm_ip4_config_dns_over_tls_get(dst)) + nm_ip4_config_dns_over_tls_set(dst, NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT); + g_object_thaw_notify(G_OBJECT(dst)); } @@ -1466,6 +1477,7 @@ skip_routes: /* ignore WINS */ /* ignore mdns */ /* ignore LLMNR */ + /* ignore dns_over_tls */ if (update_dst) g_object_thaw_notify(G_OBJECT(dst)); @@ -1777,6 +1789,11 @@ nm_ip4_config_replace(NMIP4Config *dst, const NMIP4Config *src, gboolean *releva has_relevant_changes = TRUE; } + if (src_priv->dns_over_tls != dst_priv->dns_over_tls) { + dst_priv->dns_over_tls = src_priv->dns_over_tls; + has_relevant_changes = TRUE; + } + /* DNS priority */ if (src_priv->dns_priority != dst_priv->dns_priority) { nm_ip4_config_set_dns_priority(dst, src_priv->dns_priority); @@ -2333,7 +2350,7 @@ _nm_ip_config_check_and_add_domain(GPtrArray *array, const char *domain) if (domain[len - 1] == '.') domain = copy = g_strndup(domain, len - 1); - if (nm_utils_strv_find_first((char **) array->pdata, array->len, domain) >= 0) { + if (nm_strv_ptrarray_find_first(array, domain) >= 0) { g_free(copy); return FALSE; } @@ -2521,6 +2538,18 @@ nm_ip4_config_llmnr_set(NMIP4Config *self, NMSettingConnectionLlmnr llmnr) NM_IP4_CONFIG_GET_PRIVATE(self)->llmnr = llmnr; } +NMSettingConnectionDnsOverTls +nm_ip4_config_dns_over_tls_get(const NMIP4Config *self) +{ + return NM_IP4_CONFIG_GET_PRIVATE(self)->dns_over_tls; +} + +void +nm_ip4_config_dns_over_tls_set(NMIP4Config *self, NMSettingConnectionDnsOverTls dns_over_tls) +{ + NM_IP4_CONFIG_GET_PRIVATE(self)->dns_over_tls = dns_over_tls; +} + /*****************************************************************************/ NMIPConfigFlags @@ -2901,6 +2930,10 @@ nm_ip4_config_hash(const NMIP4Config *self, GChecksum *sum, gboolean dns_only) if (val != NM_SETTING_CONNECTION_LLMNR_DEFAULT) g_checksum_update(sum, (const guint8 *) &val, sizeof(val)); + val = nm_ip4_config_dns_over_tls_get(self); + if (val != NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT) + g_checksum_update(sum, (const guint8 *) &val, sizeof(val)); + /* FIXME(ip-config-checksum): the DNS priority should be considered relevant * and added into the checksum as well, but this can't be done right now * because in the DNS manager we rely on the fact that an empty @@ -3095,14 +3128,15 @@ nm_ip4_config_init(NMIP4Config *self) nm_ip_config_dedup_multi_idx_type_init((NMIPConfigDedupMultiIdxType *) &priv->idx_ip4_routes, NMP_OBJECT_TYPE_IP4_ROUTE); - priv->mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT; - priv->llmnr = NM_SETTING_CONNECTION_LLMNR_DEFAULT; - priv->nameservers = g_array_new(FALSE, FALSE, sizeof(guint32)); - priv->domains = g_ptr_array_new_with_free_func(g_free); - priv->searches = g_ptr_array_new_with_free_func(g_free); - priv->dns_options = g_ptr_array_new_with_free_func(g_free); - priv->nis = g_array_new(FALSE, TRUE, sizeof(guint32)); - priv->wins = g_array_new(FALSE, TRUE, sizeof(guint32)); + priv->mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT; + priv->llmnr = NM_SETTING_CONNECTION_LLMNR_DEFAULT; + priv->dns_over_tls = NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT; + priv->nameservers = g_array_new(FALSE, FALSE, sizeof(guint32)); + priv->domains = g_ptr_array_new_with_free_func(g_free); + priv->searches = g_ptr_array_new_with_free_func(g_free); + priv->dns_options = g_ptr_array_new_with_free_func(g_free); + priv->nis = g_array_new(FALSE, TRUE, sizeof(guint32)); + priv->wins = g_array_new(FALSE, TRUE, sizeof(guint32)); } NMIP4Config * diff --git a/src/core/nm-ip4-config.h b/src/core/nm-ip4-config.h index fdaa6d46..2eb193b2 100644 --- a/src/core/nm-ip4-config.h +++ b/src/core/nm-ip4-config.h @@ -124,12 +124,13 @@ gboolean nm_ip4_config_commit(const NMIP4Config * self, NMPlatform * platform, NMIPRouteTableSyncMode route_table_sync); -void nm_ip4_config_merge_setting(NMIP4Config * self, - NMSettingIPConfig * setting, - NMSettingConnectionMdns mdns, - NMSettingConnectionLlmnr llmnr, - guint32 route_table, - guint32 route_metric); +void nm_ip4_config_merge_setting(NMIP4Config * self, + NMSettingIPConfig * setting, + NMSettingConnectionMdns mdns, + NMSettingConnectionLlmnr llmnr, + NMSettingConnectionDnsOverTls dns_over_tls, + guint32 route_table, + guint32 route_metric); NMSetting *nm_ip4_config_create_setting(const NMIP4Config *self); void nm_ip4_config_merge(NMIP4Config * dst, @@ -161,6 +162,8 @@ NMSettingConnectionMdns nm_ip4_config_mdns_get(const NMIP4Config *self); void nm_ip4_config_mdns_set(NMIP4Config *self, NMSettingConnectionMdns mdns); NMSettingConnectionLlmnr nm_ip4_config_llmnr_get(const NMIP4Config *self); void nm_ip4_config_llmnr_set(NMIP4Config *self, NMSettingConnectionLlmnr llmnr); +NMSettingConnectionDnsOverTls nm_ip4_config_dns_over_tls_get(const NMIP4Config *self); +void nm_ip4_config_dns_over_tls_set(NMIP4Config *self, NMSettingConnectionDnsOverTls dns_over_tls); void nm_ip4_config_set_config_flags(NMIP4Config *self, NMIPConfigFlags flags, NMIPConfigFlags mask); NMIPConfigFlags nm_ip4_config_get_config_flags(const NMIP4Config *self); @@ -275,7 +278,7 @@ NM_IS_IP_CONFIG_ADDR_FAMILY(gconstpointer config, int addr_family) } #if _NM_CC_SUPPORT_GENERIC - /* _NM_IS_IP_CONFIG() is a bit unusual. If _Generic() is supported, +/* _NM_IS_IP_CONFIG() is a bit unusual. If _Generic() is supported, * it checks whether @config is either NM_IS_IP4_CONFIG() or NM_IS_IP6_CONFIG(), * depending on the pointer type of @config. * @@ -286,10 +289,10 @@ NM_IS_IP_CONFIG_ADDR_FAMILY(gconstpointer config, int addr_family) * NMIP4Config *ptr = nm_ip4_config_new(...); * g_assert (_NM_IS_IP_CONFIG (ptr, ptr)); */ - #define _NM_IS_IP_CONFIG(typeexpr, config) \ - ({ \ - const void *const _config = (config); \ - _Generic ((typeexpr), \ +#define _NM_IS_IP_CONFIG(typeexpr, config) \ + ({ \ + const void *const _config = (config); \ + _Generic ((typeexpr), \ const void *const: (NM_IS_IP4_CONFIG (_config) || NM_IS_IP6_CONFIG (_config)), \ const void * : (NM_IS_IP4_CONFIG (_config) || NM_IS_IP6_CONFIG (_config)), \ void *const: (NM_IS_IP4_CONFIG (_config) || NM_IS_IP6_CONFIG (_config)), \ @@ -306,9 +309,9 @@ NM_IS_IP_CONFIG_ADDR_FAMILY(gconstpointer config, int addr_family) const NMIP6Config * : (NM_IS_IP6_CONFIG (_config)), \ NMIP6Config *const: (NM_IS_IP6_CONFIG (_config)), \ NMIP6Config * : (NM_IS_IP6_CONFIG (_config))); \ - }) + }) #else - #define _NM_IS_IP_CONFIG(typeexpr, config) NM_IS_IP_CONFIG(config) +#define _NM_IS_IP_CONFIG(typeexpr, config) NM_IS_IP_CONFIG(config) #endif #define NM_IP_CONFIG_CAST(config) \ diff --git a/src/core/nm-ip6-config.c b/src/core/nm-ip6-config.c index 65e84737..5ec68bd2 100644 --- a/src/core/nm-ip6-config.c +++ b/src/core/nm-ip6-config.c @@ -1678,8 +1678,7 @@ nm_ip6_config_reset_routes_ndisc(NMIP6Config * self, const NMNDiscRoute * routes, guint routes_n, guint32 route_table, - guint32 route_metric, - gboolean kernel_support_rta_pref) + guint32 route_metric) { NMIP6ConfigPrivate *priv; guint i; @@ -1735,7 +1734,6 @@ nm_ip6_config_reset_routes_ndisc(NMIP6Config * self, .table_coerced = nm_platform_route_table_coerce(route_table), .metric = route_metric, }; - const NMIcmpv6RouterPref first_pref = gateways[0].preference; for (i = 0; i < gateways_n; i++) { r.gateway = gateways[i].address; @@ -1753,13 +1751,6 @@ nm_ip6_config_reset_routes_ndisc(NMIP6Config * self, changed = TRUE; new_best_default_route = _nm_ip_config_best_default_route_find_better(new_best_default_route, obj_new); - - if (first_pref != gateways[i].preference && !kernel_support_rta_pref) { - /* We are unable to configure a router preference. Hence, we skip all gateways - * with a different preference from the first gateway. Note, that the gateways - * are sorted in order of highest to lowest preference. */ - break; - } } } diff --git a/src/core/nm-ip6-config.h b/src/core/nm-ip6-config.h index 8694ab0c..a54040fc 100644 --- a/src/core/nm-ip6-config.h +++ b/src/core/nm-ip6-config.h @@ -198,8 +198,7 @@ void nm_ip6_config_reset_routes_ndisc(NMIP6Config * self, const struct _NMNDiscRoute * routes, guint routes_n, guint32 route_table, - guint32 route_metric, - gboolean kernel_support_rta_pref); + guint32 route_metric); void nm_ip6_config_update_routes_metric(NMIP6Config *self, gint64 metric); diff --git a/src/core/nm-l3-config-data.c b/src/core/nm-l3-config-data.c index f2ec040b..033c8942 100644 --- a/src/core/nm-l3-config-data.c +++ b/src/core/nm-l3-config-data.c @@ -131,6 +131,14 @@ struct _NML3ConfigData { guint32 ndisc_reachable_time_msec_val; guint32 ndisc_retrans_timer_msec_val; + union { + struct { + NMOptionBool never_default_6; + NMOptionBool never_default_4; + }; + NMOptionBool never_default_x[2]; + }; + NMTernary metered : 3; NMTernary proxy_browser_only : 3; @@ -323,7 +331,7 @@ _strv_ptrarray_merge(GPtrArray **p_dst, const GPtrArray *src) const char *s = src->pdata[i]; if (dst_initial_len > 0 - && nm_utils_strv_find_first((char **) ((*p_dst)->pdata), dst_initial_len, s) >= 0) + && nm_strv_find_first((const char *const *) ((*p_dst)->pdata), dst_initial_len, s) >= 0) continue; g_ptr_array_add(*p_dst, g_strdup(s)); @@ -439,27 +447,23 @@ nm_l3_config_data_log(const NML3ConfigData *self, const char *s_prefix = "ndisc: "; if (self->ndisc_hop_limit_set) { - nm_utils_strbuf_append(&p, - &l, - "%shop-limit=%d", - s_prefix, - self->ndisc_hop_limit_val); + nm_strbuf_append(&p, &l, "%shop-limit=%d", s_prefix, self->ndisc_hop_limit_val); s_prefix = ", "; } if (self->ndisc_reachable_time_msec_set) { - nm_utils_strbuf_append(&p, - &l, - "%sreachable-time-msec=%u", - s_prefix, - self->ndisc_reachable_time_msec_val); + nm_strbuf_append(&p, + &l, + "%sreachable-time-msec=%u", + s_prefix, + self->ndisc_reachable_time_msec_val); s_prefix = ", "; } if (self->ndisc_retrans_timer_msec_set) { - nm_utils_strbuf_append(&p, - &l, - "%sretrans-timer-msec=%u", - s_prefix, - self->ndisc_retrans_timer_msec_val); + nm_strbuf_append(&p, + &l, + "%sretrans-timer-msec=%u", + s_prefix, + self->ndisc_retrans_timer_msec_val); s_prefix = ", "; } _L("%s", sbuf); @@ -541,6 +545,9 @@ nm_l3_config_data_log(const NML3ConfigData *self, options[i].value_str); } } + + if (self->never_default_x[IS_IPv4] != NM_OPTION_BOOL_DEFAULT) + _L("never-default: %s", self->never_default_x[IS_IPv4] ? "yes" : "no"); } if (self->mdns != NM_SETTING_CONNECTION_MDNS_DEFAULT) { @@ -643,12 +650,14 @@ _idx_type_init(DedupMultiIdxType *idx_type, NMPObjectType obj_type) } NML3ConfigData * -nm_l3_config_data_new(NMDedupMultiIndex *multi_idx, int ifindex) +nm_l3_config_data_new(NMDedupMultiIndex *multi_idx, int ifindex, NMIPConfigSource source) { NML3ConfigData *self; nm_assert(multi_idx); nm_assert(ifindex > 0); + nm_assert(source == NM_IP_CONFIG_SOURCE_UNKNOWN + || (source >= NM_IP_CONFIG_SOURCE_KERNEL && source <= NM_IP_CONFIG_SOURCE_USER)); self = g_slice_new(NML3ConfigData); *self = (NML3ConfigData){ @@ -663,7 +672,9 @@ nm_l3_config_data_new(NMDedupMultiIndex *multi_idx, int ifindex) .proxy_method = NM_PROXY_CONFIG_METHOD_UNKNOWN, .route_table_sync_4 = NM_IP_ROUTE_TABLE_SYNC_MODE_NONE, .route_table_sync_6 = NM_IP_ROUTE_TABLE_SYNC_MODE_NONE, - .source = NM_IP_CONFIG_SOURCE_UNKNOWN, + .never_default_6 = NM_OPTION_BOOL_DEFAULT, + .never_default_4 = NM_OPTION_BOOL_DEFAULT, + .source = source, .ip6_privacy = NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN, .ndisc_hop_limit_set = FALSE, .ndisc_reachable_time_msec_set = FALSE, @@ -691,17 +702,21 @@ nm_l3_config_data_ref(const NML3ConfigData *self) const NML3ConfigData * nm_l3_config_data_ref_and_seal(const NML3ConfigData *self) { - nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); - ((NML3ConfigData *) self)->is_sealed = TRUE; - ((NML3ConfigData *) self)->ref_count++; + if (self) { + nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); + ((NML3ConfigData *) self)->is_sealed = TRUE; + ((NML3ConfigData *) self)->ref_count++; + } return self; } const NML3ConfigData * nm_l3_config_data_seal(const NML3ConfigData *self) { - nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); - ((NML3ConfigData *) self)->is_sealed = TRUE; + if (self) { + nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); + ((NML3ConfigData *) self)->is_sealed = TRUE; + } return self; } @@ -871,6 +886,26 @@ nm_l3_config_data_lookup_obj(const NML3ConfigData *self, const NMPObject *obj) return nm_dedup_multi_index_lookup_obj(self->multi_idx, idx, obj); } +const NMPlatformIP4Address * +nm_l3_config_data_lookup_address_4(const NML3ConfigData *self, + in_addr_t addr, + guint8 plen, + in_addr_t peer_addr) +{ + const NMDedupMultiEntry *head; + NMPObject obj_stack; + + nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); + + nmp_object_stackinit_id_ip4_address(&obj_stack, self->ifindex, addr, plen, peer_addr); + + head = nm_l3_config_data_lookup_obj(self, &obj_stack); + if (!head) + return NULL; + + return NMP_OBJECT_CAST_IP4_ADDRESS(head->obj); +} + const NMPlatformIP6Address * nm_l3_config_data_lookup_address_6(const NML3ConfigData *self, const struct in6_addr *addr) { @@ -879,7 +914,7 @@ nm_l3_config_data_lookup_address_6(const NML3ConfigData *self, const struct in6_ nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); - /* this works only, because the primary key for a Ipv6 address is the + /* this works only, because the primary key for a IPv6 address is the * ifindex and the "struct in6_addr". */ nmp_object_stackinit_id_ip6_address(&obj_stack, self->ifindex, addr); @@ -1104,6 +1139,14 @@ _l3_config_data_add_obj(NMDedupMultiIndex * multi_idx, obj_new_stackinit.ip_address.addr_source = obj_old->ip_address.addr_source; modified = TRUE; } + + /* OR assume_config_once flag */ + if (obj_new->ip_address.a_assume_config_once + && !obj_old->ip_address.a_assume_config_once) { + obj_new = nmp_object_stackinit_obj(&obj_new_stackinit, obj_new); + obj_new_stackinit.ip_address.a_assume_config_once = TRUE; + modified = TRUE; + } break; case NMP_OBJECT_TYPE_IP4_ROUTE: case NMP_OBJECT_TYPE_IP6_ROUTE: @@ -1113,6 +1156,14 @@ _l3_config_data_add_obj(NMDedupMultiIndex * multi_idx, obj_new_stackinit.ip_route.rt_source = obj_old->ip_route.rt_source; modified = TRUE; } + + /* OR assume_config_once flag */ + if (obj_new->ip_route.r_assume_config_once + && !obj_old->ip_route.r_assume_config_once) { + obj_new = nmp_object_stackinit_obj(&obj_new_stackinit, obj_new); + obj_new_stackinit.ip_route.r_assume_config_once = TRUE; + modified = TRUE; + } break; default: nm_assert_not_reached(); @@ -1168,11 +1219,11 @@ _l3_config_best_default_route_find_better(const NMPObject *obj_cur, const NMPObj NMP_OBJECT_TYPE_IP4_ROUTE, NMP_OBJECT_TYPE_IP6_ROUTE)) || NMP_OBJECT_GET_TYPE(obj_cur) == NMP_OBJECT_GET_TYPE(obj_cmp)); - nm_assert(!obj_cur || nmp_object_ip_route_is_best_defaut_route(obj_cur)); + nm_assert(!obj_cur || nmp_object_ip_route_is_best_default_route(obj_cur)); /* assumes that @obj_cur is already the best default route (or NULL). It checks whether * @obj_cmp is also a default route and returns the best of both. */ - if (obj_cmp && nmp_object_ip_route_is_best_defaut_route(obj_cmp)) { + if (obj_cmp && nmp_object_ip_route_is_best_default_route(obj_cmp)) { guint32 metric_cur, metric_cmp; if (!obj_cur) @@ -1297,9 +1348,16 @@ const NMPObject * nm_l3_config_data_get_best_default_route(const NML3ConfigData *self, int addr_family) { nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); - nm_assert_addr_family(addr_family); - return self->best_default_route_x[NM_IS_IPv4(addr_family)]; + switch (addr_family) { + case AF_INET: + return self->best_default_route_4; + case AF_INET6: + return self->best_default_route_6; + case AF_UNSPEC: + return self->best_default_route_4 ?: self->best_default_route_6; + } + return nm_assert_unreachable_val(NULL); } /*****************************************************************************/ @@ -1336,10 +1394,15 @@ _check_and_add_domain(GPtrArray **p_arr, const char *domain) gconstpointer nm_l3_config_data_get_nameservers(const NML3ConfigData *self, int addr_family, guint *out_len) { - nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); + nm_assert(!self || _NM_IS_L3_CONFIG_DATA(self, TRUE)); nm_assert_addr_family(addr_family); nm_assert(out_len); + if (!self) { + *out_len = 0; + return NULL; + } + return _garray_inaddr_get(self->nameservers_x[NM_IS_IPv4(addr_family)], out_len); } @@ -1372,7 +1435,13 @@ nm_l3_config_data_clear_nameservers(NML3ConfigData *self, int addr_family) const in_addr_t * nm_l3_config_data_get_wins(const NML3ConfigData *self, guint *out_len) { - nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); + nm_assert(!self || _NM_IS_L3_CONFIG_DATA(self, TRUE)); + nm_assert(out_len); + + if (!self) { + *out_len = 0; + return NULL; + } return _garray_inaddr_get(self->wins, out_len); } @@ -1420,10 +1489,15 @@ nm_l3_config_data_set_nis_domain(NML3ConfigData *self, const char *nis_domain) const char *const * nm_l3_config_data_get_domains(const NML3ConfigData *self, int addr_family, guint *out_len) { - nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); + nm_assert(!self || _NM_IS_L3_CONFIG_DATA(self, TRUE)); nm_assert_addr_family(addr_family); nm_assert(out_len); + if (!self) { + *out_len = 0; + return NULL; + } + return nm_strv_ptrarray_get_unsafe(self->domains_x[NM_IS_IPv4(addr_family)], out_len); } @@ -1439,10 +1513,15 @@ nm_l3_config_data_add_domain(NML3ConfigData *self, int addr_family, const char * const char *const * nm_l3_config_data_get_searches(const NML3ConfigData *self, int addr_family, guint *out_len) { - nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); + nm_assert(!self || _NM_IS_L3_CONFIG_DATA(self, TRUE)); nm_assert_addr_family(addr_family); nm_assert(out_len); + if (!self) { + *out_len = 0; + return NULL; + } + return nm_strv_ptrarray_get_unsafe(self->searches_x[NM_IS_IPv4(addr_family)], out_len); } @@ -1492,10 +1571,15 @@ nm_l3_config_data_add_dns_option(NML3ConfigData *self, int addr_family, const ch const char *const * nm_l3_config_data_get_dns_options(const NML3ConfigData *self, int addr_family, guint *out_len) { - nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); + nm_assert(!self || _NM_IS_L3_CONFIG_DATA(self, TRUE)); nm_assert_addr_family(addr_family); nm_assert(out_len); + if (!self) { + *out_len = 0; + return NULL; + } + return nm_strv_ptrarray_get_unsafe(self->dns_options_x[NM_IS_IPv4(addr_family)], out_len); } @@ -1621,6 +1705,29 @@ nm_l3_config_data_set_route_table_sync(NML3ConfigData * self, return TRUE; } +NMTernary +nm_l3_config_data_get_never_default(const NML3ConfigData *self, int addr_family) +{ + nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); + + return NM_TERNARY_FROM_OPTION_BOOL(self->never_default_x[NM_IS_IPv4(addr_family)]); +} + +gboolean +nm_l3_config_data_set_never_default(NML3ConfigData *self, int addr_family, NMTernary never_default) +{ + const int IS_IPv4 = NM_IS_IPv4(addr_family); + const NMOptionBool v = NM_TERNARY_TO_OPTION_BOOL(never_default); + + nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE)); + + if (self->never_default_x[IS_IPv4] == v) + return FALSE; + + self->never_default_x[IS_IPv4] = v; + return TRUE; +} + NMTernary nm_l3_config_data_get_metered(const NML3ConfigData *self) { @@ -1682,22 +1789,13 @@ nm_l3_config_data_set_ip6_mtu(NML3ConfigData *self, guint32 ip6_mtu) return TRUE; } -gboolean -nm_l3_config_data_set_source(NML3ConfigData *self, NMIPConfigSource source) -{ - nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE)); - - if (self->source == source) - return FALSE; - - self->source = source; - return TRUE; -} - NMSettingIP6ConfigPrivacy nm_l3_config_data_get_ip6_privacy(const NML3ConfigData *self) { - nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE)); + nm_assert(!self || _NM_IS_L3_CONFIG_DATA(self, TRUE)); + + if (!self) + return NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN; return self->ip6_privacy; } @@ -1799,7 +1897,7 @@ nm_l3_config_data_set_proxy_pac_script(NML3ConfigData *self, const char *value) gboolean nm_l3_config_data_get_ndisc_hop_limit(const NML3ConfigData *self, int *out_val) { - nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE)); + nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); if (!self->ndisc_hop_limit_set) { NM_SET_OUT(out_val, 0); @@ -1822,7 +1920,7 @@ nm_l3_config_data_set_ndisc_hop_limit(NML3ConfigData *self, int val) gboolean nm_l3_config_data_get_ndisc_reachable_time_msec(const NML3ConfigData *self, guint32 *out_val) { - nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE)); + nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); if (!self->ndisc_reachable_time_msec_set) { NM_SET_OUT(out_val, 0); @@ -1845,7 +1943,7 @@ nm_l3_config_data_set_ndisc_reachable_time_msec(NML3ConfigData *self, guint32 va gboolean nm_l3_config_data_get_ndisc_retrans_timer_msec(const NML3ConfigData *self, guint32 *out_val) { - nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE)); + nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); if (!self->ndisc_retrans_timer_msec_set) { NM_SET_OUT(out_val, 0); @@ -1922,14 +2020,26 @@ nm_l3_config_data_set_dhcp_lease_from_options(NML3ConfigData *self, /*****************************************************************************/ static int -_dedup_multi_index_cmp(const NML3ConfigData *a, const NML3ConfigData *b, NMPObjectType obj_type) +_dedup_multi_index_cmp(const NML3ConfigData *a, + const NML3ConfigData *b, + NMPObjectType obj_type, + gboolean ignore_ifindex) { const NMDedupMultiHeadEntry *h_a = nm_l3_config_data_lookup_objs(a, obj_type); const NMDedupMultiHeadEntry *h_b = nm_l3_config_data_lookup_objs(b, obj_type); NMDedupMultiIter iter_a; NMDedupMultiIter iter_b; + /* We handle ignore_index via NMP_OBJECT_CMP_FLAGS_IGNORE_IFINDEX flag, which is + * only implemented for certain types. */ + nm_assert(NM_IN_SET(obj_type, + NMP_OBJECT_TYPE_IP4_ADDRESS, + NMP_OBJECT_TYPE_IP6_ADDRESS, + NMP_OBJECT_TYPE_IP4_ROUTE, + NMP_OBJECT_TYPE_IP6_ROUTE)); + NM_CMP_SELF(h_a, h_b); + NM_CMP_DIRECT(h_a->len, h_b->len); nm_assert(h_a->len > 0); @@ -1952,7 +2062,10 @@ _dedup_multi_index_cmp(const NML3ConfigData *a, const NML3ConfigData *b, NMPObje have_b = nm_platform_dedup_multi_iter_next_obj(&iter_b, &obj_b, obj_type); nm_assert(have_b); - NM_CMP_RETURN(nmp_object_cmp(obj_a, obj_b)); + NM_CMP_RETURN(nmp_object_cmp_full(obj_a, + obj_b, + ignore_ifindex ? NMP_OBJECT_CMP_FLAGS_IGNORE_IFINDEX + : NMP_OBJECT_CMP_FLAGS_NONE)); } } @@ -1961,25 +2074,30 @@ nm_l3_config_data_cmp_full(const NML3ConfigData *a, const NML3ConfigData *b, NML3ConfigCmpFlags cmp_flags) { - int IS_IPv4; + int IS_IPv4; + gboolean ignore_ifindex; NM_CMP_SELF(a, b); - if (!NM_FLAGS_HAS(cmp_flags, NM_L3_CONFIG_CMP_FLAGS_IGNORE_IFINDEX)) + ignore_ifindex = NM_FLAGS_HAS(cmp_flags, NM_L3_CONFIG_CMP_FLAGS_IGNORE_IFINDEX); + + if (!ignore_ifindex) NM_CMP_DIRECT(a->ifindex, b->ifindex); NM_CMP_DIRECT(a->flags, b->flags); - NM_CMP_RETURN(_dedup_multi_index_cmp(a, b, NMP_OBJECT_TYPE_IP4_ADDRESS)); - NM_CMP_RETURN(_dedup_multi_index_cmp(a, b, NMP_OBJECT_TYPE_IP6_ADDRESS)); - NM_CMP_RETURN(_dedup_multi_index_cmp(a, b, NMP_OBJECT_TYPE_IP4_ROUTE)); - NM_CMP_RETURN(_dedup_multi_index_cmp(a, b, NMP_OBJECT_TYPE_IP6_ROUTE)); + NM_CMP_RETURN(_dedup_multi_index_cmp(a, b, NMP_OBJECT_TYPE_IP4_ADDRESS, ignore_ifindex)); + NM_CMP_RETURN(_dedup_multi_index_cmp(a, b, NMP_OBJECT_TYPE_IP6_ADDRESS, ignore_ifindex)); + NM_CMP_RETURN(_dedup_multi_index_cmp(a, b, NMP_OBJECT_TYPE_IP4_ROUTE, ignore_ifindex)); + NM_CMP_RETURN(_dedup_multi_index_cmp(a, b, NMP_OBJECT_TYPE_IP6_ROUTE, ignore_ifindex)); for (IS_IPv4 = 1; IS_IPv4 >= 0; IS_IPv4--) { const int addr_family = IS_IPv4 ? AF_INET : AF_INET6; - NM_CMP_RETURN( - nmp_object_cmp(a->best_default_route_x[IS_IPv4], b->best_default_route_x[IS_IPv4])); + NM_CMP_RETURN(nmp_object_cmp_full(a->best_default_route_x[IS_IPv4], + b->best_default_route_x[IS_IPv4], + ignore_ifindex ? NMP_OBJECT_CMP_FLAGS_IGNORE_IFINDEX + : NMP_OBJECT_CMP_FLAGS_NONE)); NM_CMP_RETURN( _garray_inaddr_cmp(a->nameservers_x[IS_IPv4], b->nameservers_x[IS_IPv4], addr_family)); @@ -1999,6 +2117,7 @@ nm_l3_config_data_cmp_full(const NML3ConfigData *a, NM_CMP_DIRECT(a->dns_priority_x[IS_IPv4], b->dns_priority_x[IS_IPv4]); NM_CMP_DIRECT(a->route_table_sync_x[IS_IPv4], b->route_table_sync_x[IS_IPv4]); + NM_CMP_DIRECT(a->never_default_x[IS_IPv4], b->never_default_x[IS_IPv4]); } NM_CMP_RETURN(_garray_inaddr_cmp(a->wins, b->wins, AF_INET)); @@ -2066,8 +2185,8 @@ _data_get_direct_route_for_host(const NML3ConfigData *self, NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4)) { const NMPlatformIPXRoute *item = NMP_OBJECT_CAST_IPX_ROUTE(item_obj); - if (nm_ip_addr_is_null(addr_family, - nm_platform_ip_route_get_gateway(addr_family, &item->rx))) + if (!nm_ip_addr_is_null(addr_family, + nm_platform_ip_route_get_gateway(addr_family, &item->rx))) continue; if (best_route && best_route->rx.plen > item->rx.plen) @@ -2114,7 +2233,7 @@ nm_l3_config_data_get_blacklisted_ip4_routes(const NML3ConfigData *self, gboolea const NMPObject * my_addr_obj; NMDedupMultiIter iter; - nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE)); + nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE)); /* For IPv6 slaac, we explicitly add the device-routes (onlink). * As we don't do that for IPv4 and manual IPv6 addresses. Add them here @@ -2125,9 +2244,6 @@ nm_l3_config_data_get_blacklisted_ip4_routes(const NML3ConfigData *self, gboolea in_addr_t network_4; NMPlatformIPXRoute rx; - if (my_addr->external) - continue; - nm_assert(my_addr->plen <= 32); if (my_addr->plen == 0) continue; @@ -2176,120 +2292,137 @@ nm_l3_config_data_get_blacklisted_ip4_routes(const NML3ConfigData *self, gboolea /*****************************************************************************/ void -nm_l3_config_data_add_dependent_routes(NML3ConfigData *self, - int addr_family, - guint32 route_table, - guint32 route_metric, - gboolean is_vrf) +nm_l3_config_data_add_dependent_onlink_routes(NML3ConfigData *self, int addr_family) { - const int IS_IPv4 = NM_IS_IPv4(addr_family); gs_unref_ptrarray GPtrArray *extra_onlink_routes = NULL; - const NMPObject * my_addr_obj; - const NMPObject * my_route_obj; - NMPlatformIPXRoute rx; + const NMPObject * obj_src; NMDedupMultiIter iter; - in_addr_t network_4 = 0; + int IS_IPv4; guint i; + if (addr_family == AF_UNSPEC) { + nm_l3_config_data_add_dependent_onlink_routes(self, AF_INET); + nm_l3_config_data_add_dependent_onlink_routes(self, AF_INET6); + return; + } + + IS_IPv4 = NM_IS_IPv4(addr_family); + nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE)); - nm_assert_addr_family(addr_family); /* For IPv6 slaac, we explicitly add the device-routes (onlink). * As we don't do that for IPv4 and manual IPv6 addresses. Add them here * as dependent routes. */ - if (!IS_IPv4) { - /* Pre-generate multicast route */ - rx.r6 = (NMPlatformIP6Route){ - .ifindex = self->ifindex, - .network.s6_addr[0] = 0xffu, - .plen = 8, - .table_coerced = nm_platform_route_table_coerce(RT_TABLE_LOCAL), - .type_coerced = nm_platform_route_type_coerce(RTN_UNICAST), - .metric = 256, - }; - nm_l3_config_data_add_route(self, addr_family, NULL, &rx.rx); - } + nm_l3_config_data_iter_obj_for_each (&iter, self, &obj_src, NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4)) { + const NMPlatformIPXRoute *route_src = NMP_OBJECT_CAST_IPX_ROUTE(obj_src); + NMPObject * new_route; + NMPlatformIPXRoute * new_r; + const NMIPAddr * p_gateway; - nm_l3_config_data_iter_obj_for_each (&iter, - self, - &my_addr_obj, - NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4)) { - const NMPlatformIPXAddress *const my_addr = NMP_OBJECT_CAST_IPX_ADDRESS(my_addr_obj); + p_gateway = nm_platform_ip_route_get_gateway(addr_family, &route_src->rx); + + if (nm_ip_addr_is_null(addr_family, p_gateway)) + continue; - if (my_addr->ax.external) + if (_data_get_direct_route_for_host( + self, + addr_family, + p_gateway, + nm_platform_route_table_uncoerce(route_src->rx.table_coerced, TRUE))) continue; + new_route = nmp_object_clone(obj_src, FALSE); + new_r = NMP_OBJECT_CAST_IPX_ROUTE(new_route); if (IS_IPv4) { - nm_assert(my_addr->a4.plen <= 32); - if (my_addr->a4.plen == 0) - continue; + new_r->r4.network = route_src->r4.gateway; + new_r->r4.plen = 32; + new_r->r4.gateway = 0; + } else { + new_r->r6.network = route_src->r6.gateway; + new_r->r6.plen = 128; + new_r->r6.gateway = in6addr_any; } - if (IS_IPv4) { - rx.r4 = (NMPlatformIP4Route){ - .ifindex = self->ifindex, - .rt_source = NM_IP_CONFIG_SOURCE_KERNEL, - .network = my_addr->a4.address, - .plen = 32, - .pref_src = my_addr->a4.address, - .type_coerced = nm_platform_route_type_coerce(RTN_LOCAL), - .scope_inv = nm_platform_route_scope_inv(RT_SCOPE_HOST), - .table_coerced = - nm_platform_route_table_coerce(is_vrf ? route_table : RT_TABLE_LOCAL), - }; - } else { - rx.r6 = (NMPlatformIP6Route){ - .ifindex = self->ifindex, - .network = my_addr->a6.address, - .plen = 128, - .type_coerced = nm_platform_route_type_coerce(RTN_LOCAL), - .metric = 0, - .table_coerced = - nm_platform_route_table_coerce(is_vrf ? route_table : RT_TABLE_LOCAL), - }; + /* we cannot add the route right away, because that invalidates the iteration. */ + if (!extra_onlink_routes) + extra_onlink_routes = g_ptr_array_new_with_free_func((GDestroyNotify) nmp_object_unref); + g_ptr_array_add(extra_onlink_routes, new_route); + } + if (extra_onlink_routes) { + for (i = 0; i < extra_onlink_routes->len; i++) { + nm_l3_config_data_add_route_full(self, + addr_family, + extra_onlink_routes->pdata[i], + NULL, + NM_L3_CONFIG_ADD_FLAGS_EXCLUSIVE, + NULL, + NULL); } - nm_l3_config_data_add_route(self, addr_family, NULL, &rx.rx); + } +} - if (my_addr->ax.plen == 0) +void +nm_l3_config_data_add_dependent_device_routes(NML3ConfigData * self, + int addr_family, + guint32 route_table, + guint32 route_metric, + const NML3ConfigData *source) +{ + const int IS_IPv4 = NM_IS_IPv4(addr_family); + const NMPObject * obj_src; + NMPlatformIPXRoute rx; + NMDedupMultiIter iter; + + nm_assert_addr_family(addr_family); + nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE)); + nm_assert(_NM_IS_L3_CONFIG_DATA(source, TRUE)); + nm_assert(self != source); + + /* For IPv6 slaac, we explicitly add the device-routes (onlink) and track them + * as regular routes in NML3ConfigData. + * + * For IPv4 and for manual IPv6 addresses we don't do that. Instead, add those + * routes automatically afterwards. + * + * As route-table/metric is associated with the source l3cd, we need to process + * all source l3cds separately. */ + + nm_l3_config_data_iter_obj_for_each (&iter, + source, + &obj_src, + NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4)) { + const NMPlatformIPXAddress *const addr_src = NMP_OBJECT_CAST_IPX_ADDRESS(obj_src); + const NMPlatformIPXAddress * addr_dst; + + addr_dst = NMP_OBJECT_CAST_IPX_ADDRESS( + nm_dedup_multi_entry_get_obj(nm_l3_config_data_lookup_obj(self, obj_src))); + if (!addr_dst) continue; if (IS_IPv4) { - network_4 = - nm_utils_ip4_address_clear_host_address(my_addr->a4.peer_address, my_addr->a4.plen); + NMPlatformIPXRoute r_stack; + const NMPlatformIPRoute *r; - if (nm_utils_ip4_address_is_zeronet(network_4)) { - /* Kernel doesn't add device-routes for destinations that - * start with 0.x.y.z. Skip them. */ + if (addr_dst->a4.a_acd_not_ready) continue; - } - if (my_addr->a4.plen == 32 && my_addr->a4.address == my_addr->a4.peer_address) { - /* Kernel doesn't add device-routes for /32 addresses unless - * they have a peer. */ - continue; - } + r = (NMPlatformIPRoute *) nm_platform_ip4_address_generate_device_route(&addr_src->a4, + self->ifindex, + route_table, + route_metric, + &r_stack.r4); + if (r) + nm_l3_config_data_add_route(self, addr_family, NULL, r); } else { - if (NM_FLAGS_HAS(my_addr->a6.n_ifa_flags, IFA_F_NOPREFIXROUTE)) + const gboolean has_peer = !IN6_IS_ADDR_UNSPECIFIED(&addr_src->a6.peer_address); + int routes_i; + + if (addr_src->ax.plen == 0) continue; - } - if (IS_IPv4) { - rx.r4 = (NMPlatformIP4Route){ - .ifindex = self->ifindex, - .rt_source = NM_IP_CONFIG_SOURCE_KERNEL, - .network = network_4, - .plen = my_addr->a4.plen, - .pref_src = my_addr->a4.address, - .table_coerced = nm_platform_route_table_coerce(route_table), - .metric = route_metric, - .scope_inv = nm_platform_route_scope_inv(NM_RT_SCOPE_LINK), - }; - nm_platform_ip_route_normalize(addr_family, &rx.rx); - nm_l3_config_data_add_route(self, addr_family, NULL, &rx.rx); - } else { - const gboolean has_peer = !IN6_IS_ADDR_UNSPECIFIED(&my_addr->a6.peer_address); - int routes_i; + if (NM_FLAGS_HAS(addr_src->a6.n_ifa_flags, IFA_F_NOPREFIXROUTE)) + continue; /* If we have an IPv6 peer, we add two /128 routes * (unless, both addresses are identical). */ @@ -2299,20 +2432,20 @@ nm_l3_config_data_add_dependent_routes(NML3ConfigData *self, guint8 plen; if (routes_i == 1 && has_peer - && IN6_ARE_ADDR_EQUAL(&my_addr->a6.address, &my_addr->a6.peer_address)) + && IN6_ARE_ADDR_EQUAL(&addr_src->a6.address, &addr_src->a6.peer_address)) break; if (has_peer) { if (routes_i == 0) - a6 = &my_addr->a6.address; + a6 = &addr_src->a6.address; else - a6 = &my_addr->a6.peer_address; + a6 = &addr_src->a6.peer_address; plen = 128; } else { a6 = nm_utils_ip6_address_clear_host_address(&a6_stack, - &my_addr->a6.address, - my_addr->a6.plen); - plen = my_addr->a6.plen; + &addr_src->a6.address, + addr_src->a6.plen); + plen = addr_src->a6.plen; } rx.r6 = (NMPlatformIP6Route){ @@ -2328,73 +2461,16 @@ nm_l3_config_data_add_dependent_routes(NML3ConfigData *self, } } } - - nm_l3_config_data_iter_obj_for_each (&iter, - self, - &my_route_obj, - NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4)) { - const NMPlatformIPXRoute *my_route = NMP_OBJECT_CAST_IPX_ROUTE(my_route_obj); - NMPObject * new_route; - NMPlatformIPXRoute * new_r; - const NMIPAddr * p_gateway; - - if (!NM_PLATFORM_IP_ROUTE_IS_DEFAULT(my_route) - || NM_IS_IP_CONFIG_SOURCE_RTPROT(my_route->rx.rt_source)) - continue; - - p_gateway = nm_platform_ip_route_get_gateway(addr_family, &my_route->rx); - - if (nm_ip_addr_is_null(addr_family, p_gateway)) - continue; - - if (_data_get_direct_route_for_host( - self, - addr_family, - p_gateway, - nm_platform_route_table_uncoerce(my_route->rx.table_coerced, TRUE))) - continue; - - new_route = nmp_object_clone(my_route_obj, FALSE); - new_r = NMP_OBJECT_CAST_IPX_ROUTE(new_route); - if (IS_IPv4) { - new_r->r4.network = my_route->r4.gateway; - new_r->r4.plen = 32; - new_r->r4.gateway = 0; - } else { - new_r->r6.network = my_route->r6.gateway; - new_r->r6.plen = 128; - new_r->r6.gateway = in6addr_any; - } - - /* we cannot add the route right away, because that invalidates the iteration. */ - if (!extra_onlink_routes) - extra_onlink_routes = g_ptr_array_new_with_free_func((GDestroyNotify) nmp_object_unref); - g_ptr_array_add(extra_onlink_routes, new_route); - } - if (extra_onlink_routes) { - for (i = 0; i < extra_onlink_routes->len; i++) { - nm_l3_config_data_add_route_full(self, - addr_family, - extra_onlink_routes->pdata[i], - NULL, - NM_L3_CONFIG_ADD_FLAGS_EXCLUSIVE, - NULL, - NULL); - } - } } /*****************************************************************************/ static void -_init_from_connection_ip(NML3ConfigData *self, - int addr_family, - NMConnection * connection, - guint32 route_table, - guint32 route_metric) +_init_from_connection_ip(NML3ConfigData *self, int addr_family, NMConnection *connection) { const int IS_IPv4 = NM_IS_IPv4(addr_family); NMSettingIPConfig *s_ip; + gboolean never_default; guint naddresses; guint nroutes; guint nnameservers; @@ -2415,25 +2491,28 @@ _init_from_connection_ip(NML3ConfigData *self, if (!s_ip) return; - if (!nm_setting_ip_config_get_never_default(s_ip) - && (gateway_str = nm_setting_ip_config_get_gateway(s_ip)) + never_default = nm_setting_ip_config_get_never_default(s_ip); + + nm_l3_config_data_set_never_default(self, addr_family, !!never_default); + + if (!never_default && (gateway_str = nm_setting_ip_config_get_gateway(s_ip)) && inet_pton(addr_family, gateway_str, &gateway_bin) == 1 && !nm_ip_addr_is_null(addr_family, &gateway_bin)) { NMPlatformIPXRoute r; if (IS_IPv4) { r.r4 = (NMPlatformIP4Route){ - .rt_source = NM_IP_CONFIG_SOURCE_USER, - .gateway = gateway_bin.addr4, - .table_coerced = nm_platform_route_table_coerce(route_table), - .metric = route_metric, + .rt_source = NM_IP_CONFIG_SOURCE_USER, + .gateway = gateway_bin.addr4, + .table_any = TRUE, + .metric_any = TRUE, }; } else { r.r6 = (NMPlatformIP6Route){ - .rt_source = NM_IP_CONFIG_SOURCE_USER, - .gateway = gateway_bin.addr6, - .table_coerced = nm_platform_route_table_coerce(route_table), - .metric = route_metric, + .rt_source = NM_IP_CONFIG_SOURCE_USER, + .gateway = gateway_bin.addr6, + .table_any = TRUE, + .metric_any = TRUE, }; } @@ -2488,6 +2567,7 @@ _init_from_connection_ip(NML3ConfigData *self, NMIPAddr next_hop_bin; gint64 metric64; guint32 metric; + gboolean metric_any; guint plen; nm_assert(nm_ip_route_get_family(s_route) == addr_family); @@ -2496,11 +2576,14 @@ _init_from_connection_ip(NML3ConfigData *self, nm_ip_route_get_next_hop_binary(s_route, &next_hop_bin); metric64 = nm_ip_route_get_metric(s_route); - if (metric64 < 0) - metric = route_metric; - else - metric = metric64; - metric = nm_utils_ip_route_metric_normalize(addr_family, metric); + if (metric64 < 0) { + metric_any = TRUE; + metric = 0; + } else { + metric_any = FALSE; + metric = metric64; + metric = nm_utils_ip_route_metric_normalize(addr_family, metric); + } plen = nm_ip_route_get_prefix(s_route); @@ -2508,25 +2591,27 @@ _init_from_connection_ip(NML3ConfigData *self, if (IS_IPv4) { r.r4 = (NMPlatformIP4Route){ - .network = network_bin.addr4, - .plen = nm_ip_route_get_prefix(s_route), - .gateway = next_hop_bin.addr4, - .metric = metric, - .rt_source = NM_IP_CONFIG_SOURCE_USER, + .network = network_bin.addr4, + .plen = nm_ip_route_get_prefix(s_route), + .gateway = next_hop_bin.addr4, + .metric_any = metric_any, + .metric = metric, + .rt_source = NM_IP_CONFIG_SOURCE_USER, }; nm_assert(r.r4.plen <= 32); } else { r.r6 = (NMPlatformIP6Route){ - .network = network_bin.addr6, - .plen = nm_ip_route_get_prefix(s_route), - .gateway = next_hop_bin.addr6, - .metric = metric, - .rt_source = NM_IP_CONFIG_SOURCE_USER, + .network = network_bin.addr6, + .plen = nm_ip_route_get_prefix(s_route), + .gateway = next_hop_bin.addr6, + .metric_any = metric_any, + .metric = metric, + .rt_source = NM_IP_CONFIG_SOURCE_USER, }; nm_assert(r.r6.plen <= 128); } - nm_utils_ip_route_attribute_to_platform(addr_family, s_route, &r.rx, route_table); + nm_utils_ip_route_attribute_to_platform(addr_family, s_route, &r.rx, -1); nm_l3_config_data_add_route(self, addr_family, NULL, &r.rx); } @@ -2550,34 +2635,36 @@ _init_from_connection_ip(NML3ConfigData *self, } idx = 0; - while ((idx = nm_setting_ip_config_next_valid_dns_option(s_ip, i)) >= 0) { + while ((idx = nm_setting_ip_config_next_valid_dns_option(s_ip, idx)) >= 0) { nm_l3_config_data_add_dns_option(self, addr_family, - nm_setting_ip_config_get_dns_option(s_ip, i)); + nm_setting_ip_config_get_dns_option(s_ip, idx)); idx++; } nm_l3_config_data_set_dns_priority(self, addr_family, nm_setting_ip_config_get_dns_priority(s_ip)); + + if (!IS_IPv4) { + nm_l3_config_data_set_ip6_privacy( + self, + nm_setting_ip6_config_get_ip6_privacy(NM_SETTING_IP6_CONFIG(s_ip))); + } } NML3ConfigData * nm_l3_config_data_new_from_connection(NMDedupMultiIndex *multi_idx, int ifindex, - NMConnection * connection, - guint32 route_table_4, - guint32 route_table_6, - guint32 route_metric_4, - guint32 route_metric_6) + NMConnection * connection) { NML3ConfigData *self; NMSettingProxy *s_proxy; - self = nm_l3_config_data_new(multi_idx, ifindex); + self = nm_l3_config_data_new(multi_idx, ifindex, NM_IP_CONFIG_SOURCE_USER); - _init_from_connection_ip(self, AF_INET, connection, route_table_4, route_metric_4); - _init_from_connection_ip(self, AF_INET6, connection, route_table_6, route_metric_6); + _init_from_connection_ip(self, AF_INET, connection); + _init_from_connection_ip(self, AF_INET6, connection); s_proxy = _nm_connection_get_setting(connection, NM_TYPE_SETTING_PROXY); if (s_proxy) { @@ -2693,7 +2780,7 @@ nm_l3_config_data_new_from_platform(NMDedupMultiIndex * multi_idx, if (nm_platform_link_get_master(platform, ifindex) > 0) return NULL; - self = nm_l3_config_data_new(multi_idx, ifindex); + self = nm_l3_config_data_new(multi_idx, ifindex, NM_IP_CONFIG_SOURCE_KERNEL); _init_from_platform(self, AF_INET, platform, ipv6_privacy_rfc4941); _init_from_platform(self, AF_INET6, platform, ipv6_privacy_rfc4941); @@ -2710,13 +2797,16 @@ nm_l3_config_data_merge(NML3ConfigData * self, const guint32 * default_route_table_x /* length 2, for IS_IPv4 */, const guint32 * default_route_metric_x /* length 2, for IS_IPv4 */, const guint32 * default_route_penalty_x /* length 2, for IS_IPv4 */, - NML3ConfigMergeHookAddObj hook_add_addr, + const int * default_dns_priority_x /* length 2, for IS_IPv4 */, + NML3ConfigMergeHookAddObj hook_add_obj, gpointer hook_user_data) { static const guint32 x_default_route_table_x[2] = {RT_TABLE_MAIN, RT_TABLE_MAIN}; static const guint32 x_default_route_metric_x[2] = {NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6, NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP4}; static const guint32 x_default_route_penalty_x[2] = {0, 0}; + static const int x_default_dns_priority_x[2] = {NM_DNS_PRIORITY_DEFAULT_NORMAL, + NM_DNS_PRIORITY_DEFAULT_NORMAL}; NMDedupMultiIter iter; const NMPObject * obj; int IS_IPv4; @@ -2730,6 +2820,8 @@ nm_l3_config_data_merge(NML3ConfigData * self, default_route_metric_x = x_default_route_metric_x; if (!default_route_penalty_x) default_route_penalty_x = x_default_route_penalty_x; + if (!default_dns_priority_x) + default_dns_priority_x = x_default_dns_priority_x; nm_assert(default_route_table_x[0] != 0); nm_assert(default_route_table_x[1] != 0); @@ -2747,51 +2839,100 @@ nm_l3_config_data_merge(NML3ConfigData * self, src, &obj, NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4)) { - NMPlatformIPXAddress addr_stack; - const NMPlatformIPAddress *addr = NULL; - NMTernary ip4acd_not_ready = NM_TERNARY_DEFAULT; + const NMPlatformIPAddress *a_src = NMP_OBJECT_CAST_IP_ADDRESS(obj); + NMPlatformIPXAddress a; + NML3ConfigMergeHookResult hook_result = { + .ip4acd_not_ready = NM_OPTION_BOOL_DEFAULT, + .assume_config_once = NM_OPTION_BOOL_DEFAULT, + }; + +#define _ensure_a() \ + G_STMT_START \ + { \ + if (a_src != &a.ax) { \ + if (IS_IPv4) \ + a.a4 = *NMP_OBJECT_CAST_IP4_ADDRESS(obj); \ + else \ + a.a6 = *NMP_OBJECT_CAST_IP6_ADDRESS(obj); \ + a_src = &a.ax; \ + } \ + } \ + G_STMT_END - if (hook_add_addr && !hook_add_addr(src, obj, &ip4acd_not_ready, hook_user_data)) + if (hook_add_obj && !hook_add_obj(src, obj, &hook_result, hook_user_data)) continue; - if (IS_IPv4 && ip4acd_not_ready != NM_TERNARY_DEFAULT - && (!!ip4acd_not_ready) != NMP_OBJECT_CAST_IP4_ADDRESS(obj)->ip4acd_not_ready) { - addr_stack.a4 = *NMP_OBJECT_CAST_IP4_ADDRESS(obj); - addr_stack.a4.ip4acd_not_ready = (!!ip4acd_not_ready); - addr = &addr_stack.ax; - } else - nm_assert(IS_IPv4 || ip4acd_not_ready == NM_TERNARY_DEFAULT); + nm_assert(IS_IPv4 || hook_result.ip4acd_not_ready == NM_OPTION_BOOL_DEFAULT); + + if (a_src->ifindex != self->ifindex) { + _ensure_a(); + a.ax.ifindex = self->ifindex; + } + + if (hook_result.ip4acd_not_ready != NM_OPTION_BOOL_DEFAULT && IS_IPv4 + && (!!hook_result.ip4acd_not_ready) + != ((const NMPlatformIP4Address *) a_src)->a_acd_not_ready) { + _ensure_a(); + a.a4.a_acd_not_ready = (!!hook_result.ip4acd_not_ready); + } + + if (hook_result.assume_config_once != NM_OPTION_BOOL_DEFAULT + && (!!hook_result.assume_config_once) != a_src->a_assume_config_once) { + _ensure_a(); + a.ax.a_assume_config_once = (!!hook_result.assume_config_once); + } nm_l3_config_data_add_address_full(self, addr_family, - addr ? NULL : obj, - addr, + a_src == &a.ax ? NULL : obj, + a_src == &a.ax ? a_src : NULL, NM_L3_CONFIG_ADD_FLAGS_EXCLUSIVE, NULL); } +#undef _ensure_a + if (!NM_FLAGS_HAS(merge_flags, NM_L3_CONFIG_MERGE_FLAGS_NO_ROUTES)) { nm_l3_config_data_iter_obj_for_each (&iter, src, &obj, NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4)) { - const NMPlatformIPRoute *r_src = NMP_OBJECT_CAST_IP_ROUTE(obj); - NMPlatformIPXRoute r; + const NMPlatformIPRoute * r_src = NMP_OBJECT_CAST_IP_ROUTE(obj); + NMPlatformIPXRoute r; + NML3ConfigMergeHookResult hook_result = { + .ip4acd_not_ready = NM_OPTION_BOOL_DEFAULT, + .assume_config_once = NM_OPTION_BOOL_DEFAULT, + }; #define _ensure_r() \ G_STMT_START \ { \ if (r_src != &r.rx) { \ - r_src = &r.rx; \ if (IS_IPv4) \ r.r4 = *NMP_OBJECT_CAST_IP4_ROUTE(obj); \ else \ r.r6 = *NMP_OBJECT_CAST_IP6_ROUTE(obj); \ - r.rx.ifindex = self->ifindex; \ + r_src = &r.rx; \ } \ } \ G_STMT_END + if (hook_add_obj && !hook_add_obj(src, obj, &hook_result, hook_user_data)) + continue; + + nm_assert(hook_result.ip4acd_not_ready == NM_OPTION_BOOL_DEFAULT); + + if (r_src->ifindex != self->ifindex) { + _ensure_r(); + r.rx.ifindex = self->ifindex; + } + + if (hook_result.assume_config_once != NM_OPTION_BOOL_DEFAULT + && (!!hook_result.assume_config_once) != r_src->r_assume_config_once) { + _ensure_r(); + r.rx.r_assume_config_once = (!!hook_result.assume_config_once); + } + if (!NM_FLAGS_HAS(merge_flags, NM_L3_CONFIG_MERGE_FLAGS_CLONE)) { if (r_src->table_any) { _ensure_r(); @@ -2848,12 +2989,20 @@ nm_l3_config_data_merge(NML3ConfigData * self, if (!NM_FLAGS_ANY(self->flags, has_dns_priority_flag) && NM_FLAGS_ANY(src->flags, has_dns_priority_flag)) { - self->dns_priority_x[IS_IPv4] = src->dns_priority_x[IS_IPv4]; + int p = src->dns_priority_x[IS_IPv4]; + + if (p == 0 && !NM_FLAGS_HAS(merge_flags, NM_L3_CONFIG_MERGE_FLAGS_CLONE)) + p = default_dns_priority_x[IS_IPv4]; + + self->dns_priority_x[IS_IPv4] = p; self->flags |= has_dns_priority_flag; } if (self->route_table_sync_x[IS_IPv4] == NM_IP_ROUTE_TABLE_SYNC_MODE_NONE) self->route_table_sync_x[IS_IPv4] = src->route_table_sync_x[IS_IPv4]; + + if (self->never_default_x[IS_IPv4] == NM_OPTION_BOOL_DEFAULT) + self->never_default_x[IS_IPv4] = src->never_default_x[IS_IPv4]; } if (!NM_FLAGS_HAS(merge_flags, NM_L3_CONFIG_MERGE_FLAGS_NO_DNS)) { @@ -2933,7 +3082,7 @@ nm_l3_config_data_new_clone(const NML3ConfigData *src, int ifindex) if (ifindex <= 0) ifindex = src->ifindex; - self = nm_l3_config_data_new(src->multi_idx, ifindex); + self = nm_l3_config_data_new(src->multi_idx, ifindex, src->source); nm_l3_config_data_merge(self, src, NM_L3_CONFIG_MERGE_FLAGS_CLONE, @@ -2941,9 +3090,15 @@ nm_l3_config_data_new_clone(const NML3ConfigData *src, int ifindex) NULL, NULL, NULL, + NULL, NULL); - nm_assert(nm_l3_config_data_cmp_full(src, self, NM_L3_CONFIG_CMP_FLAGS_IGNORE_IFINDEX) == 0); + nm_assert(nm_l3_config_data_cmp_full(src, + self, + src->ifindex != ifindex + ? NM_L3_CONFIG_CMP_FLAGS_IGNORE_IFINDEX + : NM_L3_CONFIG_CMP_FLAGS_NONE) + == 0); nm_assert(nm_l3_config_data_get_ifindex(self) == ifindex); return self; diff --git a/src/core/nm-l3-config-data.h b/src/core/nm-l3-config-data.h index 9bed47e0..1ad23c32 100644 --- a/src/core/nm-l3-config-data.h +++ b/src/core/nm-l3-config-data.h @@ -52,15 +52,6 @@ typedef enum { /** * NML3ConfigMergeFlags: * @NM_L3_CONFIG_MERGE_FLAGS_NONE: no flags set - * @NM_L3_CONFIG_MERGE_FLAGS_ONLY_FOR_ACD: if this merge flag is set, - * the the NML3ConfigData doesn't get merged and it's information won't be - * synced. The only purpose is to run ACD on its IPv4 addresses, but - * regardless whether ACD succeeds/fails, the IP addresses won't be configured. - * The point is to run ACD first (without configuring it), and only - * commit the settings if requested. That can either happen by - * nm_l3cfg_add_config() the same NML3Cfg again (with a different - * tag), or by calling nm_l3cfg_add_config() again with this flag - * cleared (and the same tag). * @NM_L3_CONFIG_MERGE_FLAGS_NO_ROUTES: don't merge routes * @NM_L3_CONFIG_MERGE_FLAGS_NO_DEFAULT_ROUTES: don't merge default routes. * Note that if the respective NML3ConfigData has NM_L3_CONFIG_DAT_FLAGS_IGNORE_MERGE_NO_DEFAULT_ROUTES @@ -71,18 +62,18 @@ typedef enum { */ typedef enum _nm_packed { NM_L3_CONFIG_MERGE_FLAGS_NONE = 0, - NM_L3_CONFIG_MERGE_FLAGS_ONLY_FOR_ACD = (1LL << 0), - NM_L3_CONFIG_MERGE_FLAGS_NO_ROUTES = (1LL << 1), - NM_L3_CONFIG_MERGE_FLAGS_NO_DEFAULT_ROUTES = (1LL << 2), - NM_L3_CONFIG_MERGE_FLAGS_NO_DNS = (1LL << 3), - NM_L3_CONFIG_MERGE_FLAGS_CLONE = (1LL << 4), + NM_L3_CONFIG_MERGE_FLAGS_NO_ROUTES = (1LL << 0), + NM_L3_CONFIG_MERGE_FLAGS_NO_DEFAULT_ROUTES = (1LL << 1), + NM_L3_CONFIG_MERGE_FLAGS_NO_DNS = (1LL << 2), + NM_L3_CONFIG_MERGE_FLAGS_CLONE = (1LL << 3), } NML3ConfigMergeFlags; /*****************************************************************************/ static inline gboolean NM_IS_L3_CONFIG_DATA(const NML3ConfigData *self); -NML3ConfigData * nm_l3_config_data_new(NMDedupMultiIndex *multi_idx, int ifindex); +NML3ConfigData * +nm_l3_config_data_new(NMDedupMultiIndex *multi_idx, int ifindex, NMIPConfigSource source); const NML3ConfigData *nm_l3_config_data_ref(const NML3ConfigData *self); const NML3ConfigData *nm_l3_config_data_ref_and_seal(const NML3ConfigData *self); const NML3ConfigData *nm_l3_config_data_seal(const NML3ConfigData *self); @@ -137,21 +128,22 @@ NML3ConfigData *nm_l3_config_data_new_clone(const NML3ConfigData *src, int ifind NML3ConfigData *nm_l3_config_data_new_from_connection(NMDedupMultiIndex *multi_idx, int ifindex, - NMConnection * connection, - guint32 route_table_4, - guint32 route_table_6, - guint32 route_metric_4, - guint32 route_metric_6); + NMConnection * connection); NML3ConfigData *nm_l3_config_data_new_from_platform(NMDedupMultiIndex * multi_idx, int ifindex, NMPlatform * platform, NMSettingIP6ConfigPrivacy ipv6_privacy_rfc4941); -typedef gboolean (*NML3ConfigMergeHookAddObj)(const NML3ConfigData *l3cd, - const NMPObject * obj, - NMTernary * out_ip4acd_not_ready, - gpointer user_data); +typedef struct { + NMOptionBool ip4acd_not_ready; + NMOptionBool assume_config_once; +} NML3ConfigMergeHookResult; + +typedef gboolean (*NML3ConfigMergeHookAddObj)(const NML3ConfigData * l3cd, + const NMPObject * obj, + NML3ConfigMergeHookResult *result, + gpointer user_data); void nm_l3_config_data_merge(NML3ConfigData * self, const NML3ConfigData *src, @@ -159,17 +151,20 @@ void nm_l3_config_data_merge(NML3ConfigData * self, const guint32 *default_route_table_x /* length 2, for IS_IPv4 */, const guint32 *default_route_metric_x /* length 2, for IS_IPv4 */, const guint32 *default_route_penalty_x /* length 2, for IS_IPv4 */, - NML3ConfigMergeHookAddObj hook_add_addr, + const int * default_dns_priority_x /* length 2, for IS_IPv4 */, + NML3ConfigMergeHookAddObj hook_add_obj, gpointer hook_user_data); GPtrArray *nm_l3_config_data_get_blacklisted_ip4_routes(const NML3ConfigData *self, gboolean is_vrf); -void nm_l3_config_data_add_dependent_routes(NML3ConfigData *self, - int addr_family, - guint32 route_table, - guint32 route_metric, - gboolean is_vrf); +void nm_l3_config_data_add_dependent_onlink_routes(NML3ConfigData *self, int addr_family); + +void nm_l3_config_data_add_dependent_device_routes(NML3ConfigData * self, + int addr_family, + guint32 route_table, + guint32 route_metric, + const NML3ConfigData *source); /*****************************************************************************/ @@ -192,7 +187,7 @@ NM_IS_L3_CONFIG_DATA(const NML3ConfigData *self) * * Additionally, also call nm_l3_config_data_get_ifindex(), which does more * checks during nm_assert(). */ - nm_assert(nm_l3_config_data_get_ifindex(self) > 0); + nm_assert(!self || nm_l3_config_data_get_ifindex(self) > 0); return !!self; } @@ -229,6 +224,11 @@ const NMDedupMultiIdxType *nm_l3_config_data_lookup_index(const NML3ConfigData * const NMDedupMultiEntry *nm_l3_config_data_lookup_obj(const NML3ConfigData *self, const NMPObject * obj); +const NMPlatformIP4Address *nm_l3_config_data_lookup_address_4(const NML3ConfigData *self, + in_addr_t addr, + guint8 plen, + in_addr_t peer_addr); + const NMPlatformIP6Address *nm_l3_config_data_lookup_address_6(const NML3ConfigData * self, const struct in6_addr *addr); @@ -363,8 +363,6 @@ nm_l3_config_data_unset_flags(NML3ConfigData *self, NML3ConfigDatFlags flags) /*****************************************************************************/ -gboolean nm_l3_config_data_set_source(NML3ConfigData *self, NMIPConfigSource source); - const NMPObject *nm_l3_config_data_get_first_obj(const NML3ConfigData *self, NMPObjectType obj_type, gboolean (*predicate)(const NMPObject *obj)); @@ -455,6 +453,11 @@ gboolean nm_l3_config_data_set_route_table_sync(NML3ConfigData * self, int addr_family, NMIPRouteTableSyncMode route_table_sync); +NMTernary nm_l3_config_data_get_never_default(const NML3ConfigData *self, int addr_family); + +gboolean +nm_l3_config_data_set_never_default(NML3ConfigData *self, int addr_family, NMTernary never_default); + NMTernary nm_l3_config_data_get_metered(const NML3ConfigData *self); gboolean nm_l3_config_data_set_metered(NML3ConfigData *self, NMTernary metered); @@ -509,6 +512,17 @@ nm_l3_config_data_get_dns_options(const NML3ConfigData *self, int addr_family, g gboolean nm_l3_config_data_get_dns_priority(const NML3ConfigData *self, int addr_family, int *out_prio); +static inline int +nm_l3_config_data_get_dns_priority_or_default(const NML3ConfigData *self, int addr_family) +{ + int v; + + nm_assert_addr_family(addr_family); + if (!self || !nm_l3_config_data_get_dns_priority(self, addr_family, &v)) + return 0; + return v; +} + gboolean nm_l3_config_data_set_dns_priority(NML3ConfigData *self, int addr_family, int dns_priority); diff --git a/src/core/nm-l3-ipv4ll.c b/src/core/nm-l3-ipv4ll.c index 28ceb39e..eb9ceb9b 100644 --- a/src/core/nm-l3-ipv4ll.c +++ b/src/core/nm-l3-ipv4ll.c @@ -317,51 +317,32 @@ _acd_info_is_good(const NML3AcdAddrInfo *acd_info) /*****************************************************************************/ -static NMPlatformIP4Address * -_l3cd_config_plat_init_addr(NMPlatformIP4Address *a, int ifindex, in_addr_t addr) -{ - nm_assert(nm_utils_ip4_address_is_link_local(addr)); - - *a = (NMPlatformIP4Address){ - .ifindex = ifindex, - .address = addr, - .peer_address = addr, - .plen = ADDR_IPV4LL_PREFIX_LEN, - .addr_source = NM_IP_CONFIG_SOURCE_IP4LL, - }; - return a; -} - -static NMPlatformIP4Route * -_l3cd_config_plat_init_route(NMPlatformIP4Route *r, int ifindex) -{ - *r = (NMPlatformIP4Route){ - .ifindex = ifindex, - .network = htonl(0xE0000000u), - .plen = 4, - .rt_source = NM_IP_CONFIG_SOURCE_IP4LL, - .table_any = TRUE, - .metric_any = TRUE, - }; - return r; -} - static const NML3ConfigData * _l3cd_config_create(int ifindex, in_addr_t addr, NMDedupMultiIndex *multi_idx) { nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; - NMPlatformIP4Address a; - NMPlatformIP4Route r; nm_assert(nm_utils_ip4_address_is_link_local(addr)); nm_assert(ifindex > 0); nm_assert(multi_idx); - l3cd = nm_l3_config_data_new(multi_idx, ifindex); - nm_l3_config_data_set_source(l3cd, NM_IP_CONFIG_SOURCE_IP4LL); + l3cd = nm_l3_config_data_new(multi_idx, ifindex, NM_IP_CONFIG_SOURCE_IP4LL); + + nm_l3_config_data_add_address_4( + l3cd, + NM_PLATFORM_IP4_ADDRESS_INIT(.ifindex = ifindex, + .address = addr, + .peer_address = addr, + .plen = ADDR_IPV4LL_PREFIX_LEN, + .addr_source = NM_IP_CONFIG_SOURCE_IP4LL)); - nm_l3_config_data_add_address_4(l3cd, _l3cd_config_plat_init_addr(&a, ifindex, addr)); - nm_l3_config_data_add_route_4(l3cd, _l3cd_config_plat_init_route(&r, ifindex)); + nm_l3_config_data_add_route_4(l3cd, + NM_PLATFORM_IP4_ROUTE_INIT(.ifindex = ifindex, + .network = htonl(0xE0000000u), + .plen = 4, + .rt_source = NM_IP_CONFIG_SOURCE_IP4LL, + .table_any = TRUE, + .metric_any = TRUE)); return nm_l3_config_data_seal(g_steal_pointer(&l3cd)); } @@ -610,15 +591,19 @@ _l3cd_config_add(NML3IPv4LL *self) NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6, 0, 0, + NM_DNS_PRIORITY_DEFAULT_NORMAL, + NM_DNS_PRIORITY_DEFAULT_NORMAL, NM_L3_ACD_DEFEND_TYPE_ONCE, self->reg_timeout_msec, - NM_L3_CONFIG_MERGE_FLAGS_ONLY_FOR_ACD)) + NM_L3CFG_CONFIG_FLAGS_ONLY_FOR_ACD, + NM_L3_CONFIG_MERGE_FLAGS_NONE)) nm_assert_not_reached(); self->l3cfg_commit_handle = nm_l3cfg_commit_type_register(self->l3cfg, NM_L3_CFG_COMMIT_TYPE_ASSUME, - self->l3cfg_commit_handle); - nm_l3cfg_commit_on_idle_schedule(self->l3cfg); + self->l3cfg_commit_handle, + "ipv4ll"); + nm_l3cfg_commit_on_idle_schedule(self->l3cfg, NM_L3_CFG_COMMIT_TYPE_AUTO); } static gboolean @@ -640,7 +625,7 @@ _l3cd_config_remove(NML3IPv4LL *self) nm_assert_not_reached(); nm_l3cfg_commit_type_unregister(self->l3cfg, g_steal_pointer(&self->l3cfg_commit_handle)); - nm_l3cfg_commit_on_idle_schedule(self->l3cfg); + nm_l3cfg_commit_on_idle_schedule(self->l3cfg, NM_L3_CFG_COMMIT_TYPE_AUTO); return TRUE; } @@ -1044,7 +1029,7 @@ nm_l3_ipv4ll_unref(NML3IPv4LL *self) nm_assert_not_reached(); nm_l3cfg_commit_type_unregister(self->l3cfg, g_steal_pointer(&self->l3cfg_commit_handle)); - nm_l3cfg_commit_on_idle_schedule(self->l3cfg); + nm_l3cfg_commit_on_idle_schedule(self->l3cfg, NM_L3_CFG_COMMIT_TYPE_AUTO); } else nm_assert(!self->l3cfg_commit_handle); diff --git a/src/core/nm-l3-ipv6ll.c b/src/core/nm-l3-ipv6ll.c new file mode 100644 index 00000000..14387321 --- /dev/null +++ b/src/core/nm-l3-ipv6ll.c @@ -0,0 +1,717 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include "src/core/nm-default-daemon.h" + +#include "nm-l3-ipv6ll.h" + +#include + +#include "nm-core-utils.h" + +/*****************************************************************************/ + +/* FIXME(l3cfg): ensure that NML3IPv6LL generates the same stable privacy addresses + * as previous implementation. */ + +/*****************************************************************************/ + +NM_UTILS_LOOKUP_STR_DEFINE(nm_l3_ipv6ll_state_to_string, + NML3IPv6LLState, + NM_UTILS_LOOKUP_DEFAULT_NM_ASSERT("???"), + NM_UTILS_LOOKUP_STR_ITEM(NM_L3_IPV6LL_STATE_NONE, "none"), + NM_UTILS_LOOKUP_STR_ITEM(NM_L3_IPV6LL_STATE_DEFUNCT, "defunct"), + NM_UTILS_LOOKUP_STR_ITEM(NM_L3_IPV6LL_STATE_STARTING, "starting"), + NM_UTILS_LOOKUP_STR_ITEM(NM_L3_IPV6LL_STATE_DAD_IN_PROGRESS, + "dad-in-progress"), + NM_UTILS_LOOKUP_STR_ITEM(NM_L3_IPV6LL_STATE_READY, "ready"), + NM_UTILS_LOOKUP_STR_ITEM(NM_L3_IPV6LL_STATE_DAD_FAILED, "dad-failed"), ); + +/*****************************************************************************/ + +struct _NML3IPv6LL { + NML3Cfg * l3cfg; + NML3CfgCommitTypeHandle *l3cfg_commit_handle; + NML3IPv6LLNotifyFcn notify_fcn; + gpointer user_data; + GSource * starting_on_idle_source; + GSource * wait_for_addr_source; + GSource * emit_changed_idle_source; + gulong l3cfg_signal_notify_id; + NML3IPv6LLState state; + + /* if we have cur_lladdr set, then this might cache the last + * matching NMPObject from the platform cache. This only serves + * for optimizing the lookup to the platform cache. */ + const NMPlatformIP6Address *cur_lladdr_obj; + + struct in6_addr cur_lladdr; + + /* if we have cur_lladdr and _state_has_lladdr() indicates that + * the LL address is suitable, this is a NML3ConfigData instance + * with the configuration. */ + const NML3ConfigData *l3cd; + + /* "assume" means that we first look whether there is any suitable + * IPv6 address on the device, and in that case, try to use that + * instead of generating a new one. Otherwise, we always try to + * generate a new LL address. */ + bool assume : 1; + + struct { + NMUtilsStableType stable_type; + guint32 dad_counter; + struct { + const char *ifname; + const char *network_id; + } stable_privacy; + struct { + NMUtilsIPv6IfaceId iid; + } token; + } addrgen; +}; + +/*****************************************************************************/ + +#define _NMLOG_DOMAIN LOGD_IP6 +#define _NMLOG_PREFIX_NAME "ipv6ll" +#define _NMLOG(level, ...) \ + G_STMT_START \ + { \ + nm_log((level), \ + (_NMLOG_DOMAIN), \ + NULL, \ + NULL, \ + _NMLOG_PREFIX_NAME "[" NM_HASH_OBFUSCATE_PTR_FMT \ + ",ifindex=%d]: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ + NM_HASH_OBFUSCATE_PTR(self), \ + nm_l3cfg_get_ifindex((self)->l3cfg) _NM_UTILS_MACRO_REST(__VA_ARGS__)); \ + } \ + G_STMT_END + +/*****************************************************************************/ + +#define L3CD_TAG(self) (&(self)->notify_fcn) + +/*****************************************************************************/ + +#define _ASSERT(self) \ + G_STMT_START \ + { \ + NML3IPv6LL *const _self = (self); \ + \ + nm_assert(NM_IS_L3_IPV6LL(_self)); \ + } \ + G_STMT_END + +/*****************************************************************************/ + +static void _check(NML3IPv6LL *self); + +/*****************************************************************************/ + +NML3Cfg * +nm_l3_ipv6ll_get_l3cfg(NML3IPv6LL *self) +{ + nm_assert(NM_IS_L3_IPV6LL(self)); + + return self->l3cfg; +} + +int +nm_l3_ipv6ll_get_ifindex(NML3IPv6LL *self) +{ + nm_assert(NM_IS_L3_IPV6LL(self)); + + return nm_l3cfg_get_ifindex(self->l3cfg); +} + +NMPlatform * +nm_l3_ipv6ll_get_platform(NML3IPv6LL *self) +{ + nm_assert(NM_IS_L3_IPV6LL(self)); + + return nm_l3cfg_get_platform(self->l3cfg); +} + +/*****************************************************************************/ + +static gboolean +_state_has_lladdr(NML3IPv6LLState state) +{ + return NM_IN_SET(state, NM_L3_IPV6LL_STATE_DAD_IN_PROGRESS, NM_L3_IPV6LL_STATE_READY); +} + +NML3IPv6LLState +nm_l3_ipv6ll_get_state(NML3IPv6LL *self, const struct in6_addr **out_lladdr) +{ + nm_assert(NM_IS_L3_IPV6LL(self)); + + NM_SET_OUT(out_lladdr, _state_has_lladdr(self->state) ? &self->cur_lladdr : NULL); + return self->state; +} + +static const NML3ConfigData * +_l3cd_config_create(int ifindex, const struct in6_addr *lladdr, NMDedupMultiIndex *multi_idx) +{ + NML3ConfigData *l3cd; + + nm_assert(ifindex > 0); + nm_assert(lladdr); + nm_assert(IN6_IS_ADDR_LINKLOCAL(lladdr)); + + l3cd = nm_l3_config_data_new(multi_idx, ifindex, NM_IP_CONFIG_SOURCE_IP6LL); + + nm_l3_config_data_add_address_6( + l3cd, + NM_PLATFORM_IP6_ADDRESS_INIT(.address = *lladdr, + .plen = 64, + .addr_source = NM_IP_CONFIG_SOURCE_IP6LL)); + + nm_l3_config_data_add_route_6( + l3cd, + NM_PLATFORM_IP6_ROUTE_INIT(.network.s6_addr16[0] = htons(0xfe80u), + .plen = 64, + .metric_any = TRUE, + .table_any = TRUE, + .rt_source = NM_IP_CONFIG_SOURCE_IP6LL)); + + return nm_l3_config_data_seal(l3cd); +} + +const NML3ConfigData * +nm_l3_ipv6ll_get_l3cd(NML3IPv6LL *self) +{ + nm_assert(NM_IS_L3_IPV6LL(self)); + + if (!_state_has_lladdr(self->state)) { + nm_assert(!self->l3cd); + return NULL; + } + + if (!self->l3cd) { + self->l3cd = _l3cd_config_create(nm_l3_ipv6ll_get_ifindex(self), + &self->cur_lladdr, + nm_l3cfg_get_multi_idx(self->l3cfg)); + } + + return self->l3cd; +} + +/*****************************************************************************/ + +static gboolean +_emit_changed_on_idle_cb(gpointer user_data) +{ + NML3IPv6LL * self = user_data; + const struct in6_addr *lladdr; + NML3IPv6LLState state; + char sbuf[INET6_ADDRSTRLEN]; + + nm_clear_g_source_inst(&self->emit_changed_idle_source); + + state = nm_l3_ipv6ll_get_state(self, &lladdr); + + _LOGT("emit changed signal (state=%s%s%s)", + nm_l3_ipv6ll_state_to_string(state), + lladdr ? ", " : "", + lladdr ? _nm_utils_inet6_ntop(lladdr, sbuf) : ""); + + self->notify_fcn(self, state, lladdr, self->user_data); + + return G_SOURCE_CONTINUE; +} + +/*****************************************************************************/ + +static gboolean +_generate_new_address(NML3IPv6LL *self, struct in6_addr *out_lladdr) +{ + struct in6_addr lladdr; + + memset(&lladdr, 0, sizeof(struct in6_addr)); + lladdr.s6_addr16[0] = htons(0xfe80u); + + if (self->addrgen.stable_type == NM_UTILS_STABLE_TYPE_NONE) { + if (self->addrgen.dad_counter > 0) + return FALSE; + self->addrgen.dad_counter++; + nm_utils_ipv6_addr_set_interface_identifier(&lladdr, &self->addrgen.token.iid); + } else { + /* RFC7217 says we MUST limit the number of retries, and it SHOULD try + * at least IDGEN_RETRIES times (that is, 3 times). + * + * 3 times seems really low. Instead, let's try 6 times. */ + G_STATIC_ASSERT(NM_STABLE_PRIVACY_RFC7217_IDGEN_RETRIES == 3); + if (self->addrgen.dad_counter >= NM_STABLE_PRIVACY_RFC7217_IDGEN_RETRIES + 3) + return FALSE; + + nm_utils_ipv6_addr_set_stable_privacy(self->addrgen.stable_type, + &lladdr, + self->addrgen.stable_privacy.ifname, + self->addrgen.stable_privacy.network_id, + self->addrgen.dad_counter++); + } + + *out_lladdr = lladdr; + return TRUE; +} + +/*****************************************************************************/ + +static gboolean +_pladdr_is_ll_failed(const NMPlatformIP6Address *addr) +{ + nm_assert(addr); + nm_assert(IN6_IS_ADDR_LINKLOCAL(&addr->address)); + + return NM_FLAGS_ANY(addr->n_ifa_flags, IFA_F_DADFAILED | IFA_F_DEPRECATED); +} + +static gboolean +_pladdr_is_ll_tentative(const NMPlatformIP6Address *addr) +{ + nm_assert(addr); + nm_assert(IN6_IS_ADDR_LINKLOCAL(&addr->address)); + nm_assert(!_pladdr_is_ll_failed(addr)); + + return NM_FLAGS_HAS(addr->n_ifa_flags, IFA_F_TENTATIVE) + && !NM_FLAGS_HAS(addr->n_ifa_flags, IFA_F_OPTIMISTIC); +} + +static const NMPlatformIP6Address * +_pladdr_find_ll(NML3IPv6LL *self, gboolean *out_cur_addr_failed) +{ + NMDedupMultiIter iter; + NMPLookup lookup; + const NMPlatformIP6Address *pladdr1 = NULL; + const NMPObject * obj; + const NMPlatformIP6Address *pladdr_ready = NULL; + const NMPlatformIP6Address *pladdr_tentative = NULL; + gboolean cur_addr_check = TRUE; + gboolean cur_addr_failed = FALSE; + gboolean pladdr1_looked_up = FALSE; + + nm_assert(!self->cur_lladdr_obj + || IN6_ARE_ADDR_EQUAL(&self->cur_lladdr, &self->cur_lladdr_obj->address)); + + *out_cur_addr_failed = FALSE; + + if (self->state == NM_L3_IPV6LL_STATE_READY && self->cur_lladdr_obj) { + nm_assert(!_pladdr_is_ll_tentative(self->cur_lladdr_obj)); + pladdr1 = NMP_OBJECT_CAST_IP6_ADDRESS( + nm_platform_lookup_obj(nm_l3_ipv6ll_get_platform(self), + NMP_CACHE_ID_TYPE_OBJECT_TYPE, + NMP_OBJECT_UP_CAST(self->cur_lladdr_obj))); + if (self->cur_lladdr_obj == pladdr1) { + /* Fast-path. We are ready and the cur_lladdr_obj is still in the cache. We + * got the result with a dictionary lookup without need to iterate over + * all addresses. */ + return self->cur_lladdr_obj; + } + pladdr1_looked_up = TRUE; + } + + if (!self->assume) { + /* We don't accept any suitable LL address, only he one we are waiting for. + * Let's do a dictionary lookup. */ + + if (IN6_IS_ADDR_LINKLOCAL(&self->cur_lladdr)) { + if (!pladdr1_looked_up) { + NMPObject needle; + + nmp_object_stackinit_id_ip6_address(&needle, + nm_l3_ipv6ll_get_ifindex(self), + &self->cur_lladdr); + pladdr1 = NMP_OBJECT_CAST_IP6_ADDRESS( + nm_platform_lookup_obj(nm_l3_ipv6ll_get_platform(self), + NMP_CACHE_ID_TYPE_OBJECT_TYPE, + &needle)); + } + if (pladdr1) { + if (!_pladdr_is_ll_failed(pladdr1)) + return pladdr1; + *out_cur_addr_failed = TRUE; + } + } else + nm_assert(!pladdr1_looked_up); + + return NULL; + } + + if (!NM_IN_SET(self->state, NM_L3_IPV6LL_STATE_DAD_IN_PROGRESS, NM_L3_IPV6LL_STATE_READY)) + cur_addr_check = FALSE; + + nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP6_ADDRESS, nm_l3_ipv6ll_get_ifindex(self)); + + nm_platform_iter_obj_for_each (&iter, nm_l3_ipv6ll_get_platform(self), &lookup, &obj) { + const NMPlatformIP6Address *pladdr = NMP_OBJECT_CAST_IP6_ADDRESS(obj); + + if (!IN6_IS_ADDR_LINKLOCAL(&pladdr->address)) + continue; + + if (_pladdr_is_ll_failed(pladdr)) { + if (cur_addr_check && IN6_ARE_ADDR_EQUAL(&self->cur_lladdr, &pladdr->address)) { + /* "pladdr" is the address we are currently doing DAD for. But it failed. + * We need to recognize and report to the caller, to stop waiting for this + * address. */ + cur_addr_failed = TRUE; + cur_addr_check = FALSE; + } + continue; + } + + if (_pladdr_is_ll_tentative(pladdr)) { + if (!pladdr_tentative) + pladdr_tentative = pladdr; + else if (pladdr == self->cur_lladdr_obj) + pladdr_tentative = pladdr; + else if (IN6_ARE_ADDR_EQUAL(&self->cur_lladdr, &pladdr->address)) + pladdr_tentative = pladdr; + continue; + } + + if (pladdr == self->cur_lladdr_obj) { + /* it doesn't get any better. We have our best address. */ + return pladdr; + } + if (!pladdr_ready) + pladdr_ready = pladdr; + else if (IN6_ARE_ADDR_EQUAL(&self->cur_lladdr, &pladdr->address)) + pladdr_ready = pladdr; + } + + *out_cur_addr_failed = cur_addr_failed; + return pladdr_ready ?: pladdr_tentative; +} + +/*****************************************************************************/ + +static void +_lladdr_handle_changed(NML3IPv6LL *self) +{ + const NML3ConfigData *l3cd; + gboolean changed = FALSE; + + /* We register the l3cd with l3cfg to start DAD. That is different from + * NML3IPv4LL, where we use NM_L3_CONFIG_MERGE_FLAGS_ONLY_FOR_ACD. The difference + * is that for IPv6 we let kernel do DAD, so we need to actually configure the + * address. For IPv4, we can run ACD without configuring anything in kernel, + * and let the user decide how to proceed. + * + * Also in this case, we use the most graceful commit-type (NM_L3_CFG_COMMIT_TYPE_ASSUME), + * but for that to work, we also need NM_L3CFG_CONFIG_FLAGS_ASSUME_CONFIG_ONCE flag. */ + + l3cd = nm_l3_ipv6ll_get_l3cd(self); + + if (l3cd) { + if (nm_l3cfg_add_config(self->l3cfg, + L3CD_TAG(self), + TRUE, + l3cd, + NM_L3CFG_CONFIG_PRIORITY_IPV6LL, + 0, + 0, + NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP4, + NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6, + 0, + 0, + NM_DNS_PRIORITY_DEFAULT_NORMAL, + NM_DNS_PRIORITY_DEFAULT_NORMAL, + NM_L3_ACD_DEFEND_TYPE_ALWAYS, + 0, + NM_L3CFG_CONFIG_FLAGS_ASSUME_CONFIG_ONCE, + NM_L3_CONFIG_MERGE_FLAGS_NONE)) + changed = TRUE; + } else { + if (nm_l3cfg_remove_config_all(self->l3cfg, L3CD_TAG(self))) + changed = TRUE; + } + + self->l3cfg_commit_handle = nm_l3cfg_commit_type_register(self->l3cfg, + l3cd ? NM_L3_CFG_COMMIT_TYPE_ASSUME + : NM_L3_CFG_COMMIT_TYPE_NONE, + self->l3cfg_commit_handle, + "ipv6ll"); + + if (changed) + nm_l3cfg_commit_on_idle_schedule(self->l3cfg, NM_L3_CFG_COMMIT_TYPE_AUTO); + + if (!self->emit_changed_idle_source) { + _LOGT("schedule changed signal on idle"); + self->emit_changed_idle_source = nm_g_idle_add_source(_emit_changed_on_idle_cb, self); + } +} + +/*****************************************************************************/ + +static gboolean +_set_cur_lladdr(NML3IPv6LL *self, NML3IPv6LLState state, const struct in6_addr *lladdr) +{ + gboolean changed = FALSE; + + if (lladdr) { + nm_assert(IN6_IS_ADDR_LINKLOCAL(lladdr)); + if (!IN6_ARE_ADDR_EQUAL(&self->cur_lladdr, lladdr)) { + self->cur_lladdr = *lladdr; + nm_clear_l3cd(&self->l3cd); + changed = TRUE; + } + } else { + if (!nm_ip_addr_is_null(AF_INET6, &self->cur_lladdr)) { + nm_clear_l3cd(&self->l3cd); + self->cur_lladdr = nm_ip_addr_zero.addr6; + changed = TRUE; + } + nm_assert(!self->l3cd); + nm_assert(!_state_has_lladdr(state)); + } + + if (self->state != state) { + if (!_state_has_lladdr(state)) + nm_clear_l3cd(&self->l3cd); + self->state = state; + changed = TRUE; + } + + return changed; +} + +static gboolean +_set_cur_lladdr_obj(NML3IPv6LL *self, NML3IPv6LLState state, const NMPlatformIP6Address *lladdr_obj) +{ + nm_assert(lladdr_obj); + nm_assert(_state_has_lladdr(state)); + + nmp_object_ref_set_up_cast(&self->cur_lladdr_obj, lladdr_obj); + return _set_cur_lladdr(self, state, &lladdr_obj->address); +} + +static gboolean +_set_cur_lladdr_bin(NML3IPv6LL *self, NML3IPv6LLState state, const struct in6_addr *lladdr) +{ + nmp_object_ref_set_up_cast(&self->cur_lladdr_obj, NULL); + return _set_cur_lladdr(self, state, lladdr); +} + +static gboolean +_wait_for_addr_timeout_cb(gpointer user_data) +{ + NML3IPv6LL *self = user_data; + + nm_clear_g_source_inst(&self->wait_for_addr_source); + + nm_assert( + NM_IN_SET(self->state, NM_L3_IPV6LL_STATE_DAD_FAILED, NM_L3_IPV6LL_STATE_DAD_IN_PROGRESS)); + + _check(self); + + return G_SOURCE_CONTINUE; +} + +static void +_check(NML3IPv6LL *self) +{ + const NMPlatformIP6Address *pladdr; + char sbuf[INET6_ADDRSTRLEN]; + gboolean cur_addr_failed; + struct in6_addr lladdr; + + pladdr = _pladdr_find_ll(self, &cur_addr_failed); + + if (pladdr) { + nm_clear_g_source_inst(&self->wait_for_addr_source); + + if (_pladdr_is_ll_tentative(pladdr)) { + if (_set_cur_lladdr_obj(self, NM_L3_IPV6LL_STATE_DAD_IN_PROGRESS, pladdr)) { + _LOGT("changed: waiting for address %s to complete DAD", + _nm_utils_inet6_ntop(&self->cur_lladdr, sbuf)); + _lladdr_handle_changed(self); + } + return; + } + + if (_set_cur_lladdr_obj(self, NM_L3_IPV6LL_STATE_READY, pladdr)) { + _LOGT("changed: address %s is ready", _nm_utils_inet6_ntop(&self->cur_lladdr, sbuf)); + _lladdr_handle_changed(self); + } + return; + } + + if (self->cur_lladdr_obj || cur_addr_failed) { + /* we were doing DAD, but the address is no longer a suitable candidate. + * Prematurely abort DAD to generate a new address below. */ + nm_assert( + NM_IN_SET(self->state, NM_L3_IPV6LL_STATE_DAD_IN_PROGRESS, NM_L3_IPV6LL_STATE_READY)); + if (self->state == NM_L3_IPV6LL_STATE_DAD_IN_PROGRESS) + _LOGT("changed: address %s did not complete DAD", + _nm_utils_inet6_ntop(&self->cur_lladdr, sbuf)); + else { + _LOGT("changed: address %s is gone", _nm_utils_inet6_ntop(&self->cur_lladdr, sbuf)); + } + + /* reset the state here, so that we are sure that the following + * _set_cur_lladdr_bin() calls (below) will notice the change + * and trigger a _lladdr_handle_changed(). */ + _set_cur_lladdr_bin(self, NM_L3_IPV6LL_STATE_STARTING, NULL); + nm_clear_g_source_inst(&self->wait_for_addr_source); + } else if (self->wait_for_addr_source) { + /* we are waiting. Nothing to do for now. */ + return; + } + + if (!_generate_new_address(self, &lladdr)) { + /* our DAD counter expired. We reset it, and start a timer to retry + * and recover. */ + self->addrgen.dad_counter = 0; + self->wait_for_addr_source = + nm_g_timeout_add_source(10000, _wait_for_addr_timeout_cb, self); + if (_set_cur_lladdr_bin(self, NM_L3_IPV6LL_STATE_DAD_FAILED, NULL)) { + _LOGW("changed: no IPv6 link local address to retry after Duplicate Address Detection " + "failures (back off)"); + _lladdr_handle_changed(self); + } + return; + } + + /* we give NML3Cfg 2 seconds to configure the address on the interface. We + * thus very soon expect to see this address configured (and kernel started DAD). + * If that does not happen within timeout, we assume that this address failed DAD. */ + self->wait_for_addr_source = nm_g_timeout_add_source(2000, _wait_for_addr_timeout_cb, self); + if (_set_cur_lladdr_bin(self, NM_L3_IPV6LL_STATE_DAD_IN_PROGRESS, &lladdr)) { + _LOGT("changed: starting DAD for address %s", + _nm_utils_inet6_ntop(&self->cur_lladdr, sbuf)); + _lladdr_handle_changed(self); + } + return; +} + +/*****************************************************************************/ + +static void +_l3cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, NML3IPv6LL *self) +{ + if (notify_data->notify_type == NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE_ON_IDLE) { + if (NM_FLAGS_ANY(notify_data->platform_change_on_idle.obj_type_flags, + nmp_object_type_to_flags(NMP_OBJECT_TYPE_IP6_ADDRESS))) + _check(self); + return; + } +} + +/*****************************************************************************/ + +static gboolean +_starting_on_idle_cb(gpointer user_data) +{ + NML3IPv6LL *self = user_data; + + nm_clear_g_source_inst(&self->starting_on_idle_source); + + self->l3cfg_signal_notify_id = + g_signal_connect(self->l3cfg, NM_L3CFG_SIGNAL_NOTIFY, G_CALLBACK(_l3cfg_notify_cb), self); + + _check(self); + + return G_SOURCE_CONTINUE; +} + +/*****************************************************************************/ + +NML3IPv6LL * +_nm_l3_ipv6ll_new(NML3Cfg * l3cfg, + gboolean assume, + NMUtilsStableType stable_type, + const char * ifname, + const char * network_id, + const NMUtilsIPv6IfaceId *token_iid, + NML3IPv6LLNotifyFcn notify_fcn, + gpointer user_data) +{ + NML3IPv6LL *self; + + g_return_val_if_fail(NM_IS_L3CFG(l3cfg), NULL); + g_return_val_if_fail(notify_fcn, NULL); + g_return_val_if_fail( + (stable_type == NM_UTILS_STABLE_TYPE_NONE && !ifname && !network_id && token_iid) + || (stable_type != NM_UTILS_STABLE_TYPE_NONE && ifname && network_id && !token_iid), + NULL); + + self = g_slice_new(NML3IPv6LL); + *self = (NML3IPv6LL){ + .l3cfg = g_object_ref(l3cfg), + .notify_fcn = notify_fcn, + .user_data = user_data, + .state = NM_L3_IPV6LL_STATE_STARTING, + .starting_on_idle_source = nm_g_idle_add_source(_starting_on_idle_cb, self), + .l3cfg_signal_notify_id = 0, + .cur_lladdr_obj = NULL, + .cur_lladdr = IN6ADDR_ANY_INIT, + .assume = assume, + .addrgen = + { + .stable_type = stable_type, + .dad_counter = 0, + }, + }; + + if (self->addrgen.stable_type == NM_UTILS_STABLE_TYPE_NONE) { + char sbuf_token[sizeof(self->addrgen.token.iid) * 3]; + + self->addrgen.token.iid = *token_iid; + _LOGT("created: l3cfg=" NM_HASH_OBFUSCATE_PTR_FMT ", ifindex=%d, token=%s%s", + NM_HASH_OBFUSCATE_PTR(l3cfg), + nm_l3cfg_get_ifindex(l3cfg), + nm_utils_bin2hexstr_full(&self->addrgen.token.iid, + sizeof(self->addrgen.token.iid), + ':', + FALSE, + sbuf_token), + self->assume ? ", assume" : ""); + } else { + self->addrgen.stable_privacy.ifname = g_strdup(ifname); + self->addrgen.stable_privacy.network_id = g_strdup(network_id); + _LOGT("created: l3cfg=" NM_HASH_OBFUSCATE_PTR_FMT + ", ifindex=%d, stable-type=%u, ifname=%s, network_id=%s%s", + NM_HASH_OBFUSCATE_PTR(l3cfg), + nm_l3cfg_get_ifindex(l3cfg), + (unsigned) self->addrgen.stable_type, + self->addrgen.stable_privacy.ifname, + self->addrgen.stable_privacy.network_id, + self->assume ? ", assume" : ""); + } + + return self; +} + +void +nm_l3_ipv6ll_destroy(NML3IPv6LL *self) +{ + if (!self) + return; + + _ASSERT(self); + + _LOGT("finalize"); + + nm_l3cfg_commit_type_unregister(self->l3cfg, g_steal_pointer(&self->l3cfg_commit_handle)); + + nm_l3cfg_remove_config_all(self->l3cfg, L3CD_TAG(self)); + + nm_clear_g_source_inst(&self->starting_on_idle_source); + nm_clear_g_source_inst(&self->wait_for_addr_source); + nm_clear_g_source_inst(&self->emit_changed_idle_source); + nm_clear_g_signal_handler(self->l3cfg, &self->l3cfg_signal_notify_id); + + g_clear_object(&self->l3cfg); + + nm_clear_l3cd(&self->l3cd); + + nm_clear_nmp_object_up_cast(&self->cur_lladdr_obj); + + if (self->addrgen.stable_type != NM_UTILS_STABLE_TYPE_NONE) { + g_free((char *) self->addrgen.stable_privacy.ifname); + g_free((char *) self->addrgen.stable_privacy.network_id); + } + + nm_g_slice_free(self); +} diff --git a/src/core/nm-l3-ipv6ll.h b/src/core/nm-l3-ipv6ll.h new file mode 100644 index 00000000..770a4268 --- /dev/null +++ b/src/core/nm-l3-ipv6ll.h @@ -0,0 +1,112 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#ifndef __NM_L3_IPV6LL_H__ +#define __NM_L3_IPV6LL_H__ + +#include "nm-l3cfg.h" +#include "nm-core-utils.h" + +/*****************************************************************************/ + +typedef struct _NML3IPv6LL NML3IPv6LL; + +typedef enum _nm_packed { + NM_L3_IPV6LL_STATE_STARTING, + NM_L3_IPV6LL_STATE_DAD_IN_PROGRESS, + NM_L3_IPV6LL_STATE_READY, + NM_L3_IPV6LL_STATE_DAD_FAILED, + + /* The following flags are not actually use by NML3IPv6LL. They exist for + * convenience of the users, to encode additional states. */ + + /* IPv6LL is disabled */ + NM_L3_IPV6LL_STATE_NONE, + + /* We want to do IPv6LL, but something is missing so we cannot even create + * a NML3IPv6LL instance. For example, no NML3Cfg instance or no interface name. */ + NM_L3_IPV6LL_STATE_DEFUNCT, + +} NML3IPv6LLState; + +const char *nm_l3_ipv6ll_state_to_string(NML3IPv6LLState state); + +typedef void (*NML3IPv6LLNotifyFcn)(NML3IPv6LL * ipv6ll, + NML3IPv6LLState state, + const struct in6_addr *lladdr, + gpointer user_data); + +static inline gboolean +NM_IS_L3_IPV6LL(const NML3IPv6LL *self) +{ + nm_assert(!self || (NM_IS_L3CFG(*((NML3Cfg **) self)))); + return !!self; +} + +NML3IPv6LL *_nm_l3_ipv6ll_new(NML3Cfg * l3cfg, + gboolean assume, + NMUtilsStableType stable_type, + const char * ifname, + const char * network_id, + const NMUtilsIPv6IfaceId *token_iid, + NML3IPv6LLNotifyFcn notify_fcn, + gpointer user_data); + +static inline NML3IPv6LL * +nm_l3_ipv6ll_new_stable_privacy(NML3Cfg * l3cfg, + gboolean assume, + NMUtilsStableType stable_type, + const char * ifname, + const char * network_id, + NML3IPv6LLNotifyFcn notify_fcn, + gpointer user_data) +{ + nm_assert(stable_type != NM_UTILS_STABLE_TYPE_NONE); + return _nm_l3_ipv6ll_new(l3cfg, + assume, + stable_type, + ifname, + network_id, + NULL, + notify_fcn, + user_data); +} + +static inline NML3IPv6LL * +nm_l3_ipv6ll_new_token(NML3Cfg * l3cfg, + gboolean assume, + const NMUtilsIPv6IfaceId *token_iid, + NML3IPv6LLNotifyFcn notify_fcn, + gpointer user_data) +{ + return _nm_l3_ipv6ll_new(l3cfg, + assume, + NM_UTILS_STABLE_TYPE_NONE, + NULL, + NULL, + token_iid, + notify_fcn, + user_data); +} + +void nm_l3_ipv6ll_destroy(NML3IPv6LL *self); + +NM_AUTO_DEFINE_FCN0(NML3IPv6LL *, _nm_auto_destroy_l3ipv6ll, nm_l3_ipv6ll_destroy); +#define nm_auto_destroy_l3ipv6ll nm_auto(_nm_auto_destroy_l3ipv6ll) + +/*****************************************************************************/ + +NML3Cfg *nm_l3_ipv6ll_get_l3cfg(NML3IPv6LL *self); + +int nm_l3_ipv6ll_get_ifindex(NML3IPv6LL *self); + +NMPlatform *nm_l3_ipv6ll_get_platform(NML3IPv6LL *self); + +/*****************************************************************************/ + +NML3IPv6LLState nm_l3_ipv6ll_get_state(NML3IPv6LL *self, const struct in6_addr **out_lladdr); + +const NML3ConfigData *nm_l3_ipv6ll_get_l3cd(NML3IPv6LL *self); + +/*****************************************************************************/ + +#endif /* __NM_L3_IPV6LL_H__ */ diff --git a/src/core/nm-l3cfg.c b/src/core/nm-l3cfg.c index 93e92673..aa56c13f 100644 --- a/src/core/nm-l3cfg.c +++ b/src/core/nm-l3cfg.c @@ -18,6 +18,17 @@ /*****************************************************************************/ +#define ROUTES_TEMPORARY_NOT_AVAILABLE_MAX_AGE_MSEC ((gint64) 20000) + +/* When a ObjStateData becomes a "zombie", we aim to delete it from platform + * on the next commit (until it disappears from platform). But we might have + * a bug, so that we fail to delete the platform (for example, related to + * IPv6 multicast routes). We thus rate limit how often we try to do this, + * before giving up. */ +#define ZOMBIE_COUNT_START 5 + +/*****************************************************************************/ + G_STATIC_ASSERT(NM_ACD_TIMEOUT_RFC5227_MSEC == N_ACD_TIMEOUT_RFC5227); #define ACD_SUPPORTED_ETH_ALEN ETH_ALEN @@ -97,6 +108,58 @@ typedef struct { G_STATIC_ASSERT(G_STRUCT_OFFSET(AcdData, info.addr) == 0); +typedef struct { + const NMPObject *obj; + + /* Whether obj is currently in the platform cache or not. + * Since "obj" is the NMPObject from the merged NML3ConfigData, + * the object in platform has the same ID (but may otherwise not + * be identical). If this is not NULL, then currently the object + * is configured in kernel. */ + const NMPObject *os_plobj; + + CList os_lst; + + /* If we have a timeout pending, we link the instance to + * self->priv.p->obj_state_temporary_not_available_lst_head. */ + CList os_temporary_not_available_lst; + + /* If a NMPObject is no longer to be configured (but was configured + * during a previous commit), then we need to remember it so that the + * next commit can delete the address/route in kernel. It becomes a zombie. */ + CList os_zombie_lst; + + /* We might want to configure "obj" in platform, but it's currently not possible. + * For example, certain IPv6 routes can only be added after the IPv6 address + * becomes non-tentative (*sigh*). In such a case, we need to remember that, and + * retry later. If this timestamp is set to a non-zero value, then it means + * we tried to configure the obj (at that timestamp) and failed, but we are + * waiting to retry. + * + * See also self->priv.p->obj_state_temporary_not_available_lst_head + * and self->priv.p->obj_state_temporary_not_available_timeout_source. */ + gint64 os_temporary_not_available_timestamp_msec; + + /* When the obj is a zombie (that means, it was previously configured by NML3Cfg, but + * now no longer), it needs to be deleted from platform. This ratelimits the time + * how often we try that. When the counter reaches zero, we forget about it. */ + guint8 os_zombie_count; + + /* whether we ever saw the object in platform. */ + bool os_was_in_platform : 1; + + /* Indicates whether NetworkManager actively tried to configure the object + * in platform once. */ + bool os_nm_configured : 1; + + /* This flag is only used temporarily to do a bulk update and + * clear all the ones that are no longer in used. */ + bool os_dirty : 1; + bool os_tna_dirty : 1; +} ObjStateData; + +G_STATIC_ASSERT(G_STRUCT_OFFSET(ObjStateData, obj) == 0); + struct _NML3CfgCommitTypeHandle { CList commit_type_lst; NML3CfgCommitType commit_type; @@ -104,6 +167,7 @@ struct _NML3CfgCommitTypeHandle { typedef struct { const NML3ConfigData *l3cd; + NML3CfgConfigFlags config_flags; NML3ConfigMergeFlags merge_flags; union { struct { @@ -126,6 +190,13 @@ typedef struct { }; guint32 default_route_penalty_x[2]; }; + union { + struct { + int default_dns_priority_6; + int default_dns_priority_4; + }; + int default_dns_priority_x[2]; + }; gconstpointer tag_confdata; guint64 pseudo_timestamp_confdata; int priority_confdata; @@ -146,7 +217,6 @@ enum { static guint signals[LAST_SIGNAL] = {0}; typedef struct _NML3CfgPrivate { - GArray *property_emit_list; GArray *l3_config_datas; NML3IPv4LL *ipv4ll; @@ -157,9 +227,11 @@ typedef struct _NML3CfgPrivate { CList commit_type_lst_head; - GHashTable *routes_temporary_not_available_hash; + GHashTable *obj_state_hash; - GHashTable *externally_removed_objs_hash; + CList obj_state_lst_head; + CList obj_state_zombie_lst_head; + CList obj_state_temporary_not_available_lst_head; GHashTable *acd_ipv4_addresses_on_link; @@ -181,41 +253,30 @@ typedef struct _NML3CfgPrivate { guint64 pseudo_timestamp_counter; - union { - struct { - guint externally_removed_objs_cnt_addresses_6; - guint externally_removed_objs_cnt_addresses_4; - }; - guint externally_removed_objs_cnt_addresses_x[2]; - }; + GSource *obj_state_temporary_not_available_timeout_source; - union { - struct { - guint externally_removed_objs_cnt_routes_6; - guint externally_removed_objs_cnt_routes_4; - }; - guint externally_removed_objs_cnt_routes_x[2]; - }; + NML3CfgCommitType commit_on_idle_type; - union { - struct { - GPtrArray *last_addresses_6; - GPtrArray *last_addresses_4; - }; - GPtrArray *last_addresses_x[2]; - }; + gint8 commit_reentrant_count; - union { - struct { - GPtrArray *last_routes_6; - GPtrArray *last_routes_4; - }; - GPtrArray *last_routes_x[2]; - }; + /* The value that was set before we touched the sysctl (this only is + * meaningful if "ip6_privacy_set" is true. At the end, we want to restore + * this value. */ + NMSettingIP6ConfigPrivacy ip6_privacy_initial : 4; - guint routes_temporary_not_available_id; + /* The value that we set the last time. This is cached so that we don't + * repeatedly try to commit the same value. */ + NMSettingIP6ConfigPrivacy ip6_privacy_set_before : 4; - gint8 commit_reentrant_count; + guint32 ndisc_retrans_timer_msec; + guint32 ndisc_reachable_time_msec; + int ndisc_hop_limit; + + /* Whether "self" set the ip6_privacy sysctl (and whether it needs to be reset). */ + bool ip6_privacy_set : 1; + bool ndisc_reachable_time_msec_set : 1; + bool ndisc_retrans_timer_msec_set : 1; + bool ndisc_hop_limit_set : 1; bool commit_type_update_sticky : 1; @@ -268,8 +329,6 @@ G_DEFINE_TYPE(NML3Cfg, nm_l3cfg, G_TYPE_OBJECT) static void _l3_commit(NML3Cfg *self, NML3CfgCommitType commit_type, gboolean is_idle); -static void _property_emit_notify(NML3Cfg *self, NML3CfgPropertyEmitType emit_type); - static void _nm_l3cfg_emit_signal_notify_acd_event_all(NML3Cfg *self); static gboolean _acd_has_valid_link(const NMPObject *obj, @@ -305,6 +364,7 @@ static NM_UTILS_ENUM2STR_DEFINE( NM_UTILS_ENUM2STR(NM_L3_CONFIG_NOTIFY_TYPE_L3CD_CHANGED, "l3cd-changed"), NM_UTILS_ENUM2STR(NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE, "platform-change"), NM_UTILS_ENUM2STR(NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE_ON_IDLE, "platform-change-on-idle"), + NM_UTILS_ENUM2STR(NM_L3_CONFIG_NOTIFY_TYPE_PRE_COMMIT, "pre-commit"), NM_UTILS_ENUM2STR(NM_L3_CONFIG_NOTIFY_TYPE_POST_COMMIT, "post-commit"), NM_UTILS_ENUM2STR(NM_L3_CONFIG_NOTIFY_TYPE_ROUTES_TEMPORARY_NOT_AVAILABLE_EXPIRED, "routes-temporary-not-available-expired"), @@ -314,7 +374,7 @@ static NM_UTILS_ENUM2STR_DEFINE(_l3_acd_defend_type_to_string, NML3AcdDefendType, NM_UTILS_ENUM2STR(NM_L3_ACD_DEFEND_TYPE_ALWAYS, "always"), NM_UTILS_ENUM2STR(NM_L3_ACD_DEFEND_TYPE_NEVER, "never"), - NM_UTILS_ENUM2STR(NM_L3_ACD_DEFEND_TYPE_NONE, "none"), + NM_UTILS_ENUM2STR(_NM_L3_ACD_DEFEND_TYPE_NONE, "none"), NM_UTILS_ENUM2STR(NM_L3_ACD_DEFEND_TYPE_ONCE, "once"), ); static NM_UTILS_LOOKUP_DEFINE(_l3_acd_defend_type_to_nacd, @@ -342,6 +402,17 @@ static NM_UTILS_LOOKUP_DEFINE(_l3_acd_addr_state_to_string, /*****************************************************************************/ +gboolean +nm_l3cfg_is_vrf(const NML3Cfg *self) +{ + const NMPlatformLink *pllink; + + pllink = nm_l3cfg_get_pllink(self, TRUE); + return pllink && pllink->type == NM_LINK_TYPE_VRF; +} + +/*****************************************************************************/ + static const char * _l3_config_notify_data_to_string(const NML3ConfigNotifyData *notify_data, char * sbuf, @@ -358,31 +429,29 @@ _l3_config_notify_data_to_string(const NML3ConfigNotifyData *notify_data, nm_assert(sbuf_size > 0); _l3_config_notify_type_to_string(notify_data->notify_type, s, l); - nm_utils_strbuf_seek_end(&s, &l); + nm_strbuf_seek_end(&s, &l); switch (notify_data->notify_type) { case NM_L3_CONFIG_NOTIFY_TYPE_L3CD_CHANGED: - nm_utils_strbuf_append( - &s, - &l, - ", l3cd-old=%s", - NM_HASH_OBFUSCATE_PTR_STR(notify_data->l3cd_changed.l3cd_old, sbufobf)); - nm_utils_strbuf_append( - &s, - &l, - ", l3cd-new=%s", - NM_HASH_OBFUSCATE_PTR_STR(notify_data->l3cd_changed.l3cd_new, sbufobf)); - nm_utils_strbuf_append(&s, &l, ", commited=%d", notify_data->l3cd_changed.commited); + nm_strbuf_append(&s, + &l, + ", l3cd-old=%s", + NM_HASH_OBFUSCATE_PTR_STR(notify_data->l3cd_changed.l3cd_old, sbufobf)); + nm_strbuf_append(&s, + &l, + ", l3cd-new=%s", + NM_HASH_OBFUSCATE_PTR_STR(notify_data->l3cd_changed.l3cd_new, sbufobf)); + nm_strbuf_append(&s, &l, ", commited=%d", notify_data->l3cd_changed.commited); break; case NM_L3_CONFIG_NOTIFY_TYPE_ACD_EVENT: - nm_utils_strbuf_append(&s, - &l, - ", addr=%s, state=%s", - _nm_utils_inet4_ntop(notify_data->acd_event.info.addr, sbuf_addr), - _l3_acd_addr_state_to_string(notify_data->acd_event.info.state)); + nm_strbuf_append(&s, + &l, + ", addr=%s, state=%s", + _nm_utils_inet4_ntop(notify_data->acd_event.info.addr, sbuf_addr), + _l3_acd_addr_state_to_string(notify_data->acd_event.info.state)); break; case NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE: - nm_utils_strbuf_append( + nm_strbuf_append( &s, &l, ", obj-type=%s, change=%s, obj=", @@ -391,15 +460,15 @@ _l3_config_notify_data_to_string(const NML3ConfigNotifyData *notify_data, nmp_object_to_string(notify_data->platform_change.obj, NMP_OBJECT_TO_STRING_PUBLIC, s, l); break; case NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE_ON_IDLE: - nm_utils_strbuf_append(&s, - &l, - ", obj-type-flags=0x%x", - notify_data->platform_change_on_idle.obj_type_flags); + nm_strbuf_append(&s, + &l, + ", obj-type-flags=0x%x", + notify_data->platform_change_on_idle.obj_type_flags); break; case NM_L3_CONFIG_NOTIFY_TYPE_IPV4LL_EVENT: nm_assert(NM_IS_L3_IPV4LL(notify_data->ipv4ll_event.ipv4ll)); addr4 = nm_l3_ipv4ll_get_addr(notify_data->ipv4ll_event.ipv4ll); - nm_utils_strbuf_append( + nm_strbuf_append( &s, &l, ", ipv4ll=" NM_HASH_OBFUSCATE_PTR_FMT "%s%s, state=%s", @@ -555,157 +624,447 @@ _nm_n_acd_data_probe_new(NML3Cfg *self, in_addr_t addr, guint32 timeout_msec, gp /*****************************************************************************/ -static guint * -_l3cfg_externally_removed_objs_counter(NML3Cfg *self, NMPObjectType obj_type) +#define nm_assert_obj_state(self, obj_state) \ + G_STMT_START \ + { \ + if (NM_MORE_ASSERTS > 0) { \ + const NML3Cfg * _self = (self); \ + const ObjStateData *_obj_state = (obj_state); \ + \ + nm_assert(_obj_state); \ + nm_assert(NM_IN_SET(NMP_OBJECT_GET_TYPE(_obj_state->obj), \ + NMP_OBJECT_TYPE_IP4_ADDRESS, \ + NMP_OBJECT_TYPE_IP6_ADDRESS, \ + NMP_OBJECT_TYPE_IP4_ROUTE, \ + NMP_OBJECT_TYPE_IP6_ROUTE)); \ + nm_assert(!_obj_state->os_plobj || _obj_state->os_was_in_platform); \ + nm_assert((_obj_state->os_temporary_not_available_timestamp_msec == 0) \ + == c_list_is_empty(&_obj_state->os_temporary_not_available_lst)); \ + if (_self) { \ + if (c_list_is_empty(&_obj_state->os_zombie_lst)) { \ + nm_assert(_self->priv.p->combined_l3cd_commited); \ + \ + if (NM_MORE_ASSERTS > 5) { \ + nm_assert(c_list_contains(&_self->priv.p->obj_state_lst_head, \ + &_obj_state->os_lst)); \ + nm_assert((_obj_state->os_temporary_not_available_timestamp_msec == 0) \ + || c_list_contains( \ + &_self->priv.p->obj_state_temporary_not_available_lst_head, \ + &_obj_state->os_temporary_not_available_lst)); \ + nm_assert(_obj_state->os_plobj \ + == nm_platform_lookup_obj(_self->priv.platform, \ + NMP_CACHE_ID_TYPE_OBJECT_TYPE, \ + _obj_state->obj)); \ + nm_assert( \ + c_list_is_empty(&obj_state->os_zombie_lst) \ + ? (_obj_state->obj \ + == nm_dedup_multi_entry_get_obj(nm_l3_config_data_lookup_obj( \ + _self->priv.p->combined_l3cd_commited, \ + _obj_state->obj))) \ + : (!nm_l3_config_data_lookup_obj( \ + _self->priv.p->combined_l3cd_commited, \ + _obj_state->obj))); \ + } \ + } \ + } \ + } \ + } \ + G_STMT_END + +static gboolean +_obj_state_data_get_assume_config_once(const ObjStateData *obj_state) { - switch (obj_type) { - case NMP_OBJECT_TYPE_IP4_ADDRESS: - return &self->priv.p->externally_removed_objs_cnt_addresses_4; - case NMP_OBJECT_TYPE_IP6_ADDRESS: - return &self->priv.p->externally_removed_objs_cnt_addresses_6; - case NMP_OBJECT_TYPE_IP4_ROUTE: - return &self->priv.p->externally_removed_objs_cnt_routes_4; - case NMP_OBJECT_TYPE_IP6_ROUTE: - return &self->priv.p->externally_removed_objs_cnt_routes_6; - default: - return nm_assert_unreachable_val(NULL); - } + nm_assert_obj_state(NULL, obj_state); + + return nmp_object_get_assume_config_once(obj_state->obj); +} + +static ObjStateData * +_obj_state_data_new(const NMPObject *obj, const NMPObject *plobj) +{ + ObjStateData *obj_state; + + obj_state = g_slice_new(ObjStateData); + *obj_state = (ObjStateData){ + .obj = nmp_object_ref(obj), + .os_plobj = nmp_object_ref(plobj), + .os_was_in_platform = !!plobj, + .os_nm_configured = FALSE, + .os_dirty = FALSE, + .os_temporary_not_available_lst = C_LIST_INIT(obj_state->os_temporary_not_available_lst), + .os_zombie_lst = C_LIST_INIT(obj_state->os_zombie_lst), + }; + return obj_state; } static void -_l3cfg_externally_removed_objs_drop(NML3Cfg *self) +_obj_state_data_free(gpointer data) { - nm_assert(NM_IS_L3CFG(self)); + ObjStateData *obj_state = data; + + c_list_unlink_stale(&obj_state->os_lst); + c_list_unlink_stale(&obj_state->os_zombie_lst); + c_list_unlink_stale(&obj_state->os_temporary_not_available_lst); + nmp_object_unref(obj_state->obj); + nmp_object_unref(obj_state->os_plobj); + nm_g_slice_free(obj_state); +} + +static const char * +_obj_state_data_to_string(const ObjStateData *obj_state, char *buf, gsize buf_size) +{ + const char *buf0 = buf; + gint64 now_msec = 0; + + nm_assert(buf); + nm_assert(buf_size > 0); + nm_assert_obj_state(NULL, obj_state); + + nm_strbuf_append(&buf, + &buf_size, + "[" NM_HASH_OBFUSCATE_PTR_FMT ", %s, ", + NM_HASH_OBFUSCATE_PTR(obj_state), + NMP_OBJECT_GET_CLASS(obj_state->obj)->obj_type_name); + + nmp_object_to_string(obj_state->obj, NMP_OBJECT_TO_STRING_PUBLIC, buf, buf_size); + nm_strbuf_seek_end(&buf, &buf_size); + nm_strbuf_append_c(&buf, &buf_size, ']'); + + if (!c_list_is_empty(&obj_state->os_zombie_lst)) + nm_strbuf_append(&buf, &buf_size, ", zombie[%u]", obj_state->os_zombie_count); + + if (obj_state->os_nm_configured) + nm_strbuf_append_str(&buf, &buf_size, ", nm-configured"); + + if (obj_state->os_plobj) { + nm_assert(obj_state->os_was_in_platform); + nm_strbuf_append_str(&buf, &buf_size, ", in-platform"); + } else if (obj_state->os_was_in_platform) + nm_strbuf_append_str(&buf, &buf_size, ", was-in-platform"); + + if (obj_state->os_temporary_not_available_timestamp_msec > 0) { + nm_utils_get_monotonic_timestamp_msec_cached(&now_msec); + nm_strbuf_append( + &buf, + &buf_size, + ", temporary-not-available-since=%" G_GINT64_FORMAT ".%03d", + (now_msec - obj_state->os_temporary_not_available_timestamp_msec) / 1000, + (int) ((now_msec - obj_state->os_temporary_not_available_timestamp_msec) % 1000)); + } + + return buf0; +} + +static gboolean +_obj_state_data_update(ObjStateData *obj_state, const NMPObject *obj) +{ + gboolean changed = FALSE; + + nm_assert_obj_state(NULL, obj_state); + nm_assert(obj); + nm_assert(nmp_object_id_equal(obj_state->obj, obj)); + + obj_state->os_dirty = FALSE; - self->priv.p->externally_removed_objs_cnt_addresses_4 = 0; - self->priv.p->externally_removed_objs_cnt_addresses_6 = 0; - self->priv.p->externally_removed_objs_cnt_routes_4 = 0; - self->priv.p->externally_removed_objs_cnt_routes_6 = 0; - if (nm_g_hash_table_size(self->priv.p->externally_removed_objs_hash) > 0) - _LOGD("externally-removed: untrack all"); - nm_clear_pointer(&self->priv.p->externally_removed_objs_hash, g_hash_table_unref); + if (obj_state->obj != obj) { + nm_auto_nmpobj const NMPObject *obj_old = NULL; + + if (!nmp_object_equal(obj_state->obj, obj)) + changed = TRUE; + obj_old = g_steal_pointer(&obj_state->obj); + obj_state->obj = nmp_object_ref(obj); + } + + if (!c_list_is_empty(&obj_state->os_zombie_lst)) { + c_list_unlink(&obj_state->os_zombie_lst); + changed = TRUE; + } + + return changed; } +/*****************************************************************************/ + static void -_l3cfg_externally_removed_objs_drop_unused(NML3Cfg *self) +_obj_states_externally_removed_track(NML3Cfg *self, const NMPObject *obj, gboolean in_platform) { - GHashTableIter h_iter; - const NMPObject *obj; - char sbuf[sizeof(_nm_utils_to_string_buffer)]; + char sbuf[sizeof(_nm_utils_to_string_buffer)]; + ObjStateData *obj_state; nm_assert(NM_IS_L3CFG(self)); + nm_assert_is_bool(in_platform); - if (!self->priv.p->externally_removed_objs_hash) + nm_assert( + in_platform + ? (obj + == nm_platform_lookup_obj(self->priv.platform, NMP_CACHE_ID_TYPE_OBJECT_TYPE, obj)) + : (!nm_platform_lookup_obj(self->priv.platform, NMP_CACHE_ID_TYPE_OBJECT_TYPE, obj))); + + obj_state = g_hash_table_lookup(self->priv.p->obj_state_hash, &obj); + if (!obj_state) return; - if (!self->priv.p->combined_l3cd_commited) { - _l3cfg_externally_removed_objs_drop(self); + if (!in_platform) + obj = NULL; + + if (obj_state->os_plobj == obj) + goto out; + + if (!in_platform && !c_list_is_empty(&obj_state->os_zombie_lst)) { + /* this is a zombie. We can forget about it.*/ + nm_clear_nmp_object(&obj_state->os_plobj); + c_list_unlink(&obj_state->os_zombie_lst); + _LOGD("obj-state: zombie gone (untrack): %s", + _obj_state_data_to_string(obj_state, sbuf, sizeof(sbuf))); + g_hash_table_remove(self->priv.p->obj_state_hash, obj_state); return; } - g_hash_table_iter_init(&h_iter, self->priv.p->externally_removed_objs_hash); - while (g_hash_table_iter_next(&h_iter, (gpointer *) &obj, NULL)) { - if (!nm_l3_config_data_lookup_obj(self->priv.p->combined_l3cd_commited, obj)) { - /* The object is no longer tracked in the configuration. - * The externally_removed_objs_hash is to prevent adding entires that were - * removed externally, so if we don't plan to add the entry, we no longer need to track - * it. */ - _LOGD("externally-removed: untrack %s", - nmp_object_to_string(obj, NMP_OBJECT_TO_STRING_PUBLIC, sbuf, sizeof(sbuf))); - (*(_l3cfg_externally_removed_objs_counter(self, NMP_OBJECT_GET_TYPE(obj))))--; - g_hash_table_iter_remove(&h_iter); - } + nm_assert(c_list_is_empty(&obj_state->os_zombie_lst)); + + if (in_platform) { + nmp_object_ref_set(&obj_state->os_plobj, obj); + obj_state->os_was_in_platform = TRUE; + _LOGD("obj-state: appeared in platform: %s", + _obj_state_data_to_string(obj_state, sbuf, sizeof(sbuf))); + goto out; } + + nm_clear_nmp_object(&obj_state->os_plobj); + _LOGD("obj-state: remove from platform: %s", + _obj_state_data_to_string(obj_state, sbuf, sizeof(sbuf))); + +out: + nm_assert_obj_state(self, obj_state); } static void -_l3cfg_externally_removed_objs_track(NML3Cfg *self, const NMPObject *obj, gboolean is_removed) +_obj_states_update_all(NML3Cfg *self) { - char sbuf[1000]; + static const NMPObjectType obj_types[] = { + NMP_OBJECT_TYPE_IP4_ADDRESS, + NMP_OBJECT_TYPE_IP6_ADDRESS, + NMP_OBJECT_TYPE_IP4_ROUTE, + NMP_OBJECT_TYPE_IP6_ROUTE, + }; + char sbuf[sizeof(_nm_utils_to_string_buffer)]; + ObjStateData *obj_state; + int i; + gboolean any_dirty = FALSE; nm_assert(NM_IS_L3CFG(self)); - if (!self->priv.p->combined_l3cd_commited) - return; + c_list_for_each_entry (obj_state, &self->priv.p->obj_state_lst_head, os_lst) { + if (!c_list_is_empty(&obj_state->os_zombie_lst)) { + /* we can ignore zombies. */ + continue; + } + any_dirty = TRUE; + obj_state->os_dirty = TRUE; + } + + for (i = 0; i < (int) G_N_ELEMENTS(obj_types); i++) { + const NMPObjectType obj_type = obj_types[i]; + NMDedupMultiIter o_iter; + const NMPObject * obj; + + if (!self->priv.p->combined_l3cd_commited) + continue; + + nm_l3_config_data_iter_obj_for_each (&o_iter, + self->priv.p->combined_l3cd_commited, + &obj, + obj_type) { + obj_state = g_hash_table_lookup(self->priv.p->obj_state_hash, &obj); + if (!obj_state) { + obj_state = + _obj_state_data_new(obj, + nm_platform_lookup_obj(self->priv.platform, + NMP_CACHE_ID_TYPE_OBJECT_TYPE, + obj)); + c_list_link_tail(&self->priv.p->obj_state_lst_head, &obj_state->os_lst); + g_hash_table_add(self->priv.p->obj_state_hash, obj_state); + _LOGD("obj-state: track: %s", + _obj_state_data_to_string(obj_state, sbuf, sizeof(sbuf))); + nm_assert_obj_state(self, obj_state); + continue; + } - if (!is_removed) { - /* the object is still (or again) present. It no longer gets hidden. */ - if (self->priv.p->externally_removed_objs_hash) { - const NMPObject *obj2; - gpointer x_val; - - if (g_hash_table_steal_extended(self->priv.p->externally_removed_objs_hash, - obj, - (gpointer *) &obj2, - &x_val)) { - (*(_l3cfg_externally_removed_objs_counter(self, NMP_OBJECT_GET_TYPE(obj2))))--; - _LOGD("externally-removed: untrack %s", - nmp_object_to_string(obj2, NMP_OBJECT_TO_STRING_PUBLIC, sbuf, sizeof(sbuf))); - nmp_object_unref(obj2); + if (_obj_state_data_update(obj_state, obj)) { + _LOGD("obj-state: update: %s", + _obj_state_data_to_string(obj_state, sbuf, sizeof(sbuf))); } + + nm_assert_obj_state(self, obj_state); } - return; } - if (!nm_l3_config_data_lookup_obj(self->priv.p->combined_l3cd_commited, obj)) { - /* we don't care about this object, so there is nothing to hide hide */ - return; + if (any_dirty) { + GHashTableIter h_iter; + + g_hash_table_iter_init(&h_iter, self->priv.p->obj_state_hash); + while (g_hash_table_iter_next(&h_iter, (gpointer *) &obj_state, NULL)) { + if (!c_list_is_empty(&obj_state->os_zombie_lst)) + continue; + if (!obj_state->os_dirty) + continue; + + if (obj_state->os_plobj && obj_state->os_nm_configured) { + c_list_link_tail(&self->priv.p->obj_state_zombie_lst_head, + &obj_state->os_zombie_lst); + obj_state->os_zombie_count = ZOMBIE_COUNT_START; + _LOGD("obj-state: now zombie: %s", + _obj_state_data_to_string(obj_state, sbuf, sizeof(sbuf))); + continue; + } + + _LOGD("obj-state: untrack: %s", + _obj_state_data_to_string(obj_state, sbuf, sizeof(sbuf))); + g_hash_table_iter_remove(&h_iter); + } } +} - if (G_UNLIKELY(!self->priv.p->externally_removed_objs_hash)) { - self->priv.p->externally_removed_objs_hash = - g_hash_table_new_full((GHashFunc) nmp_object_id_hash, - (GEqualFunc) nmp_object_id_equal, - (GDestroyNotify) nmp_object_unref, - NULL); +typedef struct { + NML3Cfg * self; + NML3CfgCommitType commit_type; +} ObjStatesSyncFilterData; + +static gboolean +_obj_states_sync_filter(/* const NMDedupMultiObj * */ gconstpointer o, gpointer user_data) +{ + char sbuf[sizeof(_nm_utils_to_string_buffer)]; + const NMPObject * obj = o; + const ObjStatesSyncFilterData *sync_filter_data = user_data; + NMPObjectType obj_type; + ObjStateData * obj_state; + + nm_assert(sync_filter_data); + nm_assert(NM_IS_L3CFG(sync_filter_data->self)); + + obj_type = NMP_OBJECT_GET_TYPE(obj); + + if (obj_type == NMP_OBJECT_TYPE_IP4_ADDRESS + && NMP_OBJECT_CAST_IP4_ADDRESS(obj)->a_acd_not_ready) + return FALSE; + + obj_state = g_hash_table_lookup(sync_filter_data->self->priv.p->obj_state_hash, &obj); + + nm_assert_obj_state(sync_filter_data->self, obj_state); + nm_assert(obj_state->obj == obj); + nm_assert(c_list_is_empty(&obj_state->os_zombie_lst)); + + if (!obj_state->os_nm_configured) { + NML3Cfg *self; + + if (sync_filter_data->commit_type == NM_L3_CFG_COMMIT_TYPE_ASSUME + && !_obj_state_data_get_assume_config_once(obj_state)) + return FALSE; + + obj_state->os_nm_configured = TRUE; + + self = sync_filter_data->self; + _LOGD("obj-state: configure-first-time: %s", + _obj_state_data_to_string(obj_state, sbuf, sizeof(sbuf))); + return TRUE; } - if (g_hash_table_add(self->priv.p->externally_removed_objs_hash, - (gpointer) nmp_object_ref(obj))) { - (*(_l3cfg_externally_removed_objs_counter(self, NMP_OBJECT_GET_TYPE(obj))))++; - _LOGD("externally-removed: track %s", - nmp_object_to_string(obj, NMP_OBJECT_TO_STRING_PUBLIC, sbuf, sizeof(sbuf))); + if (obj_state->os_temporary_not_available_timestamp_msec > 0) { + /* we currently try to configure this address (but failed earlier). + * Definitely retry. */ + return TRUE; } + + if (!obj_state->os_plobj && sync_filter_data->commit_type != NM_L3_CFG_COMMIT_TYPE_REAPPLY) + return FALSE; + + return TRUE; } static void -_l3cfg_externally_removed_objs_pickup(NML3Cfg *self, int addr_family) +_obj_state_zombie_lst_get_prune_lists(NML3Cfg * self, + int addr_family, + GPtrArray **out_addresses_prune, + GPtrArray **out_routes_prune) { - const int IS_IPv4 = NM_IS_IPv4(addr_family); - NMDedupMultiIter iter; - const NMPObject *obj; + const int IS_IPv4 = NM_IS_IPv4(addr_family); + const NMPObjectType obj_type_route = NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4); + const NMPObjectType obj_type_address = NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4); + char sbuf[sizeof(_nm_utils_to_string_buffer)]; + ObjStateData * obj_state; + ObjStateData * obj_state_safe; - if (!self->priv.p->combined_l3cd_commited) - return; + nm_assert(NM_IS_L3CFG(self)); + nm_assert(out_addresses_prune && !*out_addresses_prune); + nm_assert(out_routes_prune && !*out_routes_prune); - nm_l3_config_data_iter_obj_for_each (&iter, - self->priv.p->combined_l3cd_commited, - &obj, - NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4)) { - if (!nm_platform_lookup_entry(self->priv.platform, NMP_CACHE_ID_TYPE_OBJECT_TYPE, obj)) - _l3cfg_externally_removed_objs_track(self, obj, TRUE); - } - nm_l3_config_data_iter_obj_for_each (&iter, - self->priv.p->combined_l3cd_commited, - &obj, - NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4)) { - if (!nm_platform_lookup_entry(self->priv.platform, NMP_CACHE_ID_TYPE_OBJECT_TYPE, obj)) - _l3cfg_externally_removed_objs_track(self, obj, TRUE); + c_list_for_each_entry_safe (obj_state, + obj_state_safe, + &self->priv.p->obj_state_zombie_lst_head, + os_zombie_lst) { + NMPObjectType obj_type; + GPtrArray ** p_a; + + nm_assert_obj_state(self, obj_state); + nm_assert(obj_state->os_zombie_count > 0); + + obj_type = NMP_OBJECT_GET_TYPE(obj_state->obj); + + if (obj_type == obj_type_route) + p_a = out_routes_prune; + else if (obj_type == obj_type_address) + p_a = out_addresses_prune; + else + continue; + + if (!*p_a) + *p_a = g_ptr_array_new_with_free_func((GDestroyNotify) nmp_object_unref); + + g_ptr_array_add(*p_a, (gpointer) nmp_object_ref(obj_state->obj)); + + if (--obj_state->os_zombie_count == 0) { + _LOGD("obj-state: prune zombie (untrack): %s", + _obj_state_data_to_string(obj_state, sbuf, sizeof(sbuf))); + g_hash_table_remove(self->priv.p->obj_state_hash, obj_state); + continue; + } + _LOGD("obj-state: prune zombie: %s", + _obj_state_data_to_string(obj_state, sbuf, sizeof(sbuf))); } } -static gboolean -_l3cfg_externally_removed_objs_filter(/* const NMDedupMultiObj * */ gconstpointer o, - gpointer user_data) +static void +_obj_state_zombie_lst_prune_all(NML3Cfg *self, int addr_family) { - const NMPObject *obj = o; - GHashTable * externally_removed_objs_hash = user_data; + char sbuf[sizeof(_nm_utils_to_string_buffer)]; + ObjStateData *obj_state; + ObjStateData *obj_state_safe; - if (NMP_OBJECT_GET_TYPE(obj) == NMP_OBJECT_TYPE_IP4_ADDRESS - && NMP_OBJECT_CAST_IP4_ADDRESS(obj)->ip4acd_not_ready) - return FALSE; + /* we call this during reapply. Then we delete all the routes/addresses + * that are configured, and not only the zombies. + * + * Still, we need to adjust the os_zombie_count and assume that we + * are going to drop them. */ + + c_list_for_each_entry_safe (obj_state, + obj_state_safe, + &self->priv.p->obj_state_zombie_lst_head, + os_zombie_lst) { + nm_assert_obj_state(self, obj_state); + nm_assert(obj_state->os_zombie_count > 0); + + if (NMP_OBJECT_GET_ADDR_FAMILY(obj_state->obj) != addr_family) + continue; - return !nm_g_hash_table_contains(externally_removed_objs_hash, obj); + if (--obj_state->os_zombie_count == 0) { + _LOGD("obj-state: zombie pruned during reapply (untrack): %s", + _obj_state_data_to_string(obj_state, sbuf, sizeof(sbuf))); + g_hash_table_remove(self->priv.p->obj_state_hash, obj_state); + continue; + } + _LOGD("obj-state: zombie pruned during reapply: %s", + _obj_state_data_to_string(obj_state, sbuf, sizeof(sbuf))); + } } /*****************************************************************************/ @@ -810,11 +1169,6 @@ _nm_l3cfg_notify_platform_change_on_idle(NML3Cfg *self, guint32 obj_type_flags) _nm_l3cfg_emit_signal_notify(self, ¬ify_data); _nm_l3cfg_emit_signal_notify_acd_event_all(self); - - if (NM_FLAGS_ANY(obj_type_flags, nmp_object_type_to_flags(NMP_OBJECT_TYPE_IP4_ROUTE))) - _property_emit_notify(self, NM_L3CFG_PROPERTY_EMIT_TYPE_IP4_ROUTE); - if (NM_FLAGS_ANY(obj_type_flags, nmp_object_type_to_flags(NMP_OBJECT_TYPE_IP6_ROUTE))) - _property_emit_notify(self, NM_L3CFG_PROPERTY_EMIT_TYPE_IP6_ROUTE); } void @@ -847,7 +1201,7 @@ _nm_l3cfg_notify_platform_change(NML3Cfg * self, case NMP_OBJECT_TYPE_IP6_ADDRESS: case NMP_OBJECT_TYPE_IP4_ROUTE: case NMP_OBJECT_TYPE_IP6_ROUTE: - _l3cfg_externally_removed_objs_track(self, obj, change_type == NM_PLATFORM_SIGNAL_REMOVED); + _obj_states_externally_removed_track(self, obj, change_type != NM_PLATFORM_SIGNAL_REMOVED); default: break; } @@ -864,146 +1218,6 @@ _nm_l3cfg_notify_platform_change(NML3Cfg * self, /*****************************************************************************/ -typedef struct { - GObject * target_obj; - const GParamSpec * target_property; - NML3CfgPropertyEmitType emit_type; -} PropertyEmitData; - -static void -_property_emit_notify(NML3Cfg *self, NML3CfgPropertyEmitType emit_type) -{ - gs_free PropertyEmitData *collected_heap = NULL; - PropertyEmitData * collected = NULL; - PropertyEmitData * emit_data; - guint num; - guint i; - guint j; - - if (!self->priv.p->property_emit_list) - return; - - num = 0; - emit_data = &g_array_index(self->priv.p->property_emit_list, PropertyEmitData, 0); - for (i = 0; i < self->priv.p->property_emit_list->len; i++, emit_data++) { - if (emit_data->emit_type == emit_type) { - collected = emit_data; - num++; - } - } - - if (num == 0) - return; - - if (num == 1) { - g_object_notify_by_pspec(collected->target_obj, (GParamSpec *) collected->target_property); - return; - } - - if (num < 300u / sizeof(*collected)) - collected = g_alloca(sizeof(PropertyEmitData) * num); - else { - collected_heap = g_new(PropertyEmitData, num); - collected = collected_heap; - } - - emit_data = &g_array_index(self->priv.p->property_emit_list, PropertyEmitData, 0); - for (i = 0, j = 0; i < self->priv.p->property_emit_list->len; i++, emit_data++) { - if (emit_data->emit_type == emit_type) { - collected[j++] = *emit_data; - g_object_ref(collected->target_obj); - } - } - - nm_assert(j == num); - - for (i = 0; i < num; i++) { - g_object_notify_by_pspec(collected[i].target_obj, - (GParamSpec *) collected[i].target_property); - if (i > 0) - g_object_unref(collected[i].target_obj); - } -} - -void -nm_l3cfg_property_emit_register(NML3Cfg * self, - GObject * target_obj, - const GParamSpec * target_property, - NML3CfgPropertyEmitType emit_type) -{ - PropertyEmitData *emit_data; - guint i; - - nm_assert(NM_IS_L3CFG(self)); - nm_assert(G_IS_OBJECT(target_obj)); - nm_assert(target_property); - nm_assert(NM_IN_SET(emit_type, - NM_L3CFG_PROPERTY_EMIT_TYPE_IP4_ROUTE, - NM_L3CFG_PROPERTY_EMIT_TYPE_IP6_ROUTE)); - nm_assert(target_property - == nm_g_object_class_find_property_from_gtype(G_OBJECT_TYPE(target_obj), - target_property->name)); - - if (!self->priv.p->property_emit_list) - self->priv.p->property_emit_list = g_array_new(FALSE, FALSE, sizeof(PropertyEmitData)); - else { - emit_data = &g_array_index(self->priv.p->property_emit_list, PropertyEmitData, 0); - for (i = 0; i < self->priv.p->property_emit_list->len; i++, emit_data++) { - if (emit_data->target_obj != target_obj - || emit_data->target_property != target_property) - continue; - nm_assert(emit_data->emit_type == emit_type); - emit_data->emit_type = emit_type; - return; - } - } - - emit_data = nm_g_array_append_new(self->priv.p->property_emit_list, PropertyEmitData); - *emit_data = (PropertyEmitData){ - .target_obj = target_obj, - .target_property = target_property, - .emit_type = emit_type, - }; -} - -void -nm_l3cfg_property_emit_unregister(NML3Cfg * self, - GObject * target_obj, - const GParamSpec *target_property) -{ - PropertyEmitData *emit_data; - guint i; - - nm_assert(NM_IS_L3CFG(self)); - nm_assert(G_IS_OBJECT(target_obj)); - nm_assert(!target_property - || target_property - == nm_g_object_class_find_property_from_gtype(G_OBJECT_TYPE(target_obj), - target_property->name)); - - if (!self->priv.p->property_emit_list) - return; - - for (i = self->priv.p->property_emit_list->len; i > 0; i--) { - emit_data = &g_array_index(self->priv.p->property_emit_list, PropertyEmitData, i); - - if (emit_data->target_obj != target_obj) - continue; - if (target_property && emit_data->target_property != target_property) - continue; - - g_array_remove_index_fast(self->priv.p->property_emit_list, i); - - if (target_property) { - /* if a target-property is given, we don't have another entry in - * the list. */ - return; - } - } -} - -/*****************************************************************************/ - gboolean nm_l3cfg_get_acd_is_pending(NML3Cfg *self) { @@ -1012,12 +1226,6 @@ nm_l3cfg_get_acd_is_pending(NML3Cfg *self) return self->priv.p->acd_is_pending; } -static gboolean -_acd_track_data_is_not_dirty(const NML3AcdAddrTrackInfo *acd_track) -{ - return acd_track && !acd_track->_priv.acd_dirty_track; -} - static void _acd_track_data_clear(NML3AcdAddrTrackInfo *acd_track) { @@ -1044,7 +1252,7 @@ _acd_data_collect_tracks_data(const AcdData * acd_data, guint32 * out_best_acd_timeout_msec, NML3AcdDefendType *out_best_acd_defend_type) { - NML3AcdDefendType best_acd_defend_type = NM_L3_ACD_DEFEND_TYPE_NONE; + NML3AcdDefendType best_acd_defend_type = _NM_L3_ACD_DEFEND_TYPE_NONE; guint32 best_acd_timeout_msec = G_MAXUINT32; guint n = 0; guint i; @@ -1063,7 +1271,7 @@ _acd_data_collect_tracks_data(const AcdData * acd_data, best_acd_defend_type = acd_track->_priv.acd_defend_type_track; } - nm_assert(n == 0 || best_acd_defend_type > NM_L3_ACD_DEFEND_TYPE_NONE); + nm_assert(n == 0 || best_acd_defend_type > _NM_L3_ACD_DEFEND_TYPE_NONE); nm_assert(best_acd_defend_type <= NM_L3_ACD_DEFEND_TYPE_ALWAYS); NM_SET_OUT(out_best_acd_timeout_msec, n > 0 ? best_acd_timeout_msec : 0u); @@ -1136,9 +1344,9 @@ _l3_acd_nacd_event_down_timeout_cb(gpointer user_data) static gboolean _l3_acd_nacd_event(int fd, GIOCondition condition, gpointer user_data) { - NML3Cfg *self = user_data; - gboolean success = FALSE; - int r; + gs_unref_object NML3Cfg *self = g_object_ref(user_data); + gboolean success = FALSE; + int r; nm_assert(NM_IS_L3CFG(self)); nm_assert(self->priv.p->nacd); @@ -1155,6 +1363,13 @@ _l3_acd_nacd_event(int fd, GIOCondition condition, gpointer user_data) AcdData * acd_data; NAcdEvent * event; + if (!self->priv.p->nacd) { + /* In the loop we emit signals, where *anything* might happen. + * Check that we still have the nacd instance. */ + success = TRUE; + goto out; + } + r = n_acd_pop_event(self->priv.p->nacd, &event); if (r) { _LOGT("acd: pop-event failed with error %d", r); @@ -1286,7 +1501,7 @@ _l3_acd_nacd_instance_reset(NML3Cfg *self, NMTernary start_timer, gboolean acd_d switch (start_timer) { case NM_TERNARY_FALSE: _l3_changed_configs_set_dirty(self); - nm_l3cfg_commit_on_idle_schedule(self); + nm_l3cfg_commit_on_idle_schedule(self, NM_L3_CFG_COMMIT_TYPE_AUTO); break; case NM_TERNARY_TRUE: self->priv.p->nacd_instance_ensure_retry = @@ -1527,8 +1742,8 @@ _l3_acd_data_add(NML3Cfg * self, .n_track_infos_alloc = 0, .acd_event_notify_lst = C_LIST_INIT(acd_data->acd_event_notify_lst), .probing_timestamp_msec = 0, - .acd_defend_type_desired = NM_L3_ACD_DEFEND_TYPE_NONE, - .acd_defend_type_current = NM_L3_ACD_DEFEND_TYPE_NONE, + .acd_defend_type_desired = _NM_L3_ACD_DEFEND_TYPE_NONE, + .acd_defend_type_current = _NM_L3_ACD_DEFEND_TYPE_NONE, .acd_defend_type_is_active = FALSE, }; c_list_link_tail(&self->priv.p->acd_lst_head, &acd_data->acd_lst); @@ -1794,7 +2009,7 @@ _nm_printf(5, 6) static void _l3_acd_data_state_set_full(NML3Cfg * self, /* The availability of an address just changed (and we are instructed to * trigger a new commit). Do it. */ _l3_changed_configs_set_dirty(self); - nm_l3cfg_commit_on_idle_schedule(self); + nm_l3cfg_commit_on_idle_schedule(self, NM_L3_CFG_COMMIT_TYPE_AUTO); } } @@ -2464,7 +2679,7 @@ handle_start_defending: ACD_STATE_CHANGE_MODE_INIT_REAPPLY, ACD_STATE_CHANGE_MODE_POST_COMMIT)); - nm_assert(acd_data->acd_defend_type_desired > NM_L3_ACD_DEFEND_TYPE_NONE); + nm_assert(acd_data->acd_defend_type_desired > _NM_L3_ACD_DEFEND_TYPE_NONE); nm_assert(acd_data->acd_defend_type_desired <= NM_L3_ACD_DEFEND_TYPE_ALWAYS); if (acd_data->acd_defend_type_desired != acd_data->acd_defend_type_current) { @@ -2570,33 +2785,163 @@ nm_l3cfg_get_acd_addr_info(NML3Cfg *self, in_addr_t addr) /*****************************************************************************/ +gboolean +nm_l3cfg_check_ready(NML3Cfg * self, + const NML3ConfigData * l3cd, + int addr_family, + NML3CfgCheckReadyFlags flags, + gboolean * acd_used) +{ + NMDedupMultiIter iter; + const NMPObject *obj; + + nm_assert(NM_IS_L3CFG(self)); + nm_assert_addr_family_or_unspec(addr_family); + + NM_SET_OUT(acd_used, FALSE); + + if (!l3cd) + return TRUE; + + if (NM_IN_SET(addr_family, AF_UNSPEC, AF_INET) + && NM_FLAGS_HAS(flags, NM_L3CFG_CHECK_READY_FLAGS_IP4_ACD_READY)) { + gboolean pending = FALSE; + + nm_l3_config_data_iter_obj_for_each (&iter, l3cd, &obj, NMP_OBJECT_TYPE_IP4_ADDRESS) { + const NML3AcdAddrInfo *addr_info; + + addr_info = nm_l3cfg_get_acd_addr_info(self, NMP_OBJECT_CAST_IP4_ADDRESS(obj)->address); + if (!addr_info) { + /* We don't track the this address? That's odd. Not ready. */ + pending = TRUE; + } else { + if (addr_info->state <= NM_L3_ACD_ADDR_STATE_PROBING) { + /* Still probing. Not ready. */ + pending = TRUE; + } else if (addr_info->state == NM_L3_ACD_ADDR_STATE_USED) { + NM_SET_OUT(acd_used, TRUE); + } + } + /* we only care that we don't have ACD still pending. Otherwise we are ready, + * including if we have no addr_info about this address or the address is in use. */ + } + if (pending) + return FALSE; + } + + if (NM_IN_SET(addr_family, AF_UNSPEC, AF_INET6) + && NM_FLAGS_HAS(flags, NM_L3CFG_CHECK_READY_FLAGS_IP6_DAD_READY)) { + nm_l3_config_data_iter_obj_for_each (&iter, l3cd, &obj, NMP_OBJECT_TYPE_IP6_ADDRESS) { + ObjStateData *obj_state; + + obj_state = g_hash_table_lookup(self->priv.p->obj_state_hash, &obj); + + if (!obj_state) { + /* Hm, we don't track this object? That is odd. Not ready. */ + return FALSE; + } + + if (!obj_state->os_nm_configured && !obj_state->os_plobj) { + /* We didn't (yet) configure this address and it also is not in platform. + * Not ready. */ + return FALSE; + } + + if (obj_state->os_plobj + && NM_FLAGS_HAS(NMP_OBJECT_CAST_IP6_ADDRESS(obj_state->os_plobj)->n_ifa_flags, + IFA_F_TENTATIVE)) { + /* The address is configured in kernel, but still tentative. Not ready. */ + return FALSE; + } + + /* This address is ready. Even if it is not (not anymore) configured in kernel (as + * indicated by obj_state->os_plobj). We apparently did configure it once, and + * it's no longer tentative. This address are good. */ + } + } + + return TRUE; +} + +/*****************************************************************************/ + static gboolean _l3_commit_on_idle_cb(gpointer user_data) { - NML3Cfg *self = user_data; + _nm_unused gs_unref_object NML3Cfg *self_keep_alive = NULL; + NML3Cfg * self = user_data; + NML3CfgCommitType commit_type; + + commit_type = self->priv.p->commit_on_idle_type; + + if (nm_clear_g_source_inst(&self->priv.p->commit_on_idle_source)) + self_keep_alive = self; + else + nm_assert_not_reached(); - nm_clear_g_source_inst(&self->priv.p->commit_on_idle_source); + self->priv.p->commit_on_idle_type = NM_L3_CFG_COMMIT_TYPE_AUTO; - _LOGT("commit on idle"); - _l3_commit(self, NM_L3_CFG_COMMIT_TYPE_AUTO, TRUE); + _l3_commit(self, commit_type, TRUE); return G_SOURCE_REMOVE; } +/* DOC(l3cfg:commit-type): + * + * Usually we don't want to call the synchronous nm_l3cfg_commit(), because + * that has side effects and might not be safe to do (depending on the current + * circumstances in which commit is called). The usually proper thing to do + * is schedule a commit on an idle handler. Use this function. + * + * During commit, the actually used commit-type (that is, the level of "how much" + * will be synced) is determined by users who register their desired commit + * type via nm_l3cfg_commit_type_register(), where always the "maxium" is used. + * + * nm_l3cfg_commit() and nm_l3cfg_commit_on_idle_schedule() also accept an additional + * commit_type argument. This acts like a one-shot registration. + */ gboolean -nm_l3cfg_commit_on_idle_schedule(NML3Cfg *self) +nm_l3cfg_commit_on_idle_schedule(NML3Cfg *self, NML3CfgCommitType commit_type) { + char sbuf_commit_type[50]; + nm_assert(NM_IS_L3CFG(self)); + nm_assert(NM_IN_SET(commit_type, + NM_L3_CFG_COMMIT_TYPE_AUTO, + NM_L3_CFG_COMMIT_TYPE_ASSUME, + NM_L3_CFG_COMMIT_TYPE_UPDATE, + NM_L3_CFG_COMMIT_TYPE_REAPPLY)); - if (self->priv.p->commit_on_idle_source) + if (self->priv.p->commit_on_idle_source) { + if (self->priv.p->commit_on_idle_type < commit_type) { + /* For multiple calls, we collect the maximum "commit-type". */ + _LOGT("commit on idle (scheduled) (update to %s)", + _l3_cfg_commit_type_to_string(commit_type, + sbuf_commit_type, + sizeof(sbuf_commit_type))); + self->priv.p->commit_on_idle_type = commit_type; + } return FALSE; + } + + _LOGT("commit on idle (scheduled) (%s)", + _l3_cfg_commit_type_to_string(commit_type, sbuf_commit_type, sizeof(sbuf_commit_type))); + self->priv.p->commit_on_idle_source = nm_g_idle_add_source(_l3_commit_on_idle_cb, self); + self->priv.p->commit_on_idle_type = commit_type; + + /* While we have an idle update scheduled, we need to keep the instance alive. */ + g_object_ref(self); - _LOGT("commit on idle (scheduled)"); - self->priv.p->commit_on_idle_source = - nm_g_idle_source_new(G_PRIORITY_DEFAULT, _l3_commit_on_idle_cb, self, NULL); - g_source_attach(self->priv.p->commit_on_idle_source, NULL); return TRUE; } +gboolean +nm_l3cfg_commit_on_idle_is_scheduled(NML3Cfg *self) +{ + nm_assert(NM_IS_L3CFG(self)); + + return !!(self->priv.p->commit_on_idle_source); +} + /*****************************************************************************/ #define _l3_config_datas_at(l3_config_datas, idx) \ @@ -2695,8 +3040,11 @@ nm_l3cfg_add_config(NML3Cfg * self, guint32 default_route_metric_6, guint32 default_route_penalty_4, guint32 default_route_penalty_6, + int default_dns_priority_4, + int default_dns_priority_6, NML3AcdDefendType acd_defend_type, guint32 acd_timeout_msec, + NML3CfgConfigFlags config_flags, NML3ConfigMergeFlags merge_flags) { L3ConfigData *l3_config_data; @@ -2761,6 +3109,7 @@ nm_l3cfg_add_config(NML3Cfg * self, *l3_config_data = (L3ConfigData){ .tag_confdata = tag, .l3cd = nm_l3_config_data_ref_and_seal(l3cd), + .config_flags = config_flags, .merge_flags = merge_flags, .default_route_table_4 = default_route_table_4, .default_route_table_6 = default_route_table_6, @@ -2768,6 +3117,8 @@ nm_l3cfg_add_config(NML3Cfg * self, .default_route_metric_6 = default_route_metric_6, .default_route_penalty_4 = default_route_penalty_4, .default_route_penalty_6 = default_route_penalty_6, + .default_dns_priority_4 = default_dns_priority_4, + .default_dns_priority_6 = default_dns_priority_6, .acd_defend_type_confdata = acd_defend_type, .acd_timeout_msec_confdata = acd_timeout_msec, .priority_confdata = priority, @@ -2784,6 +3135,10 @@ nm_l3cfg_add_config(NML3Cfg * self, l3_config_data->priority_confdata = priority; changed = TRUE; } + if (l3_config_data->config_flags != config_flags) { + l3_config_data->config_flags = config_flags; + changed = TRUE; + } if (l3_config_data->merge_flags != merge_flags) { l3_config_data->merge_flags = merge_flags; changed = TRUE; @@ -2812,6 +3167,14 @@ nm_l3cfg_add_config(NML3Cfg * self, l3_config_data->default_route_penalty_6 = default_route_penalty_6; changed = TRUE; } + if (l3_config_data->default_dns_priority_4 != default_dns_priority_4) { + l3_config_data->default_dns_priority_4 = default_dns_priority_4; + changed = TRUE; + } + if (l3_config_data->default_dns_priority_6 != default_dns_priority_6) { + l3_config_data->default_dns_priority_6 = default_dns_priority_6; + changed = TRUE; + } if (l3_config_data->acd_defend_type_confdata != acd_defend_type) { l3_config_data->acd_defend_type_confdata = acd_defend_type; changed = TRUE; @@ -2879,17 +3242,23 @@ _l3cfg_remove_config(NML3Cfg * self, } gboolean -nm_l3cfg_remove_config(NML3Cfg *self, gconstpointer tag, const NML3ConfigData *ifcfg) +nm_l3cfg_remove_config(NML3Cfg *self, gconstpointer tag, const NML3ConfigData *l3cd) { - nm_assert(ifcfg); + nm_assert(l3cd); + + return _l3cfg_remove_config(self, tag, FALSE, l3cd); +} - return _l3cfg_remove_config(self, tag, FALSE, ifcfg); +gboolean +nm_l3cfg_remove_config_all(NML3Cfg *self, gconstpointer tag) +{ + return _l3cfg_remove_config(self, tag, FALSE, NULL); } gboolean -nm_l3cfg_remove_config_all(NML3Cfg *self, gconstpointer tag, gboolean only_dirty) +nm_l3cfg_remove_config_all_dirty(NML3Cfg *self, gconstpointer tag) { - return _l3cfg_remove_config(self, tag, only_dirty, NULL); + return _l3cfg_remove_config(self, tag, TRUE, NULL); } /*****************************************************************************/ @@ -2897,13 +3266,15 @@ nm_l3cfg_remove_config_all(NML3Cfg *self, gconstpointer tag, gboolean only_dirty typedef struct { NML3Cfg * self; gconstpointer tag; + bool assume_config_once; + bool to_commit; } L3ConfigMergeHookAddObjData; static gboolean -_l3_hook_add_addr_cb(const NML3ConfigData *l3cd, - const NMPObject * obj, - NMTernary * out_ip4acd_not_ready, - gpointer user_data) +_l3_hook_add_obj_cb(const NML3ConfigData * l3cd, + const NMPObject * obj, + NML3ConfigMergeHookResult *hook_result, + gpointer user_data) { const L3ConfigMergeHookAddObjData *hook_data = user_data; NML3Cfg * self = hook_data->self; @@ -2911,40 +3282,68 @@ _l3_hook_add_addr_cb(const NML3ConfigData *l3cd, in_addr_t addr; gboolean acd_bad = FALSE; - nm_assert(out_ip4acd_not_ready && *out_ip4acd_not_ready == NM_TERNARY_DEFAULT); + nm_assert(obj); + nm_assert(hook_result); + nm_assert(hook_result->ip4acd_not_ready == NM_OPTION_BOOL_DEFAULT); + nm_assert(hook_result->assume_config_once == NM_OPTION_BOOL_DEFAULT); - if (NMP_OBJECT_GET_TYPE(obj) != NMP_OBJECT_TYPE_IP4_ADDRESS) - return TRUE; + hook_result->assume_config_once = hook_data->assume_config_once; - addr = NMP_OBJECT_CAST_IP4_ADDRESS(obj)->address; + switch (NMP_OBJECT_GET_TYPE(obj)) { + case NMP_OBJECT_TYPE_IP4_ADDRESS: - if (ACD_ADDR_SKIP(addr)) - goto out; + addr = NMP_OBJECT_CAST_IP4_ADDRESS(obj)->address; - acd_data = _l3_acd_data_find(self, addr); + if (ACD_ADDR_SKIP(addr)) + goto out_ip4_address; - if (!acd_data) { - /* we don't yet track an ACD state for this address. That can only - * happend during _l3cfg_update_combined_config() with !to_commit, - * where we didn't update the ACD state. - * - * This means, unless you actually commit, nm_l3cfg_get_combined_l3cd(self, get_commited = FALSE) - * won't consider IPv4 addresses ready, that have no known ACD state yet. */ - nm_assert(self->priv.p->changed_configs_acd_state); - acd_bad = TRUE; - goto out; - } + acd_data = _l3_acd_data_find(self, addr); - nm_assert( - _acd_track_data_is_not_dirty(_acd_data_find_track(acd_data, l3cd, obj, hook_data->tag))); - if (!NM_IN_SET(acd_data->info.state, - NM_L3_ACD_ADDR_STATE_READY, - NM_L3_ACD_ADDR_STATE_DEFENDING)) - acd_bad = TRUE; + if (!hook_data->to_commit) { + nm_assert(self->priv.p->changed_configs_acd_state); + /* We don't do an actual commit in _l3cfg_update_combined_config(). That means our acd-data + * is not up to date. Check whether we have no acd_data ready, and if not, consider the address + * as not ready. It cannot be ready until the next commit starts ACD. */ + if (!acd_data) { + acd_bad = TRUE; + goto out_ip4_address; + } + nm_assert(({ + NML3AcdAddrTrackInfo *_ti = + _acd_data_find_track(acd_data, l3cd, obj, hook_data->tag); -out: - *out_ip4acd_not_ready = acd_bad ? NM_TERNARY_TRUE : NM_TERNARY_FALSE; - return TRUE; + !_ti || _ti->_priv.acd_dirty_track; + })); + } else { + /* If we commit, we called _l3_acd_data_add_all(), thus our acd_data must be present + * and not dirty. */ + nm_assert(({ + NML3AcdAddrTrackInfo *_ti = + _acd_data_find_track(acd_data, l3cd, obj, hook_data->tag); + + _ti && !_ti->_priv.acd_dirty_track; + })); + } + + if (!NM_IN_SET(acd_data->info.state, + NM_L3_ACD_ADDR_STATE_READY, + NM_L3_ACD_ADDR_STATE_DEFENDING)) { + acd_bad = TRUE; + goto out_ip4_address; + } + +out_ip4_address: + hook_result->ip4acd_not_ready = acd_bad ? NM_OPTION_BOOL_TRUE : NM_OPTION_BOOL_FALSE; + return TRUE; + + default: + nm_assert_not_reached(); + /* fall-through */ + case NMP_OBJECT_TYPE_IP6_ADDRESS: + case NMP_OBJECT_TYPE_IP4_ROUTE: + case NMP_OBJECT_TYPE_IP6_ROUTE: + return TRUE; + } } static void @@ -3007,29 +3406,54 @@ _l3cfg_update_combined_config(NML3Cfg * self, if (l3_config_datas_len > 0) { L3ConfigMergeHookAddObjData hook_data = { - .self = self, + .self = self, + .to_commit = to_commit, }; l3cd = nm_l3_config_data_new(nm_platform_get_multi_idx(self->priv.platform), - self->priv.ifindex); + self->priv.ifindex, + NM_IP_CONFIG_SOURCE_UNKNOWN); for (i = 0; i < l3_config_datas_len; i++) { const L3ConfigData *l3cd_data = l3_config_datas_arr[i]; - if (NM_FLAGS_HAS(l3cd_data->merge_flags, NM_L3_CONFIG_MERGE_FLAGS_ONLY_FOR_ACD)) + if (NM_FLAGS_HAS(l3cd_data->config_flags, NM_L3CFG_CONFIG_FLAGS_ONLY_FOR_ACD)) continue; hook_data.tag = l3cd_data->tag_confdata; + hook_data.assume_config_once = + NM_FLAGS_HAS(l3cd_data->config_flags, NM_L3CFG_CONFIG_FLAGS_ASSUME_CONFIG_ONCE); + nm_l3_config_data_merge(l3cd, l3cd_data->l3cd, l3cd_data->merge_flags, l3cd_data->default_route_table_x, l3cd_data->default_route_metric_x, l3cd_data->default_route_penalty_x, - _l3_hook_add_addr_cb, + l3cd_data->default_dns_priority_x, + _l3_hook_add_obj_cb, &hook_data); } + for (i = 0; i < l3_config_datas_len; i++) { + const L3ConfigData *l3cd_data = l3_config_datas_arr[i]; + int IS_IPv4; + + if (NM_FLAGS_HAS(l3cd_data->config_flags, NM_L3CFG_CONFIG_FLAGS_ONLY_FOR_ACD)) + continue; + + for (IS_IPv4 = 1; IS_IPv4 >= 0; IS_IPv4--) { + nm_l3_config_data_add_dependent_device_routes( + l3cd, + IS_IPv4 ? AF_INET : AF_INET6, + l3cd_data->default_route_table_x[IS_IPv4], + l3cd_data->default_route_metric_x[IS_IPv4], + l3cd_data->l3cd); + } + } + + nm_l3_config_data_add_dependent_onlink_routes(l3cd, AF_UNSPEC); + nm_assert(l3cd); nm_assert(nm_l3_config_data_get_ifindex(l3cd) == self->priv.ifindex); @@ -3060,6 +3484,8 @@ out: nm_l3_config_data_ref(self->priv.p->combined_l3cd_merged); commited_changed = TRUE; + _obj_states_update_all(self); + _nm_l3cfg_emit_signal_notify_l3cd_changed(self, l3cd_commited_old, self->priv.p->combined_l3cd_commited, @@ -3095,75 +3521,45 @@ out: /*****************************************************************************/ -typedef struct { - const NMPObject *obj; - gint64 timestamp_msec; - bool dirty; -} RoutesTemporaryNotAvailableData; - -static void -_routes_temporary_not_available_data_free(gpointer user_data) -{ - RoutesTemporaryNotAvailableData *data = user_data; - - nmp_object_unref(data->obj); - nm_g_slice_free(data); -} - -#define ROUTES_TEMPORARY_NOT_AVAILABLE_MAX_AGE_MSEC ((gint64) 20000) - static gboolean _routes_temporary_not_available_timeout(gpointer user_data) { - RoutesTemporaryNotAvailableData *data; - NML3Cfg * self = NM_L3CFG(user_data); - GHashTableIter iter; - gint64 expiry_threshold_msec; - gboolean any_expired = FALSE; - gint64 now_msec; - gint64 oldest_msec; + NML3Cfg * self = NM_L3CFG(user_data); + ObjStateData *obj_state; + gint64 now_msec; + gint64 expiry_msec; - self->priv.p->routes_temporary_not_available_id = 0; + nm_clear_g_source_inst(&self->priv.p->obj_state_temporary_not_available_timeout_source); - if (!self->priv.p->routes_temporary_not_available_hash) - return G_SOURCE_REMOVE; + obj_state = c_list_first_entry(&self->priv.p->obj_state_temporary_not_available_lst_head, + ObjStateData, + os_temporary_not_available_lst); - /* we check the timeouts again. That is, because we allow to remove - * entries from routes_temporary_not_available_hash, without rescheduling - * out timeouts. */ + if (!obj_state) + return G_SOURCE_CONTINUE; now_msec = nm_utils_get_monotonic_timestamp_msec(); - expiry_threshold_msec = now_msec - ROUTES_TEMPORARY_NOT_AVAILABLE_MAX_AGE_MSEC; - oldest_msec = G_MAXINT64; + expiry_msec = obj_state->os_temporary_not_available_timestamp_msec + + ROUTES_TEMPORARY_NOT_AVAILABLE_MAX_AGE_MSEC; - g_hash_table_iter_init(&iter, self->priv.p->routes_temporary_not_available_hash); - while (g_hash_table_iter_next(&iter, (gpointer *) &data, NULL)) { - if (data->timestamp_msec >= expiry_threshold_msec) { - any_expired = TRUE; - break; - } - if (data->timestamp_msec < oldest_msec) - oldest_msec = data->timestamp_msec; - } - - if (any_expired) { - /* a route expired. We emit a signal, but we don't schedule it again. That will - * only happen if the user calls nm_l3cfg_commit() again. */ - _nm_l3cfg_emit_signal_notify_simple( - self, - NM_L3_CONFIG_NOTIFY_TYPE_ROUTES_TEMPORARY_NOT_AVAILABLE_EXPIRED); - return G_SOURCE_REMOVE; + if (now_msec < expiry_msec) { + /* the timeout is not yet reached. Restart the timer... */ + self->priv.p->obj_state_temporary_not_available_timeout_source = + nm_g_timeout_add_source(expiry_msec - now_msec, + _routes_temporary_not_available_timeout, + self); + return G_SOURCE_CONTINUE; } - if (oldest_msec != G_MAXINT64) { - /* we have a timeout still. Reschedule. */ - self->priv.p->routes_temporary_not_available_id = - g_timeout_add(oldest_msec + ROUTES_TEMPORARY_NOT_AVAILABLE_MAX_AGE_MSEC - now_msec, - _routes_temporary_not_available_timeout, - self); - } - return G_SOURCE_REMOVE; + /* One (or several) routes expired. We emit a signal, but we don't schedule it again. + * We expect the callers to commit again, which will one last time try to configure + * the route. If that again fails, we detect the timeout, log a warning and don't + * track the object as not temporary-not-available anymore. */ + _nm_l3cfg_emit_signal_notify_simple( + self, + NM_L3_CONFIG_NOTIFY_TYPE_ROUTES_TEMPORARY_NOT_AVAILABLE_EXPIRED); + return G_SOURCE_CONTINUE; } static gboolean @@ -3171,14 +3567,15 @@ _routes_temporary_not_available_update(NML3Cfg * self, int addr_family, GPtrArray *routes_temporary_not_available_arr) { - RoutesTemporaryNotAvailableData *data; - GHashTableIter iter; - gint64 oldest_msec; - gint64 now_msec; - gboolean prune_all = FALSE; - gboolean success = TRUE; - guint i; - + ObjStateData * obj_state; + ObjStateData * obj_state_safe; + gint64 now_msec; + gboolean prune_all = FALSE; + gboolean success = TRUE; + guint i; + const NMPClass *klass; + + klass = nmp_class_from_type(NMP_OBJECT_TYPE_IP_ROUTE(NM_IS_IPv4(addr_family))); now_msec = nm_utils_get_monotonic_timestamp_msec(); if (nm_g_ptr_array_len(routes_temporary_not_available_arr) <= 0) { @@ -3186,36 +3583,45 @@ _routes_temporary_not_available_update(NML3Cfg * self, goto out_prune; } - if (self->priv.p->routes_temporary_not_available_hash) { - g_hash_table_iter_init(&iter, self->priv.p->routes_temporary_not_available_hash); - while (g_hash_table_iter_next(&iter, (gpointer *) &data, NULL)) { - if (NMP_OBJECT_GET_ADDR_FAMILY(data->obj) == addr_family) - data->dirty = TRUE; + c_list_for_each_entry (obj_state, + &self->priv.p->obj_state_temporary_not_available_lst_head, + os_temporary_not_available_lst) { + if (NMP_OBJECT_GET_CLASS(obj_state->obj) == klass) { + nm_assert(obj_state->os_temporary_not_available_timestamp_msec > 0); + obj_state->os_tna_dirty = TRUE; } - } else { - self->priv.p->routes_temporary_not_available_hash = - g_hash_table_new_full(nmp_object_indirect_id_hash, - nmp_object_indirect_id_equal, - _routes_temporary_not_available_data_free, - NULL); } for (i = 0; i < routes_temporary_not_available_arr->len; i++) { const NMPObject *o = routes_temporary_not_available_arr->pdata[i]; - char sbuf[1024]; + char sbuf[sizeof(_nm_utils_to_string_buffer)]; nm_assert(NMP_OBJECT_GET_TYPE(o) == NMP_OBJECT_TYPE_IP_ROUTE(NM_IS_IPv4(addr_family))); - data = g_hash_table_lookup(self->priv.p->routes_temporary_not_available_hash, &o); + obj_state = g_hash_table_lookup(self->priv.p->obj_state_hash, &o); - if (data) { - if (!data->dirty) - continue; + if (!obj_state) { + /* Hm? We don't track this object? Very odd, a bug? */ + nm_assert_not_reached(); + continue; + } - nm_assert(data->timestamp_msec > 0 && data->timestamp_msec <= now_msec); + if (obj_state->os_temporary_not_available_timestamp_msec > 0) { + nm_assert(obj_state->os_temporary_not_available_timestamp_msec > 0 + && obj_state->os_temporary_not_available_timestamp_msec <= now_msec); - if (now_msec > data->timestamp_msec + ROUTES_TEMPORARY_NOT_AVAILABLE_MAX_AGE_MSEC) { - /* timeout. Could not add this address. */ + if (!obj_state->os_tna_dirty) { + /* Odd, this only can happen if routes_temporary_not_available_arr contains duplicates. + * It should not. */ + nm_assert_not_reached(); + continue; + } + + if (now_msec > obj_state->os_temporary_not_available_timestamp_msec + + ROUTES_TEMPORARY_NOT_AVAILABLE_MAX_AGE_MSEC) { + /* Timeout. Could not add this address. + * + * For now, keep it obj_state->os_tna_dirty and prune it below. */ _LOGW("failure to add IPv%c route: %s", nm_utils_addr_family_to_char(addr_family), nmp_object_to_string(o, NMP_OBJECT_TO_STRING_PUBLIC, sbuf, sizeof(sbuf))); @@ -3223,7 +3629,7 @@ _routes_temporary_not_available_update(NML3Cfg * self, continue; } - data->dirty = FALSE; + obj_state->os_tna_dirty = FALSE; continue; } @@ -3231,47 +3637,229 @@ _routes_temporary_not_available_update(NML3Cfg * self, nm_utils_addr_family_to_char(addr_family), nmp_object_to_string(o, NMP_OBJECT_TO_STRING_PUBLIC, sbuf, sizeof(sbuf))); - data = g_slice_new(RoutesTemporaryNotAvailableData); - *data = (RoutesTemporaryNotAvailableData){ - .obj = nmp_object_ref(o), - .timestamp_msec = now_msec, - .dirty = FALSE, - }; - g_hash_table_add(self->priv.p->routes_temporary_not_available_hash, data); + obj_state->os_tna_dirty = FALSE; + obj_state->os_temporary_not_available_timestamp_msec = now_msec; + c_list_link_tail(&self->priv.p->obj_state_temporary_not_available_lst_head, + &obj_state->os_temporary_not_available_lst); } out_prune: - oldest_msec = G_MAXINT64; - - if (self->priv.p->routes_temporary_not_available_hash) { - g_hash_table_iter_init(&iter, self->priv.p->routes_temporary_not_available_hash); - while (g_hash_table_iter_next(&iter, (gpointer *) &data, NULL)) { - nm_assert(NMP_OBJECT_GET_ADDR_FAMILY(data->obj) == addr_family || !data->dirty); - if (!prune_all && !data->dirty) { - if (data->timestamp_msec < oldest_msec) - oldest_msec = data->timestamp_msec; - continue; + c_list_for_each_entry_safe (obj_state, + obj_state_safe, + &self->priv.p->obj_state_temporary_not_available_lst_head, + os_temporary_not_available_lst) { + if (prune_all || obj_state->os_tna_dirty) { + if (NMP_OBJECT_GET_CLASS(obj_state->obj) == klass) { + obj_state->os_temporary_not_available_timestamp_msec = 0; + c_list_unlink(&obj_state->os_temporary_not_available_lst); } - g_hash_table_iter_remove(&iter); } - if (oldest_msec != G_MAXINT64) - nm_clear_pointer(&self->priv.p->routes_temporary_not_available_hash, - g_hash_table_unref); } - nm_clear_g_source(&self->priv.p->routes_temporary_not_available_id); - if (oldest_msec != G_MAXINT64) { - nm_assert(oldest_msec + ROUTES_TEMPORARY_NOT_AVAILABLE_MAX_AGE_MSEC < now_msec); - self->priv.p->routes_temporary_not_available_id = - g_timeout_add(oldest_msec + ROUTES_TEMPORARY_NOT_AVAILABLE_MAX_AGE_MSEC - now_msec, - _routes_temporary_not_available_timeout, - self); + nm_clear_g_source_inst(&self->priv.p->obj_state_temporary_not_available_timeout_source); + + obj_state = c_list_first_entry(&self->priv.p->obj_state_temporary_not_available_lst_head, + ObjStateData, + os_temporary_not_available_lst); + if (obj_state) { + self->priv.p->obj_state_temporary_not_available_timeout_source = + nm_g_timeout_add_source((obj_state->os_temporary_not_available_timestamp_msec + + ROUTES_TEMPORARY_NOT_AVAILABLE_MAX_AGE_MSEC - now_msec), + _routes_temporary_not_available_timeout, + self); } return success; } /*****************************************************************************/ +static const char * +ip6_privacy_to_str(NMSettingIP6ConfigPrivacy ip6_privacy) +{ + switch (ip6_privacy) { + case NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED: + return "0"; + case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR: + return "1"; + case NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR: + return "2"; + case NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN: + break; + } + return nm_assert_unreachable_val("0"); +} + +static void +_l3_commit_ndisc_params(NML3Cfg *self, NML3CfgCommitType commit_type) +{ + const NML3ConfigData *l3cd; + gboolean retrans_set = FALSE; + gboolean reachable_set = FALSE; + gboolean hop_limit_set = FALSE; + guint32 reachable = 0; + guint32 retrans = 0; + int hop_limit = 0; + const char * ifname; + + if (commit_type < NM_L3_CFG_COMMIT_TYPE_UPDATE) { + self->priv.p->ndisc_reachable_time_msec_set = FALSE; + self->priv.p->ndisc_retrans_timer_msec_set = FALSE; + self->priv.p->ndisc_hop_limit_set = FALSE; + return; + } + + l3cd = self->priv.p->combined_l3cd_commited; + if (l3cd) { + reachable_set = nm_l3_config_data_get_ndisc_reachable_time_msec(l3cd, &reachable); + retrans_set = nm_l3_config_data_get_ndisc_retrans_timer_msec(l3cd, &retrans); + hop_limit = nm_l3_config_data_get_ndisc_hop_limit(l3cd, &hop_limit); + } + ifname = nm_l3cfg_get_ifname(self, TRUE); + + if (reachable_set + && (!self->priv.p->ndisc_reachable_time_msec_set + || self->priv.p->ndisc_reachable_time_msec != reachable)) { + self->priv.p->ndisc_reachable_time_msec = reachable; + self->priv.p->ndisc_reachable_time_msec_set = TRUE; + if (ifname) { + nm_platform_sysctl_ip_neigh_set_ipv6_reachable_time(self->priv.platform, + ifname, + reachable); + } + } + + if (retrans_set + && (!self->priv.p->ndisc_retrans_timer_msec_set + || self->priv.p->ndisc_reachable_time_msec != retrans)) { + self->priv.p->ndisc_retrans_timer_msec = retrans; + self->priv.p->ndisc_retrans_timer_msec_set = TRUE; + if (ifname) { + nm_platform_sysctl_ip_neigh_set_ipv6_retrans_time(self->priv.platform, ifname, retrans); + } + } + + if (hop_limit_set + && (!self->priv.p->ndisc_hop_limit_set || self->priv.p->ndisc_hop_limit != hop_limit)) { + self->priv.p->ndisc_hop_limit = hop_limit; + self->priv.p->ndisc_hop_limit_set = TRUE; + if (ifname) { + nm_platform_sysctl_ip_conf_set_ipv6_hop_limit_safe(self->priv.platform, + ifname, + hop_limit); + } + } + + // FIXME: restore values if necessary +} + +static void +_l3_commit_ip6_privacy(NML3Cfg *self, NML3CfgCommitType commit_type) +{ + NMSettingIP6ConfigPrivacy ip6_privacy; + NMSettingIP6ConfigPrivacy ip6_privacy_set_before; + const char * ifname; + + if (commit_type < NM_L3_CFG_COMMIT_TYPE_UPDATE) + ip6_privacy = NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN; + else + ip6_privacy = nm_l3_config_data_get_ip6_privacy(self->priv.p->combined_l3cd_commited); + + if (ip6_privacy == NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN) { + if (!self->priv.p->ip6_privacy_set) { + /* Nothing to set. But do we need to reset a previous value? */ + return; + } + self->priv.p->ip6_privacy_set = FALSE; + ip6_privacy = self->priv.p->ip6_privacy_initial; + ifname = nm_l3cfg_get_ifname(self, TRUE); + _LOGT("commit-ip6-privacy: reset initial value %d (was %d)%s%s", + (int) ip6_privacy, + (int) self->priv.p->ip6_privacy_set_before, + NM_PRINT_FMT_QUOTED2(ifname, ", ifname ", ifname, " (skip, no interface)")); + if (ip6_privacy == NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN) + return; + if (!ifname) + return; + goto set; + } + + nm_assert(NM_IN_SET(ip6_privacy, + NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED, + NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR, + NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR)); + + if (self->priv.p->ip6_privacy_set && self->priv.p->ip6_privacy_set_before == ip6_privacy + && commit_type < NM_L3_CFG_COMMIT_TYPE_REAPPLY) { + /* Already set. We leave this alone except during reapply. */ + return; + } + + ip6_privacy_set_before = self->priv.p->ip6_privacy_set_before; + self->priv.p->ip6_privacy_set_before = ip6_privacy; + + if (!self->priv.p->ip6_privacy_set) { + gint64 s = G_MININT64; + + self->priv.p->ip6_privacy_set = TRUE; + ifname = nm_l3cfg_get_ifname(self, TRUE); + if (ifname) { + s = nm_platform_sysctl_ip_conf_get_int_checked(self->priv.platform, + AF_INET6, + ifname, + "use_tempaddr", + 10, + G_MININT32, + G_MAXINT32, + G_MININT64); + if (s != G_MININT64) + s = NM_CLAMP(s, 0, 2); + } + switch (s) { + case 0: + self->priv.p->ip6_privacy_initial = NM_SETTING_IP6_CONFIG_PRIVACY_DISABLED; + break; + case 1: + self->priv.p->ip6_privacy_initial = NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_PUBLIC_ADDR; + break; + case 2: + self->priv.p->ip6_privacy_initial = NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR; + break; + default: + nm_assert_not_reached(); + /* fall-through */ + case G_MININT64: + self->priv.p->ip6_privacy_initial = NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN; + break; + } + _LOGT("commit-ip6-privacy: set value %d (initial value was %d)%s%s", + (int) ip6_privacy, + (int) self->priv.p->ip6_privacy_initial, + NM_PRINT_FMT_QUOTED2(ifname, ", ifname ", ifname, " (skip, no interface)")); + if (!ifname) + return; + /* The first time, we always set the value, and don't skip it based on what we + * read. */ + goto set; + } + + ifname = nm_l3cfg_get_ifname(self, TRUE); + _LOGT("commit-ip6-privacy: set value %d (after %d, initial value was %d)%s%s", + (int) ip6_privacy, + (int) ip6_privacy_set_before, + (int) self->priv.p->ip6_privacy_initial, + NM_PRINT_FMT_QUOTED2(ifname, ", ifname ", ifname, " (skip, no interface)")); + if (!ifname) + return; + +set: + nm_assert(ifname); + self->priv.p->ip6_privacy_set_before = ip6_privacy; + nm_platform_sysctl_ip_conf_set(self->priv.platform, + AF_INET6, + ifname, + "use_tempaddr", + ip6_privacy_to_str(ip6_privacy)); +} static gboolean _l3_commit_one(NML3Cfg * self, @@ -3303,58 +3891,35 @@ _l3_commit_one(NML3Cfg * self, nm_utils_addr_family_to_char(addr_family), _l3_cfg_commit_type_to_string(commit_type, sbuf_commit_type, sizeof(sbuf_commit_type))); - if (changed_combined_l3cd) { - /* our combined configuration changed. We may track entries in externally_removed_objs_hash, - * which are not longer to be considered by our configuration. We need to forget about them. */ - _l3cfg_externally_removed_objs_drop_unused(self); - } - - if (commit_type == NM_L3_CFG_COMMIT_TYPE_ASSUME) { - /* we need to artificially pre-populate the externally remove hash. */ - _l3cfg_externally_removed_objs_pickup(self, addr_family); - } - if (self->priv.p->combined_l3cd_commited) { - GHashTable * externally_removed_objs_hash; - NMDedupMultiFcnSelectPredicate predicate; - const NMDedupMultiHeadEntry * head_entry; - - if (commit_type != NM_L3_CFG_COMMIT_TYPE_REAPPLY - && self->priv.p->externally_removed_objs_cnt_addresses_x[IS_IPv4] > 0) { - predicate = _l3cfg_externally_removed_objs_filter; - externally_removed_objs_hash = self->priv.p->externally_removed_objs_hash; - } else { - if (IS_IPv4) - predicate = _l3cfg_externally_removed_objs_filter; - else - predicate = NULL; - externally_removed_objs_hash = NULL; - } + const NMDedupMultiHeadEntry * head_entry; + const ObjStatesSyncFilterData sync_filter_data = { + .self = self, + .commit_type = commit_type, + }; + head_entry = nm_l3_config_data_lookup_objs(self->priv.p->combined_l3cd_commited, NMP_OBJECT_TYPE_IP_ADDRESS(IS_IPv4)); addresses = nm_dedup_multi_objs_to_ptr_array_head(head_entry, - predicate, - externally_removed_objs_hash); + _obj_states_sync_filter, + (gpointer) &sync_filter_data); - if (commit_type != NM_L3_CFG_COMMIT_TYPE_REAPPLY - && self->priv.p->externally_removed_objs_cnt_routes_x[IS_IPv4] > 0) { - predicate = _l3cfg_externally_removed_objs_filter; - externally_removed_objs_hash = self->priv.p->externally_removed_objs_hash; - } else { - predicate = NULL; - externally_removed_objs_hash = NULL; - } head_entry = nm_l3_config_data_lookup_objs(self->priv.p->combined_l3cd_commited, NMP_OBJECT_TYPE_IP_ROUTE(IS_IPv4)); routes = nm_dedup_multi_objs_to_ptr_array_head(head_entry, - predicate, - externally_removed_objs_hash); + _obj_states_sync_filter, + (gpointer) &sync_filter_data); route_table_sync = nm_l3_config_data_get_route_table_sync(self->priv.p->combined_l3cd_commited, addr_family); } + if (!IS_IPv4) { + _l3_commit_ip6_privacy(self, commit_type); + _l3_commit_ndisc_params(self, commit_type); + } + if (route_table_sync == NM_IP_ROUTE_TABLE_SYNC_MODE_NONE) route_table_sync = NM_IP_ROUTE_TABLE_SYNC_MODE_ALL; @@ -3367,17 +3932,11 @@ _l3_commit_one(NML3Cfg * self, addr_family, self->priv.ifindex, route_table_sync); - } else if (commit_type == NM_L3_CFG_COMMIT_TYPE_UPDATE) { - addresses_prune = nm_g_ptr_array_ref(self->priv.p->last_addresses_x[IS_IPv4]); - routes_prune = nm_g_ptr_array_ref(self->priv.p->last_routes_x[IS_IPv4]); - } - - nm_g_ptr_array_set(&self->priv.p->last_addresses_x[IS_IPv4], addresses); - nm_g_ptr_array_set(&self->priv.p->last_routes_x[IS_IPv4], routes); + _obj_state_zombie_lst_prune_all(self, addr_family); + } else + _obj_state_zombie_lst_get_prune_lists(self, addr_family, &addresses_prune, &routes_prune); - /* FIXME(l3cfg): need to honor and set nm_l3_config_data_get_ip6_privacy(). */ /* FIXME(l3cfg): need to honor and set nm_l3_config_data_get_ndisc_*(). */ - /* FIXME(l3cfg): need to honor and set nm_l3_config_data_get_ip6_mtu(). */ /* FIXME(l3cfg): need to honor and set nm_l3_config_data_get_mtu(). */ nm_platform_ip_address_sync(self->priv.platform, @@ -3409,8 +3968,11 @@ _l3_commit_one(NML3Cfg * self, static void _l3_commit(NML3Cfg *self, NML3CfgCommitType commit_type, gboolean is_idle) { - nm_auto_unref_l3cd const NML3ConfigData *l3cd_old = NULL; - gboolean commit_type_detected = FALSE; + _nm_unused gs_unref_object NML3Cfg *self_keep_alive = NULL; + nm_auto_unref_l3cd const NML3ConfigData *l3cd_old = NULL; + NML3CfgCommitType commit_type_auto; + gboolean commit_type_from_auto = FALSE; + gboolean is_sticky_update = FALSE; char sbuf_ct[30]; gboolean changed_combined_l3cd; @@ -3423,44 +3985,45 @@ _l3_commit(NML3Cfg *self, NML3CfgCommitType commit_type, gboolean is_idle) NM_L3_CFG_COMMIT_TYPE_REAPPLY)); nm_assert(self->priv.p->commit_reentrant_count == 0); - switch (commit_type) { - case NM_L3_CFG_COMMIT_TYPE_AUTO: - /* if in "AUTO" mode we currently have commit-type "UPDATE", that - * causes also the following update to still be "UPDATE". Either - * the same commit */ - commit_type_detected = TRUE; - commit_type = nm_l3cfg_commit_type_get(self); - if (commit_type == NM_L3_CFG_COMMIT_TYPE_UPDATE) - self->priv.p->commit_type_update_sticky = TRUE; - else if (self->priv.p->commit_type_update_sticky) { + /* The actual commit type is always the maximum of what is requested + * and what is registered via nm_l3cfg_commit_type_register(), combined + * with the ad-hoc requested @commit_type argument. */ + commit_type_auto = nm_l3cfg_commit_type_get(self); + if (commit_type == NM_L3_CFG_COMMIT_TYPE_AUTO || commit_type_auto > commit_type) { + commit_type_from_auto = TRUE; + commit_type = commit_type_auto; + } + + /* Levels UPDATE and higher are sticky. That means, when do perform such a commit + * type, then the next one will at least be of level "UPDATE". The idea is + * that if the current commit adds an address, then the following needs + * to do at least "UPDATE" level to remove it again. Even if in the meantime + * the "UPDATE" is unregistered (nm_l3cfg_commit_type_unregister()). */ + if (commit_type < NM_L3_CFG_COMMIT_TYPE_UPDATE) { + if (self->priv.p->commit_type_update_sticky) { self->priv.p->commit_type_update_sticky = FALSE; commit_type = NM_L3_CFG_COMMIT_TYPE_UPDATE; + is_sticky_update = TRUE; } - break; - case NM_L3_CFG_COMMIT_TYPE_ASSUME: - break; - case NM_L3_CFG_COMMIT_TYPE_REAPPLY: - case NM_L3_CFG_COMMIT_TYPE_UPDATE: - self->priv.p->commit_type_update_sticky = FALSE; - break; - case NM_L3_CFG_COMMIT_TYPE_NONE: - break; - } + } else + self->priv.p->commit_type_update_sticky = TRUE; - _LOGT("commit %s%s%s", + _LOGT("commit %s%s%s%s", _l3_cfg_commit_type_to_string(commit_type, sbuf_ct, sizeof(sbuf_ct)), - commit_type_detected ? " (auto)" : "", + commit_type_from_auto ? " (auto)" : "", + is_sticky_update ? " (sticky-update)" : "", is_idle ? " (idle handler)" : ""); - if (commit_type == NM_L3_CFG_COMMIT_TYPE_NONE) - return; + nm_assert(commit_type > NM_L3_CFG_COMMIT_TYPE_AUTO); - self->priv.p->commit_reentrant_count++; + if (nm_clear_g_source_inst(&self->priv.p->commit_on_idle_source)) + self_keep_alive = self; + self->priv.p->commit_on_idle_type = NM_L3_CFG_COMMIT_TYPE_AUTO; - nm_clear_g_source_inst(&self->priv.p->commit_on_idle_source); + if (commit_type <= NM_L3_CFG_COMMIT_TYPE_NONE) + return; - if (commit_type == NM_L3_CFG_COMMIT_TYPE_REAPPLY) - _l3cfg_externally_removed_objs_drop(self); + self->priv.p->commit_reentrant_count++; _l3cfg_update_combined_config(self, TRUE, @@ -3468,7 +4031,7 @@ _l3_commit(NML3Cfg *self, NML3CfgCommitType commit_type, gboolean is_idle) &l3cd_old, &changed_combined_l3cd); - /* FIXME(l3cfg): handle items currently not configurable in kernel. */ + _nm_l3cfg_emit_signal_notify_simple(self, NM_L3_CONFIG_NOTIFY_TYPE_PRE_COMMIT); _l3_commit_one(self, AF_INET, commit_type, changed_combined_l3cd, l3cd_old); _l3_commit_one(self, AF_INET6, commit_type, changed_combined_l3cd, l3cd_old); @@ -3481,6 +4044,7 @@ _l3_commit(NML3Cfg *self, NML3CfgCommitType commit_type, gboolean is_idle) _nm_l3cfg_emit_signal_notify_simple(self, NM_L3_CONFIG_NOTIFY_TYPE_POST_COMMIT); } +/* See DOC(l3cfg:commit-type) */ void nm_l3cfg_commit(NML3Cfg *self, NML3CfgCommitType commit_type) { @@ -3508,29 +4072,39 @@ nm_l3cfg_commit_type_get(NML3Cfg *self) * @commit_type: the commit type to register * @existing_handle: instead of being a new registration, update an existing handle. * This may be %NULL, which is like having no previous registration. + * @source: the source of the commit type, for logging. * * NML3Cfg needs to know whether it is in charge of an interface (and how "much"). * By default, it is not in charge, but various users can register themself with * a certain @commit_type. The "higher" commit type is the used one when calling * nm_l3cfg_commit() with %NM_L3_CFG_COMMIT_TYPE_AUTO. * - * Returns: a handle tracking the registration, or %NULL of @commit_type + * Returns: a handle tracking the registration, or %NULL if @commit_type * is %NM_L3_CFG_COMMIT_TYPE_NONE. */ NML3CfgCommitTypeHandle * nm_l3cfg_commit_type_register(NML3Cfg * self, NML3CfgCommitType commit_type, - NML3CfgCommitTypeHandle *existing_handle) + NML3CfgCommitTypeHandle *existing_handle, + const char * source) { NML3CfgCommitTypeHandle *handle; NML3CfgCommitTypeHandle *h; gboolean linked; + NML3CfgCommitTypeHandle *ret = NULL; + char buf[64]; nm_assert(NM_IS_L3CFG(self)); nm_assert(NM_IN_SET(commit_type, NM_L3_CFG_COMMIT_TYPE_NONE, NM_L3_CFG_COMMIT_TYPE_ASSUME, NM_L3_CFG_COMMIT_TYPE_UPDATE)); + + /* It would be easy (and maybe convenient) to allow that @existing_handle + * can currently be registered on another NML3Cfg instance. But then we couldn't + * do this assertion, and it seems error prone to allow arbitrary handles where + * we cannot check whether it is valid. So if @existing_handle is given, it + * must be tracked by @self (and only by @self). */ nm_assert( !existing_handle || c_list_contains(&self->priv.p->commit_type_lst_head, &existing_handle->commit_type_lst)); @@ -3538,21 +4112,24 @@ nm_l3cfg_commit_type_register(NML3Cfg * self, if (existing_handle) { if (commit_type == NM_L3_CFG_COMMIT_TYPE_NONE) { nm_l3cfg_commit_type_unregister(self, existing_handle); - return NULL; + goto out; + } + if (existing_handle->commit_type == commit_type) { + ret = existing_handle; + goto out; } - if (existing_handle->commit_type == commit_type) - return existing_handle; c_list_unlink_stale(&existing_handle->commit_type_lst); handle = existing_handle; } else { if (commit_type == NM_L3_CFG_COMMIT_TYPE_NONE) - return NULL; - handle = g_slice_new(NML3CfgCommitTypeHandle); - handle->commit_type = commit_type; + goto out; + handle = g_slice_new(NML3CfgCommitTypeHandle); if (c_list_is_empty(&self->priv.p->commit_type_lst_head)) g_object_ref(self); } + handle->commit_type = commit_type; + linked = FALSE; c_list_for_each_entry (h, &self->priv.p->commit_type_lst_head, commit_type_lst) { if (handle->commit_type >= h->commit_type) { @@ -3564,7 +4141,15 @@ nm_l3cfg_commit_type_register(NML3Cfg * self, if (!linked) c_list_link_tail(&self->priv.p->commit_type_lst_head, &handle->commit_type_lst); - return handle; + ret = handle; +out: + _LOGT("commit type register (type \"%s\", source \"%s\", existing " NM_HASH_OBFUSCATE_PTR_FMT + ") -> " NM_HASH_OBFUSCATE_PTR_FMT "", + _l3_cfg_commit_type_to_string(commit_type, buf, sizeof(buf)), + source, + NM_HASH_OBFUSCATE_PTR(existing_handle), + NM_HASH_OBFUSCATE_PTR(ret)); + return ret; } void @@ -3577,6 +4162,8 @@ nm_l3cfg_commit_type_unregister(NML3Cfg *self, NML3CfgCommitTypeHandle *handle) nm_assert(c_list_contains(&self->priv.p->commit_type_lst_head, &handle->commit_type_lst)); + _LOGT("commit type unregister " NM_HASH_OBFUSCATE_PTR_FMT "", NM_HASH_OBFUSCATE_PTR(handle)); + c_list_unlink_stale(&handle->commit_type_lst); if (c_list_is_empty(&self->priv.p->commit_type_lst_head)) g_object_unref(self); @@ -3688,7 +4275,7 @@ _nm_l3cfg_unregister_ipv4ll(NML3Cfg *self) { nm_assert(NM_IS_L3CFG(self)); - /* we don't own the refernce to "self->priv.p->ipv4ll", but + /* we don't own the reference to "self->priv.p->ipv4ll", but * when that instance gets destroyed, we get called back to * forget about it. Basically, it's like a weak pointer. */ @@ -3747,6 +4334,14 @@ nm_l3cfg_init(NML3Cfg *self) c_list_init(&self->priv.p->acd_lst_head); c_list_init(&self->priv.p->acd_event_notify_lst_head); c_list_init(&self->priv.p->commit_type_lst_head); + c_list_init(&self->priv.p->obj_state_lst_head); + c_list_init(&self->priv.p->obj_state_temporary_not_available_lst_head); + c_list_init(&self->priv.p->obj_state_zombie_lst_head); + + self->priv.p->obj_state_hash = g_hash_table_new_full(nmp_object_indirect_id_hash, + nmp_object_indirect_id_equal, + _obj_state_data_free, + NULL); } static void @@ -3786,9 +4381,7 @@ finalize(GObject *object) nm_assert(c_list_is_empty(&self->priv.p->commit_type_lst_head)); - nm_clear_g_source_inst(&self->priv.p->commit_on_idle_source); - - nm_assert(nm_g_array_len(self->priv.p->property_emit_list) == 0u); + nm_assert(!self->priv.p->commit_on_idle_source); _l3_acd_data_prune(self, TRUE); @@ -3801,15 +4394,12 @@ finalize(GObject *object) nm_clear_g_source_inst(&self->priv.p->nacd_source); nm_clear_g_source_inst(&self->priv.p->nacd_instance_ensure_retry); - nm_clear_pointer(&self->priv.p->last_addresses_4, g_ptr_array_unref); - nm_clear_pointer(&self->priv.p->last_addresses_6, g_ptr_array_unref); - nm_clear_pointer(&self->priv.p->last_routes_4, g_ptr_array_unref); - nm_clear_pointer(&self->priv.p->last_routes_6, g_ptr_array_unref); - - nm_clear_g_source(&self->priv.p->routes_temporary_not_available_id); - nm_clear_pointer(&self->priv.p->routes_temporary_not_available_hash, g_hash_table_unref); + nm_clear_g_source_inst(&self->priv.p->obj_state_temporary_not_available_timeout_source); - nm_clear_pointer(&self->priv.p->externally_removed_objs_hash, g_hash_table_unref); + nm_clear_pointer(&self->priv.p->obj_state_hash, g_hash_table_destroy); + nm_assert(c_list_is_empty(&self->priv.p->obj_state_lst_head)); + nm_assert(c_list_is_empty(&self->priv.p->obj_state_temporary_not_available_lst_head)); + nm_assert(c_list_is_empty(&self->priv.p->obj_state_zombie_lst_head)); g_clear_object(&self->priv.netns); g_clear_object(&self->priv.platform); diff --git a/src/core/nm-l3cfg.h b/src/core/nm-l3cfg.h index 037f2178..19dec118 100644 --- a/src/core/nm-l3cfg.h +++ b/src/core/nm-l3cfg.h @@ -7,6 +7,7 @@ #include "nm-l3-config-data.h" #define NM_L3CFG_CONFIG_PRIORITY_IPV4LL 0 +#define NM_L3CFG_CONFIG_PRIORITY_IPV6LL 0 #define NM_ACD_TIMEOUT_RFC5227_MSEC 9000u #define NM_TYPE_L3CFG (nm_l3cfg_get_type()) @@ -22,12 +23,43 @@ #define NM_L3CFG_SIGNAL_NOTIFY "l3cfg-notify" typedef enum _nm_packed { - NM_L3_ACD_DEFEND_TYPE_NONE, + _NM_L3_ACD_DEFEND_TYPE_NONE, NM_L3_ACD_DEFEND_TYPE_NEVER, NM_L3_ACD_DEFEND_TYPE_ONCE, NM_L3_ACD_DEFEND_TYPE_ALWAYS, } NML3AcdDefendType; +/** + * NML3CfgConfigFlags: + * @NM_L3CFG_CONFIG_FLAGS_NONE: no flags, the default. + * @NM_L3_CONFIG_MERGE_FLAGS_ONLY_FOR_ACD: if this merge flag is set, + * the the NML3ConfigData doesn't get merged and it's information won't be + * synced. The only purpose is to run ACD on its IPv4 addresses, but + * regardless whether ACD succeeds/fails, the IP addresses won't be configured. + * The point is to run ACD first (without configuring it), and only + * commit the settings if requested. That can either happen by + * nm_l3cfg_add_config() the same NML3Cfg again (with a different + * tag), or by calling nm_l3cfg_add_config() again with this flag + * cleared (and the same tag). + * @NM_L3CFG_CONFIG_FLAGS_ASSUME_CONFIG_ONCE: a commit with + * %NM_L3_CFG_COMMIT_TYPE_ASSUME, means to not remove/add + * addresses that are missing/already exist. The assume mode + * is for taking over a device gracefully after restart, so + * it aims to preserve whatever was configured (or not configured). + * With this flag enabled, the first commit in assume mode will still + * add the addresses/routes. This is necessary for example with IPv6LL. + * Also while assuming a device, we want to configure things + * (like an IPv6 address), so we need to bypass the common + * "don't change" behavior. At least once. If the address/route + * is still not (no longer) configured on the subsequent + * commit, it's not getting added again. + */ +typedef enum _nm_packed { + NM_L3CFG_CONFIG_FLAGS_NONE = 0, + NM_L3CFG_CONFIG_FLAGS_ONLY_FOR_ACD = (1LL << 0), + NM_L3CFG_CONFIG_FLAGS_ASSUME_CONFIG_ONCE = (1LL << 1), +} NML3CfgConfigFlags; + typedef enum _nm_packed { NM_L3_ACD_ADDR_STATE_INIT, NM_L3_ACD_ADDR_STATE_PROBING, @@ -98,6 +130,12 @@ typedef enum { NM_L3_CONFIG_NOTIFY_TYPE_ACD_EVENT, + /* emitted before the merged l3cd is committed to platform. + * + * This event also gets emitted "under unsafe circumstances". + * See NM_L3_CONFIG_NOTIFY_TYPE_L3CD_CHANGED. */ + NM_L3_CONFIG_NOTIFY_TYPE_PRE_COMMIT, + /* emitted at the end of nm_l3cfg_platform_commit(). This signals also that * nm_l3cfg_is_ready() might have switched to TRUE. */ NM_L3_CONFIG_NOTIFY_TYPE_POST_COMMIT, @@ -105,7 +143,9 @@ typedef enum { /* NML3Cfg hooks to the NMPlatform signals for link, addresses and routes. * It re-emits the platform signal. * Contrary to NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE_ON_IDLE, this even - * is re-emitted synchronously. */ + * is re-emitted synchronously. You probably want to hook to the on-idle signal, + * unless you need to catch all intermediate changes too. Note that this + * event is not re-entrant safe (so beware what you are doing). */ NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE, /* NML3Cfg hooks to the NMPlatform signals for link, addresses and routes. @@ -235,6 +275,8 @@ nm_l3cfg_get_ifname(const NML3Cfg *self, gboolean get_next) return nmp_object_link_get_ifname(nm_l3cfg_get_plobj(self, get_next)); } +gboolean nm_l3cfg_is_vrf(const NML3Cfg *self); + static inline NMNetns * nm_l3cfg_get_netns(const NML3Cfg *self) { @@ -251,31 +293,12 @@ nm_l3cfg_get_platform(const NML3Cfg *self) return self->priv.platform; } -gboolean nm_l3cfg_get_acd_is_pending(NML3Cfg *self); - /*****************************************************************************/ void _nm_l3cfg_emit_signal_notify(NML3Cfg *self, const NML3ConfigNotifyData *notify_data); /*****************************************************************************/ -typedef enum { - NM_L3CFG_PROPERTY_EMIT_TYPE_ANY, - NM_L3CFG_PROPERTY_EMIT_TYPE_IP4_ROUTE, - NM_L3CFG_PROPERTY_EMIT_TYPE_IP6_ROUTE, -} NML3CfgPropertyEmitType; - -void nm_l3cfg_property_emit_register(NML3Cfg * self, - GObject * target_obj, - const GParamSpec * target_property, - NML3CfgPropertyEmitType emit_type); - -void nm_l3cfg_property_emit_unregister(NML3Cfg * self, - GObject * target_obj, - const GParamSpec *target_property); - -/*****************************************************************************/ - void nm_l3cfg_mark_config_dirty(NML3Cfg *self, gconstpointer tag, gboolean dirty); gboolean nm_l3cfg_add_config(NML3Cfg * self, @@ -289,17 +312,39 @@ gboolean nm_l3cfg_add_config(NML3Cfg * self, guint32 default_route_metric_6, guint32 default_route_penalty_4, guint32 default_route_penalty_6, + int default_dns_priority_4, + int default_dns_priority_6, NML3AcdDefendType acd_defend_type, guint32 acd_timeout_msec, + NML3CfgConfigFlags config_flags, NML3ConfigMergeFlags merge_flags); -gboolean nm_l3cfg_remove_config(NML3Cfg *self, gconstpointer tag, const NML3ConfigData *ifcfg); +gboolean nm_l3cfg_remove_config(NML3Cfg *self, gconstpointer tag, const NML3ConfigData *l3cd); -gboolean nm_l3cfg_remove_config_all(NML3Cfg *self, gconstpointer tag, gboolean only_dirty); +gboolean nm_l3cfg_remove_config_all(NML3Cfg *self, gconstpointer tag); +gboolean nm_l3cfg_remove_config_all_dirty(NML3Cfg *self, gconstpointer tag); /*****************************************************************************/ -/* The numeric values of the enum matters: higher number mean more "important". +/* DOC(l3cfg:commit-type): + * + * The major idea of NML3Cfg is that independent parties can register configuration + * (NML3ConfigData via nm_l3cfg_add_config()), and then nm_l3cfg_commit() will + * actually configure it. Usually we would not call the synchronous nm_l3cfg_commit(), + * but instead nm_l3cfg_commit_on_idle_schedule(). + * + * We have different levels of "how much" we should sync during commit. That is + * NML3CfgCommitType. Since independent parties should be able to work together, + * they can only ask for their minimal required commit-type level. That means, + * during commit we will commit with the highest level of how much one of the + * users request the commit. To request a commit level, users can call + * nm_l3cfg_commit_type_register(). nm_l3cfg_commit_on_idle_schedule() also + * accepts a one-time commit-type argument. + * + * This is related to NMDevice's sys_iface_state, which we use to control whether + * to touch/assume/manage the interface. + * + * The numeric values of the enum matters: higher number mean more "important". * E.g. "assume" tries to preserve the most settings, while "reapply" forces * all configuration to match. */ typedef enum _nm_packed { @@ -314,7 +359,10 @@ typedef enum _nm_packed { /* ASSUME means to keep any pre-existing extra routes/addresses, while * also not adding routes/addresses that are not present yet. This is to * gracefully take over after restart, where the existing IP configuration - * should not change. */ + * should not change. + * + * The flag NM_L3CFG_CONFIG_FLAGS_ASSUME_CONFIG_ONCE can make certain addresses/ + * routes commitable also during "assume". */ NM_L3_CFG_COMMIT_TYPE_ASSUME, /* UPDATE means to add new addresses/routes, while also removing addresses/routes @@ -331,24 +379,53 @@ typedef enum _nm_packed { void nm_l3cfg_commit(NML3Cfg *self, NML3CfgCommitType commit_type); -gboolean nm_l3cfg_commit_on_idle_schedule(NML3Cfg *self); +gboolean nm_l3cfg_commit_on_idle_schedule(NML3Cfg *self, NML3CfgCommitType commit_type); + +gboolean nm_l3cfg_commit_on_idle_is_scheduled(NML3Cfg *self); /*****************************************************************************/ +gboolean nm_l3cfg_get_acd_is_pending(NML3Cfg *self); + const NML3AcdAddrInfo *nm_l3cfg_get_acd_addr_info(NML3Cfg *self, in_addr_t addr); /*****************************************************************************/ +typedef enum { + NM_L3CFG_CHECK_READY_FLAGS_NONE = 0, + NM_L3CFG_CHECK_READY_FLAGS_IP4_ACD_READY = (1ull << 0), + NM_L3CFG_CHECK_READY_FLAGS_IP6_DAD_READY = (1ull << 1), +} NML3CfgCheckReadyFlags; + +gboolean nm_l3cfg_check_ready(NML3Cfg * self, + const NML3ConfigData * l3cd, + int addr_family, + NML3CfgCheckReadyFlags flags, + gboolean * acd_used); + +/*****************************************************************************/ + NML3CfgCommitType nm_l3cfg_commit_type_get(NML3Cfg *self); typedef struct _NML3CfgCommitTypeHandle NML3CfgCommitTypeHandle; NML3CfgCommitTypeHandle *nm_l3cfg_commit_type_register(NML3Cfg * self, NML3CfgCommitType commit_type, - NML3CfgCommitTypeHandle *existing_handle); + NML3CfgCommitTypeHandle *existing_handle, + const char * source); void nm_l3cfg_commit_type_unregister(NML3Cfg *self, NML3CfgCommitTypeHandle *handle); +static inline gboolean +nm_l3cfg_commit_type_clear(NML3Cfg *self, NML3CfgCommitTypeHandle **handle) +{ + if (!handle || !*handle) + return FALSE; + + nm_l3cfg_commit_type_unregister(self, g_steal_pointer(handle)); + return TRUE; +} + /*****************************************************************************/ const NML3ConfigData *nm_l3cfg_get_combined_l3cd(NML3Cfg *self, gboolean get_commited); diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index d859c1ea..3c9660c7 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -8,47 +8,46 @@ #include "nm-manager.h" -#include #include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include -#include "libnm-glib-aux/nm-c-list.h" - -#include "libnm-core-aux-intern/nm-common-macros.h" -#include "nm-dbus-manager.h" -#include "vpn/nm-vpn-manager.h" -#include "devices/nm-device.h" +#include "NetworkManagerUtils.h" +#include "devices/nm-device-factory.h" #include "devices/nm-device-generic.h" +#include "devices/nm-device.h" +#include "dhcp/nm-dhcp-manager.h" +#include "libnm-core-aux-intern/nm-common-macros.h" +#include "libnm-core-intern/nm-core-internal.h" +#include "libnm-glib-aux/nm-c-list.h" #include "libnm-platform/nm-platform.h" #include "libnm-platform/nmp-object.h" -#include "nm-hostname-manager.h" -#include "nm-keep-alive.h" -#include "nm-rfkill-manager.h" -#include "dhcp/nm-dhcp-manager.h" -#include "settings/nm-settings.h" -#include "settings/nm-settings-connection.h" -#include "nm-auth-utils.h" -#include "nm-auth-manager.h" -#include "NetworkManagerUtils.h" -#include "devices/nm-device-factory.h" -#include "nm-sleep-monitor.h" -#include "nm-connectivity.h" -#include "nm-policy.h" -#include "nm-session-monitor.h" +#include "libnm-std-aux/nm-dbus-compat.h" #include "nm-act-request.h" -#include "libnm-core-intern/nm-core-internal.h" -#include "nm-config.h" #include "nm-audit-manager.h" -#include "libnm-std-aux/nm-dbus-compat.h" -#include "nm-checkpoint.h" +#include "nm-auth-manager.h" +#include "nm-auth-utils.h" #include "nm-checkpoint-manager.h" +#include "nm-checkpoint.h" +#include "nm-config.h" +#include "nm-connectivity.h" +#include "nm-dbus-manager.h" #include "nm-dbus-object.h" #include "nm-dispatcher.h" -#include "NetworkManagerUtils.h" +#include "nm-hostname-manager.h" +#include "nm-keep-alive.h" +#include "nm-policy.h" +#include "nm-priv-helper-call.h" +#include "nm-rfkill-manager.h" +#include "nm-session-monitor.h" +#include "nm-sleep-monitor.h" +#include "settings/nm-settings-connection.h" +#include "settings/nm-settings.h" +#include "vpn/nm-vpn-manager.h" #define DEVICE_STATE_PRUNE_RATELIMIT_MAX 100u @@ -214,6 +213,13 @@ struct _NMManager { typedef struct { NMDBusObjectClass parent; + +#if WITH_OPENVSWITCH + /* these fields only serve the purpose to use the symbols.*/ + void (*_use_symbol_nm_priv_helper_call_get_fd)(void); + void (*_use_symbol_nm_priv_helper_utils_open_fd)(void); +#endif + } NMManagerClass; G_DEFINE_TYPE(NMManager, nm_manager, NM_TYPE_DBUS_OBJECT) @@ -2854,9 +2860,10 @@ recheck_assume_connection(NMManager *self, NMDevice *device) g_return_val_if_fail(NM_IS_DEVICE(device), FALSE); if (!nm_device_get_managed(device, FALSE)) { - /* If the device is only unmanaged by NM_UNMANAGED_PLATFORM_INIT, + /* If the device is unmanaged by NM_UNMANAGED_PLATFORM_INIT or NM_UNMANAGED_PARENT, * don't reset the state now but wait until it becomes managed. */ - if (nm_device_get_unmanaged_flags(device, NM_UNMANAGED_ALL) != NM_UNMANAGED_PLATFORM_INIT) + if (nm_device_get_unmanaged_flags(device, NM_UNMANAGED_ALL) + & ~(NM_UNMANAGED_PLATFORM_INIT | NM_UNMANAGED_PARENT)) nm_device_assume_state_reset(device); _LOG2D(LOGD_DEVICE, device, "assume: don't assume because %s", "not managed"); return FALSE; @@ -2867,7 +2874,7 @@ recheck_assume_connection(NMManager *self, NMDevice *device) _LOG2D(LOGD_DEVICE, device, "assume: don't assume due to device state %s", - nm_device_state_to_str(state)); + nm_device_state_to_string(state)); return FALSE; } @@ -3179,9 +3186,10 @@ _device_realize_finish(NMManager *self, NMDevice *device, const NMPlatformLink * nm_device_realize_finish(device, plink); if (!nm_device_get_managed(device, FALSE)) { - /* If the device is only unmanaged by NM_UNMANAGED_PLATFORM_INIT, + /* If the device is unmanaged by NM_UNMANAGED_PLATFORM_INIT or NM_UNMANAGED_PARENT, * don't reset the state now but wait until it becomes managed. */ - if (nm_device_get_unmanaged_flags(device, NM_UNMANAGED_ALL) != NM_UNMANAGED_PLATFORM_INIT) + if (nm_device_get_unmanaged_flags(device, NM_UNMANAGED_ALL) + & ~(NM_UNMANAGED_PLATFORM_INIT | NM_UNMANAGED_PARENT)) nm_device_assume_state_reset(device); return; } @@ -4751,7 +4759,7 @@ active_connection_parent_active(NMActiveConnection *active, NMSettingsConnection *sett_conn; NMDevice * parent; - g_signal_handlers_disconnect_by_func(active, (GCallback) active_connection_parent_active, self); + g_signal_handlers_disconnect_by_func(active, G_CALLBACK(active_connection_parent_active), self); if (!parent_ac) { _LOGW(LOGD_CORE, @@ -4926,7 +4934,7 @@ _internal_activate_device(NMManager *self, NMActiveConnection *active, GError ** /* We can't realize now; defer until the parent device is ready. */ g_signal_connect(active, NM_ACTIVE_CONNECTION_PARENT_ACTIVE, - (GCallback) active_connection_parent_active, + G_CALLBACK(active_connection_parent_active), self); nm_active_connection_set_parent(active, parent_ac); } else { @@ -6164,7 +6172,7 @@ sleep_devices_add(NMManager *self, NMDevice *device, gboolean suspending) g_hash_table_insert(priv->sleep_devices, g_object_ref(device), suspending ? nm_sleep_monitor_inhibit_take(priv->sleep_monitor) : NULL); - g_signal_connect(device, "notify::" NM_DEVICE_STATE, (GCallback) device_sleep_cb, self); + g_signal_connect(device, "notify::" NM_DEVICE_STATE, G_CALLBACK(device_sleep_cb), self); return TRUE; } @@ -8076,7 +8084,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) g_value_set_boolean(value, priv->sleeping); break; case PROP_DEVICES: - g_value_take_boxed(value, nm_utils_strv_make_deep_copied(_get_devices_paths(self, FALSE))); + g_value_take_boxed(value, nm_strv_make_deep_copied(_get_devices_paths(self, FALSE))); break; case PROP_METERED: g_value_set_uint(value, priv->metered); @@ -8087,12 +8095,12 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) nm_global_dns_config_to_dbus(dns_config, value); break; case PROP_ALL_DEVICES: - g_value_take_boxed(value, nm_utils_strv_make_deep_copied(_get_devices_paths(self, TRUE))); + g_value_take_boxed(value, nm_strv_make_deep_copied(_get_devices_paths(self, TRUE))); break; case PROP_CHECKPOINTS: g_value_take_boxed( value, - priv->checkpoint_mgr ? nm_utils_strv_make_deep_copied( + priv->checkpoint_mgr ? nm_strv_make_deep_copied( nm_checkpoint_manager_get_checkpoint_paths(priv->checkpoint_mgr, NULL)) : NULL); break; @@ -8530,6 +8538,16 @@ nm_manager_class_init(NMManagerClass *manager_class) GObjectClass * object_class = G_OBJECT_CLASS(manager_class); NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(manager_class); +#if WITH_OPENVSWITCH + /* Use the symbols. These symbols are in NetworkManager binary but will be + * used by the OVS device plugin. If we don't use the symbol here, it will + * be wrongly dropped. */ + manager_class->_use_symbol_nm_priv_helper_call_get_fd = + (void (*)(void)) nm_priv_helper_call_get_fd; + manager_class->_use_symbol_nm_priv_helper_utils_open_fd = + (void (*)(void)) nm_priv_helper_utils_open_fd; +#endif + dbus_object_class->export_path = NM_DBUS_EXPORT_PATH_STATIC(NM_DBUS_PATH); dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_manager); diff --git a/src/core/nm-netns.c b/src/core/nm-netns.c index d5a0317d..224070be 100644 --- a/src/core/nm-netns.c +++ b/src/core/nm-netns.c @@ -29,7 +29,7 @@ typedef struct { GHashTable * l3cfgs; GHashTable * shared_ips; CList l3cfg_signal_pending_lst_head; - guint signal_pending_idle_id; + GSource * signal_pending_idle_source; } NMNetnsPrivate; struct _NMNetns { @@ -189,7 +189,7 @@ _platform_signal_on_idle_cb(gpointer user_data) L3CfgData * l3cfg_data; CList work_list; - priv->signal_pending_idle_id = 0; + nm_clear_g_source_inst(&priv->signal_pending_idle_source); /* we emit all queued signals together. However, we don't want to hook the * main loop for longer than the currently queued elements. @@ -210,7 +210,7 @@ _platform_signal_on_idle_cb(gpointer user_data) nm_steal_int(&l3cfg_data->signal_pending_obj_type_flags)); } - return G_SOURCE_REMOVE; + return G_SOURCE_CONTINUE; } static void @@ -235,8 +235,9 @@ _platform_signal_cb(NMPlatform * platform, if (c_list_is_empty(&l3cfg_data->signal_pending_lst)) { c_list_link_tail(&priv->l3cfg_signal_pending_lst_head, &l3cfg_data->signal_pending_lst); - if (priv->signal_pending_idle_id == 0) - priv->signal_pending_idle_id = g_idle_add(_platform_signal_on_idle_cb, self); + if (!priv->signal_pending_idle_source) + priv->signal_pending_idle_source = + nm_g_idle_add_source(_platform_signal_on_idle_cb, self); } _nm_l3cfg_notify_platform_change(l3cfg_data->l3cfg, @@ -460,7 +461,7 @@ dispose(GObject *object) nm_assert(c_list_is_empty(&priv->l3cfg_signal_pending_lst_head)); nm_assert(!priv->shared_ips); - nm_clear_g_source(&priv->signal_pending_idle_id); + nm_clear_g_source_inst(&priv->signal_pending_idle_source); if (priv->platform) g_signal_handlers_disconnect_by_data(priv->platform, &priv->_self_signal_user_data); diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c index e147e504..03e082f1 100644 --- a/src/core/nm-policy.c +++ b/src/core/nm-policy.c @@ -322,7 +322,9 @@ ip6_remove_device_prefix_delegations(NMPolicy *self, NMDevice *device) } static void -device_ip6_prefix_delegated(NMDevice *device, NMPlatformIP6Address *prefix, gpointer user_data) +device_ip6_prefix_delegated(NMDevice * device, + const NMPlatformIP6Address *prefix, + gpointer user_data) { NMPolicyPrivate * priv = user_data; NMPolicy * self = _PRIV_TO_SELF(priv); @@ -913,7 +915,7 @@ update_system_hostname(NMPolicy *self, const char *msg) if (wait) { g_signal_connect(info->device, NM_DEVICE_DNS_LOOKUP_DONE, - (GCallback) device_dns_lookup_done, + G_CALLBACK(device_dns_lookup_done), self); return; } @@ -2057,7 +2059,7 @@ device_state_changed(NMDevice * device, _LOGD(LOGD_DEVICE, "blocking autoconnect of connection '%s': %s", nm_settings_connection_get_id(sett_conn), - NM_UTILS_LOOKUP_STR_A(nm_device_state_reason_to_str, + NM_UTILS_LOOKUP_STR_A(nm_device_state_reason_to_string, nm_device_state_reason_check(reason))); nm_settings_connection_autoconnect_blocked_reason_set(sett_conn, blocked_reason, @@ -2141,6 +2143,7 @@ device_ip_config_changed(NMDevice * device, NMPolicyPrivate *priv = user_data; NMPolicy * self = _PRIV_TO_SELF(priv); int addr_family; + NMDeviceState state; nm_assert(new_config || old_config); nm_assert(!new_config || NM_IS_IP_CONFIG(new_config)); @@ -2159,7 +2162,8 @@ device_ip_config_changed(NMDevice * device, * ignore IP config changes but when the device is in activated state. * Prevents unnecessary changes to DNS information. */ - if (nm_device_get_state(device) == NM_DEVICE_STATE_ACTIVATED) { + state = nm_device_get_state(device); + if (state > NM_DEVICE_STATE_IP_CONFIG && state <= NM_DEVICE_STATE_ACTIVATED) { if (old_config != new_config) { if (new_config) _dns_manager_set_ip_config(priv->dns_manager, @@ -2222,30 +2226,30 @@ devices_list_register(NMPolicy *self, NMDevice *device) NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE(self); /* Connect state-changed with _after, so that the handler is invoked after other handlers. */ - g_signal_connect_after(device, NM_DEVICE_STATE_CHANGED, (GCallback) device_state_changed, priv); + g_signal_connect_after(device, NM_DEVICE_STATE_CHANGED, G_CALLBACK(device_state_changed), priv); g_signal_connect(device, NM_DEVICE_IP4_CONFIG_CHANGED, - (GCallback) device_ip_config_changed, + G_CALLBACK(device_ip_config_changed), priv); g_signal_connect(device, NM_DEVICE_IP6_CONFIG_CHANGED, - (GCallback) device_ip_config_changed, + G_CALLBACK(device_ip_config_changed), priv); g_signal_connect(device, NM_DEVICE_IP6_PREFIX_DELEGATED, - (GCallback) device_ip6_prefix_delegated, + G_CALLBACK(device_ip6_prefix_delegated), priv); g_signal_connect(device, NM_DEVICE_IP6_SUBNET_NEEDED, - (GCallback) device_ip6_subnet_needed, + G_CALLBACK(device_ip6_subnet_needed), priv); g_signal_connect(device, "notify::" NM_DEVICE_AUTOCONNECT, - (GCallback) device_autoconnect_changed, + G_CALLBACK(device_autoconnect_changed), priv); g_signal_connect(device, NM_DEVICE_RECHECK_AUTO_ACTIVATE, - (GCallback) device_recheck_auto_activate, + G_CALLBACK(device_recheck_auto_activate), priv); } @@ -2801,49 +2805,49 @@ constructed(GObject *object) g_signal_connect(priv->hostname_manager, "notify::" NM_HOSTNAME_MANAGER_HOSTNAME, - (GCallback) hostname_changed, + G_CALLBACK(hostname_changed), priv); g_signal_connect(priv->manager, "notify::" NM_MANAGER_SLEEPING, - (GCallback) sleeping_changed, + G_CALLBACK(sleeping_changed), priv); g_signal_connect(priv->manager, "notify::" NM_MANAGER_NETWORKING_ENABLED, - (GCallback) sleeping_changed, + G_CALLBACK(sleeping_changed), priv); g_signal_connect(priv->manager, NM_MANAGER_INTERNAL_DEVICE_ADDED, - (GCallback) device_added, + G_CALLBACK(device_added), priv); g_signal_connect(priv->manager, NM_MANAGER_INTERNAL_DEVICE_REMOVED, - (GCallback) device_removed, + G_CALLBACK(device_removed), priv); g_signal_connect(priv->manager, NM_MANAGER_ACTIVE_CONNECTION_ADDED, - (GCallback) active_connection_added, + G_CALLBACK(active_connection_added), priv); g_signal_connect(priv->manager, NM_MANAGER_ACTIVE_CONNECTION_REMOVED, - (GCallback) active_connection_removed, + G_CALLBACK(active_connection_removed), priv); g_signal_connect(priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_ADDED, - (GCallback) connection_added, + G_CALLBACK(connection_added), priv); g_signal_connect(priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_UPDATED, - (GCallback) connection_updated, + G_CALLBACK(connection_updated), priv); g_signal_connect(priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_REMOVED, - (GCallback) connection_removed, + G_CALLBACK(connection_removed), priv); g_signal_connect(priv->settings, NM_SETTINGS_SIGNAL_CONNECTION_FLAGS_CHANGED, - (GCallback) connection_flags_changed, + G_CALLBACK(connection_flags_changed), priv); g_signal_connect(priv->agent_mgr, diff --git a/src/core/nm-priv-helper-call.c b/src/core/nm-priv-helper-call.c new file mode 100644 index 00000000..06249ece --- /dev/null +++ b/src/core/nm-priv-helper-call.c @@ -0,0 +1,101 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include "src/core/nm-default-daemon.h" + +#include "nm-priv-helper-call.h" + +#include + +#include "nm-dbus-manager.h" + +/*****************************************************************************/ + +static void +_nm_priv_helper_call_get_fd_cb(GObject *source, GAsyncResult *res, gpointer user_data) +{ + NMPrivHelperCallGetFDCallback callback; + gpointer callback_data; + gs_unref_variant GVariant *ret = NULL; + gs_free_error GError *error = NULL; + gs_unref_object GUnixFDList *fd_list = NULL; + gs_free int * fd_arr = NULL; + + nm_utils_user_data_unpack(user_data, &callback, &callback_data); + + ret = g_dbus_connection_call_with_unix_fd_list_finish(G_DBUS_CONNECTION(source), + &fd_list, + res, + &error); + + if (error) { + callback(-1, error, callback_data); + return; + } + + if (!fd_list || g_unix_fd_list_get_length(fd_list) != 1) { + nm_utils_error_set(&error, + NM_UTILS_ERROR_UNKNOWN, + "Unexpectedly not one FD is returned by nm-priv-helper GetFD()"); + callback(-1, error, callback_data); + return; + } + + fd_arr = g_unix_fd_list_steal_fds(fd_list, NULL); + + /* we transfer ownership of the file descriptor! */ + callback(fd_arr[0], NULL, callback_data); +} + +static gboolean +_nm_priv_helper_call_get_fd_fail_on_idle(gpointer user_data) +{ + gs_unref_object GCancellable *cancellable = NULL; + NMPrivHelperCallGetFDCallback callback; + gpointer callback_data; + gs_free_error GError *error = NULL; + + nm_utils_user_data_unpack(user_data, &cancellable, &callback, &callback_data); + + if (!g_cancellable_set_error_if_cancelled(cancellable, &error)) + nm_utils_error_set(&error, + NM_UTILS_ERROR_UNKNOWN, + "Cannot talk to nm-priv-helper without D-Bus"); + + callback(-1, error, callback_data); + return G_SOURCE_REMOVE; +} + +void +nm_priv_helper_call_get_fd(NMPrivHelperGetFDType fd_type, + GCancellable * cancellable, + NMPrivHelperCallGetFDCallback callback, + gpointer user_data) +{ + GDBusConnection *dbus_connection; + + nm_assert(NM_IN_SET(fd_type, NM_PRIV_HELPER_GET_FD_TYPE_OVSDB_SOCKET)); + nm_assert(!cancellable || G_IS_CANCELLABLE(cancellable)); + nm_assert(callback); + + dbus_connection = NM_MAIN_DBUS_CONNECTION_GET; + + if (!dbus_connection) { + nm_g_idle_add(_nm_priv_helper_call_get_fd_fail_on_idle, + nm_utils_user_data_pack(g_object_ref(cancellable), callback, user_data)); + return; + } + + g_dbus_connection_call_with_unix_fd_list(dbus_connection, + NM_PRIV_HELPER_DBUS_BUS_NAME, + NM_PRIV_HELPER_DBUS_OBJECT_PATH, + NM_PRIV_HELPER_DBUS_IFACE_NAME, + "GetFD", + g_variant_new("(u)", fd_type), + G_VARIANT_TYPE("()"), + G_DBUS_CALL_FLAGS_NONE, + 10000, + NULL, + cancellable, + _nm_priv_helper_call_get_fd_cb, + nm_utils_user_data_pack(callback, user_data)); +} diff --git a/src/core/nm-priv-helper-call.h b/src/core/nm-priv-helper-call.h new file mode 100644 index 00000000..1915c5b3 --- /dev/null +++ b/src/core/nm-priv-helper-call.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#ifndef __NM_PRIV_HELPER_CALL_H__ +#define __NM_PRIV_HELPER_CALL_H__ + +#include "../libnm-base/nm-priv-helper-utils.h" + +typedef void (*NMPrivHelperCallGetFDCallback)(int fd_take, GError *error, gpointer user_data); + +void nm_priv_helper_call_get_fd(NMPrivHelperGetFDType fd_type, + GCancellable * cancellable, + NMPrivHelperCallGetFDCallback callback, + gpointer user_data); + +#endif /* __NM_PRIV_HELPER_CALL_H__ */ diff --git a/src/core/nm-session-monitor.c b/src/core/nm-session-monitor.c index 88de1a00..2cc99ab3 100644 --- a/src/core/nm-session-monitor.c +++ b/src/core/nm-session-monitor.c @@ -14,17 +14,17 @@ #include #if SESSION_TRACKING_SYSTEMD && SESSION_TRACKING_ELOGIND - #error Cannot build both systemd-logind and elogind support +#error Cannot build both systemd-logind and elogind support #endif #if SESSION_TRACKING_SYSTEMD - #include - #define LOGIND_NAME "systemd-logind" +#include +#define LOGIND_NAME "systemd-logind" #endif #if SESSION_TRACKING_ELOGIND - #include - #define LOGIND_NAME "elogind" +#include +#define LOGIND_NAME "elogind" #endif #include "NetworkManagerUtils.h" diff --git a/src/core/nm-sleep-monitor.c b/src/core/nm-sleep-monitor.c index 306453e7..76f13203 100644 --- a/src/core/nm-sleep-monitor.c +++ b/src/core/nm-sleep-monitor.c @@ -16,23 +16,23 @@ #if defined(SUSPEND_RESUME_UPOWER) - #define SUSPEND_DBUS_NAME "org.freedesktop.UPower" - #define SUSPEND_DBUS_PATH "/org/freedesktop/UPower" - #define SUSPEND_DBUS_INTERFACE "org.freedesktop.UPower" - #define USE_UPOWER 1 - #define _NMLOG_PREFIX_NAME "sleep-monitor-up" +#define SUSPEND_DBUS_NAME "org.freedesktop.UPower" +#define SUSPEND_DBUS_PATH "/org/freedesktop/UPower" +#define SUSPEND_DBUS_INTERFACE "org.freedesktop.UPower" +#define USE_UPOWER 1 +#define _NMLOG_PREFIX_NAME "sleep-monitor-up" #elif defined(SUSPEND_RESUME_SYSTEMD) || defined(SUSPEND_RESUME_ELOGIND) - #define SUSPEND_DBUS_NAME "org.freedesktop.login1" - #define SUSPEND_DBUS_PATH "/org/freedesktop/login1" - #define SUSPEND_DBUS_INTERFACE "org.freedesktop.login1.Manager" - #define USE_UPOWER 0 - #if defined(SUSPEND_RESUME_SYSTEMD) - #define _NMLOG_PREFIX_NAME "sleep-monitor-sd" - #else - #define _NMLOG_PREFIX_NAME "sleep-monitor-el" - #endif +#define SUSPEND_DBUS_NAME "org.freedesktop.login1" +#define SUSPEND_DBUS_PATH "/org/freedesktop/login1" +#define SUSPEND_DBUS_INTERFACE "org.freedesktop.login1.Manager" +#define USE_UPOWER 0 +#if defined(SUSPEND_RESUME_SYSTEMD) +#define _NMLOG_PREFIX_NAME "sleep-monitor-sd" +#else +#define _NMLOG_PREFIX_NAME "sleep-monitor-el" +#endif #elif defined(SUSPEND_RESUME_CONSOLEKIT) @@ -40,15 +40,15 @@ * uses. http://consolekit2.github.io/ConsoleKit2/#Manager.Inhibit */ - #define SUSPEND_DBUS_NAME "org.freedesktop.ConsoleKit" - #define SUSPEND_DBUS_PATH "/org/freedesktop/ConsoleKit/Manager" - #define SUSPEND_DBUS_INTERFACE "org.freedesktop.ConsoleKit.Manager" - #define USE_UPOWER 0 - #define _NMLOG_PREFIX_NAME "sleep-monitor-ck" +#define SUSPEND_DBUS_NAME "org.freedesktop.ConsoleKit" +#define SUSPEND_DBUS_PATH "/org/freedesktop/ConsoleKit/Manager" +#define SUSPEND_DBUS_INTERFACE "org.freedesktop.ConsoleKit.Manager" +#define USE_UPOWER 0 +#define _NMLOG_PREFIX_NAME "sleep-monitor-ck" #else - #error define one of SUSPEND_RESUME_SYSTEMD, SUSPEND_RESUME_ELOGIND, SUSPEND_RESUME_CONSOLEKIT, or SUSPEND_RESUME_UPOWER +#error define one of SUSPEND_RESUME_SYSTEMD, SUSPEND_RESUME_ELOGIND, SUSPEND_RESUME_CONSOLEKIT, or SUSPEND_RESUME_UPOWER #endif diff --git a/src/core/nm-test-utils-core.h b/src/core/nm-test-utils-core.h index 99d12ba9..e037ba92 100644 --- a/src/core/nm-test-utils-core.h +++ b/src/core/nm-test-utils-core.h @@ -222,7 +222,7 @@ nmtst_platform_ip4_routes_equal(const NMPlatformIP4Route *a, } } - #ifdef __NMP_OBJECT_H__ +#ifdef __NMP_OBJECT_H__ static inline void nmtst_platform_ip4_routes_equal_aptr(const NMPObject *const * a, @@ -242,7 +242,7 @@ nmtst_platform_ip4_routes_equal_aptr(const NMPObject *const * a, nmtst_platform_ip4_routes_equal(c_a, b, len, ignore_order); } - #endif +#endif static inline int _nmtst_platform_ip6_routes_equal_sort(gconstpointer a, gconstpointer b, gpointer user_data) @@ -291,7 +291,7 @@ nmtst_platform_ip6_routes_equal(const NMPlatformIP6Route *a, } } - #ifdef __NMP_OBJECT_H__ +#ifdef __NMP_OBJECT_H__ static inline void nmtst_platform_ip6_routes_equal_aptr(const NMPObject *const * a, @@ -311,13 +311,13 @@ nmtst_platform_ip6_routes_equal_aptr(const NMPObject *const * a, nmtst_platform_ip6_routes_equal(c_a, b, len, ignore_order); } - #endif +#endif #endif #ifdef __NETWORKMANAGER_IP4_CONFIG_H__ - #include "libnm-glib-aux/nm-dedup-multi.h" +#include "libnm-glib-aux/nm-dedup-multi.h" static inline NMIP4Config * nmtst_ip4_config_new(int ifindex) @@ -331,7 +331,7 @@ nmtst_ip4_config_new(int ifindex) #ifdef __NETWORKMANAGER_IP6_CONFIG_H__ - #include "libnm-glib-aux/nm-dedup-multi.h" +#include "libnm-glib-aux/nm-dedup-multi.h" static inline NMIP6Config * nmtst_ip6_config_new(int ifindex) diff --git a/src/core/nm-types.h b/src/core/nm-types.h index 7ad5aee1..294cf409 100644 --- a/src/core/nm-types.h +++ b/src/core/nm-types.h @@ -7,7 +7,7 @@ #define __NETWORKMANAGER_TYPES_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_DAEMON) - #error Cannot use this header. +#error Cannot use this header. #endif /* core */ diff --git a/src/core/platform/tests/meson.build b/src/core/platform/tests/meson.build index 5d55707a..8824ed2f 100644 --- a/src/core/platform/tests/meson.build +++ b/src/core/platform/tests/meson.build @@ -14,7 +14,6 @@ test_units = [ ['test-platform-general', 'test-platform-general.c', test_c_flags, default_test_timeout], ['test-route-fake', 'test-route.c', test_fake_c_flags, default_test_timeout], ['test-route-linux', 'test-route.c', test_linux_c_flags, default_test_timeout], - ['test-tc-fake', 'test-tc.c', test_fake_c_flags, default_test_timeout], ['test-tc-linux', 'test-tc.c', test_linux_c_flags, default_test_timeout], ] diff --git a/src/core/platform/tests/test-common.c b/src/core/platform/tests/test-common.c index 2fc9e836..4f56a3a7 100644 --- a/src/core/platform/tests/test-common.c +++ b/src/core/platform/tests/test-common.c @@ -37,7 +37,9 @@ gboolean nmtstp_is_root_test(void) { g_assert(_nmtstp_setup_platform_func); - return _nmtstp_setup_platform_func == nm_linux_platform_setup; + return NM_IN_SET(_nmtstp_setup_platform_func, + nm_linux_platform_setup, + nm_linux_platform_setup_with_tc_cache); } gboolean @@ -2694,9 +2696,13 @@ _l3_acd_nacd_event(int fd, GIOCondition condition, gpointer user_data) NM_HASH_OBFUSCATE_PTR(defender), NM_ETHER_ADDR_FORMAT_VAL((const NMEtherAddr *) event->defended.sender)); break; + case N_ACD_EVENT_DOWN: + /* Not sure why this sometimes happens. But this is only the test stub, ignore it. */ + _LOGT("acd-defender[" NM_HASH_OBFUSCATE_PTR_FMT "]: link down event received", + NM_HASH_OBFUSCATE_PTR(defender)); + break; case N_ACD_EVENT_USED: case N_ACD_EVENT_CONFLICT: - case N_ACD_EVENT_DOWN: default: g_assert_not_reached(); break; diff --git a/src/core/platform/tests/test-common.h b/src/core/platform/tests/test-common.h index 1fb97d24..fc4149f0 100644 --- a/src/core/platform/tests/test-common.h +++ b/src/core/platform/tests/test-common.h @@ -104,11 +104,11 @@ SignalData *add_signal_full(const char * name, int ifindex, const char * ifname); #define add_signal(name, change_type, callback) \ - add_signal_full(name, change_type, (GCallback) callback, 0, NULL) + add_signal_full(name, change_type, G_CALLBACK(callback), 0, NULL) #define add_signal_ifindex(name, change_type, callback, ifindex) \ - add_signal_full(name, change_type, (GCallback) callback, ifindex, NULL) + add_signal_full(name, change_type, G_CALLBACK(callback), ifindex, NULL) #define add_signal_ifname(name, change_type, callback, ifname) \ - add_signal_full(name, change_type, (GCallback) callback, 0, ifname) + add_signal_full(name, change_type, G_CALLBACK(callback), 0, ifname) void _accept_signal(const char *file, int line, const char *func, SignalData *data); void _accept_signals(const char *file, int line, const char *func, SignalData *data, int min, int max); diff --git a/src/core/platform/tests/test-link.c b/src/core/platform/tests/test-link.c index f6c3841e..24e3fd99 100644 --- a/src/core/platform/tests/test-link.c +++ b/src/core/platform/tests/test-link.c @@ -580,6 +580,7 @@ test_bridge_addr(void) char addr[ETH_ALEN]; NMPlatformLink link; const NMPlatformLink *plink = NULL; + NMPLinkAddress hw_perm_addr; nm_utils_hwaddr_aton("de:ad:be:ef:00:11", addr, sizeof(addr)); @@ -599,27 +600,49 @@ test_bridge_addr(void) plink = nm_platform_link_get(NM_PLATFORM_GET, link.ifindex); g_assert(plink); + g_assert(!nm_platform_link_get_permanent_address(NM_PLATFORM_GET, plink, &hw_perm_addr)); - if (nm_platform_kernel_support_get(NM_PLATFORM_KERNEL_SUPPORT_TYPE_USER_IPV6LL)) { - g_assert(!nm_platform_link_get_user_ipv6ll_enabled(NM_PLATFORM_GET, link.ifindex)); + if (nmtstp_is_root_test()) { + g_assert_cmpint(nm_platform_link_get_inet6_addr_gen_mode(NM_PLATFORM_GET, link.ifindex), + ==, + NM_IN6_ADDR_GEN_MODE_EUI64); + g_assert_cmpint(_nm_platform_link_get_inet6_addr_gen_mode(plink), + ==, + NM_IN6_ADDR_GEN_MODE_EUI64); g_assert_cmpint(_nm_platform_uint8_inv(plink->inet6_addr_gen_mode_inv), ==, NM_IN6_ADDR_GEN_MODE_EUI64); g_assert(NMTST_NM_ERR_SUCCESS( - nm_platform_link_set_user_ipv6ll_enabled(NM_PLATFORM_GET, link.ifindex, TRUE))); - g_assert(nm_platform_link_get_user_ipv6ll_enabled(NM_PLATFORM_GET, link.ifindex)); + nm_platform_link_set_inet6_addr_gen_mode(NM_PLATFORM_GET, + link.ifindex, + NM_IN6_ADDR_GEN_MODE_NONE))); + g_assert_cmpint(nm_platform_link_get_inet6_addr_gen_mode(NM_PLATFORM_GET, link.ifindex), + ==, + NM_IN6_ADDR_GEN_MODE_NONE); plink = nm_platform_link_get(NM_PLATFORM_GET, link.ifindex); g_assert(plink); + g_assert(!nm_platform_link_get_permanent_address(NM_PLATFORM_GET, plink, &hw_perm_addr)); + g_assert_cmpint(_nm_platform_link_get_inet6_addr_gen_mode(plink), + ==, + NM_IN6_ADDR_GEN_MODE_NONE); g_assert_cmpint(_nm_platform_uint8_inv(plink->inet6_addr_gen_mode_inv), ==, NM_IN6_ADDR_GEN_MODE_NONE); g_assert(NMTST_NM_ERR_SUCCESS( - nm_platform_link_set_user_ipv6ll_enabled(NM_PLATFORM_GET, link.ifindex, FALSE))); - g_assert(!nm_platform_link_get_user_ipv6ll_enabled(NM_PLATFORM_GET, link.ifindex)); + nm_platform_link_set_inet6_addr_gen_mode(NM_PLATFORM_GET, + link.ifindex, + NM_IN6_ADDR_GEN_MODE_EUI64))); + g_assert_cmpint(nm_platform_link_get_inet6_addr_gen_mode(NM_PLATFORM_GET, link.ifindex), + ==, + NM_IN6_ADDR_GEN_MODE_EUI64); plink = nm_platform_link_get(NM_PLATFORM_GET, link.ifindex); g_assert(plink); + g_assert(!nm_platform_link_get_permanent_address(NM_PLATFORM_GET, plink, &hw_perm_addr)); + g_assert_cmpint(_nm_platform_link_get_inet6_addr_gen_mode(plink), + ==, + NM_IN6_ADDR_GEN_MODE_EUI64); g_assert_cmpint(_nm_platform_uint8_inv(plink->inet6_addr_gen_mode_inv), ==, NM_IN6_ADDR_GEN_MODE_EUI64); @@ -730,6 +753,7 @@ static void test_external(void) { const NMPlatformLink *pllink; + NMPLinkAddress hw_perm_addr; SignalData * link_added, *link_changed, *link_removed; int ifindex; @@ -758,6 +782,7 @@ test_external(void) pllink = nm_platform_link_get(NM_PLATFORM_GET, ifindex); g_assert(pllink); + g_assert(!nm_platform_link_get_permanent_address(NM_PLATFORM_GET, pllink, &hw_perm_addr)); if (!pllink->initialized) { /* we still lack the notification via UDEV. Expect another link changed signal. */ wait_signal(link_changed); @@ -1488,7 +1513,7 @@ test_software_detect(gconstpointer user_data) * The fix (17af2bce) is included kernel 4.7, dated 24 July, 2016. */ for (i = ifindex_parent + 1; i < ifindex_parent + 100; i++) { - snprintf(buf, sizeof(buf), "/sys/class/macvtap/tap%d", i); + g_snprintf(buf, sizeof(buf), "/sys/class/macvtap/tap%d", i); if (!g_file_test(buf, G_FILE_TEST_IS_SYMLINK)) break; @@ -2522,6 +2547,7 @@ test_nl_bugs_veth(void) const NMPlatformLink *pllink_veth0, *pllink_veth1; gs_free_error GError * error = NULL; NMTstpNamespaceHandle *ns_handle = NULL; + NMPLinkAddress hw_perm_addr; /* create veth pair. */ ifindex_veth0 = nmtstp_link_veth_add(NM_PLATFORM_GET, -1, IFACE_VETH0, IFACE_VETH1)->ifindex; @@ -2538,6 +2564,7 @@ test_nl_bugs_veth(void) /* assert that NMPlatformLink.parent is the peer-ifindex. */ pllink_veth0 = nm_platform_link_get(NM_PLATFORM_GET, ifindex_veth0); g_assert(pllink_veth0); + g_assert(!nm_platform_link_get_permanent_address(NM_PLATFORM_GET, pllink_veth0, &hw_perm_addr)); if (pllink_veth0->parent == 0) { /* Kernels prior to 4.1 dated 21 June, 2015 don't support exposing the veth peer * as IFA_LINK. skip the remainder of the test. */ @@ -2549,6 +2576,7 @@ test_nl_bugs_veth(void) * https://bugzilla.redhat.com/show_bug.cgi?id=1285827 in place. */ pllink_veth1 = nm_platform_link_get(NM_PLATFORM_GET, ifindex_veth1); g_assert(pllink_veth1); + g_assert(!nm_platform_link_get_permanent_address(NM_PLATFORM_GET, pllink_veth1, &hw_perm_addr)); g_assert_cmpint(pllink_veth1->parent, ==, ifindex_veth0); /* move one veth peer to another namespace and check that the @@ -2588,6 +2616,7 @@ test_nl_bugs_spuroius_newlink(void) const char * IFACE_DUMMY0 = "nm-test-dummy0"; int ifindex_bond0, ifindex_dummy0; const NMPlatformLink *pllink; + NMPLinkAddress hw_perm_addr; gboolean wait_for_settle; /* see https://bugzilla.redhat.com/show_bug.cgi?id=1285719 */ @@ -2609,6 +2638,7 @@ test_nl_bugs_spuroius_newlink(void) pllink = nm_platform_link_get(NM_PLATFORM_GET, ifindex_dummy0); g_assert(pllink); + g_assert(!nm_platform_link_get_permanent_address(NM_PLATFORM_GET, pllink, &hw_perm_addr)); if (pllink->master == ifindex_bond0) break; }); @@ -2621,6 +2651,7 @@ again: nm_platform_process_events(NM_PLATFORM_GET); pllink = nm_platform_link_get(NM_PLATFORM_GET, ifindex_bond0); g_assert(!pllink); + g_assert(!nm_platform_link_get_permanent_address(NM_PLATFORM_GET, pllink, &hw_perm_addr)); if (wait_for_settle) { wait_for_settle = FALSE; @@ -2641,6 +2672,7 @@ test_nl_bugs_spuroius_dellink(void) const char * IFACE_DUMMY0 = "nm-test-dummy0"; int ifindex_bridge0, ifindex_dummy0; const NMPlatformLink *pllink; + NMPLinkAddress hw_perm_addr; gboolean wait_for_settle; /* see https://bugzilla.redhat.com/show_bug.cgi?id=1285719 */ @@ -2663,6 +2695,7 @@ test_nl_bugs_spuroius_dellink(void) pllink = nm_platform_link_get(NM_PLATFORM_GET, ifindex_dummy0); g_assert(pllink); + g_assert(!nm_platform_link_get_permanent_address(NM_PLATFORM_GET, pllink, &hw_perm_addr)); if (pllink->master == ifindex_bridge0) break; }); @@ -2677,8 +2710,10 @@ again: nm_platform_process_events(NM_PLATFORM_GET); pllink = nm_platform_link_get(NM_PLATFORM_GET, ifindex_bridge0); g_assert(pllink); + g_assert(!nm_platform_link_get_permanent_address(NM_PLATFORM_GET, pllink, &hw_perm_addr)); pllink = nm_platform_link_get(NM_PLATFORM_GET, ifindex_dummy0); g_assert(pllink); + g_assert(!nm_platform_link_get_permanent_address(NM_PLATFORM_GET, pllink, &hw_perm_addr)); g_assert_cmpint(pllink->parent, ==, 0); if (wait_for_settle) { @@ -2716,7 +2751,7 @@ _test_netns_create_platform(void) netns = nmp_netns_new(); g_assert(NMP_IS_NETNS(netns)); - platform = nm_linux_platform_new(TRUE, TRUE); + platform = nm_linux_platform_new(TRUE, TRUE, TRUE); g_assert(NM_IS_LINUX_PLATFORM(platform)); nmp_netns_pop(netns); @@ -2805,7 +2840,7 @@ test_netns_general(gpointer fixture, gconstpointer test_data) if (_check_sysctl_skip()) return; - platform_1 = nm_linux_platform_new(TRUE, TRUE); + platform_1 = nm_linux_platform_new(TRUE, TRUE, TRUE); platform_2 = _test_netns_create_platform(); /* add some dummy devices. The "other-*" devices are there to bump the ifindex */ @@ -2933,7 +2968,7 @@ test_netns_set_netns(gpointer fixture, gconstpointer test_data) if (_test_netns_check_skip()) return; - platforms[0] = platform_0 = nm_linux_platform_new(TRUE, TRUE); + platforms[0] = platform_0 = nm_linux_platform_new(TRUE, TRUE, TRUE); platforms[1] = platform_1 = _test_netns_create_platform(); platforms[2] = platform_2 = _test_netns_create_platform(); @@ -3032,7 +3067,7 @@ test_netns_push(gpointer fixture, gconstpointer test_data) if (_check_sysctl_skip()) return; - pl[0].platform = platform_0 = nm_linux_platform_new(TRUE, TRUE); + pl[0].platform = platform_0 = nm_linux_platform_new(TRUE, TRUE, TRUE); pl[1].platform = platform_1 = _test_netns_create_platform(); pl[2].platform = platform_2 = _test_netns_create_platform(); @@ -3179,7 +3214,7 @@ test_netns_bind_to_path(gpointer fixture, gconstpointer test_data) if (_test_netns_check_skip()) return; - platforms[0] = platform_0 = nm_linux_platform_new(TRUE, TRUE); + platforms[0] = platform_0 = nm_linux_platform_new(TRUE, TRUE, TRUE); platforms[1] = platform_1 = _test_netns_create_platform(); platforms[2] = platform_2 = _test_netns_create_platform(); @@ -3344,7 +3379,7 @@ test_sysctl_netns_switch(void) if (_test_netns_check_skip()) return; - platforms[0] = platform_0 = nm_linux_platform_new(TRUE, TRUE); + platforms[0] = platform_0 = nm_linux_platform_new(TRUE, TRUE, TRUE); platforms[1] = platform_1 = _test_netns_create_platform(); platforms[2] = platform_2 = _test_netns_create_platform(); PL = platforms[nmtst_get_rand_uint32() % 3]; diff --git a/src/core/platform/tests/test-platform-general.c b/src/core/platform/tests/test-platform-general.c index 05158228..8ffd92b5 100644 --- a/src/core/platform/tests/test-platform-general.c +++ b/src/core/platform/tests/test-platform-general.c @@ -31,7 +31,7 @@ test_init_linux_platform(void) { gs_unref_object NMPlatform *platform = NULL; - platform = nm_linux_platform_new(TRUE, NM_PLATFORM_NETNS_SUPPORT_DEFAULT); + platform = nm_linux_platform_new(TRUE, NM_PLATFORM_NETNS_SUPPORT_DEFAULT, TRUE); } /*****************************************************************************/ @@ -42,7 +42,7 @@ test_link_get_all(void) gs_unref_object NMPlatform *platform = NULL; gs_unref_ptrarray GPtrArray *links = NULL; - platform = nm_linux_platform_new(TRUE, NM_PLATFORM_NETNS_SUPPORT_DEFAULT); + platform = nm_linux_platform_new(TRUE, NM_PLATFORM_NETNS_SUPPORT_DEFAULT, TRUE); links = nm_platform_link_get_all(platform, TRUE); } @@ -104,34 +104,34 @@ test_platform_ip_address_pretty_sort_cmp(gconstpointer test_data) [0] = ("5b1aea34648cabfec7c3523f76cf1ce34ca17a9a32f3f0f218424e48836dd1cb504e03d53e1124c5" "0065aeb2e6fbf952902383028e3b47f280f062ea1a7e0b7be218d067530e1b0487b8c3b99f2b8a1a" "8982c42f0000003437c5156e072b2f2f0037c9cfe07c34ddb3980deb14ab7b5af84a034703000000" - "883b0f3fd6ed84d6c959e553b887edcd01c2f5d200000043b809d259e499db7d00f1853bdcb0e4bc" - "0e2b00b667b7b16d8d1e69c803000000b973972c17a47631c169f11ff9119c400368b6630000007a" + "883b0f3fd6ed84d6c959e553b887edcd6101f5d200000043b809d259e499db7d00f1853bdcb0e4bc" + "0e2b00b667b7b16d8d1e69c803000000b973972c17a47631c169f11ff9119c40b403b6630000007a" "034f43340d01683c0045097aea4a849f060ddf57b24a5be9636360d603000000ad7c499dd538d345" - "74c038404923e75d0209e2fc0000004acc807cdce682f80f00315c45ef817264c89a736ed55ed637" - "b96c200203000000faf1809becd2506315a6da29b2e94d3a031fe0e900000083a36035fb6297dfa7" + "74c038404923e75d0e02e2fc0000004acc807cdce682f80f00315c45ef817264c89a736ed55ed637" + "b96c200203000000faf1809becd2506315a6da29b2e94d3ab503e0e900000083a36035fb6297dfa7" "00686b5efd0d53bb6215de4bb6f6f3d031a79028030000008bb836c0a25ea71f5daaed4d99eb2ebe" - "033c432f000000bf4ccf30d3aaaf02a4005d7308b67f91bf9d82c856ba942455e8d07c8403000000" - "f2abb982b001ec16901f55f960c55c22022099a80000002b4d4647f53b1921af0088e3759a08e7a5" - "6663861eea1bf42c12ea3b9503000000fb95e8332fdfff658483a2d039a7bf1402d3481e00000060" + "be03432f000000bf4ccf30d3aaaf02a4005d7308b67f91bf9d82c856ba942455e8d07c8403000000" + "f2abb982b001ec16901f55f960c55c22f30299a80000002b4d4647f53b1921af0088e3759a08e7a5" + "6663861eea1bf42c12ea3b9503000000fb95e8332fdfff658483a2d039a7bf148e02481e00000060" "e89f7abdb682380a00eae374835b4a49a2b980b6aba92da6409969aa03000000e00473755d31e5b2" - "de252167c1c91b3a02ba0c700000007740318db913a353ed006efc068829c0e66ad0143a0554efb4" - "40e55b8b03000000c0cfb2b4386bec092fa5757ecde9348b00c12ebd000000ab667224dae775e5cc" + "de252167c1c91b3a36020c700000007740318db913a353ed006efc068829c0e66ad0143a0554efb4" + "40e55b8b03000000c0cfb2b4386bec092fa5757ecde9348bda002ebd000000ab667224dae775e5cc" "0041aca2ff0f576767d3648102b61886d149f07403000000153ece68ade15cec25a59273e7519f34" "c4458d70000000f3819aa46fbe1439340033ae6dec0fb124f264af67eed7c9a8ecc8fb1103000000" - "fcebbaeb0c56535923f14874042a8aff021f8e5ec3cc13cc36bbe3c9bb0ec36f00e007bb64a2827b" - "7cdd38d0314c178e5a06c40b03000000ab90135fa636af4464d210a256be75e0029c44770000004b" + "fcebbaeb0c56535923f14874042a8aff1d028e5ec3cc13cc36bbe3c9bb0ec36f00e007bb64a2827b" + "7cdd38d0314c178e5a06c40b03000000ab90135fa636af4464d210a256be75e0500244770000004b" "2e69220d6c0fc09c25d6534c809829af4a9df58dbfef186d416f3a1e030000002c932e655203d82a" - "3c84c4eb274ed18603780281000000f2235376239daeaacb3cae864b437baaae91921681c2162b9b" - "69e66142030000004fda8a3e0b841cf76391dd68269b53ec0244a831000000b78c54dda9ac3bb1b1" + "3c84c4eb274ed18687030281000000f2235376239daeaacb3cae864b437baaae91921681c2162b9b" + "69e66142030000004fda8a3e0b841cf76391dd68269b53eccb02a831000000b78c54dda9ac3bb1b1" "d43e6505621b9a7f0422ae3fc8979ee0416f95e70300000057d6249b652ba98c7dc7f17f666969e4" - "023baf7a000000ee0b06fa9e988f80f0de6dc8dfcf2a3ad3bbcc0fa3b314f695111d891d03000000" - "cd897619f51f44e644d7cf1d06b2b1150082549e62c12fba5b1cdec48d10bbb13b8313d8cd2a24d3" - "4fc812bd2f8a59d90fcc00ac030000005292cd32dc096cd5d8a4c5cf3351ee1c03c2056c00000051" + "5c02af7a000000ee0b06fa9e988f80f0de6dc8dfcf2a3ad3bbcc0fa3b314f695111d891d03000000" + "cd897619f51f44e644d7cf1d06b2b115d800549e62c12fba5b1cdec48d10bbb13b8313d8cd2a24d3" + "4fc812bd2f8a59d90fcc00ac030000005292cd32dc096cd5d8a4c5cf3351ee1cfc03056c00000051" "bbce426cfa4b861cc78592be7b14e7ba9c15acb881ae55f0e5fe7d360300000066a3ae3939762df3" - "3a2d55060c78d55100b110fd00000041b9aca07b6e4925dd27943a272c171ed15abbbe1cd911db7b" - "86ed271803000000a5edc511c1507a141e0f515638c7ba31027609450000003357ae79989870ccec" + "3a2d55060c78d551cb0010fd00000041b9aca07b6e4925dd27943a272c171ed15abbbe1cd911db7b" + "86ed271803000000a5edc511c1507a141e0f515638c7ba31f50209450000003357ae79989870ccec" "3def0ad92749e016663fe6ee0228c1da82d1595603000000348352d715cf9d411ea012e5307294b6" - "0146dac4000000075efee38dd16f8ee4ccd2f50c30706cae3fdcc2f0ee3d5e26bb20413203000000" + "e301dac4000000075efee38dd16f8ee4ccd2f50c30706cae3fdcc2f0ee3d5e26bb20413203000000" "862573c2303dd1d65c7b2cffeca6d1adaccae11f0000000f855ebf3b772eb2b1c896c9a7304f6645" "0a5f6abd850b06e3b10123e6030000001dff045298cfee0636674cdefb57b9ae54cfe8f400000038" "1ba2c4396de60f032bc7f34de2959871c0d4c0d4eb720c4ab550c5db03000000f32f4af595d785d5" @@ -139,108 +139,108 @@ test_platform_ip_address_pretty_sort_cmp(gconstpointer test_data) "b16c7376030000005219061ab4c5c79489b2cc6a883c146972decb8b000000f5e6d66df46ea13910" "7754dee62c36d2fc70ccc567df7a49b8585287dc03000000cfb18b2b2cb749e2e03e544d0eb4f73e" "75039fcf251b32fc79685b05ddd3aa9ba511d2e40edb4d758fb554158ae5c7c0beb42b3403000000" - "895d5f24037d233302ad3b82d639272e0246eadfbd2146bf8cfdb205f90e54b58a6ee136a779f37c" + "895d5f24037d233302ad3b82d639272e4a02eadfbd2146bf8cfdb205f90e54b58a6ee136a779f37c" "30d2c5053c40ecaec38b6b8e03000000bea73223e59bf0193432e9fa7a899f2d8ec7e4b89bf5a5d0" "6776e66a9d80ab132e1ac921eb76adbb229df32e561fa80a0fc4676703000000a23eb66e720da9e0" - "7ac998b5690807d50217369ee1af4ca5a6a95581af5fd7ceacdca10f47d7b351a36b178aabc78a4a" - "1a0dd8c003000000e2815a1a37a52bddd1c2f1018b587eed03bb58f0e9201f17bd99fcf72909ac9e" + "7ac998b5690807d52602369ee1af4ca5a6a95581af5fd7ceacdca10f47d7b351a36b178aabc78a4a" + "1a0dd8c003000000e2815a1a37a52bddd1c2f1018b587eed720358f0e9201f17bd99fcf72909ac9e" "7a55299e9bb4fd53bc7417940fcffe3f81cafd6302000000d6732578acd14320aefd4503189f7630" - "038e501c0000002b9f3c39f24b0572b100745cb25851429b3bbfb50168dfd04eb62f22ca02000000" - "891715df7fc6a902edae579e2e10c7f7022ba0340436242cbeb0248cee3fbc160032d4f28aa28c08" + "2403501c0000002b9f3c39f24b0572b100745cb25851429b3bbfb50168dfd04eb62f22ca02000000" + "891715df7fc6a902edae579e2e10c7f7a202a0340436242cbeb0248cee3fbc160032d4f28aa28c08" "f80dd50c6712dfb4abba4a32020000008ffe423d01883918039249f398f9b37ea091465100000064" "3722d9b707c0d8a400b7c8307f06b4b29088f20d9ac676d5e4bafc4e02000000fde69eec3af2e6d0" "bd68ab722af14548b29572e504265f6c72923e22594f3f790008ed2e2ebb0771db46a54cadb245ea" - "8c3b371502000000710c030690f5f18ea125dbf7d7e93bd6011fa56dfdcfc1155f236c8b9c79a620" + "8c3b371502000000710c030690f5f18ea125dbf7d7e93bd65c01a56dfdcfc1155f236c8b9c79a620" "00660bbf024b03ff0a8e27c405e64244e36f90d402000000fd41fe47684b370b6ec6584d64496089" - "570968ead4d1ae91c819bb068196d59900de3246e43f5e7945aaf95e2ffa3a119c64ed0402000000" - "a660ac824b7fae389861419c50da49bf02092583000000259f9f0251becc987907879cca68fec7bb" - "bb5f8edf248b4995d184e82002000000a19cdf6dd1c173f6078a806d329c9b0000bfc972000000f5" - "b2cd3dbddc74e26de958e48d2ab8b0313e7f8933e315130f641e447502000000b9b68c08a5e4351e" - "a349e1ccf662e058b879a45100000045fcb6a035339d504c9726d80d9c2d89df765b4d9a130257dc" - "d1e1b34902000000bcd7be07d78e6222e45aaf61814f703b40125e6b000000cbaaa37b861e6d46da" - "fe7d6ec4ac1ea051010911915ddb05f2c43bd794010000005bfe47c6f53a54e01b0c1d89414d94d0" - "032d2ec50000000103781b0f294a2b7300421398f4de67e9cee64b38b56e03e01539ce4101000000" - "18238487a417f3da01d99dae5f19009601582cab0000005b2363d13edc5aa115005eb914d8fbe9a4" - "fdb3d117d76b0de5bd82e9ea010000003d1b91caae8cb60b49ba9be338d856a40267c3d400000064" + "570968ead4d1ae91c819bb068196d59900de3246e43f5e7945aaf95e2ffa3a11d1e1b34902000000" + "bcd7be07d78e6222e45aaf61814f703b40125e6b000000cbaaa37b861e6d46dafe7d6ec4ac1ea051" + "010911915ddb05f29c64ed0402000000a660ac824b7fae389861419c50da49bf2b02258300000025" + "9f9f0251becc987907879cca68fec7bbbb5f8edf248b4995d184e82002000000a19cdf6dd1c173f6" + "078a806d329c9b008b00c972000000f5b2cd3dbddc74e26de958e48d2ab8b0313e7f8933e315130f" + "641e447502000000b9b68c08a5e4351ea349e1ccf662e058b879a45100000045fcb6a035339d504c" + "9726d80d9c2d89df765b4d9a130257dcc43bd794010000005bfe47c6f53a54e01b0c1d89414d94d0" + "e0032ec50000000103781b0f294a2b7300421398f4de67e9cee64b38b56e03e01539ce4101000000" + "18238487a417f3da01d99dae5f190096cc012cab0000005b2363d13edc5aa115005eb914d8fbe9a4" + "fdb3d117d76b0de5bd82e9ea010000003d1b91caae8cb60b49ba9be338d856a40c02c3d400000064" "9da90bd2fff2f2560046870bd7d5f14870c6d18d6242b356b9ef1b2101000000f90adac616a31dc2" - "e46a234558817151008fc9c900000073e64b0bd761fdf274005dca8ce1bd1871ae17bb4515856092" - "b4d9e89b010000006855676c277cf1bd017c9148da5892bb0351c3a70000009f3391ce7d3fd48469" + "e46a234558817151b300c9c900000073e64b0bd761fdf274005dca8ce1bd1871ae17bb4515856092" + "b4d9e89b010000006855676c277cf1bd017c9148da5892bb4903c3a70000009f3391ce7d3fd48469" "005f0c233dbdd2a97835df1f1782dee86c1de913010000003ee1d76fc1ea76e98c9dfc78997ab53e" - "00c21963f5b4cb2454830c68e44ea74b002b83f9b3bee14d861a4c9eeecc89f65408c1b701000000" - "d9e1825fa638e1af284a024b7f9e85ff00e050a2000000276e08cb887464b93400c3127c750fabdd" - "69121aec129cdc690d58fbcc01000000d0d44ff1e51c35157666c05348e6f50700a8e89800000012" + "27001963f5b4cb2454830c68e44ea74b002b83f9b3bee14d861a4c9eeecc89f65408c1b701000000" + "d9e1825fa638e1af284a024b7f9e85ff730050a2000000276e08cb887464b93400c3127c750fabdd" + "69121aec129cdc690d58fbcc01000000d0d44ff1e51c35157666c05348e6f507ff00e89800000012" "b900b2061d0c334b009f2dd1cdf64b0f9a60e0e289f08db3fde6b0250100000039dd8f88152a5845" - "4d9ca9d20f45dfa702e78604000000fbcd7db68b9ae586da00b4070c50320427c4dd3d031e33f22c" - "210aeb09010000007000b96d06992b6a58acd3995b9663d20248f333ef467092818aa77d6732b678" + "4d9ca9d20f45dfa774028604000000fbcd7db68b9ae586da00b4070c50320427c4dd3d031e33f22c" + "210aeb09010000007000b96d06992b6a58acd3995b9663d2df02f333ef467092818aa77d6732b678" "00844ef5a943825fcd743f59bd14c89b955e1a13010000007acbce3e3bcdf3824f1b134847ff26ba" - "009a774900000017ec852d59f3d17232edd86ad6c3103a68843a9aef34983882d3d3878501000000" - "5e0dfe491d1ba96742c7b5e02b2271220188b02a06d0dc5504b0595daf37deb499996bfb667f072d" - "ec1e5d9cdc8a11f4409bcfb30100000099d90a8543961b2ccd47724a3c460ba80383f4c500000063" + "4400774900000017ec852d59f3d17232edd86ad6c3103a68843a9aef34983882d3d3878501000000" + "5e0dfe491d1ba96742c7b5e02b2271229c01b02a06d0dc5504b0595daf37deb499996bfb667f072d" + "ec1e5d9cdc8a11f4409bcfb30100000099d90a8543961b2ccd47724a3c460ba85103f4c500000063" "eafb1ac4c0982b283aa9986700b2a2b3ed257b8b0489f48f053ec8ca0100000027335a25a364d101" - "5ffac03089f4553902b01784000000d7b83579b8da27345a72437f9b6245de39ec9e71ee4b951507" + "5ffac03089f45539e1021784000000d7b83579b8da27345a72437f9b6245de39ec9e71ee4b951507" "f121014a01000000efc67bce716c856e3973dc42a1003be94f89d8ee0000009b5d5bbe6c10085f3d" "6176f78a19bb8df1804c122fce5078c156e8f3fe010000000ea8042602a1f8e6f5657f3f9e3eb807" "cbad7645000000b8df6f628a70456d79f25d5895fb57fa60d9279fb2b8fcbac65ad47b8a01000000" "da40d88d40a6d75bc404156225b7eedefc2b44574b15e2ae496ad01bf007eacb0a28aec868282510" - "b60291ea6480e356925b568a0000000087bb24e5264fd3ebe9cf9f6df9615189018ee815000000a7" + "b60291ea6480e356925b568a0000000087bb24e5264fd3ebe9cf9f6df9615189f701e815000000a7" "5c9555876b6a3f13002b6cb8360feaac1d5c302df59dd32a7a859db500000000362956cd46646a0e" - "222160e5f769bb290366ed370000005b6a813387e99bb834009da86c64fefab2548759d313a5b92d" - "8e47935e0000000034f0386a253c21d94064f6b021281e230094ae20000000d71fd050bf8d85055b" + "222160e5f769bb295703ed370000005b6a813387e99bb834009da86c64fefab2548759d313a5b92d" + "8e47935e0000000034f0386a253c21d94064f6b021281e235f00ae20000000d71fd050bf8d85055b" "00e3756ccdb3455c60ca7b11c66af76e594f24a100000000e143fd52599364e13468f80fd514573f" "b572671c0000006932d1d5f5d0ce2cf6007a70ba5193a162bc92ec1b11d9172c857ae81200000000" "3e29535402e9b690c628d048eacce745ea213cb1000000b632ef3be6070dafa200187470e9da5570" "9427c226d324d9a08487fd0d00000000b7a350f9fc1519defa7db4532545666937c22a3b000000dc" "c405cbee5016c25200d8901d7a0165fe20744edb6ba04f14a4c73cf500000000a4bab14874afdf54" "e6aae816430607ca0675e09818e9bbec5918c59068baf76a008940f6fc3bbdc7f6090f756aae660b" - "6e4c699300000000d9c1e67743efb54e54270e46042e911803894e38000000376feecb80ac245409" - "c0becc271d9c2f67179bff0644399ae7e3c9472e00000000c5cfd9f2343b21362c19a0921dce2f83" - "00defa45000000270b9977e166bee737fe73670c439a644c323b59b4cd20eb7dabea74f700000000" - "f6989d2d6a909e986ff7add5df2c93e05459507b0000000f466554d2ae4d52a8c67b2e48b47003c8" - "1785d3ffdbd9a617df6b3542000000004c5cf8107ba282f4f983821918f93e742d08f0550000006f" - "2292362e5d68265d9f98c82d9b7a559be3acf4fc36fa6b5159747cf200000000ab2dadc5a39411fd" + "6e4c699300000000d9c1e67743efb54e54270e46042e91186a034e38000000376feecb80ac245409" + "c0becc271d9c2f67179bff0644399ae7df6b3542000000004c5cf8107ba282f4f983821918f93e74" + "2d08f0550000006f2292362e5d68265d9f98c82d9b7a559be3acf4fc36fa6b51e3c9472e00000000" + "c5cfd9f2343b21362c19a0921dce2f839200fa45000000270b9977e166bee737fe73670c439a644c" + "323b59b4cd20eb7dabea74f700000000f6989d2d6a909e986ff7add5df2c93e05459507b0000000f" + "466554d2ae4d52a8c67b2e48b47003c81785d3ffdbd9a61759747cf200000000ab2dadc5a39411fd" "4ff1116d478987316a553fc2000000cfc6ebe434a7ae8ff040483e310819e3b10db116431ec6f769" "438a72e1000000002495a609675344f7e2e3a5ebaec3c85f0a1742f70abe95c50345132a61eda239" "d9d083c3bf085387046ef8a36f0e9e696b382ab0000000009a6ce5d906837dbca6a5ee19d6f63fe9" - "03dd01f7246f13b2050424a2b3a45ef7a029c896b4132bd895072cfeffe9d6815997069500000000" - "0d3c723b91adb0da7c4aa7e7eb5a15bc03015fb98b841fd84cc43c510385b9a4c2aac1d67a909b29" + "cb0301f7246f13b2050424a2b3a45ef7a029c896b4132bd895072cfeffe9d6815997069500000000" + "0d3c723b91adb0da7c4aa7e7eb5a15bcde035fb98b841fd84cc43c510385b9a4c2aac1d67a909b29" "7c703915312e9c3cae02dfa000000000dd603bd35e7fa0f02f2f3313d8469d09a92409c0b7f0318a" "575a4f8e061db3dd7fde25654a4059d565dbc8a91e3b4457b077ddad3108be69f9b97d05c917ad6b" "10e693bb6e26f2ba90c8e909a9fe20e5c7a4c656482a9b0d00625009a40aeb62a42b6a62548e3c38" - "cd3c72f203000000ca82ac5180101be4f85cef468ea086ea01aafdc3a9fe1ec787bc45db7c52a52d" + "cd3c72f203000000ca82ac5180101be4f85cef468ea086ea9a01fdc3a9fe1ec787bc45db7c52a52d" "00bd39a44e8e8bc17c01ac63eca0c1cf5ff7f03a03000000c9a89192c1c8be55281a59d1fd338f35" - "0075f8cea9fec34573654ea6624f138ef9531cd9367a02e4d241989477a363d53b02239e03000000" - "24438387def0f4c6544e4b275d9b714600f810d2a9fec17647176b7c07d856e3b883efebc09dd9d6" - "1966b7ae7412041d57393c6f03000000182c0287822a272bec4501a1e27acfee018588ffa9fe6cae" + "7e00f8cea9fec34573654ea6624f138ef9531cd9367a02e4d241989477a363d53b02239e03000000" + "24438387def0f4c6544e4b275d9b7146a70010d2a9fec17647176b7c07d856e3b883efebc09dd9d6" + "1966b7ae7412041d57393c6f03000000182c0287822a272bec4501a1e27acfee7a0188ffa9fe6cae" "426de59560fad65d67c624f285d7174177a47579dda0b6eaa9a84c820300000070b1646d8026e9f1" - "704f1b16286ba2da017ef082a9feed33ef60a8b540b26f66761d1f13badfad0fe8fa8f3c1aad2a82" + "704f1b16286ba2dabc01f082a9feed33ef60a8b540b26f66761d1f13badfad0fe8fa8f3c1aad2a82" "fa40546c03000000df2d7c2790d3119a051bb2ee8192ac0cfa3abc1ea9fe3e7d75a2f42b50c6a363" "40132378b95c59313bacba64dbe996206e6904f50200000047150b9b14010469823acb72bb89182f" - "00112196a9feb9153b36bc60be5b534e006527f67485ab35aca0c7ee419733853cf09e8b02000000" - "e79c10acfce165e332a62384ec04e5ba009185ada9fe0070a36dd51323b2c54200154d12f86c260a" - "9edfa7a74c1c83c1050f63f802000000443cacf59c6379a44b7892f487afa98c0221c19ca9fe942f" + "93002196a9feb9153b36bc60be5b534e006527f67485ab35aca0c7ee419733853cf09e8b02000000" + "e79c10acfce165e332a62384ec04e5bab40085ada9fe0070a36dd51323b2c54200154d12f86c260a" + "9edfa7a74c1c83c1050f63f802000000443cacf59c6379a44b7892f487afa98cb102c19ca9fe942f" "460bcea75481f25e007d0de9a7afe283bd2f22ead05ff72006c83bc0020000004bdade862c224f6f" - "36506ebd455e679c00369bb8a9fecec3f8c8fa6867a982be8a934f852cc3d4d82bc0ec7303f99f8f" - "def85b7502000000a0bef8675b29a197b7b3cceaf5f1bb120335256aa9fe6e5d58099ffc4a503a71" + "36506ebd455e679cef009bb8a9fecec3f8c8fa6867a982be8a934f852cc3d4d82bc0ec7303f99f8f" + "def85b7502000000a0bef8675b29a197b7b3cceaf5f1bb12c503256aa9fe6e5d58099ffc4a503a71" "2350acbd48411f0dc15d2f0f49dad345d966279502000000e06302aba042aaa218dc091e9aa1477f" "6fdc9830a9fec95829a8838314dff34d24c332219a1b163a732d803e0e2f4f916d06412601000000" - "98c39e7cc282208fefc57ff447036b9501adcb22a9fe793f797a3c7dadd1c86e009d0c90bc512e13" - "7dcef5e4a27985bd5cfd5ce601000000152f2b70eaef7443e0f79ab6902dde5301b3ec71a9fe9f25" + "98c39e7cc282208fefc57ff447036b955101cb22a9fe793f797a3c7dadd1c86e009d0c90bc512e13" + "7dcef5e4a27985bd5cfd5ce601000000152f2b70eaef7443e0f79ab6902dde533601ec71a9fe9f25" "4ac95883195580410062ed564153e17478f8c3344d89c0bbfaa100fd01000000be184524a6bdc878" - "9cf851782d895bcc03a98489a9fe8c1287e6f7bb020ffdb00012098610e52bb2a16a4008aefd545b" - "0d80684e01000000ba8110fb9733cc24904f288262e6ea77032fa5f8a9feeefa701d120523bd98f2" + "9cf851782d895bcc8d038489a9fe8c1287e6f7bb020ffdb00012098610e52bb2a16a4008aefd545b" + "0d80684e01000000ba8110fb9733cc24904f288262e6ea77a203a5f8a9feeefa701d120523bd98f2" "00098b43cd68be6e3f81268193fd637e9037d7a701000000c47cf0f551e96770a754ac19ef820fe0" - "0031f2d3a9fe049150b8d10ab700cc3a7cf51be0403b654ba2f56808092069af5f5b481b01000000" + "2900f2d3a9fe049150b8d10ab700cc3a7cf51be0403b654ba2f56808092069af5f5b481b01000000" "68cb3bc873b04d937a6ed8f7bc51e54066fed098a9fe048a92d3adc69a84eb47622400207799416a" - "f1f0a086fbd7e2f7dea0077a00000000c386e9c6e6a2cbfa10ee58bdc75183600085d627a9feb1cb" + "f1f0a086fbd7e2f7dea0077a00000000c386e9c6e6a2cbfa10ee58bdc75183609900d627a9feb1cb" "e491cbbbf9443fd6007eb3c5bf64b671d6f18dbf463f9b83f512dc1c00000000fbab244735d67c61" - "283031667b2d74a102e0b1b1a9fe2aa590a2312e17f1a35900459582f4ef43c780908872746e39ef" - "a9a89f8700000000fcdf6d9be94030b34774d1d7dddedd9802f0f627a9fe965a87041331b2834bcf" + "283031667b2d74a10302b1b1a9fe2aa590a2312e17f1a35900459582f4ef43c780908872746e39ef" + "a9a89f8700000000fcdf6d9be94030b34774d1d7dddedd989902f627a9fe965a87041331b2834bcf" "00b4e3ce848518c4e3f6cbf25e5e1b992231bb0200000000173c333cd03bc905b7b899afeb760e3f" - "024a2efca9fe96b89b1bc8f415bd4e77be46bae5a1b3cae76665a268abfe8a41a84e27c100000000" - "cb29efdf672d2fa57fc85ebbe276c5660364192da9fee7af5eb888e9eb37bb046686943b101e1f55" - "3215abf8fbdf17c3677e5a3a00000000608df061d45d864d09f4ecf17625f82d03c74828a9fe1e37" + "00022efca9fe96b89b1bc8f415bd4e77be46bae5a1b3cae76665a268abfe8a41a84e27c100000000" + "cb29efdf672d2fa57fc85ebbe276c5661a03192da9fee7af5eb888e9eb37bb046686943b101e1f55" + "3215abf8fbdf17c3677e5a3a00000000608df061d45d864d09f4ecf17625f82da1034828a9fe1e37" "1051852c972ea7954079884af257b044fd13a6826a4c619f3d136cac000000009402a4c216772167" - "3f2b02b3256ead1f03ea9bc1a9fefca162fb81e733cff620ca7feefe1933631e8e69f6d9d6962d2c"), + "3f2b02b3256ead1f2f039bc1a9fefca162fb81e733cff620ca7feefe1933631e8e69f6d9d6962d2c"), [1] = ("54270e46020000006a894e387625da376feecb80ac245409c0becc271d9c2f67179bff0644399ae7" "9c64ed0432d599eaa660ac824b7fae389861419c7a899f2d010000009bf5a5d06776e66a9d80ab13" "2e1ac921eb76adbb229df32e561fa80a40e55b8b1dd92e18c0cfb2b4386bec092fa5757ecde9348b" diff --git a/src/core/platform/tests/test-tc.c b/src/core/platform/tests/test-tc.c index cd9536cc..ee7b861e 100644 --- a/src/core/platform/tests/test-tc.c +++ b/src/core/platform/tests/test-tc.c @@ -57,7 +57,7 @@ test_qdisc1(void) g_ptr_array_add(known, qdisc_new(ifindex, "fq_codel", TC_H_ROOT)); g_ptr_array_add(known, qdisc_new(ifindex, "ingress", TC_H_INGRESS)); - g_assert(nm_platform_qdisc_sync(NM_PLATFORM_GET, ifindex, known)); + g_assert(nm_platform_tc_sync(NM_PLATFORM_GET, ifindex, known, NULL)); plat = qdiscs_lookup(ifindex); g_assert(plat); g_assert_cmpint(plat->len, ==, 2); @@ -97,7 +97,7 @@ test_qdisc_fq_codel(void) obj->qdisc.fq_codel.quantum = 1000; g_ptr_array_add(known, obj); - g_assert(nm_platform_qdisc_sync(NM_PLATFORM_GET, ifindex, known)); + g_assert(nm_platform_tc_sync(NM_PLATFORM_GET, ifindex, known, NULL)); plat = qdiscs_lookup(ifindex); g_assert(plat); g_assert_cmpint(plat->len, ==, 1); @@ -136,7 +136,7 @@ test_qdisc_sfq(void) obj->qdisc.sfq.flows = 256; g_ptr_array_add(known, obj); - g_assert(nm_platform_qdisc_sync(NM_PLATFORM_GET, ifindex, known)); + g_assert(nm_platform_tc_sync(NM_PLATFORM_GET, ifindex, known, NULL)); plat = qdiscs_lookup(ifindex); g_assert(plat); g_assert_cmpint(plat->len, ==, 1); @@ -179,7 +179,7 @@ test_qdisc_tbf(void) obj->qdisc.handle = TC_H_MAKE(0x8005 << 16, 0); g_ptr_array_add(known, obj); - g_assert(nm_platform_qdisc_sync(NM_PLATFORM_GET, ifindex, known)); + g_assert(nm_platform_tc_sync(NM_PLATFORM_GET, ifindex, known, NULL)); plat = qdiscs_lookup(ifindex); g_assert(plat); g_assert_cmpint(plat->len, ==, 2); @@ -202,7 +202,7 @@ test_qdisc_tbf(void) /*****************************************************************************/ -NMTstpSetupFunc const _nmtstp_setup_platform_func = SETUP; +NMTstpSetupFunc const _nmtstp_setup_platform_func = nm_linux_platform_setup_with_tc_cache; void _nmtstp_init_tests(int *argc, char ***argv) @@ -213,10 +213,8 @@ _nmtstp_init_tests(int *argc, char ***argv) void _nmtstp_setup_tests(void) { - if (nmtstp_is_root_test()) { - nmtstp_env1_add_test_func("/link/qdisc/1", test_qdisc1, TRUE); - nmtstp_env1_add_test_func("/link/qdisc/fq_codel", test_qdisc_fq_codel, TRUE); - nmtstp_env1_add_test_func("/link/qdisc/sfq", test_qdisc_sfq, TRUE); - nmtstp_env1_add_test_func("/link/qdisc/tbf", test_qdisc_tbf, TRUE); - } + nmtstp_env1_add_test_func("/link/qdisc/1", test_qdisc1, TRUE); + nmtstp_env1_add_test_func("/link/qdisc/fq_codel", test_qdisc_fq_codel, TRUE); + nmtstp_env1_add_test_func("/link/qdisc/sfq", test_qdisc_sfq, TRUE); + nmtstp_env1_add_test_func("/link/qdisc/tbf", test_qdisc_tbf, TRUE); } diff --git a/src/core/ppp/nm-ppp-manager.c b/src/core/ppp/nm-ppp-manager.c index fefc5d61..e6790f22 100644 --- a/src/core/ppp/nm-ppp-manager.c +++ b/src/core/ppp/nm-ppp-manager.c @@ -21,7 +21,7 @@ #include #ifndef aligned_u64 - #define aligned_u64 unsigned long long __attribute__((aligned(8))) +#define aligned_u64 unsigned long long __attribute__((aligned(8))) #endif #include #include @@ -761,7 +761,7 @@ create_pppd_cmd_line(NMPPPManager * self, g_return_val_if_fail(setting != NULL, NULL); #ifndef PPPD_PATH - #define PPPD_PATH NULL +#define PPPD_PATH NULL #endif pppd_binary = nm_utils_find_helper("pppd", PPPD_PATH, err); diff --git a/src/core/settings/nm-settings-connection.c b/src/core/settings/nm-settings-connection.c index b423bf5b..71da97d0 100644 --- a/src/core/settings/nm-settings-connection.c +++ b/src/core/settings/nm-settings-connection.c @@ -346,7 +346,7 @@ _getsettings_cached_get(NMSettingsConnection *self, const NMConnectionSerializat priv->getsettings_cached.options = *options; priv->getsettings_cached.options.seen_bssids = - nm_utils_strv_dup_packed(priv->getsettings_cached.options.seen_bssids, -1); + nm_strv_dup_packed(priv->getsettings_cached.options.seen_bssids, -1); return priv->getsettings_cached.variant; } @@ -382,7 +382,7 @@ _nm_settings_connection_set_connection(NMSettingsConnection * self, NM_SETTING_COMPARE_FLAG_EXACT)) { connection_old = priv->connection; priv->connection = g_object_ref(new_connection); - nmtst_connection_assert_unchanging(priv->connection); + nm_assert_connection_unchanging(priv->connection); _getsettings_cached_clear(priv); _nm_settings_notify_sorted_by_autoconnect_priority_maybe_changed(priv->settings); diff --git a/src/core/settings/nm-settings.c b/src/core/settings/nm-settings.c index f9f98de7..b71b9d18 100644 --- a/src/core/settings/nm-settings.c +++ b/src/core/settings/nm-settings.c @@ -17,7 +17,7 @@ #include #if HAVE_SELINUX - #include +#include #endif #include "libnm-core-aux-intern/nm-common-macros.h" @@ -1352,7 +1352,7 @@ _connection_changed_track(NMSettings * self, || (_nm_connection_verify(connection, NULL) == NM_SETTING_VERIFY_SUCCESS)); nm_assert(!connection || nm_streq0(uuid, nm_connection_get_uuid(connection))); - nmtst_connection_assert_unchanging(connection); + nm_assert_connection_unchanging(connection); sett_conn_entry = _sett_conn_entries_get(self, uuid) ?: _sett_conn_entries_create_and_add(self, uuid); @@ -3372,7 +3372,7 @@ load_plugins(NMSettings *self, const char *const *plugins, GError **error) continue; } - if (nm_utils_strv_find_first((char **) plugins, iter - plugins, pname) >= 0) { + if (nm_strv_find_first(plugins, iter - plugins, pname) >= 0) { /* the plugin is already mentioned in the list previously. * Don't load a duplicate. */ continue; @@ -3452,7 +3452,7 @@ impl_settings_save_hostname(NMDBusObject * obj, g_variant_get(parameters, "(&s)", &hostname); /* Minimal validation of the hostname */ - if (!nm_hostname_manager_validate_hostname(hostname)) { + if (!nm_utils_validate_hostname(hostname)) { error_code = NM_SETTINGS_ERROR_INVALID_HOSTNAME; error_reason = "The hostname was too long or contained invalid characters"; goto err; @@ -3938,7 +3938,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) priv->connections_len, G_STRUCT_OFFSET(NMSettingsConnection, _connections_lst), TRUE); - g_value_take_boxed(value, nm_utils_strv_make_deep_copied(strv)); + g_value_take_boxed(value, nm_strv_make_deep_copied(strv)); break; case PROP_STARTUP_COMPLETE: g_value_set_boolean(value, !nm_settings_get_startup_complete_blocked_reason(self, FALSE)); diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c index 5038ac6a..8fdc01fb 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c @@ -848,7 +848,7 @@ _unhandled_specs_from_hashtable(GHashTable *hash) GSList * list = NULL; guint i, l; - keys = nm_utils_strdict_get_keys(hash, TRUE, &l); + keys = nm_strdict_get_keys(hash, TRUE, &l); for (i = l; i > 0;) { i--; list = g_slist_prepend(list, g_strdup(keys[i])); diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c index 03b347f9..6dd5ef05 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c @@ -31,6 +31,7 @@ #include "nm-setting-ethtool.h" #include "nm-setting-8021x.h" #include "nm-setting-bond.h" +#include "nm-setting-bond-port.h" #include "nm-setting-team.h" #include "nm-setting-team-port.h" #include "nm-setting-bridge.h" @@ -474,7 +475,7 @@ make_connection_setting(const char *file, if (v) { gs_free const char **items = NULL; - items = nm_utils_strsplit_set(v, " "); + items = nm_strsplit_set(v, " "); for (iter = items; iter && *iter; iter++) { if (!nm_setting_connection_add_permission(s_con, "user", *iter, NULL)) PARSE_WARNING("invalid USERS item '%s'", *iter); @@ -490,7 +491,7 @@ make_connection_setting(const char *file, if (v) { gs_free const char **items = NULL; - items = nm_utils_strsplit_set(v, " \t"); + items = nm_strsplit_set(v, " \t"); for (iter = items; iter && *iter; iter++) { if (!nm_setting_connection_add_secondary(s_con, *iter)) PARSE_WARNING("secondary connection UUID '%s' already added", *iter); @@ -633,6 +634,15 @@ make_connection_setting(const char *file, PARSE_WARNING("invalid LLMNR setting"); g_object_set(s_con, NM_SETTING_CONNECTION_LLMNR, i_val, NULL); + i_val = NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT; + if (!svGetValueEnum(ifcfg, + "DNS_OVER_TLS", + nm_setting_connection_dns_over_tls_get_type(), + &i_val, + NULL)) + PARSE_WARNING("invalid DNS_OVER_TLS setting"); + g_object_set(s_con, NM_SETTING_CONNECTION_DNS_OVER_TLS, i_val, NULL); + return NM_SETTING(s_con); } @@ -1036,7 +1046,7 @@ parse_route_line(const char *line, * Maybe later we want to support some form of quotation here. * Which of course, would be incompatible with initscripts. */ - words_free = nm_utils_strsplit_set(line, " \t\n"); + words_free = nm_strsplit_set(line, " \t\n"); words = words_free ?: NM_PTRARRAY_EMPTY(const char *); @@ -1582,7 +1592,7 @@ parse_dns_options(NMSettingIPConfig *ip_config, const char *value) if (!nm_setting_ip_config_has_dns_options(ip_config)) nm_setting_ip_config_clear_dns_options(ip_config, TRUE); - options = nm_utils_strsplit_set(value, " "); + options = nm_strsplit_set(value, " "); if (options) { for (item = options; *item; item++) { if (!nm_setting_ip_config_add_dns_option(ip_config, *item)) @@ -1974,26 +1984,27 @@ make_ip4_setting(shvarFile *ifcfg, /* DNS servers * Pick up just IPv4 addresses (IPv6 addresses are taken by make_ip6_setting()) */ - for (i = 1; i <= 10; i++) { + for (i = 1; i < 10000; i++) { char tag[256]; numbered_tag(tag, "DNS", i); nm_clear_g_free(&value); v = svGetValueStr(ifcfg, tag, &value); - if (v) { - if (nm_utils_ipaddr_is_valid(AF_INET, v)) { - if (!nm_setting_ip_config_add_dns(s_ip4, v)) - PARSE_WARNING("duplicate DNS server %s", tag); - } else if (nm_utils_ipaddr_is_valid(AF_INET6, v)) { - /* Ignore IPv6 addresses */ - } else { - g_set_error(error, - NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid DNS server address '%s'", - v); - return NULL; - } + if (!v) + break; + + if (nm_utils_ipaddr_is_valid(AF_INET, v)) { + if (!nm_setting_ip_config_add_dns(s_ip4, v)) + PARSE_WARNING("duplicate DNS server %s", tag); + } else if (nm_utils_ipaddr_is_valid(AF_INET6, v)) { + /* Ignore IPv6 addresses */ + } else { + g_set_error(error, + NM_SETTINGS_ERROR, + NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid DNS server address '%s'", + v); + return NULL; } } @@ -2003,7 +2014,7 @@ make_ip4_setting(shvarFile *ifcfg, if (v) { gs_free const char **searches = NULL; - searches = nm_utils_strsplit_set(v, " "); + searches = nm_strsplit_set(v, " "); if (searches) { for (item = searches; *item; item++) { if (!nm_setting_ip_config_add_dns_search(s_ip4, *item)) @@ -2063,7 +2074,7 @@ make_ip4_setting(shvarFile *ifcfg, if (v) { gs_free const char **searches = NULL; - searches = nm_utils_strsplit_set(v, " "); + searches = nm_strsplit_set(v, " "); if (searches) { for (item = searches; *item; item++) { if (!nm_setting_ip_config_add_dns_search(s_ip4, *item)) @@ -2249,6 +2260,7 @@ make_ip6_setting(shvarFile *ifcfg, shvarFile *network_ifcfg, gboolean routes_rea gboolean ip6_privacy = FALSE, ip6_privacy_prefer_public_ip; NMSettingIP6ConfigPrivacy ip6_privacy_val; guint32 route_table; + gboolean is_disabled; s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); @@ -2375,10 +2387,9 @@ make_ip6_setting(shvarFile *ifcfg, shvarFile *network_ifcfg, gboolean routes_rea NULL); /* Don't bother to read IP, DNS and routes when IPv6 is disabled */ - if (NM_IN_STRSET(method, - NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_METHOD_DISABLED)) - return NM_SETTING(g_steal_pointer(&s_ip6)); + is_disabled = NM_IN_STRSET(method, + NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP6_CONFIG_METHOD_DISABLED); nm_clear_g_free(&value); v = svGetValueStr(ifcfg, "DHCPV6_DUID", &value); @@ -2437,16 +2448,24 @@ make_ip6_setting(shvarFile *ifcfg, shvarFile *network_ifcfg, gboolean routes_rea ipv6addr_secondaries ?: "", NULL); - list = nm_utils_strsplit_set(value, " "); - for (iter = list, i = 0; iter && *iter; iter++, i++) { - NMIPAddress *addr = NULL; + list = nm_strsplit_set(value, " "); + if (list) { + if (is_disabled) + PARSE_WARNING("ignore IPv6 addresses with method disabled/ignore"); + else { + for (iter = list, i = 0; *iter; iter++, i++) { + nm_auto_unref_ip_address NMIPAddress *addr = NULL; - if (!parse_full_ip6_address(ifcfg, *iter, i, &addr, error)) - return NULL; + if (!parse_full_ip6_address(ifcfg, *iter, i, &addr, is_disabled ? NULL : error)) { + if (is_disabled) + break; + return NULL; + } - if (!nm_setting_ip_config_add_address(s_ip6, addr)) - PARSE_WARNING("duplicate IP6 address"); - nm_ip_address_unref(addr); + if (!nm_setting_ip_config_add_address(s_ip6, addr)) + PARSE_WARNING("duplicate IP6 address"); + } + } } /* Gateway */ @@ -2462,18 +2481,20 @@ make_ip6_setting(shvarFile *ifcfg, shvarFile *network_ifcfg, gboolean routes_rea } if (v) { char *ptr; + if ((ptr = strchr(v, '%')) != NULL) *ptr = '\0'; /* remove %interface prefix if present */ if (!nm_utils_ipaddr_is_valid(AF_INET6, v)) { - g_set_error(error, - NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Invalid IP6 address '%s'", - v); - return NULL; - } - - g_object_set(s_ip6, NM_SETTING_IP_CONFIG_GATEWAY, v, NULL); + if (!is_disabled) { + g_set_error(error, + NM_SETTINGS_ERROR, + NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IP6 address '%s'", + v); + return NULL; + } + } else + g_object_set(s_ip6, NM_SETTING_IP_CONFIG_GATEWAY, v, NULL); } } @@ -2497,23 +2518,27 @@ make_ip6_setting(shvarFile *ifcfg, shvarFile *network_ifcfg, gboolean routes_rea /* DNS servers * Pick up just IPv6 addresses (IPv4 addresses are taken by make_ip4_setting()) */ - for (i = 1; i <= 10; i++) { + for (i = 1; i < 10000; i++) { char tag[256]; numbered_tag(tag, "DNS", i); nm_clear_g_free(&value); v = svGetValueStr(ifcfg, tag, &value); - if (!v) { - /* all done */ + if (!v) break; - } if (nm_utils_ipaddr_is_valid(AF_INET6, v)) { + if (is_disabled) { + PARSE_WARNING("ignore DNS server addresses with method disabled/ignore"); + break; + } if (!nm_setting_ip_config_add_dns(s_ip6, v)) PARSE_WARNING("duplicate DNS server %s", tag); } else if (nm_utils_ipaddr_is_valid(AF_INET, v)) { /* Ignore IPv4 addresses */ } else { + if (is_disabled) + continue; g_set_error(error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, @@ -2540,11 +2565,15 @@ make_ip6_setting(shvarFile *ifcfg, shvarFile *network_ifcfg, gboolean routes_rea if (v) { gs_free const char **searches = NULL; - searches = nm_utils_strsplit_set(v, " "); + searches = nm_strsplit_set(v, " "); if (searches) { - for (iter = searches; *iter; iter++) { - if (!nm_setting_ip_config_add_dns_search(s_ip6, *iter)) - PARSE_WARNING("duplicate DNS domain '%s'", *iter); + if (is_disabled) { + PARSE_WARNING("ignore IPV6_DOMAIN with method disabled/ignore"); + } else { + for (iter = searches; *iter; iter++) { + if (!nm_setting_ip_config_add_dns_search(s_ip6, *iter)) + PARSE_WARNING("duplicate DNS domain '%s'", *iter); + } } } } @@ -2957,7 +2986,7 @@ read_dcb_percent_array(shvarFile * ifcfg, return TRUE; } - split = nm_utils_strsplit_set(val, ","); + split = nm_strsplit_set(val, ","); if (NM_PTRARRAY_LEN(split) != 8) { PARSE_WARNING("invalid %s percentage list value '%s'", prop, val); g_set_error_literal(error, @@ -3001,6 +3030,7 @@ make_dcb_setting(shvarFile *ifcfg, NMSetting **out_setting, GError **error) gs_unref_object NMSettingDcb *s_dcb = NULL; gboolean dcb_on; NMSettingDcbFlags flags = NM_SETTING_DCB_FLAG_NONE; + gs_free char * val = NULL; g_return_val_if_fail(out_setting, FALSE); *out_setting = NULL; @@ -3020,21 +3050,18 @@ make_dcb_setting(shvarFile *ifcfg, NMSetting **out_setting, GError **error) error)) { return FALSE; } - if (nm_setting_dcb_get_app_fcoe_flags(s_dcb) & NM_SETTING_DCB_FLAG_ENABLE) { - gs_free char *val = NULL; - val = svGetValueStr_cp(ifcfg, KEY_DCB_APP_FCOE_MODE); - if (val) { - if (NM_IN_STRSET(val, NM_SETTING_DCB_FCOE_MODE_FABRIC, NM_SETTING_DCB_FCOE_MODE_VN2VN)) - g_object_set(G_OBJECT(s_dcb), NM_SETTING_DCB_APP_FCOE_MODE, val, NULL); - else { - PARSE_WARNING("invalid FCoE mode '%s'", val); - g_set_error_literal(error, - NM_SETTINGS_ERROR, - NM_SETTINGS_ERROR_INVALID_CONNECTION, - "invalid FCoE mode"); - return FALSE; - } + val = svGetValueStr_cp(ifcfg, KEY_DCB_APP_FCOE_MODE); + if (val) { + if (NM_IN_STRSET(val, NM_SETTING_DCB_FCOE_MODE_FABRIC, NM_SETTING_DCB_FCOE_MODE_VN2VN)) + g_object_set(G_OBJECT(s_dcb), NM_SETTING_DCB_APP_FCOE_MODE, val, NULL); + else { + PARSE_WARNING("invalid FCoE mode '%s'", val); + g_set_error_literal(error, + NM_SETTINGS_ERROR, + NM_SETTINGS_ERROR_INVALID_CONNECTION, + "invalid FCoE mode"); + return FALSE; } } @@ -3376,7 +3403,7 @@ fill_wpa_ciphers(shvarFile *ifcfg, NMSettingWirelessSecurity *wsec, gboolean gro if (!p) return TRUE; - list = nm_utils_strsplit_set(p, " "); + list = nm_strsplit_set(p, " "); for (iter = list; iter && *iter; iter++, i++) { if (!strcmp(*iter, "CCMP")) { if (group) @@ -3612,7 +3639,7 @@ parse_8021x_phase2_auth(shvarFile * ifcfg, } inner_auth = g_ascii_strdown(v, -1); - list = nm_utils_strsplit_set(inner_auth, " "); + list = nm_strsplit_set(inner_auth, " "); for (iter = list; iter && *iter; iter++) { if (NM_IN_STRSET(*iter, "pap", "chap", "mschap", "mschapv2", "gtc", "otp", "md5")) { if (num_auth == 0) { @@ -3787,7 +3814,7 @@ eap_fast_reader(const char * eap_method, if (fast_provisioning) { gs_free const char **list = NULL; - list = nm_utils_strsplit_set(fast_provisioning, " \t"); + list = nm_strsplit_set(fast_provisioning, " \t"); for (iter = list; iter && *iter; iter++) { if (strcmp(*iter, "allow-unauth") == 0) allow_unauth = TRUE; @@ -3865,7 +3892,7 @@ read_8021x_list_value(shvarFile * ifcfg, if (!v) return; - strv = nm_utils_strsplit_set(v, " \t"); + strv = nm_strsplit_set(v, " \t"); if (strv) g_object_set(setting, prop_name, strv, NULL); } @@ -3892,7 +3919,7 @@ fill_8021x(shvarFile *ifcfg, const char *file, const char *key_mgmt, gboolean wi return NULL; } - list = nm_utils_strsplit_set(v, " "); + list = nm_strsplit_set(v, " "); s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); @@ -4245,7 +4272,7 @@ transform_hwaddr_blacklist(const char *blacklist) const char **strv; gsize i, j; - strv = nm_utils_strsplit_set(blacklist, " \t"); + strv = nm_strsplit_set(blacklist, " \t"); if (!strv) return NULL; for (i = 0, j = 0; strv[j]; j++) { @@ -4714,7 +4741,7 @@ parse_ethtool_option(const char * value, gs_free const char **words = NULL; NMEthtoolType ethtool_type = NM_ETHTOOL_TYPE_UNKNOWN; - words = nm_utils_strsplit_set(value, " \t\n"); + words = nm_strsplit_set(value, " \t\n"); if (!words) return; @@ -4976,7 +5003,7 @@ parse_ethtool_options(shvarFile *ifcfg, NMConnection *connection) gs_free const char **opts = NULL; const char *const * iter; - opts = nm_utils_strsplit_set(ethtool_opts, ";"); + opts = nm_strsplit_set(ethtool_opts, ";"); for (iter = opts; iter && iter[0]; iter++) { /* in case of repeated wol_passwords, parse_ethtool_option() * will do the right thing and clear wol_password before resetting. */ @@ -5084,7 +5111,7 @@ make_wired_setting(shvarFile *ifcfg, const char *file, NMSetting8021x **s_8021x, gs_free const char **chans = NULL; guint32 num_chans; - chans = nm_utils_strsplit_set(cvalue, ","); + chans = nm_strsplit_set(cvalue, ","); num_chans = NM_PTRARRAY_LEN(chans); if (num_chans < 2 || num_chans > 3) { PARSE_WARNING("invalid SUBCHANNELS '%s' (%u channels, 2 or 3 expected)", @@ -5456,7 +5483,7 @@ make_bond_setting(shvarFile *ifcfg, const char *file, GError **error) gs_free const char **items = NULL; const char *const * iter; - items = nm_utils_strsplit_set(v, " "); + items = nm_strsplit_set(v, " "); for (iter = items; iter && *iter; iter++) { gs_free char *key = NULL; const char * val; @@ -5474,6 +5501,31 @@ make_bond_setting(shvarFile *ifcfg, const char *file, GError **error) return (NMSetting *) s_bond; } +static NMSetting * +make_bond_port_setting(shvarFile *ifcfg) +{ + NMSetting * s_port = NULL; + gs_free char *value_to_free = NULL; + const char * value; + guint queue_id; + + g_return_val_if_fail(ifcfg != NULL, FALSE); + + value = svGetValue(ifcfg, "BOND_PORT_QUEUE_ID", &value_to_free); + if (value) { + s_port = nm_setting_bond_port_new(); + queue_id = + _nm_utils_ascii_str_to_uint64(value, 10, 0, G_MAXUINT16, NM_BOND_PORT_QUEUE_ID_DEF); + if (errno != 0) { + PARSE_WARNING("Invalid bond port queue_id value '%s'", value); + return s_port; + } + g_object_set(G_OBJECT(s_port), NM_SETTING_BOND_PORT_QUEUE_ID, queue_id, NULL); + } + + return s_port; +} + static NMConnection * bond_connection_from_ifcfg(const char *file, shvarFile *ifcfg, GError **error) { @@ -5766,7 +5818,7 @@ handle_bridging_opts(NMSetting * setting, gs_free const char **items = NULL; const char *const * iter; - items = nm_utils_strsplit_set(value, " "); + items = nm_strsplit_set(value, " "); for (iter = items; iter && *iter; iter++) { gs_free char *key = NULL; const char * val; @@ -6027,7 +6079,7 @@ parse_prio_map_list(NMSettingVlan *s_vlan, shvarFile *ifcfg, const char *key, NM v = svGetValueStr(ifcfg, key, &value); if (!v) return; - list = nm_utils_strsplit_set(v, ","); + list = nm_strsplit_set(v, ","); for (iter = list; iter && *iter; iter++) { if (!strchr(*iter, ':')) @@ -6138,7 +6190,7 @@ make_vlan_setting(shvarFile *ifcfg, const char *file, GError **error) gs_free const char **strv = NULL; const char *const * ptr; - strv = nm_utils_strsplit_set(v, ", "); + strv = nm_strsplit_set(v, ", "); for (ptr = strv; ptr && *ptr; ptr++) { if (nm_streq(*ptr, "GVRP") && gvrp == -1) vlan_flags |= NM_VLAN_FLAG_GVRP; @@ -6284,7 +6336,7 @@ check_dns_search_domains(shvarFile *ifcfg, NMSetting *s_ip4, NMSetting *s_ip6) gs_free const char **searches = NULL; const char *const * item; - searches = nm_utils_strsplit_set(v, " "); + searches = nm_strsplit_set(v, " "); if (searches) { for (item = searches; *item; item++) { if (!nm_setting_ip_config_add_dns_search(NM_SETTING_IP_CONFIG(s_ip6), *item)) @@ -6641,6 +6693,10 @@ connection_from_file_full(const char *filename, if (setting) nm_connection_add_setting(connection, setting); + setting = make_bond_port_setting(main_ifcfg); + if (setting) + nm_connection_add_setting(connection, setting); + setting = make_team_port_setting(main_ifcfg); if (setting) nm_connection_add_setting(connection, setting); diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-storage.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-storage.c index 134bdf68..3feb4440 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-storage.c +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-storage.c @@ -112,7 +112,7 @@ nms_ifcfg_rh_storage_new_connection(NMSIfcfgRHPlugin * plugin, nm_assert(NM_IS_CONNECTION(connection_take)); nm_assert(_nm_connection_verify(connection_take, NULL) == NM_SETTING_VERIFY_SUCCESS); - nmtst_connection_assert_unchanging(connection_take); + nm_assert_connection_unchanging(connection_take); self = _storage_new(plugin, nm_connection_get_uuid(connection_take), filename); self->connection = connection_take; diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c index febfc120..1afdf8ee 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c @@ -827,6 +827,7 @@ const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[] = { _KEY_TYPE("BAND", NMS_IFCFG_KEY_TYPE_IS_PLAIN), _KEY_TYPE("BONDING_MASTER", NMS_IFCFG_KEY_TYPE_IS_PLAIN), _KEY_TYPE("BONDING_OPTS", NMS_IFCFG_KEY_TYPE_IS_PLAIN), + _KEY_TYPE("BOND_PORT_QUEUE_ID", NMS_IFCFG_KEY_TYPE_IS_PLAIN), _KEY_TYPE("BOOTPROTO", NMS_IFCFG_KEY_TYPE_IS_PLAIN), _KEY_TYPE("BRIDGE", NMS_IFCFG_KEY_TYPE_IS_PLAIN), _KEY_TYPE("BRIDGE_MACADDR", NMS_IFCFG_KEY_TYPE_IS_PLAIN), @@ -891,6 +892,7 @@ const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[] = { _KEY_TYPE("DHCPv6_DUID", NMS_IFCFG_KEY_TYPE_IS_PLAIN), _KEY_TYPE("DHCPv6_IAID", NMS_IFCFG_KEY_TYPE_IS_PLAIN), _KEY_TYPE("DNS", NMS_IFCFG_KEY_TYPE_IS_NUMBERED), + _KEY_TYPE("DNS_OVER_TLS", NMS_IFCFG_KEY_TYPE_IS_PLAIN), _KEY_TYPE("DOMAIN", NMS_IFCFG_KEY_TYPE_IS_PLAIN), _KEY_TYPE("ESSID", NMS_IFCFG_KEY_TYPE_IS_PLAIN), _KEY_TYPE("ETHTOOL_OPTS", NMS_IFCFG_KEY_TYPE_IS_PLAIN), diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h index b7751ec9..6b396a9a 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h @@ -33,7 +33,7 @@ typedef struct { NMSIfcfgKeyTypeFlags key_flags; } NMSIfcfgKeyTypeInfo; -extern const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[251]; +extern const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[253]; const NMSIfcfgKeyTypeInfo *nms_ifcfg_well_known_key_find_info(const char *key, gssize *out_idx); diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c index ef85b6bf..263c9253 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c @@ -19,6 +19,7 @@ #include "libnm-glib-aux/nm-str-buf.h" #include "libnm-glib-aux/nm-io-utils.h" #include "nm-manager.h" +#include "nm-setting-bond-port.h" #include "nm-setting-connection.h" #include "nm-setting-wired.h" #include "nm-setting-wireless.h" @@ -204,18 +205,18 @@ write_object(NMSetting8021x * s_8021x, g_return_val_if_fail(ifcfg != NULL, FALSE); g_return_val_if_fail(objtype != NULL, FALSE); - scheme = (*(objtype->vtable->scheme_func)) (s_8021x); + scheme = (*(objtype->vtable->scheme_func))(s_8021x); switch (scheme) { case NM_SETTING_802_1X_CK_SCHEME_UNKNOWN: break; case NM_SETTING_802_1X_CK_SCHEME_BLOB: - blob = (*(objtype->vtable->blob_func)) (s_8021x); + blob = (*(objtype->vtable->blob_func))(s_8021x); break; case NM_SETTING_802_1X_CK_SCHEME_PATH: - value = (*(objtype->vtable->path_func)) (s_8021x); + value = (*(objtype->vtable->path_func))(s_8021x); break; case NM_SETTING_802_1X_CK_SCHEME_PKCS11: - value = (*(objtype->vtable->uri_func)) (s_8021x); + value = (*(objtype->vtable->uri_func))(s_8021x); break; default: g_set_error(error, @@ -228,8 +229,8 @@ write_object(NMSetting8021x * s_8021x, /* Set the password for certificate/private key. */ nm_sprintf_buf(secret_name, "%s_PASSWORD", objtype->ifcfg_rh_key); nm_sprintf_buf(secret_flags, "%s_PASSWORD_FLAGS", objtype->ifcfg_rh_key); - password = (*(objtype->vtable->passwd_func)) (s_8021x); - flags = (*(objtype->vtable->pwflag_func)) (s_8021x); + password = (*(objtype->vtable->passwd_func))(s_8021x); + flags = (*(objtype->vtable->pwflag_func))(s_8021x); set_secret(ifcfg, secrets, secret_name, password, secret_flags, flags); if (!objtype->vtable->format_func) @@ -1442,12 +1443,12 @@ write_vlan_setting(NMConnection *connection, shvarFile *ifcfg, gboolean *wired, svSetValueBoolean(ifcfg, "REORDER_HDR", NM_FLAGS_HAS(vlan_flags, NM_VLAN_FLAG_REORDER_HEADERS)); svSetValueBoolean(ifcfg, "GVRP", NM_FLAGS_HAS(vlan_flags, NM_VLAN_FLAG_GVRP)); - nm_utils_strbuf_init(s_buf, &s_buf_ptr, &s_buf_len); + nm_strbuf_init_arr(s_buf, &s_buf_ptr, &s_buf_len); if (NM_FLAGS_HAS(vlan_flags, NM_VLAN_FLAG_LOOSE_BINDING)) - nm_utils_strbuf_append_str(&s_buf_ptr, &s_buf_len, "LOOSE_BINDING"); + nm_strbuf_append_str(&s_buf_ptr, &s_buf_len, "LOOSE_BINDING"); if (!NM_FLAGS_HAS(vlan_flags, NM_VLAN_FLAG_REORDER_HEADERS)) - nm_utils_strbuf_append(&s_buf_ptr, &s_buf_len, "%sNO_REORDER_HDR", s_buf[0] ? "," : ""); + nm_strbuf_append(&s_buf_ptr, &s_buf_len, "%sNO_REORDER_HDR", s_buf[0] ? "," : ""); svSetValueStr(ifcfg, "VLAN_FLAGS", s_buf); @@ -1888,6 +1889,16 @@ write_bridge_port_setting(NMConnection *connection, shvarFile *ifcfg, GError **e return TRUE; } +static void +write_bond_port_setting(NMConnection *connection, shvarFile *ifcfg) +{ + NMSettingBondPort *s_port; + + s_port = _nm_connection_get_setting(connection, NM_TYPE_SETTING_BOND_PORT); + if (s_port) + svSetValueInt64(ifcfg, "BOND_PORT_QUEUE_ID", nm_setting_bond_port_get_queue_id(s_port)); +} + static gboolean write_team_port_setting(NMConnection *connection, shvarFile *ifcfg, GError **error) { @@ -2020,8 +2031,7 @@ write_dcb_setting(NMConnection *connection, shvarFile *ifcfg, GError **error) "APP_FCOE", nm_setting_dcb_get_app_fcoe_flags(s_dcb), nm_setting_dcb_get_app_fcoe_priority(s_dcb)); - if (nm_setting_dcb_get_app_fcoe_flags(s_dcb) & NM_SETTING_DCB_FLAG_ENABLE) - svSetValueStr(ifcfg, KEY_DCB_APP_FCOE_MODE, nm_setting_dcb_get_app_fcoe_mode(s_dcb)); + svSetValueStr(ifcfg, KEY_DCB_APP_FCOE_MODE, nm_setting_dcb_get_app_fcoe_mode(s_dcb)); write_dcb_app(ifcfg, "APP_ISCSI", @@ -2076,6 +2086,7 @@ write_connection_setting(NMSettingConnection *s_con, shvarFile *ifcfg) gint32 vint32; NMSettingConnectionMdns mdns; NMSettingConnectionLlmnr llmnr; + NMSettingConnectionDnsOverTls dns_over_tls; guint32 vuint32; const char * tmp, *mud_url; @@ -2259,6 +2270,14 @@ write_connection_setting(NMSettingConnection *s_con, shvarFile *ifcfg) if (llmnr != NM_SETTING_CONNECTION_LLMNR_DEFAULT) { svSetValueEnum(ifcfg, "LLMNR", nm_setting_connection_llmnr_get_type(), llmnr); } + + dns_over_tls = nm_setting_connection_get_dns_over_tls(s_con); + if (dns_over_tls != NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT) { + svSetValueEnum(ifcfg, + "DNS_OVER_TLS", + nm_setting_connection_dns_over_tls_get_type(), + dns_over_tls); + } } static char * @@ -2685,12 +2704,11 @@ write_dns_setting(shvarFile *ifcfg, NMConnection *connection, int addr_family) } } -static gboolean +static void write_ip4_setting(NMConnection *connection, shvarFile * ifcfg, shvarFile ** out_route_content_svformat, - GString ** out_route_content, - GError ** error) + GString ** out_route_content) { NMSettingIPConfig * s_ip4; const char * value; @@ -2713,7 +2731,7 @@ write_ip4_setting(NMConnection *connection, s_ip4 = nm_connection_get_setting_ip4_config(connection); if (!s_ip4) - return TRUE; + return; method = nm_setting_ip_config_get_method(s_ip4); @@ -2722,7 +2740,7 @@ write_ip4_setting(NMConnection *connection, method = NM_SETTING_IP4_CONFIG_METHOD_AUTO; if (nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) - return TRUE; + return; num = nm_setting_ip_config_get_num_addresses(s_ip4); @@ -2881,8 +2899,6 @@ write_ip4_setting(NMConnection *connection, } svSetValueStr(ifcfg, "DHCP_REJECT_SERVERS", str->str); } - - return TRUE; } static void @@ -2968,11 +2984,8 @@ write_ip4_aliases(NMConnection *connection, const char *base_ifcfg_path) } } -static gboolean -write_ip6_setting(NMConnection *connection, - shvarFile * ifcfg, - GString ** out_route6_content, - GError ** error) +static void +write_ip6_setting(NMConnection *connection, shvarFile *ifcfg, GString **out_route6_content) { NMSettingIPConfig * s_ip6; const char * value; @@ -2991,17 +3004,15 @@ write_ip6_setting(NMConnection *connection, s_ip6 = nm_connection_get_setting_ip6_config(connection); if (!s_ip6) - return TRUE; + return; value = nm_setting_ip_config_get_method(s_ip6); g_assert(value); if (!strcmp(value, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) { svSetValueStr(ifcfg, "IPV6INIT", "no"); - return TRUE; } else if (!strcmp(value, NM_SETTING_IP6_CONFIG_METHOD_DISABLED)) { svSetValueStr(ifcfg, "IPV6_DISABLED", "yes"); svSetValueStr(ifcfg, "IPV6INIT", "no"); - return TRUE; } else if (!strcmp(value, NM_SETTING_IP6_CONFIG_METHOD_AUTO)) { svSetValueStr(ifcfg, "IPV6INIT", "yes"); svSetValueStr(ifcfg, "IPV6_AUTOCONF", "yes"); @@ -3148,8 +3159,6 @@ write_ip6_setting(NMConnection *connection, write_res_options(ifcfg, s_ip6, "IPV6_RES_OPTIONS"); NM_SET_OUT(out_route6_content, write_route_file(s_ip6)); - - return TRUE; } static void @@ -3228,10 +3237,11 @@ do_write_construct(NMConnection * connection, GError ** error) { NMSettingConnection * s_con; - nm_auto_shvar_file_close shvarFile *ifcfg = NULL; - gs_free char * ifcfg_name = NULL; - gs_free char * route_path = NULL; - gs_free char * route6_path = NULL; + nm_auto_shvar_file_close shvarFile *ifcfg = NULL; + const char * ifcfg_name; + gs_free char * ifcfg_name_free = NULL; + gs_free char * route_path = NULL; + gs_free char * route6_path = NULL; const char * type; gs_unref_hashtable GHashTable *blobs = NULL; gs_unref_hashtable GHashTable *secrets = NULL; @@ -3255,11 +3265,7 @@ do_write_construct(NMConnection * connection, if (filename) { /* For existing connections, 'filename' should be full path to ifcfg file */ - ifcfg = svOpenFile(filename, error); - if (!ifcfg) - return FALSE; - - ifcfg_name = g_strdup(filename); + ifcfg_name = filename; } else if (ifcfg_dir) { gs_free char *escaped = NULL; int i_path; @@ -3280,21 +3286,27 @@ do_write_construct(NMConnection * connection, if (g_file_test(path_candidate, G_FILE_TEST_EXISTS)) continue; - ifcfg_name = g_steal_pointer(&path_candidate); + ifcfg_name_free = g_steal_pointer(&path_candidate); break; } - if (!ifcfg_name) { + if (!ifcfg_name_free) { g_set_error_literal(error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Failed to find usable ifcfg file name"); return FALSE; } + ifcfg_name = ifcfg_name_free; + } else { + g_set_error(error, + NM_SETTINGS_ERROR, + NM_SETTINGS_ERROR_FAILED, + "No file name given for storing profile to ifcfg-rh"); + g_return_val_if_reached(FALSE); + } - ifcfg = svCreateFile(ifcfg_name); - } else - ifcfg = svCreateFile("/tmp/ifcfg-dummy"); + ifcfg = svCreateFile(ifcfg_name); route_path = utils_get_route_path(svFileGetName(ifcfg)); if (!route_path) { @@ -3377,6 +3389,8 @@ do_write_construct(NMConnection * connection, if (!write_bridge_port_setting(connection, ifcfg, error)) return FALSE; + write_bond_port_setting(connection, ifcfg); + if (!write_team_port_setting(connection, ifcfg, error)) return FALSE; @@ -3441,15 +3455,12 @@ do_write_construct(NMConnection * connection, } else route_ignore = FALSE; - if (!write_ip4_setting(connection, - ifcfg, - !route_ignore && route_path_is_svformat ? &route_content_svformat : NULL, - !route_ignore && route_path_is_svformat ? NULL : &route_content, - error)) - return FALSE; + write_ip4_setting(connection, + ifcfg, + !route_ignore && route_path_is_svformat ? &route_content_svformat : NULL, + !route_ignore && route_path_is_svformat ? NULL : &route_content); - if (!write_ip6_setting(connection, ifcfg, !route_ignore ? &route6_content : NULL, error)) - return FALSE; + write_ip6_setting(connection, ifcfg, !route_ignore ? &route6_content : NULL); write_ip_routing_rules(connection, ifcfg, route_ignore); diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-System_test-wired-802-1X-subj-matches.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-System_test-wired-802-1X-subj-matches.cexpected index 240cd5c1..d2f5c453 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-System_test-wired-802-1X-subj-matches.cexpected +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-System_test-wired-802-1X-subj-matches.cexpected @@ -16,6 +16,8 @@ BOOTPROTO=dhcp DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no NAME="System test-wired-802-1X-subj-matches" UUID=${UUID} DEVICE=eth0 diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Bond_Main.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Bond_Main.cexpected index b288c04a..ccc0f35a 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Bond_Main.cexpected +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Bond_Main.cexpected @@ -11,6 +11,9 @@ GATEWAY=1.1.1.1 DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no +IPV6_ADDR_GEN_MODE=stable-privacy NAME="Test Write Bond Main" UUID=${UUID} DEVICE=bond0 diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Permissions.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Permissions.cexpected index 80e96921..d4a978b6 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Permissions.cexpected +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Permissions.cexpected @@ -5,6 +5,9 @@ BOOTPROTO=dhcp DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no +IPV6_ADDR_GEN_MODE=stable-privacy NAME="Test Write Permissions" UUID=${UUID} ONBOOT=yes diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wifi_LEAP.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wifi_LEAP.cexpected index d3db19b2..f1b01a21 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wifi_LEAP.cexpected +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wifi_LEAP.cexpected @@ -11,6 +11,9 @@ BOOTPROTO=dhcp DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no +IPV6_ADDR_GEN_MODE=stable-privacy NAME="Test Write Wifi LEAP" UUID=${UUID} ONBOOT=yes diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wifi_WEP_104_ASCII.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wifi_WEP_104_ASCII.cexpected index 32db7262..60540fbe 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wifi_WEP_104_ASCII.cexpected +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wifi_WEP_104_ASCII.cexpected @@ -10,6 +10,9 @@ BOOTPROTO=dhcp DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no +IPV6_ADDR_GEN_MODE=stable-privacy NAME="Test Write Wifi WEP 104 ASCII" UUID=${UUID} ONBOOT=yes diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_Static_Routes.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_Static_Routes.cexpected index cc29a2cc..fe864c43 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_Static_Routes.cexpected +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_Static_Routes.cexpected @@ -17,6 +17,8 @@ IPV4_FAILURE_FATAL=no ACD_TIMEOUT=400 ARPING_WAIT=1 IPV6INIT=no +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no NAME="Test Write Wired Static Routes" UUID=${UUID} ONBOOT=yes diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_match.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_match.cexpected index 9499278e..908cb917 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_match.cexpected +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Test_Write_Wired_match.cexpected @@ -8,6 +8,8 @@ BOOTPROTO=dhcp DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no NAME="Test Write Wired with Match setting" UUID=${UUID} ONBOOT=yes diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Vlan_test-vlan-interface.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Vlan_test-vlan-interface.cexpected index 44eb777c..6ad151aa 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Vlan_test-vlan-interface.cexpected +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-Vlan_test-vlan-interface.cexpected @@ -17,6 +17,8 @@ PREFIX=24 DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no NAME="Vlan test-vlan-interface" UUID=${UUID} DEVICE=vlan43 diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-dcb-test.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-dcb-test.cexpected index 56e233cc..fef36f2f 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-dcb-test.cexpected +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-dcb-test.cexpected @@ -4,7 +4,6 @@ DCB_APP_FCOE_ENABLE=yes DCB_APP_FCOE_ADVERTISE=yes DCB_APP_FCOE_WILLING=yes DCB_APP_FCOE_PRIORITY=5 -DCB_APP_FCOE_MODE=fabric DCB_APP_ISCSI_ENABLE=yes DCB_APP_ISCSI_ADVERTISE=yes DCB_APP_ISCSI_WILLING=yes diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-random_wifi_connection.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-random_wifi_connection.cexpected index ead3a047..1f5e04ff 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-random_wifi_connection.cexpected +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-random_wifi_connection.cexpected @@ -8,6 +8,8 @@ BOOTPROTO=dhcp DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no NAME="random wifi connection" UUID=${UUID} ONBOOT=yes diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-random_wifi_connection_2.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-random_wifi_connection_2.cexpected index 7bc1ae6c..3dcdbda0 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-random_wifi_connection_2.cexpected +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-random_wifi_connection_2.cexpected @@ -8,6 +8,8 @@ BOOTPROTO=dhcp DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no NAME="random wifi connection 2" UUID=${UUID} ONBOOT=yes diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bond-port b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bond-port new file mode 100644 index 00000000..111924c0 --- /dev/null +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-bond-port @@ -0,0 +1,9 @@ +TYPE=Ethernet +NAME=eth0 +UUID=43737e70-7c4f-4b67-9f4f-6d2d4747b1ff +DEVICE=eth0 +ONBOOT=yes +LLDP=no +MASTER=bond99 +SLAVE=yes +BOND_PORT_QUEUE_ID=1 diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ip6-disabled.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ip6-disabled.cexpected index cae51b89..b3199c01 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ip6-disabled.cexpected +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-ip6-disabled.cexpected @@ -6,6 +6,8 @@ DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6_DISABLED=yes IPV6INIT=no +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no NAME="Test Write Wired Disabled IP6" UUID=${UUID} ONBOOT=yes diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-sriov-write.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-sriov-write.cexpected index c882c479..a77c615d 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-sriov-write.cexpected +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-sriov-write.cexpected @@ -12,6 +12,9 @@ GATEWAY=1.1.1.1 DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no +IPV6_ADDR_GEN_MODE=stable-privacy NAME="Test Write SR-IOV config" UUID=${UUID} DEVICE=eth0 diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-static-routes-legacy.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-static-routes-legacy.cexpected index 8197f320..41714df6 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-static-routes-legacy.cexpected +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-static-routes-legacy.cexpected @@ -6,6 +6,8 @@ BOOTPROTO=dhcp DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no NAME=test-static-routes-legacy UUID=ba60d05a-7898-820d-c2db-427a88f8f2a5 DEVICE=eth0 diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-tc-write-empty.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-tc-write-empty.cexpected index 4df768b4..1125ef55 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-tc-write-empty.cexpected +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-tc-write-empty.cexpected @@ -9,6 +9,9 @@ GATEWAY=1.1.1.1 DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no +IPV6_ADDR_GEN_MODE=stable-privacy NAME="Test Write TC config" UUID=${UUID} DEVICE=eth0 diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-tc-write.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-tc-write.cexpected index a67ca598..d87efd72 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-tc-write.cexpected +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-tc-write.cexpected @@ -10,6 +10,9 @@ GATEWAY=1.1.1.1 DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no +IPV6_ADDR_GEN_MODE=stable-privacy NAME="Test Write TC config" UUID=${UUID} DEVICE=eth0 diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-vlanid-use.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-vlanid-use.cexpected index a7be14ce..2eaec850 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-vlanid-use.cexpected +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-vlanid-use.cexpected @@ -9,6 +9,8 @@ HWADDR= PROXY_METHOD=none BROWSER_ONLY=no IPV6INIT=no +IPV6_DEFROUTE=yes +IPV6_FAILURE_FATAL=no NAME="Vlan test-vlan-vlanid-use" UUID=${UUID} DEVICE=eth0.9 diff --git a/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index d9829f84..b1cfdfec 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -167,9 +167,8 @@ _assert_expected_content(NMConnection *connection, const char *filename, const c g_string_erase(str, i, NM_STRLEN("${UUID}")); g_string_insert_len(str, i, uuid, j); - g_free(content_expectd); - len_expectd = str->len; - content_expectd = g_string_free(str, FALSE); + len_expectd = str->len; + nm_strdup_reset_take(&content_expectd, g_string_free(str, FALSE)); i += j; continue; } @@ -344,7 +343,7 @@ _writer_new_connection_reread(NMConnection * connection, { gboolean success; GError * error = NULL; - char * filename = NULL; + gs_free char * filename = NULL; gs_unref_object NMConnection *con_verified = NULL; gs_unref_object NMConnection *reread_copy = NULL; NMConnection **reread = out_reread ?: ((nmtst_get_rand_uint32() % 2) ? &reread_copy : NULL); @@ -372,11 +371,9 @@ _writer_new_connection_reread(NMConnection * connection, _assert_expected_content(con_verified, filename, expected); if (out_filename) - *out_filename = filename; - else { + *out_filename = g_steal_pointer(&filename); + else nmtst_file_unlink(filename); - g_free(filename); - } } static void @@ -467,12 +464,10 @@ test_read_netmask_1(void) connection = _connection_from_file(FILENAME, NULL, TYPE_ETHERNET, NULL); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System netmask-1"); - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpuint(nm_setting_ip_config_get_num_dns(s_ip4), ==, 1); ip4_addr = nm_setting_ip_config_get_address(s_ip4, 0); g_assert(ip4_addr); @@ -501,12 +496,12 @@ verify_cert_or_key(NMSetting8021x *s_compare, const char * privkey_password, const char * property) { - NMSetting8021x * s_8021x; - GError * error = NULL; - gboolean success = FALSE; - const char * expected = NULL, *setting = NULL; - gboolean phase2 = FALSE; - NMSetting8021xCKScheme scheme = NM_SETTING_802_1X_CK_SCHEME_UNKNOWN; + gs_unref_object NMSetting8021x *s_8021x = NULL; + GError * error = NULL; + gboolean success = FALSE; + const char * expected = NULL, *setting = NULL; + gboolean phase2 = FALSE; + NMSetting8021xCKScheme scheme = NM_SETTING_802_1X_CK_SCHEME_UNKNOWN; if (strstr(property, "phase2")) phase2 = TRUE; @@ -615,28 +610,24 @@ verify_cert_or_key(NMSetting8021x *s_compare, setting = nm_setting_802_1x_get_private_key_path(s_compare); } g_assert_cmpstr(setting, ==, expected); - - g_object_unref(s_8021x); return TRUE; } static void test_read_basic(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - const char * mac; - char expected_mac_address[ETH_ALEN] = {0x00, 0x16, 0x41, 0x11, 0x22, 0x33}; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWired * s_wired; + NMSettingIPConfig * s_ip4; + NMSettingIPConfig * s_ip6; + const char * mac; + char expected_mac_address[ETH_ALEN] = {0x00, 0x16, 0x41, 0x11, 0x22, 0x33}; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-minimal", NULL, TYPE_ETHERNET, NULL); - /* ===== CONNECTION SETTING ===== */ - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System test-minimal"); g_assert_cmpint(nm_setting_connection_get_timestamp(s_con), ==, 0); g_assert(nm_setting_connection_get_autoconnect(s_con)); @@ -647,47 +638,38 @@ test_read_basic(void) * depending on where the tests are run. */ - /* ===== WIRED SETTING ===== */ - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); g_assert_cmpint(nm_setting_wired_get_mtu(s_wired), ==, 0); - /* MAC address */ mac = nm_setting_wired_get_mac_address(s_wired); g_assert(mac); g_assert(nm_utils_hwaddr_matches(mac, -1, expected_mac_address, ETH_ALEN)); - /* ===== IPv4 SETTING ===== */ - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_DISABLED); g_assert(nm_setting_ip_config_get_never_default(s_ip4) == FALSE); - /* ===== IPv6 SETTING ===== */ - s_ip6 = nm_connection_get_setting_ip6_config(connection); - g_assert(s_ip6); + s_ip6 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_IGNORE); g_assert(nm_setting_ip_config_get_never_default(s_ip6) == FALSE); - - g_object_unref(connection); } static void test_read_miscellaneous_variables(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - char * expected_mac_blacklist[3] = {"00:16:41:11:22:88", + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWired * s_wired; + NMSettingIPConfig * s_ip4; + char * expected_mac_blacklist[3] = {"00:16:41:11:22:88", "00:16:41:11:22:99", "6a:5d:5a:fa:dd:f0"}; - int mac_blacklist_num, i; - guint64 expected_timestamp = 0; + int mac_blacklist_num, i; + guint64 expected_timestamp = 0; NMTST_EXPECT_NM_WARN("*invalid MAC in HWADDR_BLACKLIST 'XX:aa:invalid'*"); connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-misc-variables", @@ -696,19 +678,14 @@ test_read_miscellaneous_variables(void) NULL); g_test_assert_expected_messages(); - /* ===== CONNECTION SETTING ===== */ - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpint(nm_setting_connection_get_timestamp(s_con), ==, expected_timestamp); g_assert(nm_setting_connection_get_autoconnect(s_con)); g_assert_cmpint(nm_setting_connection_get_autoconnect_retries(s_con), ==, 100); - /* ===== WIRED SETTING ===== */ - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); g_assert_cmpint(nm_setting_wired_get_mtu(s_wired), ==, 0); - /* MAC blacklist */ mac_blacklist_num = nm_setting_wired_get_num_mac_blacklist_items(s_wired); g_assert_cmpint(mac_blacklist_num, ==, 3); for (i = 0; i < mac_blacklist_num; i++) @@ -717,26 +694,22 @@ test_read_miscellaneous_variables(void) expected_mac_blacklist[i], -1)); - /* ===== IPv4 SETTING ===== */ - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_DISABLED); g_assert(nm_setting_ip_config_get_never_default(s_ip4) == FALSE); - - g_object_unref(connection); } static void test_read_variables_corner_cases(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - const char * mac; - char expected_mac_address[ETH_ALEN] = {0x00, 0x16, 0x41, 0x11, 0x22, 0x33}; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWired * s_wired; + NMSettingIPConfig * s_ip4; + const char * mac; + char expected_mac_address[ETH_ALEN] = {0x00, 0x16, 0x41, 0x11, 0x22, 0x33}; NMTST_EXPECT_NM_WARN("*key NAME is badly quoted and is treated as \"\"*"); NMTST_EXPECT_NM_WARN("*key ZONE is badly quoted and is treated as \"\"*"); @@ -746,9 +719,7 @@ test_read_variables_corner_cases(void) NULL); g_test_assert_expected_messages(); - /* ===== CONNECTION SETTING ===== */ - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System test-variables-corner-cases-1"); @@ -756,34 +727,27 @@ test_read_variables_corner_cases(void) g_assert_cmpint(nm_setting_connection_get_timestamp(s_con), ==, 0); g_assert(nm_setting_connection_get_autoconnect(s_con)); - /* ===== WIRED SETTING ===== */ - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); g_assert_cmpint(nm_setting_wired_get_mtu(s_wired), ==, 0); - /* MAC address */ mac = nm_setting_wired_get_mac_address(s_wired); g_assert(mac); g_assert(nm_utils_hwaddr_matches(mac, -1, expected_mac_address, ETH_ALEN)); - /* ===== IPv4 SETTING ===== */ - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_DISABLED); g_assert(nm_setting_ip_config_get_never_default(s_ip4) == FALSE); - - g_object_unref(connection); } static void test_read_unmanaged(void) { - NMConnection * connection; - NMSettingConnection *s_con; - char * unhandled_spec = NULL; - guint64 expected_timestamp = 0; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + gs_free char * unhandled_spec = NULL; + guint64 expected_timestamp = 0; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-nm-controlled", NULL, @@ -791,24 +755,19 @@ test_read_unmanaged(void) &unhandled_spec); g_assert_cmpstr(unhandled_spec, ==, "unmanaged:mac:00:11:22:33:f8:9f"); - /* ===== CONNECTION SETTING ===== */ - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System test-nm-controlled"); g_assert_cmpint(nm_setting_connection_get_timestamp(s_con), ==, expected_timestamp); g_assert(nm_setting_connection_get_autoconnect(s_con)); - - g_free(unhandled_spec); - g_object_unref(connection); } static void test_read_unmanaged_unrecognized(void) { - NMConnection * connection; - NMSettingConnection *s_con; - gs_free char * unhandled_spec = NULL; - guint64 expected_timestamp = 0; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + gs_free char * unhandled_spec = NULL; + guint64 expected_timestamp = 0; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-nm-controlled-unrecognized", NULL, @@ -816,22 +775,18 @@ test_read_unmanaged_unrecognized(void) &unhandled_spec); g_assert_cmpstr(unhandled_spec, ==, "unmanaged:interface-name:=ipoac0"); - /* ===== CONNECTION SETTING ===== */ - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "PigeonNet"); g_assert_cmpint(nm_setting_connection_get_timestamp(s_con), ==, expected_timestamp); - - g_object_unref(connection); } static void test_read_unrecognized(void) { - NMConnection * connection; - NMSettingConnection *s_con; - gs_free char * unhandled_spec = NULL; - guint64 expected_timestamp = 0; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + gs_free char * unhandled_spec = NULL; + guint64 expected_timestamp = 0; NMTST_EXPECT_NM_WARN("*key NAME is badly quoted and is treated as \"\"*"); connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-unrecognized", @@ -841,30 +796,26 @@ test_read_unrecognized(void) g_test_assert_expected_messages(); g_assert_cmpstr(unhandled_spec, ==, "unrecognized:mac:00:11:22:33"); - /* ===== CONNECTION SETTING ===== */ - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System test-unrecognized"); g_assert_cmpint(nm_setting_connection_get_timestamp(s_con), ==, expected_timestamp); - - g_object_unref(connection); } static void test_read_wired_static(gconstpointer test_data) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - char * unmanaged = NULL; - const char * mac; - char expected_mac_address[ETH_ALEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0xee}; - NMIPAddress * ip4_addr; - NMIPAddress * ip6_addr; - const char * file, *expected_id; - gpointer expect_ip6_p; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWired * s_wired; + NMSettingIPConfig * s_ip4; + NMSettingIPConfig * s_ip6; + char * unmanaged = NULL; + const char * mac; + char expected_mac_address[ETH_ALEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0xee}; + NMIPAddress *ip4_addr; + NMIPAddress *ip6_addr; + const char * file, *expected_id; + gpointer expect_ip6_p; nmtst_test_data_unpack(test_data, &file, &expected_id, &expect_ip6_p); @@ -873,26 +824,19 @@ test_read_wired_static(gconstpointer test_data) connection = _connection_from_file(file, NULL, TYPE_ETHERNET, &unmanaged); g_assert_cmpstr(unmanaged, ==, NULL); - /* ===== CONNECTION SETTING ===== */ - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, expected_id); g_assert_cmpint(nm_setting_connection_get_timestamp(s_con), ==, 0); g_assert(nm_setting_connection_get_autoconnect(s_con)); - /* ===== WIRED SETTING ===== */ - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); g_assert_cmpint(nm_setting_wired_get_mtu(s_wired), ==, 1492); - /* MAC address */ mac = nm_setting_wired_get_mac_address(s_wired); g_assert(mac); g_assert(nm_utils_hwaddr_matches(mac, -1, expected_mac_address, ETH_ALEN)); - /* ===== IPv4 SETTING ===== */ - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); @@ -901,24 +845,19 @@ test_read_wired_static(gconstpointer test_data) g_assert(nm_setting_ip_config_has_dns_options(s_ip4)); g_assert_cmpint(nm_setting_ip_config_get_num_dns_options(s_ip4), ==, 0); - /* DNS Addresses */ g_assert_cmpint(nm_setting_ip_config_get_num_dns(s_ip4), ==, 2); g_assert_cmpstr(nm_setting_ip_config_get_dns(s_ip4, 0), ==, "4.2.2.1"); g_assert_cmpstr(nm_setting_ip_config_get_dns(s_ip4, 1), ==, "4.2.2.2"); - /* IP addresses */ g_assert_cmpint(nm_setting_ip_config_get_num_addresses(s_ip4), ==, 1); ip4_addr = nm_setting_ip_config_get_address(s_ip4, 0); g_assert(ip4_addr); g_assert_cmpint(nm_ip_address_get_prefix(ip4_addr), ==, 24); g_assert_cmpstr(nm_ip_address_get_address(ip4_addr), ==, "192.168.1.5"); - /* Gateway */ g_assert_cmpstr(nm_setting_ip_config_get_gateway(s_ip4), ==, "192.168.1.1"); - /* ===== IPv6 SETTING ===== */ - s_ip6 = nm_connection_get_setting_ip6_config(connection); - g_assert(s_ip6); + s_ip6 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); if (GPOINTER_TO_INT(expect_ip6_p)) { g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip6), ==, @@ -951,19 +890,18 @@ test_read_wired_static(gconstpointer test_data) NM_SETTING_IP6_CONFIG_METHOD_IGNORE); g_assert(!nm_setting_ip_config_has_dns_options(s_ip6)); } - - g_object_unref(connection); } static void test_read_wired_static_no_prefix(gconstpointer user_data) { - guint32 expected_prefix = GPOINTER_TO_UINT(user_data); - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingIPConfig * s_ip4; - NMIPAddress * ip4_addr; - char * file, *expected_id; + guint32 expected_prefix = GPOINTER_TO_UINT(user_data); + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingIPConfig * s_ip4; + NMIPAddress * ip4_addr; + gs_free char * file = NULL; + gs_free char * expected_id = NULL; file = g_strdup_printf(TEST_IFCFG_DIR "/ifcfg-test-wired-static-no-prefix-%u", expected_prefix); expected_id = g_strdup_printf("System test-wired-static-no-prefix-%u", expected_prefix); @@ -972,14 +910,10 @@ test_read_wired_static_no_prefix(gconstpointer user_data) connection = _connection_from_file(file, NULL, TYPE_ETHERNET, NULL); g_test_assert_expected_messages(); - /* ===== CONNECTION SETTING ===== */ - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, expected_id); - /* ===== IPv4 SETTING ===== */ - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); @@ -991,23 +925,19 @@ test_read_wired_static_no_prefix(gconstpointer user_data) ip4_addr = nm_setting_ip_config_get_address(s_ip4, 0); g_assert(ip4_addr); g_assert_cmpint(nm_ip_address_get_prefix(ip4_addr), ==, expected_prefix); - - g_free(file); - g_free(expected_id); - g_object_unref(connection); } static void test_read_wired_dhcp(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - char * unmanaged = NULL; - char expected_mac_address[ETH_ALEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0xee}; - const char * mac; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWired * s_wired; + NMSettingIPConfig * s_ip4; + NMSettingIPConfig * s_ip6; + char * unmanaged = NULL; + char expected_mac_address[ETH_ALEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0xee}; + const char *mac; NMTST_EXPECT_NM_WARN("*key IPV6INIT is duplicated and the early occurrence ignored*"); connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-dhcp", @@ -1017,25 +947,18 @@ test_read_wired_dhcp(void) g_test_assert_expected_messages(); g_assert(unmanaged == NULL); - /* ===== CONNECTION SETTING ===== */ - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System test-wired-dhcp"); g_assert_cmpuint(nm_setting_connection_get_timestamp(s_con), ==, 0); g_assert(nm_setting_connection_get_autoconnect(s_con)); - /* ===== WIRED SETTING ===== */ - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); - /* MAC address */ mac = nm_setting_wired_get_mac_address(s_wired); g_assert(mac); g_assert(nm_utils_hwaddr_matches(mac, -1, expected_mac_address, sizeof(expected_mac_address))); - /* ===== IPv4 SETTING ===== */ - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); g_assert_cmpstr(nm_setting_ip4_config_get_dhcp_fqdn(NM_SETTING_IP4_CONFIG(s_ip4)), ==, @@ -1048,35 +971,29 @@ test_read_wired_dhcp(void) ==, NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED | NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE); - /* ===== IPv6 SETTING ===== */ - s_ip6 = nm_connection_get_setting_ip6_config(connection); - g_assert(s_ip6); + s_ip6 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_DHCP); g_assert_cmpstr(nm_setting_ip_config_get_dhcp_hostname(s_ip6), ==, "foo.bar"); g_assert_cmpuint(nm_setting_ip_config_get_dhcp_hostname_flags(s_ip6), ==, NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS); - - g_object_unref(connection); } static void test_read_wired_dhcp_plus_ip(void) { - NMConnection * connection; - NMSettingIPConfig *s_ip4; - NMSettingIPConfig *s_ip6; - NMIPAddress * ip4_addr; - NMIPAddress * ip6_addr; + gs_unref_object NMConnection *connection = NULL; + NMSettingIPConfig * s_ip4; + NMSettingIPConfig * s_ip6; + NMIPAddress * ip4_addr; + NMIPAddress * ip6_addr; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-dhcp-plus-ip", NULL, TYPE_ETHERNET, NULL); - /* ===== IPv4 SETTING ===== */ - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); g_assert(nm_setting_ip_config_get_may_fail(s_ip4)); @@ -1100,9 +1017,7 @@ test_read_wired_dhcp_plus_ip(void) g_assert_cmpint(nm_ip_address_get_prefix(ip4_addr), ==, 16); g_assert_cmpstr(nm_ip_address_get_address(ip4_addr), ==, "9.8.7.6"); - /* ===== IPv6 SETTING ===== */ - s_ip6 = nm_connection_get_setting_ip6_config(connection); - g_assert(s_ip6); + s_ip6 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_AUTO); g_assert(nm_setting_ip_config_get_may_fail(s_ip6)); @@ -1127,25 +1042,21 @@ test_read_wired_dhcp_plus_ip(void) g_assert(ip6_addr); g_assert_cmpint(nm_ip_address_get_prefix(ip6_addr), ==, 96); g_assert_cmpstr(nm_ip_address_get_address(ip6_addr), ==, "3001:abba::3234"); - - g_object_unref(connection); } static void test_read_wired_shared_plus_ip(void) { - NMConnection * connection; - NMSettingIPConfig *s_ip4; - NMIPAddress * ip4_addr; + gs_unref_object NMConnection *connection = NULL; + NMSettingIPConfig * s_ip4; + NMIPAddress * ip4_addr; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-shared-plus-ip", NULL, TYPE_ETHERNET, NULL); - /* ===== IPv4 SETTING ===== */ - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_SHARED); @@ -1160,19 +1071,16 @@ test_read_wired_shared_plus_ip(void) /* Gateway */ g_assert_cmpstr(nm_setting_ip_config_get_gateway(s_ip4), ==, "1.1.1.1"); - - g_object_unref(connection); } static void test_read_wired_global_gateway(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMIPAddress * ip4_addr; - char * unmanaged = NULL; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingIPConfig * s_ip4; + NMIPAddress * ip4_addr; + char * unmanaged = NULL; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-global-gateway", TEST_IFCFG_DIR "/network-test-wired-global-gateway", @@ -1180,18 +1088,12 @@ test_read_wired_global_gateway(void) &unmanaged); g_assert(unmanaged == NULL); - /* ===== CONNECTION SETTING ===== */ - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System test-wired-global-gateway"); - /* ===== WIRED SETTING ===== */ - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); - /* ===== IPv4 SETTING ===== */ - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); @@ -1204,19 +1106,16 @@ test_read_wired_global_gateway(void) /* Gateway */ g_assert_cmpstr(nm_setting_ip_config_get_gateway(s_ip4), ==, "192.168.1.2"); - - g_object_unref(connection); } /* Ignore GATEWAY from /etc/sysconfig/network for automatic connections */ static void test_read_wired_global_gateway_ignore(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - char * unmanaged = NULL; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingIPConfig * s_ip4; + char * unmanaged = NULL; NMTST_EXPECT_NM_WARN("*ignoring GATEWAY (/etc/sysconfig/network) for * because the connection " "has no static addresses"); @@ -1227,20 +1126,14 @@ test_read_wired_global_gateway_ignore(void) g_test_assert_expected_messages(); g_assert(unmanaged == NULL); - /* ===== CONNECTION SETTING ===== */ - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System test-wired-global-gateway-ignore"); - /* ===== WIRED SETTING ===== */ - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); - /* ===== IPv4 SETTING ===== */ - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); /* Addresses */ @@ -1248,25 +1141,21 @@ test_read_wired_global_gateway_ignore(void) /* Gateway */ g_assert_cmpstr(nm_setting_ip_config_get_gateway(s_ip4), ==, NULL); - - g_object_unref(connection); } static void test_read_wired_obsolete_gateway_n(void) { - NMConnection * connection; - NMSettingIPConfig *s_ip4; - NMIPAddress * ip4_addr; + gs_unref_object NMConnection *connection = NULL; + NMSettingIPConfig * s_ip4; + NMIPAddress * ip4_addr; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-obsolete-gateway-n", NULL, TYPE_ETHERNET, NULL); - /* ===== IPv4 SETTING ===== */ - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); @@ -1280,8 +1169,6 @@ test_read_wired_obsolete_gateway_n(void) /* Gateway */ g_assert_cmpstr(nm_setting_ip_config_get_gateway(s_ip4), ==, "1.1.1.1"); - - g_object_unref(connection); } static void @@ -1294,7 +1181,8 @@ test_user_1(void) connection = nmtst_create_minimal_connection("Test User 1", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); - s_user = NM_SETTING_USER(nm_setting_user_new()); + + s_user = _nm_connection_new_setting(connection, NM_TYPE_SETTING_USER); #define _USER_SET_DATA(s_user, key, val) \ G_STMT_START \ @@ -1330,8 +1218,6 @@ test_user_1(void) _USER_SET_DATA_X(s_user, "my.keys.1"); _USER_SET_DATA_X(s_user, "my.other.KEY.42"); - nm_connection_add_setting(connection, NM_SETTING(s_user)); - _writer_new_connec_exp(connection, TEST_SCRATCH_DIR, TEST_IFCFG_DIR "/ifcfg-Test_User_1.cexpected", @@ -1345,42 +1231,35 @@ test_user_1(void) static void test_read_wired_never_default(void) { - NMConnection * connection; - NMSettingIPConfig *s_ip4; - NMSettingIPConfig *s_ip6; + gs_unref_object NMConnection *connection = NULL; + NMSettingIPConfig * s_ip4; + NMSettingIPConfig * s_ip6; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-never-default", TEST_IFCFG_DIR "/network-test-wired-never-default", TYPE_ETHERNET, NULL); - /* ===== WIRED SETTING ===== */ - g_assert(nm_connection_get_setting_wired(connection)); + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); - /* ===== IPv4 SETTING ===== */ - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); g_assert(nm_setting_ip_config_get_never_default(s_ip4)); g_assert_cmpint(nm_setting_ip_config_get_num_dns(s_ip4), ==, 0); - /* ===== IPv6 SETTING ===== */ - s_ip6 = nm_connection_get_setting_ip6_config(connection); - g_assert(s_ip6); + s_ip6 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_AUTO); g_assert(nm_setting_ip_config_get_never_default(s_ip6)); - - g_object_unref(connection); } static void test_read_wired_defroute_no(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - char * unmanaged = NULL; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingIPConfig * s_ip4; + NMSettingIPConfig * s_ip6; + char * unmanaged = NULL; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-defroute-no", NULL, @@ -1388,33 +1267,28 @@ test_read_wired_defroute_no(void) &unmanaged); g_assert(unmanaged == NULL); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System test-wired-defroute-no"); - g_assert(nm_connection_get_setting_wired(connection)); + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); g_assert(nm_setting_ip_config_get_never_default(s_ip4)); - s_ip6 = nm_connection_get_setting_ip6_config(connection); - g_assert(s_ip6); + s_ip6 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_AUTO); g_assert(nm_setting_ip_config_get_never_default(s_ip6)); - - g_object_unref(connection); } static void test_read_wired_defroute_no_gatewaydev_yes(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - char * unmanaged = NULL; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingIPConfig * s_ip4; + NMSettingIPConfig * s_ip6; + char * unmanaged = NULL; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-defroute-no-gatewaydev-yes", @@ -1422,58 +1296,45 @@ test_read_wired_defroute_no_gatewaydev_yes(void) TYPE_ETHERNET, &unmanaged); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System test-wired-defroute-no-gatewaydev-yes"); - g_assert(nm_connection_get_setting_wired(connection)); + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); g_assert(nm_setting_ip_config_get_never_default(s_ip4) == FALSE); - s_ip6 = nm_connection_get_setting_ip6_config(connection); - g_assert(s_ip6); + s_ip6 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_AUTO); g_assert(nm_setting_ip_config_get_never_default(s_ip6) == FALSE); - - g_object_unref(connection); } static void test_read_wired_static_routes(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMIPRoute * ip4_route; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingIPConfig * s_ip4; + NMIPRoute * ip4_route; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-static-routes", NULL, TYPE_ETHERNET, NULL); - /* ===== CONNECTION SETTING ===== */ - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System test-wired-static-routes"); - /* ===== WIRED SETTING ===== */ - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); - /* ===== IPv4 SETTING ===== */ - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); - /* Routes */ g_assert_cmpint(nm_setting_ip_config_get_num_routes(s_ip4), ==, 4); ip4_route = nm_setting_ip_config_get_route(s_ip4, 0); @@ -1524,19 +1385,16 @@ test_read_wired_static_routes(void) g_assert_cmpint(nm_ip_route_get_prefix(ip4_route), ==, 32); nmtst_assert_route_attribute_string(ip4_route, NM_IP_ROUTE_ATTRIBUTE_TYPE, "local"); nmtst_assert_route_attribute_byte(ip4_route, NM_IP_ROUTE_ATTRIBUTE_SCOPE, 254); - - g_object_unref(connection); } static void test_read_wired_static_routes_legacy(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - char * unmanaged = NULL; - NMIPRoute * ip4_route; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingIPConfig * s_ip4; + char * unmanaged = NULL; + NMIPRoute * ip4_route; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-static-routes-legacy", NULL, @@ -1544,28 +1402,18 @@ test_read_wired_static_routes_legacy(void) &unmanaged); g_assert(!unmanaged); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System test-wired-static-routes-legacy"); - /* ===== WIRED SETTING ===== */ - - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); - /* ===== IPv4 SETTING ===== */ - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); - /* Routes */ g_assert_cmpint(nm_setting_ip_config_get_num_routes(s_ip4), ==, 5); /* Route #1 */ @@ -1612,20 +1460,17 @@ test_read_wired_static_routes_legacy(void) g_assert(ip4_route != NULL); g_assert_cmpstr(nm_ip_route_get_dest(ip4_route), ==, "1.2.3.4"); nmtst_assert_route_attribute_string(ip4_route, NM_IP_ROUTE_ATTRIBUTE_TYPE, "local"); - - g_object_unref(connection); } static void test_read_wired_ipv4_manual(gconstpointer data) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - char * unmanaged = NULL; - NMIPAddress * ip4_addr; - const char * file, *expected_id; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingIPConfig * s_ip4; + char * unmanaged = NULL; + NMIPAddress * ip4_addr; + const char * file, *expected_id; nmtst_test_data_unpack(data, &file, &expected_id); @@ -1634,21 +1479,12 @@ test_read_wired_ipv4_manual(gconstpointer data) connection = _connection_from_file(file, NULL, TYPE_ETHERNET, &unmanaged); g_assert(!unmanaged); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, expected_id); - /* ===== WIRED SETTING ===== */ - - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); - - /* ===== IPv4 SETTING ===== */ + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); @@ -1674,21 +1510,18 @@ test_read_wired_ipv4_manual(gconstpointer data) g_assert(ip4_addr != NULL); g_assert_cmpstr(nm_ip_address_get_address(ip4_addr), ==, "3.3.3.3"); g_assert_cmpint(nm_ip_address_get_prefix(ip4_addr), ==, 8); - - g_object_unref(connection); } static void test_read_wired_ipv6_manual(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - char * unmanaged = NULL; - NMIPAddress * ip6_addr; - NMIPRoute * ip6_route; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingIPConfig * s_ip4; + NMSettingIPConfig * s_ip6; + char * unmanaged = NULL; + NMIPAddress * ip6_addr; + NMIPRoute * ip6_route; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-ipv6-manual", NULL, @@ -1696,21 +1529,12 @@ test_read_wired_ipv6_manual(void) &unmanaged); g_assert(!unmanaged); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System test-wired-ipv6-manual"); - /* ===== WIRED SETTING ===== */ + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); - - /* ===== IPv4 SETTING ===== */ - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); /* DNS Addresses */ g_assert_cmpint(nm_setting_ip_config_get_num_dns(s_ip4), ==, 2); @@ -1721,10 +1545,7 @@ test_read_wired_ipv6_manual(void) g_assert_cmpstr(nm_setting_ip_config_get_dns_search(s_ip4, 1), ==, "ipsum.org"); g_assert_cmpstr(nm_setting_ip_config_get_dns_search(s_ip4, 2), ==, "dolor.edu"); - /* ===== IPv6 SETTING ===== */ - - s_ip6 = nm_connection_get_setting_ip6_config(connection); - g_assert(s_ip6); + s_ip6 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_MANUAL); @@ -1794,22 +1615,19 @@ test_read_wired_ipv6_manual(void) /* DNS domains - none as domains are stuffed to 'ipv4' setting */ g_assert_cmpint(nm_setting_ip_config_get_num_dns_searches(s_ip6), ==, 0); - - g_object_unref(connection); } static void test_read_wired_ipv6_only(gconstpointer test_data) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - char * unmanaged = NULL; - NMIPAddress * ip6_addr; - const char * method; - const char * file, *expected_id; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingIPConfig * s_ip4; + NMSettingIPConfig * s_ip6; + char * unmanaged = NULL; + NMIPAddress * ip6_addr; + const char * method; + const char * file, *expected_id; nmtst_test_data_unpack(test_data, &file, &expected_id); @@ -1818,29 +1636,17 @@ test_read_wired_ipv6_only(gconstpointer test_data) connection = _connection_from_file(file, NULL, TYPE_ETHERNET, &unmanaged); g_assert(!unmanaged); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, expected_id); - /* ===== WIRED SETTING ===== */ + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); - - /* ===== IPv4 SETTING ===== */ - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); method = nm_setting_ip_config_get_method(s_ip4); g_assert_cmpstr(method, ==, NM_SETTING_IP4_CONFIG_METHOD_DISABLED); - /* ===== IPv6 SETTING ===== */ - - s_ip6 = nm_connection_get_setting_ip6_config(connection); - g_assert(s_ip6); + s_ip6 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_MANUAL); @@ -1863,20 +1669,17 @@ test_read_wired_ipv6_only(gconstpointer test_data) g_assert_cmpstr(nm_setting_ip_config_get_dns_search(s_ip6, 0), ==, "lorem.com"); g_assert_cmpstr(nm_setting_ip_config_get_dns_search(s_ip6, 1), ==, "ipsum.org"); g_assert_cmpstr(nm_setting_ip_config_get_dns_search(s_ip6, 2), ==, "dolor.edu"); - - g_object_unref(connection); } static void test_read_wired_dhcp6_only(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - char * unmanaged = NULL; - const char * method; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingIPConfig * s_ip4; + NMSettingIPConfig * s_ip6; + char * unmanaged = NULL; + const char * method; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-dhcp6-only", NULL, @@ -1884,32 +1687,18 @@ test_read_wired_dhcp6_only(void) &unmanaged); g_assert(!unmanaged); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System test-wired-dhcp6-only"); - /* ===== WIRED SETTING ===== */ - - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); - - /* ===== IPv4 SETTING ===== */ + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); method = nm_setting_ip_config_get_method(s_ip4); g_assert_cmpstr(method, ==, NM_SETTING_IP4_CONFIG_METHOD_DISABLED); - /* ===== IPv6 SETTING ===== */ - - s_ip6 = nm_connection_get_setting_ip6_config(connection); - g_assert(s_ip6); + s_ip6 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_DHCP); - - g_object_unref(connection); } static void @@ -1926,24 +1715,23 @@ test_read_wired_autoip(void) &unmanaged); g_assert(unmanaged == NULL); - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL); g_assert(!nm_setting_ip_config_get_may_fail(s_ip4)); g_assert(nm_setting_ip_config_get_ignore_auto_dns(s_ip4)); - s_con = nm_connection_get_setting_connection(connection); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpint(nm_setting_connection_get_wait_device_timeout(s_con), ==, 2600); } static void test_read_onboot_no(void) { - NMConnection * connection; - NMSettingConnection *s_con; - char * unmanaged = NULL; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + char * unmanaged = NULL; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-onboot-no", NULL, @@ -1951,39 +1739,32 @@ test_read_onboot_no(void) &unmanaged); g_assert(!unmanaged); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert(!nm_setting_connection_get_autoconnect(s_con)); - - g_object_unref(connection); } static void test_read_noip(void) { - NMConnection * connection; - NMSettingIPConfig *s_ip4; - NMSettingIPConfig *s_ip6; + gs_unref_object NMConnection *connection = NULL; + NMSettingIPConfig * s_ip4; + NMSettingIPConfig * s_ip6; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-noip", NULL, TYPE_ETHERNET, NULL); - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_DISABLED); g_assert(nm_setting_ip_config_get_never_default(s_ip4) == FALSE); - s_ip6 = nm_connection_get_setting_ip6_config(connection); - g_assert(s_ip6); + s_ip6 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_IGNORE); g_assert(nm_setting_ip_config_get_never_default(s_ip6) == FALSE); - - g_object_unref(connection); } #define TEST_IFCFG_WIRED_8021x_PEAP_MSCHAPV2_CA_CERT TEST_IFCFG_DIR "/test_ca_cert.pem" @@ -1991,16 +1772,15 @@ test_read_noip(void) static void test_read_wired_8021x_peap_mschapv2(void) { - NMConnection * connection; - NMSettingWired * s_wired; - NMSettingIPConfig *s_ip4; - NMSetting8021x * s_8021x; - NMSetting8021x * tmp_8021x; - char * unmanaged = NULL; - GError * error = NULL; - gboolean success = FALSE; - const char * expected_ca_cert_path; - const char * read_ca_cert_path; + gs_unref_object NMConnection *connection = NULL; + NMSettingIPConfig * s_ip4; + NMSetting8021x * s_8021x; + gs_unref_object NMSetting8021x *tmp_8021x = NULL; + char * unmanaged = NULL; + GError * error = NULL; + gboolean success = FALSE; + const char * expected_ca_cert_path; + const char * read_ca_cert_path; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-8021x-peap-mschapv2", NULL, @@ -2008,20 +1788,12 @@ test_read_wired_8021x_peap_mschapv2(void) &unmanaged); g_assert(!unmanaged); - /* ===== WIRED SETTING ===== */ + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); - - /* ===== IPv4 SETTING ===== */ - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); - /* ===== 802.1x SETTING ===== */ - s_8021x = nm_connection_get_setting_802_1x(connection); - g_assert(s_8021x); + s_8021x = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_802_1X); g_assert_cmpint(nm_setting_802_1x_get_num_eap_methods(s_8021x), ==, 1); g_assert_cmpstr(nm_setting_802_1x_get_eap_method(s_8021x, 0), ==, "peap"); @@ -2049,33 +1821,26 @@ test_read_wired_8021x_peap_mschapv2(void) g_assert(read_ca_cert_path); g_assert_cmpstr(read_ca_cert_path, ==, expected_ca_cert_path); - - g_object_unref(tmp_8021x); - - g_object_unref(connection); } static void test_read_wired_8021x_tls_secret_flags(gconstpointer test_data) { - NMConnection * connection; - NMSettingWired *s_wired; - NMSetting8021x *s_8021x; - char * dirname, *tmp; - const char * ifcfg; - gpointer expected_flags_p; + gs_unref_object NMConnection *connection = NULL; + NMSetting8021x * s_8021x; + gs_free char * dirname = NULL; + gs_free char * tmp1 = NULL; + gs_free char * tmp2 = NULL; + const char * ifcfg; + gpointer expected_flags_p; nmtst_test_data_unpack(test_data, &ifcfg, &expected_flags_p); connection = _connection_from_file(ifcfg, NULL, TYPE_ETHERNET, NULL); - /* ===== WIRED SETTING ===== */ - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); - /* ===== 802.1x SETTING ===== */ - s_8021x = nm_connection_get_setting_802_1x(connection); - g_assert(s_8021x); + s_8021x = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_802_1X); g_assert_cmpint(nm_setting_802_1x_get_num_eap_methods(s_8021x), ==, 1); g_assert_cmpstr(nm_setting_802_1x_get_eap_method(s_8021x, 0), ==, "tls"); g_assert_cmpstr(nm_setting_802_1x_get_identity(s_8021x), ==, "David Smith"); @@ -2084,18 +1849,13 @@ test_read_wired_8021x_tls_secret_flags(gconstpointer test_data) GPOINTER_TO_INT(expected_flags_p)); dirname = g_path_get_dirname(ifcfg); - tmp = g_build_path("/", dirname, "test_ca_cert.pem", NULL); - g_assert_cmpstr(nm_setting_802_1x_get_ca_cert_path(s_8021x), ==, tmp); - g_free(tmp); - tmp = g_build_path("/", dirname, "test1_key_and_cert.pem", NULL); - g_assert_cmpstr(nm_setting_802_1x_get_client_cert_path(s_8021x), ==, tmp); - g_assert_cmpstr(nm_setting_802_1x_get_private_key_path(s_8021x), ==, tmp); - g_free(tmp); + tmp1 = g_build_path("/", dirname, "test_ca_cert.pem", NULL); + g_assert_cmpstr(nm_setting_802_1x_get_ca_cert_path(s_8021x), ==, tmp1); - g_free(dirname); - - g_object_unref(connection); + tmp2 = g_build_path("/", dirname, "test1_key_and_cert.pem", NULL); + g_assert_cmpstr(nm_setting_802_1x_get_client_cert_path(s_8021x), ==, tmp2); + g_assert_cmpstr(nm_setting_802_1x_get_private_key_path(s_8021x), ==, tmp2); } static void @@ -2111,9 +1871,7 @@ test_read_write_802_1X_subj_matches(void) TYPE_ETHERNET, NULL); - /* ===== 802.1x SETTING ===== */ - s_8021x = nm_connection_get_setting_802_1x(connection); - g_assert(s_8021x); + s_8021x = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_802_1X); g_assert_cmpint(nm_setting_802_1x_get_num_eap_methods(s_8021x), ==, 1); g_assert_cmpstr(nm_setting_802_1x_get_eap_method(s_8021x, 0), ==, "peap"); g_assert_cmpstr(nm_setting_802_1x_get_identity(s_8021x), ==, "Jara Cimrman"); @@ -2143,8 +1901,7 @@ test_read_write_802_1X_subj_matches(void) nmtst_assert_connection_equals(connection, TRUE, reread, FALSE); /* Check 802.1X stuff of the re-read connection. */ - s_8021x = nm_connection_get_setting_802_1x(reread); - g_assert(s_8021x); + s_8021x = nmtst_connection_assert_setting(reread, NM_TYPE_SETTING_802_1X); g_assert_cmpint(nm_setting_802_1x_get_num_eap_methods(s_8021x), ==, 1); g_assert_cmpstr(nm_setting_802_1x_get_eap_method(s_8021x, 0), ==, "peap"); g_assert_cmpstr(nm_setting_802_1x_get_identity(s_8021x), ==, "Jara Cimrman"); @@ -2168,8 +1925,8 @@ test_read_write_802_1X_subj_matches(void) static void test_read_802_1x_ttls_eapgtc(void) { - NMConnection * connection; - NMSetting8021x *s_8021x; + gs_unref_object NMConnection *connection = NULL; + NMSetting8021x * s_8021x; /* Test that EAP-* inner methods are correctly read into the * NMSetting8021x::autheap property. @@ -2180,9 +1937,7 @@ test_read_802_1x_ttls_eapgtc(void) TYPE_WIRELESS, NULL); - /* ===== 802.1x SETTING ===== */ - s_8021x = nm_connection_get_setting_802_1x(connection); - g_assert(s_8021x); + s_8021x = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_802_1X); /* EAP methods */ g_assert_cmpint(nm_setting_802_1x_get_num_eap_methods(s_8021x), ==, 1); @@ -2191,8 +1946,6 @@ test_read_802_1x_ttls_eapgtc(void) /* Auth methods */ g_assert_cmpstr(nm_setting_802_1x_get_phase2_auth(s_8021x), ==, NULL); g_assert_cmpstr(nm_setting_802_1x_get_phase2_autheap(s_8021x), ==, "gtc"); - - g_object_unref(connection); } static void @@ -2208,8 +1961,7 @@ test_read_802_1x_tls_p12_no_client_cert(void) TYPE_ETHERNET, NULL); - s_8021x = nm_connection_get_setting_802_1x(connection); - g_assert(s_8021x); + s_8021x = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_802_1X); g_assert_cmpint(nm_setting_802_1x_get_private_key_scheme(s_8021x), ==, @@ -2242,9 +1994,7 @@ test_read_write_802_1x_password_raw(void) TYPE_ETHERNET, NULL); - /* ===== 802.1x SETTING ===== */ - s_8021x = nm_connection_get_setting_802_1x(connection); - g_assert(s_8021x); + s_8021x = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_802_1X); bytes = nm_setting_802_1x_get_password_raw(s_8021x); g_assert(bytes); @@ -2269,18 +2019,18 @@ test_read_write_802_1x_password_raw(void) static void test_read_wired_aliases_good(gconstpointer test_data) { - const int N = GPOINTER_TO_INT(test_data); - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingIPConfig * s_ip4; - int expected_num_addresses; - const char * expected_address_0[] = {"192.168.1.5", + const int N = GPOINTER_TO_INT(test_data); + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingIPConfig * s_ip4; + int expected_num_addresses; + const char * expected_address_0[] = {"192.168.1.5", "192.168.1.6", "192.168.1.9", "192.168.1.99", NULL}; - const char * expected_address_3[] = {"192.168.1.5", "192.168.1.6", NULL}; - const char * expected_label_0[] = { + const char * expected_address_3[] = {"192.168.1.5", "192.168.1.6", NULL}; + const char * expected_label_0[] = { NULL, "aliasem0:1", "aliasem0:2", @@ -2305,19 +2055,13 @@ test_read_wired_aliases_good(gconstpointer test_data) connection = _connection_from_file(path, NULL, TYPE_ETHERNET, NULL); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); if (N == 0) g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System aliasem0"); else g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System aliasem3"); - /* ===== IPv4 SETTING ===== */ - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); @@ -2358,33 +2102,25 @@ test_read_wired_aliases_good(gconstpointer test_data) for (i = 0; i < expected_num_addresses; i++) g_assert(!expected_address[i]); - - g_object_unref(connection); } static void test_read_wired_aliases_bad(const char *base, const char *expected_id) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingIPConfig * s_ip4; - NMIPAddress * ip4_addr; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingIPConfig * s_ip4; + NMIPAddress * ip4_addr; g_assert(expected_id); connection = _connection_from_file(base, NULL, TYPE_ETHERNET, NULL); g_test_assert_expected_messages(); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, expected_id); - /* ===== IPv4 SETTING ===== */ - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); @@ -2400,8 +2136,6 @@ test_read_wired_aliases_bad(const char *base, const char *expected_id) /* Gateway */ g_assert_cmpstr(nm_setting_ip_config_get_gateway(s_ip4), ==, "192.168.1.1"); - - g_object_unref(connection); } static void @@ -2421,13 +2155,15 @@ test_read_wired_aliases_bad_2(void) static void test_read_dns_options(void) { - NMConnection * connection; - NMSettingIPConfig *s_ip4, *s_ip6; - char * unmanaged = NULL; - const char * option; - const char * options4[] = {"ndots:3", "single-request-reopen"}; - const char * options6[] = {"inet6"}; - guint32 i, num; + gs_unref_object NMConnection *connection = NULL; + NMSettingIPConfig * s_ip4; + NMSettingIPConfig * s_ip6; + char * unmanaged = NULL; + const char * option; + const char * options4[] = {"ndots:3", "single-request-reopen"}; + const char * options6[] = {"inet6"}; + guint32 num; + guint32 i; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-dns-options", NULL, @@ -2435,11 +2171,9 @@ test_read_dns_options(void) &unmanaged); g_assert_cmpstr(unmanaged, ==, NULL); - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); - s_ip6 = nm_connection_get_setting_ip6_config(connection); - g_assert(s_ip6); + s_ip6 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); num = nm_setting_ip_config_get_num_dns_options(s_ip4); g_assert_cmpint(num, ==, G_N_ELEMENTS(options4)); @@ -2456,8 +2190,6 @@ test_read_dns_options(void) option = nm_setting_ip_config_get_dns_option(s_ip6, i); g_assert_cmpstr(options6[i], ==, option); } - - g_object_unref(connection); } static void @@ -2477,8 +2209,7 @@ test_clear_master(void) &unmanaged); g_assert_cmpstr(unmanaged, ==, NULL); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_master(s_con), ==, "br0"); g_assert_cmpstr(nm_setting_connection_get_slave_type(s_con), ==, "bridge"); @@ -2534,10 +2265,7 @@ test_write_dns_options(void) connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test DNS options", @@ -2549,16 +2277,10 @@ test_write_dns_options(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - + s_wired = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); g_object_set(s_wired, NM_SETTING_WIRED_MAC_ADDRESS, mac, NM_SETTING_WIRED_MTU, mtu, NULL); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, @@ -2576,10 +2298,7 @@ test_write_dns_options(void) nm_setting_ip_config_add_dns_option(s_ip4, "debug"); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, @@ -2608,23 +2327,20 @@ test_write_dns_options(void) static void test_read_wifi_open(void) { - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWireless * s_wireless; - NMSettingWirelessSecurity *s_wsec; - NMSettingIPConfig * s_ip4, *s_ip6; - GBytes * ssid; - const char * mac; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWireless * s_wifi; + NMSettingIPConfig * s_ip4; + NMSettingIPConfig * s_ip6; + GBytes * ssid; + const char * mac; char expected_mac_address[ETH_ALEN] = {0x00, 0x16, 0x41, 0x11, 0x22, 0x33}; const char *expected_ssid = "blahblah"; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-open", NULL, TYPE_WIRELESS, NULL); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System blahblah (test-wifi-open)"); /* UUID can't be tested if the ifcfg does not contain the UUID key, because @@ -2636,109 +2352,83 @@ test_read_wifi_open(void) g_assert(nm_setting_connection_get_autoconnect(s_con)); g_assert_cmpint(nm_setting_connection_get_autoconnect_priority(s_con), ==, -1); - /* ===== WIRELESS SETTING ===== */ + s_wifi = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); - - /* MAC address */ - mac = nm_setting_wireless_get_mac_address(s_wireless); + mac = nm_setting_wireless_get_mac_address(s_wifi); g_assert(mac); g_assert(nm_utils_hwaddr_matches(mac, -1, expected_mac_address, sizeof(expected_mac_address))); - g_assert_cmpint(nm_setting_wireless_get_mtu(s_wireless), ==, 0); + g_assert_cmpint(nm_setting_wireless_get_mtu(s_wifi), ==, 0); - ssid = nm_setting_wireless_get_ssid(s_wireless); + ssid = nm_setting_wireless_get_ssid(s_wifi); g_assert(ssid); g_assert_cmpmem(g_bytes_get_data(ssid, NULL), g_bytes_get_size(ssid), expected_ssid, strlen(expected_ssid)); - g_assert(!nm_setting_wireless_get_bssid(s_wireless)); - g_assert_cmpstr(nm_setting_wireless_get_mode(s_wireless), ==, "infrastructure"); - g_assert_cmpint(nm_setting_wireless_get_channel(s_wireless), ==, 1); - - /* ===== Wi-Fi SECURITY SETTING ===== */ - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec == NULL); + g_assert(!nm_setting_wireless_get_bssid(s_wifi)); + g_assert_cmpstr(nm_setting_wireless_get_mode(s_wifi), ==, "infrastructure"); + g_assert_cmpint(nm_setting_wireless_get_channel(s_wifi), ==, 1); - /* ===== IPv4 SETTING ===== */ + nmtst_connection_assert_no_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpint(nm_setting_ip_config_get_route_metric(s_ip4), ==, 104); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); - s_ip6 = nm_connection_get_setting_ip6_config(connection); - g_assert(s_ip6); + s_ip6 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_assert_cmpint(nm_setting_ip_config_get_route_metric(s_ip6), ==, 106); - - g_object_unref(connection); } static void test_read_wifi_open_auto(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWireless * s_wireless; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWireless * s_wifi; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-open-auto", NULL, TYPE_WIRELESS, NULL); - /* ===== CONNECTION SETTING ===== */ - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System blahblah (test-wifi-open-auto)"); - /* ===== WIRELESS SETTING ===== */ - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); - g_assert_cmpstr(nm_setting_wireless_get_mode(s_wireless), ==, "infrastructure"); - - g_object_unref(connection); + s_wifi = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); + g_assert_cmpstr(nm_setting_wireless_get_mode(s_wifi), ==, "infrastructure"); } static void test_read_wifi_open_ssid_hex(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWireless * s_wireless; - GBytes * ssid; - const char * expected_ssid = "blahblah"; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWireless * s_wifi; + GBytes * ssid; + const char * expected_ssid = "blahblah"; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-open-ssid-hex", NULL, TYPE_WIRELESS, NULL); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System blahblah (test-wifi-open-ssid-hex)"); - /* ===== WIRELESS SETTING ===== */ + s_wifi = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); - - ssid = nm_setting_wireless_get_ssid(s_wireless); + ssid = nm_setting_wireless_get_ssid(s_wifi); g_assert(ssid); g_assert_cmpmem(g_bytes_get_data(ssid, NULL), g_bytes_get_size(ssid), expected_ssid, strlen(expected_ssid)); - - g_object_unref(connection); } static void @@ -2746,7 +2436,7 @@ test_read_wifi_open_ssid_hex_bad(void) { gs_unref_object NMConnection *connection = NULL; NMSettingConnection * s_con; - NMSettingWireless * s_wireless; + NMSettingWireless * s_wifi; GBytes * ssid; const char * expected_ssid = "0x626cxx"; @@ -2755,16 +2445,14 @@ test_read_wifi_open_ssid_hex_bad(void) TYPE_WIRELESS, NULL); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System 0x626cxx (test-wifi-open-ssid-bad-hex)"); - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); + s_wifi = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - ssid = nm_setting_wireless_get_ssid(s_wireless); + ssid = nm_setting_wireless_get_ssid(s_wifi); g_assert(ssid); g_assert_cmpmem(g_bytes_get_data(ssid, NULL), g_bytes_get_size(ssid), @@ -2781,50 +2469,42 @@ test_read_wifi_open_ssid_bad(gconstpointer data) static void test_read_wifi_open_ssid_quoted(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWireless * s_wireless; - GBytes * ssid; - const char * expected_ssid = "foo\"bar\\"; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWireless * s_wifi; + GBytes * ssid; + const char * expected_ssid = "foo\"bar\\"; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-open-ssid-quoted", NULL, TYPE_WIRELESS, NULL); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System foo\"bar\\ (test-wifi-open-ssid-quoted)"); - /* ===== WIRELESS SETTING ===== */ + s_wifi = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); - - ssid = nm_setting_wireless_get_ssid(s_wireless); + ssid = nm_setting_wireless_get_ssid(s_wifi); g_assert(ssid); g_assert_cmpmem(g_bytes_get_data(ssid, NULL), g_bytes_get_size(ssid), expected_ssid, strlen(expected_ssid)); - - g_object_unref(connection); } static void test_read_wifi_wep(void) { - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWireless * s_wireless; - NMSettingWirelessSecurity *s_wsec; - NMSettingIPConfig * s_ip4; - GBytes * ssid; - const char * mac; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWireless * s_wifi; + NMSettingWirelessSecurity * s_wsec; + NMSettingIPConfig * s_ip4; + GBytes * ssid; + const char * mac; char expected_mac_address[ETH_ALEN] = {0x00, 0x16, 0x41, 0x11, 0x22, 0x33}; const char * expected_ssid = "blahblah"; NMWepKeyType key_type; @@ -2832,10 +2512,7 @@ test_read_wifi_wep(void) connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wep", NULL, TYPE_WIRELESS, NULL); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System blahblah (test-wifi-wep)"); /* UUID can't be tested if the ifcfg does not contain the UUID key, because @@ -2846,34 +2523,27 @@ test_read_wifi_wep(void) g_assert_cmpint(nm_setting_connection_get_timestamp(s_con), ==, 0); g_assert(nm_setting_connection_get_autoconnect(s_con)); - /* ===== WIRELESS SETTING ===== */ - - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); + s_wifi = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - /* MAC address */ - mac = nm_setting_wireless_get_mac_address(s_wireless); + mac = nm_setting_wireless_get_mac_address(s_wifi); g_assert(mac); g_assert(nm_utils_hwaddr_matches(mac, -1, expected_mac_address, sizeof(expected_mac_address))); /* MTU */ - g_assert_cmpint(nm_setting_wireless_get_mtu(s_wireless), ==, 0); + g_assert_cmpint(nm_setting_wireless_get_mtu(s_wifi), ==, 0); - ssid = nm_setting_wireless_get_ssid(s_wireless); + ssid = nm_setting_wireless_get_ssid(s_wifi); g_assert(ssid); g_assert_cmpmem(g_bytes_get_data(ssid, NULL), g_bytes_get_size(ssid), expected_ssid, strlen(expected_ssid)); - g_assert(!nm_setting_wireless_get_bssid(s_wireless)); - g_assert_cmpstr(nm_setting_wireless_get_mode(s_wireless), ==, "infrastructure"); - g_assert_cmpint(nm_setting_wireless_get_channel(s_wireless), ==, 1); - - /* ===== WIRELESS SECURITY SETTING ===== */ + g_assert(!nm_setting_wireless_get_bssid(s_wifi)); + g_assert_cmpstr(nm_setting_wireless_get_mode(s_wifi), ==, "infrastructure"); + g_assert_cmpint(nm_setting_wireless_get_channel(s_wifi), ==, 1); - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_assert_cmpstr(nm_setting_wireless_security_get_key_mgmt(s_wsec), ==, "none"); g_assert_cmpstr(nm_setting_wireless_security_get_auth_alg(s_wsec), ==, "shared"); g_assert_cmpint(nm_setting_wireless_security_get_wep_tx_keyidx(s_wsec), ==, 0); @@ -2888,35 +2558,27 @@ test_read_wifi_wep(void) g_assert(!nm_setting_wireless_security_get_wep_key(s_wsec, 2)); g_assert(!nm_setting_wireless_security_get_wep_key(s_wsec, 3)); - /* ===== IPv4 SETTING ===== */ - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); - - g_object_unref(connection); } static void test_read_wifi_wep_adhoc(void) { - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWireless * s_wireless; - NMSettingWirelessSecurity *s_wsec; - NMSettingIPConfig * s_ip4; - GBytes * ssid; - const char * expected_ssid = "blahblah"; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWireless * s_wifi; + NMSettingWirelessSecurity * s_wsec; + NMSettingIPConfig * s_ip4; + GBytes * ssid; + const char * expected_ssid = "blahblah"; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wep-adhoc", NULL, TYPE_WIRELESS, NULL); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System blahblah (test-wifi-wep-adhoc)"); @@ -2928,26 +2590,20 @@ test_read_wifi_wep_adhoc(void) g_assert(!nm_setting_connection_get_autoconnect(s_con)); - /* ===== WIRELESS SETTING ===== */ + s_wifi = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); - - ssid = nm_setting_wireless_get_ssid(s_wireless); + ssid = nm_setting_wireless_get_ssid(s_wifi); g_assert(ssid); g_assert_cmpmem(g_bytes_get_data(ssid, NULL), g_bytes_get_size(ssid), expected_ssid, strlen(expected_ssid)); - g_assert(!nm_setting_wireless_get_bssid(s_wireless)); - g_assert_cmpstr(nm_setting_wireless_get_mode(s_wireless), ==, "adhoc"); - g_assert_cmpint(nm_setting_wireless_get_channel(s_wireless), ==, 11); - - /* ===== WIRELESS SECURITY SETTING ===== */ + g_assert(!nm_setting_wireless_get_bssid(s_wifi)); + g_assert_cmpstr(nm_setting_wireless_get_mode(s_wifi), ==, "adhoc"); + g_assert_cmpint(nm_setting_wireless_get_channel(s_wifi), ==, 11); - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_assert_cmpstr(nm_setting_wireless_security_get_key_mgmt(s_wsec), ==, "none"); g_assert(!nm_setting_wireless_security_get_auth_alg(s_wsec)); g_assert_cmpint(nm_setting_wireless_security_get_wep_tx_keyidx(s_wsec), ==, 0); @@ -2959,10 +2615,7 @@ test_read_wifi_wep_adhoc(void) g_assert(!nm_setting_wireless_security_get_wep_key(s_wsec, 2)); g_assert(!nm_setting_wireless_security_get_wep_key(s_wsec, 3)); - /* ===== IPv4 SETTING ===== */ - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); /* Ignore auto DNS */ @@ -2972,37 +2625,24 @@ test_read_wifi_wep_adhoc(void) g_assert_cmpint(nm_setting_ip_config_get_num_dns(s_ip4), ==, 2); g_assert_cmpstr(nm_setting_ip_config_get_dns(s_ip4, 0), ==, "4.2.2.1"); g_assert_cmpstr(nm_setting_ip_config_get_dns(s_ip4, 1), ==, "4.2.2.2"); - - g_object_unref(connection); } static void test_read_wifi_wep_passphrase(void) { - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWireless * s_wireless; - NMSettingWirelessSecurity *s_wsec; + gs_unref_object NMConnection *connection = NULL; + NMSettingWirelessSecurity * s_wsec; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wep-passphrase", NULL, TYPE_WIRELESS, NULL); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); - - /* ===== WIRELESS SETTING ===== */ - - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); - /* ===== WIRELESS SECURITY SETTING ===== */ + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_assert_cmpstr(nm_setting_wireless_security_get_key_mgmt(s_wsec), ==, "none"); g_assert_cmpint(nm_setting_wireless_security_get_wep_tx_keyidx(s_wsec), ==, 0); g_assert_cmpint(nm_setting_wireless_security_get_wep_key_type(s_wsec), @@ -3012,38 +2652,25 @@ test_read_wifi_wep_passphrase(void) g_assert(!nm_setting_wireless_security_get_wep_key(s_wsec, 1)); g_assert(!nm_setting_wireless_security_get_wep_key(s_wsec, 2)); g_assert(!nm_setting_wireless_security_get_wep_key(s_wsec, 3)); - - g_object_unref(connection); } static void test_read_wifi_wep_40_ascii(void) { - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWireless * s_wireless; - NMSettingWirelessSecurity *s_wsec; - NMWepKeyType key_type; + gs_unref_object NMConnection *connection = NULL; + NMSettingWirelessSecurity * s_wsec; + NMWepKeyType key_type; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wep-40-ascii", NULL, TYPE_WIRELESS, NULL); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); - - /* ===== WIRELESS SETTING ===== */ - - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); - /* ===== WIRELESS SECURITY SETTING ===== */ + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_assert_cmpstr(nm_setting_wireless_security_get_key_mgmt(s_wsec), ==, "none"); g_assert_cmpint(nm_setting_wireless_security_get_wep_tx_keyidx(s_wsec), ==, 0); @@ -3054,38 +2681,25 @@ test_read_wifi_wep_40_ascii(void) g_assert(!nm_setting_wireless_security_get_wep_key(s_wsec, 1)); g_assert(!nm_setting_wireless_security_get_wep_key(s_wsec, 2)); g_assert(!nm_setting_wireless_security_get_wep_key(s_wsec, 3)); - - g_object_unref(connection); } static void test_read_wifi_wep_104_ascii(void) { - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWireless * s_wireless; - NMSettingWirelessSecurity *s_wsec; - NMWepKeyType key_type; + gs_unref_object NMConnection *connection = NULL; + NMSettingWirelessSecurity * s_wsec; + NMWepKeyType key_type; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wep-104-ascii", NULL, TYPE_WIRELESS, NULL); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); - /* ===== WIRELESS SETTING ===== */ + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); - - /* ===== WIRELESS SECURITY SETTING ===== */ - - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_assert_cmpstr(nm_setting_wireless_security_get_key_mgmt(s_wsec), ==, "none"); g_assert_cmpint(nm_setting_wireless_security_get_wep_tx_keyidx(s_wsec), ==, 0); @@ -3096,64 +2710,45 @@ test_read_wifi_wep_104_ascii(void) g_assert(!nm_setting_wireless_security_get_wep_key(s_wsec, 1)); g_assert(!nm_setting_wireless_security_get_wep_key(s_wsec, 2)); g_assert(!nm_setting_wireless_security_get_wep_key(s_wsec, 3)); - - g_object_unref(connection); } static void test_read_wifi_leap(void) { - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWireless * s_wireless; - NMSettingWirelessSecurity *s_wsec; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWirelessSecurity * s_wsec; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-leap", NULL, TYPE_WIRELESS, NULL); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System blahblah (test-wifi-leap)"); - /* ===== WIRELESS SETTING ===== */ - - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); - - /* ===== WIRELESS SECURITY SETTING ===== */ + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_assert_cmpstr(nm_setting_wireless_security_get_key_mgmt(s_wsec), ==, "ieee8021x"); g_assert_cmpstr(nm_setting_wireless_security_get_auth_alg(s_wsec), ==, "leap"); g_assert_cmpstr(nm_setting_wireless_security_get_leap_username(s_wsec), ==, "Bill Smith"); g_assert_cmpstr(nm_setting_wireless_security_get_leap_password(s_wsec), ==, "foobarblah"); - - g_object_unref(connection); } static void test_read_wifi_leap_secret_flags(gconstpointer test_data) { - NMConnection * connection; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity *s_wsec; - const char * file; - gpointer expected_flags_p; + gs_unref_object NMConnection *connection = NULL; + NMSettingWirelessSecurity * s_wsec; + const char * file; + gpointer expected_flags_p; nmtst_test_data_unpack(test_data, &file, &expected_flags_p); connection = _connection_from_file(file, NULL, TYPE_WIRELESS, NULL); - /* ===== WIRELESS SETTING ===== */ - s_wifi = nm_connection_get_setting_wireless(connection); - g_assert(s_wifi); + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - /* ===== WIRELESS SECURITY SETTING ===== */ - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_assert(g_strcmp0(nm_setting_wireless_security_get_key_mgmt(s_wsec), "ieee8021x") == 0); g_assert(g_strcmp0(nm_setting_wireless_security_get_auth_alg(s_wsec), "leap") == 0); @@ -3162,8 +2757,6 @@ test_read_wifi_leap_secret_flags(gconstpointer test_data) g_assert(nm_setting_wireless_security_get_leap_password_flags(s_wsec) == GPOINTER_TO_INT(expected_flags_p)); g_assert(nm_setting_wireless_security_get_leap_password(s_wsec) == NULL); - - g_object_unref(connection); } static void @@ -3179,13 +2772,13 @@ test_ifcfg_no_trailing_newline(void) static void test_read_wifi_wpa_psk(void) { - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWireless * s_wireless; - NMSettingWirelessSecurity *s_wsec; - NMSettingIPConfig * s_ip4; - GBytes * ssid; - const char * mac; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWireless * s_wifi; + NMSettingWirelessSecurity * s_wsec; + NMSettingIPConfig * s_ip4; + GBytes * ssid; + const char * mac; char expected_mac_address[ETH_ALEN] = {0x00, 0x16, 0x41, 0x11, 0x22, 0x33}; const char *expected_ssid = "blahblah"; guint32 n, i; @@ -3201,10 +2794,7 @@ test_read_wifi_wpa_psk(void) connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wpa-psk", NULL, TYPE_WIRELESS, NULL); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System blahblah (test-wifi-wpa-psk)"); /* UUID can't be tested if the ifcfg does not contain the UUID key, because @@ -3215,32 +2805,26 @@ test_read_wifi_wpa_psk(void) g_assert_cmpint(nm_setting_connection_get_timestamp(s_con), ==, 0); g_assert(nm_setting_connection_get_autoconnect(s_con)); - /* ===== WIRELESS SETTING ===== */ - - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); + s_wifi = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - mac = nm_setting_wireless_get_mac_address(s_wireless); + mac = nm_setting_wireless_get_mac_address(s_wifi); g_assert(mac); g_assert(nm_utils_hwaddr_matches(mac, -1, expected_mac_address, sizeof(expected_mac_address))); - g_assert_cmpint(nm_setting_wireless_get_mtu(s_wireless), ==, 0); + g_assert_cmpint(nm_setting_wireless_get_mtu(s_wifi), ==, 0); - ssid = nm_setting_wireless_get_ssid(s_wireless); + ssid = nm_setting_wireless_get_ssid(s_wifi); g_assert(ssid); g_assert_cmpmem(g_bytes_get_data(ssid, NULL), g_bytes_get_size(ssid), expected_ssid, strlen(expected_ssid)); - g_assert(!nm_setting_wireless_get_bssid(s_wireless)); - g_assert_cmpstr(nm_setting_wireless_get_mode(s_wireless), ==, "infrastructure"); - g_assert_cmpint(nm_setting_wireless_get_channel(s_wireless), ==, 1); + g_assert(!nm_setting_wireless_get_bssid(s_wifi)); + g_assert_cmpstr(nm_setting_wireless_get_mode(s_wifi), ==, "infrastructure"); + g_assert_cmpint(nm_setting_wireless_get_channel(s_wifi), ==, 1); - /* ===== WIRELESS SECURITY SETTING ===== */ - - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_assert_cmpstr(nm_setting_wireless_security_get_key_mgmt(s_wsec), ==, "wpa-psk"); g_assert_cmpstr(nm_setting_wireless_security_get_psk(s_wsec), ==, @@ -3295,13 +2879,8 @@ test_read_wifi_wpa_psk(void) g_assert(found_proto_wpa); g_assert(found_proto_rsn); - /* ===== IPv4 SETTING ===== */ - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); - - g_object_unref(connection); } static void @@ -3309,7 +2888,7 @@ test_read_wifi_sae(void) { gs_unref_object NMConnection *connection = NULL; NMSettingConnection * s_con; - NMSettingWireless * s_wireless; + NMSettingWireless * s_wifi; NMSettingWirelessSecurity * s_wsec; GBytes * ssid; const char * expected_ssid = "blahblah"; @@ -3317,30 +2896,27 @@ test_read_wifi_sae(void) connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-sae", NULL, TYPE_WIRELESS, NULL); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System blahblah (test-wifi-sae)"); g_assert_cmpint(nm_setting_connection_get_timestamp(s_con), ==, 0); g_assert(nm_setting_connection_get_autoconnect(s_con)); - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); + s_wifi = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - g_assert_cmpint(nm_setting_wireless_get_mtu(s_wireless), ==, 0); + g_assert_cmpint(nm_setting_wireless_get_mtu(s_wifi), ==, 0); - ssid = nm_setting_wireless_get_ssid(s_wireless); + ssid = nm_setting_wireless_get_ssid(s_wifi); g_assert(ssid); g_assert_cmpmem(g_bytes_get_data(ssid, NULL), g_bytes_get_size(ssid), expected_ssid, strlen(expected_ssid)); - g_assert(!nm_setting_wireless_get_bssid(s_wireless)); - g_assert_cmpstr(nm_setting_wireless_get_mode(s_wireless), ==, "infrastructure"); + g_assert(!nm_setting_wireless_get_bssid(s_wifi)); + g_assert_cmpstr(nm_setting_wireless_get_mode(s_wifi), ==, "infrastructure"); - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_assert_cmpstr(nm_setting_wireless_security_get_key_mgmt(s_wsec), ==, "sae"); g_assert_cmpstr(nm_setting_wireless_security_get_psk(s_wsec), ==, "The king is dead."); g_assert(!nm_setting_wireless_security_get_auth_alg(s_wsec)); @@ -3351,7 +2927,7 @@ test_read_wifi_owe(void) { gs_unref_object NMConnection *connection = NULL; NMSettingConnection * s_con; - NMSettingWireless * s_wireless; + NMSettingWireless * s_wifi; NMSettingWirelessSecurity * s_wsec; GBytes * ssid; const char * expected_ssid = "blahblah_owe"; @@ -3359,30 +2935,27 @@ test_read_wifi_owe(void) connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-owe", NULL, TYPE_WIRELESS, NULL); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System blahblah_owe (test-wifi-owe)"); g_assert_cmpint(nm_setting_connection_get_timestamp(s_con), ==, 0); g_assert(nm_setting_connection_get_autoconnect(s_con)); - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); + s_wifi = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - g_assert_cmpint(nm_setting_wireless_get_mtu(s_wireless), ==, 0); + g_assert_cmpint(nm_setting_wireless_get_mtu(s_wifi), ==, 0); - ssid = nm_setting_wireless_get_ssid(s_wireless); + ssid = nm_setting_wireless_get_ssid(s_wifi); g_assert(ssid); g_assert_cmpmem(g_bytes_get_data(ssid, NULL), g_bytes_get_size(ssid), expected_ssid, strlen(expected_ssid)); - g_assert(!nm_setting_wireless_get_bssid(s_wireless)); - g_assert_cmpstr(nm_setting_wireless_get_mode(s_wireless), ==, "infrastructure"); + g_assert(!nm_setting_wireless_get_bssid(s_wifi)); + g_assert_cmpstr(nm_setting_wireless_get_mode(s_wifi), ==, "infrastructure"); - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_assert_cmpstr(nm_setting_wireless_security_get_key_mgmt(s_wsec), ==, "owe"); g_assert(!nm_setting_wireless_security_get_psk(s_wsec)); g_assert(!nm_setting_wireless_security_get_auth_alg(s_wsec)); @@ -3391,71 +2964,47 @@ test_read_wifi_owe(void) static void test_read_wifi_wpa_psk_2(void) { - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWireless * s_wireless; - NMSettingWirelessSecurity *s_wsec; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWirelessSecurity * s_wsec; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wpa-psk-2", NULL, TYPE_WIRELESS, NULL); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System ipsum (test-wifi-wpa-psk-2)"); - /* ===== WIRELESS SETTING ===== */ - - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - /* ===== WIRELESS SECURITY SETTING ===== */ - - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_assert_cmpstr(nm_setting_wireless_security_get_psk(s_wsec), ==, "They're really saying I love you. >>`<< '"); - - g_object_unref(connection); } static void test_read_wifi_wpa_psk_unquoted(void) { - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWireless * s_wireless; - NMSettingWirelessSecurity *s_wsec; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWirelessSecurity * s_wsec; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wpa-psk-unquoted", NULL, TYPE_WIRELESS, NULL); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System blahblah (test-wifi-wpa-psk-unquoted)"); - /* ===== WIRELESS SETTING ===== */ + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); - - /* ===== WIRELESS SECURITY SETTING ===== */ - - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_assert_cmpstr(nm_setting_wireless_security_get_psk(s_wsec), ==, "54336845e2f3f321c4c7"); - - g_object_unref(connection); } static void @@ -3472,36 +3021,27 @@ test_read_wifi_wpa_psk_unquoted2(void) static void test_read_wifi_wpa_psk_adhoc(void) { - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWireless * s_wireless; - NMSettingWirelessSecurity *s_wsec; - NMSettingIPConfig * s_ip4; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWireless * s_wifi; + NMSettingWirelessSecurity * s_wsec; + NMSettingIPConfig * s_ip4; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wpa-psk-adhoc", NULL, TYPE_WIRELESS, NULL); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System blahblah (test-wifi-wpa-psk-adhoc)"); - /* ===== WIRELESS SETTING ===== */ + s_wifi = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); + g_assert_cmpstr(nm_setting_wireless_get_mode(s_wifi), ==, "adhoc"); - g_assert_cmpstr(nm_setting_wireless_get_mode(s_wireless), ==, "adhoc"); - - /* ===== WIRELESS SECURITY SETTING ===== */ - - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_assert_cmpstr(nm_setting_wireless_security_get_key_mgmt(s_wsec), ==, "wpa-psk"); g_assert_cmpstr(nm_setting_wireless_security_get_psk(s_wsec), ==, @@ -3516,64 +3056,45 @@ test_read_wifi_wpa_psk_adhoc(void) g_assert_cmpint(nm_setting_wireless_security_get_num_protos(s_wsec), ==, 1); g_assert_cmpstr(nm_setting_wireless_security_get_proto(s_wsec, 0), ==, "rsn"); - /* ===== IPv4 SETTING ===== */ - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); - - g_object_unref(connection); } static void test_read_wifi_wpa_psk_hex(void) { - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWireless * s_wireless; - NMSettingWirelessSecurity *s_wsec; - NMSettingIPConfig * s_ip4; - GBytes * ssid; - const char * expected_ssid = "blahblah"; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWireless * s_wifi; + NMSettingWirelessSecurity * s_wsec; + NMSettingIPConfig * s_ip4; + GBytes * ssid; + const char * expected_ssid = "blahblah"; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wpa-psk-hex", NULL, TYPE_WIRELESS, NULL); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System blahblah (test-wifi-wpa-psk-hex)"); - /* ===== WIRELESS SETTING ===== */ - - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); + s_wifi = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - ssid = nm_setting_wireless_get_ssid(s_wireless); + ssid = nm_setting_wireless_get_ssid(s_wifi); g_assert(ssid); - g_assert(nm_utils_gbytes_equal_mem(ssid, expected_ssid, strlen(expected_ssid))); + g_assert(nm_g_bytes_equal_mem(ssid, expected_ssid, strlen(expected_ssid))); - /* ===== WIRELESS SECURITY SETTING ===== */ - - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_assert_cmpstr(nm_setting_wireless_security_get_key_mgmt(s_wsec), ==, "wpa-psk"); g_assert_cmpstr(nm_setting_wireless_security_get_psk(s_wsec), ==, "1da190379817bc360dda52e85c388c439a21ea5c7bf819c64e9da051807deae6"); - /* ===== IPv4 SETTING ===== */ - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); - - g_object_unref(connection); } #define TEST_IFCFG_WIFI_WPA_EAP_TLS_CA_CERT TEST_IFCFG_DIR "/test_ca_cert.pem" @@ -3583,12 +3104,11 @@ test_read_wifi_wpa_psk_hex(void) static void test_read_wifi_wpa_eap_tls(void) { - NMConnection * connection; - NMSettingWireless *s_wireless; - NMSettingIPConfig *s_ip4; - NMSetting8021x * s_8021x; - char * unmanaged = NULL; - const char * expected_privkey_password = "test1"; + gs_unref_object NMConnection *connection = NULL; + NMSettingIPConfig * s_ip4; + NMSetting8021x * s_8021x; + char * unmanaged = NULL; + const char * expected_privkey_password = "test1"; NMTST_EXPECT_NM_WARN("*key ONBOOT is duplicated and the early occurrence ignored*"); connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wpa-eap-tls", @@ -3598,20 +3118,12 @@ test_read_wifi_wpa_eap_tls(void) g_test_assert_expected_messages(); g_assert(!unmanaged); - /* ===== WIRELESS SETTING ===== */ + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); - - /* ===== IPv4 SETTING ===== */ - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); - /* ===== 802.1x SETTING ===== */ - s_8021x = nm_connection_get_setting_802_1x(connection); - g_assert(s_8021x); + s_8021x = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_802_1X); g_assert_cmpint(nm_setting_802_1x_get_num_eap_methods(s_8021x), ==, 1); g_assert_cmpstr(nm_setting_802_1x_get_eap_method(s_8021x, 0), ==, "tls"); g_assert_cmpstr(nm_setting_802_1x_get_identity(s_8021x), ==, "Bill Smith"); @@ -3638,8 +3150,6 @@ test_read_wifi_wpa_eap_tls(void) TEST_IFCFG_WIFI_WPA_EAP_TLS_PRIVATE_KEY, expected_privkey_password, NM_SETTING_802_1X_PRIVATE_KEY); - - g_object_unref(connection); } /* Also use TLS defines from the previous test */ @@ -3647,12 +3157,11 @@ test_read_wifi_wpa_eap_tls(void) static void test_read_wifi_wpa_eap_ttls_tls(void) { - NMConnection * connection; - NMSettingWireless *s_wireless; - NMSettingIPConfig *s_ip4; - NMSetting8021x * s_8021x; - char * unmanaged = NULL; - const char * expected_privkey_password = "test1"; + gs_unref_object NMConnection *connection = NULL; + NMSettingIPConfig * s_ip4; + NMSetting8021x * s_8021x; + char * unmanaged = NULL; + const char * expected_privkey_password = "test1"; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wpa-eap-ttls-tls", NULL, @@ -3660,20 +3169,12 @@ test_read_wifi_wpa_eap_ttls_tls(void) &unmanaged); g_assert(!unmanaged); - /* ===== WIRELESS SETTING ===== */ + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); - - /* ===== IPv4 SETTING ===== */ - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); - /* ===== 802.1x SETTING ===== */ - s_8021x = nm_connection_get_setting_802_1x(connection); - g_assert(s_8021x); + s_8021x = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_802_1X); g_assert_cmpint(nm_setting_802_1x_get_num_eap_methods(s_8021x), ==, 1); g_assert_cmpstr(nm_setting_802_1x_get_eap_method(s_8021x, 0), ==, "ttls"); g_assert_cmpstr(nm_setting_802_1x_get_identity(s_8021x), ==, "Chuck Shumer"); @@ -3709,59 +3210,40 @@ test_read_wifi_wpa_eap_ttls_tls(void) TEST_IFCFG_WIFI_WPA_EAP_TLS_PRIVATE_KEY, expected_privkey_password, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY); - - g_object_unref(connection); } static void test_read_wifi_wpa_eap_suite_b_192_tls(void) { - NMConnection * connection; - NMSettingWireless * s_wireless; - NMSettingWirelessSecurity *s_wireless_sec; + gs_unref_object NMConnection *connection = NULL; + NMSettingWirelessSecurity * s_wsec; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wpa-eap-suite-b-192-tls", NULL, TYPE_WIRELESS, NULL); - /* ===== WIRELESS SETTING ===== */ - - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); - - /* ===== WIRELESS SECURITY SETTING ===== */ + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - s_wireless_sec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wireless_sec); - g_assert_cmpstr(nm_setting_wireless_security_get_key_mgmt(s_wireless_sec), - ==, - "wpa-eap-suite-b-192"); - - g_object_unref(connection); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); + g_assert_cmpstr(nm_setting_wireless_security_get_key_mgmt(s_wsec), ==, "wpa-eap-suite-b-192"); } static void test_read_wifi_dynamic_wep_leap(void) { - NMConnection * connection; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity *s_wsec; - NMSetting8021x * s_8021x; + gs_unref_object NMConnection *connection = NULL; + NMSettingWirelessSecurity * s_wsec; + NMSetting8021x * s_8021x; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-dynamic-wep-leap", NULL, TYPE_WIRELESS, NULL); - /* ===== WIRELESS SETTING ===== */ - - s_wifi = nm_connection_get_setting_wireless(connection); - g_assert(s_wifi); + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - /* ===== Wi-Fi SECURITY SETTING ===== */ - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); /* Key management */ g_assert_cmpstr(nm_setting_wireless_security_get_key_mgmt(s_wsec), ==, "ieee8021x"); @@ -3775,9 +3257,7 @@ test_read_wifi_dynamic_wep_leap(void) g_assert_cmpstr(nm_setting_wireless_security_get_leap_username(s_wsec), ==, NULL); g_assert_cmpstr(nm_setting_wireless_security_get_leap_password(s_wsec), ==, NULL); - /* ===== 802.1x SETTING ===== */ - s_8021x = nm_connection_get_setting_802_1x(connection); - g_assert(s_8021x); + s_8021x = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_802_1X); /* EAP method should be "leap" */ g_assert_cmpint(nm_setting_802_1x_get_num_eap_methods(s_8021x), ==, 1); @@ -3786,19 +3266,16 @@ test_read_wifi_dynamic_wep_leap(void) /* username & password */ g_assert_cmpstr(nm_setting_802_1x_get_identity(s_8021x), ==, "bill smith"); g_assert_cmpstr(nm_setting_802_1x_get_password(s_8021x), ==, "foobar baz"); - - g_object_unref(connection); } static void test_read_wifi_wep_eap_ttls_chap(void) { - NMConnection * connection; - NMSettingWireless * s_wireless; - NMSettingWirelessSecurity *s_wsec; - NMSettingIPConfig * s_ip4; - NMSetting8021x * s_8021x; - char * unmanaged = NULL; + gs_unref_object NMConnection *connection = NULL; + NMSettingWirelessSecurity * s_wsec; + NMSettingIPConfig * s_ip4; + NMSetting8021x * s_8021x; + char * unmanaged = NULL; NMTST_EXPECT_NM_WARN("*key ONBOOT is duplicated and the early occurrence ignored*"); connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wep-eap-ttls-chap", @@ -3808,25 +3285,15 @@ test_read_wifi_wep_eap_ttls_chap(void) g_test_assert_expected_messages(); g_assert(!unmanaged); - /* ===== WIRELESS SETTING ===== */ + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); - - /* ===== IPv4 SETTING ===== */ - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); - /* ===== 802.1x SETTING ===== */ - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_assert_cmpstr(nm_setting_wireless_security_get_key_mgmt(s_wsec), ==, "ieee8021x"); - /* ===== 802.1x SETTING ===== */ - s_8021x = nm_connection_get_setting_802_1x(connection); - g_assert(s_8021x); + s_8021x = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_802_1X); /* EAP methods */ g_assert_cmpint(nm_setting_802_1x_get_num_eap_methods(s_8021x), ==, 1); @@ -3841,38 +3308,32 @@ test_read_wifi_wep_eap_ttls_chap(void) g_assert_cmpstr(nm_setting_802_1x_get_phase2_auth(s_8021x), ==, "chap"); g_assert_cmpstr(nm_setting_802_1x_get_identity(s_8021x), ==, "David Smith"); g_assert_cmpstr(nm_setting_802_1x_get_password(s_8021x), ==, "foobar baz"); - - g_object_unref(connection); } static void test_read_wired_wake_on_lan(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWired * s_wired; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWired * s_wired; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-wake-on-lan", NULL, TYPE_WIRELESS, NULL); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_connection_type(s_con), ==, NM_SETTING_WIRED_SETTING_NAME); - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); g_assert_cmpint(nm_setting_wired_get_wake_on_lan(s_wired), ==, NM_SETTING_WIRED_WAKE_ON_LAN_ARP | NM_SETTING_WIRED_WAKE_ON_LAN_PHY | NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC); g_assert_cmpstr(nm_setting_wired_get_wake_on_lan_password(s_wired), ==, "00:11:22:33:44:55"); - - g_object_unref(connection); } static void @@ -3887,14 +3348,12 @@ test_read_wired_auto_negotiate_off(void) TYPE_ETHERNET, NULL); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_connection_type(s_con), ==, NM_SETTING_WIRED_SETTING_NAME); - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); g_assert(!nm_setting_wired_get_auto_negotiate(s_wired)); g_assert_cmpint(nm_setting_wired_get_speed(s_wired), ==, 100); @@ -3913,14 +3372,12 @@ test_read_wired_auto_negotiate_on(void) TYPE_ETHERNET, NULL); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_connection_type(s_con), ==, NM_SETTING_WIRED_SETTING_NAME); - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); g_assert(nm_setting_wired_get_auto_negotiate(s_wired)); g_assert_cmpint(nm_setting_wired_get_speed(s_wired), ==, 0); @@ -3939,14 +3396,12 @@ test_read_wired_unknown_ethtool_opt(void) TYPE_ETHERNET, NULL); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_connection_type(s_con), ==, NM_SETTING_WIRED_SETTING_NAME); - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); g_assert(!nm_setting_wired_get_auto_negotiate(s_wired)); g_assert(!nm_setting_wired_get_speed(s_wired)); @@ -3980,8 +3435,8 @@ test_roundtrip_ethtool(void) NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); - s_ethtool = nm_setting_ethtool_new(); - nm_connection_add_setting(connection, s_ethtool); + + s_ethtool = _nm_connection_new_setting(connection, NM_TYPE_SETTING_ETHTOOL); _writer_new_connec_exp(connection, TEST_SCRATCH_DIR, TEST_IFCFG_DIR "/ifcfg-test_roundtrip_ethtool-2.cexpected", @@ -3992,7 +3447,7 @@ test_roundtrip_ethtool(void) NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); - s_wired = nm_connection_get_setting(connection, NM_TYPE_SETTING_WIRED); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); g_object_set(s_wired, NM_SETTING_WIRED_AUTO_NEGOTIATE, TRUE, NULL); _writer_new_connec_exp(connection, TEST_SCRATCH_DIR, @@ -4004,8 +3459,8 @@ test_roundtrip_ethtool(void) NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); - s_ethtool = nm_setting_ethtool_new(); - nm_connection_add_setting(connection, s_ethtool); + + s_ethtool = _nm_connection_new_setting(connection, NM_TYPE_SETTING_ETHTOOL); nm_setting_option_set_boolean(s_ethtool, NM_ETHTOOL_OPTNAME_FEATURE_RX, TRUE); _writer_new_connec_exp(connection, TEST_SCRATCH_DIR, @@ -4017,10 +3472,10 @@ test_roundtrip_ethtool(void) NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); - s_wired = nm_connection_get_setting(connection, NM_TYPE_SETTING_WIRED); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); g_object_set(s_wired, NM_SETTING_WIRED_AUTO_NEGOTIATE, TRUE, NULL); - s_ethtool = nm_setting_ethtool_new(); - nm_connection_add_setting(connection, s_ethtool); + + s_ethtool = _nm_connection_new_setting(connection, NM_TYPE_SETTING_ETHTOOL); nm_setting_option_set_boolean(s_ethtool, NM_ETHTOOL_OPTNAME_FEATURE_RX, TRUE); _writer_new_connec_exp(connection, TEST_SCRATCH_DIR, @@ -4032,24 +3487,20 @@ test_roundtrip_ethtool(void) static void test_read_wifi_hidden(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWireless * s_wifi; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWireless * s_wifi; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-hidden", NULL, TYPE_WIRELESS, NULL); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_connection_type(s_con), ==, NM_SETTING_WIRELESS_SETTING_NAME); - s_wifi = nm_connection_get_setting_wireless(connection); - g_assert(s_wifi); + s_wifi = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); g_assert(nm_setting_wireless_get_hidden(s_wifi) == TRUE); - - g_object_unref(connection); } static void @@ -4061,15 +3512,12 @@ test_write_wifi_hidden(void) NMSettingConnection * s_con; NMSettingWireless * s_wifi; shvarFile * f; - GBytes * ssid; - const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; + gs_unref_bytes GBytes *ssid = + nmtst_gbytes_from_arr(0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44); connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wi-Fi Hidden", @@ -4079,16 +3527,9 @@ test_write_wifi_hidden(void) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_HIDDEN, TRUE, NULL); - g_bytes_unref(ssid); - nmtst_assert_connection_verifies(connection); _writer_new_connec_exp(connection, @@ -4121,8 +3562,7 @@ test_read_wifi_mac_random(gconstpointer user_data) path = g_strdup_printf(TEST_IFCFG_DIR "/ifcfg-test-wifi-mac-random-%s", name); connection = _connection_from_file(path, NULL, TYPE_WIRELESS, NULL); - s_wifi = nm_connection_get_setting_wireless(connection); - g_assert(s_wifi); + s_wifi = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); g_assert_cmpint(nm_setting_wireless_get_mac_address_randomization(s_wifi), ==, value); } @@ -4134,10 +3574,10 @@ test_write_wifi_mac_random(gconstpointer user_data) gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; NMSettingWireless * s_wifi; - char * val; + gs_free char * val = NULL; shvarFile * f; - GBytes * ssid; - const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; + gs_unref_bytes GBytes *ssid = + nmtst_gbytes_from_arr(0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44); const char * name, *write_expected; gpointer value_p; NMSettingMacRandomization value; @@ -4150,9 +3590,7 @@ test_write_wifi_mac_random(gconstpointer user_data) connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); val = g_strdup_printf("Test Write Wi-Fi MAC %s", name); g_object_set(s_con, @@ -4163,13 +3601,8 @@ test_write_wifi_mac_random(gconstpointer user_data) NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_free(val); - - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -4178,7 +3611,6 @@ test_write_wifi_mac_random(gconstpointer user_data) NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION, value, NULL); - g_bytes_unref(ssid); nmtst_assert_connection_verifies(connection); @@ -4205,16 +3637,12 @@ test_write_wired_wake_on_lan(void) gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; NMSettingWired * s_wired; - NMSettingWiredWakeOnLan wol; - char * val; + gs_free char * val = NULL; shvarFile * f; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired Wake-on-LAN", @@ -4224,16 +3652,12 @@ test_write_wired_wake_on_lan(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - wol = NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST | NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST - | NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC; - + s_wired = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); g_object_set(s_wired, NM_SETTING_WIRED_WAKE_ON_LAN, - wol, + (guint) (NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST + | NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST + | NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC), NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, "00:00:00:11:22:33", NULL); @@ -4250,7 +3674,6 @@ test_write_wired_wake_on_lan(void) g_assert(val); g_assert(strstr(val, "wol")); g_assert(strstr(val, "sopass 00:00:00:11:22:33")); - g_free(val); svCloseFile(f); reread = _connection_from_file(testfile, NULL, TYPE_ETHERNET, NULL); @@ -4265,14 +3688,14 @@ test_write_wired_auto_negotiate_off(void) gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; NMSettingWired * s_wired; - char * val; + gs_free char * val = NULL; shvarFile * f; connection = nmtst_create_minimal_connection("Test Write Wired Auto-Negotiate", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); - s_wired = nm_connection_get_setting_wired(connection); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); g_object_set(s_wired, NM_SETTING_WIRED_AUTO_NEGOTIATE, FALSE, @@ -4293,7 +3716,6 @@ test_write_wired_auto_negotiate_off(void) g_assert(strstr(val, "autoneg off")); g_assert(strstr(val, "speed 10")); g_assert(strstr(val, "duplex half")); - g_free(val); svCloseFile(f); reread = _connection_from_file(testfile, NULL, TYPE_ETHERNET, NULL); @@ -4309,20 +3731,19 @@ test_write_wired_auto_negotiate_on(void) gs_unref_object NMConnection *reread = NULL; NMSettingWired * s_wired; NMSettingEthtool * s_ethtool; - char * val; + gs_free char * val = NULL; shvarFile * f; connection = nmtst_create_minimal_connection("Test Write Wired Auto-Negotiate", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); - s_wired = nm_connection_get_setting_wired(connection); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); g_object_set(s_wired, NM_SETTING_WIRED_AUTO_NEGOTIATE, TRUE, NULL); - s_ethtool = NM_SETTING_ETHTOOL(nm_setting_ethtool_new()); + s_ethtool = _nm_connection_new_setting(connection, NM_TYPE_SETTING_ETHTOOL); nm_setting_ethtool_set_feature(s_ethtool, NM_ETHTOOL_OPTNAME_FEATURE_TX, NM_TERNARY_TRUE); nm_setting_ethtool_set_feature(s_ethtool, NM_ETHTOOL_OPTNAME_FEATURE_RXVLAN, NM_TERNARY_FALSE); - nm_connection_add_setting(connection, NM_SETTING(s_ethtool)); _writer_new_connec_exp(connection, TEST_SCRATCH_DIR, @@ -4335,7 +3756,6 @@ test_write_wired_auto_negotiate_on(void) g_assert(strstr(val, "autoneg on")); g_assert(!strstr(val, "speed")); g_assert(!strstr(val, "duplex")); - g_free(val); svCloseFile(f); reread = _connection_from_file(testfile, NULL, TYPE_ETHERNET, NULL); @@ -4344,8 +3764,7 @@ test_write_wired_auto_negotiate_on(void) nmtst_assert_connection_equals(connection, TRUE, reread, FALSE); - s_ethtool = NM_SETTING_ETHTOOL(nm_connection_get_setting(reread, NM_TYPE_SETTING_ETHTOOL)); - g_assert(s_ethtool); + s_ethtool = nmtst_connection_assert_setting(reread, NM_TYPE_SETTING_ETHTOOL); g_assert_cmpint(nm_setting_ethtool_get_feature(s_ethtool, NM_ETHTOOL_OPTNAME_FEATURE_TX), ==, NM_TERNARY_TRUE); @@ -4360,24 +3779,20 @@ test_write_wired_auto_negotiate_on(void) static void test_read_wifi_band_a(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWireless * s_wifi; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWireless * s_wifi; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-band-a", NULL, TYPE_WIRELESS, NULL); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_connection_type(s_con), ==, NM_SETTING_WIRELESS_SETTING_NAME); - s_wifi = nm_connection_get_setting_wireless(connection); - g_assert(s_wifi); + s_wifi = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); g_assert_cmpstr(nm_setting_wireless_get_band(s_wifi), ==, "a"); - - g_object_unref(connection); } static void @@ -4389,15 +3804,12 @@ test_write_wifi_band_a(void) NMSettingConnection * s_con; NMSettingWireless * s_wifi; shvarFile * f; - GBytes * ssid; - const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; + gs_unref_bytes GBytes *ssid = + nmtst_gbytes_from_arr(0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44); connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wi-Fi Band A", @@ -4407,12 +3819,7 @@ test_write_wifi_band_a(void) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -4422,8 +3829,6 @@ test_write_wifi_band_a(void) "a", NULL); - g_bytes_unref(ssid); - nmtst_assert_connection_verifies(connection); _writer_new_connec_exp(connection, @@ -4448,14 +3853,11 @@ test_write_wifi_ap_mode(void) gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; NMSettingWireless * s_wifi; - gs_unref_bytes GBytes *ssid = NULL; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("MySSID"); connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wi-Fi AP Mode", @@ -4465,12 +3867,7 @@ test_write_wifi_ap_mode(void) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new("MySSID", NM_STRLEN("MySSID")); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -4523,12 +3920,12 @@ test_read_wifi_band_bg_channel_mismatch(void) static void test_read_wired_qeth_static(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - char * unmanaged = NULL; - const char *const * subchannels; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWired * s_wired; + NMSettingIPConfig * s_ip4; + char * unmanaged = NULL; + const char *const * subchannels; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-qeth-static", NULL, @@ -4536,16 +3933,10 @@ test_read_wired_qeth_static(void) &unmanaged); g_assert(!unmanaged); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System test-wired-qeth-static"); - /* ===== WIRED SETTING ===== */ - - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); g_assert(!nm_setting_wired_get_mac_address(s_wired)); @@ -4563,25 +3954,20 @@ test_read_wired_qeth_static(void) g_assert_cmpstr(nm_setting_wired_get_s390_option_by_key(s_wired, "portno"), ==, "0"); g_assert_cmpstr(nm_setting_wired_get_s390_option_by_key(s_wired, "layer2"), ==, "1"); - /* ===== IPv4 SETTING ===== */ - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL); - - g_object_unref(connection); } static void test_read_wired_ctc_static(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWired * s_wired; - char * unmanaged = NULL; - const char *const * subchannels; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWired * s_wired; + char * unmanaged = NULL; + const char *const * subchannels; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wired-ctc-static", NULL, @@ -4589,14 +3975,10 @@ test_read_wired_ctc_static(void) &unmanaged); g_assert(unmanaged == NULL); - /* ===== CONNECTION SETTING ===== */ - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con != NULL); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System test-wired-ctc-static"); - /* ===== WIRED SETTING ===== */ - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired != NULL); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); g_assert(nm_setting_wired_get_mac_address(s_wired) == NULL); @@ -4610,28 +3992,22 @@ test_read_wired_ctc_static(void) g_assert_cmpstr(nm_setting_wired_get_s390_nettype(s_wired), ==, "ctc"); g_assert_cmpstr(nm_setting_wired_get_s390_option_by_key(s_wired, "ctcprot"), ==, "0"); - - g_object_unref(connection); } static void test_read_wifi_wep_no_keys(void) { - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWireless * s_wireless; - NMSettingWirelessSecurity *s_wsec; - NMWepKeyType key_type; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingWirelessSecurity * s_wsec; + NMWepKeyType key_type; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wep-no-keys", NULL, TYPE_WIRELESS, NULL); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_id(s_con), ==, "System foobar (test-wifi-wep-no-keys)"); @@ -4641,15 +4017,9 @@ test_read_wifi_wep_no_keys(void) * depending on where the tests are run. */ - /* ===== WIRELESS SETTING ===== */ - - s_wireless = nm_connection_get_setting_wireless(connection); - g_assert(s_wireless); - - /* ===== WIRELESS SECURITY SETTING ===== */ + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); /* Key management */ g_assert_cmpstr(nm_setting_wireless_security_get_key_mgmt(s_wsec), ==, "none"); @@ -4663,26 +4033,21 @@ test_read_wifi_wep_no_keys(void) /* WEP key index 0; we don't expect it to be filled */ g_assert(!nm_setting_wireless_security_get_wep_key(s_wsec, 0)); - - g_object_unref(connection); } static void test_read_permissions(void) { - NMConnection * connection; - NMSettingConnection *s_con; - gboolean success; - guint32 num; - const char * tmp; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + gboolean success; + guint32 num; + const char * tmp; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-permissions", NULL, TYPE_ETHERNET, NULL); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); num = nm_setting_connection_get_num_permissions(s_con); g_assert_cmpint(num, ==, 3); @@ -4702,18 +4067,15 @@ test_read_permissions(void) success = nm_setting_connection_get_permission(s_con, 2, NULL, &tmp, NULL); g_assert(success); g_assert_cmpstr(tmp, ==, "johnny5"); - - g_object_unref(connection); } static void test_read_wifi_wep_agent_keys(void) { - NMConnection * connection; - NMSettingWireless * s_wifi; - NMSettingWirelessSecurity *s_wsec; - NMWepKeyType key_type; - NMSettingSecretFlags flags; + gs_unref_object NMConnection *connection = NULL; + NMSettingWirelessSecurity * s_wsec; + NMWepKeyType key_type; + NMSettingSecretFlags flags; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-wifi-wep-agent-keys", NULL, @@ -4724,13 +4086,9 @@ test_read_wifi_wep_agent_keys(void) * we don't have any WEP keys because they are agent owned. */ - /* ===== WIRELESS SETTING ===== */ - s_wifi = nm_connection_get_setting_wireless(connection); - g_assert(s_wifi); + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS); - /* ===== WIRELESS SECURITY SETTING ===== */ - s_wsec = nm_connection_get_setting_wireless_security(connection); - g_assert(s_wsec); + s_wsec = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_assert(strcmp(nm_setting_wireless_security_get_key_mgmt(s_wsec), "none") == 0); g_assert(nm_setting_wireless_security_get_wep_tx_keyidx(s_wsec) == 0); @@ -4743,8 +4101,6 @@ test_read_wifi_wep_agent_keys(void) flags = nm_setting_wireless_security_get_wep_key_flags(s_wsec); g_assert(flags & NM_SETTING_SECRET_FLAG_AGENT_OWNED); - - g_object_unref(connection); } static void @@ -4765,10 +4121,7 @@ test_write_wired_static(void) connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired Static", @@ -4782,10 +4135,7 @@ test_write_wired_static(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - + s_wired = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); g_object_set(s_wired, NM_SETTING_WIRED_MAC_ADDRESS, "31:33:33:37:be:cd", @@ -4793,10 +4143,7 @@ test_write_wired_static(void) (guint32) 1492, NULL); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, @@ -4824,10 +4171,7 @@ test_write_wired_static(void) nm_setting_ip_config_add_dns_search(s_ip4, "foobar.com"); nm_setting_ip_config_add_dns_search(s_ip4, "lab.foobar.com"); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, @@ -4891,13 +4235,13 @@ test_write_wired_static(void) reread = _connection_from_file(testfile, NULL, TYPE_ETHERNET, NULL); - reread_s_ip4 = nm_connection_get_setting_ip4_config(reread); - reread_s_ip6 = nm_connection_get_setting_ip6_config(reread); + reread_s_ip4 = nmtst_connection_assert_setting(reread, NM_TYPE_SETTING_IP4_CONFIG); + reread_s_ip6 = nmtst_connection_assert_setting(reread, NM_TYPE_SETTING_IP6_CONFIG); g_assert_cmpint(nm_setting_ip_config_get_route_metric(reread_s_ip4), ==, 204); g_assert_cmpint(nm_setting_ip_config_get_route_metric(reread_s_ip6), ==, 206); - nm_connection_add_setting(connection, nm_setting_proxy_new()); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_PROXY); nmtst_assert_connection_equals(connection, FALSE, reread, FALSE); } @@ -4920,10 +4264,7 @@ test_write_wired_static_with_generic(void) connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired Static", @@ -4937,10 +4278,7 @@ test_write_wired_static_with_generic(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - + s_wired = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); g_object_set(s_wired, NM_SETTING_WIRED_MAC_ADDRESS, "31:33:33:37:be:cd", @@ -4948,10 +4286,7 @@ test_write_wired_static_with_generic(void) (guint32) 1492, NULL); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, @@ -4979,10 +4314,7 @@ test_write_wired_static_with_generic(void) nm_setting_ip_config_add_dns_search(s_ip4, "foobar.com"); nm_setting_ip_config_add_dns_search(s_ip4, "lab.foobar.com"); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, @@ -5039,21 +4371,22 @@ test_write_wired_static_with_generic(void) nm_setting_ip_config_add_dns_search(s_ip6, "foobar6.com"); nm_setting_ip_config_add_dns_search(s_ip6, "lab6.foobar.com"); - nm_connection_add_setting(connection, nm_setting_generic_new()); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_GENERIC); nmtst_assert_connection_verifies(connection); _writer_new_connection_FIXME(connection, TEST_SCRATCH_DIR, &testfile); route6file = utils_get_route6_path(testfile); - reread = _connection_from_file(testfile, NULL, TYPE_ETHERNET, NULL); - reread_s_ip4 = nm_connection_get_setting_ip4_config(reread); - reread_s_ip6 = nm_connection_get_setting_ip6_config(reread); + reread = _connection_from_file(testfile, NULL, TYPE_ETHERNET, NULL); + + reread_s_ip4 = nmtst_connection_assert_setting(reread, NM_TYPE_SETTING_IP4_CONFIG); + reread_s_ip6 = nmtst_connection_assert_setting(reread, NM_TYPE_SETTING_IP6_CONFIG); g_assert_cmpint(nm_setting_ip_config_get_route_metric(reread_s_ip4), ==, 204); g_assert_cmpint(nm_setting_ip_config_get_route_metric(reread_s_ip6), ==, 206); - nm_connection_add_setting(connection, nm_setting_proxy_new()); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_PROXY); { gs_unref_hashtable GHashTable *diffs = NULL; @@ -5064,8 +4397,8 @@ test_write_wired_static_with_generic(void) g_assert(g_hash_table_lookup(diffs, "generic")); g_assert(!nm_connection_compare(connection, reread, NM_SETTING_COMPARE_FLAG_EXACT)); } - g_assert(!nm_connection_get_setting(reread, NM_TYPE_SETTING_GENERIC)); - nm_connection_add_setting(reread, nm_setting_generic_new()); + nmtst_connection_assert_no_setting(reread, NM_TYPE_SETTING_GENERIC); + _nm_connection_new_setting(reread, NM_TYPE_SETTING_GENERIC); { gs_unref_hashtable GHashTable *diffs = NULL; @@ -5082,16 +4415,12 @@ test_write_wired_dhcp(void) gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; - NMSettingWired * s_wired; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired DHCP", @@ -5103,14 +4432,9 @@ test_write_wired_dhcp(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, @@ -5130,10 +4454,7 @@ test_write_wired_dhcp(void) nmtst_assert_connection_verifies(connection); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_DHCP, @@ -5195,15 +4516,12 @@ test_write_routing_rules(void) gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; - NMSettingWired * s_wired; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; connection = nm_simple_connection_new(); - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Routing Rules", @@ -5215,17 +4533,12 @@ test_write_routing_rules(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); _ip_routing_rule_add_to_setting(s_ip4, "pref 10 from 0.0.0.0/0 table 1"); @@ -5251,17 +4564,13 @@ test_write_wired_match(void) gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; - NMSettingWired * s_wired; NMSettingMatch * s_match; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired with Match setting", @@ -5273,31 +4582,26 @@ test_write_wired_match(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - - g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); + g_object_set(s_ip6, + NM_SETTING_IP_CONFIG_METHOD, + NM_SETTING_IP6_CONFIG_METHOD_IGNORE, + NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, + (int) NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, + NULL); - /* Match setting */ - s_match = (NMSettingMatch *) nm_setting_match_new(); + s_match = _nm_connection_new_setting(connection, NM_TYPE_SETTING_MATCH); nm_setting_match_add_interface_name(s_match, "ens*"); nm_setting_match_add_interface_name(s_match, "eth 1?"); nm_setting_match_add_interface_name(s_match, "!veth*"); nm_setting_match_add_driver(s_match, "!virtio"); nm_setting_match_add_driver(s_match, "e1000e"); nm_setting_match_add_kernel_command_line(s_match, "!ip="); - nm_connection_add_setting(connection, NM_SETTING(s_match)); nmtst_assert_connection_verifies(connection); _writer_new_connec_exp(connection, @@ -5343,10 +4647,8 @@ test_read_write_wired_dhcp_send_hostname(void) NULL); /* Check dhcp-hostname and dhcp-send-hostname */ - s_ip4 = nm_connection_get_setting_ip4_config(connection); - s_ip6 = nm_connection_get_setting_ip6_config(connection); - g_assert(s_ip4); - g_assert(s_ip6); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); + s_ip6 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_assert(nm_setting_ip_config_get_dhcp_send_hostname(s_ip4) == TRUE); g_assert_cmpstr(nm_setting_ip_config_get_dhcp_hostname(s_ip4), ==, "svata-pulec"); g_assert(!nm_setting_ip_config_get_dhcp_hostname(s_ip6)); @@ -5363,10 +4665,8 @@ test_read_write_wired_dhcp_send_hostname(void) nmtst_assert_connection_equals(connection, TRUE, reread, FALSE); /* Check dhcp-hostname and dhcp-send-hostname from the re-read connection. */ - s_ip4 = nm_connection_get_setting_ip4_config(reread); - s_ip6 = nm_connection_get_setting_ip6_config(reread); - g_assert(s_ip4); - g_assert(s_ip6); + s_ip4 = nmtst_connection_assert_setting(reread, NM_TYPE_SETTING_IP4_CONFIG); + s_ip6 = nmtst_connection_assert_setting(reread, NM_TYPE_SETTING_IP6_CONFIG); g_assert(nm_setting_ip_config_get_dhcp_send_hostname(s_ip4) == FALSE); g_assert_cmpstr(nm_setting_ip_config_get_dhcp_hostname(s_ip4), ==, dhcp_hostname); g_assert_cmpstr(nm_setting_ip_config_get_dhcp_hostname(s_ip6), ==, dhcp_hostname); @@ -5383,8 +4683,7 @@ test_read_wired_dhcpv6_hostname_fallback(void) TYPE_ETHERNET, NULL); - s_ip6 = nm_connection_get_setting_ip6_config(connection); - g_assert(s_ip6); + s_ip6 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_assert(nm_setting_ip_config_get_dhcp_send_hostname(s_ip6) == TRUE); g_assert_cmpstr(nm_setting_ip_config_get_dhcp_hostname(s_ip6), ==, "fully.qualified.domain"); } @@ -5404,10 +4703,7 @@ test_write_wired_static_ip6_only(void) connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired Static IP6 Only", @@ -5419,22 +4715,13 @@ test_write_wired_static_ip6_only(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - + s_wired = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); g_object_set(s_wired, NM_SETTING_WIRED_MAC_ADDRESS, "31:33:33:37:be:cd", NULL); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_DISABLED, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, NULL); /* Add addresses */ @@ -5462,7 +4749,6 @@ test_write_ip6_disabled(void) gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; - NMSettingWired * s_wired; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; @@ -5471,16 +4757,18 @@ test_write_ip6_disabled(void) NM_SETTING_WIRED_SETTING_NAME, &s_con); - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_DISABLED, NULL); + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); + g_object_set(s_ip6, + NM_SETTING_IP_CONFIG_METHOD, + NM_SETTING_IP6_CONFIG_METHOD_DISABLED, + NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, + (int) NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, + NULL); nmtst_assert_connection_verifies(connection); @@ -5513,16 +4801,14 @@ test_write_wired_static_ip6_only_gw(gconstpointer user_data) NMSettingIPConfig * s_ip6; NMIPAddress * addr6; GError * error = NULL; - char * id = NULL; + gs_free char * id = NULL; gs_free char * written_ifcfg_gateway = NULL; const char * gateway6 = user_data; shvarFile * ifcfg; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); id = g_strdup_printf("Test Write Wired Static IP6 Only With Gateway %s", gateway6 ?: "NULL"); g_object_set(s_con, @@ -5535,24 +4821,14 @@ test_write_wired_static_ip6_only_gw(gconstpointer user_data) NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME, NULL); - g_free(id); - - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); + s_wired = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); g_object_set(s_wired, NM_SETTING_WIRED_MAC_ADDRESS, "31:33:33:37:be:cd", NULL); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_DISABLED, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, @@ -5582,14 +4858,14 @@ test_write_wired_static_ip6_only_gw(gconstpointer user_data) svCloseFile(ifcfg); /* access the gateway from the loaded connection. */ - s_ip6 = nm_connection_get_setting_ip6_config(reread); - g_assert(s_ip6 && nm_setting_ip_config_get_num_addresses(s_ip6) == 1); + s_ip6 = nmtst_connection_assert_setting(reread, NM_TYPE_SETTING_IP6_CONFIG); + g_assert(nm_setting_ip_config_get_num_addresses(s_ip6) == 1); addr6 = nm_setting_ip_config_get_address(s_ip6, 0); g_assert(addr6); /* assert that the gateway was written and reloaded as expected */ if (!gateway6 || !strcmp(gateway6, "::")) { - g_assert(nm_setting_ip_config_get_gateway(s_ip6) == NULL); + g_assert_cmpstr(nm_setting_ip_config_get_gateway(s_ip6), ==, NULL); g_assert(written_ifcfg_gateway == NULL); } else { g_assert(nm_setting_ip_config_get_gateway(s_ip6) != NULL); @@ -5607,7 +4883,6 @@ test_read_write_static_routes_legacy(void) gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; - NMSettingWired * s_wired; NMSettingIPConfig * s_ip4; const char * tmp; @@ -5616,10 +4891,7 @@ test_read_write_static_routes_legacy(void) TYPE_ETHERNET, NULL); - /* ===== CONNECTION SETTING ===== */ - - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); /* ID */ tmp = nm_setting_connection_get_id(s_con); @@ -5628,15 +4900,9 @@ test_read_write_static_routes_legacy(void) /* Autoconnect */ g_assert(nm_setting_connection_get_autoconnect(s_con)); - /* ===== WIRED SETTING ===== */ - - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); + nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); - /* ===== IPv4 SETTING ===== */ - - s_ip4 = nm_connection_get_setting_ip4_config(connection); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); g_assert(!nm_setting_ip_config_get_never_default(s_ip4)); @@ -5676,10 +4942,7 @@ test_write_wired_static_routes(void) connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired Static Routes", @@ -5691,10 +4954,7 @@ test_write_wired_static_routes(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - + s_wired = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); g_object_set(s_wired, NM_SETTING_WIRED_MAC_ADDRESS, "31:33:33:37:be:cd", @@ -5702,10 +4962,7 @@ test_write_wired_static_routes(void) (guint32) 1492, NULL); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, @@ -5746,15 +5003,14 @@ test_write_wired_static_routes(void) nm_setting_ip_config_add_dns_search(s_ip4, "foobar.com"); nm_setting_ip_config_add_dns_search(s_ip4, "lab.foobar.com"); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, + (int) NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, NULL); nmtst_assert_connection_verifies(connection); @@ -5770,8 +5026,7 @@ test_write_wired_static_routes(void) * connection equals. */ g_assert(!reread_same); nmtst_assert_connection_verifies_without_normalization(reread); - s_ip4 = nm_connection_get_setting_ip4_config(reread); - g_assert(s_ip4); + s_ip4 = nmtst_connection_assert_setting(reread, NM_TYPE_SETTING_IP4_CONFIG); g_assert_cmpint(nm_setting_ip_config_get_num_routes(s_ip4), ==, 2); route = nm_setting_ip_config_get_route(s_ip4, 1); g_assert(route); @@ -5791,7 +5046,6 @@ test_write_wired_dhcp_8021x_peap_mschapv2(void) gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; - NMSettingWired * s_wired; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; NMSetting8021x * s_8021x; @@ -5800,10 +5054,7 @@ test_write_wired_dhcp_8021x_peap_mschapv2(void) connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired DHCP 802.1x PEAP MSCHAPv2", @@ -5815,31 +5066,22 @@ test_write_wired_dhcp_8021x_peap_mschapv2(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, + (int) NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, NULL); - /* 802.1x setting */ - s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); - nm_connection_add_setting(connection, NM_SETTING(s_8021x)); - + s_8021x = _nm_connection_new_setting(connection, NM_TYPE_SETTING_802_1X); g_object_set(s_8021x, NM_SETTING_802_1X_IDENTITY, "Bob Saget", @@ -5854,7 +5096,6 @@ test_write_wired_dhcp_8021x_peap_mschapv2(void) NM_SETTING_802_1X_PHASE2_AUTH, "mschapv2", NULL); - nm_setting_802_1x_add_eap_method(s_8021x, "peap"); success = nm_setting_802_1x_set_ca_cert(s_8021x, @@ -5883,7 +5124,6 @@ test_write_wired_8021x_tls(gconstpointer test_data) gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; - NMSettingWired * s_wired; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; NMSetting8021x * s_8021x; @@ -5891,7 +5131,9 @@ test_write_wired_8021x_tls(gconstpointer test_data) GError * error = NULL; NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; const char * pw; - char * tmp; + gs_free char * tmp1 = NULL; + gs_free char * tmp2 = NULL; + gs_free char * tmp3 = NULL; gpointer scheme_p, flags_p; NMSetting8021xCKScheme scheme; NMSettingSecretFlags flags; @@ -5902,10 +5144,7 @@ test_write_wired_8021x_tls(gconstpointer test_data) connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired 802.1x TLS Blobs", @@ -5917,29 +5156,20 @@ test_write_wired_8021x_tls(gconstpointer test_data) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, NULL); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - - /* 802.1x setting */ - s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); - nm_connection_add_setting(connection, NM_SETTING(s_8021x)); + s_8021x = _nm_connection_new_setting(connection, NM_TYPE_SETTING_802_1X); g_object_set(s_8021x, NM_SETTING_802_1X_IDENTITY, "Bill Smith", NULL); nm_setting_802_1x_add_eap_method(s_8021x, "tls"); @@ -5992,8 +5222,7 @@ test_write_wired_8021x_tls(gconstpointer test_data) * matter what scheme was used in the original connection they will be read * back in as paths. */ - s_8021x = nm_connection_get_setting_802_1x(reread); - g_assert(s_8021x); + s_8021x = nmtst_connection_assert_setting(reread, NM_TYPE_SETTING_802_1X); g_assert_cmpint(nm_setting_802_1x_get_ca_cert_scheme(s_8021x), ==, NM_SETTING_802_1X_CK_SCHEME_PATH); @@ -6027,7 +5256,7 @@ test_write_wired_8021x_tls(gconstpointer test_data) * say it's not system-owned, and therefore it should not show up * in the re-read connection. */ - s_8021x = nm_connection_get_setting_802_1x(connection); + s_8021x = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_802_1X); g_object_set(s_8021x, NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD, NULL, NULL); } @@ -6035,17 +5264,14 @@ test_write_wired_8021x_tls(gconstpointer test_data) } /* Clean up created certs and keys */ - tmp = utils_cert_path(testfile, "ca-cert", "der"); - nmtst_file_unlink_if_exists(tmp); - g_free(tmp); + tmp1 = utils_cert_path(testfile, "ca-cert", "der"); + nmtst_file_unlink_if_exists(tmp1); - tmp = utils_cert_path(testfile, "client-cert", "der"); - nmtst_file_unlink_if_exists(tmp); - g_free(tmp); + tmp2 = utils_cert_path(testfile, "client-cert", "der"); + nmtst_file_unlink_if_exists(tmp2); - tmp = utils_cert_path(testfile, "private-key", "pem"); - nmtst_file_unlink_if_exists(tmp); - g_free(tmp); + tmp3 = utils_cert_path(testfile, "private-key", "pem"); + nmtst_file_unlink_if_exists(tmp3); } static void @@ -6055,7 +5281,6 @@ test_write_wired_aliases(void) gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; - NMSettingWired * s_wired; NMSettingIPConfig * s_ip4; int num_addresses = 4; const char * ip[] = {"1.1.1.1", "1.1.1.2", "1.1.1.3", "1.1.1.4"}; @@ -6072,10 +5297,7 @@ test_write_wired_aliases(void) connection = nm_simple_connection_new(); g_assert(connection); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "alias0", @@ -6085,14 +5307,9 @@ test_write_wired_aliases(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, @@ -6145,7 +5362,7 @@ test_write_wired_aliases(void) * aliases get read back in essentially random order. So just * verify the aliases manually. */ - s_ip4 = nm_connection_get_setting_ip4_config(connection); + s_ip4 = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_assert(nm_setting_ip_config_get_num_addresses(s_ip4) == num_addresses); /* Addresses */ @@ -6191,7 +5408,6 @@ test_write_gateway(void) gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; - NMSettingWired * s_wired; NMSettingIPConfig * s_ip4; GError * error = NULL; shvarFile * f; @@ -6199,10 +5415,7 @@ test_write_gateway(void) connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Static Addresses Gateway", @@ -6212,14 +5425,9 @@ test_write_gateway(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, @@ -6270,16 +5478,13 @@ test_write_wifi_open(void) NMSettingWireless * s_wifi; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; - GBytes * ssid; - const unsigned char ssid_data[] = {0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44}; - shvarFile * ifcfg; + gs_unref_bytes GBytes *ssid = + nmtst_gbytes_from_arr(0x54, 0x65, 0x73, 0x74, 0x20, 0x53, 0x53, 0x49, 0x44); + shvarFile *ifcfg; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi Open", @@ -6291,12 +5496,7 @@ test_write_wifi_open(void) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -6314,23 +5514,17 @@ test_write_wifi_open(void) (guint32) 1345, NULL); - g_bytes_unref(ssid); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, + (int) NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, NULL); nmtst_assert_connection_verifies(connection); @@ -6356,16 +5550,23 @@ test_write_wifi_open_hex_ssid(void) NMSettingWireless * s_wifi; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; - GBytes * ssid; - const unsigned char ssid_data[] = - {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd}; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_arr(0x11, + 0x22, + 0x33, + 0x44, + 0x55, + 0x66, + 0x77, + 0x88, + 0x99, + 0xaa, + 0xbb, + 0xcc, + 0xdd); connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi Open Hex SSID", @@ -6377,12 +5578,7 @@ test_write_wifi_open_hex_ssid(void) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, sizeof(ssid_data)); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -6390,18 +5586,10 @@ test_write_wifi_open_hex_ssid(void) "infrastructure", NULL); - g_bytes_unref(ssid); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, @@ -6430,16 +5618,12 @@ test_write_wifi_wep(void) NMSettingWirelessSecurity * s_wsec; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; - GBytes * ssid; - const char * ssid_data = "blahblah"; - struct stat statbuf; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + struct stat statbuf; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP", @@ -6451,12 +5635,7 @@ test_write_wifi_wep(void) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, strlen(ssid_data)); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -6464,12 +5643,7 @@ test_write_wifi_wep(void) "infrastructure", NULL); - g_bytes_unref(ssid); - - /* Wireless security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wsec)); - + s_wsec = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", @@ -6483,21 +5657,17 @@ test_write_wifi_wep(void) nm_setting_wireless_security_set_wep_key(s_wsec, 2, "aaaaaaaaaaaaaaaaaaaaaaaaaa"); nm_setting_wireless_security_set_wep_key(s_wsec, 3, "BBBBBBBBBBBBBBBBBBBBBBBBBB"); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, + (int) NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, NULL); nmtst_assert_connection_verifies(connection); @@ -6527,17 +5697,13 @@ test_write_wifi_wep_adhoc(void) NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; GError * error = NULL; - GBytes * ssid; - const char * ssid_data = "blahblah"; - struct stat statbuf; - NMIPAddress * addr; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + struct stat statbuf; + NMIPAddress * addr; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP AdHoc", @@ -6549,27 +5715,14 @@ test_write_wifi_wep_adhoc(void) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, strlen(ssid_data)); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "adhoc", NULL); - g_bytes_unref(ssid); - - /* Wireless security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wsec)); - + s_wsec = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", NULL); nm_setting_wireless_security_set_wep_key(s_wsec, 0, "0123456789abcdef0123456789"); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, @@ -6585,10 +5738,7 @@ test_write_wifi_wep_adhoc(void) nm_setting_ip_config_add_dns(s_ip4, "4.2.2.1"); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, @@ -6622,16 +5772,12 @@ test_write_wifi_wep_passphrase(void) NMSettingWirelessSecurity * s_wsec; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; - GBytes * ssid; - const char * ssid_data = "blahblah"; - struct stat statbuf; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + struct stat statbuf; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP Passphrase", @@ -6643,12 +5789,7 @@ test_write_wifi_wep_passphrase(void) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, strlen(ssid_data)); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -6656,12 +5797,7 @@ test_write_wifi_wep_passphrase(void) "infrastructure", NULL); - g_bytes_unref(ssid); - - /* Wireless security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wsec)); - + s_wsec = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", @@ -6674,16 +5810,10 @@ test_write_wifi_wep_passphrase(void) NULL); nm_setting_wireless_security_set_wep_key(s_wsec, 0, "asdfdjaslfjasd;flasjdfl;aksdf"); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, @@ -6717,16 +5847,12 @@ test_write_wifi_wep_40_ascii(void) NMSettingWirelessSecurity * s_wsec; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; - GBytes * ssid; - const char * ssid_data = "blahblah40"; - struct stat statbuf; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah40"); + struct stat statbuf; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP 40 ASCII", @@ -6738,12 +5864,7 @@ test_write_wifi_wep_40_ascii(void) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, strlen(ssid_data)); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -6751,12 +5872,7 @@ test_write_wifi_wep_40_ascii(void) "infrastructure", NULL); - g_bytes_unref(ssid); - - /* Wireless security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wsec)); - + s_wsec = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", @@ -6772,16 +5888,10 @@ test_write_wifi_wep_40_ascii(void) nm_setting_wireless_security_set_wep_key(s_wsec, 2, "dolor"); nm_setting_wireless_security_set_wep_key(s_wsec, 3, "donec"); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, @@ -6815,16 +5925,12 @@ test_write_wifi_wep_104_ascii(void) NMSettingWirelessSecurity * s_wsec; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; - GBytes * ssid; - const char * ssid_data = "blahblah104"; - struct stat statbuf; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah104"); + struct stat statbuf; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP 104 ASCII", @@ -6836,12 +5942,7 @@ test_write_wifi_wep_104_ascii(void) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, strlen(ssid_data)); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -6849,12 +5950,7 @@ test_write_wifi_wep_104_ascii(void) "infrastructure", NULL); - g_bytes_unref(ssid); - - /* Wireless security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wsec)); - + s_wsec = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", @@ -6870,16 +5966,10 @@ test_write_wifi_wep_104_ascii(void) nm_setting_wireless_security_set_wep_key(s_wsec, 2, "WEP-104 ASCII"); nm_setting_wireless_security_set_wep_key(s_wsec, 3, "thisismyascii"); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, @@ -6916,16 +6006,12 @@ test_write_wifi_leap(void) NMSettingWirelessSecurity * s_wsec; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; - GBytes * ssid; - const char * ssid_data = "blahblah"; - struct stat statbuf; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + struct stat statbuf; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi LEAP", @@ -6937,12 +6023,7 @@ test_write_wifi_leap(void) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, strlen(ssid_data)); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -6950,12 +6031,7 @@ test_write_wifi_leap(void) "infrastructure", NULL); - g_bytes_unref(ssid); - - /* Wireless security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wsec)); - + s_wsec = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", @@ -6967,16 +6043,10 @@ test_write_wifi_leap(void) "foobar22", NULL); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, @@ -7013,17 +6083,13 @@ test_write_wifi_leap_secret_flags(gconstpointer data) NMSettingWirelessSecurity * s_wsec; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; - GBytes * ssid; - const char * ssid_data = "blahblah"; - NMSettingSecretFlags flags = GPOINTER_TO_UINT(data); + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + NMSettingSecretFlags flags = GPOINTER_TO_UINT(data); connection = nm_simple_connection_new(); g_assert(connection); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi LEAP Secret Flags", @@ -7033,23 +6099,15 @@ test_write_wifi_leap_secret_flags(gconstpointer data) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, strlen(ssid_data)); + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); - g_bytes_unref(ssid); - - /* Wireless security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wsec)); + s_wsec = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", @@ -7063,15 +6121,10 @@ test_write_wifi_leap_secret_flags(gconstpointer data) flags, NULL); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, @@ -7108,8 +6161,7 @@ test_write_wifi_wpa_psk(gconstpointer test_data) NMSettingWirelessSecurity * s_wsec; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; - GBytes * ssid; - const char * ssid_data = "blahblah"; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); struct { const char *name, *psk; gpointer wep_group_p, wpa_p, wpa2_p; @@ -7126,10 +6178,7 @@ test_write_wifi_wpa_psk(gconstpointer test_data) connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, args.name, @@ -7141,12 +6190,7 @@ test_write_wifi_wpa_psk(gconstpointer test_data) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, strlen(ssid_data)); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -7154,12 +6198,7 @@ test_write_wifi_wpa_psk(gconstpointer test_data) "infrastructure", NULL); - g_bytes_unref(ssid); - - /* Wireless security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wsec)); - + s_wsec = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", @@ -7184,16 +6223,10 @@ test_write_wifi_wpa_psk(gconstpointer test_data) nm_setting_wireless_security_add_group(s_wsec, "ccmp"); } - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, @@ -7225,16 +6258,12 @@ test_write_wifi_wpa_psk_adhoc(void) NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; GError * error = NULL; - GBytes * ssid; - const char * ssid_data = "blahblah"; - NMIPAddress * addr; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + NMIPAddress * addr; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WPA PSK", @@ -7246,12 +6275,7 @@ test_write_wifi_wpa_psk_adhoc(void) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, strlen(ssid_data)); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -7263,12 +6287,7 @@ test_write_wifi_wpa_psk_adhoc(void) "bg", NULL); - g_bytes_unref(ssid); - - /* Wireless security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wsec)); - + s_wsec = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", @@ -7280,10 +6299,7 @@ test_write_wifi_wpa_psk_adhoc(void) nm_setting_wireless_security_add_pairwise(s_wsec, "ccmp"); nm_setting_wireless_security_add_group(s_wsec, "ccmp"); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, @@ -7299,10 +6315,7 @@ test_write_wifi_wpa_psk_adhoc(void) nm_setting_ip_config_add_dns(s_ip4, "4.2.2.1"); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, @@ -7336,15 +6349,11 @@ test_write_wifi_wpa_eap_tls(void) NMSettingIPConfig * s_ip6; gboolean success; GError * error = NULL; - GBytes * ssid; - const char * ssid_data = "blahblah"; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WPA EAP-TLS", @@ -7356,12 +6365,7 @@ test_write_wifi_wpa_eap_tls(void) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, strlen(ssid_data)); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -7369,12 +6373,7 @@ test_write_wifi_wpa_eap_tls(void) "infrastructure", NULL); - g_bytes_unref(ssid); - - /* Wireless security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wsec)); - + s_wsec = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap", @@ -7385,17 +6384,14 @@ test_write_wifi_wpa_eap_tls(void) nm_setting_wireless_security_add_pairwise(s_wsec, "tkip"); nm_setting_wireless_security_add_group(s_wsec, "tkip"); - /* Wireless security setting */ - s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); - nm_connection_add_setting(connection, NM_SETTING(s_8021x)); - - g_object_set(s_8021x, NM_SETTING_802_1X_IDENTITY, "Bill Smith", NULL); + s_8021x = _nm_connection_new_setting(connection, NM_TYPE_SETTING_802_1X); g_object_set(s_8021x, + NM_SETTING_802_1X_IDENTITY, + "Bill Smith", NM_SETTING_802_1X_PHASE1_AUTH_FLAGS, (guint) (NM_SETTING_802_1X_AUTH_FLAGS_TLS_1_0_DISABLE | NM_SETTING_802_1X_AUTH_FLAGS_TLS_1_1_DISABLE), NULL); - nm_setting_802_1x_add_eap_method(s_8021x, "tls"); success = nm_setting_802_1x_set_ca_cert(s_8021x, @@ -7420,16 +6416,10 @@ test_write_wifi_wpa_eap_tls(void) &error); nmtst_assert_success(success, error); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, @@ -7463,15 +6453,11 @@ test_write_wifi_wpa_eap_ttls_tls(void) NMSettingIPConfig * s_ip6; gboolean success; GError * error = NULL; - GBytes * ssid; - const char * ssid_data = "blahblah"; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WPA EAP-TTLS (TLS)", @@ -7483,12 +6469,7 @@ test_write_wifi_wpa_eap_ttls_tls(void) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, strlen(ssid_data)); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -7496,23 +6477,14 @@ test_write_wifi_wpa_eap_ttls_tls(void) "infrastructure", NULL); - g_bytes_unref(ssid); - - /* Wireless security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wsec)); - + s_wsec = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap", NULL); nm_setting_wireless_security_add_proto(s_wsec, "rsn"); nm_setting_wireless_security_add_pairwise(s_wsec, "ccmp"); nm_setting_wireless_security_add_group(s_wsec, "ccmp"); - /* Wireless security setting */ - s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); - nm_connection_add_setting(connection, NM_SETTING(s_8021x)); - + s_8021x = _nm_connection_new_setting(connection, NM_TYPE_SETTING_802_1X); nm_setting_802_1x_add_eap_method(s_8021x, "ttls"); - g_object_set(s_8021x, NM_SETTING_802_1X_IDENTITY, "Bill Smith", @@ -7556,16 +6528,10 @@ test_write_wifi_wpa_eap_ttls_tls(void) &error); nmtst_assert_success(success, error); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, @@ -7599,15 +6565,11 @@ test_write_wifi_wpa_eap_ttls_mschapv2(void) NMSettingIPConfig * s_ip6; gboolean success; GError * error = NULL; - GBytes * ssid; - const char * ssid_data = "blahblah"; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WPA EAP-TTLS (MSCHAPv2)", @@ -7619,12 +6581,7 @@ test_write_wifi_wpa_eap_ttls_mschapv2(void) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, strlen(ssid_data)); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -7632,12 +6589,7 @@ test_write_wifi_wpa_eap_ttls_mschapv2(void) "infrastructure", NULL); - g_bytes_unref(ssid); - - /* Wireless security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wsec)); - + s_wsec = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap", NULL); nm_setting_wireless_security_add_proto(s_wsec, "wpa"); nm_setting_wireless_security_add_proto(s_wsec, "rsn"); @@ -7646,12 +6598,8 @@ test_write_wifi_wpa_eap_ttls_mschapv2(void) nm_setting_wireless_security_add_group(s_wsec, "tkip"); nm_setting_wireless_security_add_group(s_wsec, "ccmp"); - /* Wireless security setting */ - s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); - nm_connection_add_setting(connection, NM_SETTING(s_8021x)); - + s_8021x = _nm_connection_new_setting(connection, NM_TYPE_SETTING_802_1X); nm_setting_802_1x_add_eap_method(s_8021x, "ttls"); - g_object_set(s_8021x, NM_SETTING_802_1X_IDENTITY, "Bill Smith", @@ -7670,16 +6618,10 @@ test_write_wifi_wpa_eap_ttls_mschapv2(void) &error); nmtst_assert_success(success, error); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, @@ -7704,14 +6646,14 @@ test_write_wifi_wpa_then_open(void) nmtst_auto_unlinkfile char *testfile = NULL; gs_free char * keyfile = NULL; gs_unref_object NMConnection *connection = NULL; - gs_unref_object NMConnection *reread = NULL; + gs_unref_object NMConnection *reread1 = NULL; + gs_unref_object NMConnection *reread2 = NULL; NMSettingConnection * s_con; NMSettingWireless * s_wifi; NMSettingWirelessSecurity * s_wsec; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; - GBytes * ssid; - const char * ssid_data = "blahblah"; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); /* Test that writing out a WPA config then changing that to an open * config doesn't leave various WPA-related keys lying around in the ifcfg. @@ -7719,10 +6661,7 @@ test_write_wifi_wpa_then_open(void) connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "random wifi connection", @@ -7734,12 +6673,7 @@ test_write_wifi_wpa_then_open(void) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, strlen(ssid_data)); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -7747,12 +6681,7 @@ test_write_wifi_wpa_then_open(void) "infrastructure", NULL); - g_bytes_unref(ssid); - - /* Wireless security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wsec)); - + s_wsec = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", @@ -7768,30 +6697,26 @@ test_write_wifi_wpa_then_open(void) nm_setting_wireless_security_add_pairwise(s_wsec, "ccmp"); nm_setting_wireless_security_add_group(s_wsec, "ccmp"); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, + (int) NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, NULL); nmtst_assert_connection_verifies(connection); _writer_new_connection(connection, TEST_SCRATCH_DIR, &testfile); - reread = _connection_from_file(testfile, NULL, TYPE_WIRELESS, NULL); - - nmtst_assert_connection_equals(connection, TRUE, reread, FALSE); + reread1 = _connection_from_file(testfile, NULL, TYPE_WIRELESS, NULL); - g_object_unref(reread); + nmtst_assert_connection_equals(connection, TRUE, reread1, FALSE); nmtst_connection_normalize(connection); @@ -7806,9 +6731,9 @@ test_write_wifi_wpa_then_open(void) keyfile = utils_get_keys_path(testfile); g_assert(!g_file_test(keyfile, G_FILE_TEST_EXISTS)); - reread = _connection_from_file(testfile, NULL, TYPE_WIRELESS, NULL); + reread2 = _connection_from_file(testfile, NULL, TYPE_WIRELESS, NULL); - nmtst_assert_connection_equals(connection, TRUE, reread, FALSE); + nmtst_assert_connection_equals(connection, TRUE, reread2, FALSE); } static void @@ -7817,16 +6742,15 @@ test_write_wifi_wpa_then_wep_with_perms(void) nmtst_auto_unlinkfile char *testfile = NULL; nmtst_auto_unlinkfile char *keyfile = NULL; gs_unref_object NMConnection *connection = NULL; - gs_unref_object NMConnection *reread = NULL; + gs_unref_object NMConnection *reread1 = NULL; + gs_unref_object NMConnection *reread2 = NULL; NMSettingConnection * s_con; NMSettingWireless * s_wifi; NMSettingWirelessSecurity * s_wsec; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; gboolean success; - GBytes * ssid; - char ** perms; - const char * ssid_data = "SomeSSID"; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("SomeSSID"); /* Test that writing out a WPA config then changing that to a WEP * config works and doesn't cause infinite loop or other issues. @@ -7835,11 +6759,7 @@ test_write_wifi_wpa_then_wep_with_perms(void) connection = nm_simple_connection_new(); g_assert(connection); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - - perms = g_strsplit("user:superman:", ",", -1); + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "random wifi connection 2", @@ -7848,19 +6768,13 @@ test_write_wifi_wpa_then_wep_with_perms(void) NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NM_SETTING_CONNECTION_PERMISSIONS, - perms, + NM_MAKE_STRV("user:superman:"), NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME, NULL); - g_strfreev(perms); g_assert_cmpint(nm_setting_connection_get_num_permissions(s_con), ==, 1); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, strlen(ssid_data)); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -7868,12 +6782,7 @@ test_write_wifi_wpa_then_wep_with_perms(void) "infrastructure", NULL); - g_bytes_unref(ssid); - - /* Wireless security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wsec)); - + s_wsec = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", @@ -7889,38 +6798,31 @@ test_write_wifi_wpa_then_wep_with_perms(void) nm_setting_wireless_security_add_pairwise(s_wsec, "ccmp"); nm_setting_wireless_security_add_group(s_wsec, "ccmp"); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, + (int) NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, NULL); nmtst_assert_connection_verifies(connection); _writer_new_connection(connection, TEST_SCRATCH_DIR, &testfile); - reread = _connection_from_file(testfile, NULL, TYPE_WIRELESS, NULL); - - nmtst_assert_connection_equals(connection, TRUE, reread, FALSE); + reread1 = _connection_from_file(testfile, NULL, TYPE_WIRELESS, NULL); - g_object_unref(reread); + nmtst_assert_connection_equals(connection, TRUE, reread1, FALSE); nmtst_connection_normalize(connection); /* Now change the connection to WEP and recheck */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wsec)); + s_wsec = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", NULL); nm_setting_wireless_security_set_wep_key(s_wsec, 0, "abraka dabra"); @@ -7931,11 +6833,11 @@ test_write_wifi_wpa_then_wep_with_perms(void) testfile, TEST_IFCFG_DIR "/ifcfg-random_wifi_connection_2.cexpected"); - reread = _connection_from_file(testfile, NULL, TYPE_WIRELESS, NULL); + reread2 = _connection_from_file(testfile, NULL, TYPE_WIRELESS, NULL); nmtst_connection_normalize(connection); success = nm_connection_compare(connection, - reread, + reread2, NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS | NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS); g_assert(success); @@ -7956,15 +6858,12 @@ test_write_wifi_dynamic_wep_leap(void) NMSetting8021x * s_8021x; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; - GBytes * ssid; - const char * ssid_data = "blahblah"; - shvarFile * ifcfg; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("blahblah"); + shvarFile * ifcfg; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi Dynamic WEP LEAP", @@ -7974,12 +6873,7 @@ test_write_wifi_dynamic_wep_leap(void) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(ssid_data, strlen(ssid_data)); - + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, @@ -7987,20 +6881,11 @@ test_write_wifi_dynamic_wep_leap(void) "infrastructure", NULL); - g_bytes_unref(ssid); - - /* Wireless security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wsec)); - + s_wsec = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", NULL); - /* Wireless security setting */ - s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); - nm_connection_add_setting(connection, NM_SETTING(s_8021x)); - + s_8021x = _nm_connection_new_setting(connection, NM_TYPE_SETTING_802_1X); nm_setting_802_1x_add_eap_method(s_8021x, "leap"); - g_object_set(s_8021x, NM_SETTING_802_1X_IDENTITY, "Bill Smith", @@ -8008,15 +6893,10 @@ test_write_wifi_dynamic_wep_leap(void) ";alkdfja;dslkfjsad;lkfjsadf", NULL); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, @@ -8054,14 +6934,10 @@ test_write_wired_qeth_dhcp(void) NMSettingWired * s_wired; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; - char ** subchans; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired qeth Static", @@ -8073,34 +6949,23 @@ test_write_wired_qeth_dhcp(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - subchans = g_strsplit("0.0.600,0.0.601,0.0.602", ",", -1); + s_wired = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); g_object_set(s_wired, NM_SETTING_WIRED_S390_SUBCHANNELS, - subchans, + NM_MAKE_STRV("0.0.600", "0.0.601", "0.0.602"), NM_SETTING_WIRED_S390_NETTYPE, "qeth", NULL); - g_strfreev(subchans); nm_setting_wired_add_s390_option(s_wired, "portname", "FOOBAR"); nm_setting_wired_add_s390_option(s_wired, "portno", "1"); nm_setting_wired_add_s390_option(s_wired, "layer2", "0"); nm_setting_wired_add_s390_option(s_wired, "protocol", "blahbalh"); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, @@ -8127,15 +6992,11 @@ test_write_wired_ctc_dhcp(void) NMSettingWired * s_wired; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; - char ** subchans; shvarFile * ifcfg; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired ctc Static", @@ -8145,29 +7006,19 @@ test_write_wired_ctc_dhcp(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - subchans = g_strsplit("0.0.600,0.0.601", ",", -1); + s_wired = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); g_object_set(s_wired, NM_SETTING_WIRED_S390_SUBCHANNELS, - subchans, + NM_MAKE_STRV("0.0.600", "0.0.601"), NM_SETTING_WIRED_S390_NETTYPE, "ctc", NULL); - g_strfreev(subchans); nm_setting_wired_add_s390_option(s_wired, "ctcprot", "0"); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, @@ -8201,16 +7052,12 @@ test_write_permissions(void) gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; - NMSettingWired * s_wired; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Permissions", @@ -8226,20 +7073,12 @@ test_write_permissions(void) nm_setting_connection_add_permission(s_con, "user", "foobar", NULL); nm_setting_connection_add_permission(s_con, "user", "asdfasdf", NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, @@ -8270,16 +7109,12 @@ test_write_wifi_wep_agent_keys(void) NMSettingWirelessSecurity * s_wsec; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; - const char * str_ssid = "foobarbaz"; - GBytes * ssid; + gs_unref_bytes GBytes *ssid = nmtst_gbytes_from_str("foobarbaz"); connection = nm_simple_connection_new(); g_assert(connection != NULL); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wifi WEP Agent Owned", @@ -8289,39 +7124,28 @@ test_write_wifi_wep_agent_keys(void) NM_SETTING_WIRELESS_SETTING_NAME, NULL); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE, + NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, + (int) NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64, NULL); - /* Wifi setting */ - s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wifi)); - - ssid = g_bytes_new(str_ssid, strlen(str_ssid)); + s_wifi = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS); g_object_set(s_wifi, NM_SETTING_WIRELESS_SSID, ssid, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL); - g_bytes_unref(ssid); - - /* Wifi security setting */ - s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wsec)); + s_wsec = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRELESS_SECURITY); g_object_set(s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", @@ -8352,20 +7176,14 @@ test_write_wifi_wep_agent_keys(void) static void test_write_wired_pppoe(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - NMSettingPppoe * s_pppoe; - NMSettingPpp * s_ppp; - GError * error = NULL; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingIPConfig * s_ip4; + NMSettingPppoe * s_pppoe; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Wired PPPoE", @@ -8377,21 +7195,13 @@ test_write_wired_pppoe(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* PPPoE setting */ - s_pppoe = (NMSettingPppoe *) nm_setting_pppoe_new(); - nm_connection_add_setting(connection, NM_SETTING(s_pppoe)); - - g_object_set(G_OBJECT(s_pppoe), + s_pppoe = _nm_connection_new_setting(connection, NM_TYPE_SETTING_PPPOE); + g_object_set(s_pppoe, NM_SETTING_PPPOE_SERVICE, "stupid-service", NM_SETTING_PPPOE_USERNAME, @@ -8400,33 +7210,24 @@ test_write_wired_pppoe(void) "test1", NULL); - /* PPP setting */ - s_ppp = (NMSettingPpp *) nm_setting_ppp_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ppp)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_PPP); nmtst_assert_connection_verifies(connection); _writer_new_connection_fail(connection, TEST_SCRATCH_DIR, NULL); - - g_object_unref(connection); - g_clear_error(&error); } static void test_write_vpn(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingIPConfig * s_ip4; - NMSettingVpn * s_vpn; - GError * error = NULL; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingIPConfig * s_ip4; + NMSettingVpn * s_vpn; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write VPN", @@ -8438,10 +7239,7 @@ test_write_vpn(void) NM_SETTING_VPN_SETTING_NAME, NULL); - /* VPN setting */ - s_vpn = (NMSettingVpn *) nm_setting_vpn_new(); - nm_connection_add_setting(connection, NM_SETTING(s_vpn)); - + s_vpn = _nm_connection_new_setting(connection, NM_TYPE_SETTING_VPN); g_object_set(s_vpn, NM_SETTING_VPN_SERVICE_TYPE, "awesomevpn", @@ -8452,39 +7250,27 @@ test_write_vpn(void) nm_setting_vpn_add_data_item(s_vpn, "server", "vpn.somewhere.com"); nm_setting_vpn_add_secret(s_vpn, "password", "sup3rs3cr3t"); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); nmtst_assert_connection_verifies(connection); _writer_new_connection_fail(connection, TEST_SCRATCH_DIR, NULL); - - g_object_unref(connection); - g_clear_error(&error); } static void test_write_mobile_broadband(gconstpointer data) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingIPConfig * s_ip4; - NMSettingGsm * s_gsm; - NMSettingCdma * s_cdma; - NMSettingPpp * s_ppp; - NMSettingSerial * s_serial; - GError * error = NULL; - gboolean gsm = GPOINTER_TO_UINT(data); + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingIPConfig * s_ip4; + NMSettingCdma * s_cdma; + NMSettingSerial * s_serial; + gboolean gsm = GPOINTER_TO_UINT(data); connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, gsm ? "Test Write GSM" : "Test Write CDMA", @@ -8496,22 +7282,14 @@ test_write_mobile_broadband(gconstpointer data) gsm ? NM_SETTING_GSM_SETTING_NAME : NM_SETTING_CDMA_SETTING_NAME, NULL); - if (gsm) { - /* GSM setting */ - s_gsm = (NMSettingGsm *) nm_setting_gsm_new(); - nm_connection_add_setting(connection, NM_SETTING(s_gsm)); - } else { - /* CDMA setting */ - s_cdma = (NMSettingCdma *) nm_setting_cdma_new(); - nm_connection_add_setting(connection, NM_SETTING(s_cdma)); - + if (gsm) + _nm_connection_new_setting(connection, NM_TYPE_SETTING_GSM); + else { + s_cdma = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CDMA); g_object_set(s_cdma, NM_SETTING_CDMA_NUMBER, "#777", NULL); } - /* Serial setting */ - s_serial = (NMSettingSerial *) nm_setting_serial_new(); - nm_connection_add_setting(connection, NM_SETTING(s_serial)); - + s_serial = _nm_connection_new_setting(connection, NM_TYPE_SETTING_SERIAL); g_object_set(s_serial, NM_SETTING_SERIAL_BAUD, 115200, @@ -8523,42 +7301,31 @@ test_write_mobile_broadband(gconstpointer data) 1, NULL); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* PPP setting */ - s_ppp = (NMSettingPpp *) nm_setting_ppp_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ppp)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_PPP); nmtst_assert_connection_verifies(connection); _writer_new_connection_fail(connection, TEST_SCRATCH_DIR, NULL); - - g_object_unref(connection); - g_clear_error(&error); } static void test_read_bridge_main(void) { - NMConnection * connection; - NMSettingBridge *s_bridge; - NMSettingWired * s_wired; - const char * mac; - char expected_mac_address[ETH_ALEN] = {0x00, 0x16, 0x41, 0x11, 0x22, 0x33}; + gs_unref_object NMConnection *connection = NULL; + NMSettingBridge * s_bridge; + NMSettingWired * s_wired; + const char * mac; + char expected_mac_address[ETH_ALEN] = {0x00, 0x16, 0x41, 0x11, 0x22, 0x33}; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-bridge-main", NULL, TYPE_ETHERNET, NULL); g_assert_cmpstr(nm_connection_get_interface_name(connection), ==, "br0"); - /* ===== Bridging SETTING ===== */ - - s_bridge = nm_connection_get_setting_bridge(connection); - g_assert(s_bridge); + s_bridge = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_BRIDGE); g_assert_cmpuint(nm_setting_bridge_get_forward_delay(s_bridge), ==, 2); g_assert(nm_setting_bridge_get_stp(s_bridge)); g_assert_cmpuint(nm_setting_bridge_get_priority(s_bridge), ==, 32744); @@ -8570,14 +7337,10 @@ test_read_bridge_main(void) g_assert_cmpint(nm_setting_bridge_get_vlan_filtering(s_bridge), ==, TRUE); g_assert_cmpint(nm_setting_bridge_get_vlan_default_pvid(s_bridge), ==, 99); - /* MAC address */ - s_wired = nm_connection_get_setting_wired(connection); - g_assert(s_wired); - mac = nm_setting_wired_get_cloned_mac_address(s_wired); + s_wired = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_WIRED); + mac = nm_setting_wired_get_cloned_mac_address(s_wired); g_assert(mac); g_assert(nm_utils_hwaddr_matches(mac, -1, expected_mac_address, ETH_ALEN)); - - g_object_unref(connection); } static void @@ -8588,8 +7351,8 @@ test_write_bridge_main(void) gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; NMSettingBridge * s_bridge; - NMSettingIPConfig * s_ip4, *s_ip6; - NMSettingWired * s_wired; + NMSettingIPConfig * s_ip4; + NMSettingIPConfig * s_ip6; NMIPAddress * addr; static const char * mac = "31:33:33:37:be:cd"; GError * error = NULL; @@ -8599,10 +7362,7 @@ test_write_bridge_main(void) connection = nm_simple_connection_new(); g_assert(connection); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Bridge Main", @@ -8616,9 +7376,7 @@ test_write_bridge_main(void) NM_SETTING_BRIDGE_SETTING_NAME, NULL); - /* bridge setting */ - s_bridge = (NMSettingBridge *) nm_setting_bridge_new(); - nm_connection_add_setting(connection, NM_SETTING(s_bridge)); + s_bridge = _nm_connection_new_setting(connection, NM_TYPE_SETTING_BRIDGE); vlans = g_ptr_array_new_with_free_func((GDestroyNotify) nm_bridge_vlan_unref); vlan = nm_bridge_vlan_new(10, 16); @@ -8644,10 +7402,7 @@ test_write_bridge_main(void) vlans, NULL); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, @@ -8662,17 +7417,12 @@ test_write_bridge_main(void) nm_setting_ip_config_add_address(s_ip4, addr); nm_ip_address_unref(addr); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); - nm_connection_add_setting(connection, nm_setting_proxy_new()); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_PROXY); nmtst_assert_connection_verifies_without_normalization(connection); @@ -8686,29 +7436,25 @@ test_write_bridge_main(void) static void test_read_bridge_component(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingBridgePort *s_port; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingBridgePort * s_port; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-bridge-component", NULL, TYPE_ETHERNET, NULL); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_master(s_con), ==, "br0"); g_assert_cmpstr(nm_setting_connection_get_slave_type(s_con), ==, NM_SETTING_BRIDGE_SETTING_NAME); - s_port = nm_connection_get_setting_bridge_port(connection); - g_assert(s_port); + s_port = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_BRIDGE_PORT); g_assert(nm_setting_bridge_port_get_hairpin_mode(s_port)); g_assert_cmpuint(nm_setting_bridge_port_get_priority(s_port), ==, 28); g_assert_cmpuint(nm_setting_bridge_port_get_path_cost(s_port), ==, 100); - - g_object_unref(connection); } static void @@ -8728,10 +7474,7 @@ test_write_bridge_component(void) connection = nm_simple_connection_new(); g_assert(connection); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Bridge Component", @@ -8747,10 +7490,7 @@ test_write_bridge_component(void) NM_SETTING_BRIDGE_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - + s_wired = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); g_object_set(s_wired, NM_SETTING_WIRED_MAC_ADDRESS, mac, NM_SETTING_WIRED_MTU, mtu, NULL); /* Bridge port */ @@ -8765,8 +7505,7 @@ test_write_bridge_component(void) nm_bridge_vlan_set_pvid(vlan, TRUE); g_ptr_array_add(vlans, vlan); - s_port = nm_setting_bridge_port_new(); - nm_connection_add_setting(connection, s_port); + s_port = _nm_connection_new_setting(connection, NM_TYPE_SETTING_BRIDGE_PORT); g_object_set(s_port, NM_SETTING_BRIDGE_PORT_PRIORITY, 50, @@ -8791,8 +7530,8 @@ test_write_bridge_component(void) static void test_read_bridge_missing_stp(void) { - NMConnection * connection; - NMSettingBridge *s_bridge; + gs_unref_object NMConnection *connection = NULL; + NMSettingBridge * s_bridge; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-bridge-missing-stp", NULL, @@ -8801,13 +7540,8 @@ test_read_bridge_missing_stp(void) g_assert_cmpstr(nm_connection_get_interface_name(connection), ==, "br0"); - /* ===== Bridging SETTING ===== */ - - s_bridge = nm_connection_get_setting_bridge(connection); - g_assert(s_bridge); + s_bridge = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_BRIDGE); g_assert(nm_setting_bridge_get_stp(s_bridge) == FALSE); - - g_object_unref(connection); } #define TEST_IFCFG_VLAN_INTERFACE TEST_IFCFG_DIR "/ifcfg-test-vlan-interface" @@ -8815,16 +7549,16 @@ test_read_bridge_missing_stp(void) static void test_read_vlan_interface(void) { - NMConnection * connection; - NMSettingVlan *s_vlan; - guint32 from = 0, to = 0; + gs_unref_object NMConnection *connection = NULL; + NMSettingVlan * s_vlan; + guint32 from = 0; + guint32 to = 0; connection = _connection_from_file(TEST_IFCFG_VLAN_INTERFACE, NULL, TYPE_ETHERNET, NULL); g_assert_cmpstr(nm_connection_get_interface_name(connection), ==, "vlan43"); - s_vlan = nm_connection_get_setting_vlan(connection); - g_assert(s_vlan); + s_vlan = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_VLAN); g_assert_cmpstr(nm_setting_vlan_get_parent(s_vlan), ==, "eth9"); g_assert_cmpint(nm_setting_vlan_get_id(s_vlan), ==, 43); @@ -8857,8 +7591,6 @@ test_read_vlan_interface(void) g_assert(nm_setting_vlan_get_priority(s_vlan, NM_VLAN_EGRESS_MAP, 2, &from, &to)); g_assert_cmpint(from, ==, 14); g_assert_cmpint(to, ==, 7); - - g_object_unref(connection); } #define TEST_IFCFG_VLAN_ONLY_VLANID TEST_IFCFG_DIR "/ifcfg-test-vlan-only-vlanid" @@ -8866,21 +7598,18 @@ test_read_vlan_interface(void) static void test_read_vlan_only_vlan_id(void) { - NMConnection * connection; - NMSettingVlan *s_vlan; + gs_unref_object NMConnection *connection = NULL; + NMSettingVlan * s_vlan; connection = _connection_from_file(TEST_IFCFG_VLAN_ONLY_VLANID, NULL, TYPE_ETHERNET, NULL); g_assert(nm_connection_get_interface_name(connection) == NULL); - s_vlan = nm_connection_get_setting_vlan(connection); - g_assert(s_vlan); + s_vlan = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_VLAN); g_assert_cmpstr(nm_setting_vlan_get_parent(s_vlan), ==, "eth9"); g_assert_cmpint(nm_setting_vlan_get_id(s_vlan), ==, 43); g_assert_cmpint(nm_setting_vlan_get_flags(s_vlan), ==, NM_VLAN_FLAG_REORDER_HEADERS); - - g_object_unref(connection); } static void @@ -8898,8 +7627,7 @@ test_read_vlan_vlanid_use(void) g_assert_cmpstr(nm_connection_get_interface_name(connection), ==, "eth0.9"); - s_vlan = nm_connection_get_setting_vlan(connection); - g_assert(s_vlan); + s_vlan = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_VLAN); g_assert_cmpstr(nm_setting_vlan_get_parent(s_vlan), ==, "eth0"); g_assert_cmpint(nm_setting_vlan_get_id(s_vlan), ==, 10); @@ -8918,8 +7646,8 @@ test_read_vlan_vlanid_use(void) static void test_read_vlan_only_device(void) { - NMConnection * connection; - NMSettingVlan *s_vlan; + gs_unref_object NMConnection *connection = NULL; + NMSettingVlan * s_vlan; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-vlan-only-device", NULL, @@ -8928,40 +7656,34 @@ test_read_vlan_only_device(void) g_assert_cmpstr(nm_connection_get_interface_name(connection), ==, "eth0.9"); - s_vlan = nm_connection_get_setting_vlan(connection); - g_assert(s_vlan); + s_vlan = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_VLAN); g_assert_cmpstr(nm_setting_vlan_get_parent(s_vlan), ==, "eth0"); g_assert_cmpint(nm_setting_vlan_get_id(s_vlan), ==, 9); - - g_object_unref(connection); } static void test_read_vlan_physdev(void) { - NMConnection * connection; - NMSettingVlan *s_vlan; + gs_unref_object NMConnection *connection = NULL; + NMSettingVlan * s_vlan; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-vlan-physdev", NULL, TYPE_ETHERNET, NULL); g_assert_cmpstr(nm_connection_get_interface_name(connection), ==, "vlan0.3"); - s_vlan = nm_connection_get_setting_vlan(connection); - g_assert(s_vlan); + s_vlan = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_VLAN); g_assert_cmpstr(nm_setting_vlan_get_parent(s_vlan), ==, "eth0"); g_assert_cmpint(nm_setting_vlan_get_id(s_vlan), ==, 3); - - g_object_unref(connection); } static void test_read_vlan_reorder_hdr_1(void) { - NMConnection * connection; - NMSettingVlan *s_vlan; + gs_unref_object NMConnection *connection = NULL; + NMSettingVlan * s_vlan; NMTST_EXPECT_NM_WARN("*REORDER_HDR key is deprecated, use VLAN_FLAGS*"); connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-vlan-reorder-hdr-1", @@ -8972,22 +7694,19 @@ test_read_vlan_reorder_hdr_1(void) g_assert_cmpstr(nm_connection_get_interface_name(connection), ==, "vlan0.3"); - s_vlan = nm_connection_get_setting_vlan(connection); - g_assert(s_vlan); + s_vlan = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_VLAN); g_assert_cmpstr(nm_setting_vlan_get_parent(s_vlan), ==, "eth0"); g_assert_cmpint(nm_setting_vlan_get_id(s_vlan), ==, 3); /* Check that REORDER_HDR=0 is ignored */ g_assert_cmpint(nm_setting_vlan_get_flags(s_vlan), ==, NM_VLAN_FLAG_REORDER_HEADERS); - - g_object_unref(connection); } static void test_read_vlan_reorder_hdr_2(void) { - NMConnection * connection; - NMSettingVlan *s_vlan; + gs_unref_object NMConnection *connection = NULL; + NMSettingVlan * s_vlan; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-vlan-reorder-hdr-2", NULL, @@ -8996,61 +7715,52 @@ test_read_vlan_reorder_hdr_2(void) g_assert_cmpstr(nm_connection_get_interface_name(connection), ==, "vlan0.3"); - s_vlan = nm_connection_get_setting_vlan(connection); - g_assert(s_vlan); + s_vlan = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_VLAN); g_assert_cmpstr(nm_setting_vlan_get_parent(s_vlan), ==, "eth0"); g_assert_cmpint(nm_setting_vlan_get_id(s_vlan), ==, 3); /* Check that VLAN_FLAGS=NO_REORDER_HDR works */ g_assert_cmpint(nm_setting_vlan_get_flags(s_vlan), ==, NM_VLAN_FLAG_LOOSE_BINDING); - - g_object_unref(connection); } static void test_read_vlan_flags_1(void) { - NMConnection * connection; - NMSettingVlan *s_vlan; + gs_unref_object NMConnection *connection = NULL; + NMSettingVlan * s_vlan; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-vlan-flags-1", NULL, TYPE_ETHERNET, NULL); g_assert_cmpstr(nm_connection_get_interface_name(connection), ==, "super-vlan"); - s_vlan = nm_connection_get_setting_vlan(connection); - g_assert(s_vlan); + s_vlan = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_VLAN); g_assert_cmpstr(nm_setting_vlan_get_parent(s_vlan), ==, "eth9"); g_assert_cmpint(nm_setting_vlan_get_id(s_vlan), ==, 44); g_assert_cmpint(nm_setting_vlan_get_flags(s_vlan), ==, NM_VLAN_FLAG_LOOSE_BINDING | NM_VLAN_FLAG_REORDER_HEADERS); - - g_object_unref(connection); } static void test_read_vlan_flags_2(void) { - NMConnection * connection; - NMSettingVlan *s_vlan; + gs_unref_object NMConnection *connection = NULL; + NMSettingVlan * s_vlan; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-vlan-flags-2", NULL, TYPE_ETHERNET, NULL); g_assert_cmpstr(nm_connection_get_interface_name(connection), ==, "super-vlan"); - s_vlan = nm_connection_get_setting_vlan(connection); - g_assert(s_vlan); + s_vlan = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_VLAN); g_assert_cmpstr(nm_setting_vlan_get_parent(s_vlan), ==, "eth9"); g_assert_cmpint(nm_setting_vlan_get_id(s_vlan), ==, 44); g_assert_cmpint(nm_setting_vlan_get_flags(s_vlan), ==, NM_VLAN_FLAG_GVRP | NM_VLAN_FLAG_LOOSE_BINDING | NM_VLAN_FLAG_REORDER_HEADERS); - - g_object_unref(connection); } static void @@ -9108,14 +7818,10 @@ test_write_vlan_reorder_hdr(void) gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; NMSettingVlan * s_vlan; - NMSettingWired * s_wired; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write VLAN reorder_hdr", @@ -9127,14 +7833,9 @@ test_write_vlan_reorder_hdr(void) NM_SETTING_VLAN_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - /* VLAN setting */ - s_vlan = (NMSettingVlan *) nm_setting_vlan_new(); - nm_connection_add_setting(connection, NM_SETTING(s_vlan)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); + s_vlan = _nm_connection_new_setting(connection, NM_TYPE_SETTING_VLAN); g_object_set(s_vlan, NM_SETTING_VLAN_PARENT, "eth0", @@ -9161,16 +7862,12 @@ test_write_ethernet_missing_ipv6(void) gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; - NMSettingWired * s_wired; NMSettingIPConfig * s_ip4; connection = nm_simple_connection_new(); g_assert(connection); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Ethernet Without IPv6 Setting", @@ -9182,13 +7879,9 @@ test_write_ethernet_missing_ipv6(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, @@ -9227,31 +7920,26 @@ test_read_ibft_ignored(void) static void test_read_bond_main(void) { - NMConnection * connection; - NMSettingBond *s_bond; + gs_unref_object NMConnection *connection = NULL; + NMSettingBond * s_bond; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-bond-main", NULL, TYPE_ETHERNET, NULL); g_assert_cmpstr(nm_connection_get_interface_name(connection), ==, "bond0"); - /* ===== Bonding SETTING ===== */ - - s_bond = nm_connection_get_setting_bond(connection); - g_assert(s_bond); + s_bond = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_BOND); g_assert_cmpstr(nm_setting_bond_get_option_by_name(s_bond, NM_SETTING_BOND_OPTION_MIIMON), ==, "100"); - - g_object_unref(connection); } static void test_read_bond_eth_type(void) { - NMConnection * connection; - NMSettingBond *s_bond; + gs_unref_object NMConnection *connection = NULL; + NMSettingBond * s_bond; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-bond-eth-type", NULL, @@ -9260,10 +7948,7 @@ test_read_bond_eth_type(void) g_assert_cmpstr(nm_connection_get_interface_name(connection), ==, "bond0"); - /* ===== Bonding SETTING ===== */ - - s_bond = nm_connection_get_setting_bond(connection); - g_assert(s_bond); + s_bond = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_BOND); g_assert_cmpstr(nm_setting_bond_get_option_by_name(s_bond, NM_SETTING_BOND_OPTION_MIIMON), ==, @@ -9271,8 +7956,6 @@ test_read_bond_eth_type(void) g_assert_cmpstr(nm_setting_bond_get_option_by_name(s_bond, NM_SETTING_BOND_OPTION_LACP_RATE), ==, "1"); - - g_object_unref(connection); } static void @@ -9285,16 +7968,12 @@ test_write_bond_main(void) NMSettingBond * s_bond; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; - NMSettingWired * s_wired; NMIPAddress * addr; GError * error = NULL; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Bond Main", @@ -9308,22 +7987,14 @@ test_write_bond_main(void) NM_SETTING_BOND_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - /* bond setting */ - s_bond = (NMSettingBond *) nm_setting_bond_new(); - nm_connection_add_setting(connection, NM_SETTING(s_bond)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); + s_bond = _nm_connection_new_setting(connection, NM_TYPE_SETTING_BOND); nm_setting_bond_add_option(s_bond, NM_SETTING_BOND_OPTION_DOWNDELAY, "5"); nm_setting_bond_add_option(s_bond, NM_SETTING_BOND_OPTION_UPDELAY, "10"); nm_setting_bond_add_option(s_bond, NM_SETTING_BOND_OPTION_MIIMON, "100"); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, @@ -9338,13 +8009,10 @@ test_write_bond_main(void) nm_setting_ip_config_add_address(s_ip4, addr); nm_ip_address_unref(addr); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); - nm_connection_add_setting(connection, nm_setting_proxy_new()); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_PROXY); nmtst_assert_connection_verifies_without_normalization(connection); @@ -9361,21 +8029,18 @@ test_write_bond_main(void) static void test_read_bond_slave(void) { - NMConnection * connection; - NMSettingConnection *s_con; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-bond-slave", NULL, TYPE_ETHERNET, NULL); g_test_assert_expected_messages(); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_master(s_con), ==, "bond0"); g_assert_cmpstr(nm_setting_connection_get_slave_type(s_con), ==, NM_SETTING_BOND_SETTING_NAME); - - g_object_unref(connection); } static void @@ -9391,10 +8056,7 @@ test_write_bond_slave(void) connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Bond Slave", @@ -9410,10 +8072,7 @@ test_write_bond_slave(void) NM_SETTING_BOND_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - + s_wired = _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); g_object_set(s_wired, NM_SETTING_WIRED_MAC_ADDRESS, mac, NM_SETTING_WIRED_MTU, mtu, NULL); nmtst_assert_connection_verifies(connection); @@ -9425,13 +8084,72 @@ test_write_bond_slave(void) nmtst_assert_connection_equals(connection, TRUE, reread, FALSE); } +static void +test_read_bond_port(void) +{ + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con = NULL; + NMSettingBondPort * s_port = NULL; + + connection = + _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-bond-port", NULL, TYPE_ETHERNET, NULL); + + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); + g_assert_cmpstr(nm_setting_connection_get_master(s_con), ==, "bond99"); + g_assert_cmpstr(nm_setting_connection_get_slave_type(s_con), ==, NM_SETTING_BOND_SETTING_NAME); + + s_port = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_BOND_PORT); + g_assert_cmpuint(nm_setting_bond_port_get_queue_id(s_port), ==, 1); +} + +static void +test_write_bond_port(void) +{ + nmtst_auto_unlinkfile char *testfile = NULL; + gs_unref_object NMConnection *connection = NULL; + gs_unref_object NMConnection *reread = NULL; + NMSettingConnection * s_con; + NMSettingBondPort * s_bond_port; + + connection = nm_simple_connection_new(); + + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); + g_object_set(s_con, + NM_SETTING_CONNECTION_ID, + "Test Write Bond Port", + NM_SETTING_CONNECTION_UUID, + nm_uuid_generate_random_str_a(), + NM_SETTING_CONNECTION_AUTOCONNECT, + TRUE, + NM_SETTING_CONNECTION_TYPE, + NM_SETTING_WIRED_SETTING_NAME, + NM_SETTING_CONNECTION_MASTER, + "bond0", + NM_SETTING_CONNECTION_SLAVE_TYPE, + NM_SETTING_BOND_SETTING_NAME, + NULL); + + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); + + s_bond_port = _nm_connection_new_setting(connection, NM_TYPE_SETTING_BOND_PORT); + g_object_set(s_bond_port, NM_SETTING_BOND_PORT_QUEUE_ID, 1, NULL); + + nmtst_assert_connection_verifies(connection); + + _writer_new_connection(connection, TEST_SCRATCH_DIR, &testfile); + + reread = _connection_from_file(testfile, NULL, TYPE_ETHERNET, NULL); + + nmtst_assert_connection_equals(connection, TRUE, reread, FALSE); +} + static void test_read_infiniband(void) { - NMConnection * connection; - NMSettingInfiniband *s_infiniband; - char * unmanaged = NULL; - const char * mac; + gs_unref_object NMConnection *connection = NULL; + NMSettingInfiniband * s_infiniband; + char * unmanaged = NULL; + const char * mac; char expected_mac_address[INFINIBAND_ALEN] = {0x80, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11, 0x22}; @@ -9443,22 +8161,15 @@ test_read_infiniband(void) &unmanaged); g_assert(!unmanaged); - /* ===== INFINIBAND SETTING ===== */ + s_infiniband = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_INFINIBAND); - s_infiniband = nm_connection_get_setting_infiniband(connection); - g_assert(s_infiniband); - - /* MAC address */ mac = nm_setting_infiniband_get_mac_address(s_infiniband); g_assert(mac); g_assert(nm_utils_hwaddr_matches(mac, -1, expected_mac_address, sizeof(expected_mac_address))); - /* Transport mode */ transport_mode = nm_setting_infiniband_get_transport_mode(s_infiniband); g_assert(transport_mode); g_assert_cmpstr(transport_mode, ==, "connected"); - - g_object_unref(connection); } static void @@ -9478,10 +8189,7 @@ test_write_infiniband(void) connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write InfiniBand", @@ -9493,10 +8201,7 @@ test_write_infiniband(void) NM_SETTING_INFINIBAND_SETTING_NAME, NULL); - /* InfiniBand setting */ - s_infiniband = (NMSettingInfiniband *) nm_setting_infiniband_new(); - nm_connection_add_setting(connection, NM_SETTING(s_infiniband)); - + s_infiniband = _nm_connection_new_setting(connection, NM_TYPE_SETTING_INFINIBAND); g_object_set(s_infiniband, NM_SETTING_INFINIBAND_MAC_ADDRESS, mac, @@ -9506,10 +8211,7 @@ test_write_infiniband(void) "connected", NULL); - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); - + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, @@ -9524,10 +8226,7 @@ test_write_infiniband(void) nm_setting_ip_config_add_address(s_ip4, addr); nm_ip_address_unref(addr); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); nmtst_assert_connection_verifies(connection); @@ -9548,8 +8247,7 @@ test_read_bond_slave_ib(void) connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-bond-slave-ib", NULL, NULL, NULL); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_master(s_con), ==, "bond0"); g_assert_cmpstr(nm_setting_connection_get_slave_type(s_con), ==, NM_SETTING_BOND_SETTING_NAME); @@ -9567,10 +8265,7 @@ test_write_bond_slave_ib(void) connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Bond Slave InfiniBand", @@ -9586,10 +8281,7 @@ test_write_bond_slave_ib(void) NM_SETTING_BOND_SETTING_NAME, NULL); - /* InfiniBand setting */ - s_infiniband = (NMSettingInfiniband *) nm_setting_infiniband_new(); - nm_connection_add_setting(connection, NM_SETTING(s_infiniband)); - + s_infiniband = _nm_connection_new_setting(connection, NM_TYPE_SETTING_INFINIBAND); g_object_set(s_infiniband, NM_SETTING_INFINIBAND_MAC_ADDRESS, mac, @@ -9611,9 +8303,9 @@ test_write_bond_slave_ib(void) static void test_read_bond_opts_mode_numeric(void) { - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingBond * s_bond; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingBond * s_bond; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-bond-mode-numeric", NULL, @@ -9622,19 +8314,15 @@ test_read_bond_opts_mode_numeric(void) g_assert_cmpstr(nm_connection_get_interface_name(connection), ==, "bond0"); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_connection_type(s_con), ==, NM_SETTING_BOND_SETTING_NAME); - s_bond = nm_connection_get_setting_bond(connection); - g_assert(s_bond); + s_bond = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_BOND); g_assert_cmpstr(nm_setting_bond_get_option_by_name(s_bond, NM_SETTING_BOND_OPTION_MODE), ==, "802.3ad"); - - g_object_unref(connection); } #define DCB_ALL_FLAGS \ @@ -9643,20 +8331,19 @@ test_read_bond_opts_mode_numeric(void) static void test_read_dcb_basic(void) { - NMConnection *connection; - NMSettingDcb *s_dcb; - guint i; - guint expected_group_ids[8] = {0, 0, 0, 0, 1, 1, 1, 0xF}; - guint expected_group_bandwidths[8] = {25, 0, 0, 75, 0, 0, 0, 0}; - guint expected_bandwidths[8] = {5, 10, 30, 25, 10, 50, 5, 0}; - gboolean expected_strict[8] = {FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE}; - guint expected_traffic_classes[8] = {7, 6, 5, 4, 3, 2, 1, 0}; - gboolean expected_pfcs[8] = {TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE}; + gs_unref_object NMConnection *connection = NULL; + NMSettingDcb * s_dcb; + guint i; + guint expected_group_ids[8] = {0, 0, 0, 0, 1, 1, 1, 0xF}; + guint expected_group_bandwidths[8] = {25, 0, 0, 75, 0, 0, 0, 0}; + guint expected_bandwidths[8] = {5, 10, 30, 25, 10, 50, 5, 0}; + gboolean expected_strict[8] = {FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE}; + guint expected_traffic_classes[8] = {7, 6, 5, 4, 3, 2, 1, 0}; + gboolean expected_pfcs[8] = {TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE}; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-dcb", NULL, TYPE_ETHERNET, NULL); - s_dcb = nm_connection_get_setting_dcb(connection); - g_assert(s_dcb); + s_dcb = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_DCB); g_assert_cmpint(nm_setting_dcb_get_app_fcoe_flags(s_dcb), ==, DCB_ALL_FLAGS); g_assert_cmpint(nm_setting_dcb_get_app_fcoe_priority(s_dcb), ==, 7); @@ -9702,8 +8389,6 @@ test_read_dcb_basic(void) g_assert_cmpint(nm_setting_dcb_get_priority_traffic_class(s_dcb, i), ==, expected_traffic_classes[i]); - - g_object_unref(connection); } static void @@ -9713,7 +8398,6 @@ test_write_dcb_basic(void) gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; - NMSettingWired * s_wired; NMSettingDcb * s_dcb; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; @@ -9727,9 +8411,8 @@ test_write_dcb_basic(void) connection = nm_simple_connection_new(); - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - g_object_set(G_OBJECT(s_con), + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); + g_object_set(s_con, NM_SETTING_CONNECTION_ID, "dcb-test", NM_SETTING_CONNECTION_UUID, @@ -9740,30 +8423,16 @@ test_write_dcb_basic(void) "eth0", NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - /* IP stuff */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - g_object_set(G_OBJECT(s_ip4), - NM_SETTING_IP_CONFIG_METHOD, - NM_SETTING_IP4_CONFIG_METHOD_AUTO, - NULL); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - g_object_set(G_OBJECT(s_ip6), - NM_SETTING_IP_CONFIG_METHOD, - NM_SETTING_IP6_CONFIG_METHOD_AUTO, - NULL); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); + g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* DCB */ - s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); - nm_connection_add_setting(connection, NM_SETTING(s_dcb)); + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); + g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); - g_object_set(G_OBJECT(s_dcb), + s_dcb = _nm_connection_new_setting(connection, NM_TYPE_SETTING_DCB); + g_object_set(s_dcb, NM_SETTING_DCB_APP_FCOE_FLAGS, DCB_ALL_FLAGS, NM_SETTING_DCB_APP_FCOE_PRIORITY, @@ -9814,8 +8483,7 @@ test_read_dcb_default_app_priorities(void) TYPE_ETHERNET, NULL); - s_dcb = nm_connection_get_setting_dcb(connection); - g_assert(s_dcb); + s_dcb = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_DCB); g_assert_cmpint(nm_setting_dcb_get_app_fcoe_flags(s_dcb), ==, NM_SETTING_DCB_FLAG_ENABLE); g_assert_cmpint(nm_setting_dcb_get_app_fcoe_priority(s_dcb), ==, -1); @@ -9950,8 +8618,7 @@ test_read_fcoe_mode(gconstpointer user_data) file = g_strdup_printf(TEST_IFCFG_DIR "/ifcfg-test-fcoe-%s", expected_mode); connection = _connection_from_file(file, NULL, TYPE_ETHERNET, NULL); - s_dcb = nm_connection_get_setting_dcb(connection); - g_assert(s_dcb); + s_dcb = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_DCB); g_assert_cmpint(nm_setting_dcb_get_app_fcoe_flags(s_dcb), ==, NM_SETTING_DCB_FLAG_ENABLE); g_assert_cmpstr(nm_setting_dcb_get_app_fcoe_mode(s_dcb), ==, expected_mode); @@ -9965,7 +8632,6 @@ test_write_fcoe_mode(gconstpointer user_data) gs_unref_object NMConnection *reread = NULL; const char * expected_mode = user_data; NMSettingConnection * s_con; - NMSettingWired * s_wired; NMSettingDcb * s_dcb; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; @@ -9973,9 +8639,8 @@ test_write_fcoe_mode(gconstpointer user_data) connection = nm_simple_connection_new(); - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - g_object_set(G_OBJECT(s_con), + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); + g_object_set(s_con, NM_SETTING_CONNECTION_ID, "fcoe-test", NM_SETTING_CONNECTION_UUID, @@ -9986,30 +8651,16 @@ test_write_fcoe_mode(gconstpointer user_data) "eth0", NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - /* IP stuff */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - g_object_set(G_OBJECT(s_ip4), - NM_SETTING_IP_CONFIG_METHOD, - NM_SETTING_IP4_CONFIG_METHOD_AUTO, - NULL); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - g_object_set(G_OBJECT(s_ip6), - NM_SETTING_IP_CONFIG_METHOD, - NM_SETTING_IP6_CONFIG_METHOD_AUTO, - NULL); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); + g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* DCB */ - s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); - nm_connection_add_setting(connection, NM_SETTING(s_dcb)); + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); + g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); - g_object_set(G_OBJECT(s_dcb), + s_dcb = _nm_connection_new_setting(connection, NM_TYPE_SETTING_DCB); + g_object_set(s_dcb, NM_SETTING_DCB_APP_FCOE_FLAGS, NM_SETTING_DCB_FLAG_ENABLE, NM_SETTING_DCB_APP_FCOE_MODE, @@ -10032,28 +8683,24 @@ test_write_fcoe_mode(gconstpointer user_data) static void test_read_team_master(gconstpointer user_data) { - const char *const PATH_NAME = user_data; - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingTeam * s_team; - const char * expected_config = + const char *const PATH_NAME = user_data; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingTeam * s_team; + const char * expected_config = "{\"device\": \"team0\", \"link_watch\": {\"name\": \"ethtool\"}}"; connection = _connection_from_file(PATH_NAME, NULL, TYPE_ETHERNET, NULL); g_assert_cmpstr(nm_connection_get_interface_name(connection), ==, "team0"); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_connection_type(s_con), ==, NM_SETTING_TEAM_SETTING_NAME); - s_team = nm_connection_get_setting_team(connection); - g_assert(s_team); + s_team = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_TEAM); g_assert_cmpstr(nm_setting_team_get_config(s_team), ==, expected_config); - - g_object_unref(connection); } static void @@ -10080,7 +8727,6 @@ test_write_team_master(void) gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; NMSettingTeam * s_team; - NMSettingWired * s_wired; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; const char * expected_config = @@ -10089,10 +8735,7 @@ test_write_team_master(void) connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Team Master", @@ -10104,29 +8747,18 @@ test_write_team_master(void) NM_SETTING_TEAM_SETTING_NAME, NULL); - /* Team setting */ - s_team = (NMSettingTeam *) nm_setting_team_new(); - nm_connection_add_setting(connection, NM_SETTING(s_team)); - + s_team = _nm_connection_new_setting(connection, NM_TYPE_SETTING_TEAM); g_object_set(s_team, NM_SETTING_TEAM_CONFIG, expected_config, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); - nm_connection_add_setting(connection, nm_setting_proxy_new()); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_PROXY); nmtst_assert_connection_verifies_without_normalization(connection); @@ -10145,26 +8777,22 @@ test_write_team_master(void) static void test_read_team_port(gconstpointer user_data) { - const char *const PATH_NAME = user_data; - NMConnection * connection; - NMSettingConnection *s_con; - NMSettingTeamPort * s_team_port; - const char * expected_config = "{\"p4p1\": {\"prio\": -10, \"sticky\": true}}"; + const char *const PATH_NAME = user_data; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingTeamPort * s_team_port; + const char * expected_config = "{\"p4p1\": {\"prio\": -10, \"sticky\": true}}"; connection = _connection_from_file(PATH_NAME, NULL, TYPE_ETHERNET, NULL); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_connection_type(s_con), ==, NM_SETTING_WIRED_SETTING_NAME); g_assert_cmpstr(nm_setting_connection_get_master(s_con), ==, "team0"); - s_team_port = nm_connection_get_setting_team_port(connection); - g_assert(s_team_port); + s_team_port = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_TEAM_PORT); g_assert_cmpstr(nm_setting_team_port_get_config(s_team_port), ==, expected_config); - - g_object_unref(connection); } static void @@ -10175,16 +8803,12 @@ test_write_team_port(void) gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; NMSettingTeamPort * s_team_port; - NMSettingWired * s_wired; const char * expected_config = "{\"p4p1\": {\"prio\": -10, \"sticky\": true}}"; shvarFile * f; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Team Port", @@ -10198,14 +8822,10 @@ test_write_team_port(void) NM_SETTING_TEAM_SETTING_NAME, NULL); - /* Team setting */ - s_team_port = (NMSettingTeamPort *) nm_setting_team_port_new(); - nm_connection_add_setting(connection, NM_SETTING(s_team_port)); + s_team_port = _nm_connection_new_setting(connection, NM_TYPE_SETTING_TEAM_PORT); g_object_set(s_team_port, NM_SETTING_TEAM_PORT_CONFIG, expected_config, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); nmtst_assert_connection_verifies(connection); @@ -10234,16 +8854,13 @@ test_write_team_infiniband_port(void) gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; NMSettingTeamPort * s_team_port; - NMSettingInfiniband * s_inf; + NMSettingInfiniband * s_infiniband; const char * expected_config = "{\"inf1\": {\"prio\": -10, \"sticky\": true}}"; shvarFile * f; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Team Infiniband Port", @@ -10259,15 +8876,11 @@ test_write_team_infiniband_port(void) "inf1", NULL); - /* Team setting */ - s_team_port = (NMSettingTeamPort *) nm_setting_team_port_new(); - nm_connection_add_setting(connection, NM_SETTING(s_team_port)); + s_team_port = _nm_connection_new_setting(connection, NM_TYPE_SETTING_TEAM_PORT); g_object_set(s_team_port, NM_SETTING_TEAM_PORT_CONFIG, expected_config, NULL); - /* Infiniband setting */ - s_inf = (NMSettingInfiniband *) nm_setting_infiniband_new(); - nm_connection_add_setting(connection, NM_SETTING(s_inf)); - g_object_set(s_inf, NM_SETTING_INFINIBAND_TRANSPORT_MODE, "datagram", NULL); + s_infiniband = _nm_connection_new_setting(connection, NM_TYPE_SETTING_INFINIBAND); + g_object_set(s_infiniband, NM_SETTING_INFINIBAND_TRANSPORT_MODE, "datagram", NULL); nmtst_assert_connection_verifies(connection); @@ -10291,28 +8904,26 @@ test_write_team_infiniband_port(void) static void test_read_team_port_empty_config(void) { - NMConnection * connection; - NMSettingConnection *s_con; + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + NMSettingTeamPort * s_team_port; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-team-port-empty-config", NULL, TYPE_ETHERNET, NULL); - s_con = nm_connection_get_setting_connection(connection); - g_assert(s_con); + s_con = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_CONNECTION); g_assert_cmpstr(nm_setting_connection_get_connection_type(s_con), ==, NM_SETTING_WIRED_SETTING_NAME); g_assert_cmpstr(nm_setting_connection_get_master(s_con), ==, "team0"); /* Normalization adds a team-port setting */ - g_assert(nm_connection_get_setting_team_port(connection)); + s_team_port = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_TEAM_PORT); /* empty/missing config */ - g_assert(!nm_setting_team_port_get_config(nm_connection_get_setting_team_port(connection))); - - g_object_unref(connection); + g_assert(!nm_setting_team_port_get_config(s_team_port)); } static void @@ -10359,7 +8970,7 @@ test_team_reread_slave(void) NM_SETTING_CONNECTION_SLAVE_TYPE, "team", NULL); - g_object_set(nm_connection_get_setting_vlan(connection_2), + g_object_set(nmtst_connection_assert_setting(connection_2, NM_TYPE_SETTING_VLAN), NM_SETTING_VLAN_FLAGS, 1, NM_SETTING_VLAN_ID, @@ -10367,7 +8978,9 @@ test_team_reread_slave(void) NM_SETTING_VLAN_PARENT, "enp31s0f1", NULL); - nm_connection_add_setting(connection_2, nm_setting_team_port_new()); + + _nm_connection_new_setting(connection_2, NM_TYPE_SETTING_TEAM_PORT); + nmtst_connection_normalize(connection_2); nmtst_assert_connection_equals(connection_1, FALSE, connection_2, FALSE); @@ -10392,8 +9005,8 @@ test_team_reread_slave(void) static void test_read_proxy_basic(void) { - NMConnection * connection; - NMSettingProxy *s_proxy; + gs_unref_object NMConnection *connection = NULL; + NMSettingProxy * s_proxy; /* Test basic proxy configuration */ @@ -10402,18 +9015,13 @@ test_read_proxy_basic(void) TYPE_ETHERNET, NULL); - /* ===== Proxy setting ===== */ - s_proxy = nm_connection_get_setting_proxy(connection); - g_assert(s_proxy); + s_proxy = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_PROXY); - /* Proxy method */ g_assert_cmpint(nm_setting_proxy_get_method(s_proxy), ==, NM_SETTING_PROXY_METHOD_AUTO); g_assert(nm_setting_proxy_get_browser_only(s_proxy)); g_assert_cmpstr(nm_setting_proxy_get_pac_url(s_proxy), ==, "http://wpad.mycompany.com/wpad.dat"); - - g_object_unref(connection); } static void @@ -10423,17 +9031,13 @@ test_write_proxy_basic(void) gs_unref_object NMConnection *connection = NULL; gs_unref_object NMConnection *reread = NULL; NMSettingConnection * s_con; - NMSettingWired * s_wired; NMSettingProxy * s_proxy; const char * expected_url = "https://wpad.neverland.org/wpad.dat"; shvarFile * f; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write Proxy Basic", @@ -10443,15 +9047,11 @@ test_write_proxy_basic(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Proxy setting */ - s_proxy = (NMSettingProxy *) nm_setting_proxy_new(); - nm_connection_add_setting(connection, NM_SETTING(s_proxy)); + s_proxy = _nm_connection_new_setting(connection, NM_TYPE_SETTING_PROXY); g_object_set(s_proxy, NM_SETTING_PROXY_METHOD, NM_SETTING_PROXY_METHOD_AUTO, NULL); g_object_set(s_proxy, NM_SETTING_PROXY_PAC_URL, expected_url, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); nmtst_assert_connection_verifies(connection); @@ -10919,12 +9519,12 @@ test_write_unknown(gconstpointer test_data) static void test_read_vlan_trailing_spaces(void) { - const char * testfile = TEST_IFCFG_DIR "/ifcfg-test-vlan-trailing-spaces"; - NMConnection * connection; - gboolean success; - GError * error = NULL; - NMSettingVlan *s_vlan; - char * contents = NULL; + const char * testfile = TEST_IFCFG_DIR "/ifcfg-test-vlan-trailing-spaces"; + gs_unref_object NMConnection *connection = NULL; + gboolean success; + GError * error = NULL; + NMSettingVlan * s_vlan; + gs_free char * contents = NULL; /* Ensure there is whitespace at the end of the VLAN interface name, * to prevent the whitespace getting stripped off and committed mistakenly @@ -10935,19 +9535,15 @@ test_read_vlan_trailing_spaces(void) g_assert(success); g_assert(contents && contents[0]); g_assert(strstr(contents, "DEVICE=\"vlan201\" \n")); - g_free(contents); connection = _connection_from_file(testfile, NULL, TYPE_ETHERNET, NULL); - s_vlan = nm_connection_get_setting_vlan(connection); - g_assert(s_vlan); + s_vlan = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_VLAN); g_assert_cmpstr(nm_connection_get_interface_name(connection), ==, "vlan201"); g_assert_cmpstr(nm_setting_vlan_get_parent(s_vlan), ==, "enccw0.0.fb00"); g_assert_cmpint(nm_setting_vlan_get_id(s_vlan), ==, 201); g_assert_cmpint(nm_setting_vlan_get_flags(s_vlan), ==, NM_VLAN_FLAG_REORDER_HEADERS); - - g_object_unref(connection); } /*****************************************************************************/ @@ -10998,31 +9594,28 @@ test_utils_name(void) static void do_test_utils_path_ifcfg(const char *desc, const char *path, const char *expected) { - char *result; + gs_free char *result = NULL; result = utils_get_ifcfg_path(path); g_assert_cmpstr(result, ==, expected); - g_free(result); } static void do_test_utils_path_keys(const char *desc, const char *path, const char *expected) { - char *result; + gs_free char *result = NULL; result = utils_get_keys_path(path); g_assert_cmpstr(result, ==, expected); - g_free(result); } static void do_test_utils_path_route(const char *desc, const char *path, const char *expected) { - char *result; + gs_free char *result = NULL; result = utils_get_route_path(path); g_assert_cmpstr(result, ==, expected); - g_free(result); } static void @@ -11092,15 +9685,15 @@ test_sriov_read(void) NMSriovVF * vf; GVariant * variant; GError * error = NULL; - char * str; + gs_free char * str1 = NULL; + gs_free char * str2 = NULL; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-sriov", NULL, TYPE_ETHERNET, NULL); g_assert_cmpstr(nm_connection_get_interface_name(connection), ==, "eth0"); - s_sriov = NM_SETTING_SRIOV(nm_connection_get_setting(connection, NM_TYPE_SETTING_SRIOV)); - g_assert(s_sriov); + s_sriov = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_SRIOV); g_assert_cmpint(nm_setting_sriov_get_total_vfs(s_sriov), ==, 16); g_assert_cmpint(nm_setting_sriov_get_num_vfs(s_sriov), ==, 3); @@ -11122,18 +9715,16 @@ test_sriov_read(void) g_assert_cmpint(g_variant_get_boolean(variant), ==, TRUE); /* VF 12 */ - vf = nm_setting_sriov_get_vf(s_sriov, 1); - str = nm_utils_sriov_vf_to_str(vf, FALSE, &error); + vf = nm_setting_sriov_get_vf(s_sriov, 1); + str1 = nm_utils_sriov_vf_to_str(vf, FALSE, &error); g_assert_no_error(error); - g_assert_cmpstr(str, ==, "12 min-tx-rate=100 trust=false vlans=1.200.ad"); - g_free(str); + g_assert_cmpstr(str1, ==, "12 min-tx-rate=100 trust=false vlans=1.200.ad"); /* VF 15 */ - vf = nm_setting_sriov_get_vf(s_sriov, 2); - str = nm_utils_sriov_vf_to_str(vf, FALSE, &error); + vf = nm_setting_sriov_get_vf(s_sriov, 2); + str2 = nm_utils_sriov_vf_to_str(vf, FALSE, &error); g_assert_no_error(error); - g_assert_cmpstr(str, ==, "15 mac=01:23:45:67:89:ab max-tx-rate=200 vlans=2"); - g_free(str); + g_assert_cmpstr(str2, ==, "15 mac=01:23:45:67:89:ab max-tx-rate=200 vlans=2"); } static void @@ -11145,7 +9736,6 @@ test_sriov_write(void) NMSettingConnection * s_con; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; - NMSettingWired * s_wired; NMSettingSriov * s_sriov; NMSriovVF * vf; gs_unref_ptrarray GPtrArray *vfs = NULL; @@ -11154,10 +9744,7 @@ test_sriov_write(void) connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write SR-IOV config", @@ -11171,14 +9758,9 @@ test_sriov_write(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, @@ -11193,15 +9775,10 @@ test_sriov_write(void) nm_setting_ip_config_add_address(s_ip4, addr); nm_ip_address_unref(addr); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); - /* SRIOV setting */ - s_sriov = (NMSettingSriov *) nm_setting_sriov_new(); - nm_connection_add_setting(connection, NM_SETTING(s_sriov)); + s_sriov = _nm_connection_new_setting(connection, NM_TYPE_SETTING_SRIOV); vfs = g_ptr_array_new_with_free_func((GDestroyNotify) nm_sriov_vf_unref); @@ -11222,7 +9799,7 @@ test_sriov_write(void) NM_TERNARY_TRUE, NULL); - nm_connection_add_setting(connection, nm_setting_proxy_new()); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_PROXY); nmtst_assert_connection_verifies_without_normalization(connection); @@ -11241,18 +9818,17 @@ test_sriov_write(void) static void test_tc_read(void) { - NMConnection * connection; - NMSettingTCConfig *s_tc; - NMTCQdisc * qdisc; - NMTCTfilter * filter; - char * str; + gs_unref_object NMConnection *connection = NULL; + NMSettingTCConfig * s_tc; + NMTCQdisc * qdisc; + NMTCTfilter * filter; + gs_free char * str = NULL; connection = _connection_from_file(TEST_IFCFG_DIR "/ifcfg-test-tc", NULL, TYPE_ETHERNET, NULL); g_assert_cmpstr(nm_connection_get_interface_name(connection), ==, "eth0"); - s_tc = nm_connection_get_setting_tc_config(connection); - g_assert(s_tc); + s_tc = nmtst_connection_assert_setting(connection, NM_TYPE_SETTING_TC_CONFIG); g_assert_cmpint(nm_setting_tc_config_get_num_qdiscs(s_tc), ==, 1); qdisc = nm_setting_tc_config_get_qdisc(s_tc, 0); @@ -11266,9 +9842,6 @@ test_tc_read(void) g_assert(filter); str = nm_utils_tc_tfilter_to_str(filter, NULL); g_assert_cmpstr(str, ==, "parent 1234: matchall action simple sdata Hello"); - g_free(str); - - g_object_unref(connection); } static void @@ -11280,17 +9853,12 @@ test_tc_write_empty(void) NMSettingConnection * s_con; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; - NMSettingWired * s_wired; - NMSettingTCConfig * s_tc; NMIPAddress * addr; GError * error = NULL; connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write TC config", @@ -11304,14 +9872,9 @@ test_tc_write_empty(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, @@ -11326,17 +9889,12 @@ test_tc_write_empty(void) nm_setting_ip_config_add_address(s_ip4, addr); nm_ip_address_unref(addr); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); - /* TC setting */ - s_tc = (NMSettingTCConfig *) nm_setting_tc_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_tc)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_TC_CONFIG); - nm_connection_add_setting(connection, nm_setting_proxy_new()); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_PROXY); nmtst_assert_connection_verifies_without_normalization(connection); @@ -11359,7 +9917,6 @@ test_tc_write(void) NMSettingConnection * s_con; NMSettingIPConfig * s_ip4; NMSettingIPConfig * s_ip6; - NMSettingWired * s_wired; NMSettingTCConfig * s_tc; NMTCQdisc * qdisc; NMTCTfilter * tfilter; @@ -11368,10 +9925,7 @@ test_tc_write(void) connection = nm_simple_connection_new(); - /* Connection setting */ - s_con = (NMSettingConnection *) nm_setting_connection_new(); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - + s_con = _nm_connection_new_setting(connection, NM_TYPE_SETTING_CONNECTION); g_object_set(s_con, NM_SETTING_CONNECTION_ID, "Test Write TC config", @@ -11385,14 +9939,9 @@ test_tc_write(void) NM_SETTING_WIRED_SETTING_NAME, NULL); - /* Wired setting */ - s_wired = (NMSettingWired *) nm_setting_wired_new(); - nm_connection_add_setting(connection, NM_SETTING(s_wired)); - - /* IP4 setting */ - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip4)); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_WIRED); + s_ip4 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP4_CONFIG); g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, @@ -11407,15 +9956,10 @@ test_tc_write(void) nm_setting_ip_config_add_address(s_ip4, addr); nm_ip_address_unref(addr); - /* IP6 setting */ - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_ip6)); - + s_ip6 = _nm_connection_new_setting(connection, NM_TYPE_SETTING_IP6_CONFIG); g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NULL); - /* TC setting */ - s_tc = (NMSettingTCConfig *) nm_setting_tc_config_new(); - nm_connection_add_setting(connection, NM_SETTING(s_tc)); + s_tc = _nm_connection_new_setting(connection, NM_TYPE_SETTING_TC_CONFIG); qdisc = nm_tc_qdisc_new("pfifo_fast", TC_H_MAKE(0x2468 << 16, 0x2), &error); g_assert_no_error(error); @@ -11428,7 +9972,7 @@ test_tc_write(void) nm_setting_tc_config_add_tfilter(s_tc, tfilter); nm_tc_tfilter_unref(tfilter); - nm_connection_add_setting(connection, nm_setting_proxy_new()); + _nm_connection_new_setting(connection, NM_TYPE_SETTING_PROXY); nmtst_assert_connection_verifies_without_normalization(connection); @@ -12040,6 +10584,8 @@ main(int argc, char **argv) g_test_add_func(TPATH "bond/write-slave", test_write_bond_slave); g_test_add_func(TPATH "bond/write-slave-ib", test_write_bond_slave_ib); g_test_add_func(TPATH "bond/bonding-opts-numeric-mode", test_read_bond_opts_mode_numeric); + g_test_add_func(TPATH "bond/read-bond-port", test_read_bond_port); + g_test_add_func(TPATH "bond/write-bond-port", test_write_bond_port); g_test_add_func(TPATH "bridge/read-master", test_read_bridge_main); g_test_add_func(TPATH "bridge/write-master", test_write_bridge_main); diff --git a/src/core/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c b/src/core/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c index a8a9c40a..84986877 100644 --- a/src/core/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c +++ b/src/core/settings/plugins/ifupdown/nms-ifupdown-interface-parser.c @@ -112,7 +112,7 @@ _recursive_ifparser(if_parser *parser, const char *eni_file, int quiet) /* Check if interfaces file exists and open it */ if (!g_file_test(eni_file, G_FILE_TEST_EXISTS)) { if (!quiet) - _LOGW("interfaces file %s doesn't exist", eni_file); + _LOGI("interfaces file %s doesn't exist", eni_file); return; } inp = fopen(eni_file, "re"); diff --git a/src/core/settings/plugins/ifupdown/nms-ifupdown-parser.c b/src/core/settings/plugins/ifupdown/nms-ifupdown-parser.c index db6b1aef..5bad2362 100644 --- a/src/core/settings/plugins/ifupdown/nms-ifupdown-parser.c +++ b/src/core/settings/plugins/ifupdown/nms-ifupdown-parser.c @@ -397,7 +397,7 @@ ifupdown_ip4_add_dns(NMSettingIPConfig *s_ip4, const char *dns) if (dns == NULL) return; - list = nm_utils_strsplit_set(dns, " \t"); + list = nm_strsplit_set(dns, " \t"); for (iter = list; iter && *iter; iter++) { if (!inet_pton(AF_INET, *iter, &addr)) { _LOGW(" ignoring invalid nameserver '%s'", *iter); @@ -497,7 +497,7 @@ update_ip4_setting_from_if_block(NMConnection *connection, if_block *block, GErr gs_free const char **list = NULL; const char ** iter; - list = nm_utils_strsplit_set(search_v, " \t"); + list = nm_strsplit_set(search_v, " \t"); for (iter = list; iter && *iter; iter++) { if (!nm_setting_ip_config_add_dns_search(s_ip4, *iter)) _LOGW(" duplicate DNS domain '%s'", *iter); @@ -521,7 +521,7 @@ ifupdown_ip6_add_dns(NMSettingIPConfig *s_ip6, const char *dns) if (dns == NULL) return; - list = nm_utils_strsplit_set(dns, " \t"); + list = nm_strsplit_set(dns, " \t"); for (iter = list; iter && *iter; iter++) { if (!inet_pton(AF_INET6, *iter, &addr)) { _LOGW(" ignoring invalid nameserver '%s'", *iter); @@ -605,7 +605,7 @@ update_ip6_setting_from_if_block(NMConnection *connection, if_block *block, GErr gs_free const char **list = NULL; const char ** iter; - list = nm_utils_strsplit_set(search_v, " \t"); + list = nm_strsplit_set(search_v, " \t"); for (iter = list; iter && *iter; iter++) { if (!nm_setting_ip_config_add_dns_search(s_ip6, *iter)) _LOGW(" duplicate DNS domain '%s'", *iter); diff --git a/src/core/settings/plugins/ifupdown/nms-ifupdown-plugin.c b/src/core/settings/plugins/ifupdown/nms-ifupdown-plugin.c index 80a5638a..602a7327 100644 --- a/src/core/settings/plugins/ifupdown/nms-ifupdown-plugin.c +++ b/src/core/settings/plugins/ifupdown/nms-ifupdown-plugin.c @@ -189,7 +189,7 @@ _unmanaged_specs(GHashTable *eni_ifaces) GSList * specs = NULL; guint i, len; - keys = nm_utils_strdict_get_keys(eni_ifaces, TRUE, &len); + keys = nm_strdict_get_keys(eni_ifaces, TRUE, &len); for (i = len; i > 0;) { i--; specs = g_slist_prepend(specs, @@ -264,7 +264,7 @@ load_eni_ifaces(NMSIfupdownPlugin *self) _LOGD("parse: found bridge ports %s for %s", ports, block->name); - port_ifaces = nm_utils_strsplit_set(ports, " \t"); + port_ifaces = nm_strsplit_set(ports, " \t"); for (i = 0; port_ifaces && port_ifaces[i]; i++) { const char *token = port_ifaces[i]; @@ -323,7 +323,7 @@ load_eni_ifaces(NMSIfupdownPlugin *self) NM_PRINT_FMT_QUOTED(local, " (", local->message, ")", "")); sd = NULL; } else { - nmtst_connection_assert_unchanging(connection); + nm_assert_connection_unchanging(connection); uuid = nm_connection_get_uuid(connection); if (!storage) diff --git a/src/core/settings/plugins/keyfile/nms-keyfile-plugin.c b/src/core/settings/plugins/keyfile/nms-keyfile-plugin.c index e8ae1814..aa36ee8f 100644 --- a/src/core/settings/plugins/keyfile/nms-keyfile-plugin.c +++ b/src/core/settings/plugins/keyfile/nms-keyfile-plugin.c @@ -101,27 +101,27 @@ _extra_flags_to_string(char * str, const char *str0 = str; if (!is_nm_generated && !is_volatile && !is_external) - nm_utils_strbuf_append_str(&str, &str_len, ""); + nm_strbuf_append_str(&str, &str_len, ""); else { char ch = '('; - nm_utils_strbuf_append_c(&str, &str_len, ' '); + nm_strbuf_append_c(&str, &str_len, ' '); if (is_nm_generated) { - nm_utils_strbuf_append_c(&str, &str_len, ch); - nm_utils_strbuf_append_str(&str, &str_len, "nm-generated"); + nm_strbuf_append_c(&str, &str_len, ch); + nm_strbuf_append_str(&str, &str_len, "nm-generated"); ch = ','; } if (is_volatile) { - nm_utils_strbuf_append_c(&str, &str_len, ch); - nm_utils_strbuf_append_str(&str, &str_len, "volatile"); + nm_strbuf_append_c(&str, &str_len, ch); + nm_strbuf_append_str(&str, &str_len, "volatile"); ch = ','; } if (is_external) { - nm_utils_strbuf_append_c(&str, &str_len, ch); - nm_utils_strbuf_append_str(&str, &str_len, "external"); + nm_strbuf_append_c(&str, &str_len, ch); + nm_strbuf_append_str(&str, &str_len, "external"); ch = ','; } - nm_utils_strbuf_append_c(&str, &str_len, ')'); + nm_strbuf_append_c(&str, &str_len, ')'); } return str0; diff --git a/src/core/settings/plugins/keyfile/nms-keyfile-storage.c b/src/core/settings/plugins/keyfile/nms-keyfile-storage.c index 8c526c81..ec0634c4 100644 --- a/src/core/settings/plugins/keyfile/nms-keyfile-storage.c +++ b/src/core/settings/plugins/keyfile/nms-keyfile-storage.c @@ -168,7 +168,7 @@ nms_keyfile_storage_new_connection(NMSKeyfilePlugin * plugin, nm_assert(filename && filename[0] == '/'); nm_assert(storage_type >= NMS_KEYFILE_STORAGE_TYPE_RUN && storage_type <= _NMS_KEYFILE_STORAGE_TYPE_LIB_LAST); - nmtst_connection_assert_unchanging(connection_take); + nm_assert_connection_unchanging(connection_take); self = _storage_new(plugin, nm_connection_get_uuid(connection_take), diff --git a/src/core/settings/plugins/keyfile/tests/test-keyfile-settings.c b/src/core/settings/plugins/keyfile/tests/test-keyfile-settings.c index a13c2586..4ceed49d 100644 --- a/src/core/settings/plugins/keyfile/tests/test-keyfile-settings.c +++ b/src/core/settings/plugins/keyfile/tests/test-keyfile-settings.c @@ -992,7 +992,7 @@ test_read_intlike_ssid(void) ssid = nm_setting_wireless_get_ssid(s_wifi); g_assert(ssid); - g_assert(nm_utils_gbytes_equal_mem(ssid, expected_ssid, strlen(expected_ssid))); + g_assert(nm_g_bytes_equal_mem(ssid, expected_ssid, strlen(expected_ssid))); } static void @@ -1010,7 +1010,7 @@ test_read_intlike_ssid_2(void) ssid = nm_setting_wireless_get_ssid(s_wifi); g_assert(ssid); - g_assert(nm_utils_gbytes_equal_mem(ssid, expected_ssid, strlen(expected_ssid))); + g_assert(nm_g_bytes_equal_mem(ssid, expected_ssid, strlen(expected_ssid))); } static void @@ -1774,7 +1774,7 @@ test_write_wired_8021x_tls_connection_blob(void) password_raw = nm_setting_802_1x_get_password_raw(s_8021x); g_assert(password_raw); - g_assert(nm_utils_gbytes_equal_mem(password_raw, PASSWORD_RAW, NM_STRLEN(PASSWORD_RAW))); + g_assert(nm_g_bytes_equal_mem(password_raw, PASSWORD_RAW, NM_STRLEN(PASSWORD_RAW))); unlink(testfile); @@ -2160,7 +2160,7 @@ test_read_new_wireless_group_names(void) ssid = nm_setting_wireless_get_ssid(s_wifi); g_assert(ssid); - g_assert(nm_utils_gbytes_equal_mem(ssid, expected_ssid, strlen(expected_ssid))); + g_assert(nm_g_bytes_equal_mem(ssid, expected_ssid, strlen(expected_ssid))); g_assert_cmpstr(nm_setting_wireless_get_mode(s_wifi), ==, NM_SETTING_WIRELESS_MODE_INFRA); diff --git a/src/core/supplicant/nm-supplicant-config.c b/src/core/supplicant/nm-supplicant-config.c index 1959a161..c486ba1d 100644 --- a/src/core/supplicant/nm-supplicant-config.c +++ b/src/core/supplicant/nm-supplicant-config.c @@ -417,7 +417,7 @@ nm_supplicant_config_add_setting_macsec(NMSupplicantConfig *self, port = nm_setting_macsec_get_port(setting); if (port > 0 && port < 65534) { - snprintf(buf, sizeof(buf), "%d", port); + g_snprintf(buf, sizeof(buf), "%d", port); if (!nm_supplicant_config_add_option(self, "macsec_port", buf, -1, NULL, error)) return FALSE; } diff --git a/src/core/supplicant/nm-supplicant-interface.c b/src/core/supplicant/nm-supplicant-interface.c index 1556e290..2d56b836 100644 --- a/src/core/supplicant/nm-supplicant-interface.c +++ b/src/core/supplicant/nm-supplicant-interface.c @@ -115,6 +115,9 @@ typedef struct _NMSupplicantInterfacePrivate { CList peer_lst_head; CList peer_initializing_lst_head; + in_addr_t p2p_assigned_addr; + guint8 p2p_assigned_plen; + gint64 last_scan_msec; NMSupplicantAuthState auth_state; @@ -693,7 +696,7 @@ _bss_info_properties_changed(NMSupplicantInterface *self, } else arr_len = 0; - if (!nm_utils_gbytes_equal_mem(bss_info->ssid, arr_data, arr_len)) { + if (!nm_g_bytes_equal_mem(bss_info->ssid, arr_data, arr_len)) { _nm_unused gs_unref_bytes GBytes *old_free = g_steal_pointer(&bss_info->ssid); bss_info->ssid = (arr_len == 0) ? NULL : g_bytes_new(arr_data, arr_len); @@ -915,23 +918,23 @@ _peer_info_properties_changed(NMSupplicantInterface *self, peer_info->signal_percent = nm_wifi_utils_level_to_quality(v_i32); if (nm_g_variant_lookup(properties, "DeviceName", "&s", &v_s)) - nm_utils_strdup_reset(&peer_info->device_name, v_s); + nm_strdup_reset(&peer_info->device_name, v_s); if (nm_g_variant_lookup(properties, "Manufacturer", "&s", &v_s)) - nm_utils_strdup_reset(&peer_info->manufacturer, v_s); + nm_strdup_reset(&peer_info->manufacturer, v_s); if (nm_g_variant_lookup(properties, "Model", "&s", &v_s)) - nm_utils_strdup_reset(&peer_info->model, v_s); + nm_strdup_reset(&peer_info->model, v_s); if (nm_g_variant_lookup(properties, "ModelNumber", "&s", &v_s)) - nm_utils_strdup_reset(&peer_info->model_number, v_s); + nm_strdup_reset(&peer_info->model_number, v_s); if (nm_g_variant_lookup(properties, "Serial", "&s", &v_s)) - nm_utils_strdup_reset(&peer_info->serial, v_s); + nm_strdup_reset(&peer_info->serial, v_s); if (nm_g_variant_lookup(properties, "Groups", "^a&o", &v_strv)) { g_free(peer_info->groups); - peer_info->groups = nm_utils_strv_dup_packed(v_strv, -1); + peer_info->groups = nm_strv_dup_packed(v_strv, -1); g_free(v_strv); } @@ -967,7 +970,7 @@ _peer_info_properties_changed(NMSupplicantInterface *self, v_v = nm_g_variant_lookup_value(properties, "IEs", G_VARIANT_TYPE_BYTESTRING); if (v_v) { arr_data = g_variant_get_fixed_array(v_v, &arr_len, 1); - if (!nm_utils_gbytes_equal_mem(peer_info->ies, arr_data, arr_len)) { + if (!nm_g_bytes_equal_mem(peer_info->ies, arr_data, arr_len)) { _nm_unused gs_unref_bytes GBytes *old_free = g_steal_pointer(&peer_info->ies); peer_info->ies = g_bytes_new(arr_data, arr_len); @@ -1904,11 +1907,11 @@ _properties_changed_main(NMSupplicantInterface *self, GVariant *properties) } if (nm_g_variant_lookup(properties, "Ifname", "&s", &v_s)) { - if (nm_utils_strdup_reset(&priv->ifname, v_s)) + if (nm_strdup_reset(&priv->ifname, v_s)) do_log_driver_info = TRUE; } if (nm_g_variant_lookup(properties, "Driver", "&s", &v_s)) { - if (nm_utils_strdup_reset(&priv->driver, v_s)) + if (nm_strdup_reset(&priv->driver, v_s)) do_log_driver_info = TRUE; } @@ -2305,7 +2308,7 @@ assoc_add_network_cb(GObject *source, GAsyncResult *result, gpointer user_data) self, NM_WPAS_DBUS_IFACE_INTERFACE, "AddBlob", - g_variant_new("(s@ay)", blob_name, nm_utils_gbytes_to_variant_ay(blob_data)), + g_variant_new("(s@ay)", blob_name, nm_g_bytes_to_variant_ay(blob_data)), G_VARIANT_TYPE("()"), G_DBUS_CALL_FLAGS_NONE, DBUS_TIMEOUT_MSEC, @@ -2609,7 +2612,7 @@ nm_supplicant_interface_request_scan(NMSupplicantInterface * se g_variant_builder_init(&ssids_builder, G_VARIANT_TYPE_BYTESTRING_ARRAY); for (i = 0; i < ssids_len; i++) { nm_assert(ssids[i]); - g_variant_builder_add(&ssids_builder, "@ay", nm_utils_gbytes_to_variant_ay(ssids[i])); + g_variant_builder_add(&ssids_builder, "@ay", nm_g_bytes_to_variant_ay(ssids[i])); } g_variant_builder_add(&builder, "{sv}", "SSIDs", g_variant_builder_end(&ssids_builder)); } @@ -2942,6 +2945,15 @@ _get_all_p2p_device_cb(GVariant *result, GError *error, gpointer user_data) _properties_changed(user_data, NM_WPAS_DBUS_IFACE_INTERFACE_P2P_DEVICE, properties, TRUE); } +static void +_set_p2p_assigned_addr(NMSupplicantInterface *self, gconstpointer addr, guint8 plen) +{ + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); + + nm_ip_addr_set(AF_INET, &priv->p2p_assigned_addr, addr); + priv->p2p_assigned_plen = plen; +} + static void _signal_handle(NMSupplicantInterface *self, const char * signal_interface_name, @@ -3036,6 +3048,7 @@ _signal_handle(NMSupplicantInterface *self, gs_unref_object NMSupplicantInterface *iface = NULL; const char * group_path; const char * iface_path; + GVariant * v_v = NULL; g_variant_get(parameters, "(@a{sv})", &args); if (!g_variant_lookup(args, "group_object", "&o", &group_path)) @@ -3057,6 +3070,34 @@ _signal_handle(NMSupplicantInterface *self, } } + v_v = g_variant_lookup_value(args, "IpAddr", G_VARIANT_TYPE_BYTESTRING); + if (v_v) { + const guint8 *addr_data; + gsize addr_len = 0; + const guint8 *mask_data = NULL; + gsize mask_len = 0; + + /* The address is passed in network-byte-order */ + addr_data = g_variant_get_fixed_array(v_v, &addr_len, 1); + + /* TODO: Should we expose IpAddrGo? If yes, maybe as gateway? */ + v_v = g_variant_lookup_value(args, "IpAddrMask", G_VARIANT_TYPE_BYTESTRING); + if (v_v) + mask_data = g_variant_get_fixed_array(v_v, &mask_len, 1); + + if (addr_len == NM_AF_INET_SIZE && mask_len == NM_AF_INET_SIZE) { + guint32 netmask; + + memcpy(&netmask, mask_data, NM_AF_INET_SIZE); + + _set_p2p_assigned_addr(iface, + addr_data, + nm_utils_ip4_netmask_to_prefix(netmask)); + } else { + _LOGW("P2P: GroupStarted signaled invalid IP Address information"); + } + } + /* Signal existence of the (new) interface. */ g_signal_emit(self, signals[GROUP_STARTED], 0, iface); } @@ -3137,6 +3178,24 @@ nm_supplicant_interface_get_p2p_group_owner(NMSupplicantInterface *self) return NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self)->p2p_group_owner_cached; } +gboolean +nm_supplicant_interface_get_p2p_assigned_addr(NMSupplicantInterface *self, + in_addr_t * addr, + guint8 * plen) +{ + NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE(self); + + if (nm_ip_addr_is_null(AF_INET, &priv->p2p_assigned_addr)) + return FALSE; + + if (addr) + nm_ip_addr_set(AF_INET, addr, &priv->p2p_assigned_addr); + if (plen) + *plen = priv->p2p_assigned_plen; + + return TRUE; +} + /*****************************************************************************/ static void diff --git a/src/core/supplicant/nm-supplicant-interface.h b/src/core/supplicant/nm-supplicant-interface.h index a62eeb62..4c5d8f64 100644 --- a/src/core/supplicant/nm-supplicant-interface.h +++ b/src/core/supplicant/nm-supplicant-interface.h @@ -164,6 +164,10 @@ const char *nm_supplicant_interface_get_p2p_group_path(NMSupplicantInterface *se gboolean nm_supplicant_interface_get_p2p_group_owner(NMSupplicantInterface *self); +gboolean nm_supplicant_interface_get_p2p_assigned_addr(NMSupplicantInterface *self, + in_addr_t * assigned_addr, + guint8 * plen); + void nm_supplicant_interface_p2p_start_find(NMSupplicantInterface *self, guint timeout); void nm_supplicant_interface_p2p_stop_find(NMSupplicantInterface *self); diff --git a/src/core/supplicant/nm-supplicant-manager.c b/src/core/supplicant/nm-supplicant-manager.c index e432889b..52beae78 100644 --- a/src/core/supplicant/nm-supplicant-manager.c +++ b/src/core/supplicant/nm-supplicant-manager.c @@ -244,8 +244,7 @@ nm_supplicant_manager_set_wfd_ies(NMSupplicantManager *self, GBytes *wfd_ies) g_variant_builder_add(¶ms, "s", NM_WPAS_DBUS_INTERFACE); g_variant_builder_add(¶ms, "s", "WFDIEs"); - g_variant_builder_add_value(¶ms, - g_variant_new_variant(nm_utils_gbytes_to_variant_ay(wfd_ies))); + g_variant_builder_add_value(¶ms, g_variant_new_variant(nm_g_bytes_to_variant_ay(wfd_ies))); g_dbus_connection_call(priv->dbus_connection, priv->name_owner->str, diff --git a/src/core/supplicant/nm-supplicant-settings-verify.c b/src/core/supplicant/nm-supplicant-settings-verify.c index 5e77b207..ceb4b6ae 100644 --- a/src/core/supplicant/nm-supplicant-settings-verify.c +++ b/src/core/supplicant/nm-supplicant-settings-verify.c @@ -223,7 +223,7 @@ validate_type_keyword(const struct Opt *opt, const char *value, const guint32 le s++; } - if (nm_utils_strv_find_first((char **) opt->str_allowed, -1, value) < 0) + if (nm_strv_find_first(opt->str_allowed, -1, value) < 0) return FALSE; if (!s) diff --git a/src/core/supplicant/nm-supplicant-types.h b/src/core/supplicant/nm-supplicant-types.h index c9b72de1..743ef8f0 100644 --- a/src/core/supplicant/nm-supplicant-types.h +++ b/src/core/supplicant/nm-supplicant-types.h @@ -14,9 +14,9 @@ #define NM_WPAS_DBUS_INTERFACE "fi.w1.wpa_supplicant1" #if HAVE_WEXT - #define NM_WPAS_DEFAULT_WIFI_DRIVER "nl80211,wext" +#define NM_WPAS_DEFAULT_WIFI_DRIVER "nl80211,wext" #else - #define NM_WPAS_DEFAULT_WIFI_DRIVER "nl80211" +#define NM_WPAS_DEFAULT_WIFI_DRIVER "nl80211" #endif #define NM_WPAS_DBUS_IFACE_INTERFACE NM_WPAS_DBUS_INTERFACE ".Interface" diff --git a/src/core/tests/test-core.c b/src/core/tests/test-core.c index f28c4178..3524cb17 100644 --- a/src/core/tests/test-core.c +++ b/src/core/tests/test-core.c @@ -1728,86 +1728,86 @@ test_nm_utils_strbuf_append(void) char buf[NM_STRLEN(BUF_ORIG) + 1]; char str[NM_STRLEN(BUF_ORIG) + 1]; -#define _strbuf_append(buf, len, format, ...) \ - G_STMT_START \ - { \ - char ** _buf = (buf); \ - gsize * _len = (len); \ - const char * _str_iter; \ - gs_free char *_str = NULL; \ - \ - switch (nmtst_get_rand_uint32() % 4) { \ - case 0: \ - nm_utils_strbuf_append(_buf, _len, (format), __VA_ARGS__); \ - break; \ - case 1: \ - _str = g_strdup_printf((format), __VA_ARGS__); \ - nm_utils_strbuf_append_str(_buf, _len, _str); \ - break; \ - case 2: \ - _str = g_strdup_printf((format), __VA_ARGS__); \ - nm_utils_strbuf_append_bin(_buf, _len, _str, strlen(_str)); \ - break; \ - case 3: \ - _str = g_strdup_printf((format), __VA_ARGS__); \ - if (!_str[0]) \ - nm_utils_strbuf_append_str(_buf, _len, _str); \ - for (_str_iter = _str; _str_iter[0]; _str_iter++) \ - nm_utils_strbuf_append_c(_buf, _len, _str_iter[0]); \ - break; \ - } \ - } \ +#define _strbuf_append(buf, len, format, ...) \ + G_STMT_START \ + { \ + char ** _buf = (buf); \ + gsize * _len = (len); \ + const char * _str_iter; \ + gs_free char *_str = NULL; \ + \ + switch (nmtst_get_rand_uint32() % 4) { \ + case 0: \ + nm_strbuf_append(_buf, _len, (format), __VA_ARGS__); \ + break; \ + case 1: \ + _str = g_strdup_printf((format), __VA_ARGS__); \ + nm_strbuf_append_str(_buf, _len, _str); \ + break; \ + case 2: \ + _str = g_strdup_printf((format), __VA_ARGS__); \ + nm_strbuf_append_bin(_buf, _len, _str, strlen(_str)); \ + break; \ + case 3: \ + _str = g_strdup_printf((format), __VA_ARGS__); \ + if (!_str[0]) \ + nm_strbuf_append_str(_buf, _len, _str); \ + for (_str_iter = _str; _str_iter[0]; _str_iter++) \ + nm_strbuf_append_c(_buf, _len, _str_iter[0]); \ + break; \ + } \ + } \ G_STMT_END -#define _strbuf_append_str(buf, len, str) \ - G_STMT_START \ - { \ - char ** _buf = (buf); \ - gsize * _len = (len); \ - const char *_str = (str); \ - \ - switch (nmtst_get_rand_uint32() % 4) { \ - case 0: \ - nm_utils_strbuf_append(_buf, _len, "%s", _str ?: ""); \ - break; \ - case 1: \ - nm_utils_strbuf_append_str(_buf, _len, _str); \ - break; \ - case 2: \ - nm_utils_strbuf_append_bin(_buf, _len, _str, _str ? strlen(_str) : 0); \ - break; \ - case 3: \ - if (!_str || !_str[0]) \ - nm_utils_strbuf_append_str(_buf, _len, _str); \ - for (; _str && _str[0]; _str++) \ - nm_utils_strbuf_append_c(_buf, _len, _str[0]); \ - break; \ - } \ - } \ +#define _strbuf_append_str(buf, len, str) \ + G_STMT_START \ + { \ + char ** _buf = (buf); \ + gsize * _len = (len); \ + const char *_str = (str); \ + \ + switch (nmtst_get_rand_uint32() % 4) { \ + case 0: \ + nm_strbuf_append(_buf, _len, "%s", _str ?: ""); \ + break; \ + case 1: \ + nm_strbuf_append_str(_buf, _len, _str); \ + break; \ + case 2: \ + nm_strbuf_append_bin(_buf, _len, _str, _str ? strlen(_str) : 0); \ + break; \ + case 3: \ + if (!_str || !_str[0]) \ + nm_strbuf_append_str(_buf, _len, _str); \ + for (; _str && _str[0]; _str++) \ + nm_strbuf_append_c(_buf, _len, _str[0]); \ + break; \ + } \ + } \ G_STMT_END -#define _strbuf_append_c(buf, len, ch) \ - G_STMT_START \ - { \ - char **_buf = (buf); \ - gsize *_len = (len); \ - char _ch = (ch); \ - \ - switch (nmtst_get_rand_uint32() % 4) { \ - case 0: \ - nm_utils_strbuf_append(_buf, _len, "%c", _ch); \ - break; \ - case 1: \ - nm_utils_strbuf_append_str(_buf, _len, ((char[2]){_ch, 0})); \ - break; \ - case 2: \ - nm_utils_strbuf_append_bin(_buf, _len, &_ch, 1); \ - break; \ - case 3: \ - nm_utils_strbuf_append_c(_buf, _len, _ch); \ - break; \ - } \ - } \ +#define _strbuf_append_c(buf, len, ch) \ + G_STMT_START \ + { \ + char **_buf = (buf); \ + gsize *_len = (len); \ + char _ch = (ch); \ + \ + switch (nmtst_get_rand_uint32() % 4) { \ + case 0: \ + nm_strbuf_append(_buf, _len, "%c", _ch); \ + break; \ + case 1: \ + nm_strbuf_append_str(_buf, _len, ((char[2]){_ch, 0})); \ + break; \ + case 2: \ + nm_strbuf_append_bin(_buf, _len, &_ch, 1); \ + break; \ + case 3: \ + nm_strbuf_append_c(_buf, _len, _ch); \ + break; \ + } \ + } \ G_STMT_END for (buf_len = 0; buf_len < 10; buf_len++) { @@ -1854,28 +1854,28 @@ test_nm_utils_strbuf_append(void) if (t_len > 0 && strlen(str) >= buf_len && (nmtst_get_rand_uint32() % 2)) { /* the string was truncated by g_snprintf(). That means, at the last position in the * buffer is now NUL. - * Replace the NUL by the actual character, and check that nm_utils_strbuf_seek_end() + * Replace the NUL by the actual character, and check that nm_strbuf_seek_end() * does the right thing: NUL terminate the buffer and seek past the end of the buffer. */ g_assert_cmpmem(t_buf, t_len - 1, str, t_len - 1); g_assert(t_buf[t_len - 1] == '\0'); g_assert(str[t_len - 1] != '\0'); t_buf[t_len - 1] = str[t_len - 1]; - nm_utils_strbuf_seek_end(&t_buf, &t_len); + nm_strbuf_seek_end(&t_buf, &t_len); g_assert(t_len == 0); g_assert(t_buf == &buf[buf_len]); g_assert(t_buf[-1] == '\0'); } else { - nm_utils_strbuf_seek_end(&t_buf, &t_len); + nm_strbuf_seek_end(&t_buf, &t_len); if (buf_len > 0 && strlen(str) + 1 > buf_len) { /* the buffer was truncated by g_snprintf() above. * - * But nm_utils_strbuf_seek_end() does not recognize that and returns + * But nm_strbuf_seek_end() does not recognize that and returns * a remaining length of 1. * - * Note that other nm_utils_strbuf_append*() functions recognize + * Note that other nm_strbuf_append*() functions recognize * truncation, and properly set the remaining length to zero. - * As the assertions below check for the behavior of nm_utils_strbuf_append*(), - * we assert here that nm_utils_strbuf_seek_end() behaved as expected, and then + * As the assertions below check for the behavior of nm_strbuf_append*(), + * we assert here that nm_strbuf_seek_end() behaved as expected, and then * adjust t_buf/t_len according to the "is-truncated" case. */ g_assert(t_len == 1); g_assert(t_buf == &buf[buf_len - 1]); @@ -2594,7 +2594,7 @@ main(int argc, char **argv) g_test_add_func("/general/test_logging_domains", test_logging_domains); g_test_add_func("/general/test_logging_error", test_logging_error); - g_test_add_func("/general/nm_utils_strbuf_append", test_nm_utils_strbuf_append); + g_test_add_func("/general/nm_strbuf_append", test_nm_utils_strbuf_append); g_test_add_func("/general/nm_utils_ip6_address_clear_host_address", test_nm_utils_ip6_address_clear_host_address); diff --git a/src/core/tests/test-ip6-config.c b/src/core/tests/test-ip6-config.c index ddf4c789..2e6d8aaa 100644 --- a/src/core/tests/test-ip6-config.c +++ b/src/core/tests/test-ip6-config.c @@ -327,7 +327,7 @@ test_nm_ip6_config_addresses_sort(void) 0, 0, 0, - IFA_F_TEMPORARY); + IFA_F_SECONDARY); ADDR_ADD("2607:f0d0:1002:51::8", NULL, 64, @@ -336,7 +336,7 @@ test_nm_ip6_config_addresses_sort(void) 0, 0, 0, - IFA_F_TEMPORARY); + IFA_F_SECONDARY); ADDR_ADD("2607:f0d0:1002:51::0", NULL, 64, @@ -345,7 +345,7 @@ test_nm_ip6_config_addresses_sort(void) 0, 0, 0, - IFA_F_TEMPORARY); + IFA_F_SECONDARY); ADDR_ADD("fec0::1", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); ADDR_ADD("fe80::208:74ff:feda:625c", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); ADDR_ADD("fe80::208:74ff:feda:625d", NULL, 128, 0, NM_IP_CONFIG_SOURCE_KERNEL, 0, 0, 0, 0); @@ -374,7 +374,7 @@ test_nm_ip6_config_addresses_sort(void) 0, 0, 0, - IFA_F_TEMPORARY); + IFA_F_SECONDARY); ADDR_ADD("2607:f0d0:1002:51::4", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); ADDR_ADD("2607:f0d0:1002:51::5", NULL, 64, 0, NM_IP_CONFIG_SOURCE_USER, 0, 0, 0, 0); ADDR_ADD("2607:f0d0:1002:51::8", @@ -385,7 +385,7 @@ test_nm_ip6_config_addresses_sort(void) 0, 0, 0, - IFA_F_TEMPORARY); + IFA_F_SECONDARY); ADDR_ADD("2607:f0d0:1002:51::0", NULL, 64, @@ -394,7 +394,7 @@ test_nm_ip6_config_addresses_sort(void) 0, 0, 0, - IFA_F_TEMPORARY); + IFA_F_SECONDARY); ADDR_ADD("2607:f0d0:1002:51::6", NULL, 64, diff --git a/src/core/tests/test-l3cfg.c b/src/core/tests/test-l3cfg.c index ba065c09..100c2496 100644 --- a/src/core/tests/test-l3cfg.c +++ b/src/core/tests/test-l3cfg.c @@ -2,8 +2,11 @@ #include "src/core/nm-default-daemon.h" +#include + #include "nm-l3cfg.h" #include "nm-l3-ipv4ll.h" +#include "nm-l3-ipv6ll.h" #include "nm-netns.h" #include "libnm-platform/nm-platform.h" @@ -132,6 +135,7 @@ typedef struct { NML3AcdDefendType acd_defend_type_a; TestL3cfgNotifyType notify_type; + guint pre_commit_event_count; guint post_commit_event_count; guint general_event_count; guint general_event_flags; @@ -151,6 +155,7 @@ _test_l3cfg_data_set_notify_type(TestL3cfgData *tdata, TestL3cfgNotifyType notif g_assert(tdata); tdata->notify_type = notify_type; + tdata->pre_commit_event_count = 0; tdata->post_commit_event_count = 0; tdata->general_event_count = 0; tdata->general_event_flags = 0; @@ -209,6 +214,10 @@ _test_l3cfg_signal_notify(NML3Cfg * l3cfg, case TEST_L3CFG_NOTIFY_TYPE_COMMIT_1: g_assert_cmpint(tdata->post_commit_event_count, ==, 0); switch (notify_data->notify_type) { + case NM_L3_CONFIG_NOTIFY_TYPE_PRE_COMMIT: + g_assert_cmpint(tdata->pre_commit_event_count, ==, 0); + tdata->pre_commit_event_count++; + return; case NM_L3_CONFIG_NOTIFY_TYPE_POST_COMMIT: tdata->post_commit_event_count++; return; @@ -255,6 +264,7 @@ _test_l3cfg_signal_notify(NML3Cfg * l3cfg, 1 + 2 + (tdata->add_addr4_101 ? (tdata->has_addr4_101 ? 1 : 3) : 0); if (NM_IN_SET(notify_data->notify_type, + NM_L3_CONFIG_NOTIFY_TYPE_PRE_COMMIT, NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE, NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE_ON_IDLE)) return; @@ -368,7 +378,8 @@ test_l3cfg(gconstpointer test_data) g_signal_connect(l3cfg0, NM_L3CFG_SIGNAL_NOTIFY, G_CALLBACK(_test_l3cfg_signal_notify), tdata); - commit_type_1 = nm_l3cfg_commit_type_register(l3cfg0, NM_L3_CFG_COMMIT_TYPE_UPDATE, NULL); + commit_type_1 = + nm_l3cfg_commit_type_register(l3cfg0, NM_L3_CFG_COMMIT_TYPE_UPDATE, NULL, "test1"); if (!nmtst_get_rand_one_case_in(4)) { commit_type_2 = @@ -376,7 +387,8 @@ test_l3cfg(gconstpointer test_data) nmtst_rand_select(NM_L3_CFG_COMMIT_TYPE_NONE, NM_L3_CFG_COMMIT_TYPE_ASSUME, NM_L3_CFG_COMMIT_TYPE_UPDATE), - NULL); + NULL, + "test2"); } else commit_type_2 = NULL; @@ -389,7 +401,7 @@ test_l3cfg(gconstpointer test_data) { nm_auto_unref_l3cd_init NML3ConfigData *l3cd = NULL; - l3cd = nm_l3_config_data_new(f->multiidx, f->ifindex0); + l3cd = nm_l3_config_data_new(f->multiidx, f->ifindex0, NM_IP_CONFIG_SOURCE_UNKNOWN); nm_l3_config_data_add_address_4( l3cd, @@ -432,8 +444,11 @@ test_l3cfg(gconstpointer test_data) NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6, 0, 0, + NM_DNS_PRIORITY_DEFAULT_NORMAL, + NM_DNS_PRIORITY_DEFAULT_NORMAL, tdata->acd_defend_type_a, tdata->acd_timeout_msec_a, + NM_L3CFG_CONFIG_FLAGS_NONE, NM_L3_CONFIG_MERGE_FLAGS_NONE); } @@ -445,6 +460,7 @@ test_l3cfg(gconstpointer test_data) _test_l3cfg_data_set_notify_type(tdata, TEST_L3CFG_NOTIFY_TYPE_COMMIT_1); nm_l3cfg_commit(l3cfg0, NM_L3_CFG_COMMIT_TYPE_REAPPLY); + g_assert_cmpint(tdata->pre_commit_event_count, ==, 1); g_assert_cmpint(tdata->post_commit_event_count, ==, 1); _test_l3cfg_data_set_notify_type(tdata, TEST_L3CFG_NOTIFY_TYPE_NONE); @@ -490,7 +506,7 @@ test_l3cfg(gconstpointer test_data) if (nmtst_get_rand_one_case_in(3)) _test_fixture_1_teardown(&test_fixture); - nm_l3cfg_remove_config_all(l3cfg0, GINT_TO_POINTER('a'), FALSE); + nm_l3cfg_remove_config_all(l3cfg0, GINT_TO_POINTER('a')); if (nmtst_get_rand_one_case_in(3)) _test_fixture_1_teardown(&test_fixture); @@ -593,16 +609,21 @@ _test_l3_ipv4ll_signal_notify(NML3Cfg * l3cfg, 105, 0, 0, + NM_DNS_PRIORITY_DEFAULT_NORMAL, + NM_DNS_PRIORITY_DEFAULT_NORMAL, NM_L3_ACD_DEFEND_TYPE_ONCE, nmtst_get_rand_bool() ? tdata->acd_timeout_msec : 0u, + NM_L3CFG_CONFIG_FLAGS_NONE, NM_L3_CONFIG_MERGE_FLAGS_NONE)) g_assert_not_reached(); - nm_l3cfg_commit_on_idle_schedule(nm_l3_ipv4ll_get_l3cfg(tdata->l3ipv4ll)); + nm_l3cfg_commit_on_idle_schedule(nm_l3_ipv4ll_get_l3cfg(tdata->l3ipv4ll), + NM_L3_CFG_COMMIT_TYPE_AUTO); tdata->l3cfg_commit_type_1 = nm_l3cfg_commit_type_register(nm_l3_ipv4ll_get_l3cfg(tdata->l3ipv4ll), NM_L3_CFG_COMMIT_TYPE_UPDATE, - tdata->l3cfg_commit_type_1); + tdata->l3cfg_commit_type_1, + "test"); } } else if (nm_l3_ipv4ll_get_state(tdata->l3ipv4ll) != NM_L3_IPV4LL_STATE_DEFENDING && tdata->ready_seen > 0) { @@ -615,10 +636,10 @@ _test_l3_ipv4ll_signal_notify(NML3Cfg * l3cfg, _LOGT("remove address %s that previously passed ACD", _nm_utils_inet4_ntop(tdata->addr_commit_addr, sbuf_addr)); if (!nm_l3cfg_remove_config_all(nm_l3_ipv4ll_get_l3cfg(tdata->l3ipv4ll), - TEST_L3_IPV4LL_TAG(tdata, 1), - FALSE)) + TEST_L3_IPV4LL_TAG(tdata, 1))) g_assert_not_reached(); - nm_l3cfg_commit_on_idle_schedule(nm_l3_ipv4ll_get_l3cfg(tdata->l3ipv4ll)); + nm_l3cfg_commit_on_idle_schedule(nm_l3_ipv4ll_get_l3cfg(tdata->l3ipv4ll), + NM_L3_CFG_COMMIT_TYPE_AUTO); nm_l3cfg_commit_type_unregister(nm_l3_ipv4ll_get_l3cfg(tdata->l3ipv4ll), g_steal_pointer(&tdata->l3cfg_commit_type_1)); } @@ -766,9 +787,7 @@ test_l3_ipv4ll(gconstpointer test_data) _LOGT("poll 1 end"); if (tdata->addr_commit || nmtst_get_rand_bool()) { - nm_l3cfg_remove_config_all(nm_l3_ipv4ll_get_l3cfg(l3ipv4ll), - TEST_L3_IPV4LL_TAG(tdata, 1), - FALSE); + nm_l3cfg_remove_config_all(nm_l3_ipv4ll_get_l3cfg(l3ipv4ll), TEST_L3_IPV4LL_TAG(tdata, 1)); } nmtstp_acd_defender_destroy(g_steal_pointer(&acd_defender_1)); @@ -781,6 +800,276 @@ test_l3_ipv4ll(gconstpointer test_data) /*****************************************************************************/ +#define _LLADDR_TEST1 "fe80::dd5a:8a44:48bc:3ad" +#define _LLADDR_TEST2 "fe80::878b:938e:46f9:4807" + +typedef struct { + const TestFixture1 *f; + NML3Cfg * l3cfg0; + NML3IPv6LL * l3ipv6ll; + int step; + int ipv6ll_callback_step; + bool steps_done : 1; + const NMPObject * lladdr0; +} TestL3IPv6LLData; + +static const NMPlatformIP6Address * +_test_l3_ipv6ll_find_lladdr(TestL3IPv6LLData *tdata, int ifindex) +{ + const NMPlatformIP6Address *found = NULL; + NMDedupMultiIter iter; + const NMPObject * obj; + NMPLookup lookup; + + g_assert(tdata); + + nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_IP6_ADDRESS, ifindex); + nm_platform_iter_obj_for_each (&iter, tdata->f->platform, &lookup, &obj) { + const NMPlatformIP6Address *a = NMP_OBJECT_CAST_IP6_ADDRESS(obj); + + if (!IN6_IS_ADDR_LINKLOCAL(&a->address)) + continue; + + if (!found) + found = a; + else + g_assert_not_reached(); + } + + return found; +} + +static const NMPObject * +_test_l3_ipv6ll_find_lladdr_wait(TestL3IPv6LLData *tdata, int ifindex) +{ + const NMPObject *obj = NULL; + + nmtst_main_context_iterate_until_assert(NULL, 3000, ({ + const NMPlatformIP6Address *a; + + a = _test_l3_ipv6ll_find_lladdr(tdata, ifindex); + if (a + && !NM_FLAGS_HAS(a->n_ifa_flags, + IFA_F_TENTATIVE)) + obj = NMP_OBJECT_UP_CAST(a); + obj; + })); + + return obj; +} + +static const NMPlatformIP6Address * +_test_l3_ipv6ll_find_inet6(TestL3IPv6LLData *tdata, const struct in6_addr *addr) +{ + const NMPlatformIP6Address *a; + + a = nmtstp_platform_ip6_address_find(nm_l3cfg_get_platform(tdata->l3cfg0), + nmtst_get_rand_bool() ? 0 : tdata->f->ifindex0, + addr); + if (a) { + g_assert_cmpint(a->ifindex, ==, tdata->f->ifindex0); + g_assert_cmpmem(addr, sizeof(*addr), &a->address, sizeof(a->address)); + } + + g_assert(a + == nm_platform_ip6_address_get(nm_l3cfg_get_platform(tdata->l3cfg0), + tdata->f->ifindex0, + addr)); + + return a; +} + +static void +_test_l3_ipv6ll_signal_notify(NML3Cfg * l3cfg, + const NML3ConfigNotifyData *notify_data, + TestL3IPv6LLData * tdata) +{ + g_assert_cmpint(tdata->step, >=, 1); + g_assert_cmpint(tdata->step, <=, 2); +} + +static void +_test_l3_ipv6ll_callback_changed(NML3IPv6LL * ipv6ll, + NML3IPv6LLState state, + const struct in6_addr *lladdr, + gpointer user_data) +{ + TestL3IPv6LLData * tdata = user_data; + int step = tdata->ipv6ll_callback_step++; + const NMPlatformIP6Address *a1; + + g_assert_cmpint(tdata->step, ==, 1); + g_assert(!tdata->steps_done); + + switch (step) { + case 0: + if (NM_IN_SET(tdata->f->test_idx, 1, 2, 4)) { + g_assert_cmpint(state, ==, NM_L3_IPV6LL_STATE_DAD_IN_PROGRESS); + g_assert_cmpstr(nmtst_inet6_to_string(lladdr), ==, _LLADDR_TEST1); + } else if (NM_IN_SET(tdata->f->test_idx, 3)) { + g_assert_cmpint(state, ==, NM_L3_IPV6LL_STATE_READY); + g_assert( + IN6_ARE_ADDR_EQUAL(lladdr, &NMP_OBJECT_CAST_IP6_ADDRESS(tdata->lladdr0)->address)); + tdata->steps_done = TRUE; + } else + g_assert_not_reached(); + break; + case 1: + if (NM_IN_SET(tdata->f->test_idx, 1, 2)) { + g_assert_cmpint(state, ==, NM_L3_IPV6LL_STATE_READY); + g_assert_cmpstr(nmtst_inet6_to_string(lladdr), ==, _LLADDR_TEST1); + a1 = _test_l3_ipv6ll_find_inet6(tdata, lladdr); + g_assert(a1); + g_assert(!NM_FLAGS_HAS(a1->n_ifa_flags, IFA_F_TENTATIVE)); + tdata->steps_done = TRUE; + } else if (NM_IN_SET(tdata->f->test_idx, 4)) { + g_assert_cmpint(state, ==, NM_L3_IPV6LL_STATE_DAD_IN_PROGRESS); + g_assert_cmpstr(nmtst_inet6_to_string(lladdr), ==, _LLADDR_TEST2); + } else + g_assert_not_reached(); + break; + case 2: + if (NM_IN_SET(tdata->f->test_idx, 4)) { + g_assert_cmpint(state, ==, NM_L3_IPV6LL_STATE_READY); + g_assert_cmpstr(nmtst_inet6_to_string(lladdr), ==, _LLADDR_TEST2); + a1 = _test_l3_ipv6ll_find_inet6(tdata, lladdr); + g_assert(a1); + g_assert(!NM_FLAGS_HAS(a1->n_ifa_flags, IFA_F_TENTATIVE)); + tdata->steps_done = TRUE; + } else + g_assert_not_reached(); + break; + default: + g_assert_not_reached(); + } +} + +static void +test_l3_ipv6ll(gconstpointer test_data) +{ + NMTST_UTILS_HOST_ID_CONTEXT("l3-ipv6ll"); + const int TEST_IDX = GPOINTER_TO_INT(test_data); + nm_auto(_test_fixture_1_teardown) TestFixture1 test_fixture = {}; + gs_unref_object NML3Cfg *l3cfg0 = NULL; + TestL3IPv6LLData tdata_stack = { + .step = 0, + .steps_done = FALSE, + }; + TestL3IPv6LLData *const tdata = &tdata_stack; + char sbuf1[sizeof(_nm_utils_to_string_buffer)]; + int r; + + _LOGD("test start (/l3-ipv6ll/%d)", TEST_IDX); + + if (nmtst_test_quick()) { + gs_free char *msg = + g_strdup_printf("Skipping test: don't run long running test %s (NMTST_DEBUG=slow)\n", + g_get_prgname() ?: "test-l3-ipv6ll"); + + g_test_skip(msg); + return; + } + + tdata->f = _test_fixture_1_setup(&test_fixture, TEST_IDX); + + if (NM_IN_SET(tdata->f->test_idx, 4)) { + _LOGD("add conflicting IPv6LL on other interface..."); + r = nm_platform_link_change_flags(tdata->f->platform, tdata->f->ifindex1, IFF_UP, FALSE); + g_assert_cmpint(r, >=, 0); + + r = nm_platform_link_set_inet6_addr_gen_mode(tdata->f->platform, + tdata->f->ifindex1, + NM_IN6_ADDR_GEN_MODE_NONE); + g_assert_cmpint(r, >=, 0); + + r = nm_platform_link_change_flags(tdata->f->platform, tdata->f->ifindex1, IFF_UP, TRUE); + g_assert_cmpint(r, >=, 0); + + nmtstp_ip6_address_add(tdata->f->platform, + -1, + tdata->f->ifindex1, + *nmtst_inet6_from_string(_LLADDR_TEST1), + 64, + in6addr_any, + NM_PLATFORM_LIFETIME_PERMANENT, + NM_PLATFORM_LIFETIME_PERMANENT, + 0); + + _LOGD("wait for IPv6 LL address..."); + tdata->lladdr0 = + nmp_object_ref(_test_l3_ipv6ll_find_lladdr_wait(tdata, tdata->f->ifindex1)); + } else if (NM_IN_SET(tdata->f->test_idx, 2, 3)) { + _LOGD("wait for IPv6 LL address..."); + tdata->lladdr0 = + nmp_object_ref(_test_l3_ipv6ll_find_lladdr_wait(tdata, tdata->f->ifindex0)); + } + + if (tdata->lladdr0) { + _LOGD("got IPv6 LL address %s", + nmp_object_to_string(tdata->lladdr0, + NMP_OBJECT_TO_STRING_PUBLIC, + sbuf1, + sizeof(sbuf1))); + } + + l3cfg0 = _netns_access_l3cfg(tdata->f->netns, tdata->f->ifindex0); + tdata->l3cfg0 = l3cfg0; + + g_signal_connect(tdata->l3cfg0, + NM_L3CFG_SIGNAL_NOTIFY, + G_CALLBACK(_test_l3_ipv6ll_signal_notify), + tdata); + + tdata->l3ipv6ll = nm_l3_ipv6ll_new_stable_privacy(tdata->l3cfg0, + NM_IN_SET(tdata->f->test_idx, 3), + NM_UTILS_STABLE_TYPE_UUID, + tdata->f->ifname0, + "b6a5b934-c649-43dc-a524-3dfdb74f9419", + _test_l3_ipv6ll_callback_changed, + tdata); + + g_assert(nm_l3_ipv6ll_get_l3cfg(tdata->l3ipv6ll) == tdata->l3cfg0); + g_assert_cmpint(nm_l3_ipv6ll_get_ifindex(tdata->l3ipv6ll), ==, tdata->f->ifindex0); + + tdata->step = 1; + nmtst_main_context_iterate_until_assert(NULL, 7000, tdata->steps_done); + + g_assert_cmpint(tdata->step, ==, 1); + if (NM_IN_SET(tdata->f->test_idx, 3)) + g_assert_cmpint(tdata->ipv6ll_callback_step, ==, 1); + else if (NM_IN_SET(tdata->f->test_idx, 4)) + g_assert_cmpint(tdata->ipv6ll_callback_step, ==, 3); + else + g_assert_cmpint(tdata->ipv6ll_callback_step, ==, 2); + g_assert(tdata->steps_done); + + tdata->step = 2; + nmtst_main_context_iterate_until(NULL, nmtst_get_rand_uint32() % 1000, FALSE); + + g_assert_cmpint(tdata->step, ==, 2); + if (NM_IN_SET(tdata->f->test_idx, 3)) + g_assert_cmpint(tdata->ipv6ll_callback_step, ==, 1); + else if (NM_IN_SET(tdata->f->test_idx, 4)) + g_assert_cmpint(tdata->ipv6ll_callback_step, ==, 3); + else + g_assert_cmpint(tdata->ipv6ll_callback_step, ==, 2); + g_assert(tdata->steps_done); + g_assert(tdata->steps_done); + + tdata->step = 0; + tdata->steps_done = FALSE; + + g_signal_handlers_disconnect_by_func(tdata->l3cfg0, + G_CALLBACK(_test_l3_ipv6ll_signal_notify), + tdata); + + nm_l3_ipv6ll_destroy(tdata->l3ipv6ll); + + nm_clear_nmp_object(&tdata->lladdr0); +} + +/*****************************************************************************/ + NMTstpSetupFunc const _nmtstp_setup_platform_func = nm_linux_platform_setup; void @@ -798,4 +1087,8 @@ _nmtstp_setup_tests(void) g_test_add_data_func("/l3cfg/4", GINT_TO_POINTER(4), test_l3cfg); g_test_add_data_func("/l3-ipv4ll/1", GINT_TO_POINTER(1), test_l3_ipv4ll); g_test_add_data_func("/l3-ipv4ll/2", GINT_TO_POINTER(2), test_l3_ipv4ll); + g_test_add_data_func("/l3-ipv6ll/1", GINT_TO_POINTER(1), test_l3_ipv6ll); + g_test_add_data_func("/l3-ipv6ll/2", GINT_TO_POINTER(2), test_l3_ipv6ll); + g_test_add_data_func("/l3-ipv6ll/3", GINT_TO_POINTER(3), test_l3_ipv6ll); + g_test_add_data_func("/l3-ipv6ll/4", GINT_TO_POINTER(4), test_l3_ipv6ll); } diff --git a/src/core/tests/test-systemd.c b/src/core/tests/test-systemd.c index 12d2b911..be070248 100644 --- a/src/core/tests/test-systemd.c +++ b/src/core/tests/test-systemd.c @@ -36,14 +36,14 @@ test_dhcp_create(void) static void test_lldp_create(void) { - sd_lldp *lldp = NULL; - int r; + sd_lldp_rx *lldp = NULL; + int r; - r = sd_lldp_new(&lldp); + r = sd_lldp_rx_new(&lldp); g_assert(r == 0); g_assert(lldp); - sd_lldp_unref(lldp); + sd_lldp_rx_unref(lldp); } /*****************************************************************************/ diff --git a/src/core/tests/test-utils.c b/src/core/tests/test-utils.c index 1d562bde..59d5fd53 100644 --- a/src/core/tests/test-utils.c +++ b/src/core/tests/test-utils.c @@ -16,60 +16,55 @@ test_stable_privacy(void) struct in6_addr addr1; inet_pton(AF_INET6, "1234::", &addr1); - nm_utils_ipv6_addr_set_stable_privacy_impl(NM_UTILS_STABLE_TYPE_UUID, - &addr1, - "eth666", - "6b138152-9f3e-4b97-aaf7-e6e553f2a24e", - 0, - (guint8 *) "key", - 3, - NULL); + nm_utils_ipv6_addr_set_stable_privacy_with_host_id(NM_UTILS_STABLE_TYPE_UUID, + &addr1, + "eth666", + "6b138152-9f3e-4b97-aaf7-e6e553f2a24e", + 0, + (guint8 *) "key", + 3); nmtst_assert_ip6_address(&addr1, "1234::4ceb:14cd:3d54:793f"); /* We get an address without the UUID. */ inet_pton(AF_INET6, "1::", &addr1); - nm_utils_ipv6_addr_set_stable_privacy_impl(NM_UTILS_STABLE_TYPE_UUID, - &addr1, - "eth666", - "", - 384, - (guint8 *) "key", - 3, - NULL); + nm_utils_ipv6_addr_set_stable_privacy_with_host_id(NM_UTILS_STABLE_TYPE_UUID, + &addr1, + "eth666", + "", + 384, + (guint8 *) "key", + 3); nmtst_assert_ip6_address(&addr1, "1::11aa:2530:9144:dafa"); /* We get a different address in a different network. */ inet_pton(AF_INET6, "2::", &addr1); - nm_utils_ipv6_addr_set_stable_privacy_impl(NM_UTILS_STABLE_TYPE_UUID, - &addr1, - "eth666", - "", - 384, - (guint8 *) "key", - 3, - NULL); + nm_utils_ipv6_addr_set_stable_privacy_with_host_id(NM_UTILS_STABLE_TYPE_UUID, + &addr1, + "eth666", + "", + 384, + (guint8 *) "key", + 3); nmtst_assert_ip6_address(&addr1, "2::338e:8d:c11:8726"); inet_pton(AF_INET6, "1234::", &addr1); - nm_utils_ipv6_addr_set_stable_privacy_impl(NM_UTILS_STABLE_TYPE_STABLE_ID, - &addr1, - "eth666", - "6b138152-9f3e-4b97-aaf7-e6e553f2a24e", - 0, - (guint8 *) "key", - 3, - NULL); + nm_utils_ipv6_addr_set_stable_privacy_with_host_id(NM_UTILS_STABLE_TYPE_STABLE_ID, + &addr1, + "eth666", + "6b138152-9f3e-4b97-aaf7-e6e553f2a24e", + 0, + (guint8 *) "key", + 3); nmtst_assert_ip6_address(&addr1, "1234::ad4c:ae44:3d30:af1e"); inet_pton(AF_INET6, "1234::", &addr1); - nm_utils_ipv6_addr_set_stable_privacy_impl(NM_UTILS_STABLE_TYPE_STABLE_ID, - &addr1, - "eth666", - "stable-id-1", - 0, - (guint8 *) "key", - 3, - NULL); + nm_utils_ipv6_addr_set_stable_privacy_with_host_id(NM_UTILS_STABLE_TYPE_STABLE_ID, + &addr1, + "eth666", + "stable-id-1", + 0, + (guint8 *) "key", + 3); nmtst_assert_ip6_address(&addr1, "1234::4944:67b0:7a6c:1cf"); } diff --git a/src/core/vpn/nm-vpn-connection.c b/src/core/vpn/nm-vpn-connection.c index d06ca46a..d2034278 100644 --- a/src/core/vpn/nm-vpn-connection.c +++ b/src/core/vpn/nm-vpn-connection.c @@ -1659,6 +1659,7 @@ nm_vpn_connection_ip4_config_get(NMVpnConnection *self, GVariant *dict) s_ip, nm_setting_connection_get_mdns(s_con), nm_setting_connection_get_llmnr(s_con), + nm_setting_connection_get_dns_over_tls(s_con), route_table, route_metric); diff --git a/src/libnm-base/meson.build b/src/libnm-base/meson.build index d7e7a1b8..1bb61020 100644 --- a/src/libnm-base/meson.build +++ b/src/libnm-base/meson.build @@ -5,6 +5,7 @@ libnm_base = static_library( sources: files( 'nm-ethtool-base.c', 'nm-net-aux.c', + 'nm-priv-helper-utils.c', ), include_directories: [ src_inc, diff --git a/src/libnm-base/nm-base.h b/src/libnm-base/nm-base.h index 3257b3f0..0363e3b6 100644 --- a/src/libnm-base/nm-base.h +++ b/src/libnm-base/nm-base.h @@ -13,6 +13,11 @@ #define _NM_MAX_CLIENT_ID_LEN (sizeof(guint32) + 128) +enum { + NM_DNS_PRIORITY_DEFAULT_NORMAL = 100, + NM_DNS_PRIORITY_DEFAULT_VPN = 50, +}; + /*****************************************************************************/ typedef enum { @@ -386,4 +391,6 @@ typedef struct { /****************************************************************************/ +#define NM_BOND_PORT_QUEUE_ID_DEF 0 + #endif /* __NM_LIBNM_BASE_H__ */ diff --git a/src/libnm-base/nm-priv-helper-utils.c b/src/libnm-base/nm-priv-helper-utils.c new file mode 100644 index 00000000..8e6e4075 --- /dev/null +++ b/src/libnm-base/nm-priv-helper-utils.c @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include "libnm-glib-aux/nm-default-glib-i18n-lib.h" + +#include "nm-priv-helper-utils.h" + +#include +#include + +#include "libnm-glib-aux/nm-io-utils.h" + +/*****************************************************************************/ + +int +nm_priv_helper_utils_open_fd(NMPrivHelperGetFDType fd_type, GError **error) +{ + nm_auto_close int fd = -1; + int r; + int errsv; + + switch (fd_type) { + case NM_PRIV_HELPER_GET_FD_TYPE_OVSDB_SOCKET: + { + struct sockaddr_un sock; + int sock_len; + + G_STATIC_ASSERT_EXPR(NM_STRLEN(NM_OVSDB_SOCKET) + 1 < sizeof(sock.sun_path)); + sock_len = nm_io_sockaddr_un_set(&sock, FALSE, NM_OVSDB_SOCKET); + nm_assert(sock_len > 0); + + fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); + if (fd < 0) { + errsv = NM_ERRNO_NATIVE(errno); + g_set_error(error, G_IO_ERROR, g_io_error_from_errno(errsv), "error creating socket"); + return -errsv; + } + + r = connect(fd, (const struct sockaddr *) &sock, sock_len); + if (r != 0) { + errsv = NM_ERRNO_NATIVE(errno); + g_set_error(error, + G_IO_ERROR, + g_io_error_from_errno(errsv), + "error connecting socket (%s)", + nm_strerror_native(errsv)); + return -errsv; + } + + return nm_steal_fd(&fd); + } + case NM_PRIV_HELPER_GET_FD_TYPE_NONE: + default: + nm_utils_error_set(error, NM_UTILS_ERROR_UNKNOWN, "invalid fd_type"); + return -EINVAL; + } +} diff --git a/src/libnm-base/nm-priv-helper-utils.h b/src/libnm-base/nm-priv-helper-utils.h new file mode 100644 index 00000000..22387cff --- /dev/null +++ b/src/libnm-base/nm-priv-helper-utils.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#ifndef __NM_PRIV_HELPER_UTILS_H__ +#define __NM_PRIV_HELPER_UTILS_H__ + +/*****************************************************************************/ + +#define NM_PRIV_HELPER_DBUS_BUS_NAME "org.freedesktop.nm-priv-helper" +#define NM_PRIV_HELPER_DBUS_OBJECT_PATH "/org/freedesktop/nm-priv-helper" +#define NM_PRIV_HELPER_DBUS_IFACE_NAME "org.freedesktop.nm-priv-helper" + +/*****************************************************************************/ + +#define NM_OVSDB_SOCKET RUNSTATEDIR "/openvswitch/db.sock" + +typedef enum { + NM_PRIV_HELPER_GET_FD_TYPE_NONE = 0, + NM_PRIV_HELPER_GET_FD_TYPE_OVSDB_SOCKET = 1, +} NMPrivHelperGetFDType; + +int nm_priv_helper_utils_open_fd(NMPrivHelperGetFDType fd_type, GError **error); + +#endif /* __NM_PRIV_HELPER_UTILS_H__ */ diff --git a/src/libnm-client-aux-extern/README.md b/src/libnm-client-aux-extern/README.md index 460b269e..7d3b27e8 100644 --- a/src/libnm-client-aux-extern/README.md +++ b/src/libnm-client-aux-extern/README.md @@ -1,4 +1,7 @@ -nm-libnm-aux is a static library that: +libnm-client-aux-extern +======================= + +libnm-client-aux-extern is a static library that: - uses the public parts of "libnm" - that can also be statically linked into other users of libnm. @@ -10,6 +13,10 @@ That means: - you can use it everywhere where you dynamically link with libnm. -Also, since nm-libnm-aux itself only uses public (stable) +Also, since libnm-client-aux-extern itself only uses public (stable) API of libnm, you theoretically can copy the sources into your own source tree. + +This makes it very similar in purpose to [../libnmc-base/](../libnmc-base/). +The difference might be that this one is smaller and that you could easier +copy+paste this to a libnm application outside this source tree. diff --git a/src/libnm-client-impl/libnm.pc.in b/src/libnm-client-impl/libnm.pc.in index afc5e4d9..c65b80df 100644 --- a/src/libnm-client-impl/libnm.pc.in +++ b/src/libnm-client-impl/libnm.pc.in @@ -3,6 +3,8 @@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ vpnservicedir=@nmlibdir@/VPN +plugindir=@libdir@/NetworkManager +configdir=@sysconfdir@/NetworkManager Name: libnm Description: Convenience library for clients of NetworkManager diff --git a/src/libnm-client-impl/libnm.ver b/src/libnm-client-impl/libnm.ver index 89a99af8..ce07a876 100644 --- a/src/libnm-client-impl/libnm.ver +++ b/src/libnm-client-impl/libnm.ver @@ -1785,6 +1785,12 @@ global: nm_utils_print; } libnm_1_28_0; +libnm_1_30_8 { + #nm_ip_address_dup@libnm_1_30_8; + #nm_ip_route_dup@libnm_1_30_8; + #nm_setting_ip_config_get_required_timeout@libnm_1_30_8; +} libnm_1_30_0; + libnm_1_32_0 { global: nm_ethtool_optname_is_pause; @@ -1798,3 +1804,15 @@ libnm_1_32_4 { global: nm_setting_ip_config_get_required_timeout; } libnm_1_32_0; + +libnm_1_34_0 { +global: + nm_device_get_ports; + nm_ip_routing_rule_get_uid_range; + nm_ip_routing_rule_set_uid_range; + nm_setting_bond_port_get_queue_id; + nm_setting_bond_port_get_type; + nm_setting_bond_port_new; + nm_setting_connection_get_dns_over_tls; + nm_setting_connection_dns_over_tls_get_type; +} libnm_1_32_4; diff --git a/src/libnm-client-impl/nm-client.c b/src/libnm-client-impl/nm-client.c index 4cbd56dc..0f9d8fe1 100644 --- a/src/libnm-client-impl/nm-client.c +++ b/src/libnm-client-impl/nm-client.c @@ -2118,7 +2118,7 @@ nml_dbus_property_ao_notify_watch_cb(NMClient *self, gpointer obj_watcher) _ASSERT_pr_ao(pr_ao); } -static NMLDBusNotifyUpdatePropFlags +NMLDBusNotifyUpdatePropFlags nml_dbus_property_ao_notify(NMClient * self, NMLDBusPropertyAO * pr_ao, NMLDBusObject * dbobj, @@ -2266,9 +2266,11 @@ nml_dbus_property_ao_notify(NMClient * self, return NML_DBUS_NOTIFY_UPDATE_PROP_FLAGS_NONE; } -void +gboolean nml_dbus_property_ao_clear(NMLDBusPropertyAO *pr_ao, NMClient *self) { + gboolean changed_prop = FALSE; + _ASSERT_pr_ao(pr_ao); if (!pr_ao->owner_dbobj) { @@ -2281,7 +2283,6 @@ nml_dbus_property_ao_clear(NMLDBusPropertyAO *pr_ao, NMClient *self) nm_assert(!pr_ao->is_changed); } else { PropertyAOData *pr_ao_data; - gboolean changed_prop = FALSE; nm_assert(NM_IS_CLIENT(self)); nm_assert(pr_ao->data_lst_head.next); @@ -2329,6 +2330,8 @@ nml_dbus_property_ao_clear(NMLDBusPropertyAO *pr_ao, NMClient *self) } nm_clear_pointer(&pr_ao->arr, g_ptr_array_unref); + + return changed_prop; } void @@ -2404,7 +2407,7 @@ _obj_handle_dbus_prop_changes(NMClient * self, value = NULL; } - if (meta_property->use_notify_update_prop) { + if (meta_property->notify_update_prop) { notify_update_prop_flags = meta_property->notify_update_prop(self, dbobj, meta_iface, dbus_property_idx, value); if (notify_update_prop_flags == NML_DBUS_NOTIFY_UPDATE_PROP_FLAGS_NONE) @@ -8832,3 +8835,17 @@ NM_BACKPORT_SYMBOL(libnm_1_10_14, (NMSettingConnection * setting), (setting)); NM_BACKPORT_SYMBOL(libnm_1_10_14, GType, nm_setting_connection_mdns_get_type, (void), ()); + +NM_BACKPORT_SYMBOL(libnm_1_30_8, + int, + nm_setting_ip_config_get_required_timeout, + (NMSettingIPConfig * setting), + (setting)); + +NM_BACKPORT_SYMBOL(libnm_1_30_8, + NMIPAddress *, + nm_ip_address_dup, + (NMIPAddress * address), + (address)); + +NM_BACKPORT_SYMBOL(libnm_1_30_8, NMIPRoute *, nm_ip_route_dup, (NMIPRoute * route), (route)); diff --git a/src/libnm-client-impl/nm-dbus-helpers.h b/src/libnm-client-impl/nm-dbus-helpers.h index e519f733..5a6b2d62 100644 --- a/src/libnm-client-impl/nm-dbus-helpers.h +++ b/src/libnm-client-impl/nm-dbus-helpers.h @@ -7,7 +7,7 @@ #define __NM_DBUS_HELPERS_PRIVATE_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #include "libnm-std-aux/nm-dbus-compat.h" diff --git a/src/libnm-client-impl/nm-device-bond.c b/src/libnm-client-impl/nm-device-bond.c index 48dfd9b2..add54639 100644 --- a/src/libnm-client-impl/nm-device-bond.c +++ b/src/libnm-client-impl/nm-device-bond.c @@ -18,9 +18,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_CARRIER, PROP_SLAVES, ); typedef struct { - NMLDBusPropertyAO slaves; - char * hw_address; - bool carrier; + bool carrier; } NMDeviceBondPrivate; struct _NMDeviceBond { @@ -83,13 +81,13 @@ nm_device_bond_get_carrier(NMDeviceBond *device) * Returns: (element-type NMDevice): the #GPtrArray containing * #NMDevices that are slaves of @device. This is the internal * copy used by the device, and must not be modified. + * + * Deprecated: 1.34 Use nm_device_get_ports() instead. **/ const GPtrArray * nm_device_bond_get_slaves(NMDeviceBond *device) { - g_return_val_if_fail(NM_IS_DEVICE_BOND(device), FALSE); - - return nml_dbus_property_ao_get_objs_as_ptrarray(&NM_DEVICE_BOND_GET_PRIVATE(device)->slaves); + return nm_device_get_ports(NM_DEVICE(device)); } static gboolean @@ -124,16 +122,6 @@ static void nm_device_bond_init(NMDeviceBond *device) {} -static void -finalize(GObject *object) -{ - NMDeviceBondPrivate *priv = NM_DEVICE_BOND_GET_PRIVATE(object); - - g_free(priv->hw_address); - - G_OBJECT_CLASS(nm_device_bond_parent_class)->finalize(object); -} - static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { @@ -162,11 +150,10 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_bond = NML_DBUS_META_IFACE 0, "s", _nm_device_notify_update_prop_hw_address), - NML_DBUS_META_PROPERTY_INIT_AO_PROP("Slaves", - PROP_SLAVES, - NMDeviceBond, - _priv.slaves, - nm_device_get_type), ), ); + NML_DBUS_META_PROPERTY_INIT_FCN("Slaves", + PROP_SLAVES, + "ao", + _nm_device_notify_update_prop_ports), ), ); static void nm_device_bond_class_init(NMDeviceBondClass *klass) @@ -176,12 +163,9 @@ nm_device_bond_class_init(NMDeviceBondClass *klass) NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->get_property = get_property; - object_class->finalize = finalize; _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT(nm_object_class, NMDeviceBond); - _NM_OBJECT_CLASS_INIT_PROPERTY_AO_FIELDS_1(nm_object_class, NMDeviceBondPrivate, slaves); - device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; @@ -208,4 +192,6 @@ nm_device_bond_class_init(NMDeviceBondClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); _nml_dbus_meta_class_init_with_properties(object_class, &_nml_dbus_meta_iface_nm_device_bond); + + device_class->slaves_param_spec = obj_properties[PROP_SLAVES]; } diff --git a/src/libnm-client-impl/nm-device-bridge.c b/src/libnm-client-impl/nm-device-bridge.c index 9bc41ac8..fb0ad873 100644 --- a/src/libnm-client-impl/nm-device-bridge.c +++ b/src/libnm-client-impl/nm-device-bridge.c @@ -18,8 +18,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_CARRIER, PROP_SLAVES, ); typedef struct { - NMLDBusPropertyAO slaves; - bool carrier; + bool carrier; } NMDeviceBridgePrivate; struct _NMDeviceBridge { @@ -82,13 +81,13 @@ nm_device_bridge_get_carrier(NMDeviceBridge *device) * Returns: (element-type NMDevice): the #GPtrArray containing * #NMDevices that are slaves of @device. This is the internal * copy used by the device, and must not be modified. + * + * Deprecated: 1.34 Use nm_device_get_ports() instead. **/ const GPtrArray * nm_device_bridge_get_slaves(NMDeviceBridge *device) { - g_return_val_if_fail(NM_IS_DEVICE_BRIDGE(device), FALSE); - - return nml_dbus_property_ao_get_objs_as_ptrarray(&NM_DEVICE_BRIDGE_GET_PRIVATE(device)->slaves); + return nm_device_get_ports(NM_DEVICE(device)); } static gboolean @@ -156,11 +155,10 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_bridge = NML_DBUS_META_IFA 0, "s", _nm_device_notify_update_prop_hw_address), - NML_DBUS_META_PROPERTY_INIT_AO_PROP("Slaves", - PROP_SLAVES, - NMDeviceBridge, - _priv.slaves, - nm_device_get_type), ), ); + NML_DBUS_META_PROPERTY_INIT_FCN("Slaves", + PROP_SLAVES, + "ao", + _nm_device_notify_update_prop_ports), ), ); static void nm_device_bridge_class_init(NMDeviceBridgeClass *klass) @@ -173,8 +171,6 @@ nm_device_bridge_class_init(NMDeviceBridgeClass *klass) _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT(nm_object_class, NMDeviceBridge); - _NM_OBJECT_CLASS_INIT_PROPERTY_AO_FIELDS_1(nm_object_class, NMDeviceBridgePrivate, slaves); - device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; @@ -201,4 +197,6 @@ nm_device_bridge_class_init(NMDeviceBridgeClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); _nml_dbus_meta_class_init_with_properties(object_class, &_nml_dbus_meta_iface_nm_device_bridge); + + device_class->slaves_param_spec = obj_properties[PROP_SLAVES]; } diff --git a/src/libnm-client-impl/nm-device-ovs-bridge.c b/src/libnm-client-impl/nm-device-ovs-bridge.c index 898a41fa..465957c4 100644 --- a/src/libnm-client-impl/nm-device-ovs-bridge.c +++ b/src/libnm-client-impl/nm-device-ovs-bridge.c @@ -17,13 +17,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_SLAVES, ); -typedef struct { - NMLDBusPropertyAO slaves; -} NMDeviceOvsBridgePrivate; - struct _NMDeviceOvsBridge { - NMDevice parent; - NMDeviceOvsBridgePrivate _priv; + NMDevice parent; }; struct _NMDeviceOvsBridgeClass { @@ -48,14 +43,13 @@ G_DEFINE_TYPE(NMDeviceOvsBridge, nm_device_ovs_bridge, NM_TYPE_DEVICE) * copy used by the device, and must not be modified. * * Since: 1.14 + * + * Deprecated: 1.34 Use nm_device_get_ports() instead. **/ const GPtrArray * nm_device_ovs_bridge_get_slaves(NMDeviceOvsBridge *device) { - g_return_val_if_fail(NM_IS_DEVICE_OVS_BRIDGE(device), FALSE); - - return nml_dbus_property_ao_get_objs_as_ptrarray( - &NM_DEVICE_OVS_BRIDGE_GET_PRIVATE(device)->slaves); + return nm_device_get_ports(NM_DEVICE(device)); } static const char * @@ -123,30 +117,24 @@ static void nm_device_ovs_bridge_init(NMDeviceOvsBridge *device) {} -const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_ovsbridge = - NML_DBUS_META_IFACE_INIT_PROP(NM_DBUS_INTERFACE_DEVICE_OVS_BRIDGE, - nm_device_ovs_bridge_get_type, - NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, - NML_DBUS_META_IFACE_DBUS_PROPERTIES( - NML_DBUS_META_PROPERTY_INIT_AO_PROP("Slaves", - PROP_SLAVES, - NMDeviceOvsBridge, - _priv.slaves, - nm_device_get_type), ), ); +const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_ovsbridge = NML_DBUS_META_IFACE_INIT_PROP( + NM_DBUS_INTERFACE_DEVICE_OVS_BRIDGE, + nm_device_ovs_bridge_get_type, + NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, + NML_DBUS_META_IFACE_DBUS_PROPERTIES( + NML_DBUS_META_PROPERTY_INIT_FCN("Slaves", + PROP_SLAVES, + "ao", + _nm_device_notify_update_prop_ports), ), ); static void nm_device_ovs_bridge_class_init(NMDeviceOvsBridgeClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); - NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); + GObjectClass * object_class = G_OBJECT_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->get_property = get_property; - _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT(nm_object_class, NMDeviceOvsBridge); - - _NM_OBJECT_CLASS_INIT_PROPERTY_AO_FIELDS_1(nm_object_class, NMDeviceOvsBridgePrivate, slaves); - device_class->get_type_description = get_type_description; device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; @@ -166,4 +154,6 @@ nm_device_ovs_bridge_class_init(NMDeviceOvsBridgeClass *klass) _nml_dbus_meta_class_init_with_properties(object_class, &_nml_dbus_meta_iface_nm_device_ovsbridge); + + device_class->slaves_param_spec = obj_properties[PROP_SLAVES]; } diff --git a/src/libnm-client-impl/nm-device-ovs-port.c b/src/libnm-client-impl/nm-device-ovs-port.c index db30e1c7..76ae7a58 100644 --- a/src/libnm-client-impl/nm-device-ovs-port.c +++ b/src/libnm-client-impl/nm-device-ovs-port.c @@ -17,13 +17,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_SLAVES, ); -typedef struct { - NMLDBusPropertyAO slaves; -} NMDeviceOvsPortPrivate; - struct _NMDeviceOvsPort { - NMDevice parent; - NMDeviceOvsPortPrivate _priv; + NMDevice parent; }; struct _NMDeviceOvsPortClass { @@ -48,14 +43,13 @@ G_DEFINE_TYPE(NMDeviceOvsPort, nm_device_ovs_port, NM_TYPE_DEVICE) * copy used by the device, and must not be modified. * * Since: 1.14 + * + * Deprecated: 1.34 Use nm_device_get_ports() instead. **/ const GPtrArray * nm_device_ovs_port_get_slaves(NMDeviceOvsPort *device) { - g_return_val_if_fail(NM_IS_DEVICE_OVS_PORT(device), FALSE); - - return nml_dbus_property_ao_get_objs_as_ptrarray( - &NM_DEVICE_OVS_PORT_GET_PRIVATE(device)->slaves); + return nm_device_get_ports(NM_DEVICE(device)); } static const char * @@ -123,30 +117,24 @@ static void nm_device_ovs_port_init(NMDeviceOvsPort *device) {} -const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_ovsport = - NML_DBUS_META_IFACE_INIT_PROP(NM_DBUS_INTERFACE_DEVICE_OVS_PORT, - nm_device_ovs_port_get_type, - NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, - NML_DBUS_META_IFACE_DBUS_PROPERTIES( - NML_DBUS_META_PROPERTY_INIT_AO_PROP("Slaves", - PROP_SLAVES, - NMDeviceOvsPort, - _priv.slaves, - nm_device_get_type), ), ); +const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_ovsport = NML_DBUS_META_IFACE_INIT_PROP( + NM_DBUS_INTERFACE_DEVICE_OVS_PORT, + nm_device_ovs_port_get_type, + NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30, + NML_DBUS_META_IFACE_DBUS_PROPERTIES( + NML_DBUS_META_PROPERTY_INIT_FCN("Slaves", + PROP_SLAVES, + "ao", + _nm_device_notify_update_prop_ports), ), ); static void nm_device_ovs_port_class_init(NMDeviceOvsPortClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass); - NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); + GObjectClass * object_class = G_OBJECT_CLASS(klass); + NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->get_property = get_property; - _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT(nm_object_class, NMDeviceOvsPort); - - _NM_OBJECT_CLASS_INIT_PROPERTY_AO_FIELDS_1(nm_object_class, NMDeviceOvsPortPrivate, slaves); - device_class->get_type_description = get_type_description; device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; @@ -166,4 +154,6 @@ nm_device_ovs_port_class_init(NMDeviceOvsPortClass *klass) _nml_dbus_meta_class_init_with_properties(object_class, &_nml_dbus_meta_iface_nm_device_ovsport); + + device_class->slaves_param_spec = obj_properties[PROP_SLAVES]; } diff --git a/src/libnm-client-impl/nm-device-team.c b/src/libnm-client-impl/nm-device-team.c index ca29c9f7..9f7fe768 100644 --- a/src/libnm-client-impl/nm-device-team.c +++ b/src/libnm-client-impl/nm-device-team.c @@ -18,9 +18,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_CARRIER, PROP_SLAVES, PROP_CONFIG, ); typedef struct { - NMLDBusPropertyAO slaves; - char * config; - bool carrier; + char *config; + bool carrier; } NMDeviceTeamPrivate; struct _NMDeviceTeam { @@ -83,13 +82,13 @@ nm_device_team_get_carrier(NMDeviceTeam *device) * Returns: (element-type NMDevice): the #GPtrArray containing * #NMDevices that are slaves of @device. This is the internal * copy used by the device, and must not be modified. + * + * Deprecated: 1.34 Use nm_device_get_ports() instead. **/ const GPtrArray * nm_device_team_get_slaves(NMDeviceTeam *device) { - g_return_val_if_fail(NM_IS_DEVICE_TEAM(device), FALSE); - - return nml_dbus_property_ao_get_objs_as_ptrarray(&NM_DEVICE_TEAM_GET_PRIVATE(device)->slaves); + return nm_device_get_ports(NM_DEVICE(device)); } /** @@ -185,11 +184,10 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_team = NML_DBUS_META_IFACE 0, "s", _nm_device_notify_update_prop_hw_address), - NML_DBUS_META_PROPERTY_INIT_AO_PROP("Slaves", - PROP_SLAVES, - NMDeviceTeam, - _priv.slaves, - nm_device_get_type), ), ); + NML_DBUS_META_PROPERTY_INIT_FCN("Slaves", + PROP_SLAVES, + "ao", + _nm_device_notify_update_prop_ports), ), ); static void nm_device_team_class_init(NMDeviceTeamClass *klass) @@ -203,8 +201,6 @@ nm_device_team_class_init(NMDeviceTeamClass *klass) _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT(nm_object_class, NMDeviceTeam); - _NM_OBJECT_CLASS_INIT_PROPERTY_AO_FIELDS_1(nm_object_class, NMDeviceTeamPrivate, slaves); - device_class->connection_compatible = connection_compatible; device_class->get_setting_type = get_setting_type; @@ -244,4 +240,6 @@ nm_device_team_class_init(NMDeviceTeamClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); _nml_dbus_meta_class_init_with_properties(object_class, &_nml_dbus_meta_iface_nm_device_team); + + device_class->slaves_param_spec = obj_properties[PROP_SLAVES]; } diff --git a/src/libnm-client-impl/nm-device-wifi.c b/src/libnm-client-impl/nm-device-wifi.c index fee7e8a2..cfbbea23 100644 --- a/src/libnm-client-impl/nm-device-wifi.c +++ b/src/libnm-client-impl/nm-device-wifi.c @@ -242,7 +242,7 @@ nm_device_wifi_get_access_point_by_path(NMDeviceWifi *device, const char *path) * Use nm_utils_get_timestamp_msec() to obtain current time value suitable for * comparing to this value. * - * Returns: the last scan time in seconds + * Returns: the last scan time in milliseconds (in clock_gettime(CLOCK_BOOTTIME) scale). * * Since: 1.12 **/ diff --git a/src/libnm-client-impl/nm-device.c b/src/libnm-client-impl/nm-device.c index 4d097935..a680a05f 100644 --- a/src/libnm-client-impl/nm-device.c +++ b/src/libnm-client-impl/nm-device.c @@ -61,7 +61,8 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMDevice, PROP_IP4_CONNECTIVITY, PROP_IP6_CONNECTIVITY, PROP_INTERFACE_FLAGS, - PROP_HW_ADDRESS, ); + PROP_HW_ADDRESS, + PROP_PORTS, ); enum { STATE_CHANGED, @@ -80,9 +81,15 @@ enum { _PROPERTY_O_IDX_NUM, }; +enum { + PROPERTY_AO_IDX_AVAILABLE_CONNECTIONS, + PROPERTY_AO_IDX_PORTS, + _PROPERTY_AO_IDX_NUM, +}; + typedef struct _NMDevicePrivate { NMLDBusPropertyO property_o[_PROPERTY_O_IDX_NUM]; - NMLDBusPropertyAO available_connections; + NMLDBusPropertyAO property_ao[_PROPERTY_AO_IDX_NUM]; GPtrArray * lldp_neighbors; char * driver; char * driver_version; @@ -109,6 +116,7 @@ typedef struct _NMDevicePrivate { bool real; bool hw_address_is_new : 1; + bool ports_is_new : 1; guint32 old_state; @@ -457,6 +465,9 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) case PROP_HW_ADDRESS: g_value_set_string(value, nm_device_get_hw_address(device)); break; + case PROP_PORTS: + g_value_take_boxed(value, _nm_utils_copy_object_array(nm_device_get_ports(device))); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -509,7 +520,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device = NML_DBUS_META_IFACE_INIT NML_DBUS_META_PROPERTY_INIT_AO_PROP("AvailableConnections", PROP_AVAILABLE_CONNECTIONS, NMDevicePrivate, - available_connections, + property_ao[PROPERTY_AO_IDX_AVAILABLE_CONNECTIONS], nm_remote_connection_get_type, .is_always_ready = TRUE), NML_DBUS_META_PROPERTY_INIT_U("Capabilities", @@ -588,6 +599,15 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device = NML_DBUS_META_IFACE_INIT PROP_PHYSICAL_PORT_ID, NMDevicePrivate, physical_port_id), + NML_DBUS_META_PROPERTY_INIT_FCN( + "Ports", + PROP_PORTS, + "ao", + _nm_device_notify_update_prop_ports, + .prop_struct_offset = + G_STRUCT_OFFSET(NMDevicePrivate, property_ao[PROPERTY_AO_IDX_PORTS]), + .extra.property_vtable_ao = + &((const NMLDBusPropertVTableAO){.get_o_type_fcn = (nm_device_get_type)})), NML_DBUS_META_PROPERTY_INIT_B("Real", PROP_REAL, NMDevicePrivate, real), NML_DBUS_META_PROPERTY_INIT_IGNORE("State", "u"), NML_DBUS_META_PROPERTY_INIT_FCN("StateReason", @@ -595,6 +615,7 @@ const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device = NML_DBUS_META_IFACE_INIT "(uu)", _notify_update_prop_state_reason), NML_DBUS_META_PROPERTY_INIT_S("Udi", PROP_UDI, NMDevicePrivate, udi), ), + .base_struct_offset = G_STRUCT_OFFSET(NMDevice, _priv), ); static void @@ -614,9 +635,7 @@ nm_device_class_init(NMDeviceClass *klass) _NM_OBJECT_CLASS_INIT_PRIV_PTR_INDIRECT(nm_object_class, NMDevice); _NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_N(nm_object_class, NMDevicePrivate, property_o); - _NM_OBJECT_CLASS_INIT_PROPERTY_AO_FIELDS_1(nm_object_class, - NMDevicePrivate, - available_connections); + _NM_OBJECT_CLASS_INIT_PROPERTY_AO_FIELDS_N(nm_object_class, NMDevicePrivate, property_ao); klass->connection_compatible = connection_compatible; @@ -1034,6 +1053,20 @@ nm_device_class_init(NMDeviceClass *klass) NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + /** + * NMDevice:ports: + * + * The port devices of the controller device. For devices that cannot be + * controllers this is likely to be always empty. + * + * Since: 1.34 + **/ + obj_properties[PROP_PORTS] = g_param_spec_boxed(NM_DEVICE_PORTS, + "", + "", + G_TYPE_PTR_ARRAY, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + _nml_dbus_meta_class_init_with_properties(object_class, &_nml_dbus_meta_iface_nm_device); /** @@ -1241,6 +1274,27 @@ nm_device_get_type_description(NMDevice *device) return _nml_coerce_property_str_not_empty(priv->type_description); } +/** + * nm_device_get_ports: + * @device: a #NMDevice + * + * Gets the devices currently set as port of @device. + * + * Returns: (element-type NMDevice): the #GPtrArray containing #NMDevices that + * are slaves of @device. This is the internal copy used by the device and + * must not be modified. + * + * Since: 1.34 + **/ +const GPtrArray * +nm_device_get_ports(NMDevice *device) +{ + g_return_val_if_fail(NM_IS_DEVICE(device), NULL); + + return nml_dbus_property_ao_get_objs_as_ptrarray( + &NM_DEVICE_GET_PRIVATE(device)->property_ao[PROPERTY_AO_IDX_PORTS]); +} + NMLDBusNotifyUpdatePropFlags _nm_device_notify_update_prop_hw_address(NMClient * client, NMLDBusObject * dbobj, @@ -1267,8 +1321,8 @@ _nm_device_notify_update_prop_hw_address(NMClient * client, priv->hw_address_is_new = is_new; - nm_utils_strdup_reset(&priv->hw_address, - _nml_coerce_property_str_not_empty(g_variant_get_string(value, NULL))); + nm_strdup_reset(&priv->hw_address, + _nml_coerce_property_str_not_empty(g_variant_get_string(value, NULL))); /* always emit a changed signal here, even if "priv->hw_address" might be unchanged. * We want to emit the signal because we received a PropertiesChanged signal on D-Bus, @@ -1305,6 +1359,48 @@ nm_device_get_hw_address(NMDevice *device) return priv->hw_address; } +NMLDBusNotifyUpdatePropFlags +_nm_device_notify_update_prop_ports(NMClient * client, + NMLDBusObject * dbobj, + const NMLDBusMetaIface *meta_iface, + guint dbus_property_idx, + GVariant * value) +{ + const NMLDBusMetaProperty *meta_property = + &_nml_dbus_meta_iface_nm_device.dbus_properties[_NML_DEVICE_META_PROPERTY_INDEX_PORTS]; + NMLDBusNotifyUpdatePropFlags notify_update_prop_flags; + NMDevice * self = NM_DEVICE(dbobj->nmobj); + NMDevicePrivate * priv = NM_DEVICE_GET_PRIVATE(self); + NMDeviceClass * klass; + gboolean is_new = (meta_iface == &_nml_dbus_meta_iface_nm_device); + + nm_assert(nm_streq(meta_property->dbus_property_name, "Ports")); + + if (!is_new && priv->ports_is_new) { + /* once the instance is marked to honor the new property, the + * changed signal for the old variant gets ignored. */ + goto out; + } + priv->ports_is_new = is_new; + + notify_update_prop_flags = + nml_dbus_property_ao_notify(client, + &priv->property_ao[PROPERTY_AO_IDX_PORTS], + dbobj, + &_nml_dbus_meta_iface_nm_device, + _NML_DEVICE_META_PROPERTY_INDEX_PORTS, + value); + if (notify_update_prop_flags == NML_DBUS_NOTIFY_UPDATE_PROP_FLAGS_NONE) + goto out; + nm_assert(notify_update_prop_flags == NML_DBUS_NOTIFY_UPDATE_PROP_FLAGS_NOTIFY); + + klass = NM_DEVICE_GET_CLASS(self); + if (klass->slaves_param_spec) + _nm_client_queue_notify_object(client, self, klass->slaves_param_spec); +out: + return NML_DBUS_NOTIFY_UPDATE_PROP_FLAGS_NONE; +} + /** * nm_device_get_capabilities: * @device: a #NMDevice @@ -1652,7 +1748,7 @@ nm_device_get_available_connections(NMDevice *device) g_return_val_if_fail(NM_IS_DEVICE(device), NULL); return nml_dbus_property_ao_get_objs_as_ptrarray( - &NM_DEVICE_GET_PRIVATE(device)->available_connections); + &NM_DEVICE_GET_PRIVATE(device)->property_ao[PROPERTY_AO_IDX_AVAILABLE_CONNECTIONS]); } static const char * @@ -2770,7 +2866,7 @@ connection_compatible(NMDevice *device, NMConnection *connection, GError **error g_set_error(error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, - _("The interface names of the device and the connection didn't match.")); + _("The interface names of the device and the connection didn't match")); return FALSE; } @@ -2999,9 +3095,9 @@ nm_lldp_neighbor_get_attr_names(NMLldpNeighbor *neighbor) g_return_val_if_fail(NM_IS_LLDP_NEIGHBOR(neighbor), NULL); - keys = nm_utils_strdict_get_keys(neighbor->attrs, TRUE, NULL); + keys = nm_strdict_get_keys(neighbor->attrs, TRUE, NULL); - return nm_utils_strv_make_deep_copied_nonnull(keys); + return nm_strv_make_deep_copied_nonnull(keys); } /** diff --git a/src/libnm-client-impl/nm-dhcp4-config.h b/src/libnm-client-impl/nm-dhcp4-config.h index d0ea2b46..135720f0 100644 --- a/src/libnm-client-impl/nm-dhcp4-config.h +++ b/src/libnm-client-impl/nm-dhcp4-config.h @@ -7,7 +7,7 @@ #define __NM_DHCP4_CONFIG_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #include "nm-dhcp-config.h" diff --git a/src/libnm-client-impl/nm-dhcp6-config.h b/src/libnm-client-impl/nm-dhcp6-config.h index 253594e6..adaa5050 100644 --- a/src/libnm-client-impl/nm-dhcp6-config.h +++ b/src/libnm-client-impl/nm-dhcp6-config.h @@ -7,7 +7,7 @@ #define __NM_DHCP6_CONFIG_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #include "nm-dhcp-config.h" diff --git a/src/libnm-client-impl/nm-dns-manager.h b/src/libnm-client-impl/nm-dns-manager.h index 8053b243..e6159e61 100644 --- a/src/libnm-client-impl/nm-dns-manager.h +++ b/src/libnm-client-impl/nm-dns-manager.h @@ -7,7 +7,7 @@ #define __NM_DNS_MANAGER_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #include "nm-client.h" diff --git a/src/libnm-client-impl/nm-ip-config.c b/src/libnm-client-impl/nm-ip-config.c index 099dd088..5666888c 100644 --- a/src/libnm-client-impl/nm-ip-config.c +++ b/src/libnm-client-impl/nm-ip-config.c @@ -190,7 +190,7 @@ next: g_variant_iter_free(iter_v); } if (arr && arr->len > 0) - nameservers_new = nm_utils_strv_dup((char **) arr->pdata, arr->len, FALSE); + nameservers_new = nm_strv_dup((char **) arr->pdata, arr->len, FALSE); else nameservers_new = g_new0(char *, 1); } diff --git a/src/libnm-client-impl/nm-ip4-config.h b/src/libnm-client-impl/nm-ip4-config.h index b9297dc0..db82a0a5 100644 --- a/src/libnm-client-impl/nm-ip4-config.h +++ b/src/libnm-client-impl/nm-ip4-config.h @@ -8,7 +8,7 @@ #define __NM_IP4_CONFIG_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #include "nm-ip-config.h" diff --git a/src/libnm-client-impl/nm-ip6-config.h b/src/libnm-client-impl/nm-ip6-config.h index 0c7c2a9f..94386691 100644 --- a/src/libnm-client-impl/nm-ip6-config.h +++ b/src/libnm-client-impl/nm-ip6-config.h @@ -8,7 +8,7 @@ #define __NM_IP6_CONFIG_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #include "nm-ip-config.h" diff --git a/src/libnm-client-impl/nm-libnm-utils.c b/src/libnm-client-impl/nm-libnm-utils.c index 671466cf..4543eaa1 100644 --- a/src/libnm-client-impl/nm-libnm-utils.c +++ b/src/libnm-client-impl/nm-libnm-utils.c @@ -208,7 +208,7 @@ _fixup_string(const char * desc, if (eow) *eow = '\0'; - if (nm_utils_strv_find_first((char **) ignored_words, -1, p) >= 0) + if (nm_strv_find_first(ignored_words, -1, p) >= 0) goto next; l = strlen(p); diff --git a/src/libnm-client-impl/nm-libnm-utils.h b/src/libnm-client-impl/nm-libnm-utils.h index 3fd3b679..75e87064 100644 --- a/src/libnm-client-impl/nm-libnm-utils.h +++ b/src/libnm-client-impl/nm-libnm-utils.h @@ -303,7 +303,7 @@ const GPtrArray *nml_dbus_property_ao_get_objs_as_ptrarray(NMLDBusPropertyAO *pr gboolean nml_dbus_property_ao_is_ready(const NMLDBusPropertyAO *pr_ao); -void nml_dbus_property_ao_clear(NMLDBusPropertyAO *pr_ao, NMClient *client); +gboolean nml_dbus_property_ao_clear(NMLDBusPropertyAO *pr_ao, NMClient *client); void nml_dbus_property_ao_clear_many(NMLDBusPropertyAO *pr_ao, guint len, NMClient *self); @@ -328,30 +328,33 @@ NMLDBusNotifyUpdatePropFlags _nml_dbus_notify_update_prop_o(NMClient * guint dbus_property_idx, GVariant *value); +NMLDBusNotifyUpdatePropFlags nml_dbus_property_ao_notify(NMClient * self, + NMLDBusPropertyAO * pr_ao, + NMLDBusObject * dbobj, + const NMLDBusMetaIface *meta_iface, + guint dbus_property_idx, + GVariant * value); + typedef struct { const char * dbus_property_name; const GVariantType *dbus_type; + NMLDBusNotifyUpdatePropFlags (*notify_update_prop)(NMClient * client, + NMLDBusObject * dbobj, + const NMLDBusMetaIface *meta_iface, + guint dbus_property_idx, + GVariant * value); + guint16 prop_struct_offset; guint8 obj_properties_idx; - bool use_notify_update_prop : 1; - bool obj_property_no_reverse_idx : 1; union { - union { - const NMLDBusPropertVTableO * property_vtable_o; - const NMLDBusPropertVTableAO *property_vtable_ao; - } extra; - - NMLDBusNotifyUpdatePropFlags (*notify_update_prop)(NMClient * client, - NMLDBusObject * dbobj, - const NMLDBusMetaIface *meta_iface, - guint dbus_property_idx, - GVariant *value); - }; + const NMLDBusPropertVTableO * property_vtable_o; + const NMLDBusPropertVTableAO *property_vtable_ao; + } extra; } NMLDBusMetaProperty; @@ -395,17 +398,16 @@ typedef struct { #define NML_DBUS_META_PROPERTY_INIT_AY(...) \ _NML_DBUS_META_PROPERTY_INIT_DEFAULT("ay", GBytes *, __VA_ARGS__) -#define NML_DBUS_META_PROPERTY_INIT_O(v_dbus_property_name, \ - v_obj_properties_idx, \ - v_container, \ - v_field) \ - NML_DBUS_META_PROPERTY_INIT( \ - v_dbus_property_name, \ - "o", \ - v_obj_properties_idx, \ - .prop_struct_offset = NM_STRUCT_OFFSET_ENSURE_TYPE(NMRefString *, v_container, v_field), \ - .use_notify_update_prop = TRUE, \ - .notify_update_prop = _nml_dbus_notify_update_prop_o) +#define NML_DBUS_META_PROPERTY_INIT_O(v_dbus_property_name, \ + v_obj_properties_idx, \ + v_container, \ + v_field) \ + NML_DBUS_META_PROPERTY_INIT( \ + v_dbus_property_name, \ + "o", \ + v_obj_properties_idx, \ + .prop_struct_offset = NM_STRUCT_OFFSET_ENSURE_TYPE(NMRefString *, v_container, v_field), \ + .notify_update_prop = _nml_dbus_notify_update_prop_o) #define NML_DBUS_META_PROPERTY_INIT_O_PROP(v_dbus_property_name, \ v_obj_properties_idx, \ @@ -437,24 +439,22 @@ typedef struct { .extra.property_vtable_ao = &( \ (const NMLDBusPropertVTableAO){.get_o_type_fcn = (v_get_o_type_fcn), ##__VA_ARGS__})) -#define NML_DBUS_META_PROPERTY_INIT_FCN(v_dbus_property_name, \ - v_obj_properties_idx, \ - v_dbus_type, \ - v_notify_update_prop, \ - ...) \ - NML_DBUS_META_PROPERTY_INIT(v_dbus_property_name, \ - v_dbus_type, \ - v_obj_properties_idx, \ - .use_notify_update_prop = TRUE, \ - .notify_update_prop = (v_notify_update_prop), \ +#define NML_DBUS_META_PROPERTY_INIT_FCN(v_dbus_property_name, \ + v_obj_properties_idx, \ + v_dbus_type, \ + v_notify_update_prop, \ + ...) \ + NML_DBUS_META_PROPERTY_INIT(v_dbus_property_name, \ + v_dbus_type, \ + v_obj_properties_idx, \ + .notify_update_prop = (v_notify_update_prop), \ ##__VA_ARGS__) #define NML_DBUS_META_PROPERTY_INIT_IGNORE(v_dbus_property_name, v_dbus_type) \ NML_DBUS_META_PROPERTY_INIT(v_dbus_property_name, \ v_dbus_type, \ 0, \ - .use_notify_update_prop = TRUE, \ - .notify_update_prop = _nml_dbus_notify_update_prop_ignore) + .notify_update_prop = _nml_dbus_notify_update_prop_ignore) /* "TODO" is like "IGNORE". The difference is that we don't plan to ever implement "IGNORE", but * "TODO" is something we should add support for. */ @@ -758,21 +758,29 @@ struct _NMObjectClass { } \ G_STMT_END -#define _NM_OBJECT_CLASS_INIT_FIELD_INFO(_nm_object_class, _field_name, _offset, _num) \ - G_STMT_START \ - { \ - (_nm_object_class)->_field_name = ({ \ - static _NMObjectClassFieldInfo _f; \ - \ - _f = (_NMObjectClassFieldInfo){ \ - .parent = (_nm_object_class)->_field_name, \ - .klass = (_nm_object_class), \ - .offset = _offset, \ - .num = _num, \ - }; \ - &_f; \ - }); \ - } \ +#define _NM_OBJECT_CLASS_INIT_FIELD_INFO(nm_object_class, field_name, _offset, _num) \ + G_STMT_START \ + { \ + NMObjectClass *const _klass = (nm_object_class); \ + \ + _klass->field_name = ({ \ + static _NMObjectClassFieldInfo _f; \ + \ + /* this code is called inside a _class_init() function, it thus + * is only executed once, so we are fine to initialize a static + * variable here. */ \ + nm_assert(!_f.klass); \ + \ + _f = (_NMObjectClassFieldInfo){ \ + .parent = _klass->field_name, \ + .klass = _klass, \ + .offset = (_offset), \ + .num = (_num), \ + }; \ + \ + &_f; \ + }); \ + } \ G_STMT_END #define _NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_1(nm_object_class, type_name, field_name) \ @@ -820,8 +828,15 @@ struct _NMDeviceClass { const char *(*get_type_description)(NMDevice *device); GType (*get_setting_type)(NMDevice *device); + + /* Slaves was originally part of some subtypes of NMDevice. It was deprecated and + * a new NMDevice::ports property was added. When that property changes, we need + * to notify about the subclass' respective property. This is the property. */ + const GParamSpec *slaves_param_spec; }; +#define _NML_DEVICE_META_PROPERTY_INDEX_PORTS 27 + /*****************************************************************************/ struct _NMDeviceEthernetPrivate; @@ -1025,6 +1040,12 @@ _nm_device_notify_update_prop_hw_address(NMClient * client, guint dbus_property_idx, GVariant * value); +NMLDBusNotifyUpdatePropFlags _nm_device_notify_update_prop_ports(NMClient * client, + NMLDBusObject * dbobj, + const NMLDBusMetaIface *meta_iface, + guint dbus_property_idx, + GVariant *value); + /*****************************************************************************/ #endif /* __NM_LIBNM_UTILS_H__ */ diff --git a/src/libnm-client-impl/nm-object-private.h b/src/libnm-client-impl/nm-object-private.h index 9f78304d..11afc639 100644 --- a/src/libnm-client-impl/nm-object-private.h +++ b/src/libnm-client-impl/nm-object-private.h @@ -7,7 +7,7 @@ #define __NM_OBJECT_PRIVATE_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #include "nm-object.h" diff --git a/src/libnm-client-impl/nm-object.c b/src/libnm-client-impl/nm-object.c index 2e7de8c2..ae48853b 100644 --- a/src/libnm-client-impl/nm-object.c +++ b/src/libnm-client-impl/nm-object.c @@ -21,7 +21,7 @@ /*****************************************************************************/ -NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PATH, ); +NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PATH, PROP_CLIENT, ); typedef struct _NMObjectPrivate { NMClient * client; @@ -215,6 +215,8 @@ unregister_client(NMObject *self, NMClient *client, NMLDBusObject *dbobj) nm_assert(priv->client == client); priv->client = NULL; + _nm_client_queue_notify_object(client, self, obj_properties[PROP_CLIENT]); + clear_properties(self, client); } @@ -229,6 +231,9 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) case PROP_PATH: g_value_set_string(value, nm_object_get_path(self)); break; + case PROP_CLIENT: + g_value_set_object(value, nm_object_get_client(self)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -300,6 +305,10 @@ nm_object_class_init(NMObjectClass *klass) * NMObject:path: * * The D-Bus object path. + * + * The D-Bus path of an object instance never changes, even if the object + * gets removed from the cache. To see whether the object is still in the + * cache, check NMObject:client. **/ obj_properties[PROP_PATH] = g_param_spec_string(NM_OBJECT_PATH, "", @@ -307,5 +316,23 @@ nm_object_class_init(NMObjectClass *klass) NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + /** + * NMObject:client: + * + * The NMClient instance as returned by nm_object_get_client(). + * + * When an NMObject gets removed from the NMClient cache, + * the NMObject:path property stays unchanged, but this client + * instance gets reset to %NULL. You can use this property to + * track removal of the object from the cache. + * + * Since: 1.34 + **/ + obj_properties[PROP_CLIENT] = g_param_spec_object(NM_OBJECT_CLIENT, + "", + "", + NM_TYPE_CLIENT, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); } diff --git a/src/libnm-client-impl/nm-property-infos-dbus.xml b/src/libnm-client-impl/nm-property-infos-dbus.xml index 216ed1e7..009e1274 100644 --- a/src/libnm-client-impl/nm-property-infos-dbus.xml +++ b/src/libnm-client-impl/nm-property-infos-dbus.xml @@ -7,6 +7,8 @@ + + diff --git a/src/libnm-client-impl/nm-property-infos-ifcfg-rh.xml b/src/libnm-client-impl/nm-property-infos-ifcfg-rh.xml index df38ca79..15950eb8 100644 --- a/src/libnm-client-impl/nm-property-infos-ifcfg-rh.xml +++ b/src/libnm-client-impl/nm-property-infos-ifcfg-rh.xml @@ -45,6 +45,9 @@ + + + @@ -106,6 +109,7 @@ + diff --git a/src/libnm-client-impl/nm-property-infos-keyfile.xml b/src/libnm-client-impl/nm-property-infos-keyfile.xml index 486d61e9..78a7fc0b 100644 --- a/src/libnm-client-impl/nm-property-infos-keyfile.xml +++ b/src/libnm-client-impl/nm-property-infos-keyfile.xml @@ -7,6 +7,8 @@ + + diff --git a/src/libnm-client-impl/nm-property-infos-nmcli.xml b/src/libnm-client-impl/nm-property-infos-nmcli.xml index d6aa8a80..a234f3ce 100644 --- a/src/libnm-client-impl/nm-property-infos-nmcli.xml +++ b/src/libnm-client-impl/nm-property-infos-nmcli.xml @@ -7,6 +7,8 @@ + + @@ -71,6 +73,443 @@ + + + +Array of TC queueing disciplines. qdisc is a basic block in the +Linux traffic control subsystem + + +Each qdisc can be specified by the following attributes: + + + + +handle HANDLE + + + +specifies the qdisc handle. A qdisc, which potentially can have children, gets +assigned a major number, called a 'handle', leaving the minor number namespace +available for classes. The handle is expressed as '10:'. It is customary to +explicitly assign a handle to qdiscs expected to have children. + + + + + +parent HANDLE + + + +specifies the handle of the parent qdisc the current qdisc must be +attached to. + + + + + +root + + + +specifies that the qdisc is attached to the root of device. + + + + + +KIND + + + +this is the qdisc kind. NetworkManager currently supports the +following kinds: fq_codel, sfq, tbf. Each qdisc kind has a +different set of parameters, described below. There are also some +kinds like pfifo, pfifo_fast, prio supported by NetworkManager +but their parameters are not supported by NetworkManager. + + + + + +Parameters for 'fq_codel': + + + + +limit U32 + + + +the hard limit on the real queue size. When this limit is +reached, incoming packets are dropped. Default is 10240 packets. + + + + + +memory_limit U32 + + + +sets a limit on the total number of bytes that can be queued in +this FQ-CoDel instance. The lower of the packet limit of the +limit parameter and the memory limit will be enforced. Default is +32 MB. + + + + + +flows U32 + + + +the number of flows into which the incoming packets are +classified. Due to the stochastic nature of hashing, multiple +flows may end up being hashed into the same slot. Newer flows +have priority over older ones. This parameter can be set only at +load time since memory has to be allocated for the hash table. +Default value is 1024. + + + + + +target U32 + + + +the acceptable minimum standing/persistent queue delay. This minimum +delay is identified by tracking the local minimum queue delay that packets +experience. The unit of measurement is microsecond(us). Default value is 5ms. + + + + + +interval U32 + + + +used to ensure that the measured minimum delay does not become too stale. +The minimum delay must be experienced in the last epoch of length .B +interval. It should be set on the order of the worst-case RTT +through the bottleneck to give endpoints sufficient time to +react. Default value is 100ms. + + + + + +quantum U32 + + + +the number of bytes used as 'deficit' in the fair queuing +algorithm. Default is set to 1514 bytes which corresponds to the +Ethernet MTU plus the hardware header length of 14 bytes. + + + + + +ecn BOOL + + + +can be used to mark packets instead of dropping them. ecn is turned +on by default. + + + + + +ce_threshold U32 + + + +sets a threshold above which all packets are marked with ECN +Congestion Experienced. This is useful for DCTCP-style congestion +control algorithms that require marking at very shallow queueing +thresholds. + + + + + +Parameters for 'sfq': + + + + +divisor U32 + + + +can be used to set a different hash table size, available +from kernel 2.6.39 onwards. The specified divisor must be +a power of two and cannot be larger than 65536. Default +value: 1024. + + + + + +limit U32 + + + +Upper limit of the SFQ. Can be used to reduce the default +length of 127 packets. + + + + + +depth U32 + + + +Limit of packets per flow. Default to +127 and can be lowered. + + + + + +perturb_period U32 + + + +Interval in seconds for queue algorithm perturbation. +Defaults to 0, which means that no perturbation occurs. Do +not set too low for each perturbation may cause some +packet reordering or losses. Advised value: 60 This value +has no effect when external flow classification is used. +Its better to increase divisor value to lower risk of hash +collisions. + + + + + +quantum U32 + + + +Amount of bytes a flow is allowed to dequeue during a +round of the round robin process. Defaults to the MTU of +the interface which is also the advised value and the +minimum value. + + + + + +flows U32 + + + +Default value is 127. + + + + + +Parameters for 'tbf': + + + + +rate U64 + + + +Bandwidth or rate. These parameters accept a floating +point number, possibly followed by either a unit (both SI +and IEC units supported), or a float followed by a percent +character to specify the rate as a percentage of the +device's speed. + + + + + +burst U32 + + + +Also known as buffer or maxburst. Size of the bucket, in +bytes. This is the maximum amount of bytes that tokens can +be available for instantaneously. In general, larger +shaping rates require a larger buffer. For 10mbit/s on +Intel, you need at least 10kbyte buffer if you want to +reach your configured rate! + + +If your buffer is too small, packets may be dropped +because more tokens arrive per timer tick than fit in your +bucket. The minimum buffer size can be calculated by +dividing the rate by HZ. + + +Token usage calculations are performed using a table which +by default has a resolution of 8 packets. This resolution +can be changed by specifying the cell size with the burst. +For example, to specify a 6000 byte buffer with a 16 byte +cell size, set a burst of 6000/16. You will probably never +have to set this. Must be an integral power of 2. + + + + + +limit U32 + + + +Limit is the number of bytes that can be queued waiting +for tokens to become available. + + + + + +latency U32 + + + +specifies the maximum amount of time a packet can +sit in the TBF. The latency calculation takes into account +the size of the bucket, the rate and possibly the peakrate +(if set). The latency and limit are mutually exclusive. + + + + + + + + + +Array of TC traffic filters. Traffic control can manage the packet content during +classification by using filters. + + +Each tfilters can be specified by the following attributes: + + + + +handle HANDLE + + + +specifies the tfilters handle. A filter is used by a classful qdisc to determine in which class +a packet will be enqueued. It is important to notice that filters reside within qdiscs. Therefore, +see qdiscs handle for detailed information. + + + + + +parent HANDLE + + + +specifies the handle of the parent qdisc the current qdisc must be +attached to. + + + + + +root + + + +specifies that the qdisc is attached to the root of device. + + + + + +KIND + + + +this is the tfilters kind. NetworkManager currently supports +following kinds: mirred, simple. Each filter kind has a +different set of actions, described below. There are also some +other kinds like matchall, basic, u32 supported by NetworkManager. + + + + + +Actions for 'mirred': + + + + +egress bool + + + +Define whether the packet should exit from the interface. + + + + + +ingress bool + + + +Define whether the packet should come into the interface. + + + + + +mirror bool + + + +Define whether the packet should be copied to the destination space. + + + + + +redirect bool + + + +Define whether the packet should be moved to the destination space. + + + + + +Action for 'simple': + + + + +sdata char[32] + + + +The actual string to print. + + + + + + diff --git a/src/libnm-client-impl/nm-remote-connection-private.h b/src/libnm-client-impl/nm-remote-connection-private.h index 3ca934bf..f0869347 100644 --- a/src/libnm-client-impl/nm-remote-connection-private.h +++ b/src/libnm-client-impl/nm-remote-connection-private.h @@ -7,7 +7,7 @@ #define __NM_REMOTE_CONNECTION_PRIVATE_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #define NM_REMOTE_CONNECTION_INIT_RESULT "init-result" diff --git a/src/libnm-client-impl/nm-settings-docs-gir.xml b/src/libnm-client-impl/nm-settings-docs-gir.xml index cbbae7b6..b916ee04 100644 --- a/src/libnm-client-impl/nm-settings-docs-gir.xml +++ b/src/libnm-client-impl/nm-settings-docs-gir.xml @@ -5,10 +5,11 @@ - - + + + @@ -98,6 +99,9 @@ + + + @@ -142,7 +146,7 @@ - + @@ -464,7 +468,7 @@ - + diff --git a/src/libnm-client-impl/tests/test-libnm.c b/src/libnm-client-impl/tests/test-libnm.c index e470c63e..29ffde97 100644 --- a/src/libnm-client-impl/tests/test-libnm.c +++ b/src/libnm-client-impl/tests/test-libnm.c @@ -6,7 +6,7 @@ #include "libnm-client-impl/nm-default-libnm.h" #if defined(HAVE_DECL_MEMFD_CREATE) && HAVE_DECL_MEMFD_CREATE - #include +#include #endif #include @@ -2758,7 +2758,7 @@ test_types(void) for (i_type = 0; i_type < G_N_ELEMENTS(get_type_fcns); i_type++) { nm_auto_unref_gtypeclass GObjectClass *klass_unref = NULL; - GType gtype = (get_type_fcns[i_type]) (); + GType gtype = (get_type_fcns[i_type])(); GObjectClass * klass; g_assert(g_str_has_prefix(g_type_name(gtype), "NM")); @@ -2837,6 +2837,11 @@ test_nml_dbus_meta(void) g_assert((mif->n_dbus_properties > 0) == (!!mif->dbus_properties)); + if (nm_streq(mif->dbus_iface_name, "org.freedesktop.NetworkManager.Device")) + g_assert(nm_streq( + mif->dbus_properties[_NML_DEVICE_META_PROPERTY_INDEX_PORTS].dbus_property_name, + "Ports")); + if (mif->interface_prio == NML_DBUS_META_INTERFACE_PRIO_NONE) { g_assert(!mif->get_type_fcn); g_assert(!mif->obj_properties); @@ -3068,7 +3073,7 @@ check_dbus_properties: pspec = mif->obj_properties[mpr->obj_properties_idx]; } - if (mpr->use_notify_update_prop) { + if (mpr->notify_update_prop) { g_assert(mpr->notify_update_prop); } else { if (klass) @@ -3129,7 +3134,7 @@ check_dbus_properties: g_assert_cmpstr(expected_property_name, ==, pspec->name); - if (!mpr->use_notify_update_prop) { + if (!mpr->notify_update_prop) { for (p_expected_type_2 = &expected_types[0]; p_expected_type_2 < &expected_types[G_N_ELEMENTS(expected_types)]; p_expected_type_2++) { diff --git a/src/libnm-client-impl/tests/test-nm-client.c b/src/libnm-client-impl/tests/test-nm-client.c index 55b886a0..a3fc5847 100644 --- a/src/libnm-client-impl/tests/test-nm-client.c +++ b/src/libnm-client-impl/tests/test-nm-client.c @@ -62,7 +62,7 @@ test_device_added(void) devices = nm_client_get_devices(client); g_assert(devices->len == 0); - g_signal_connect(client, "notify::devices", (GCallback) devices_notify_cb, ¬ified); + g_signal_connect(client, "notify::devices", G_CALLBACK(devices_notify_cb), ¬ified); /* Tell the test service to add a new device */ nmtstc_service_add_device(sinfo, client, "AddWiredDevice", "eth0"); @@ -149,11 +149,11 @@ test_device_added_signal_after_init(void) devices = nm_client_get_devices(client); g_assert(devices->len == 0); - g_signal_connect(client, NM_CLIENT_DEVICE_ADDED, (GCallback) device_sai_added_cb, &result); + g_signal_connect(client, NM_CLIENT_DEVICE_ADDED, G_CALLBACK(device_sai_added_cb), &result); g_signal_connect(client, "notify::" NM_CLIENT_DEVICES, - (GCallback) devices_sai_notify_cb, + G_CALLBACK(devices_sai_notify_cb), &result); /* Tell the test service to add a new device */ @@ -307,10 +307,10 @@ test_wifi_ap_added_removed(void) g_variant_get(ret, "(o)", &expected_path); g_variant_unref(ret); - g_signal_connect(wifi, "access-point-added", (GCallback) wifi_ap_added_cb, &info); + g_signal_connect(wifi, "access-point-added", G_CALLBACK(wifi_ap_added_cb), &info); info.quit_count = 1; - g_signal_connect(wifi, "notify::access-points", (GCallback) wifi_ap_add_notify_cb, &info); + g_signal_connect(wifi, "notify::access-points", G_CALLBACK(wifi_ap_add_notify_cb), &info); info.quit_count++; /* Wait for libnm to find the AP */ @@ -340,10 +340,10 @@ test_wifi_ap_added_removed(void) g_assert_no_error(error); nm_clear_pointer(&ret, g_variant_unref); - g_signal_connect(wifi, "access-point-removed", (GCallback) wifi_ap_removed_cb, &info); + g_signal_connect(wifi, "access-point-removed", G_CALLBACK(wifi_ap_removed_cb), &info); info.quit_count = 1; - g_signal_connect(wifi, "notify::access-points", (GCallback) wifi_ap_remove_notify_cb, &info); + g_signal_connect(wifi, "notify::access-points", G_CALLBACK(wifi_ap_remove_notify_cb), &info); info.quit_count++; /* Wait for libnm to find the AP */ @@ -463,9 +463,9 @@ test_devices_array(void) g_assert(ret); g_variant_unref(ret); - g_signal_connect(client, "device-removed", (GCallback) da_device_removed_cb, &info); + g_signal_connect(client, "device-removed", G_CALLBACK(da_device_removed_cb), &info); - g_signal_connect(client, "notify::devices", (GCallback) da_devices_notify_cb, &info); + g_signal_connect(client, "notify::devices", G_CALLBACK(da_devices_notify_cb), &info); info.quit_count = 2; /* Wait for libnm to notice the changes */ @@ -948,7 +948,7 @@ _test_connection_invalid_find_connections(gpointer element, gpointer needle, gpo static void test_connection_invalid(void) { - NMTSTC_SERVICE_INFO_SETUP(my_sinfo) + NMTSTC_SERVICE_INFO_SETUP(my_sinfo); gs_unref_object NMConnection *connection = NULL; NMSettingConnection * s_con; gs_unref_object NMClient *client = NULL; diff --git a/src/libnm-client-public/NetworkManager.h b/src/libnm-client-public/NetworkManager.h index f9cc8565..3134562e 100644 --- a/src/libnm-client-public/NetworkManager.h +++ b/src/libnm-client-public/NetworkManager.h @@ -55,6 +55,7 @@ #include "nm-setting-adsl.h" #include "nm-setting-bluetooth.h" #include "nm-setting-bond.h" +#include "nm-setting-bond-port.h" #include "nm-setting-bridge.h" #include "nm-setting-bridge-port.h" #include "nm-setting-cdma.h" @@ -118,13 +119,13 @@ #if !defined(NETWORKMANAGER_COMPILATION) \ && (!defined(NM_NO_INCLUDE_EXTRA_HEADERS) || !NM_NO_INCLUDE_EXTRA_HEADERS) - /* historically, NetworkManager.h drags in the following system headers. +/* historically, NetworkManager.h drags in the following system headers. * These are not strictly necessary and the user may wish to opt out from * including them. */ - #include - #include - #include - #include +#include +#include +#include +#include #endif #undef __NETWORKMANAGER_H_INSIDE__ diff --git a/src/libnm-client-public/nm-access-point.h b/src/libnm-client-public/nm-access-point.h index 0460ea0a..50a74296 100644 --- a/src/libnm-client-public/nm-access-point.h +++ b/src/libnm-client-public/nm-access-point.h @@ -8,7 +8,7 @@ #define __NM_ACCESS_POINT_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-object.h" diff --git a/src/libnm-client-public/nm-active-connection.h b/src/libnm-client-public/nm-active-connection.h index 44b715c7..76ea107a 100644 --- a/src/libnm-client-public/nm-active-connection.h +++ b/src/libnm-client-public/nm-active-connection.h @@ -8,7 +8,7 @@ #define __NM_ACTIVE_CONNECTION_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-object.h" diff --git a/src/libnm-client-public/nm-autoptr.h b/src/libnm-client-public/nm-autoptr.h index f37e2cfc..6c34946c 100644 --- a/src/libnm-client-public/nm-autoptr.h +++ b/src/libnm-client-public/nm-autoptr.h @@ -67,6 +67,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(NMSetting8021x, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(NMSettingAdsl, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(NMSettingBluetooth, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(NMSettingBond, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(NMSettingBondPort, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(NMSettingBridge, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(NMSettingBridgePort, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(NMSettingCdma, g_object_unref) diff --git a/src/libnm-client-public/nm-checkpoint.h b/src/libnm-client-public/nm-checkpoint.h index 3bc28f6f..def1f554 100644 --- a/src/libnm-client-public/nm-checkpoint.h +++ b/src/libnm-client-public/nm-checkpoint.h @@ -7,7 +7,7 @@ #define __NM_CHECKPOINT_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-object.h" diff --git a/src/libnm-client-public/nm-client.h b/src/libnm-client-public/nm-client.h index 0145c5f4..02c8ee33 100644 --- a/src/libnm-client-public/nm-client.h +++ b/src/libnm-client-public/nm-client.h @@ -8,7 +8,7 @@ #define __NM_CLIENT_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-types.h" diff --git a/src/libnm-client-public/nm-device-6lowpan.h b/src/libnm-client-public/nm-device-6lowpan.h index d46e6db4..2388bf38 100644 --- a/src/libnm-client-public/nm-device-6lowpan.h +++ b/src/libnm-client-public/nm-device-6lowpan.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_6LOWPAN_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-adsl.h b/src/libnm-client-public/nm-device-adsl.h index 92eaf369..fa8a1278 100644 --- a/src/libnm-client-public/nm-device-adsl.h +++ b/src/libnm-client-public/nm-device-adsl.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_ADSL_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-bond.h b/src/libnm-client-public/nm-device-bond.h index 91c023a4..19e0e046 100644 --- a/src/libnm-client-public/nm-device-bond.h +++ b/src/libnm-client-public/nm-device-bond.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_BOND_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" @@ -37,7 +37,9 @@ GType nm_device_bond_get_type(void); NM_DEPRECATED_IN_1_24_FOR(nm_device_get_hw_address) const char *nm_device_bond_get_hw_address(NMDeviceBond *device); -gboolean nm_device_bond_get_carrier(NMDeviceBond *device); +gboolean nm_device_bond_get_carrier(NMDeviceBond *device); + +NM_DEPRECATED_IN_1_34_FOR(nm_device_get_ports) const GPtrArray *nm_device_bond_get_slaves(NMDeviceBond *device); G_END_DECLS diff --git a/src/libnm-client-public/nm-device-bridge.h b/src/libnm-client-public/nm-device-bridge.h index a6c50658..07905195 100644 --- a/src/libnm-client-public/nm-device-bridge.h +++ b/src/libnm-client-public/nm-device-bridge.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_BRIDGE_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" @@ -38,7 +38,9 @@ GType nm_device_bridge_get_type(void); NM_DEPRECATED_IN_1_24_FOR(nm_device_get_hw_address) const char *nm_device_bridge_get_hw_address(NMDeviceBridge *device); -gboolean nm_device_bridge_get_carrier(NMDeviceBridge *device); +gboolean nm_device_bridge_get_carrier(NMDeviceBridge *device); + +NM_DEPRECATED_IN_1_34_FOR(nm_device_get_ports) const GPtrArray *nm_device_bridge_get_slaves(NMDeviceBridge *device); G_END_DECLS diff --git a/src/libnm-client-public/nm-device-bt.h b/src/libnm-client-public/nm-device-bt.h index a7cfc796..c277bae9 100644 --- a/src/libnm-client-public/nm-device-bt.h +++ b/src/libnm-client-public/nm-device-bt.h @@ -8,7 +8,7 @@ #define __NM_DEVICE_BT_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-dummy.h b/src/libnm-client-public/nm-device-dummy.h index ad34b65e..d5b8cb24 100644 --- a/src/libnm-client-public/nm-device-dummy.h +++ b/src/libnm-client-public/nm-device-dummy.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_DUMMY_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-ethernet.h b/src/libnm-client-public/nm-device-ethernet.h index 877930e6..636e5eb5 100644 --- a/src/libnm-client-public/nm-device-ethernet.h +++ b/src/libnm-client-public/nm-device-ethernet.h @@ -8,7 +8,7 @@ #define __NM_DEVICE_ETHERNET_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-generic.h b/src/libnm-client-public/nm-device-generic.h index 5c1f3084..7b543b2f 100644 --- a/src/libnm-client-public/nm-device-generic.h +++ b/src/libnm-client-public/nm-device-generic.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_GENERIC_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-infiniband.h b/src/libnm-client-public/nm-device-infiniband.h index be9a26e5..3999b2d5 100644 --- a/src/libnm-client-public/nm-device-infiniband.h +++ b/src/libnm-client-public/nm-device-infiniband.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_INFINIBAND_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-ip-tunnel.h b/src/libnm-client-public/nm-device-ip-tunnel.h index 0d9c3e55..d7912729 100644 --- a/src/libnm-client-public/nm-device-ip-tunnel.h +++ b/src/libnm-client-public/nm-device-ip-tunnel.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_IP_TUNNEL_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-macsec.h b/src/libnm-client-public/nm-device-macsec.h index 5a036601..e468344f 100644 --- a/src/libnm-client-public/nm-device-macsec.h +++ b/src/libnm-client-public/nm-device-macsec.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_MACSEC_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-macvlan.h b/src/libnm-client-public/nm-device-macvlan.h index b8d27066..ec7eb640 100644 --- a/src/libnm-client-public/nm-device-macvlan.h +++ b/src/libnm-client-public/nm-device-macvlan.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_MACVLAN_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-modem.h b/src/libnm-client-public/nm-device-modem.h index eced137a..f9dfc348 100644 --- a/src/libnm-client-public/nm-device-modem.h +++ b/src/libnm-client-public/nm-device-modem.h @@ -8,7 +8,7 @@ #define __NM_DEVICE_MODEM_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-olpc-mesh.h b/src/libnm-client-public/nm-device-olpc-mesh.h index d8b835fa..86ac2ce7 100644 --- a/src/libnm-client-public/nm-device-olpc-mesh.h +++ b/src/libnm-client-public/nm-device-olpc-mesh.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_OLPC_MESH_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-ovs-bridge.h b/src/libnm-client-public/nm-device-ovs-bridge.h index 50754e11..f0ef1547 100644 --- a/src/libnm-client-public/nm-device-ovs-bridge.h +++ b/src/libnm-client-public/nm-device-ovs-bridge.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_OVS_BRIDGE_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-ovs-interface.h b/src/libnm-client-public/nm-device-ovs-interface.h index 6767ad4a..12b30a75 100644 --- a/src/libnm-client-public/nm-device-ovs-interface.h +++ b/src/libnm-client-public/nm-device-ovs-interface.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_OVS_INTERFACE_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-ovs-port.h b/src/libnm-client-public/nm-device-ovs-port.h index 1f69641b..170067f9 100644 --- a/src/libnm-client-public/nm-device-ovs-port.h +++ b/src/libnm-client-public/nm-device-ovs-port.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_OVS_PORT_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-ppp.h b/src/libnm-client-public/nm-device-ppp.h index 7bd282d7..ff99d9f9 100644 --- a/src/libnm-client-public/nm-device-ppp.h +++ b/src/libnm-client-public/nm-device-ppp.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_PPP_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif G_BEGIN_DECLS diff --git a/src/libnm-client-public/nm-device-team.h b/src/libnm-client-public/nm-device-team.h index 921353b6..eab5e4e6 100644 --- a/src/libnm-client-public/nm-device-team.h +++ b/src/libnm-client-public/nm-device-team.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_TEAM_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-tun.h b/src/libnm-client-public/nm-device-tun.h index ee7342de..cc05b0c1 100644 --- a/src/libnm-client-public/nm-device-tun.h +++ b/src/libnm-client-public/nm-device-tun.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_TUN_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-veth.h b/src/libnm-client-public/nm-device-veth.h index 689762a7..41b41915 100644 --- a/src/libnm-client-public/nm-device-veth.h +++ b/src/libnm-client-public/nm-device-veth.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_VETH_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-vlan.h b/src/libnm-client-public/nm-device-vlan.h index 81430509..c3920586 100644 --- a/src/libnm-client-public/nm-device-vlan.h +++ b/src/libnm-client-public/nm-device-vlan.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_VLAN_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-vrf.h b/src/libnm-client-public/nm-device-vrf.h index f835dd2f..3b59023a 100644 --- a/src/libnm-client-public/nm-device-vrf.h +++ b/src/libnm-client-public/nm-device-vrf.h @@ -4,7 +4,7 @@ #define __NM_DEVICE_VRF_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-vxlan.h b/src/libnm-client-public/nm-device-vxlan.h index 9ef5eb2d..5264e9ca 100644 --- a/src/libnm-client-public/nm-device-vxlan.h +++ b/src/libnm-client-public/nm-device-vxlan.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_VXLAN_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-wifi-p2p.h b/src/libnm-client-public/nm-device-wifi-p2p.h index 374ef4bd..3395ca29 100644 --- a/src/libnm-client-public/nm-device-wifi-p2p.h +++ b/src/libnm-client-public/nm-device-wifi-p2p.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_WIFI_P2P_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-wifi.h b/src/libnm-client-public/nm-device-wifi.h index bf712bbc..85062f51 100644 --- a/src/libnm-client-public/nm-device-wifi.h +++ b/src/libnm-client-public/nm-device-wifi.h @@ -8,7 +8,7 @@ #define __NM_DEVICE_WIFI_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-wimax.h b/src/libnm-client-public/nm-device-wimax.h index 8a0fd901..123b95b2 100644 --- a/src/libnm-client-public/nm-device-wimax.h +++ b/src/libnm-client-public/nm-device-wimax.h @@ -8,7 +8,7 @@ #define __NM_DEVICE_WIMAX_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-wireguard.h b/src/libnm-client-public/nm-device-wireguard.h index f54695ee..4a18bd81 100644 --- a/src/libnm-client-public/nm-device-wireguard.h +++ b/src/libnm-client-public/nm-device-wireguard.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_WIREGUARD_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device-wpan.h b/src/libnm-client-public/nm-device-wpan.h index 7d50fd9e..b8a7a3bf 100644 --- a/src/libnm-client-public/nm-device-wpan.h +++ b/src/libnm-client-public/nm-device-wpan.h @@ -7,7 +7,7 @@ #define __NM_DEVICE_WPAN_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-device.h" diff --git a/src/libnm-client-public/nm-device.h b/src/libnm-client-public/nm-device.h index 62baac92..23b1a805 100644 --- a/src/libnm-client-public/nm-device.h +++ b/src/libnm-client-public/nm-device.h @@ -8,7 +8,7 @@ #define __NM_DEVICE_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-object.h" @@ -57,6 +57,7 @@ _NM_DEPRECATED_SYNC_WRITABLE_PROPERTY #define NM_DEVICE_IP6_CONNECTIVITY "ip6-connectivity" #define NM_DEVICE_INTERFACE_FLAGS "interface-flags" #define NM_DEVICE_HW_ADDRESS "hw-address" +#define NM_DEVICE_PORTS "ports" /** * NMDevice: @@ -141,6 +142,9 @@ const char * nm_device_get_hw_address(NMDevice *device); NMDeviceCapabilities nm_device_get_capabilities(NMDevice *device); gboolean nm_device_get_managed(NMDevice *device); +NM_AVAILABLE_IN_1_34 +const GPtrArray *nm_device_get_ports(NMDevice *device); + NM_AVAILABLE_IN_1_2 NM_DEPRECATED_IN_1_22 _NM_DEPRECATED_SYNC_METHOD diff --git a/src/libnm-client-public/nm-dhcp-config.h b/src/libnm-client-public/nm-dhcp-config.h index 7663fb9a..0188f9c2 100644 --- a/src/libnm-client-public/nm-dhcp-config.h +++ b/src/libnm-client-public/nm-dhcp-config.h @@ -8,7 +8,7 @@ #define __NM_DHCP_CONFIG_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-object.h" diff --git a/src/libnm-client-public/nm-ip-config.h b/src/libnm-client-public/nm-ip-config.h index bdfebb6a..a63dea67 100644 --- a/src/libnm-client-public/nm-ip-config.h +++ b/src/libnm-client-public/nm-ip-config.h @@ -8,7 +8,7 @@ #define __NM_IP_CONFIG_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-object.h" diff --git a/src/libnm-client-public/nm-object.h b/src/libnm-client-public/nm-object.h index 7b4a3232..efa3aa53 100644 --- a/src/libnm-client-public/nm-object.h +++ b/src/libnm-client-public/nm-object.h @@ -8,7 +8,7 @@ #define __NM_OBJECT_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-types.h" @@ -22,7 +22,8 @@ G_BEGIN_DECLS #define NM_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_OBJECT)) #define NM_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_OBJECT, NMObjectClass)) -#define NM_OBJECT_PATH "path" +#define NM_OBJECT_PATH "path" +#define NM_OBJECT_CLIENT "client" /** * NMObject: diff --git a/src/libnm-client-public/nm-remote-connection.h b/src/libnm-client-public/nm-remote-connection.h index e29bf073..06088e86 100644 --- a/src/libnm-client-public/nm-remote-connection.h +++ b/src/libnm-client-public/nm-remote-connection.h @@ -8,7 +8,7 @@ #define __NM_REMOTE_CONNECTION_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-object.h" diff --git a/src/libnm-client-public/nm-vpn-connection.h b/src/libnm-client-public/nm-vpn-connection.h index aac259d5..1a20d0af 100644 --- a/src/libnm-client-public/nm-vpn-connection.h +++ b/src/libnm-client-public/nm-vpn-connection.h @@ -8,7 +8,7 @@ #define __NM_VPN_CONNECTION_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-active-connection.h" diff --git a/src/libnm-client-public/nm-vpn-editor.h b/src/libnm-client-public/nm-vpn-editor.h index 8cd7805f..f89617a8 100644 --- a/src/libnm-client-public/nm-vpn-editor.h +++ b/src/libnm-client-public/nm-vpn-editor.h @@ -8,7 +8,7 @@ #define __NM_VPN_EDITOR_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include diff --git a/src/libnm-client-public/nm-vpn-service-plugin.h b/src/libnm-client-public/nm-vpn-service-plugin.h index e45622aa..916ea52a 100644 --- a/src/libnm-client-public/nm-vpn-service-plugin.h +++ b/src/libnm-client-public/nm-vpn-service-plugin.h @@ -8,7 +8,7 @@ #define __NM_VPN_SERVICE_PLUGIN_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include diff --git a/src/libnm-client-public/nm-wifi-p2p-peer.h b/src/libnm-client-public/nm-wifi-p2p-peer.h index 4ab7c0e6..73e6995c 100644 --- a/src/libnm-client-public/nm-wifi-p2p-peer.h +++ b/src/libnm-client-public/nm-wifi-p2p-peer.h @@ -7,7 +7,7 @@ #define __NM_WIFI_P2P_PEER_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-object.h" diff --git a/src/libnm-client-public/nm-wimax-nsp.h b/src/libnm-client-public/nm-wimax-nsp.h index 15b8daa0..f19272db 100644 --- a/src/libnm-client-public/nm-wimax-nsp.h +++ b/src/libnm-client-public/nm-wimax-nsp.h @@ -8,7 +8,7 @@ #define __NM_WIMAX_NSP_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-object.h" diff --git a/src/libnm-client-test/nm-test-libnm-utils.h b/src/libnm-client-test/nm-test-libnm-utils.h index 58909304..4997ab33 100644 --- a/src/libnm-client-test/nm-test-libnm-utils.h +++ b/src/libnm-client-test/nm-test-libnm-utils.h @@ -28,17 +28,15 @@ _nmtstc_auto_service_cleanup(NMTstcServiceInfo **info) } #define nmtstc_auto_service_cleanup nm_auto(_nmtstc_auto_service_cleanup) -#define NMTSTC_SERVICE_INFO_SETUP(sinfo) \ - NM_PRAGMA_WARNING_DISABLE("-Wunused-variable") \ - nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = ({ \ - NMTstcServiceInfo *_sinfo; \ - \ - _sinfo = nmtstc_service_init(); \ - if (!nmtstc_service_available(_sinfo)) \ - return; \ - _sinfo; \ - }); \ - NM_PRAGMA_WARNING_REENABLE +#define NMTSTC_SERVICE_INFO_SETUP(sinfo) \ + _nm_unused nmtstc_auto_service_cleanup NMTstcServiceInfo *sinfo = ({ \ + NMTstcServiceInfo *_sinfo; \ + \ + _sinfo = nmtstc_service_init(); \ + if (!nmtstc_service_available(_sinfo)) \ + return; \ + _sinfo; \ + }) NMDevice *nmtstc_service_add_device(NMTstcServiceInfo *info, NMClient * client, diff --git a/src/libnm-core-aux-extern/nm-libnm-core-aux.c b/src/libnm-core-aux-extern/nm-libnm-core-aux.c index 6c45ecf7..e92c234f 100644 --- a/src/libnm-core-aux-extern/nm-libnm-core-aux.c +++ b/src/libnm-core-aux-extern/nm-libnm-core-aux.c @@ -8,6 +8,7 @@ #include "nm-libnm-core-aux.h" #include "libnm-core-aux-intern/nm-libnm-core-utils.h" +#include "libnm-glib-aux/nm-str-buf.h" /*****************************************************************************/ @@ -434,3 +435,43 @@ nm_utils_team_link_watcher_from_string(const char *str, GError **error) return watcher; } + +/*****************************************************************************/ + +/** + * _nm_ip_route_to_string: + * @route: route to get information about + * @strbuf: NMStrBuf to store information about route + * + * Gets available information about route and prints it into buffer + */ +void +_nm_ip_route_to_string(NMIPRoute *route, NMStrBuf *strbuf) +{ + const char *next_hop; + gint64 metric; + + nm_assert(route); + nm_assert(strbuf); + + next_hop = nm_ip_route_get_next_hop(route); + metric = nm_ip_route_get_metric(route); + + if (NM_IN_STRSET(nm_ip_route_get_dest(route), "0.0.0.0", "::") + && nm_ip_route_get_prefix(route) == 0) { + nm_str_buf_append_printf(strbuf, "default"); + } else { + nm_str_buf_append_printf(strbuf, + "%s/%u", + nm_ip_route_get_dest(route), + nm_ip_route_get_prefix(route)); + } + + if (next_hop) { + nm_str_buf_append_printf(strbuf, " via %s", next_hop); + } + + if (metric != -1) { + nm_str_buf_append_printf(strbuf, " metric %" G_GINT64_FORMAT, metric); + } +} diff --git a/src/libnm-core-aux-extern/nm-libnm-core-aux.h b/src/libnm-core-aux-extern/nm-libnm-core-aux.h index 905f2433..e45e98ab 100644 --- a/src/libnm-core-aux-extern/nm-libnm-core-aux.h +++ b/src/libnm-core-aux-extern/nm-libnm-core-aux.h @@ -7,6 +7,7 @@ #define __NM_LIBNM_CORE_AUX_H__ #include "nm-setting-team.h" +#include "nm-setting-ip-config.h" typedef enum { NM_TEAM_LINK_WATCHER_TYPE_NONE = 0, @@ -33,6 +34,9 @@ typedef enum { char *nm_utils_team_link_watcher_to_string(const NMTeamLinkWatcher *watcher); +struct _NMStrBuf; +void _nm_ip_route_to_string(NMIPRoute *route, struct _NMStrBuf *strbuf); + NMTeamLinkWatcher *nm_utils_team_link_watcher_from_string(const char *str, GError **error); #endif /* __NM_LIBNM_CORE_AUX_H__ */ diff --git a/src/libnm-core-aux-intern/nm-libnm-core-utils.c b/src/libnm-core-aux-intern/nm-libnm-core-utils.c index e53f840a..e1688859 100644 --- a/src/libnm-core-aux-intern/nm-libnm-core-utils.c +++ b/src/libnm-core-aux-intern/nm-libnm-core-utils.c @@ -8,13 +8,14 @@ #include "nm-common-macros.h" #include "nm-errors.h" +#include "libnm-core-public/nm-connection.h" /*****************************************************************************/ const char ** nm_utils_bond_option_arp_ip_targets_split(const char *arp_ip_target) { - return nm_utils_strsplit_set_full(arp_ip_target, ",", NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP); + return nm_strsplit_set_full(arp_ip_target, ",", NM_STRSPLIT_SET_FLAGS_STRSTRIP); } void @@ -358,3 +359,22 @@ nm_settings_connection_validate_permission_user(const char *item, gssize len) return TRUE; } + +gpointer +_nm_connection_ensure_setting(NMConnection *connection, GType gtype) +{ + return nm_connection_get_setting(connection, gtype) + ?: _nm_connection_new_setting(connection, gtype); +} + +gpointer +_nm_connection_new_setting(NMConnection *connection, GType gtype) +{ + NMSetting *setting; + + nm_assert(g_type_is_a(gtype, NM_TYPE_SETTING)); + + setting = g_object_new(gtype, NULL); + nm_connection_add_setting(connection, setting); + return setting; +} diff --git a/src/libnm-core-aux-intern/nm-libnm-core-utils.h b/src/libnm-core-aux-intern/nm-libnm-core-utils.h index e0a6aaf1..f90e3984 100644 --- a/src/libnm-core-aux-intern/nm-libnm-core-utils.h +++ b/src/libnm-core-aux-intern/nm-libnm-core-utils.h @@ -166,4 +166,9 @@ gboolean nm_utils_validate_dhcp4_vendor_class_id(const char *vci, GError **error gboolean nm_settings_connection_validate_permission_user(const char *item, gssize len); +/*****************************************************************************/ + +gpointer _nm_connection_ensure_setting(NMConnection *connection, GType gtype); +gpointer _nm_connection_new_setting(NMConnection *connection, GType gtype); + #endif /* __NM_LIBNM_SHARED_UTILS_H__ */ diff --git a/src/libnm-core-impl/meson.build b/src/libnm-core-impl/meson.build index f175ea3b..2e1f1751 100644 --- a/src/libnm-core-impl/meson.build +++ b/src/libnm-core-impl/meson.build @@ -37,6 +37,7 @@ libnm_core_settings_sources = files( 'nm-setting-adsl.c', 'nm-setting-bluetooth.c', 'nm-setting-bond.c', + 'nm-setting-bond-port.c', 'nm-setting-bridge-port.c', 'nm-setting-bridge.c', 'nm-setting-cdma.c', diff --git a/src/libnm-core-impl/nm-connection-private.h b/src/libnm-core-impl/nm-connection-private.h index 0580625f..27769ec1 100644 --- a/src/libnm-core-impl/nm-connection-private.h +++ b/src/libnm-core-impl/nm-connection-private.h @@ -7,7 +7,7 @@ #define __NM_CONNECTION_PRIVATE_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #include "nm-setting.h" diff --git a/src/libnm-core-impl/nm-connection.c b/src/libnm-core-impl/nm-connection.c index 4ac7b322..dc85ea0c 100644 --- a/src/libnm-core-impl/nm-connection.c +++ b/src/libnm-core-impl/nm-connection.c @@ -944,8 +944,8 @@ _nm_setting_connection_verify_secondaries(GArray *secondaries, GError **error) gs_free const char **strv_to_free = NULL; const char ** strv2; - strv2 = nm_utils_strv_dup_shallow_maybe_a(20, strv, len, &strv_to_free); - nm_utils_strv_sort(strv2, len); + strv2 = nm_strv_dup_shallow_maybe_a(20, strv, len, &strv_to_free); + nm_strv_sort(strv2, len); has_duplicate = nm_strv_has_duplicate(strv2, len, TRUE); } @@ -1002,7 +1002,7 @@ _normalize_connection_secondaries(NMConnection *self) if (!nm_uuid_is_valid_nm(s, &uuid_is_normalized, uuid_normalized)) continue; - if (nm_utils_strv_find_first(strv, j, uuid_is_normalized ? uuid_normalized : s) >= 0) + if (nm_strv_find_first(strv, j, uuid_is_normalized ? uuid_normalized : s) >= 0) continue; strv[j++] = uuid_is_normalized ? g_strdup(uuid_normalized) : g_steal_pointer(&s); @@ -1074,6 +1074,7 @@ _nm_connection_detect_slave_type(NMConnection *connection, NMSetting **out_s_por const char * controller_type_name; } infos[] = { {NM_META_SETTING_TYPE_BRIDGE_PORT, NM_SETTING_BRIDGE_SETTING_NAME}, + {NM_META_SETTING_TYPE_BOND_PORT, NM_SETTING_BOND_SETTING_NAME}, {NM_META_SETTING_TYPE_TEAM_PORT, NM_SETTING_TEAM_SETTING_NAME}, {NM_META_SETTING_TYPE_OVS_PORT, NM_SETTING_OVS_BRIDGE_SETTING_NAME}, {NM_META_SETTING_TYPE_OVS_INTERFACE, NM_SETTING_OVS_PORT_SETTING_NAME}, @@ -1208,10 +1209,23 @@ _normalize_ip_config(NMConnection *self, GHashTable *parameters) if (_supports_addr_family(self, AF_INET)) { if (!s_ip4) { - const char *default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_AUTO; + const char *default_ip4_method = NULL; - if (nm_connection_is_type(self, NM_SETTING_WIREGUARD_SETTING_NAME)) - default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED; + if (parameters) { + default_ip4_method = + g_hash_table_lookup(parameters, + NM_CONNECTION_NORMALIZE_PARAM_IP4_CONFIG_METHOD); + } + if (!default_ip4_method) { + const char *type = nm_connection_get_connection_type(self); + + if (NM_IN_STRSET(type, + NM_SETTING_WIREGUARD_SETTING_NAME, + NM_SETTING_DUMMY_SETTING_NAME)) + default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED; + else + default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_AUTO; + } /* But if no IP4 setting was specified, assume the caller was just * being lazy and use the default method. @@ -1255,13 +1269,18 @@ _normalize_ip_config(NMConnection *self, GHashTable *parameters) if (!s_ip6) { const char *default_ip6_method = NULL; - if (parameters) + if (parameters) { default_ip6_method = g_hash_table_lookup(parameters, NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD); + } if (!default_ip6_method) { - if (nm_connection_is_type(self, NM_SETTING_WIREGUARD_SETTING_NAME)) - default_ip6_method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE; + const char *type = nm_connection_get_connection_type(self); + + if (NM_IN_STRSET(type, + NM_SETTING_WIREGUARD_SETTING_NAME, + NM_SETTING_DUMMY_SETTING_NAME)) + default_ip6_method = NM_SETTING_IP6_CONFIG_METHOD_DISABLED; else default_ip6_method = NM_SETTING_IP6_CONFIG_METHOD_AUTO; } @@ -1661,6 +1680,10 @@ _normalize_invalid_slave_port_settings(NMConnection *self) && _nm_connection_remove_setting(self, NM_TYPE_SETTING_BRIDGE_PORT)) changed = TRUE; + if (!nm_streq0(slave_type, NM_SETTING_BOND_SETTING_NAME) + && _nm_connection_remove_setting(self, NM_TYPE_SETTING_BOND_PORT)) + changed = TRUE; + if (!nm_streq0(slave_type, NM_SETTING_TEAM_SETTING_NAME) && _nm_connection_remove_setting(self, NM_TYPE_SETTING_TEAM_PORT)) changed = TRUE; @@ -2092,23 +2115,23 @@ _nm_connection_ensure_normalized(NMConnection * connection, #if NM_MORE_ASSERTS static void -_nmtst_connection_unchanging_changed_cb(NMConnection *connection, gpointer user_data) +_nm_assert_connection_unchanging_changed_cb(NMConnection *connection, gpointer user_data) { nm_assert_not_reached(); } static void -_nmtst_connection_unchanging_secrets_updated_cb(NMConnection *connection, - const char * setting_name, - gpointer user_data) +_nm_assert_connection_unchanging_secrets_updated_cb(NMConnection *connection, + const char * setting_name, + gpointer user_data) { nm_assert_not_reached(); } -const char _nmtst_connection_unchanging_user_data = 0; +const char _nm_assert_connection_unchanging_user_data = 0; void -nmtst_connection_assert_unchanging(NMConnection *connection) +nm_assert_connection_unchanging(NMConnection *connection) { if (!connection) return; @@ -2121,7 +2144,7 @@ nmtst_connection_assert_unchanging(NMConnection *connection) 0, NULL, NULL, - (gpointer) &_nmtst_connection_unchanging_user_data) + (gpointer) &_nm_assert_connection_unchanging_user_data) != 0) { /* avoid connecting the assertion handler multiple times. */ return; @@ -2129,16 +2152,16 @@ nmtst_connection_assert_unchanging(NMConnection *connection) g_signal_connect(connection, NM_CONNECTION_CHANGED, - G_CALLBACK(_nmtst_connection_unchanging_changed_cb), - (gpointer) &_nmtst_connection_unchanging_user_data); + G_CALLBACK(_nm_assert_connection_unchanging_changed_cb), + (gpointer) &_nm_assert_connection_unchanging_user_data); g_signal_connect(connection, NM_CONNECTION_SECRETS_CLEARED, - G_CALLBACK(_nmtst_connection_unchanging_changed_cb), - (gpointer) &_nmtst_connection_unchanging_user_data); + G_CALLBACK(_nm_assert_connection_unchanging_changed_cb), + (gpointer) &_nm_assert_connection_unchanging_user_data); g_signal_connect(connection, NM_CONNECTION_SECRETS_UPDATED, - G_CALLBACK(_nmtst_connection_unchanging_secrets_updated_cb), - (gpointer) &_nmtst_connection_unchanging_user_data); + G_CALLBACK(_nm_assert_connection_unchanging_secrets_updated_cb), + (gpointer) &_nm_assert_connection_unchanging_user_data); } #endif @@ -2315,7 +2338,7 @@ nm_connection_need_secrets(NMConnection *connection, GPtrArray **hints) if (!setting) continue; - nm_assert(!setting_before || _nmtst_nm_setting_sort(setting_before, setting) < 0); + nm_assert(!setting_before || _nm_setting_sort_for_nm_assert(setting_before, setting) < 0); nm_assert(!setting_before || _nm_setting_compare_priority(setting_before, setting) <= 0); setting_before = setting; @@ -2552,8 +2575,7 @@ nm_connection_serialization_options_equal(const NMConnectionSerializationOptions return FALSE; if (a->timestamp.has && a->timestamp.val != b->timestamp.val) return FALSE; - if (!nm_utils_strv_equal(a->seen_bssids ?: NM_STRV_EMPTY_CC(), - b->seen_bssids ?: NM_STRV_EMPTY_CC())) + if (!nm_strv_equal(a->seen_bssids ?: NM_STRV_EMPTY_CC(), b->seen_bssids ?: NM_STRV_EMPTY_CC())) return FALSE; return TRUE; @@ -2638,7 +2660,7 @@ nm_connection_is_type(NMConnection *connection, const char *type) } int -_nmtst_nm_setting_sort(NMSetting *a, NMSetting *b) +_nm_setting_sort_for_nm_assert(NMSetting *a, NMSetting *b) { g_assert(NM_IS_SETTING(a)); g_assert(NM_IS_SETTING(b)); @@ -2705,7 +2727,7 @@ nm_connection_get_settings(NMConnection *connection, guint *out_length) NMSetting *setting = priv->settings[nm_meta_setting_types_by_priority[i]]; if (setting) { - nm_assert(j == 0 || _nmtst_nm_setting_sort(arr[j - 1], setting) < 0); + nm_assert(j == 0 || _nm_setting_sort_for_nm_assert(arr[j - 1], setting) < 0); arr[j++] = setting; } } @@ -3099,6 +3121,8 @@ nm_connection_get_virtual_device_description(NMConnection *connection) nm_connection_get_setting_infiniband(connection)); } else if (!strcmp(type, NM_SETTING_IP_TUNNEL_SETTING_NAME)) display_type = _("IP Tunnel"); + else if (!strcmp(type, NM_SETTING_WIREGUARD_SETTING_NAME)) + display_type = _("WireGuard"); if (!iface || !display_type) return NULL; diff --git a/src/libnm-core-impl/nm-crypto.c b/src/libnm-core-impl/nm-crypto.c index b14b681e..ea17449f 100644 --- a/src/libnm-core-impl/nm-crypto.c +++ b/src/libnm-core-impl/nm-crypto.c @@ -310,7 +310,7 @@ parse_old_openssl_key_file(const guint8 * data, "Malformed PEM file: both Proc-Type and DEK-Info tags are required."); return FALSE; } - nm_utils_strbuf_append_str(&str_p, &str_len, p); + nm_strbuf_append_str(&str_p, &str_len, p); nm_assert(str_len > 0); } } diff --git a/src/libnm-core-impl/nm-dbus-utils.c b/src/libnm-core-impl/nm-dbus-utils.c index bcc8cf9c..a272f08c 100644 --- a/src/libnm-core-impl/nm-dbus-utils.c +++ b/src/libnm-core-impl/nm-dbus-utils.c @@ -132,7 +132,7 @@ _nm_dbus_signal_connect_data(GDBusProxy * proxy, sd->signal_name = g_strdup(signal_name); sd->signature = signature; - closure = (swapped ? g_cclosure_new_swap : g_cclosure_new) (c_handler, data, destroy_data); + closure = (swapped ? g_cclosure_new_swap : g_cclosure_new)(c_handler, data, destroy_data); g_closure_set_marshal(closure, g_cclosure_marshal_generic); g_closure_set_meta_marshal(closure, sd, dbus_signal_meta_marshal); g_closure_add_finalize_notifier(closure, sd, dbus_signal_data_free); diff --git a/src/libnm-core-impl/nm-keyfile.c b/src/libnm-core-impl/nm-keyfile.c index c6c4a2eb..1171ab03 100644 --- a/src/libnm-core-impl/nm-keyfile.c +++ b/src/libnm-core-impl/nm-keyfile.c @@ -23,7 +23,7 @@ #include "libnm-glib-aux/nm-secret-utils.h" #include "libnm-systemd-shared/nm-sd-utils-shared.h" #include "libnm-core-aux-intern/nm-common-macros.h" - +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-core-intern/nm-core-internal.h" #include "nm-keyfile.h" #include "nm-setting-private.h" @@ -2483,7 +2483,7 @@ write_hash_of_string(GKeyFile *file, NMSetting *setting, const char *key, const hash = g_value_get_boxed(value); - keys = nm_utils_strdict_get_keys(hash, TRUE, &l); + keys = nm_strdict_get_keys(hash, TRUE, &l); for (i = 0; i < l; i++) { gs_free char *to_free = NULL; const char * property, *data; @@ -3351,7 +3351,7 @@ _read_setting(KeyfileReaderInfo *info) gs_unref_object NMSetting *setting = NULL; const char * alias; GType type; - guint i; + guint16 i; alias = nm_keyfile_plugin_get_setting_name_for_alias(info->group); if (!alias) @@ -3384,7 +3384,7 @@ _read_setting(KeyfileReaderInfo *info) if (n_keys > 0) { GHashTable *h = _nm_setting_option_hash(setting, TRUE); - nm_utils_strv_sort(keys, n_keys); + nm_strv_sort(keys, n_keys); for (k = 0; k < n_keys; k++) { gs_free char *key = keys[k]; gs_free_error GError *local = NULL; @@ -3779,11 +3779,7 @@ nm_keyfile_read(GKeyFile * keyfile, goto out_with_info_error; } - s_con = nm_connection_get_setting_connection(connection); - if (!s_con) { - s_con = NM_SETTING_CONNECTION(nm_setting_connection_new()); - nm_connection_add_setting(connection, NM_SETTING(s_con)); - } + s_con = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_CONNECTION); /* Make sure that we have 'interface-name' even if it was specified in the * "wrong" (ie, deprecated) group. @@ -4088,7 +4084,7 @@ nm_keyfile_write(NMConnection * connection, KeyfileWriterInfo info; NMSetting ** settings; int i; - guint j; + guint16 j; g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL); g_return_val_if_fail(!error || !*error, NULL); diff --git a/src/libnm-core-impl/nm-meta-setting-base-impl.c b/src/libnm-core-impl/nm-meta-setting-base-impl.c index a952ced9..8c1ad10e 100644 --- a/src/libnm-core-impl/nm-meta-setting-base-impl.c +++ b/src/libnm-core-impl/nm-meta-setting-base-impl.c @@ -8,7 +8,7 @@ #include "nm-meta-setting-base.h" #if _NM_META_SETTING_BASE_IMPL_LIBNM - #include "libnm-core-impl/nm-default-libnm-core.h" +#include "libnm-core-impl/nm-default-libnm-core.h" #endif #include "nm-setting-6lowpan.h" @@ -16,6 +16,7 @@ #include "nm-setting-adsl.h" #include "nm-setting-bluetooth.h" #include "nm-setting-bond.h" +#include "nm-setting-bond-port.h" #include "nm-setting-bridge-port.h" #include "nm-setting-bridge.h" #include "nm-setting-cdma.h" @@ -64,7 +65,7 @@ #include "nm-setting-wpan.h" #if _NM_META_SETTING_BASE_IMPL_LIBNM - #include "nm-setting-private.h" +#include "nm-setting-private.h" #endif /*****************************************************************************/ @@ -190,6 +191,13 @@ const NMMetaSettingInfo nm_meta_setting_infos[] = { .setting_name = NM_SETTING_BOND_SETTING_NAME, .get_setting_gtype = nm_setting_bond_get_type, }, + [NM_META_SETTING_TYPE_BOND_PORT] = + { + .meta_type = NM_META_SETTING_TYPE_BOND_PORT, + .setting_priority = NM_SETTING_PRIORITY_AUX, + .setting_name = NM_SETTING_BOND_PORT_SETTING_NAME, + .get_setting_gtype = nm_setting_bond_port_get_type, + }, [NM_META_SETTING_TYPE_BRIDGE] = { .meta_type = NM_META_SETTING_TYPE_BRIDGE, @@ -568,6 +576,7 @@ const NMMetaSettingType nm_meta_setting_types_by_priority[] = { NM_META_SETTING_TYPE_SRIOV, /* NM_SETTING_PRIORITY_AUX */ + NM_META_SETTING_TYPE_BOND_PORT, NM_META_SETTING_TYPE_BRIDGE_PORT, NM_META_SETTING_TYPE_ETHTOOL, NM_META_SETTING_TYPE_MATCH, diff --git a/src/libnm-core-impl/nm-property-compare.h b/src/libnm-core-impl/nm-property-compare.h index d422b1c8..2400bc42 100644 --- a/src/libnm-core-impl/nm-property-compare.h +++ b/src/libnm-core-impl/nm-property-compare.h @@ -8,7 +8,7 @@ #define __NM_PROPERTY_COMPARE_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif int nm_property_compare(GVariant *value1, GVariant *value2); diff --git a/src/libnm-core-impl/nm-setting-6lowpan.c b/src/libnm-core-impl/nm-setting-6lowpan.c index c07fb38e..606fa824 100644 --- a/src/libnm-core-impl/nm-setting-6lowpan.c +++ b/src/libnm-core-impl/nm-setting-6lowpan.c @@ -128,41 +128,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSetting6Lowpan * setting = NM_SETTING_6LOWPAN(object); - NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE(setting); - - switch (prop_id) { - case PROP_PARENT: - g_value_set_string(value, priv->parent); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSetting6Lowpan * setting = NM_SETTING_6LOWPAN(object); - NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE(setting); - - switch (prop_id) { - case PROP_PARENT: - g_free(priv->parent); - priv->parent = g_value_dup_string(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - static void nm_setting_6lowpan_init(NMSetting6Lowpan *setting) {} @@ -182,17 +147,6 @@ nm_setting_6lowpan_new(void) return g_object_new(NM_TYPE_SETTING_6LOWPAN, NULL); } -static void -finalize(GObject *object) -{ - NMSetting6Lowpan * setting = NM_SETTING_6LOWPAN(object); - NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE(setting); - - g_free(priv->parent); - - G_OBJECT_CLASS(nm_setting_6lowpan_parent_class)->finalize(object); -} - static void nm_setting_6lowpan_class_init(NMSetting6LowpanClass *klass) { @@ -202,9 +156,8 @@ nm_setting_6lowpan_class_init(NMSetting6LowpanClass *klass) g_type_class_add_private(klass, sizeof(NMSetting6LowpanPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -216,17 +169,19 @@ nm_setting_6lowpan_class_init(NMSetting6LowpanClass *klass) * * Since: 1.14 **/ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_6LOWPAN_PARENT, - PROP_PARENT, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_6lowpan_get_parent); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_6LOWPAN_PARENT, + PROP_PARENT, + NM_SETTING_PARAM_INFERRABLE, + NMSetting6LowpanPrivate, + parent); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_6LOWPAN, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_6LOWPAN, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-8021x.c b/src/libnm-core-impl/nm-setting-8021x.c index 6ddbd680..103443ba 100644 --- a/src/libnm-core-impl/nm-setting-8021x.c +++ b/src/libnm-core-impl/nm-setting-8021x.c @@ -131,53 +131,53 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSetting8021x, PROP_AUTH_TIMEOUT, ); typedef struct { - GSList * eap; /* GSList of strings */ - char * identity; - char * anonymous_identity; - char * pac_file; - GBytes * ca_cert; - char * ca_cert_password; - char * ca_path; - char * subject_match; - GSList * altsubject_matches; - char * domain_suffix_match; - char * domain_match; - GBytes * client_cert; - char * client_cert_password; - char * phase1_peapver; - char * phase1_peaplabel; - char * phase1_fast_provisioning; - char * phase2_auth; - char * phase2_autheap; - GBytes * phase2_ca_cert; - char * phase2_ca_cert_password; - char * phase2_ca_path; - char * phase2_subject_match; - GSList * phase2_altsubject_matches; - char * phase2_domain_suffix_match; - char * phase2_domain_match; - GBytes * phase2_client_cert; - char * phase2_client_cert_password; - char * password; - GBytes * password_raw; - char * pin; - GBytes * private_key; - char * private_key_password; - GBytes * phase2_private_key; - char * phase2_private_key_password; - int auth_timeout; - NMSetting8021xAuthFlags phase1_auth_flags; - NMSettingSecretFlags ca_cert_password_flags; - NMSettingSecretFlags client_cert_password_flags; - NMSettingSecretFlags phase2_ca_cert_password_flags; - NMSettingSecretFlags phase2_client_cert_password_flags; - NMSettingSecretFlags password_flags; - NMSettingSecretFlags password_raw_flags; - NMSettingSecretFlags pin_flags; - NMSettingSecretFlags private_key_password_flags; - NMSettingSecretFlags phase2_private_key_password_flags; - bool optional : 1; - bool system_ca_certs : 1; + GSList *eap; /* GSList of strings */ + char * identity; + char * anonymous_identity; + char * pac_file; + GBytes *ca_cert; + char * ca_cert_password; + char * ca_path; + char * subject_match; + GSList *altsubject_matches; + char * domain_suffix_match; + char * domain_match; + GBytes *client_cert; + char * client_cert_password; + char * phase1_peapver; + char * phase1_peaplabel; + char * phase1_fast_provisioning; + char * phase2_auth; + char * phase2_autheap; + GBytes *phase2_ca_cert; + char * phase2_ca_cert_password; + char * phase2_ca_path; + char * phase2_subject_match; + GSList *phase2_altsubject_matches; + char * phase2_domain_suffix_match; + char * phase2_domain_match; + GBytes *phase2_client_cert; + char * phase2_client_cert_password; + char * password; + GBytes *password_raw; + char * pin; + GBytes *private_key; + char * private_key_password; + GBytes *phase2_private_key; + char * phase2_private_key_password; + guint ca_cert_password_flags; + guint client_cert_password_flags; + guint phase2_ca_cert_password_flags; + guint phase2_client_cert_password_flags; + guint password_flags; + guint password_raw_flags; + guint pin_flags; + guint private_key_password_flags; + guint phase2_private_key_password_flags; + guint32 phase1_auth_flags; + gint32 auth_timeout; + bool optional; + bool system_ca_certs; } NMSetting8021xPrivate; /** @@ -594,13 +594,13 @@ _cert_impl_set(NMSetting8021x * setting, * property to the same PKCS#12 data. */ if (cert && p_client_cert && format == NM_CRYPTO_FILE_FORMAT_PKCS12 - && !nm_gbytes_equal0(cert, *p_client_cert)) { + && !nm_g_bytes_equal0(cert, *p_client_cert)) { g_bytes_unref(*p_client_cert); *p_client_cert = g_bytes_ref(cert); } else notify_client_cert = PROP_0; - if (p_cert && !nm_gbytes_equal0(cert, *p_cert)) { + if (p_cert && !nm_g_bytes_equal0(cert, *p_cert)) { g_bytes_unref(*p_cert); *p_cert = g_steal_pointer(&cert); } else @@ -2516,7 +2516,7 @@ need_secrets_sim(NMSetting8021x *self, GPtrArray *secrets, gboolean phase2) { NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self); - if (!priv->pin || !strlen(priv->pin)) + if (nm_str_is_empty(priv->pin)) g_ptr_array_add(secrets, NM_SETTING_802_1X_PIN); } @@ -2532,9 +2532,6 @@ need_private_key_password(GBytes * blob, if (flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED) return FALSE; - if (scheme == NM_SETTING_802_1X_CK_SCHEME_PKCS11 && flags == NM_SETTING_SECRET_FLAG_NONE) - return FALSE; - /* Private key password is required */ if (password) { if (path) @@ -2578,15 +2575,13 @@ need_secrets_tls(NMSetting8021x *self, GPtrArray *secrets, gboolean phase2) scheme = nm_setting_802_1x_get_phase2_ca_cert_scheme(self); if (scheme == NM_SETTING_802_1X_CK_SCHEME_PKCS11 - && !(priv->phase2_ca_cert_password_flags == NM_SETTING_SECRET_FLAG_NONE - || priv->phase2_ca_cert_password_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED) + && !(priv->phase2_ca_cert_password_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED) && !priv->phase2_ca_cert_password) g_ptr_array_add(secrets, NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD); scheme = nm_setting_802_1x_get_phase2_client_cert_scheme(self); if (scheme == NM_SETTING_802_1X_CK_SCHEME_PKCS11 - && !(priv->phase2_client_cert_password_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED - || priv->phase2_client_cert_password_flags == NM_SETTING_SECRET_FLAG_NONE) + && !(priv->phase2_client_cert_password_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED) && !priv->phase2_client_cert_password) g_ptr_array_add(secrets, NM_SETTING_802_1X_PHASE2_CLIENT_CERT_PASSWORD); } else { @@ -2607,15 +2602,13 @@ need_secrets_tls(NMSetting8021x *self, GPtrArray *secrets, gboolean phase2) scheme = nm_setting_802_1x_get_ca_cert_scheme(self); if (scheme == NM_SETTING_802_1X_CK_SCHEME_PKCS11 - && !(priv->ca_cert_password_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED - || priv->ca_cert_password_flags == NM_SETTING_SECRET_FLAG_NONE) + && !(priv->ca_cert_password_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED) && !priv->ca_cert_password) g_ptr_array_add(secrets, NM_SETTING_802_1X_CA_CERT_PASSWORD); scheme = nm_setting_802_1x_get_client_cert_scheme(self); if (scheme == NM_SETTING_802_1X_CK_SCHEME_PKCS11 - && !(priv->client_cert_password_flags == NM_SETTING_SECRET_FLAG_NONE - || priv->client_cert_password_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED) + && !(priv->client_cert_password_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED) && !priv->client_cert_password) g_ptr_array_add(secrets, NM_SETTING_802_1X_CLIENT_CERT_PASSWORD); } @@ -2762,7 +2755,7 @@ verify_ttls(NMSetting8021x *self, gboolean phase2, GError **error) { NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self); - if (!priv->identity || !strlen(priv->identity)) { + if (nm_str_is_empty(priv->identity)) { if (!priv->identity) { g_set_error_literal(error, NM_CONNECTION_ERROR, @@ -2804,21 +2797,18 @@ verify_identity(NMSetting8021x *self, gboolean phase2, GError **error) { NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self); - if (!priv->identity) { - g_set_error_literal(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_MISSING_PROPERTY, - _("property is missing")); - g_prefix_error(error, - "%s.%s: ", - NM_SETTING_802_1X_SETTING_NAME, - NM_SETTING_802_1X_IDENTITY); - return FALSE; - } else if (!strlen(priv->identity)) { - g_set_error_literal(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("property is empty")); + if (nm_str_is_empty(priv->identity)) { + if (!priv->identity) { + g_set_error_literal(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, + _("property is missing")); + } else { + g_set_error_literal(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("property is empty")); + } g_prefix_error(error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, @@ -2840,7 +2830,7 @@ need_secrets_phase2(NMSetting8021x *self, GPtrArray *secrets, gboolean phase2) /* Check phase2_auth and phase2_autheap */ method = priv->phase2_auth; - if (!method && priv->phase2_autheap) + if (!method) method = priv->phase2_autheap; if (!method) { @@ -2931,7 +2921,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) if (eap_methods_table[i].v_func == NULL) continue; if (!strcmp(eap_methods_table[i].method, method)) { - if (!(*eap_methods_table[i].v_func) (self, FALSE, error)) + if (!(*eap_methods_table[i].v_func)(self, FALSE, error)) return FALSE; break; } @@ -2977,7 +2967,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } - if (NM_FLAGS_ANY(priv->phase1_auth_flags, ~NM_SETTING_802_1X_AUTH_FLAGS_ALL)) { + if (NM_FLAGS_ANY(priv->phase1_auth_flags, ~((guint32) NM_SETTING_802_1X_AUTH_FLAGS_ALL))) { g_set_error_literal(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -3116,146 +3106,14 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) case PROP_EAP: g_value_take_boxed(value, _nm_utils_slist_to_strv(priv->eap, TRUE)); break; - case PROP_IDENTITY: - g_value_set_string(value, priv->identity); - break; - case PROP_ANONYMOUS_IDENTITY: - g_value_set_string(value, priv->anonymous_identity); - break; - case PROP_PAC_FILE: - g_value_set_string(value, priv->pac_file); - break; - case PROP_CA_CERT: - g_value_set_boxed(value, priv->ca_cert); - break; - case PROP_CA_CERT_PASSWORD: - g_value_set_string(value, priv->ca_cert_password); - break; - case PROP_CA_CERT_PASSWORD_FLAGS: - g_value_set_flags(value, priv->ca_cert_password_flags); - break; - case PROP_CA_PATH: - g_value_set_string(value, priv->ca_path); - break; - case PROP_SUBJECT_MATCH: - g_value_set_string(value, priv->subject_match); - break; case PROP_ALTSUBJECT_MATCHES: g_value_take_boxed(value, _nm_utils_slist_to_strv(priv->altsubject_matches, TRUE)); break; - case PROP_DOMAIN_SUFFIX_MATCH: - g_value_set_string(value, priv->domain_suffix_match); - break; - case PROP_DOMAIN_MATCH: - g_value_set_string(value, priv->domain_match); - break; - case PROP_CLIENT_CERT: - g_value_set_boxed(value, priv->client_cert); - break; - case PROP_CLIENT_CERT_PASSWORD: - g_value_set_string(value, priv->client_cert_password); - break; - case PROP_CLIENT_CERT_PASSWORD_FLAGS: - g_value_set_flags(value, priv->client_cert_password_flags); - break; - case PROP_PHASE1_PEAPVER: - g_value_set_string(value, priv->phase1_peapver); - break; - case PROP_PHASE1_PEAPLABEL: - g_value_set_string(value, priv->phase1_peaplabel); - break; - case PROP_PHASE1_FAST_PROVISIONING: - g_value_set_string(value, priv->phase1_fast_provisioning); - break; - case PROP_PHASE1_AUTH_FLAGS: - g_value_set_uint(value, priv->phase1_auth_flags); - break; - case PROP_PHASE2_AUTH: - g_value_set_string(value, priv->phase2_auth); - break; - case PROP_PHASE2_AUTHEAP: - g_value_set_string(value, priv->phase2_autheap); - break; - case PROP_PHASE2_CA_CERT: - g_value_set_boxed(value, priv->phase2_ca_cert); - break; - case PROP_PHASE2_CA_CERT_PASSWORD: - g_value_set_string(value, priv->phase2_ca_cert_password); - break; - case PROP_PHASE2_CA_CERT_PASSWORD_FLAGS: - g_value_set_flags(value, priv->phase2_ca_cert_password_flags); - break; - case PROP_PHASE2_CA_PATH: - g_value_set_string(value, priv->phase2_ca_path); - break; - case PROP_PHASE2_SUBJECT_MATCH: - g_value_set_string(value, priv->phase2_subject_match); - break; case PROP_PHASE2_ALTSUBJECT_MATCHES: g_value_take_boxed(value, _nm_utils_slist_to_strv(priv->phase2_altsubject_matches, TRUE)); break; - case PROP_PHASE2_DOMAIN_SUFFIX_MATCH: - g_value_set_string(value, priv->phase2_domain_suffix_match); - break; - case PROP_PHASE2_DOMAIN_MATCH: - g_value_set_string(value, priv->phase2_domain_match); - break; - case PROP_PHASE2_CLIENT_CERT: - g_value_set_boxed(value, priv->phase2_client_cert); - break; - case PROP_PHASE2_CLIENT_CERT_PASSWORD: - g_value_set_string(value, priv->phase2_client_cert_password); - break; - case PROP_PHASE2_CLIENT_CERT_PASSWORD_FLAGS: - g_value_set_flags(value, priv->phase2_client_cert_password_flags); - break; - case PROP_PASSWORD: - g_value_set_string(value, priv->password); - break; - case PROP_PASSWORD_FLAGS: - g_value_set_flags(value, priv->password_flags); - break; - case PROP_PASSWORD_RAW: - g_value_set_boxed(value, priv->password_raw); - break; - case PROP_PASSWORD_RAW_FLAGS: - g_value_set_flags(value, priv->password_raw_flags); - break; - case PROP_PRIVATE_KEY: - g_value_set_boxed(value, priv->private_key); - break; - case PROP_PRIVATE_KEY_PASSWORD: - g_value_set_string(value, priv->private_key_password); - break; - case PROP_PRIVATE_KEY_PASSWORD_FLAGS: - g_value_set_flags(value, priv->private_key_password_flags); - break; - case PROP_PHASE2_PRIVATE_KEY: - g_value_set_boxed(value, priv->phase2_private_key); - break; - case PROP_PHASE2_PRIVATE_KEY_PASSWORD: - g_value_set_string(value, priv->phase2_private_key_password); - break; - case PROP_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS: - g_value_set_flags(value, priv->phase2_private_key_password_flags); - break; - case PROP_PIN: - g_value_set_string(value, priv->pin); - break; - case PROP_PIN_FLAGS: - g_value_set_flags(value, priv->pin_flags); - break; - case PROP_SYSTEM_CA_CERTS: - g_value_set_boolean(value, priv->system_ca_certs); - break; - case PROP_AUTH_TIMEOUT: - g_value_set_int(value, priv->auth_timeout); - break; - case PROP_OPTIONAL: - g_value_set_boolean(value, priv->optional); - break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_get_property_direct(object, prop_id, value, pspec); break; } } @@ -3269,181 +3127,18 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps switch (prop_id) { case PROP_EAP: g_slist_free_full(priv->eap, g_free); - priv->eap = _nm_utils_strv_to_slist(g_value_get_boxed(value), TRUE); - break; - case PROP_IDENTITY: - g_free(priv->identity); - priv->identity = g_value_dup_string(value); - break; - case PROP_ANONYMOUS_IDENTITY: - g_free(priv->anonymous_identity); - priv->anonymous_identity = g_value_dup_string(value); - break; - case PROP_PAC_FILE: - g_free(priv->pac_file); - priv->pac_file = g_value_dup_string(value); - break; - case PROP_CA_CERT: - g_bytes_unref(priv->ca_cert); - priv->ca_cert = g_value_dup_boxed(value); - break; - case PROP_CA_CERT_PASSWORD: - g_free(priv->ca_cert_password); - priv->ca_cert_password = g_value_dup_string(value); - break; - case PROP_CA_CERT_PASSWORD_FLAGS: - priv->ca_cert_password_flags = g_value_get_flags(value); - break; - case PROP_CA_PATH: - g_free(priv->ca_path); - priv->ca_path = g_value_dup_string(value); - break; - case PROP_SUBJECT_MATCH: - g_free(priv->subject_match); - priv->subject_match = nm_strdup_not_empty(g_value_get_string(value)); + priv->eap = nm_strv_to_gslist(g_value_get_boxed(value), TRUE); break; case PROP_ALTSUBJECT_MATCHES: g_slist_free_full(priv->altsubject_matches, g_free); - priv->altsubject_matches = _nm_utils_strv_to_slist(g_value_get_boxed(value), TRUE); - break; - case PROP_DOMAIN_SUFFIX_MATCH: - g_free(priv->domain_suffix_match); - priv->domain_suffix_match = nm_strdup_not_empty(g_value_get_string(value)); - break; - case PROP_DOMAIN_MATCH: - g_free(priv->domain_match); - priv->domain_match = nm_strdup_not_empty(g_value_get_string(value)); - break; - case PROP_CLIENT_CERT: - g_bytes_unref(priv->client_cert); - priv->client_cert = g_value_dup_boxed(value); - break; - case PROP_CLIENT_CERT_PASSWORD: - g_free(priv->client_cert_password); - priv->client_cert_password = g_value_dup_string(value); - break; - case PROP_CLIENT_CERT_PASSWORD_FLAGS: - priv->client_cert_password_flags = g_value_get_flags(value); - break; - case PROP_PHASE1_PEAPVER: - g_free(priv->phase1_peapver); - priv->phase1_peapver = g_value_dup_string(value); - break; - case PROP_PHASE1_PEAPLABEL: - g_free(priv->phase1_peaplabel); - priv->phase1_peaplabel = g_value_dup_string(value); - break; - case PROP_PHASE1_FAST_PROVISIONING: - g_free(priv->phase1_fast_provisioning); - priv->phase1_fast_provisioning = g_value_dup_string(value); - break; - case PROP_PHASE1_AUTH_FLAGS: - priv->phase1_auth_flags = g_value_get_uint(value); - break; - case PROP_PHASE2_AUTH: - g_free(priv->phase2_auth); - priv->phase2_auth = g_value_dup_string(value); - break; - case PROP_PHASE2_AUTHEAP: - g_free(priv->phase2_autheap); - priv->phase2_autheap = g_value_dup_string(value); - break; - case PROP_PHASE2_CA_CERT: - g_bytes_unref(priv->phase2_ca_cert); - priv->phase2_ca_cert = g_value_dup_boxed(value); - break; - case PROP_PHASE2_CA_CERT_PASSWORD: - g_free(priv->phase2_ca_cert_password); - priv->phase2_ca_cert_password = g_value_dup_string(value); - break; - case PROP_PHASE2_CA_CERT_PASSWORD_FLAGS: - priv->phase2_ca_cert_password_flags = g_value_get_flags(value); - break; - case PROP_PHASE2_CA_PATH: - g_free(priv->phase2_ca_path); - priv->phase2_ca_path = g_value_dup_string(value); - break; - case PROP_PHASE2_SUBJECT_MATCH: - g_free(priv->phase2_subject_match); - priv->phase2_subject_match = nm_strdup_not_empty(g_value_get_string(value)); + priv->altsubject_matches = nm_strv_to_gslist(g_value_get_boxed(value), TRUE); break; case PROP_PHASE2_ALTSUBJECT_MATCHES: g_slist_free_full(priv->phase2_altsubject_matches, g_free); - priv->phase2_altsubject_matches = _nm_utils_strv_to_slist(g_value_get_boxed(value), TRUE); - break; - case PROP_PHASE2_DOMAIN_SUFFIX_MATCH: - g_free(priv->phase2_domain_suffix_match); - priv->phase2_domain_suffix_match = nm_strdup_not_empty(g_value_get_string(value)); - break; - case PROP_PHASE2_DOMAIN_MATCH: - g_free(priv->phase2_domain_match); - priv->phase2_domain_match = nm_strdup_not_empty(g_value_get_string(value)); - break; - case PROP_PHASE2_CLIENT_CERT: - g_bytes_unref(priv->phase2_client_cert); - priv->phase2_client_cert = g_value_dup_boxed(value); - break; - case PROP_PHASE2_CLIENT_CERT_PASSWORD: - g_free(priv->phase2_client_cert_password); - priv->phase2_client_cert_password = g_value_dup_string(value); - break; - case PROP_PHASE2_CLIENT_CERT_PASSWORD_FLAGS: - priv->phase2_client_cert_password_flags = g_value_get_flags(value); - break; - case PROP_PASSWORD: - g_free(priv->password); - priv->password = g_value_dup_string(value); - break; - case PROP_PASSWORD_FLAGS: - priv->password_flags = g_value_get_flags(value); - break; - case PROP_PASSWORD_RAW: - g_bytes_unref(priv->password_raw); - priv->password_raw = g_value_dup_boxed(value); - break; - case PROP_PASSWORD_RAW_FLAGS: - priv->password_raw_flags = g_value_get_flags(value); - break; - case PROP_PRIVATE_KEY: - g_bytes_unref(priv->private_key); - priv->private_key = g_value_dup_boxed(value); - break; - case PROP_PRIVATE_KEY_PASSWORD: - nm_free_secret(priv->private_key_password); - priv->private_key_password = g_value_dup_string(value); - break; - case PROP_PRIVATE_KEY_PASSWORD_FLAGS: - priv->private_key_password_flags = g_value_get_flags(value); - break; - case PROP_PHASE2_PRIVATE_KEY: - g_bytes_unref(priv->phase2_private_key); - priv->phase2_private_key = g_value_dup_boxed(value); - break; - case PROP_PHASE2_PRIVATE_KEY_PASSWORD: - nm_free_secret(priv->phase2_private_key_password); - priv->phase2_private_key_password = g_value_dup_string(value); - break; - case PROP_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS: - priv->phase2_private_key_password_flags = g_value_get_flags(value); - break; - case PROP_PIN: - g_free(priv->pin); - priv->pin = g_value_dup_string(value); - break; - case PROP_PIN_FLAGS: - priv->pin_flags = g_value_get_flags(value); - break; - case PROP_SYSTEM_CA_CERTS: - priv->system_ca_certs = g_value_get_boolean(value); - break; - case PROP_AUTH_TIMEOUT: - priv->auth_timeout = g_value_get_int(value); - break; - case PROP_OPTIONAL: - priv->optional = g_value_get_boolean(value); + priv->phase2_altsubject_matches = nm_strv_to_gslist(g_value_get_boxed(value), TRUE); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_set_property_direct(object, prop_id, value, pspec); break; } } @@ -3473,40 +3168,10 @@ finalize(GObject *object) NMSetting8021x * self = NM_SETTING_802_1X(object); NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self); - g_free(priv->identity); - g_free(priv->anonymous_identity); - g_free(priv->ca_path); - g_free(priv->subject_match); - g_free(priv->domain_suffix_match); - g_free(priv->phase1_peapver); - g_free(priv->phase1_peaplabel); - g_free(priv->phase1_fast_provisioning); - g_free(priv->phase2_auth); - g_free(priv->phase2_autheap); - g_free(priv->phase2_ca_path); - g_free(priv->phase2_subject_match); - g_free(priv->phase2_domain_suffix_match); - g_free(priv->password); - g_bytes_unref(priv->password_raw); - g_free(priv->pin); - g_slist_free_full(priv->eap, g_free); g_slist_free_full(priv->altsubject_matches, g_free); g_slist_free_full(priv->phase2_altsubject_matches, g_free); - g_bytes_unref(priv->ca_cert); - g_free(priv->ca_cert_password); - g_bytes_unref(priv->client_cert); - g_free(priv->client_cert_password); - g_bytes_unref(priv->private_key); - nm_free_secret(priv->private_key_password); - g_bytes_unref(priv->phase2_ca_cert); - g_free(priv->phase2_ca_cert_password); - g_bytes_unref(priv->phase2_client_cert); - g_free(priv->phase2_client_cert_password); - g_bytes_unref(priv->phase2_private_key); - nm_free_secret(priv->phase2_private_key_password); - G_OBJECT_CLASS(nm_setting_802_1x_parent_class)->finalize(object); } @@ -3562,11 +3227,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * example: IEEE_8021X_IDENTITY=itsme * ---end--- */ - obj_properties[PROP_IDENTITY] = g_param_spec_string(NM_SETTING_802_1X_IDENTITY, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_IDENTITY, + PROP_IDENTITY, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + identity); /** * NMSetting8021x:anonymous-identity: @@ -3581,12 +3248,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * description: Anonymous identity for EAP authentication methods. * ---end--- */ - obj_properties[PROP_ANONYMOUS_IDENTITY] = - g_param_spec_string(NM_SETTING_802_1X_ANONYMOUS_IDENTITY, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_ANONYMOUS_IDENTITY, + PROP_ANONYMOUS_IDENTITY, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + anonymous_identity); /** * NMSetting8021x:pac-file: @@ -3600,11 +3268,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * example: IEEE_8021X_PAC_FILE=/home/joe/my-fast.pac * ---end--- */ - obj_properties[PROP_PAC_FILE] = g_param_spec_string(NM_SETTING_802_1X_PAC_FILE, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_PAC_FILE, + PROP_PAC_FILE, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + pac_file); /** * NMSetting8021x:ca-cert: @@ -3634,11 +3304,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * example: IEEE_8021X_CA_CERT=/home/joe/cacert.crt * ---end--- */ - obj_properties[PROP_CA_CERT] = g_param_spec_boxed(NM_SETTING_802_1X_CA_CERT, - "", - "", - G_TYPE_BYTES, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_bytes(properties_override, + obj_properties, + NM_SETTING_802_1X_CA_CERT, + PROP_CA_CERT, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + ca_cert); /** * NMSetting8021x:ca-cert-password: @@ -3652,12 +3324,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) /* ---ifcfg-rh--- * ---end--- */ - obj_properties[PROP_CA_CERT_PASSWORD] = - g_param_spec_string(NM_SETTING_802_1X_CA_CERT_PASSWORD, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_CA_CERT_PASSWORD, + PROP_CA_CERT_PASSWORD, + NM_SETTING_PARAM_SECRET, + NMSetting8021xPrivate, + ca_cert_password); /** * NMSetting8021x:ca-cert-password-flags: @@ -3669,13 +3342,12 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) /* ---ifcfg-rh--- * ---end--- */ - obj_properties[PROP_CA_CERT_PASSWORD_FLAGS] = - g_param_spec_flags(NM_SETTING_802_1X_CA_CERT_PASSWORD_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_secret_flags(properties_override, + obj_properties, + NM_SETTING_802_1X_CA_CERT_PASSWORD_FLAGS, + PROP_CA_CERT_PASSWORD_FLAGS, + NMSetting8021xPrivate, + ca_cert_password_flags); /** * NMSetting8021x:ca-path: @@ -3693,11 +3365,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * description: The search path for the certificate. * ---end--- */ - obj_properties[PROP_CA_PATH] = g_param_spec_string(NM_SETTING_802_1X_CA_PATH, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_CA_PATH, + PROP_CA_PATH, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + ca_path); /** * NMSetting8021x:subject-match: @@ -3715,12 +3389,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * example: IEEE_8021X_SUBJECT_MATCH="Red Hat" * ---end--- */ - obj_properties[PROP_SUBJECT_MATCH] = - g_param_spec_string(NM_SETTING_802_1X_SUBJECT_MATCH, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_SUBJECT_MATCH, + PROP_SUBJECT_MATCH, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + subject_match); /** * NMSetting8021x:altsubject-matches: @@ -3762,12 +3437,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * variable: IEEE_8021X_DOMAIN_SUFFIX_MATCH(+) * ---end--- */ - obj_properties[PROP_DOMAIN_SUFFIX_MATCH] = - g_param_spec_string(NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_DOMAIN_SUFFIX_MATCH, + PROP_DOMAIN_SUFFIX_MATCH, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + domain_suffix_match); /** * NMSetting8021x:domain-match: @@ -3787,12 +3463,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * variable: IEEE_8021X_DOMAIN_MATCH(+) * ---end--- */ - obj_properties[PROP_DOMAIN_MATCH] = - g_param_spec_string(NM_SETTING_802_1X_DOMAIN_MATCH, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_DOMAIN_MATCH, + PROP_DOMAIN_MATCH, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + domain_match); /** * NMSetting8021x:client-cert: @@ -3817,12 +3494,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * example: IEEE_8021X_CLIENT_CERT=/home/joe/mycert.crt * ---end--- */ - obj_properties[PROP_CLIENT_CERT] = - g_param_spec_boxed(NM_SETTING_802_1X_CLIENT_CERT, - "", - "", - G_TYPE_BYTES, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_bytes(properties_override, + obj_properties, + NM_SETTING_802_1X_CLIENT_CERT, + PROP_CLIENT_CERT, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + client_cert); /** * NMSetting8021x:client-cert-password: @@ -3836,12 +3514,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) /* ---ifcfg-rh--- * ---end--- */ - obj_properties[PROP_CLIENT_CERT_PASSWORD] = - g_param_spec_string(NM_SETTING_802_1X_CLIENT_CERT_PASSWORD, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_CLIENT_CERT_PASSWORD, + PROP_CLIENT_CERT_PASSWORD, + NM_SETTING_PARAM_SECRET, + NMSetting8021xPrivate, + client_cert_password); /** * NMSetting8021x:client-cert-password-flags: @@ -3853,13 +3532,12 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) /* ---ifcfg-rh--- * ---end--- */ - obj_properties[PROP_CLIENT_CERT_PASSWORD_FLAGS] = - g_param_spec_flags(NM_SETTING_802_1X_CLIENT_CERT_PASSWORD_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_secret_flags(properties_override, + obj_properties, + NM_SETTING_802_1X_CLIENT_CERT_PASSWORD_FLAGS, + PROP_CLIENT_CERT_PASSWORD_FLAGS, + NMSetting8021xPrivate, + client_cert_password_flags); /** * NMSetting8021x:phase1-peapver: @@ -3878,12 +3556,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * description: Use to force a specific PEAP version. * ---end--- */ - obj_properties[PROP_PHASE1_PEAPVER] = - g_param_spec_string(NM_SETTING_802_1X_PHASE1_PEAPVER, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE1_PEAPVER, + PROP_PHASE1_PEAPVER, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + phase1_peapver); /** * NMSetting8021x:phase1-peaplabel: @@ -3901,12 +3580,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * description: Use to force the new PEAP label during key derivation. * ---end--- */ - obj_properties[PROP_PHASE1_PEAPLABEL] = - g_param_spec_string(NM_SETTING_802_1X_PHASE1_PEAPLABEL, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE1_PEAPLABEL, + PROP_PHASE1_PEAPLABEL, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + phase1_peaplabel); /** * NMSetting8021x:phase1-fast-provisioning: @@ -3926,12 +3606,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * example: IEEE_8021X_FAST_PROVISIONING="allow-auth allow-unauth" * ---end--- */ - obj_properties[PROP_PHASE1_FAST_PROVISIONING] = - g_param_spec_string(NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE1_FAST_PROVISIONING, + PROP_PHASE1_FAST_PROVISIONING, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + phase1_fast_provisioning); /** * NMSetting8021x:phase1-auth-flags: @@ -3953,14 +3634,16 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * example: IEEE_8021X_PHASE1_AUTH_FLAGS="tls-1-0-disable tls-1-1-disable" * ---end--- */ - obj_properties[PROP_PHASE1_AUTH_FLAGS] = - g_param_spec_uint(NM_SETTING_802_1X_PHASE1_AUTH_FLAGS, - "", - "", - 0, - G_MAXUINT32, - NM_SETTING_802_1X_AUTH_FLAGS_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE1_AUTH_FLAGS, + PROP_PHASE1_AUTH_FLAGS, + 0, + G_MAXUINT32, + NM_SETTING_802_1X_AUTH_FLAGS_NONE, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + phase1_auth_flags); /** * NMSetting8021x:phase2-auth: @@ -3986,12 +3669,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * example: IEEE_8021X_INNER_AUTH_METHODS=PAP * ---end--- */ - obj_properties[PROP_PHASE2_AUTH] = - g_param_spec_string(NM_SETTING_802_1X_PHASE2_AUTH, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE2_AUTH, + PROP_PHASE2_AUTH, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + phase2_auth); /** * NMSetting8021x:phase2-autheap: @@ -4012,12 +3696,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * example: IEEE_8021X_INNER_AUTH_METHODS="MSCHAPV2 EAP-TLS" * ---end--- */ - obj_properties[PROP_PHASE2_AUTHEAP] = - g_param_spec_string(NM_SETTING_802_1X_PHASE2_AUTHEAP, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE2_AUTHEAP, + PROP_PHASE2_AUTHEAP, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + phase2_autheap); /** * NMSetting8021x:phase2-ca-cert: @@ -4041,12 +3726,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * Setting this property directly is discouraged; use the * nm_setting_802_1x_set_phase2_ca_cert() function instead. **/ - obj_properties[PROP_PHASE2_CA_CERT] = - g_param_spec_boxed(NM_SETTING_802_1X_PHASE2_CA_CERT, - "", - "", - G_TYPE_BYTES, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_bytes(properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE2_CA_CERT, + PROP_PHASE2_CA_CERT, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + phase2_ca_cert); /** * NMSetting8021x:phase2-ca-cert-password: @@ -4060,12 +3746,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) /* ---ifcfg-rh--- * ---end--- */ - obj_properties[PROP_PHASE2_CA_CERT_PASSWORD] = - g_param_spec_string(NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD, + PROP_PHASE2_CA_CERT_PASSWORD, + NM_SETTING_PARAM_SECRET, + NMSetting8021xPrivate, + phase2_ca_cert_password); /** * NMSetting8021x:phase2-ca-cert-password-flags: @@ -4077,13 +3764,12 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) /* ---ifcfg-rh--- * ---end--- */ - obj_properties[PROP_PHASE2_CA_CERT_PASSWORD_FLAGS] = - g_param_spec_flags(NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_secret_flags(properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE2_CA_CERT_PASSWORD_FLAGS, + PROP_PHASE2_CA_CERT_PASSWORD_FLAGS, + NMSetting8021xPrivate, + phase2_ca_cert_password_flags); /** * NMSetting8021x:phase2-ca-path: @@ -4101,12 +3787,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * description: The search path for the certificate. * ---end--- */ - obj_properties[PROP_PHASE2_CA_PATH] = - g_param_spec_string(NM_SETTING_802_1X_PHASE2_CA_PATH, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE2_CA_PATH, + PROP_PHASE2_CA_PATH, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + phase2_ca_path); /** * NMSetting8021x:phase2-subject-match: @@ -4125,12 +3812,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * example: IEEE_8021X_PHASE2_SUBJECT_MATCH="Red Hat" * ---end--- */ - obj_properties[PROP_PHASE2_SUBJECT_MATCH] = - g_param_spec_string(NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE2_SUBJECT_MATCH, + PROP_PHASE2_SUBJECT_MATCH, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + phase2_subject_match); /** * NMSetting8021x:phase2-altsubject-matches: @@ -4172,12 +3860,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * variable: IEEE_8021X_PHASE2_DOMAIN_SUFFIX_MATCH(+) * ---end--- */ - obj_properties[PROP_PHASE2_DOMAIN_SUFFIX_MATCH] = - g_param_spec_string(NM_SETTING_802_1X_PHASE2_DOMAIN_SUFFIX_MATCH, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE2_DOMAIN_SUFFIX_MATCH, + PROP_PHASE2_DOMAIN_SUFFIX_MATCH, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + phase2_domain_suffix_match); /** * NMSetting8021x:phase2-domain-match: @@ -4198,12 +3887,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * variable: IEEE_8021X_PHASE2_DOMAIN_MATCH(+) * ---end--- */ - obj_properties[PROP_PHASE2_DOMAIN_MATCH] = - g_param_spec_string(NM_SETTING_802_1X_PHASE2_DOMAIN_MATCH, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE2_DOMAIN_MATCH, + PROP_PHASE2_DOMAIN_MATCH, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + phase2_domain_match); /** * NMSetting8021x:phase2-client-cert: @@ -4231,12 +3921,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * example: IEEE_8021X_INNER_CLIENT_CERT=/home/joe/mycert.crt * ---end--- */ - obj_properties[PROP_PHASE2_CLIENT_CERT] = - g_param_spec_boxed(NM_SETTING_802_1X_PHASE2_CLIENT_CERT, - "", - "", - G_TYPE_BYTES, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_bytes(properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE2_CLIENT_CERT, + PROP_PHASE2_CLIENT_CERT, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + phase2_client_cert); /** * NMSetting8021x:phase2-client-cert-password: @@ -4250,12 +3941,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) /* ---ifcfg-rh--- * ---end--- */ - obj_properties[PROP_PHASE2_CLIENT_CERT_PASSWORD] = - g_param_spec_string(NM_SETTING_802_1X_PHASE2_CLIENT_CERT_PASSWORD, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE2_CLIENT_CERT_PASSWORD, + PROP_PHASE2_CLIENT_CERT_PASSWORD, + NM_SETTING_PARAM_SECRET, + NMSetting8021xPrivate, + phase2_client_cert_password); /** * NMSetting8021x:phase2-client-cert-password-flags: @@ -4267,13 +3959,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) /* ---ifcfg-rh--- * ---end--- */ - obj_properties[PROP_PHASE2_CLIENT_CERT_PASSWORD_FLAGS] = - g_param_spec_flags(NM_SETTING_802_1X_PHASE2_CLIENT_CERT_PASSWORD_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_secret_flags( + properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE2_CLIENT_CERT_PASSWORD_FLAGS, + PROP_PHASE2_CLIENT_CERT_PASSWORD_FLAGS, + NMSetting8021xPrivate, + phase2_client_cert_password_flags); /** * NMSetting8021x:password: @@ -4289,12 +3981,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * lookaside file, or it can be owned by a secret agent. * ---end--- */ - obj_properties[PROP_PASSWORD] = - g_param_spec_string(NM_SETTING_802_1X_PASSWORD, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_PASSWORD, + PROP_PASSWORD, + NM_SETTING_PARAM_SECRET, + NMSetting8021xPrivate, + password); /** * NMSetting8021x:password-flags: @@ -4308,13 +4001,12 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * description: Password flags for IEEE_8021X_PASSWORD password. * ---end--- */ - obj_properties[PROP_PASSWORD_FLAGS] = - g_param_spec_flags(NM_SETTING_802_1X_PASSWORD_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_secret_flags(properties_override, + obj_properties, + NM_SETTING_802_1X_PASSWORD_FLAGS, + PROP_PASSWORD_FLAGS, + NMSetting8021xPrivate, + password_flags); /** * NMSetting8021x:password-raw: @@ -4332,12 +4024,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * example: IEEE_8021X_PASSWORD_RAW=041c8320083aa4bf * ---end--- */ - obj_properties[PROP_PASSWORD_RAW] = - g_param_spec_boxed(NM_SETTING_802_1X_PASSWORD_RAW, - "", - "", - G_TYPE_BYTES, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_bytes(properties_override, + obj_properties, + NM_SETTING_802_1X_PASSWORD_RAW, + PROP_PASSWORD_RAW, + NM_SETTING_PARAM_SECRET, + NMSetting8021xPrivate, + password_raw); /** * NMSetting8021x:password-raw-flags: @@ -4350,13 +4043,12 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * description: The secret flags for password-raw. * ---end--- */ - obj_properties[PROP_PASSWORD_RAW_FLAGS] = - g_param_spec_flags(NM_SETTING_802_1X_PASSWORD_RAW_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_secret_flags(properties_override, + obj_properties, + NM_SETTING_802_1X_PASSWORD_RAW_FLAGS, + PROP_PASSWORD_RAW_FLAGS, + NMSetting8021xPrivate, + password_raw_flags); /** * NMSetting8021x:private-key: @@ -4396,12 +4088,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * example: IEEE_8021X_PRIVATE_KEY=/home/joe/mykey.p12 * ---end--- */ - obj_properties[PROP_PRIVATE_KEY] = - g_param_spec_boxed(NM_SETTING_802_1X_PRIVATE_KEY, - "", - "", - G_TYPE_BYTES, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_bytes(properties_override, + obj_properties, + NM_SETTING_802_1X_PRIVATE_KEY, + PROP_PRIVATE_KEY, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + private_key); /** * NMSetting8021x:private-key-password: @@ -4420,12 +4113,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * lookaside file, or it can be owned by a secret agent. * ---end--- */ - obj_properties[PROP_PRIVATE_KEY_PASSWORD] = - g_param_spec_string(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD, + PROP_PRIVATE_KEY_PASSWORD, + NM_SETTING_PARAM_SECRET, + NMSetting8021xPrivate, + private_key_password); /** * NMSetting8021x:private-key-password-flags: @@ -4440,13 +4134,12 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * description: Password flags for IEEE_8021X_PRIVATE_KEY_PASSWORD password. * ---end--- */ - obj_properties[PROP_PRIVATE_KEY_PASSWORD_FLAGS] = - g_param_spec_flags(NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_secret_flags(properties_override, + obj_properties, + NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS, + PROP_PRIVATE_KEY_PASSWORD_FLAGS, + NMSetting8021xPrivate, + private_key_password_flags); /** * NMSetting8021x:phase2-private-key: @@ -4480,12 +4173,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * description: Private key for inner authentication method for EAP-TLS. * ---end--- */ - obj_properties[PROP_PHASE2_PRIVATE_KEY] = - g_param_spec_boxed(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, - "", - "", - G_TYPE_BYTES, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_bytes(properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, + PROP_PHASE2_PRIVATE_KEY, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + phase2_private_key); /** * NMSetting8021x:phase2-private-key-password: @@ -4505,12 +4199,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * lookaside file, or it can be owned by a secret agent. * ---end--- */ - obj_properties[PROP_PHASE2_PRIVATE_KEY_PASSWORD] = - g_param_spec_string(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD, + PROP_PHASE2_PRIVATE_KEY_PASSWORD, + NM_SETTING_PARAM_SECRET, + NMSetting8021xPrivate, + phase2_private_key_password); /** * NMSetting8021x:phase2-private-key-password-flags: @@ -4525,13 +4220,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * description: Password flags for IEEE_8021X_INNER_PRIVATE_KEY_PASSWORD password. * ---end--- */ - obj_properties[PROP_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS] = - g_param_spec_flags(NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_secret_flags( + properties_override, + obj_properties, + NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS, + PROP_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS, + NMSetting8021xPrivate, + phase2_private_key_password_flags); /** * NMSetting8021x:pin: @@ -4544,12 +4239,13 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * description: The pin secret used for EAP authentication methods. * ---end--- */ - obj_properties[PROP_PIN] = - g_param_spec_string(NM_SETTING_802_1X_PIN, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_802_1X_PIN, + PROP_PIN, + NM_SETTING_PARAM_SECRET, + NMSetting8021xPrivate, + pin); /** * NMSetting8021x:pin-flags: @@ -4562,12 +4258,12 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * description: The secret flags for the pin property. * ---end--- */ - obj_properties[PROP_PIN_FLAGS] = g_param_spec_flags(NM_SETTING_802_1X_PIN_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_secret_flags(properties_override, + obj_properties, + NM_SETTING_802_1X_PIN_FLAGS, + PROP_PIN_FLAGS, + NMSetting8021xPrivate, + pin_flags); /** * NMSetting8021x:system-ca-certs: @@ -4588,13 +4284,14 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * description: a boolean value. * ---end--- */ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_802_1X_SYSTEM_CA_CERTS, - PROP_SYSTEM_CA_CERTS, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_802_1x_get_system_ca_certs); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_802_1X_SYSTEM_CA_CERTS, + PROP_SYSTEM_CA_CERTS, + FALSE, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + system_ca_certs); /** * NMSetting8021x:auth-timeout: @@ -4611,14 +4308,16 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * description: Timeout in seconds for the 802.1X authentication. Zero means the global default or 25. * ---end--- */ - obj_properties[PROP_AUTH_TIMEOUT] = g_param_spec_int( - NM_SETTING_802_1X_AUTH_TIMEOUT, - "", - "", - 0, - G_MAXINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_802_1X_AUTH_TIMEOUT, + PROP_AUTH_TIMEOUT, + 0, + G_MAXINT32, + 0, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSetting8021xPrivate, + auth_timeout); /** * NMSetting8021x:optional: @@ -4638,18 +4337,20 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass) * description: whether the 802.1X authentication is optional * ---end--- */ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_802_1X_OPTIONAL, - PROP_OPTIONAL, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_802_1x_get_optional); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_802_1X_OPTIONAL, + PROP_OPTIONAL, + FALSE, + NM_SETTING_PARAM_NONE, + NMSetting8021xPrivate, + optional); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_802_1X, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_802_1X, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-adsl.c b/src/libnm-core-impl/nm-setting-adsl.c index 9f45163d..8e5dc8cf 100644 --- a/src/libnm-core-impl/nm-setting-adsl.c +++ b/src/libnm-core-impl/nm-setting-adsl.c @@ -31,13 +31,13 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_USERNAME, PROP_VCI, ); typedef struct { - char * username; - char * password; - NMSettingSecretFlags password_flags; - char * protocol; - char * encapsulation; - guint32 vpi; - guint32 vci; + char * username; + char * password; + char * protocol; + char * encapsulation; + guint password_flags; + guint32 vpi; + guint32 vci; } NMSettingAdslPrivate; /** @@ -243,81 +243,6 @@ need_secrets(NMSetting *setting) /*****************************************************************************/ -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingAdsl *setting = NM_SETTING_ADSL(object); - - switch (prop_id) { - case PROP_USERNAME: - g_value_set_string(value, nm_setting_adsl_get_username(setting)); - break; - case PROP_PASSWORD: - g_value_set_string(value, nm_setting_adsl_get_password(setting)); - break; - case PROP_PASSWORD_FLAGS: - g_value_set_flags(value, nm_setting_adsl_get_password_flags(setting)); - break; - case PROP_PROTOCOL: - g_value_set_string(value, nm_setting_adsl_get_protocol(setting)); - break; - case PROP_ENCAPSULATION: - g_value_set_string(value, nm_setting_adsl_get_encapsulation(setting)); - break; - case PROP_VPI: - g_value_set_uint(value, nm_setting_adsl_get_vpi(setting)); - break; - case PROP_VCI: - g_value_set_uint(value, nm_setting_adsl_get_vci(setting)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE(object); - const char * str; - - switch (prop_id) { - case PROP_USERNAME: - g_free(priv->username); - priv->username = g_value_dup_string(value); - break; - case PROP_PASSWORD: - g_free(priv->password); - priv->password = g_value_dup_string(value); - break; - case PROP_PASSWORD_FLAGS: - priv->password_flags = g_value_get_flags(value); - break; - case PROP_PROTOCOL: - g_free(priv->protocol); - str = g_value_get_string(value); - priv->protocol = str ? g_ascii_strdown(str, -1) : NULL; - break; - case PROP_ENCAPSULATION: - g_free(priv->encapsulation); - str = g_value_get_string(value); - priv->encapsulation = str ? g_ascii_strdown(str, -1) : NULL; - break; - case PROP_VPI: - priv->vpi = g_value_get_uint(value); - break; - case PROP_VCI: - priv->vci = g_value_get_uint(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - static void nm_setting_adsl_init(NMSettingAdsl *setting) {} @@ -335,19 +260,6 @@ nm_setting_adsl_new(void) return g_object_new(NM_TYPE_SETTING_ADSL, NULL); } -static void -finalize(GObject *object) -{ - NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE(object); - - g_free(priv->username); - g_free(priv->password); - g_free(priv->protocol); - g_free(priv->encapsulation); - - G_OBJECT_CLASS(nm_setting_adsl_parent_class)->finalize(object); -} - static void nm_setting_adsl_class_init(NMSettingAdslClass *klass) { @@ -357,9 +269,8 @@ nm_setting_adsl_class_init(NMSettingAdslClass *klass) g_type_class_add_private(klass, sizeof(NMSettingAdslPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; setting_class->verify_secrets = verify_secrets; @@ -370,92 +281,104 @@ nm_setting_adsl_class_init(NMSettingAdslClass *klass) * * Username used to authenticate with the ADSL service. **/ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_ADSL_USERNAME, - PROP_USERNAME, - NM_SETTING_PARAM_NONE, - nm_setting_adsl_get_username); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_ADSL_USERNAME, + PROP_USERNAME, + NM_SETTING_PARAM_NONE, + NMSettingAdslPrivate, + username); /** * NMSettingAdsl:password: * * Password used to authenticate with the ADSL service. **/ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_ADSL_PASSWORD, - PROP_PASSWORD, - NM_SETTING_PARAM_SECRET, - nm_setting_adsl_get_password); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_ADSL_PASSWORD, + PROP_PASSWORD, + NM_SETTING_PARAM_SECRET, + NMSettingAdslPrivate, + password); /** * NMSettingAdsl:password-flags: * * Flags indicating how to handle the #NMSettingAdsl:password property. **/ - obj_properties[PROP_PASSWORD_FLAGS] = - g_param_spec_flags(NM_SETTING_ADSL_PASSWORD_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_secret_flags(properties_override, + obj_properties, + NM_SETTING_ADSL_PASSWORD_FLAGS, + PROP_PASSWORD_FLAGS, + NMSettingAdslPrivate, + password_flags); /** * NMSettingAdsl:protocol: * * ADSL connection protocol. Can be "pppoa", "pppoe" or "ipoatm". **/ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_ADSL_PROTOCOL, - PROP_PROTOCOL, - NM_SETTING_PARAM_NONE, - nm_setting_adsl_get_protocol); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_ADSL_PROTOCOL, + PROP_PROTOCOL, + NM_SETTING_PARAM_NONE, + NMSettingAdslPrivate, + protocol, + .direct_set_string_ascii_strdown = TRUE); /** * NMSettingAdsl:encapsulation: * * Encapsulation of ADSL connection. Can be "vcmux" or "llc". **/ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_ADSL_ENCAPSULATION, - PROP_ENCAPSULATION, - NM_SETTING_PARAM_NONE, - nm_setting_adsl_get_encapsulation); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_ADSL_ENCAPSULATION, + PROP_ENCAPSULATION, + NM_SETTING_PARAM_NONE, + NMSettingAdslPrivate, + encapsulation, + .direct_set_string_ascii_strdown = TRUE); /** * NMSettingAdsl:vpi: * * VPI of ADSL connection **/ - obj_properties[PROP_VPI] = g_param_spec_uint(NM_SETTING_ADSL_VPI, - "", - "", - 0, - 65536, - 0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_ADSL_VPI, + PROP_VPI, + 0, + 65536, + 0, + NM_SETTING_PARAM_NONE, + NMSettingAdslPrivate, + vpi); /** * NMSettingAdsl:vci: * * VCI of ADSL connection **/ - obj_properties[PROP_VCI] = g_param_spec_uint(NM_SETTING_ADSL_VCI, - "", - "", - 0, - 65536, - 0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_ADSL_VCI, + PROP_VCI, + 0, + 65536, + 0, + NM_SETTING_PARAM_NONE, + NMSettingAdslPrivate, + vci); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_ADSL, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_ADSL, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-bluetooth.c b/src/libnm-core-impl/nm-setting-bluetooth.c index 4bd91a69..53e4912f 100644 --- a/src/libnm-core-impl/nm-setting-bluetooth.c +++ b/src/libnm-core-impl/nm-setting-bluetooth.c @@ -94,6 +94,8 @@ nm_setting_bluetooth_get_bdaddr(NMSettingBluetooth *setting) return NM_SETTING_BLUETOOTH_GET_PRIVATE(setting)->bdaddr; } +/*****************************************************************************/ + static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { @@ -228,46 +230,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingBluetooth *setting = NM_SETTING_BLUETOOTH(object); - - switch (prop_id) { - case PROP_BDADDR: - g_value_set_string(value, nm_setting_bluetooth_get_bdaddr(setting)); - break; - case PROP_TYPE: - g_value_set_string(value, nm_setting_bluetooth_get_connection_type(setting)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingBluetoothPrivate *priv = NM_SETTING_BLUETOOTH_GET_PRIVATE(object); - - switch (prop_id) { - case PROP_BDADDR: - g_free(priv->bdaddr); - priv->bdaddr = g_value_dup_string(value); - break; - case PROP_TYPE: - g_free(priv->type); - priv->type = g_value_dup_string(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - static void nm_setting_bluetooth_init(NMSettingBluetooth *setting) {} @@ -285,17 +247,6 @@ nm_setting_bluetooth_new(void) return g_object_new(NM_TYPE_SETTING_BLUETOOTH, NULL); } -static void -finalize(GObject *object) -{ - NMSettingBluetoothPrivate *priv = NM_SETTING_BLUETOOTH_GET_PRIVATE(object); - - g_free(priv->bdaddr); - g_free(priv->type); - - G_OBJECT_CLASS(nm_setting_bluetooth_parent_class)->finalize(object); -} - static void nm_setting_bluetooth_class_init(NMSettingBluetoothClass *klass) { @@ -305,9 +256,8 @@ nm_setting_bluetooth_class_init(NMSettingBluetoothClass *klass) g_type_class_add_private(klass, sizeof(NMSettingBluetoothPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -316,15 +266,14 @@ nm_setting_bluetooth_class_init(NMSettingBluetoothClass *klass) * * The Bluetooth address of the device. **/ - obj_properties[PROP_BDADDR] = g_param_spec_string( - NM_SETTING_BLUETOOTH_BDADDR, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_BDADDR], - &nm_sett_info_propert_type_mac_address); + _nm_setting_property_define_direct_mac_address(properties_override, + obj_properties, + NM_SETTING_BLUETOOTH_BDADDR, + PROP_BDADDR, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBluetoothPrivate, + bdaddr, + .direct_set_string_mac_address_len = ETH_ALEN); /** * NMSettingBluetooth:type: @@ -332,17 +281,19 @@ nm_setting_bluetooth_class_init(NMSettingBluetoothClass *klass) * Either "dun" for Dial-Up Networking connections or "panu" for Personal * Area Networking connections to devices supporting the NAP profile. **/ - obj_properties[PROP_TYPE] = g_param_spec_string(NM_SETTING_BLUETOOTH_TYPE, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_BLUETOOTH_TYPE, + PROP_TYPE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBluetoothPrivate, + type); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_BLUETOOTH, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_BLUETOOTH, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-bond-port.c b/src/libnm-core-impl/nm-setting-bond-port.c new file mode 100644 index 00000000..4538e8b9 --- /dev/null +++ b/src/libnm-core-impl/nm-setting-bond-port.c @@ -0,0 +1,173 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021 Red Hat, Inc. + */ + +#include "libnm-core-impl/nm-default-libnm-core.h" + +#include "nm-connection-private.h" +#include "nm-setting-bond-port.h" +#include "nm-setting-bond.h" +#include "nm-setting-connection.h" +#include "nm-utils-private.h" +#include "nm-utils.h" + +/** + * SECTION:nm-setting-bond-port + * @short_description: Describes connection properties for bond ports + * + * The #NMSettingBondPort object is a #NMSetting subclass that describes + * optional properties that apply to bond ports. + **/ + +/*****************************************************************************/ + +NM_GOBJECT_PROPERTIES_DEFINE(NMSettingBondPort, PROP_QUEUE_ID, ); + +typedef struct { + guint32 queue_id; +} NMSettingBondPortPrivate; + +/** + * NMSettingBondPort: + * + * Bond Port Settings + */ +struct _NMSettingBondPort { + NMSetting parent; + NMSettingBondPortPrivate _priv; +}; + +struct _NMSettingBondPortClass { + NMSettingClass parent; +}; + +G_DEFINE_TYPE(NMSettingBondPort, nm_setting_bond_port, NM_TYPE_SETTING) + +#define NM_SETTING_BOND_PORT_GET_PRIVATE(self) \ + _NM_GET_PRIVATE(self, NMSettingBondPort, NM_IS_SETTING_BOND_PORT, NMSetting) + +/*****************************************************************************/ + +/** + * nm_setting_bond_port_get_queue_id: + * @setting: the #NMSettingBondPort + * + * Returns: the #NMSettingBondPort:queue_id property of the setting + * + * Since: 1.34 + **/ +guint32 +nm_setting_bond_port_get_queue_id(NMSettingBondPort *setting) +{ + g_return_val_if_fail(NM_IS_SETTING_BOND_PORT(setting), 0); + + return NM_SETTING_BOND_PORT_GET_PRIVATE(setting)->queue_id; +} + +/*****************************************************************************/ + +static gboolean +verify(NMSetting *setting, NMConnection *connection, GError **error) +{ + if (connection) { + NMSettingConnection *s_con; + const char * slave_type; + + s_con = nm_connection_get_setting_connection(connection); + if (!s_con) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_SETTING, + _("missing setting")); + g_prefix_error(error, "%s: ", NM_SETTING_CONNECTION_SETTING_NAME); + return FALSE; + } + + slave_type = nm_setting_connection_get_slave_type(s_con); + if (!nm_streq0(slave_type, NM_SETTING_BOND_SETTING_NAME)) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("A connection with a '%s' setting must have the slave-type set to '%s'"), + NM_SETTING_BOND_PORT_SETTING_NAME, + NM_SETTING_BOND_SETTING_NAME); + g_prefix_error(error, + "%s.%s: ", + NM_SETTING_CONNECTION_SETTING_NAME, + NM_SETTING_CONNECTION_SLAVE_TYPE); + return FALSE; + } + } + + return TRUE; +} + +/*****************************************************************************/ + +static void +nm_setting_bond_port_init(NMSettingBondPort *setting) +{} + +/** + * nm_setting_bond_port_new: + * + * Creates a new #NMSettingBondPort object with default values. + * + * Returns: (transfer full): the new empty #NMSettingBondPort object + * + * Since: 1.34 + **/ +NMSetting * +nm_setting_bond_port_new(void) +{ + return g_object_new(NM_TYPE_SETTING_BOND_PORT, NULL); +} + +static void +nm_setting_bond_port_class_init(NMSettingBondPortClass *klass) +{ + GObjectClass * object_class = G_OBJECT_CLASS(klass); + NMSettingClass *setting_class = NM_SETTING_CLASS(klass); + GArray * properties_override = _nm_sett_info_property_override_create_array(); + + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; + + setting_class->verify = verify; + + /** + * NMSettingBondPort:queue-id: + * + * The queue ID of this bond port. The maximum value of queue ID is + * the number of TX queues currently active in device. + * + * Since: 1.34 + **/ + /* ---ifcfg-rh--- + * property: queue-id + * variable: BONDING_OPTS: queue-id= + * values: 0 - 65535 + * default: 0 + * description: Queue ID. + * ---end--- + */ + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_BOND_PORT_QUEUE_ID, + PROP_QUEUE_ID, + 0, + G_MAXUINT16, + NM_BOND_PORT_QUEUE_ID_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBondPort, + _priv.queue_id); + + g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); + + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_BOND_PORT, + NULL, + properties_override, + 0); +} diff --git a/src/libnm-core-impl/nm-setting-bond.c b/src/libnm-core-impl/nm-setting-bond.c index 252adc73..e81130cd 100644 --- a/src/libnm-core-impl/nm-setting-bond.c +++ b/src/libnm-core-impl/nm-setting-bond.c @@ -1090,20 +1090,9 @@ options_equal(NMSettingBond *s_bond, NMSettingBond *s_bond2, NMSettingCompareFla } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_fcn_options(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) { - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_BOND_OPTIONS)) { - return (!set_b || options_equal(NM_SETTING_BOND(set_a), NM_SETTING_BOND(set_b), flags)); - } - - return NM_SETTING_CLASS(nm_setting_bond_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + return (!set_b || options_equal(NM_SETTING_BOND(set_a), NM_SETTING_BOND(set_b), flags)); } /*****************************************************************************/ @@ -1190,8 +1179,7 @@ nm_setting_bond_class_init(NMSettingBondClass *klass) object_class->set_property = set_property; object_class->finalize = finalize; - setting_class->verify = verify; - setting_class->compare_property = compare_property; + setting_class->verify = verify; /** * NMSettingBond:options: (type GHashTable(utf8,utf8)): @@ -1213,9 +1201,16 @@ nm_setting_bond_class_init(NMSettingBondClass *klass) "", G_TYPE_HASH_TABLE, G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_OPTIONS], - &nm_sett_info_propert_type_strdict); + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_OPTIONS], + NM_SETT_INFO_PROPERT_TYPE_GPROP(NM_G_VARIANT_TYPE("a{ss}"), + .typdata_from_dbus.gprop_fcn = _nm_utils_strdict_from_dbus, + .typdata_to_dbus.gprop_type = + NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_STRDICT, + .compare_fcn = compare_fcn_options, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE)); /* ---dbus--- * property: interface-name @@ -1231,8 +1226,9 @@ nm_setting_bond_class_init(NMSettingBondClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_BOND, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_BOND, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-bridge-port.c b/src/libnm-core-impl/nm-setting-bridge-port.c index 33d0c009..48ad74a1 100644 --- a/src/libnm-core-impl/nm-setting-bridge-port.c +++ b/src/libnm-core-impl/nm-setting-bridge-port.c @@ -34,9 +34,9 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingBridgePort, typedef struct { GPtrArray *vlans; - guint16 priority; - guint16 path_cost; - bool hairpin_mode : 1; + guint32 priority; + guint32 path_cost; + bool hairpin_mode; } NMSettingBridgePortPrivate; /** @@ -368,35 +368,13 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_fcn_vlans(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) { - NMSettingBridgePortPrivate *priv_a; - NMSettingBridgePortPrivate *priv_b; - guint i; - - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_BRIDGE_PORT_VLANS)) { - if (set_b) { - priv_a = NM_SETTING_BRIDGE_PORT_GET_PRIVATE(set_a); - priv_b = NM_SETTING_BRIDGE_PORT_GET_PRIVATE(set_b); - - if (priv_a->vlans->len != priv_b->vlans->len) - return FALSE; - for (i = 0; i < priv_a->vlans->len; i++) { - if (nm_bridge_vlan_cmp(priv_a->vlans->pdata[i], priv_b->vlans->pdata[i])) - return FALSE; - } - } - return TRUE; + if (set_b) { + return _nm_utils_bridge_compare_vlans(NM_SETTING_BRIDGE_PORT_GET_PRIVATE(set_a)->vlans, + NM_SETTING_BRIDGE_PORT_GET_PRIVATE(set_b)->vlans); } - - return NM_SETTING_CLASS(nm_setting_bridge_port_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + return TRUE; } /*****************************************************************************/ @@ -407,15 +385,6 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) NMSettingBridgePortPrivate *priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE(object); switch (prop_id) { - case PROP_PRIORITY: - g_value_set_uint(value, priv->priority); - break; - case PROP_PATH_COST: - g_value_set_uint(value, priv->path_cost); - break; - case PROP_HAIRPIN_MODE: - g_value_set_boolean(value, priv->hairpin_mode); - break; case PROP_VLANS: g_value_take_boxed(value, _nm_utils_copy_array(priv->vlans, @@ -423,7 +392,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) (GDestroyNotify) nm_bridge_vlan_unref)); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_get_property_direct(object, prop_id, value, pspec); break; } } @@ -434,15 +403,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps NMSettingBridgePortPrivate *priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE(object); switch (prop_id) { - case PROP_PRIORITY: - priv->priority = g_value_get_uint(value); - break; - case PROP_PATH_COST: - priv->path_cost = g_value_get_uint(value); - break; - case PROP_HAIRPIN_MODE: - priv->hairpin_mode = g_value_get_boolean(value); - break; case PROP_VLANS: g_ptr_array_unref(priv->vlans); priv->vlans = _nm_utils_copy_array(g_value_get_boxed(value), @@ -450,7 +410,7 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps (GDestroyNotify) nm_bridge_vlan_unref); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_set_property_direct(object, prop_id, value, pspec); break; } } @@ -463,9 +423,6 @@ nm_setting_bridge_port_init(NMSettingBridgePort *setting) NMSettingBridgePortPrivate *priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE(setting); priv->vlans = g_ptr_array_new_with_free_func((GDestroyNotify) nm_bridge_vlan_unref); - - priv->priority = NM_BRIDGE_PORT_PRIORITY_DEF; - priv->path_cost = NM_BRIDGE_PORT_PATH_COST_DEF; } /** @@ -500,12 +457,11 @@ nm_setting_bridge_port_class_init(NMSettingBridgePortClass *klass) g_type_class_add_private(klass, sizeof(NMSettingBridgePortPrivate)); - object_class->finalize = finalize; object_class->get_property = get_property; object_class->set_property = set_property; + object_class->finalize = finalize; - setting_class->compare_property = compare_property; - setting_class->verify = verify; + setting_class->verify = verify; /** * NMSettingBridgePort:priority: @@ -520,14 +476,16 @@ nm_setting_bridge_port_class_init(NMSettingBridgePortClass *klass) * description: STP priority. * ---end--- */ - obj_properties[PROP_PRIORITY] = - g_param_spec_uint(NM_SETTING_BRIDGE_PORT_PRIORITY, - "", - "", - NM_BRIDGE_PORT_PRIORITY_MIN, - NM_BRIDGE_PORT_PRIORITY_MAX, - NM_BRIDGE_PORT_PRIORITY_DEF, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_BRIDGE_PORT_PRIORITY, + PROP_PRIORITY, + NM_BRIDGE_PORT_PRIORITY_MIN, + NM_BRIDGE_PORT_PRIORITY_MAX, + NM_BRIDGE_PORT_PRIORITY_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePortPrivate, + priority); /** * NMSettingBridgePort:path-cost: @@ -543,13 +501,16 @@ nm_setting_bridge_port_class_init(NMSettingBridgePortClass *klass) * description: STP cost. * ---end--- */ - obj_properties[PROP_PATH_COST] = g_param_spec_uint(NM_SETTING_BRIDGE_PORT_PATH_COST, - "", - "", - NM_BRIDGE_PORT_PATH_COST_MIN, - NM_BRIDGE_PORT_PATH_COST_MAX, - NM_BRIDGE_PORT_PATH_COST_DEF, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_BRIDGE_PORT_PATH_COST, + PROP_PATH_COST, + NM_BRIDGE_PORT_PATH_COST_MIN, + NM_BRIDGE_PORT_PATH_COST_MAX, + NM_BRIDGE_PORT_PATH_COST_DEF, + NM_SETTING_PARAM_NONE, + NMSettingBridgePortPrivate, + path_cost); /** * NMSettingBridgePort:hairpin-mode: @@ -564,13 +525,14 @@ nm_setting_bridge_port_class_init(NMSettingBridgePortClass *klass) * description: Hairpin mode of the bridge port. * ---end--- */ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE, - PROP_HAIRPIN_MODE, - FALSE, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_bridge_port_get_hairpin_mode); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE, + PROP_HAIRPIN_MODE, + FALSE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePortPrivate, + hairpin_mode); /** * NMSettingBridgePort:vlans: (type GPtrArray(NMBridgeVlan)) @@ -603,14 +565,19 @@ nm_setting_bridge_port_class_init(NMSettingBridgePortClass *klass) G_TYPE_PTR_ARRAY, G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_VLANS], - &nm_sett_info_propert_type_bridge_vlans); + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_VLANS], + NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"), + .compare_fcn = compare_fcn_vlans, + .to_dbus_fcn = _nm_utils_bridge_vlans_to_dbus, + .from_dbus_fcn = _nm_utils_bridge_vlans_from_dbus, )); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_BRIDGE_PORT, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_BRIDGE_PORT, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-bridge.c b/src/libnm-core-impl/nm-setting-bridge.c index e987310f..9045d619 100644 --- a/src/libnm-core-impl/nm-setting-bridge.c +++ b/src/libnm-core-impl/nm-setting-bridge.c @@ -71,18 +71,18 @@ typedef struct { guint32 multicast_hash_max; guint32 multicast_last_member_count; guint32 multicast_startup_query_count; - guint16 priority; - guint16 forward_delay; - guint16 hello_time; - guint16 max_age; - guint16 vlan_default_pvid; - guint16 group_forward_mask; - bool multicast_snooping : 1; - bool vlan_filtering : 1; - bool stp : 1; - bool vlan_stats_enabled : 1; - bool multicast_query_use_ifaddr : 1; - bool multicast_querier : 1; + guint32 priority; + guint32 forward_delay; + guint32 hello_time; + guint32 max_age; + guint32 group_forward_mask; + guint32 vlan_default_pvid; + bool stp; + bool multicast_snooping; + bool vlan_filtering; + bool vlan_stats_enabled; + bool multicast_query_use_ifaddr; + bool multicast_querier; } NMSettingBridgePrivate; /** @@ -1231,7 +1231,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) error)) return FALSE; - if (priv->group_forward_mask & 7) { + if (priv->group_forward_mask & 7u) { g_set_error_literal(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -1315,35 +1315,13 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_fcn_vlans(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) { - NMSettingBridgePrivate *priv_a; - NMSettingBridgePrivate *priv_b; - guint i; - - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_BRIDGE_VLANS)) { - if (set_b) { - priv_a = NM_SETTING_BRIDGE_GET_PRIVATE(set_a); - priv_b = NM_SETTING_BRIDGE_GET_PRIVATE(set_b); - - if (priv_a->vlans->len != priv_b->vlans->len) - return FALSE; - for (i = 0; i < priv_a->vlans->len; i++) { - if (nm_bridge_vlan_cmp(priv_a->vlans->pdata[i], priv_b->vlans->pdata[i])) - return FALSE; - } - } - return TRUE; + if (set_b) { + return _nm_utils_bridge_compare_vlans(NM_SETTING_BRIDGE_GET_PRIVATE(set_a)->vlans, + NM_SETTING_BRIDGE_GET_PRIVATE(set_b)->vlans); } - - return NM_SETTING_CLASS(nm_setting_bridge_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + return TRUE; } /*****************************************************************************/ @@ -1351,88 +1329,9 @@ compare_property(const NMSettInfoSetting *sett_info, static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE(object); - NMSettingBridge * setting = NM_SETTING_BRIDGE(object); + NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE(object); switch (prop_id) { - case PROP_MAC_ADDRESS: - g_value_set_string(value, nm_setting_bridge_get_mac_address(setting)); - break; - case PROP_STP: - g_value_set_boolean(value, priv->stp); - break; - case PROP_PRIORITY: - g_value_set_uint(value, priv->priority); - break; - case PROP_FORWARD_DELAY: - g_value_set_uint(value, priv->forward_delay); - break; - case PROP_HELLO_TIME: - g_value_set_uint(value, priv->hello_time); - break; - case PROP_MAX_AGE: - g_value_set_uint(value, priv->max_age); - break; - case PROP_AGEING_TIME: - g_value_set_uint(value, priv->ageing_time); - break; - case PROP_GROUP_ADDRESS: - g_value_set_string(value, priv->group_address); - break; - case PROP_GROUP_FORWARD_MASK: - g_value_set_uint(value, priv->group_forward_mask); - break; - case PROP_MULTICAST_HASH_MAX: - g_value_set_uint(value, priv->multicast_hash_max); - break; - case PROP_MULTICAST_LAST_MEMBER_COUNT: - g_value_set_uint(value, priv->multicast_last_member_count); - break; - case PROP_MULTICAST_LAST_MEMBER_INTERVAL: - g_value_set_uint64(value, priv->multicast_last_member_interval); - break; - case PROP_MULTICAST_MEMBERSHIP_INTERVAL: - g_value_set_uint64(value, priv->multicast_membership_interval); - break; - case PROP_MULTICAST_SNOOPING: - g_value_set_boolean(value, priv->multicast_snooping); - break; - case PROP_MULTICAST_ROUTER: - g_value_set_string(value, priv->multicast_router); - break; - case PROP_MULTICAST_QUERIER: - g_value_set_boolean(value, priv->multicast_querier); - break; - case PROP_MULTICAST_QUERIER_INTERVAL: - g_value_set_uint64(value, priv->multicast_querier_interval); - break; - case PROP_MULTICAST_QUERY_INTERVAL: - g_value_set_uint64(value, priv->multicast_query_interval); - break; - case PROP_MULTICAST_QUERY_RESPONSE_INTERVAL: - g_value_set_uint64(value, priv->multicast_query_response_interval); - break; - case PROP_MULTICAST_QUERY_USE_IFADDR: - g_value_set_boolean(value, priv->multicast_query_use_ifaddr); - break; - case PROP_MULTICAST_STARTUP_QUERY_COUNT: - g_value_set_uint(value, priv->multicast_startup_query_count); - break; - case PROP_MULTICAST_STARTUP_QUERY_INTERVAL: - g_value_set_uint64(value, priv->multicast_startup_query_interval); - break; - case PROP_VLAN_FILTERING: - g_value_set_boolean(value, priv->vlan_filtering); - break; - case PROP_VLAN_DEFAULT_PVID: - g_value_set_uint(value, priv->vlan_default_pvid); - break; - case PROP_VLAN_PROTOCOL: - g_value_set_string(value, priv->vlan_protocol); - break; - case PROP_VLAN_STATS_ENABLED: - g_value_set_boolean(value, priv->vlan_stats_enabled); - break; case PROP_VLANS: g_value_take_boxed(value, _nm_utils_copy_array(priv->vlans, @@ -1440,7 +1339,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) (GDestroyNotify) nm_bridge_vlan_unref)); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_get_property_direct(object, prop_id, value, pspec); break; } } @@ -1451,90 +1350,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE(object); switch (prop_id) { - case PROP_MAC_ADDRESS: - g_free(priv->mac_address); - priv->mac_address = - _nm_utils_hwaddr_canonical_or_invalid(g_value_get_string(value), ETH_ALEN); - break; - case PROP_STP: - priv->stp = g_value_get_boolean(value); - break; - case PROP_PRIORITY: - priv->priority = (guint16) g_value_get_uint(value); - break; - case PROP_FORWARD_DELAY: - priv->forward_delay = (guint16) g_value_get_uint(value); - break; - case PROP_HELLO_TIME: - priv->hello_time = (guint16) g_value_get_uint(value); - break; - case PROP_MAX_AGE: - priv->max_age = (guint16) g_value_get_uint(value); - break; - case PROP_AGEING_TIME: - priv->ageing_time = g_value_get_uint(value); - break; - case PROP_GROUP_ADDRESS: - g_free(priv->group_address); - priv->group_address = - _nm_utils_hwaddr_canonical_or_invalid(g_value_get_string(value), ETH_ALEN); - break; - case PROP_GROUP_FORWARD_MASK: - priv->group_forward_mask = (guint16) g_value_get_uint(value); - break; - case PROP_MULTICAST_HASH_MAX: - priv->multicast_hash_max = g_value_get_uint(value); - break; - case PROP_MULTICAST_LAST_MEMBER_COUNT: - priv->multicast_last_member_count = g_value_get_uint(value); - break; - case PROP_MULTICAST_LAST_MEMBER_INTERVAL: - priv->multicast_last_member_interval = g_value_get_uint64(value); - break; - case PROP_MULTICAST_MEMBERSHIP_INTERVAL: - priv->multicast_membership_interval = g_value_get_uint64(value); - break; - case PROP_MULTICAST_SNOOPING: - priv->multicast_snooping = g_value_get_boolean(value); - break; - case PROP_MULTICAST_ROUTER: - g_free(priv->multicast_router); - priv->multicast_router = g_value_dup_string(value); - break; - case PROP_MULTICAST_QUERIER: - priv->multicast_querier = g_value_get_boolean(value); - break; - case PROP_MULTICAST_QUERIER_INTERVAL: - priv->multicast_querier_interval = g_value_get_uint64(value); - break; - case PROP_MULTICAST_QUERY_INTERVAL: - priv->multicast_query_interval = g_value_get_uint64(value); - break; - case PROP_MULTICAST_QUERY_RESPONSE_INTERVAL: - priv->multicast_query_response_interval = g_value_get_uint64(value); - break; - case PROP_MULTICAST_QUERY_USE_IFADDR: - priv->multicast_query_use_ifaddr = g_value_get_boolean(value); - break; - case PROP_MULTICAST_STARTUP_QUERY_COUNT: - priv->multicast_startup_query_count = g_value_get_uint(value); - break; - case PROP_MULTICAST_STARTUP_QUERY_INTERVAL: - priv->multicast_startup_query_interval = g_value_get_uint64(value); - break; - case PROP_VLAN_FILTERING: - priv->vlan_filtering = g_value_get_boolean(value); - break; - case PROP_VLAN_DEFAULT_PVID: - priv->vlan_default_pvid = g_value_get_uint(value); - break; - case PROP_VLAN_PROTOCOL: - g_free(priv->vlan_protocol); - priv->vlan_protocol = g_value_dup_string(value); - break; - case PROP_VLAN_STATS_ENABLED: - priv->vlan_stats_enabled = g_value_get_boolean(value); - break; case PROP_VLANS: g_ptr_array_unref(priv->vlans); priv->vlans = _nm_utils_copy_array(g_value_get_boxed(value), @@ -1542,7 +1357,7 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps (GDestroyNotify) nm_bridge_vlan_unref); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_set_property_direct(object, prop_id, value, pspec); break; } } @@ -1555,28 +1370,6 @@ nm_setting_bridge_init(NMSettingBridge *setting) NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE(setting); priv->vlans = g_ptr_array_new_with_free_func((GDestroyNotify) nm_bridge_vlan_unref); - - priv->ageing_time = NM_BRIDGE_AGEING_TIME_DEF; - priv->forward_delay = NM_BRIDGE_FORWARD_DELAY_DEF; - priv->hello_time = NM_BRIDGE_HELLO_TIME_DEF; - priv->max_age = NM_BRIDGE_MAX_AGE_DEF; - priv->multicast_last_member_count = NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_DEF; - priv->multicast_last_member_interval = NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_DEF; - priv->multicast_membership_interval = NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_DEF; - priv->multicast_hash_max = NM_BRIDGE_MULTICAST_HASH_MAX_DEF; - priv->multicast_snooping = NM_BRIDGE_MULTICAST_SNOOPING_DEF; - priv->priority = NM_BRIDGE_PRIORITY_DEF; - priv->stp = NM_BRIDGE_STP_DEF; - priv->vlan_default_pvid = NM_BRIDGE_VLAN_DEFAULT_PVID_DEF; - priv->multicast_query_interval = NM_BRIDGE_MULTICAST_QUERY_INTERVAL_DEF; - priv->multicast_query_response_interval = NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_DEF; - priv->multicast_querier_interval = NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_DEF; - priv->multicast_startup_query_count = NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_DEF; - priv->multicast_startup_query_interval = NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_DEF; - - nm_assert(priv->multicast_querier == NM_BRIDGE_MULTICAST_QUERIER_DEF); - nm_assert(priv->multicast_query_use_ifaddr == NM_BRIDGE_MULTICAST_QUERY_USE_IFADDR_DEF); - nm_assert(priv->vlan_stats_enabled == NM_BRIDGE_VLAN_STATS_ENABLED_DEF); } /** @@ -1597,10 +1390,6 @@ finalize(GObject *object) { NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE(object); - g_free(priv->mac_address); - g_free(priv->multicast_router); - g_free(priv->group_address); - g_free(priv->vlan_protocol); g_ptr_array_unref(priv->vlans); G_OBJECT_CLASS(nm_setting_bridge_parent_class)->finalize(object); @@ -1617,8 +1406,7 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) object_class->set_property = set_property; object_class->finalize = finalize; - setting_class->compare_property = compare_property; - setting_class->verify = verify; + setting_class->verify = verify; /** * NMSettingBridge:mac-address: @@ -1650,15 +1438,14 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * BRIDGE_MACADDR for bridges is an NM extension. * ---end--- */ - obj_properties[PROP_MAC_ADDRESS] = g_param_spec_string( - NM_SETTING_BRIDGE_MAC_ADDRESS, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_MAC_ADDRESS], - &nm_sett_info_propert_type_mac_address); + _nm_setting_property_define_direct_mac_address(properties_override, + obj_properties, + NM_SETTING_BRIDGE_MAC_ADDRESS, + PROP_MAC_ADDRESS, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + mac_address, + .direct_set_string_mac_address_len = ETH_ALEN); /** * NMSettingBridge:stp: @@ -1672,13 +1459,14 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * description: Span tree protocol participation. * ---end--- */ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_BRIDGE_STP, - PROP_STP, - NM_BRIDGE_STP_DEF, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_bridge_get_stp); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_BRIDGE_STP, + PROP_STP, + NM_BRIDGE_STP_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + stp); /** * NMSettingBridge:priority: @@ -1695,14 +1483,16 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * description: STP priority. * ---end--- */ - obj_properties[PROP_PRIORITY] = - g_param_spec_uint(NM_SETTING_BRIDGE_PRIORITY, - "", - "", - NM_BRIDGE_PRIORITY_MIN, - NM_BRIDGE_PRIORITY_MAX, - NM_BRIDGE_PRIORITY_DEF, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_BRIDGE_PRIORITY, + PROP_PRIORITY, + NM_BRIDGE_PRIORITY_MIN, + NM_BRIDGE_PRIORITY_MAX, + NM_BRIDGE_PRIORITY_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + priority); /** * NMSettingBridge:forward-delay: @@ -1717,14 +1507,16 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * description: STP forwarding delay. * ---end--- */ - obj_properties[PROP_FORWARD_DELAY] = - g_param_spec_uint(NM_SETTING_BRIDGE_FORWARD_DELAY, - "", - "", - 0, - NM_BRIDGE_FORWARD_DELAY_MAX, - NM_BRIDGE_FORWARD_DELAY_DEF, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_BRIDGE_FORWARD_DELAY, + PROP_FORWARD_DELAY, + 0, + NM_BRIDGE_FORWARD_DELAY_MAX, + NM_BRIDGE_FORWARD_DELAY_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + forward_delay); /** * NMSettingBridge:hello-time: @@ -1739,14 +1531,16 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * description: STP hello time. * ---end--- */ - obj_properties[PROP_HELLO_TIME] = - g_param_spec_uint(NM_SETTING_BRIDGE_HELLO_TIME, - "", - "", - 0, - NM_BRIDGE_HELLO_TIME_MAX, - NM_BRIDGE_HELLO_TIME_DEF, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_BRIDGE_HELLO_TIME, + PROP_HELLO_TIME, + 0, + NM_BRIDGE_HELLO_TIME_MAX, + NM_BRIDGE_HELLO_TIME_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + hello_time); /** * NMSettingBridge:max-age: @@ -1761,14 +1555,16 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * description: STP maximum message age. * ---end--- */ - obj_properties[PROP_MAX_AGE] = - g_param_spec_uint(NM_SETTING_BRIDGE_MAX_AGE, - "", - "", - 0, - NM_BRIDGE_MAX_AGE_MAX, - NM_BRIDGE_MAX_AGE_DEF, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_BRIDGE_MAX_AGE, + PROP_MAX_AGE, + 0, + NM_BRIDGE_MAX_AGE_MAX, + NM_BRIDGE_MAX_AGE_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + max_age); /** * NMSettingBridge:ageing-time: @@ -1783,14 +1579,16 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * description: Ethernet MAC ageing time. * ---end--- */ - obj_properties[PROP_AGEING_TIME] = - g_param_spec_uint(NM_SETTING_BRIDGE_AGEING_TIME, - "", - "", - NM_BRIDGE_AGEING_TIME_MIN, - NM_BRIDGE_AGEING_TIME_MAX, - NM_BRIDGE_AGEING_TIME_DEF, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_BRIDGE_AGEING_TIME, + PROP_AGEING_TIME, + NM_BRIDGE_AGEING_TIME_MIN, + NM_BRIDGE_AGEING_TIME_MAX, + NM_BRIDGE_AGEING_TIME_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + ageing_time); /** * NMSettingBridge:group-forward-mask: @@ -1804,14 +1602,16 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * * Since: 1.10 **/ - obj_properties[PROP_GROUP_FORWARD_MASK] = - g_param_spec_uint(NM_SETTING_BRIDGE_GROUP_FORWARD_MASK, - "", - "", - 0, - 0xFFFF, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_BRIDGE_GROUP_FORWARD_MASK, + PROP_GROUP_FORWARD_MASK, + 0, + 0xFFFF, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + group_forward_mask); /** * NMSettingBridge:multicast-snooping: @@ -1831,13 +1631,14 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * description: IGMP snooping support. * ---end--- */ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_BRIDGE_MULTICAST_SNOOPING, - PROP_MULTICAST_SNOOPING, - NM_BRIDGE_MULTICAST_SNOOPING_DEF, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_bridge_get_multicast_snooping); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_BRIDGE_MULTICAST_SNOOPING, + PROP_MULTICAST_SNOOPING, + NM_BRIDGE_MULTICAST_SNOOPING_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + multicast_snooping); /** * NMSettingBridge:vlan-filtering: @@ -1854,13 +1655,14 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * description: VLAN filtering support. * ---end--- */ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_BRIDGE_VLAN_FILTERING, - PROP_VLAN_FILTERING, - FALSE, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_bridge_get_vlan_filtering); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_BRIDGE_VLAN_FILTERING, + PROP_VLAN_FILTERING, + FALSE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + vlan_filtering); /** * NMSettingBridge:vlan-default-pvid: @@ -1878,14 +1680,16 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * description: default VLAN PVID. * ---end--- */ - obj_properties[PROP_VLAN_DEFAULT_PVID] = - g_param_spec_uint(NM_SETTING_BRIDGE_VLAN_DEFAULT_PVID, - "", - "", - 0, - NM_BRIDGE_VLAN_VID_MAX, - NM_BRIDGE_VLAN_DEFAULT_PVID_DEF, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_BRIDGE_VLAN_DEFAULT_PVID, + PROP_VLAN_DEFAULT_PVID, + 0, + NM_BRIDGE_VLAN_VID_MAX, + NM_BRIDGE_VLAN_DEFAULT_PVID_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + vlan_default_pvid); /** * NMSettingBridge:vlans: (type GPtrArray(NMBridgeVlan)) @@ -1917,9 +1721,13 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) G_TYPE_PTR_ARRAY, G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_VLANS], - &nm_sett_info_propert_type_bridge_vlans); + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_VLANS], + NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"), + .to_dbus_fcn = _nm_utils_bridge_vlans_to_dbus, + .compare_fcn = compare_fcn_vlans, + .from_dbus_fcn = _nm_utils_bridge_vlans_from_dbus, )); /* ---dbus--- * property: interface-name @@ -1951,15 +1759,14 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * example: BRIDGING_OPTS="group_address=01:80:C2:00:00:0A" * ---end--- */ - obj_properties[PROP_GROUP_ADDRESS] = g_param_spec_string( - NM_SETTING_BRIDGE_GROUP_ADDRESS, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_GROUP_ADDRESS], - &nm_sett_info_propert_type_mac_address); + _nm_setting_property_define_direct_mac_address(properties_override, + obj_properties, + NM_SETTING_BRIDGE_GROUP_ADDRESS, + PROP_GROUP_ADDRESS, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + group_address, + .direct_set_string_mac_address_len = ETH_ALEN); /** * NMSettingBridge:vlan-protocol: @@ -1980,12 +1787,13 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * * Since: 1.24 */ - obj_properties[PROP_VLAN_PROTOCOL] = g_param_spec_string( - NM_SETTING_BRIDGE_VLAN_PROTOCOL, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_BRIDGE_VLAN_PROTOCOL, + PROP_VLAN_PROTOCOL, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + vlan_protocol); /** * NMSettingBridge:vlan-stats-enabled: @@ -2001,13 +1809,14 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * * Since: 1.24 */ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_BRIDGE_VLAN_STATS_ENABLED, - PROP_VLAN_STATS_ENABLED, - NM_BRIDGE_VLAN_STATS_ENABLED_DEF, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_bridge_get_vlan_stats_enabled); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_BRIDGE_VLAN_STATS_ENABLED, + PROP_VLAN_STATS_ENABLED, + NM_BRIDGE_VLAN_STATS_ENABLED_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + vlan_stats_enabled); /** * NMSettingBridge:multicast-router: @@ -2029,12 +1838,13 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * * Since: 1.24 */ - obj_properties[PROP_MULTICAST_ROUTER] = g_param_spec_string( - NM_SETTING_BRIDGE_MULTICAST_ROUTER, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_BRIDGE_MULTICAST_ROUTER, + PROP_MULTICAST_ROUTER, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + multicast_router); /** * NMSettingBridge:multicast-query-use-ifaddr: @@ -2052,13 +1862,14 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * * Since: 1.24 */ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_BRIDGE_MULTICAST_QUERY_USE_IFADDR, - PROP_MULTICAST_QUERY_USE_IFADDR, - NM_BRIDGE_MULTICAST_QUERY_USE_IFADDR_DEF, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_bridge_get_multicast_query_use_ifaddr); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_BRIDGE_MULTICAST_QUERY_USE_IFADDR, + PROP_MULTICAST_QUERY_USE_IFADDR, + NM_BRIDGE_MULTICAST_QUERY_USE_IFADDR_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + multicast_query_use_ifaddr); /** * NMSettingBridge:multicast-querier: @@ -2075,13 +1886,14 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * * Since: 1.24 */ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_BRIDGE_MULTICAST_QUERIER, - PROP_MULTICAST_QUERIER, - NM_BRIDGE_MULTICAST_QUERIER_DEF, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_bridge_get_multicast_querier); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_BRIDGE_MULTICAST_QUERIER, + PROP_MULTICAST_QUERIER, + NM_BRIDGE_MULTICAST_QUERIER_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + multicast_querier); /** * NMSettingBridge:multicast-hash-max: @@ -2097,14 +1909,16 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * * Since: 1.26 */ - obj_properties[PROP_MULTICAST_HASH_MAX] = - g_param_spec_uint(NM_SETTING_BRIDGE_MULTICAST_HASH_MAX, - "", - "", - NM_BRIDGE_MULTICAST_HASH_MAX_MIN, - NM_BRIDGE_MULTICAST_HASH_MAX_MAX, - NM_BRIDGE_MULTICAST_HASH_MAX_DEF, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_BRIDGE_MULTICAST_HASH_MAX, + PROP_MULTICAST_HASH_MAX, + NM_BRIDGE_MULTICAST_HASH_MAX_MIN, + NM_BRIDGE_MULTICAST_HASH_MAX_MAX, + NM_BRIDGE_MULTICAST_HASH_MAX_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + multicast_hash_max); /** * NMSettingBridge:multicast-last-member-count: @@ -2122,14 +1936,16 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * * Since: 1.26 */ - obj_properties[PROP_MULTICAST_LAST_MEMBER_COUNT] = - g_param_spec_uint(NM_SETTING_BRIDGE_MULTICAST_LAST_MEMBER_COUNT, - "", - "", - NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_MIN, - NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_MAX, - NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_DEF, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_BRIDGE_MULTICAST_LAST_MEMBER_COUNT, + PROP_MULTICAST_LAST_MEMBER_COUNT, + NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_MIN, + NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_MAX, + NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + multicast_last_member_count); /** * NMSettingBridge:multicast-last-member-interval: @@ -2146,14 +1962,16 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * * Since: 1.26 */ - obj_properties[PROP_MULTICAST_LAST_MEMBER_INTERVAL] = g_param_spec_uint64( - NM_SETTING_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL, - "", - "", - NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_MIN, - NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_MAX, - NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_DEF, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint64(properties_override, + obj_properties, + NM_SETTING_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL, + PROP_MULTICAST_LAST_MEMBER_INTERVAL, + NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_MIN, + NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_MAX, + NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + multicast_last_member_interval); /** * NMSettingBridge:multicast-membership-interval: @@ -2171,14 +1989,16 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * * Since: 1.26 */ - obj_properties[PROP_MULTICAST_MEMBERSHIP_INTERVAL] = g_param_spec_uint64( - NM_SETTING_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL, - "", - "", - NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_MIN, - NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_MAX, - NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_DEF, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint64(properties_override, + obj_properties, + NM_SETTING_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL, + PROP_MULTICAST_MEMBERSHIP_INTERVAL, + NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_MIN, + NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_MAX, + NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + multicast_membership_interval); /** * NMSettingBridge:multicast-querier-interval: @@ -2195,14 +2015,16 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * * Since: 1.26 */ - obj_properties[PROP_MULTICAST_QUERIER_INTERVAL] = g_param_spec_uint64( - NM_SETTING_BRIDGE_MULTICAST_QUERIER_INTERVAL, - "", - "", - NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_MIN, - NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_MAX, - NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_DEF, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint64(properties_override, + obj_properties, + NM_SETTING_BRIDGE_MULTICAST_QUERIER_INTERVAL, + PROP_MULTICAST_QUERIER_INTERVAL, + NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_MIN, + NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_MAX, + NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + multicast_querier_interval); /** * NMSettingBridge:multicast-query-interval: @@ -2219,14 +2041,16 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * * Since: 1.26 */ - obj_properties[PROP_MULTICAST_QUERY_INTERVAL] = g_param_spec_uint64( - NM_SETTING_BRIDGE_MULTICAST_QUERY_INTERVAL, - "", - "", - NM_BRIDGE_MULTICAST_QUERY_INTERVAL_MIN, - NM_BRIDGE_MULTICAST_QUERY_INTERVAL_MAX, - NM_BRIDGE_MULTICAST_QUERY_INTERVAL_DEF, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint64(properties_override, + obj_properties, + NM_SETTING_BRIDGE_MULTICAST_QUERY_INTERVAL, + PROP_MULTICAST_QUERY_INTERVAL, + NM_BRIDGE_MULTICAST_QUERY_INTERVAL_MIN, + NM_BRIDGE_MULTICAST_QUERY_INTERVAL_MAX, + NM_BRIDGE_MULTICAST_QUERY_INTERVAL_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + multicast_query_interval); /** * NMSettingBridge:multicast-query-response-interval: @@ -2243,14 +2067,16 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * * Since: 1.26 */ - obj_properties[PROP_MULTICAST_QUERY_RESPONSE_INTERVAL] = g_param_spec_uint64( - NM_SETTING_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL, - "", - "", - NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_MIN, - NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_MAX, - NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_DEF, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint64(properties_override, + obj_properties, + NM_SETTING_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL, + PROP_MULTICAST_QUERY_RESPONSE_INTERVAL, + NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_MIN, + NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_MAX, + NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + multicast_query_response_interval); /** * NMSettingBridge:multicast-startup-query-count: @@ -2266,14 +2092,16 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * * Since: 1.26 */ - obj_properties[PROP_MULTICAST_STARTUP_QUERY_COUNT] = - g_param_spec_uint(NM_SETTING_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT, - "", - "", - NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_MIN, - NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_MAX, - NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_DEF, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT, + PROP_MULTICAST_STARTUP_QUERY_COUNT, + NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_MIN, + NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_MAX, + NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + multicast_startup_query_count); /** * NMSettingBridge:multicast-startup-query-interval: @@ -2290,19 +2118,22 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) * * Since: 1.26 */ - obj_properties[PROP_MULTICAST_STARTUP_QUERY_INTERVAL] = g_param_spec_uint64( - NM_SETTING_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL, - "", - "", - NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_MIN, - NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_MAX, - NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_DEF, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint64(properties_override, + obj_properties, + NM_SETTING_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL, + PROP_MULTICAST_STARTUP_QUERY_INTERVAL, + NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_MIN, + NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_MAX, + NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_DEF, + NM_SETTING_PARAM_INFERRABLE, + NMSettingBridgePrivate, + multicast_startup_query_interval); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_BRIDGE, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_BRIDGE, + NULL, + properties_override, + G_STRUCT_OFFSET(NMSettingBridge, _priv)); } diff --git a/src/libnm-core-impl/nm-setting-cdma.c b/src/libnm-core-impl/nm-setting-cdma.c index 6dc61e83..214f3b91 100644 --- a/src/libnm-core-impl/nm-setting-cdma.c +++ b/src/libnm-core-impl/nm-setting-cdma.c @@ -29,7 +29,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_NUMBER, PROP_MTU, ); typedef struct { - char * number; /* For dialing, duh */ + char * number; char * username; char * password; guint32 mtu; @@ -136,23 +136,23 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingCdmaPrivate *priv = NM_SETTING_CDMA_GET_PRIVATE(setting); - if (!priv->number) { - g_set_error_literal(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_MISSING_PROPERTY, - _("property is missing")); - g_prefix_error(error, "%s.%s: ", NM_SETTING_CDMA_SETTING_NAME, NM_SETTING_CDMA_NUMBER); - return FALSE; - } else if (!strlen(priv->number)) { - g_set_error_literal(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("property is empty")); + if (nm_str_is_empty(priv->number)) { + if (!priv->number) { + g_set_error_literal(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, + _("property is missing")); + } else { + g_set_error_literal(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("property is empty")); + } g_prefix_error(error, "%s.%s: ", NM_SETTING_CDMA_SETTING_NAME, NM_SETTING_CDMA_NUMBER); return FALSE; } - if (priv->username && !strlen(priv->username)) { + if (priv->username && nm_str_is_empty(priv->username)) { g_set_error_literal(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -179,7 +179,7 @@ need_secrets(NMSetting *setting) NMSettingCdmaPrivate *priv = NM_SETTING_CDMA_GET_PRIVATE(setting); GPtrArray * secrets = NULL; - if (priv->password && *priv->password) + if (!nm_str_is_empty(priv->password)) return NULL; if (priv->username) { @@ -194,65 +194,6 @@ need_secrets(NMSetting *setting) /*****************************************************************************/ -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingCdma *setting = NM_SETTING_CDMA(object); - - switch (prop_id) { - case PROP_NUMBER: - g_value_set_string(value, nm_setting_cdma_get_number(setting)); - break; - case PROP_USERNAME: - g_value_set_string(value, nm_setting_cdma_get_username(setting)); - break; - case PROP_PASSWORD: - g_value_set_string(value, nm_setting_cdma_get_password(setting)); - break; - case PROP_PASSWORD_FLAGS: - g_value_set_flags(value, nm_setting_cdma_get_password_flags(setting)); - break; - case PROP_MTU: - g_value_set_uint(value, nm_setting_cdma_get_mtu(setting)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingCdmaPrivate *priv = NM_SETTING_CDMA_GET_PRIVATE(object); - - switch (prop_id) { - case PROP_NUMBER: - g_free(priv->number); - priv->number = g_value_dup_string(value); - break; - case PROP_USERNAME: - g_free(priv->username); - priv->username = g_value_dup_string(value); - break; - case PROP_PASSWORD: - g_free(priv->password); - priv->password = g_value_dup_string(value); - break; - case PROP_PASSWORD_FLAGS: - priv->password_flags = g_value_get_flags(value); - break; - case PROP_MTU: - priv->mtu = g_value_get_uint(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - static void nm_setting_cdma_init(NMSettingCdma *setting) {} @@ -270,29 +211,17 @@ nm_setting_cdma_new(void) return g_object_new(NM_TYPE_SETTING_CDMA, NULL); } -static void -finalize(GObject *object) -{ - NMSettingCdmaPrivate *priv = NM_SETTING_CDMA_GET_PRIVATE(object); - - g_free(priv->number); - g_free(priv->username); - g_free(priv->password); - - G_OBJECT_CLASS(nm_setting_cdma_parent_class)->finalize(object); -} - static void nm_setting_cdma_class_init(NMSettingCdmaClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMSettingClass *setting_class = NM_SETTING_CLASS(klass); + GObjectClass * object_class = G_OBJECT_CLASS(klass); + NMSettingClass *setting_class = NM_SETTING_CLASS(klass); + GArray * properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingCdmaPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; setting_class->verify_secrets = verify_secrets; @@ -305,11 +234,13 @@ nm_setting_cdma_class_init(NMSettingCdmaClass *klass) * broadband network, if any. If not specified, the default number (#777) * is used when required. **/ - obj_properties[PROP_NUMBER] = g_param_spec_string(NM_SETTING_CDMA_NUMBER, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_CDMA_NUMBER, + PROP_NUMBER, + NM_SETTING_PARAM_NONE, + NMSettingCdmaPrivate, + number); /** * NMSettingCdma:username: @@ -318,11 +249,13 @@ nm_setting_cdma_class_init(NMSettingCdmaClass *klass) * providers do not require a username, or accept any username. But if a * username is required, it is specified here. **/ - obj_properties[PROP_USERNAME] = g_param_spec_string(NM_SETTING_CDMA_USERNAME, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_CDMA_USERNAME, + PROP_USERNAME, + NM_SETTING_PARAM_NONE, + NMSettingCdmaPrivate, + username); /** * NMSettingCdma:password: @@ -331,25 +264,25 @@ nm_setting_cdma_class_init(NMSettingCdmaClass *klass) * providers do not require a password, or accept any password. But if a * password is required, it is specified here. **/ - obj_properties[PROP_PASSWORD] = - g_param_spec_string(NM_SETTING_CDMA_PASSWORD, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_CDMA_PASSWORD, + PROP_PASSWORD, + NM_SETTING_PARAM_SECRET, + NMSettingCdmaPrivate, + password); /** * NMSettingCdma:password-flags: * * Flags indicating how to handle the #NMSettingCdma:password property. **/ - obj_properties[PROP_PASSWORD_FLAGS] = - g_param_spec_flags(NM_SETTING_CDMA_PASSWORD_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_secret_flags(properties_override, + obj_properties, + NM_SETTING_CDMA_PASSWORD_FLAGS, + PROP_PASSWORD_FLAGS, + NMSettingCdmaPrivate, + password_flags); /** * NMSettingCdma:mtu: @@ -359,16 +292,22 @@ nm_setting_cdma_class_init(NMSettingCdmaClass *klass) * * Since: 1.8 **/ - obj_properties[PROP_MTU] = g_param_spec_uint(NM_SETTING_CDMA_MTU, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_CDMA_MTU, + PROP_MTU, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingCdmaPrivate, + mtu); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_CDMA); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_CDMA, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-connection.c b/src/libnm-core-impl/nm-setting-connection.c index 3d57bc3e..322250f8 100644 --- a/src/libnm-core-impl/nm-setting-connection.c +++ b/src/libnm-core-impl/nm-setting-connection.c @@ -64,37 +64,39 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingConnection, PROP_LLDP, PROP_MDNS, PROP_LLMNR, + PROP_DNS_OVER_TLS, PROP_STABLE_ID, PROP_AUTH_RETRIES, PROP_WAIT_DEVICE_TIMEOUT, PROP_MUD_URL, ); typedef struct { - GArray * permissions; - GArray * secondaries; - char * id; - char * uuid; - char * stable_id; - char * interface_name; - char * type; - char * master; - char * slave_type; - char * zone; - char * mud_url; - guint64 timestamp; - int autoconnect_priority; - int autoconnect_retries; - int multi_connect; - int auth_retries; - int mdns; - int llmnr; - int wait_device_timeout; - guint gateway_ping_timeout; - NMSettingConnectionAutoconnectSlaves autoconnect_slaves; - NMMetered metered; - NMSettingConnectionLldp lldp; - bool read_only : 1; - bool autoconnect : 1; + GArray *permissions; + GArray *secondaries; + char * id; + char * uuid; + char * stable_id; + char * interface_name; + char * type; + char * master; + char * slave_type; + char * zone; + char * mud_url; + guint64 timestamp; + int autoconnect_slaves; + int metered; + gint32 autoconnect_priority; + gint32 autoconnect_retries; + gint32 multi_connect; + gint32 auth_retries; + gint32 mdns; + gint32 llmnr; + gint32 dns_over_tls; + gint32 wait_device_timeout; + gint32 lldp; + guint32 gateway_ping_timeout; + bool autoconnect; + bool read_only; } NMSettingConnectionPrivate; /** @@ -621,12 +623,7 @@ nm_setting_connection_get_timestamp(NMSettingConnection *setting) } static GVariant * -_to_dbus_fcn_timestamp(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +_to_dbus_fcn_timestamp(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { guint64 v; @@ -982,6 +979,23 @@ nm_setting_connection_get_llmnr(NMSettingConnection *setting) return NM_SETTING_CONNECTION_GET_PRIVATE(setting)->llmnr; } +/** + * nm_setting_connection_get_dns_over_tls: + * @setting: the #NMSettingConnection + * + * Returns: the #NMSettingConnection:dns-over-tls property of the setting. + * + * Since: 1.34 + **/ +NMSettingConnectionDnsOverTls +nm_setting_connection_get_dns_over_tls(NMSettingConnection *setting) +{ + g_return_val_if_fail(NM_IS_SETTING_CONNECTION(setting), + NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT); + + return NM_SETTING_CONNECTION_GET_PRIVATE(setting)->dns_over_tls; +} + static void _set_error_missing_base_setting(GError **error, const char *type) { @@ -1279,8 +1293,7 @@ after_interface_name: return FALSE; } - if (priv->metered != NM_METERED_UNKNOWN && priv->metered != NM_METERED_YES - && priv->metered != NM_METERED_NO) { + if (!NM_IN_SET(priv->metered, NM_METERED_UNKNOWN, NM_METERED_NO, NM_METERED_YES)) { g_set_error(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -1321,6 +1334,20 @@ after_interface_name: return FALSE; } + if (priv->dns_over_tls < (int) NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT + || priv->dns_over_tls > (int) NM_SETTING_CONNECTION_DNS_OVER_TLS_YES) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("value %d is not valid"), + priv->dns_over_tls); + g_prefix_error(error, + "%s.%s: ", + NM_SETTING_CONNECTION_SETTING_NAME, + NM_SETTING_CONNECTION_DNS_OVER_TLS); + return FALSE; + } + if (!NM_IN_SET(priv->multi_connect, (int) NM_CONNECTION_MULTI_CONNECT_DEFAULT, (int) NM_CONNECTION_MULTI_CONNECT_SINGLE, @@ -1540,11 +1567,7 @@ find_virtual_interface_name(GVariant *connection_dict, GVariant **variant_to_fre } static gboolean -nm_setting_connection_no_interface_name(NMSetting * setting, - GVariant * connection_dict, - const char * property, - NMSettingParseFlags parse_flags, - GError ** error) +nm_setting_connection_no_interface_name(_NM_SETT_INFO_PROP_MISSING_FROM_DBUS_FCN_ARGS _nm_nil) { const char * virtual_interface_name; gs_unref_variant GVariant *variant_to_free = NULL; @@ -1558,24 +1581,33 @@ nm_setting_connection_no_interface_name(NMSetting * setting, } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_fcn_id(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) { - if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_IGNORE_ID) - && nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_CONNECTION_ID)) + if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_IGNORE_ID)) return NM_TERNARY_DEFAULT; - if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_IGNORE_TIMESTAMP) - && nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_CONNECTION_TIMESTAMP)) + return _nm_setting_property_compare_fcn_direct(sett_info, + property_info, + con_a, + set_a, + con_b, + set_b, + flags); +} + +static NMTernary +compare_fcn_timestamp(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) +{ + if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_IGNORE_TIMESTAMP)) return NM_TERNARY_DEFAULT; - return NM_SETTING_CLASS(nm_setting_connection_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + return _nm_setting_property_compare_fcn_default(sett_info, + property_info, + con_a, + set_a, + con_b, + set_b, + flags); } /*****************************************************************************/ @@ -1587,21 +1619,6 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE(setting); switch (prop_id) { - case PROP_ID: - g_value_set_string(value, nm_setting_connection_get_id(setting)); - break; - case PROP_UUID: - g_value_set_string(value, nm_setting_connection_get_uuid(setting)); - break; - case PROP_STABLE_ID: - g_value_set_string(value, nm_setting_connection_get_stable_id(setting)); - break; - case PROP_INTERFACE_NAME: - g_value_set_string(value, nm_setting_connection_get_interface_name(setting)); - break; - case PROP_TYPE: - g_value_set_string(value, nm_setting_connection_get_connection_type(setting)); - break; case PROP_PERMISSIONS: { char **strv; @@ -1617,65 +1634,14 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) g_value_take_boxed(value, strv); break; } - case PROP_AUTOCONNECT: - g_value_set_boolean(value, nm_setting_connection_get_autoconnect(setting)); - break; - case PROP_AUTOCONNECT_PRIORITY: - g_value_set_int(value, nm_setting_connection_get_autoconnect_priority(setting)); - break; - case PROP_AUTOCONNECT_RETRIES: - g_value_set_int(value, nm_setting_connection_get_autoconnect_retries(setting)); - break; - case PROP_MULTI_CONNECT: - g_value_set_int(value, priv->multi_connect); - break; case PROP_TIMESTAMP: g_value_set_uint64(value, nm_setting_connection_get_timestamp(setting)); break; - case PROP_READ_ONLY: - g_value_set_boolean(value, nm_setting_connection_get_read_only(setting)); - break; - case PROP_ZONE: - g_value_set_string(value, nm_setting_connection_get_zone(setting)); - break; - case PROP_MASTER: - g_value_set_string(value, nm_setting_connection_get_master(setting)); - break; - case PROP_SLAVE_TYPE: - g_value_set_string(value, nm_setting_connection_get_slave_type(setting)); - break; - case PROP_AUTOCONNECT_SLAVES: - g_value_set_enum(value, nm_setting_connection_get_autoconnect_slaves(setting)); - break; case PROP_SECONDARIES: g_value_take_boxed(value, nm_strvarray_get_strv_non_empty_dup(priv->secondaries, NULL)); break; - case PROP_GATEWAY_PING_TIMEOUT: - g_value_set_uint(value, priv->gateway_ping_timeout); - break; - case PROP_METERED: - g_value_set_enum(value, priv->metered); - break; - case PROP_LLDP: - g_value_set_int(value, priv->lldp); - break; - case PROP_AUTH_RETRIES: - g_value_set_int(value, priv->auth_retries); - break; - case PROP_MDNS: - g_value_set_int(value, priv->mdns); - break; - case PROP_LLMNR: - g_value_set_int(value, priv->llmnr); - break; - case PROP_WAIT_DEVICE_TIMEOUT: - g_value_set_int(value, priv->wait_device_timeout); - break; - case PROP_MUD_URL: - g_value_set_string(value, priv->mud_url); - break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_get_property_direct(object, prop_id, value, pspec); break; } } @@ -1686,26 +1652,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE(object); switch (prop_id) { - case PROP_ID: - g_free(priv->id); - priv->id = g_value_dup_string(value); - break; - case PROP_UUID: - g_free(priv->uuid); - priv->uuid = g_value_dup_string(value); - break; - case PROP_STABLE_ID: - g_free(priv->stable_id); - priv->stable_id = g_value_dup_string(value); - break; - case PROP_INTERFACE_NAME: - g_free(priv->interface_name); - priv->interface_name = g_value_dup_string(value); - break; - case PROP_TYPE: - g_free(priv->type); - priv->type = g_value_dup_string(value); - break; case PROP_PERMISSIONS: { const char *const *strv; @@ -1726,69 +1672,14 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps } break; } - case PROP_AUTOCONNECT: - priv->autoconnect = g_value_get_boolean(value); - break; - case PROP_AUTOCONNECT_PRIORITY: - priv->autoconnect_priority = g_value_get_int(value); - break; - case PROP_AUTOCONNECT_RETRIES: - priv->autoconnect_retries = g_value_get_int(value); - break; - case PROP_MULTI_CONNECT: - priv->multi_connect = g_value_get_int(value); - break; case PROP_TIMESTAMP: priv->timestamp = g_value_get_uint64(value); break; - case PROP_READ_ONLY: - priv->read_only = g_value_get_boolean(value); - break; - case PROP_ZONE: - g_free(priv->zone); - priv->zone = g_value_dup_string(value); - break; - case PROP_MASTER: - g_free(priv->master); - priv->master = g_value_dup_string(value); - break; - case PROP_SLAVE_TYPE: - g_free(priv->slave_type); - priv->slave_type = g_value_dup_string(value); - break; - case PROP_AUTOCONNECT_SLAVES: - priv->autoconnect_slaves = g_value_get_enum(value); - break; case PROP_SECONDARIES: nm_strvarray_set_strv(&priv->secondaries, g_value_get_boxed(value)); break; - case PROP_GATEWAY_PING_TIMEOUT: - priv->gateway_ping_timeout = g_value_get_uint(value); - break; - case PROP_METERED: - priv->metered = g_value_get_enum(value); - break; - case PROP_LLDP: - priv->lldp = g_value_get_int(value); - break; - case PROP_AUTH_RETRIES: - priv->auth_retries = g_value_get_int(value); - break; - case PROP_MDNS: - priv->mdns = g_value_get_int(value); - break; - case PROP_LLMNR: - priv->llmnr = g_value_get_int(value); - break; - case PROP_WAIT_DEVICE_TIMEOUT: - priv->wait_device_timeout = g_value_get_int(value); - break; - case PROP_MUD_URL: - g_free(priv->mud_url); - priv->mud_url = g_value_dup_string(value); - break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_set_property_direct(object, prop_id, value, pspec); break; } } @@ -1797,19 +1688,7 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps static void nm_setting_connection_init(NMSettingConnection *setting) -{ - NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE(setting); - - priv->auth_retries = -1; - priv->autoconnect = TRUE; - priv->autoconnect_priority = NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_DEFAULT; - priv->autoconnect_retries = -1; - priv->autoconnect_slaves = NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT; - priv->lldp = NM_SETTING_CONNECTION_LLDP_DEFAULT; - priv->llmnr = NM_SETTING_CONNECTION_LLMNR_DEFAULT; - priv->mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT; - priv->wait_device_timeout = -1; -} +{} /** * nm_setting_connection_new: @@ -1829,15 +1708,6 @@ finalize(GObject *object) { NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE(object); - g_free(priv->id); - g_free(priv->uuid); - g_free(priv->stable_id); - g_free(priv->interface_name); - g_free(priv->type); - g_free(priv->zone); - g_free(priv->master); - g_free(priv->slave_type); - g_free(priv->mud_url); nm_clear_pointer(&priv->permissions, g_array_unref); nm_clear_pointer(&priv->secondaries, g_array_unref); @@ -1857,8 +1727,7 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) object_class->set_property = set_property; object_class->finalize = finalize; - setting_class->verify = verify; - setting_class->compare_property = compare_property; + setting_class->verify = verify; /** * NMSettingConnection:id: @@ -1872,12 +1741,21 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * description: User friendly name for the connection profile. * ---end--- */ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_CONNECTION_ID, - PROP_ID, - NM_SETTING_PARAM_FUZZY_IGNORE, - nm_setting_connection_get_id); + _nm_setting_property_define_direct_string_full( + properties_override, + obj_properties, + NM_SETTING_CONNECTION_ID, + PROP_ID, + NM_SETTING_PARAM_FUZZY_IGNORE, + NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_STRING, + .direct_type = NM_VALUE_TYPE_STRING, + .compare_fcn = compare_fcn_id, + .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_direct, + .from_dbus_is_full = TRUE, + .from_dbus_direct_allow_transform = TRUE), + NMSettingConnectionPrivate, + id); /** * NMSettingConnection:uuid: @@ -1902,12 +1780,13 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * creates the UUID itself (by hashing the filename). * ---end--- */ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_CONNECTION_UUID, - PROP_UUID, - NM_SETTING_PARAM_FUZZY_IGNORE, - nm_setting_connection_get_uuid); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_CONNECTION_UUID, + PROP_UUID, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingConnectionPrivate, + uuid); /** * NMSettingConnection:stable-id: @@ -1956,12 +1835,13 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * description: Token to generate stable IDs. * ---end--- */ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_CONNECTION_STABLE_ID, - PROP_STABLE_ID, - NM_SETTING_PARAM_FUZZY_IGNORE, - nm_setting_connection_get_stable_id); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_CONNECTION_STABLE_ID, + PROP_STABLE_ID, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingConnectionPrivate, + stable_id); /** * NMSettingConnection:interface-name: @@ -1986,17 +1866,23 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * can be required for some connection types. * ---end--- */ - _nm_setting_property_define_string_full( + _nm_setting_property_define_direct_string_full( properties_override, obj_properties, NM_SETTING_CONNECTION_INTERFACE_NAME, PROP_INTERFACE_NAME, NM_SETTING_PARAM_INFERRABLE, NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_STRING, - .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_get_string, + .direct_type = NM_VALUE_TYPE_STRING, + .compare_fcn = _nm_setting_property_compare_fcn_direct, + .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct, .missing_from_dbus_fcn = - nm_setting_connection_no_interface_name), - nm_setting_connection_get_interface_name); + nm_setting_connection_no_interface_name, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_direct, + .from_dbus_is_full = TRUE, + .from_dbus_direct_allow_transform = TRUE), + NMSettingConnectionPrivate, + interface_name); /** * NMSettingConnection:type: @@ -2016,12 +1902,13 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * example: TYPE=Ethernet; TYPE=Bond; TYPE=Bridge; DEVICETYPE=TeamPort * ---end--- */ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_CONNECTION_TYPE, - PROP_TYPE, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_connection_get_connection_type); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_CONNECTION_TYPE, + PROP_TYPE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingConnectionPrivate, + type); /** * NMSettingConnection:permissions: @@ -2063,6 +1950,10 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * %TRUE to automatically activate the connection, %FALSE to require manual * intervention to activate the connection. * + * Autoconnect happens when the circumstances are suitable. That means for + * example that the device is currently managed and not active. Autoconnect + * thus never replaces or competes with an already active profile. + * * Note that autoconnect is not implemented for VPN profiles. See * #NMSettingConnection:secondaries as an alternative to automatically * connect VPN profiles. @@ -2074,20 +1965,24 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * description: Whether the connection should be autoconnected (not only while booting). * ---end--- */ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_CONNECTION_AUTOCONNECT, - PROP_AUTOCONNECT, - TRUE, - NM_SETTING_PARAM_FUZZY_IGNORE, - nm_setting_connection_get_autoconnect); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_CONNECTION_AUTOCONNECT, + PROP_AUTOCONNECT, + TRUE, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingConnectionPrivate, + autoconnect); /** * NMSettingConnection:autoconnect-priority: * - * The autoconnect priority. If the connection is set to autoconnect, - * connections with higher priority will be preferred. Defaults to 0. - * The higher number means higher priority. + * The autoconnect priority in range -999 to 999. If the connection is set + * to autoconnect, connections with higher priority will be preferred. + * The higher number means higher priority. Defaults to 0. + * Note that this property only matters if there are more than one candidate + * profile to select for autoconnect. In case of equal priority, the profile + * used most recently is chosen. **/ /* ---ifcfg-rh--- * property: autoconnect-priority @@ -2099,14 +1994,16 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * example: AUTOCONNECT_PRIORITY=20 * ---end--- */ - obj_properties[PROP_AUTOCONNECT_PRIORITY] = g_param_spec_int( - NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY, - "", - "", - NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MIN, - NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MAX, - NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_DEFAULT, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY, + PROP_AUTOCONNECT_PRIORITY, + NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MIN, + NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MAX, + NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_DEFAULT, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingConnectionPrivate, + autoconnect_priority); /** * NMSettingConnection:autoconnect-retries: @@ -2126,14 +2023,16 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * example: AUTOCONNECT_RETRIES=1 * ---end--- */ - obj_properties[PROP_AUTOCONNECT_RETRIES] = g_param_spec_int( - NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES, - "", - "", - -1, - G_MAXINT32, - -1, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES, + PROP_AUTOCONNECT_RETRIES, + -1, + G_MAXINT32, + -1, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingConnectionPrivate, + autoconnect_retries); /** * NMSettingConnection:multi-connect: @@ -2151,14 +2050,16 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * example: MULTI_CONNECT=3 * ---end--- */ - obj_properties[PROP_MULTI_CONNECT] = g_param_spec_int( - NM_SETTING_CONNECTION_MULTI_CONNECT, - "", - "", - G_MININT32, - G_MAXINT32, - NM_CONNECTION_MULTI_CONNECT_DEFAULT, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_CONNECTION_MULTI_CONNECT, + PROP_MULTI_CONNECT, + G_MININT32, + G_MAXINT32, + NM_CONNECTION_MULTI_CONNECT_DEFAULT, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingConnectionPrivate, + multi_connect); /** * NMSettingConnection:timestamp: @@ -2183,7 +2084,10 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) properties_override, obj_properties[PROP_TIMESTAMP], NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_UINT64, - .to_dbus_fcn = _to_dbus_fcn_timestamp, )); + .compare_fcn = compare_fcn_timestamp, + .to_dbus_fcn = _to_dbus_fcn_timestamp, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE)); /** * NMSettingConnection:read-only: @@ -2192,13 +2096,14 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * service's D-Bus interface with the right privileges, or %TRUE if the * connection is read-only and cannot be modified. **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_CONNECTION_READ_ONLY, - PROP_READ_ONLY, - FALSE, - NM_SETTING_PARAM_FUZZY_IGNORE, - nm_setting_connection_get_read_only); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_CONNECTION_READ_ONLY, + PROP_READ_ONLY, + FALSE, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingConnectionPrivate, + read_only); /** * NMSettingConnection:zone: @@ -2219,13 +2124,14 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * example: ZONE=Work * ---end--- */ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_CONNECTION_ZONE, - PROP_ZONE, - NM_SETTING_PARAM_FUZZY_IGNORE - | NM_SETTING_PARAM_REAPPLY_IMMEDIATELY, - nm_setting_connection_get_zone); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_CONNECTION_ZONE, + PROP_ZONE, + NM_SETTING_PARAM_FUZZY_IGNORE + | NM_SETTING_PARAM_REAPPLY_IMMEDIATELY, + NMSettingConnectionPrivate, + zone); /** * NMSettingConnection:master: @@ -2241,12 +2147,14 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * for compatibility with legacy tooling. * ---end--- */ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_CONNECTION_MASTER, - PROP_MASTER, - NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_INFERRABLE, - nm_setting_connection_get_master); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_CONNECTION_MASTER, + PROP_MASTER, + NM_SETTING_PARAM_FUZZY_IGNORE + | NM_SETTING_PARAM_INFERRABLE, + NMSettingConnectionPrivate, + master); /** * NMSettingConnection:slave-type: @@ -2265,12 +2173,14 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * and BRIDGE_UUID for bridging. * ---end--- */ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_CONNECTION_SLAVE_TYPE, - PROP_SLAVE_TYPE, - NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_INFERRABLE, - nm_setting_connection_get_slave_type); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_CONNECTION_SLAVE_TYPE, + PROP_SLAVE_TYPE, + NM_SETTING_PARAM_FUZZY_IGNORE + | NM_SETTING_PARAM_INFERRABLE, + NMSettingConnectionPrivate, + slave_type); /** * NMSettingConnection:autoconnect-slaves: @@ -2295,13 +2205,15 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * when this connection is activated. * ---end--- */ - obj_properties[PROP_AUTOCONNECT_SLAVES] = g_param_spec_enum( - NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES, - "", - "", - NM_TYPE_SETTING_CONNECTION_AUTOCONNECT_SLAVES, - NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_enum(properties_override, + obj_properties, + NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES, + PROP_AUTOCONNECT_SLAVES, + NM_TYPE_SETTING_CONNECTION_AUTOCONNECT_SLAVES, + NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingConnectionPrivate, + autoconnect_slaves); /** * NMSettingConnection:secondaries: @@ -2339,14 +2251,16 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * example: GATEWAY_PING_TIMEOUT=5 * ---end--- */ - obj_properties[PROP_GATEWAY_PING_TIMEOUT] = - g_param_spec_uint(NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT, - "", - "", - 0, - 600, - 0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT, + PROP_GATEWAY_PING_TIMEOUT, + 0, + 600, + 0, + NM_SETTING_PARAM_NONE, + NMSettingConnectionPrivate, + gateway_ping_timeout); /** * NMSettingConnection:metered: @@ -2366,13 +2280,15 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * example: CONNECTION_METERED=yes * ---end--- */ - obj_properties[PROP_METERED] = g_param_spec_enum( - NM_SETTING_CONNECTION_METERED, - "", - "", - NM_TYPE_METERED, - NM_METERED_UNKNOWN, - G_PARAM_READWRITE | NM_SETTING_PARAM_REAPPLY_IMMEDIATELY | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_enum(properties_override, + obj_properties, + NM_SETTING_CONNECTION_METERED, + PROP_METERED, + NM_TYPE_METERED, + NM_METERED_UNKNOWN, + NM_SETTING_PARAM_REAPPLY_IMMEDIATELY, + NMSettingConnectionPrivate, + metered); /** * NMSettingConnection:lldp: @@ -2390,14 +2306,16 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * example: LLDP=no * ---end--- */ - obj_properties[PROP_LLDP] = g_param_spec_int(NM_SETTING_CONNECTION_LLDP, - "", - "", - G_MININT32, - G_MAXINT32, - NM_SETTING_CONNECTION_LLDP_DEFAULT, - NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_READWRITE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_CONNECTION_LLDP, + PROP_LLDP, + G_MININT32, + G_MAXINT32, + NM_SETTING_CONNECTION_LLDP_DEFAULT, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingConnectionPrivate, + lldp); /** * NMSettingConnection:auth-retries: @@ -2417,14 +2335,16 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * description: Number of retries for authentication. * ---end--- */ - obj_properties[PROP_AUTH_RETRIES] = g_param_spec_int( - NM_SETTING_CONNECTION_AUTH_RETRIES, - "", - "", - -1, - G_MAXINT32, - -1, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_CONNECTION_AUTH_RETRIES, + PROP_AUTH_RETRIES, + -1, + G_MAXINT32, + -1, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingConnectionPrivate, + auth_retries); /** * NMSettingConnection:mdns: @@ -2440,7 +2360,7 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * * This feature requires a plugin which supports mDNS. Otherwise, the * setting has no effect. One such plugin is dns-systemd-resolved. -* + * * Since: 1.12 **/ /* ---ifcfg-rh--- @@ -2452,13 +2372,16 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * example: MDNS=yes * ---end--- */ - obj_properties[PROP_MDNS] = g_param_spec_int(NM_SETTING_CONNECTION_MDNS, - "", - "", - G_MININT32, - G_MAXINT32, - NM_SETTING_CONNECTION_MDNS_DEFAULT, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_CONNECTION_MDNS, + PROP_MDNS, + G_MININT32, + G_MAXINT32, + NM_SETTING_CONNECTION_MDNS_DEFAULT, + NM_SETTING_PARAM_NONE, + NMSettingConnectionPrivate, + mdns); /** * NMSettingConnection:llmnr: @@ -2488,13 +2411,52 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * example: LLMNR=yes * ---end--- */ - obj_properties[PROP_LLMNR] = g_param_spec_int(NM_SETTING_CONNECTION_LLMNR, - "", - "", - G_MININT32, - G_MAXINT32, - NM_SETTING_CONNECTION_LLMNR_DEFAULT, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_CONNECTION_LLMNR, + PROP_LLMNR, + G_MININT32, + G_MAXINT32, + NM_SETTING_CONNECTION_LLMNR_DEFAULT, + NM_SETTING_PARAM_NONE, + NMSettingConnectionPrivate, + llmnr); + + /** + * NMSettingConnection:dns-over-tls: + * + * Whether DNSOverTls (dns-over-tls) is enabled for the connection. + * DNSOverTls is a technology which uses TLS to encrypt dns traffic. + * + * The permitted values are: "yes" (2) use DNSOverTls and disabled fallback, + * "opportunistic" (1) use DNSOverTls but allow fallback to unencrypted resolution, + * "no" (0) don't ever use DNSOverTls. + * If unspecified "default" depends on the plugin used. Systemd-resolved + * uses global setting. + * + * This feature requires a plugin which supports DNSOverTls. Otherwise, the + * setting has no effect. One such plugin is dns-systemd-resolved. + * + * Since: 1.34 + **/ + /* ---ifcfg-rh--- + * property: dns-over-tls + * variable: DNS_OVER_TLS(+) + * values: yes,no,opportunistic + * default: missing variable means global default + * description: Whether or not DNSOverTls is enabled for the connection + * ---end--- + */ + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_CONNECTION_DNS_OVER_TLS, + PROP_DNS_OVER_TLS, + G_MININT32, + G_MAXINT32, + NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT, + NM_SETTING_PARAM_NONE, + NMSettingConnectionPrivate, + dns_over_tls); /** * NMSettingConnection:wait-device-timeout: @@ -2521,14 +2483,16 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * example: DEVTIMEOUT=5 * ---end--- */ - obj_properties[PROP_WAIT_DEVICE_TIMEOUT] = - g_param_spec_int(NM_SETTING_CONNECTION_WAIT_DEVICE_TIMEOUT, - "", - "", - -1, - G_MAXINT32, - -1, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_CONNECTION_WAIT_DEVICE_TIMEOUT, + PROP_WAIT_DEVICE_TIMEOUT, + -1, + G_MAXINT32, + -1, + NM_SETTING_PARAM_NONE, + NMSettingConnectionPrivate, + wait_device_timeout); /** * NMSettingConnection:mud-url: @@ -2552,17 +2516,19 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) * example: https://yourdevice.example.com/model.json * ---end--- */ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_CONNECTION_MUD_URL, - PROP_MUD_URL, - NM_SETTING_PARAM_NONE, - nm_setting_connection_get_mud_url); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_CONNECTION_MUD_URL, + PROP_MUD_URL, + NM_SETTING_PARAM_NONE, + NMSettingConnectionPrivate, + mud_url); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_CONNECTION, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_CONNECTION, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-dcb.c b/src/libnm-core-impl/nm-setting-dcb.c index f9602c3b..a6f4a973 100644 --- a/src/libnm-core-impl/nm-setting-dcb.c +++ b/src/libnm-core-impl/nm-setting-dcb.c @@ -48,21 +48,21 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingDcb, PROP_PRIORITY_TRAFFIC_CLASS, ); typedef struct { - char * app_fcoe_mode; - guint pfc[8]; - guint priority_group_id[8]; - guint priority_group_bandwidth[8]; - guint priority_bandwidth[8]; - guint priority_strict[8]; - guint priority_traffic_class[8]; - int app_fcoe_priority; - int app_iscsi_priority; - int app_fip_priority; - NMSettingDcbFlags app_fcoe_flags; - NMSettingDcbFlags app_iscsi_flags; - NMSettingDcbFlags app_fip_flags; - NMSettingDcbFlags pfc_flags; - NMSettingDcbFlags priority_group_flags; + char * app_fcoe_mode; + guint pfc[8]; + guint priority_group_id[8]; + guint priority_group_bandwidth[8]; + guint priority_bandwidth[8]; + guint priority_strict[8]; + guint priority_traffic_class[8]; + guint app_fcoe_flags; + guint app_iscsi_flags; + guint app_fip_flags; + guint pfc_flags; + guint priority_group_flags; + gint32 app_fcoe_priority; + gint32 app_iscsi_priority; + gint32 app_fip_priority; } NMSettingDcbPrivate; /** @@ -607,17 +607,10 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) error)) return FALSE; - if (!priv->app_fcoe_mode) { - g_set_error_literal(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_MISSING_PROPERTY, - _("property missing")); - g_prefix_error(error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, NM_SETTING_DCB_APP_FCOE_MODE); - return FALSE; - } - - if (strcmp(priv->app_fcoe_mode, NM_SETTING_DCB_FCOE_MODE_FABRIC) - && strcmp(priv->app_fcoe_mode, NM_SETTING_DCB_FCOE_MODE_VN2VN)) { + if (!NM_IN_STRSET(priv->app_fcoe_mode, + NULL, + NM_SETTING_DCB_FCOE_MODE_FABRIC, + NM_SETTING_DCB_FCOE_MODE_VN2VN)) { g_set_error_literal(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -745,20 +738,23 @@ set_gvalue_from_array(GValue *v, uint *a, size_t len) #define SET_GVALUE_FROM_ARRAY(v, a) set_gvalue_from_array(v, a, G_N_ELEMENTS(a)) static void -_nm_setting_dcb_uint_array_from_dbus(GVariant *dbus_value, GValue *prop_value) +_nm_setting_dcb_uint_array_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_GPROP_FCN_ARGS _nm_nil) { gconstpointer array; gsize length; - array = g_variant_get_fixed_array(dbus_value, &length, sizeof(guint32)); - set_gvalue_from_array(prop_value, (guint *) array, length); + array = g_variant_get_fixed_array(from, &length, sizeof(guint32)); + set_gvalue_from_array(to, (guint *) array, length); } static const NMSettInfoPropertType nm_sett_info_propert_type_dcb_au = NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT( NM_G_VARIANT_TYPE("au"), - .typdata_to_dbus.gprop_type = NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_GARRAY_UINT, - .gprop_from_dbus_fcn = _nm_setting_dcb_uint_array_from_dbus, ); + .typdata_to_dbus.gprop_type = NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_GARRAY_UINT, + .typdata_from_dbus.gprop_fcn = _nm_setting_dcb_uint_array_from_dbus, + .compare_fcn = _nm_setting_property_compare_fcn_default, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE); /*****************************************************************************/ @@ -769,36 +765,9 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE(setting); switch (prop_id) { - case PROP_APP_FCOE_FLAGS: - g_value_set_flags(value, priv->app_fcoe_flags); - break; - case PROP_APP_FCOE_PRIORITY: - g_value_set_int(value, priv->app_fcoe_priority); - break; - case PROP_APP_FCOE_MODE: - g_value_set_string(value, priv->app_fcoe_mode); - break; - case PROP_APP_ISCSI_FLAGS: - g_value_set_flags(value, priv->app_iscsi_flags); - break; - case PROP_APP_ISCSI_PRIORITY: - g_value_set_int(value, priv->app_iscsi_priority); - break; - case PROP_APP_FIP_FLAGS: - g_value_set_flags(value, priv->app_fip_flags); - break; - case PROP_APP_FIP_PRIORITY: - g_value_set_int(value, priv->app_fip_priority); - break; - case PROP_PFC_FLAGS: - g_value_set_flags(value, priv->pfc_flags); - break; case PROP_PRIORITY_FLOW_CONTROL: SET_GVALUE_FROM_ARRAY(value, priv->pfc); break; - case PROP_PRIORITY_GROUP_FLAGS: - g_value_set_flags(value, priv->priority_group_flags); - break; case PROP_PRIORITY_GROUP_ID: SET_GVALUE_FROM_ARRAY(value, priv->priority_group_id); break; @@ -815,7 +784,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) SET_GVALUE_FROM_ARRAY(value, priv->priority_traffic_class); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_get_property_direct(object, prop_id, value, pspec); break; } } @@ -826,37 +795,9 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE(object); switch (prop_id) { - case PROP_APP_FCOE_FLAGS: - priv->app_fcoe_flags = g_value_get_flags(value); - break; - case PROP_APP_FCOE_PRIORITY: - priv->app_fcoe_priority = g_value_get_int(value); - break; - case PROP_APP_FCOE_MODE: - g_free(priv->app_fcoe_mode); - priv->app_fcoe_mode = g_value_dup_string(value); - break; - case PROP_APP_ISCSI_FLAGS: - priv->app_iscsi_flags = g_value_get_flags(value); - break; - case PROP_APP_ISCSI_PRIORITY: - priv->app_iscsi_priority = g_value_get_int(value); - break; - case PROP_APP_FIP_FLAGS: - priv->app_fip_flags = g_value_get_flags(value); - break; - case PROP_APP_FIP_PRIORITY: - priv->app_fip_priority = g_value_get_int(value); - break; - case PROP_PFC_FLAGS: - priv->pfc_flags = g_value_get_flags(value); - break; case PROP_PRIORITY_FLOW_CONTROL: SET_ARRAY_FROM_GVALUE(value, priv->pfc); break; - case PROP_PRIORITY_GROUP_FLAGS: - priv->priority_group_flags = g_value_get_flags(value); - break; case PROP_PRIORITY_GROUP_ID: SET_ARRAY_FROM_GVALUE(value, priv->priority_group_id); break; @@ -873,7 +814,7 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps SET_ARRAY_FROM_GVALUE(value, priv->priority_traffic_class); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_set_property_direct(object, prop_id, value, pspec); break; } } @@ -882,14 +823,7 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps static void nm_setting_dcb_init(NMSettingDcb *self) -{ - NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE(self); - - priv->app_fcoe_mode = g_strdup(NM_SETTING_DCB_FCOE_MODE_FABRIC); - priv->app_fcoe_priority = -1; - priv->app_fip_priority = -1; - priv->app_iscsi_priority = -1; -} +{} /** * nm_setting_dcb_new: @@ -904,16 +838,6 @@ nm_setting_dcb_new(void) return g_object_new(NM_TYPE_SETTING_DCB, NULL); } -static void -finalize(GObject *object) -{ - NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE(object); - - g_free(priv->app_fcoe_mode); - - G_OBJECT_CLASS(nm_setting_dcb_parent_class)->finalize(object); -} - static void nm_setting_dcb_class_init(NMSettingDcbClass *klass) { @@ -925,7 +849,6 @@ nm_setting_dcb_class_init(NMSettingDcbClass *klass) object_class->get_property = get_property; object_class->set_property = set_property; - object_class->finalize = finalize; setting_class->verify = verify; @@ -944,13 +867,15 @@ nm_setting_dcb_class_init(NMSettingDcbClass *klass) * example: DCB_APP_FCOE_ENABLE=yes DCB_APP_FCOE_ADVERTISE=yes * ---end--- */ - obj_properties[PROP_APP_FCOE_FLAGS] = - g_param_spec_flags(NM_SETTING_DCB_APP_FCOE_FLAGS, - "", - "", - NM_TYPE_SETTING_DCB_FLAGS, - NM_SETTING_DCB_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_flags(properties_override, + obj_properties, + NM_SETTING_DCB_APP_FCOE_FLAGS, + PROP_APP_FCOE_FLAGS, + NM_TYPE_SETTING_DCB_FLAGS, + NM_SETTING_DCB_FLAG_NONE, + NM_SETTING_PARAM_NONE, + NMSettingDcbPrivate, + app_fcoe_flags); /** * NMSettingDcb:app-fcoe-priority: @@ -966,20 +891,25 @@ nm_setting_dcb_class_init(NMSettingDcbClass *klass) * description: Priority of FCoE frames. * ---end--- */ - obj_properties[PROP_APP_FCOE_PRIORITY] = - g_param_spec_int(NM_SETTING_DCB_APP_FCOE_PRIORITY, - "", - "", - -1, - 7, - -1, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_DCB_APP_FCOE_PRIORITY, + PROP_APP_FCOE_PRIORITY, + -1, + 7, + -1, + NM_SETTING_PARAM_NONE, + NMSettingDcbPrivate, + app_fcoe_priority); /** * NMSettingDcb:app-fcoe-mode: * * The FCoE controller mode; either %NM_SETTING_DCB_FCOE_MODE_FABRIC - * (default) or %NM_SETTING_DCB_FCOE_MODE_VN2VN. + * or %NM_SETTING_DCB_FCOE_MODE_VN2VN. + * + * Since 1.34, %NULL is the default and means %NM_SETTING_DCB_FCOE_MODE_FABRIC. + * Before 1.34, %NULL was rejected as invalid and the default was %NM_SETTING_DCB_FCOE_MODE_FABRIC. **/ /* ---ifcfg-rh--- * property: app-fcoe-mode @@ -989,12 +919,13 @@ nm_setting_dcb_class_init(NMSettingDcbClass *klass) * description: FCoE controller mode. * ---end--- */ - obj_properties[PROP_APP_FCOE_MODE] = - g_param_spec_string(NM_SETTING_DCB_APP_FCOE_MODE, - "", - "", - NM_SETTING_DCB_FCOE_MODE_FABRIC, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_DCB_APP_FCOE_MODE, + PROP_APP_FCOE_MODE, + NM_SETTING_PARAM_NONE, + NMSettingDcbPrivate, + app_fcoe_mode); /** * NMSettingDcb:app-iscsi-flags: @@ -1010,13 +941,15 @@ nm_setting_dcb_class_init(NMSettingDcbClass *klass) * description: iSCSI flags. * ---end--- */ - obj_properties[PROP_APP_ISCSI_FLAGS] = - g_param_spec_flags(NM_SETTING_DCB_APP_ISCSI_FLAGS, - "", - "", - NM_TYPE_SETTING_DCB_FLAGS, - NM_SETTING_DCB_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_flags(properties_override, + obj_properties, + NM_SETTING_DCB_APP_ISCSI_FLAGS, + PROP_APP_ISCSI_FLAGS, + NM_TYPE_SETTING_DCB_FLAGS, + NM_SETTING_DCB_FLAG_NONE, + NM_SETTING_PARAM_NONE, + NMSettingDcbPrivate, + app_iscsi_flags); /** * NMSettingDcb:app-iscsi-priority: @@ -1032,14 +965,16 @@ nm_setting_dcb_class_init(NMSettingDcbClass *klass) * description: Priority of iSCSI frames. * ---end--- */ - obj_properties[PROP_APP_ISCSI_PRIORITY] = - g_param_spec_int(NM_SETTING_DCB_APP_ISCSI_PRIORITY, - "", - "", - -1, - 7, - -1, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_DCB_APP_ISCSI_PRIORITY, + PROP_APP_ISCSI_PRIORITY, + -1, + 7, + -1, + NM_SETTING_PARAM_NONE, + NMSettingDcbPrivate, + app_iscsi_priority); /** * NMSettingDcb:app-fip-flags: @@ -1055,13 +990,15 @@ nm_setting_dcb_class_init(NMSettingDcbClass *klass) * description: FIP flags. * ---end--- */ - obj_properties[PROP_APP_FIP_FLAGS] = - g_param_spec_flags(NM_SETTING_DCB_APP_FIP_FLAGS, - "", - "", - NM_TYPE_SETTING_DCB_FLAGS, - NM_SETTING_DCB_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_flags(properties_override, + obj_properties, + NM_SETTING_DCB_APP_FIP_FLAGS, + PROP_APP_FIP_FLAGS, + NM_TYPE_SETTING_DCB_FLAGS, + NM_SETTING_DCB_FLAG_NONE, + NM_SETTING_PARAM_NONE, + NMSettingDcbPrivate, + app_fip_flags); /** * NMSettingDcb:app-fip-priority: @@ -1077,14 +1014,16 @@ nm_setting_dcb_class_init(NMSettingDcbClass *klass) * description: Priority of FIP frames. * ---end--- */ - obj_properties[PROP_APP_FIP_PRIORITY] = - g_param_spec_int(NM_SETTING_DCB_APP_FIP_PRIORITY, - "", - "", - -1, - 7, - -1, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_DCB_APP_FIP_PRIORITY, + PROP_APP_FIP_PRIORITY, + -1, + 7, + -1, + NM_SETTING_PARAM_NONE, + NMSettingDcbPrivate, + app_fip_priority); /** * NMSettingDcb:priority-flow-control-flags: @@ -1100,12 +1039,15 @@ nm_setting_dcb_class_init(NMSettingDcbClass *klass) * description: Priority flow control flags. * ---end--- */ - obj_properties[PROP_PFC_FLAGS] = g_param_spec_flags(NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS, - "", - "", - NM_TYPE_SETTING_DCB_FLAGS, - NM_SETTING_DCB_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_flags(properties_override, + obj_properties, + NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS, + PROP_PFC_FLAGS, + NM_TYPE_SETTING_DCB_FLAGS, + NM_SETTING_DCB_FLAG_NONE, + NM_SETTING_PARAM_NONE, + NMSettingDcbPrivate, + pfc_flags); /** * NMSettingDcb:priority-flow-control: (type GArray(gboolean)) @@ -1146,13 +1088,15 @@ nm_setting_dcb_class_init(NMSettingDcbClass *klass) * description: Priority groups flags. * ---end--- */ - obj_properties[PROP_PRIORITY_GROUP_FLAGS] = - g_param_spec_flags(NM_SETTING_DCB_PRIORITY_GROUP_FLAGS, - "", - "", - NM_TYPE_SETTING_DCB_FLAGS, - NM_SETTING_DCB_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_flags(properties_override, + obj_properties, + NM_SETTING_DCB_PRIORITY_GROUP_FLAGS, + PROP_PRIORITY_GROUP_FLAGS, + NM_TYPE_SETTING_DCB_FLAGS, + NM_SETTING_DCB_FLAG_NONE, + NM_SETTING_PARAM_NONE, + NMSettingDcbPrivate, + priority_group_flags); /** * NMSettingDcb:priority-group-id: (type GArray(guint)) @@ -1282,8 +1226,9 @@ nm_setting_dcb_class_init(NMSettingDcbClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_DCB, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_DCB, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-dummy.c b/src/libnm-core-impl/nm-setting-dummy.c index a998a27b..bfc82aea 100644 --- a/src/libnm-core-impl/nm-setting-dummy.c +++ b/src/libnm-core-impl/nm-setting-dummy.c @@ -78,5 +78,5 @@ nm_setting_dummy_class_init(NMSettingDummyClass *klass) setting_class->verify = verify; - _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_DUMMY); + _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_DUMMY, NULL, NULL, 0); } diff --git a/src/libnm-core-impl/nm-setting-ethtool.c b/src/libnm-core-impl/nm-setting-ethtool.c index abedcae3..901dab48 100644 --- a/src/libnm-core-impl/nm-setting-ethtool.c +++ b/src/libnm-core-impl/nm-setting-ethtool.c @@ -407,11 +407,12 @@ nm_setting_ethtool_class_init(NMSettingEthtoolClass *klass) setting_class->verify = verify; - _nm_setting_class_commit_full( + _nm_setting_class_commit( setting_class, NM_META_SETTING_TYPE_ETHTOOL, NM_SETT_INFO_SETT_DETAIL(.gendata_info = NM_SETT_INFO_SETT_GENDATA(.get_variant_type = get_variant_type, ), ), - NULL); + NULL, + 0); } diff --git a/src/libnm-core-impl/nm-setting-generic.c b/src/libnm-core-impl/nm-setting-generic.c index 0eff1ddf..ce212554 100644 --- a/src/libnm-core-impl/nm-setting-generic.c +++ b/src/libnm-core-impl/nm-setting-generic.c @@ -74,5 +74,5 @@ nm_setting_generic_class_init(NMSettingGenericClass *klass) g_type_class_add_private(klass, sizeof(NMSettingGenericPrivate)); - _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_GENERIC); + _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_GENERIC, NULL, NULL, 0); } diff --git a/src/libnm-core-impl/nm-setting-gsm.c b/src/libnm-core-impl/nm-setting-gsm.c index a177f7fb..8b2749d9 100644 --- a/src/libnm-core-impl/nm-setting-gsm.c +++ b/src/libnm-core-impl/nm-setting-gsm.c @@ -51,8 +51,8 @@ typedef struct { NMSettingSecretFlags password_flags; NMSettingSecretFlags pin_flags; guint32 mtu; - bool auto_config : 1; - bool home_only : 1; + bool auto_config; + bool home_only; } NMSettingGsmPrivate; /** @@ -667,13 +667,14 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass) * * Since: 1.22 **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_GSM_AUTO_CONFIG, - PROP_AUTO_CONFIG, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_gsm_get_auto_config); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_GSM_AUTO_CONFIG, + PROP_AUTO_CONFIG, + FALSE, + NM_SETTING_PARAM_NONE, + NMSettingGsmPrivate, + auto_config); /** * NMSettingGsm:number: @@ -794,13 +795,14 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass) * When %TRUE, only connections to the home network will be allowed. * Connections to roaming networks will not be made. **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_GSM_HOME_ONLY, - PROP_HOME_ONLY, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_gsm_get_home_only); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_GSM_HOME_ONLY, + PROP_HOME_ONLY, + FALSE, + NM_SETTING_PARAM_NONE, + NMSettingGsmPrivate, + home_only); /** * NMSettingGsm:device-id: @@ -879,8 +881,9 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_GSM, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_GSM, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-hostname.c b/src/libnm-core-impl/nm-setting-hostname.c index 248ae556..d0a15684 100644 --- a/src/libnm-core-impl/nm-setting-hostname.c +++ b/src/libnm-core-impl/nm-setting-hostname.c @@ -34,9 +34,9 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingHostname, struct _NMSettingHostname { NMSetting parent; int priority; - NMTernary from_dhcp; - NMTernary from_dns_lookup; - NMTernary only_from_default; + int from_dhcp; + int from_dns_lookup; + int only_from_default; }; struct _NMSettingHostnameClass { @@ -123,63 +123,9 @@ nm_setting_hostname_get_only_from_default(NMSettingHostname *setting) /*****************************************************************************/ -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingHostname *self = NM_SETTING_HOSTNAME(object); - - switch (prop_id) { - case PROP_PRIORITY: - g_value_set_int(value, self->priority); - break; - case PROP_FROM_DHCP: - g_value_set_enum(value, self->from_dhcp); - break; - case PROP_FROM_DNS_LOOKUP: - g_value_set_enum(value, self->from_dns_lookup); - break; - case PROP_ONLY_FROM_DEFAULT: - g_value_set_enum(value, self->only_from_default); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingHostname *self = NM_SETTING_HOSTNAME(object); - - switch (prop_id) { - case PROP_PRIORITY: - self->priority = g_value_get_int(value); - break; - case PROP_FROM_DHCP: - self->from_dhcp = g_value_get_enum(value); - break; - case PROP_FROM_DNS_LOOKUP: - self->from_dns_lookup = g_value_get_enum(value); - break; - case PROP_ONLY_FROM_DEFAULT: - self->only_from_default = g_value_get_enum(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - static void nm_setting_hostname_init(NMSettingHostname *setting) -{ - setting->from_dhcp = NM_TERNARY_DEFAULT; - setting->from_dns_lookup = NM_TERNARY_DEFAULT; - setting->only_from_default = NM_TERNARY_DEFAULT; -} +{} /** * nm_setting_hostname_new: @@ -199,11 +145,12 @@ nm_setting_hostname_new(void) static void nm_setting_hostname_class_init(NMSettingHostnameClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMSettingClass *setting_class = NM_SETTING_CLASS(klass); + GObjectClass * object_class = G_OBJECT_CLASS(klass); + NMSettingClass *setting_class = NM_SETTING_CLASS(klass); + GArray * properties_override = _nm_sett_info_property_override_create_array(); - object_class->get_property = get_property; - object_class->set_property = set_property; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; /** * NMSettingHostname:priority @@ -234,13 +181,16 @@ nm_setting_hostname_class_init(NMSettingHostnameClass *klass) * example: HOSTNAME_PRIORITY=50 * ---end--- */ - obj_properties[PROP_PRIORITY] = g_param_spec_int(NM_SETTING_HOSTNAME_PRIORITY, - "", - "", - G_MININT32, - G_MAXINT32, - 0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_HOSTNAME_PRIORITY, + PROP_PRIORITY, + G_MININT32, + G_MAXINT32, + 0, + NM_SETTING_PARAM_NONE, + NMSettingHostname, + priority); /** * NMSettingHostname:from-dhcp @@ -262,13 +212,13 @@ nm_setting_hostname_class_init(NMSettingHostnameClass *klass) * example: HOSTNAME_FROM_DHCP=0,1 * ---end--- */ - obj_properties[PROP_FROM_DHCP] = g_param_spec_enum( - NM_SETTING_HOSTNAME_FROM_DHCP, - "", - "", - NM_TYPE_TERNARY, - NM_TERNARY_DEFAULT, - NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_ternary_enum(properties_override, + obj_properties, + NM_SETTING_HOSTNAME_FROM_DHCP, + PROP_FROM_DHCP, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingHostname, + from_dhcp); /** * NMSettingHostname:from-dns-lookup @@ -291,13 +241,13 @@ nm_setting_hostname_class_init(NMSettingHostnameClass *klass) * example: HOSTNAME_FROM_DNS_LOOKUP=0,1 * ---end--- */ - obj_properties[PROP_FROM_DNS_LOOKUP] = g_param_spec_enum( - NM_SETTING_HOSTNAME_FROM_DNS_LOOKUP, - "", - "", - NM_TYPE_TERNARY, - NM_TERNARY_DEFAULT, - NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_ternary_enum(properties_override, + obj_properties, + NM_SETTING_HOSTNAME_FROM_DNS_LOOKUP, + PROP_FROM_DNS_LOOKUP, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingHostname, + from_dns_lookup); /** * NMSettingHostname:only-from-default @@ -325,15 +275,19 @@ nm_setting_hostname_class_init(NMSettingHostnameClass *klass) * example: HOSTNAME_ONLY_FROM_DEFAULT=0,1 * ---end--- */ - obj_properties[PROP_ONLY_FROM_DEFAULT] = g_param_spec_enum( - NM_SETTING_HOSTNAME_ONLY_FROM_DEFAULT, - "", - "", - NM_TYPE_TERNARY, - NM_TERNARY_DEFAULT, - NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_ternary_enum(properties_override, + obj_properties, + NM_SETTING_HOSTNAME_ONLY_FROM_DEFAULT, + PROP_ONLY_FROM_DEFAULT, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingHostname, + only_from_default); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_HOSTNAME); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_HOSTNAME, + NULL, + properties_override, + 0); } diff --git a/src/libnm-core-impl/nm-setting-infiniband.c b/src/libnm-core-impl/nm-setting-infiniband.c index 95dc7b66..adbf3636 100644 --- a/src/libnm-core-impl/nm-setting-infiniband.c +++ b/src/libnm-core-impl/nm-setting-infiniband.c @@ -379,7 +379,6 @@ finalize(GObject *object) NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE(object); g_free(priv->transport_mode); - g_free(priv->mac_address); g_free(priv->parent); g_free(priv->virtual_iface_name); @@ -426,15 +425,15 @@ nm_setting_infiniband_class_init(NMSettingInfinibandClass *klass) * example: HWADDR=01:02:03:04:05:06:07:08:09:0A:01:02:03:04:05:06:07:08:09:11 * ---end--- */ - obj_properties[PROP_MAC_ADDRESS] = g_param_spec_string( - NM_SETTING_INFINIBAND_MAC_ADDRESS, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_MAC_ADDRESS], - &nm_sett_info_propert_type_mac_address); + _nm_setting_property_define_direct_mac_address(properties_override, + obj_properties, + NM_SETTING_INFINIBAND_MAC_ADDRESS, + PROP_MAC_ADDRESS, + NM_SETTING_PARAM_INFERRABLE, + NMSettingInfinibandPrivate, + mac_address, + .direct_set_string_mac_address_len = + INFINIBAND_ALEN); /** * NMSettingInfiniband:mtu: @@ -530,8 +529,9 @@ nm_setting_infiniband_class_init(NMSettingInfinibandClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_INFINIBAND, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_INFINIBAND, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-ip-config.c b/src/libnm-core-impl/nm-setting-ip-config.c index f37e9d35..33779ed9 100644 --- a/src/libnm-core-impl/nm-setting-ip-config.c +++ b/src/libnm-core-impl/nm-setting-ip-config.c @@ -527,7 +527,7 @@ _nm_ip_address_get_attribute_names(const NMIPAddress *address, gboolean sorted, { nm_assert(address); - return nm_utils_strdict_get_keys(address->attributes, sorted, out_length); + return nm_strdict_get_keys(address->attributes, sorted, out_length); } /** @@ -546,7 +546,7 @@ nm_ip_address_get_attribute_names(NMIPAddress *address) g_return_val_if_fail(address, NULL); names = _nm_ip_address_get_attribute_names(address, TRUE, NULL); - return nm_utils_strv_make_deep_copied_nonnull(names); + return nm_strv_make_deep_copied_nonnull(names); } /** @@ -1134,7 +1134,7 @@ _nm_ip_route_get_attribute_names(const NMIPRoute *route, gboolean sorted, guint { nm_assert(route); - return nm_utils_strdict_get_keys(route->attributes, sorted, out_length); + return nm_strdict_get_keys(route->attributes, sorted, out_length); } /** @@ -1153,7 +1153,7 @@ nm_ip_route_get_attribute_names(NMIPRoute *route) g_return_val_if_fail(route != NULL, NULL); names = _nm_ip_route_get_attribute_names(route, TRUE, NULL); - return nm_utils_strv_make_deep_copied_nonnull(names); + return nm_strv_make_deep_copied_nonnull(names); } /** @@ -1440,7 +1440,7 @@ _nm_ip_route_attribute_validate_all(const NMIPRoute *route, GError **error) const char *key = attrs[i].name; GVariant * val2 = attrs[i].value_ptr; - if (!nm_ip_route_attribute_validate(key, val2, route->family, NULL, NULL)) + if (!nm_ip_route_attribute_validate(key, val2, route->family, NULL, error)) return FALSE; } @@ -2441,9 +2441,10 @@ nm_ip_routing_rule_set_suppress_prefixlength(NMIPRoutingRule *self, gint32 suppr * * Returns: %TRUE if a uid range is set. * - * Since: 1.32. Due to a bug, the symbols of this function - * are only exported starting with version 1.34.0. The function - * is unusable in 1.32. + * Since: 1.34 + * + * This API was wrongly introduced in the header files for 1.32, but the + * symbols were not exported. The API only works since 1.34 and newer. */ gboolean nm_ip_routing_rule_get_uid_range(const NMIPRoutingRule *self, @@ -2468,9 +2469,10 @@ nm_ip_routing_rule_get_uid_range(const NMIPRoutingRule *self, * For a valid range, start must be less or equal to end. * If set to an invalid range, the range gets unset. * - * Since: 1.32. Due to a bug, the symbols of this function - * are only exported starting with version 1.34.0. The function - * is unusable in 1.32. + * Since: 1.34 + * + * This API was wrongly introduced in the header files for 1.32, but the + * symbols were not exported. The API only works since 1.34 and newer. */ void nm_ip_routing_rule_set_uid_range(NMIPRoutingRule *self, @@ -3909,36 +3911,25 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingIPConfig, PROP_DHCP_IAID, PROP_DHCP_REJECT_SERVERS, ); -typedef struct { - GPtrArray *dns; /* array of IP address strings */ - GPtrArray *dns_search; /* array of domain name strings */ - GPtrArray *dns_options; /* array of DNS options */ - GPtrArray *addresses; /* array of NMIPAddress */ - GPtrArray *routes; /* array of NMIPRoute */ - GPtrArray *routing_rules; - GArray * dhcp_reject_servers; - char * method; - char * gateway; - char * dhcp_hostname; - char * dhcp_iaid; - gint64 route_metric; - guint dhcp_hostname_flags; - int dns_priority; - int dad_timeout; - int dhcp_timeout; - int required_timeout; - guint32 route_table; - bool ignore_auto_routes : 1; - bool ignore_auto_dns : 1; - bool dhcp_send_hostname : 1; - bool never_default : 1; - bool may_fail : 1; -} NMSettingIPConfigPrivate; - G_DEFINE_ABSTRACT_TYPE(NMSettingIPConfig, nm_setting_ip_config, NM_TYPE_SETTING) -#define NM_SETTING_IP_CONFIG_GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE((o), NM_TYPE_SETTING_IP_CONFIG, NMSettingIPConfigPrivate)) +static inline NMSettingIPConfigPrivate * +_NM_SETTING_IP_CONFIG_GET_PRIVATE(NMSettingIPConfig *self) +{ + NMSettingIPConfigClass *klass; + + nm_assert(NM_IS_SETTING_IP_CONFIG(self)); + + klass = NM_SETTING_IP_CONFIG_GET_CLASS(self); + + nm_assert(klass->private_offset < 0); + + return (gpointer) (((char *) ((gpointer) self)) + klass->private_offset); +} + +#define NM_SETTING_IP_CONFIG_GET_PRIVATE(self) \ + _NM_SETTING_IP_CONFIG_GET_PRIVATE( \ + NM_GOBJECT_CAST_NON_NULL(NMSettingIPConfig, self, NM_IS_SETTING_IP_CONFIG, NMSetting)) /*****************************************************************************/ @@ -4110,6 +4101,12 @@ nm_setting_ip_config_clear_dns(NMSettingIPConfig *setting) } } +GPtrArray * +_nm_setting_ip_config_get_dns_array(NMSettingIPConfig *setting) +{ + return NM_SETTING_IP_CONFIG_GET_PRIVATE(setting)->dns; +} + /** * nm_setting_ip_config_get_num_dns_searches: * @setting: the #NMSettingIPConfig @@ -4952,12 +4949,7 @@ nm_setting_ip_config_clear_routing_rules(NMSettingIPConfig *setting) } static GVariant * -_routing_rules_dbus_only_synth(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +_routing_rules_dbus_only_synth(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { NMSettingIPConfig * self = NM_SETTING_IP_CONFIG(setting); NMSettingIPConfigPrivate *priv; @@ -4988,12 +4980,7 @@ _routing_rules_dbus_only_synth(const NMSettInfoSetting * sett_info } static gboolean -_routing_rules_dbus_only_set(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +_routing_rules_dbus_only_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GVariantIter iter_rules; GVariant * rule_var; @@ -5037,6 +5024,7 @@ _routing_rules_dbus_only_set(NMSetting * setting, success = TRUE; out: + *out_is_modified = rules_changed; if (rules_changed) _routing_rules_notify(NM_SETTING_IP_CONFIG(setting)); return success; @@ -5216,7 +5204,7 @@ nm_setting_ip_config_get_dhcp_timeout(NMSettingIPConfig *setting) * * Returns: the required timeout for the address family * - * Since: 1.34, 1.32.4 + * Since: 1.34 **/ int nm_setting_ip_config_get_required_timeout(NMSettingIPConfig *setting) @@ -5628,77 +5616,77 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) return TRUE; } -static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +NMTernary +_nm_setting_ip_config_compare_fcn_addresses(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) { NMSettingIPConfigPrivate *a_priv; NMSettingIPConfigPrivate *b_priv; guint i; - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_IP_CONFIG_ADDRESSES)) { - if (set_b) { - a_priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(set_a); - b_priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(set_b); + if (set_b) { + a_priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(set_a); + b_priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(set_b); - if (a_priv->addresses->len != b_priv->addresses->len) + if (a_priv->addresses->len != b_priv->addresses->len) + return FALSE; + for (i = 0; i < a_priv->addresses->len; i++) { + if (nm_ip_address_cmp_full(a_priv->addresses->pdata[i], + b_priv->addresses->pdata[i], + NM_IP_ADDRESS_CMP_FLAGS_WITH_ATTRS) + != 0) return FALSE; - for (i = 0; i < a_priv->addresses->len; i++) { - if (nm_ip_address_cmp_full(a_priv->addresses->pdata[i], - b_priv->addresses->pdata[i], - NM_IP_ADDRESS_CMP_FLAGS_WITH_ATTRS) - != 0) - return FALSE; - } } - return TRUE; } + return TRUE; +} - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_IP_CONFIG_ROUTES)) { - if (set_b) { - a_priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(set_a); - b_priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(set_b); +NMTernary +_nm_setting_ip_config_compare_fcn_routes(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) +{ + NMSettingIPConfigPrivate *a_priv; + NMSettingIPConfigPrivate *b_priv; + guint i; - if (a_priv->routes->len != b_priv->routes->len) + if (set_b) { + a_priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(set_a); + b_priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(set_b); + + if (a_priv->routes->len != b_priv->routes->len) + return FALSE; + for (i = 0; i < a_priv->routes->len; i++) { + if (!nm_ip_route_equal_full(a_priv->routes->pdata[i], + b_priv->routes->pdata[i], + NM_IP_ROUTE_EQUAL_CMP_FLAGS_WITH_ATTRS)) return FALSE; - for (i = 0; i < a_priv->routes->len; i++) { - if (!nm_ip_route_equal_full(a_priv->routes->pdata[i], - b_priv->routes->pdata[i], - NM_IP_ROUTE_EQUAL_CMP_FLAGS_WITH_ATTRS)) - return FALSE; - } } - return TRUE; } + return TRUE; +} + +static NMTernary +compare_fcn_routing_rules(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) +{ + NMSettingIPConfigPrivate *a_priv; + NMSettingIPConfigPrivate *b_priv; + guint i; - if (nm_streq(sett_info->property_infos[property_idx].name, - NM_SETTING_IP_CONFIG_ROUTING_RULES)) { - if (set_b) { - guint n; + if (set_b) { + guint n; - a_priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(set_a); - b_priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(set_b); + a_priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(set_a); + b_priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(set_b); - n = (a_priv->routing_rules) ? a_priv->routing_rules->len : 0u; - if (n != (b_priv->routing_rules ? b_priv->routing_rules->len : 0u)) + n = (a_priv->routing_rules) ? a_priv->routing_rules->len : 0u; + if (n != (b_priv->routing_rules ? b_priv->routing_rules->len : 0u)) + return FALSE; + for (i = 0; i < n; i++) { + if (nm_ip_routing_rule_cmp(a_priv->routing_rules->pdata[i], + b_priv->routing_rules->pdata[i]) + != 0) return FALSE; - for (i = 0; i < n; i++) { - if (nm_ip_routing_rule_cmp(a_priv->routing_rules->pdata[i], - b_priv->routing_rules->pdata[i]) - != 0) - return FALSE; - } } - return TRUE; } - - return NM_SETTING_CLASS(nm_setting_ip_config_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + return TRUE; } static void @@ -5759,58 +5747,61 @@ enumerate_values(const NMSettInfoProperty *property_info, /*****************************************************************************/ -static gboolean -ip_gateway_set(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +gboolean +_nm_setting_property_from_dbus_fcn_direct_ip_config_gateway( + _NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { - /* FIXME: properly handle errors */ - /* Don't set from 'gateway' if we're going to use the gateway in 'addresses' */ if (_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "gateway")) return TRUE; - g_object_set(setting, property, g_variant_get_string(value, NULL), NULL); - return TRUE; + return _nm_setting_property_from_dbus_fcn_direct(sett_info, + property_info, + setting, + connection_dict, + value, + parse_flags, + out_is_modified, + error); } GArray * -_nm_sett_info_property_override_create_array_ip_config(void) +_nm_sett_info_property_override_create_array_ip_config(int addr_family) { GArray *properties_override = _nm_sett_info_property_override_create_array(); + nm_assert_addr_family(addr_family); + _nm_properties_override_gobj( properties_override, obj_properties[PROP_METHOD], - &nm_sett_info_propert_type_string, - .to_dbus_data.get_string = - (const char *(*) (NMSetting *) ) nm_setting_ip_config_get_method); + &nm_sett_info_propert_type_direct_string, + .direct_offset = NM_STRUCT_OFFSET_ENSURE_TYPE(char *, NMSettingIPConfigPrivate, method)); _nm_properties_override_gobj( properties_override, obj_properties[PROP_GATEWAY], - NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_STRING, - .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_get_string, - .from_dbus_fcn = ip_gateway_set), - .to_dbus_data.get_string = - (const char *(*) (NMSetting *) ) nm_setting_ip_config_get_gateway); + NM_SETT_INFO_PROPERT_TYPE_DBUS( + G_VARIANT_TYPE_STRING, + .direct_type = NM_VALUE_TYPE_STRING, + .compare_fcn = _nm_setting_property_compare_fcn_direct, + .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_direct_ip_config_gateway), + .direct_offset = NM_STRUCT_OFFSET_ENSURE_TYPE(char *, NMSettingIPConfigPrivate, gateway), + .direct_set_string_ip_address_addr_family = addr_family); _nm_properties_override_gobj( properties_override, obj_properties[PROP_DHCP_HOSTNAME], - &nm_sett_info_propert_type_string, - .to_dbus_data.get_string = - (const char *(*) (NMSetting *) ) nm_setting_ip_config_get_dhcp_hostname); + &nm_sett_info_propert_type_direct_string, + .direct_offset = + NM_STRUCT_OFFSET_ENSURE_TYPE(char *, NMSettingIPConfigPrivate, dhcp_hostname)); _nm_properties_override_gobj( properties_override, obj_properties[PROP_DHCP_IAID], - &nm_sett_info_propert_type_string, - .to_dbus_data.get_string = - (const char *(*) (NMSetting *) ) nm_setting_ip_config_get_dhcp_iaid); + &nm_sett_info_propert_type_direct_string, + .direct_offset = NM_STRUCT_OFFSET_ENSURE_TYPE(char *, NMSettingIPConfigPrivate, dhcp_iaid)); /* ---dbus--- * property: routing-rules @@ -5823,37 +5814,42 @@ _nm_sett_info_property_override_create_array_ip_config(void) NM_SETTING_IP_CONFIG_ROUTING_RULES, NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"), .to_dbus_fcn = _routing_rules_dbus_only_synth, + .compare_fcn = compare_fcn_routing_rules, .from_dbus_fcn = _routing_rules_dbus_only_set, )); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_IGNORE_AUTO_ROUTES], - &nm_sett_info_propert_type_boolean, - .to_dbus_data.get_boolean = (gboolean(*)( - NMSetting *)) nm_setting_ip_config_get_ignore_auto_routes); - - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_IGNORE_AUTO_DNS], - &nm_sett_info_propert_type_boolean, - .to_dbus_data.get_boolean = (gboolean(*)( - NMSetting *)) nm_setting_ip_config_get_ignore_auto_dns); - - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_DHCP_SEND_HOSTNAME], - &nm_sett_info_propert_type_boolean, - .to_dbus_data.get_boolean = (gboolean(*)( - NMSetting *)) nm_setting_ip_config_get_dhcp_send_hostname); - - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_NEVER_DEFAULT], - &nm_sett_info_propert_type_boolean, - .to_dbus_data.get_boolean = (gboolean(*)( - NMSetting *)) nm_setting_ip_config_get_never_default); - - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_MAY_FAIL], - &nm_sett_info_propert_type_boolean, - .to_dbus_data.get_boolean = - (gboolean(*)(NMSetting *)) nm_setting_ip_config_get_may_fail); + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_IGNORE_AUTO_ROUTES], + &nm_sett_info_propert_type_direct_boolean, + .direct_offset = + NM_STRUCT_OFFSET_ENSURE_TYPE(bool, NMSettingIPConfigPrivate, ignore_auto_routes)); + + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_IGNORE_AUTO_DNS], + &nm_sett_info_propert_type_direct_boolean, + .direct_offset = + NM_STRUCT_OFFSET_ENSURE_TYPE(bool, NMSettingIPConfigPrivate, ignore_auto_dns)); + + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_DHCP_SEND_HOSTNAME], + &nm_sett_info_propert_type_direct_boolean, + .direct_offset = + NM_STRUCT_OFFSET_ENSURE_TYPE(bool, NMSettingIPConfigPrivate, dhcp_send_hostname)); + + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_NEVER_DEFAULT], + &nm_sett_info_propert_type_direct_boolean, + .direct_offset = + NM_STRUCT_OFFSET_ENSURE_TYPE(bool, NMSettingIPConfigPrivate, never_default)); + + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_MAY_FAIL], + &nm_sett_info_propert_type_direct_boolean, + .direct_offset = NM_STRUCT_OFFSET_ENSURE_TYPE(bool, NMSettingIPConfigPrivate, may_fail)); return properties_override; } @@ -5952,7 +5948,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps { NMSettingIPConfig * setting = NM_SETTING_IP_CONFIG(object); NMSettingIPConfigPrivate *priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(setting); - const char * gateway; char ** strv; guint i; @@ -5963,11 +5958,11 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps break; case PROP_DNS: g_ptr_array_unref(priv->dns); - priv->dns = _nm_utils_strv_to_ptrarray(g_value_get_boxed(value)); + priv->dns = nm_strv_to_ptrarray(g_value_get_boxed(value)); break; case PROP_DNS_SEARCH: g_ptr_array_unref(priv->dns_search); - priv->dns_search = _nm_utils_strv_to_ptrarray(g_value_get_boxed(value)); + priv->dns_search = nm_strv_to_ptrarray(g_value_get_boxed(value)); break; case PROP_DNS_OPTIONS: strv = g_value_get_boxed(value); @@ -5998,12 +5993,10 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps (GDestroyNotify) nm_ip_address_unref); break; case PROP_GATEWAY: - gateway = g_value_get_string(value); - g_return_if_fail( - !gateway - || nm_utils_ipaddr_is_valid(NM_SETTING_IP_CONFIG_GET_FAMILY(setting), gateway)); g_free(priv->gateway); - priv->gateway = canonicalize_ip(NM_SETTING_IP_CONFIG_GET_FAMILY(setting), gateway, TRUE); + priv->gateway = + _nm_utils_ipaddr_canonical_or_invalid(NM_SETTING_IP_CONFIG_GET_FAMILY(setting), + g_value_get_string(value)); break; case PROP_ROUTES: g_ptr_array_unref(priv->routes); @@ -6063,20 +6056,24 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps /*****************************************************************************/ +void +_nm_setting_ip_config_private_init(gpointer self, NMSettingIPConfigPrivate *priv) +{ + nm_assert(NM_IS_SETTING_IP_CONFIG(self)); + + priv->dns = g_ptr_array_new_with_free_func(g_free); + priv->dns_search = g_ptr_array_new_with_free_func(g_free); + priv->addresses = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_address_unref); + priv->routes = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_route_unref); + priv->route_metric = -1; + priv->dad_timeout = -1; + priv->required_timeout = -1; +} + static void nm_setting_ip_config_init(NMSettingIPConfig *setting) { - NMSettingIPConfigPrivate *priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(setting); - - priv->dns = g_ptr_array_new_with_free_func(g_free); - priv->dns_search = g_ptr_array_new_with_free_func(g_free); - priv->addresses = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_address_unref); - priv->routes = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_route_unref); - priv->route_metric = -1; - priv->dhcp_send_hostname = TRUE; - priv->may_fail = TRUE; - priv->dad_timeout = -1; - priv->required_timeout = -1; + /* cannot yet access NM_SETTING_IP_CONFIG_GET_PRIVATE(). */ } static void @@ -6085,11 +6082,6 @@ finalize(GObject *object) NMSettingIPConfig * self = NM_SETTING_IP_CONFIG(object); NMSettingIPConfigPrivate *priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(self); - g_free(priv->method); - g_free(priv->gateway); - g_free(priv->dhcp_hostname); - g_free(priv->dhcp_iaid); - g_ptr_array_unref(priv->dns); g_ptr_array_unref(priv->dns_search); if (priv->dns_options) @@ -6109,14 +6101,11 @@ nm_setting_ip_config_class_init(NMSettingIPConfigClass *klass) GObjectClass * object_class = G_OBJECT_CLASS(klass); NMSettingClass *setting_class = NM_SETTING_CLASS(klass); - g_type_class_add_private(klass, sizeof(NMSettingIPConfigPrivate)); - object_class->get_property = get_property; object_class->set_property = set_property; object_class->finalize = finalize; setting_class->verify = verify; - setting_class->compare_property = compare_property; setting_class->duplicate_copy_properties = duplicate_copy_properties; setting_class->enumerate_values = enumerate_values; @@ -6532,7 +6521,7 @@ nm_setting_ip_config_class_init(NMSettingIPConfigClass *klass) * default value (either configuration ipvx.required-timeout override or * zero). * - * Since: 1.34, 1.32.4 + * Since: 1.34 **/ obj_properties[PROP_REQUIRED_TIMEOUT] = g_param_spec_int( NM_SETTING_IP_CONFIG_REQUIRED_TIMEOUT, diff --git a/src/libnm-core-impl/nm-setting-ip-tunnel.c b/src/libnm-core-impl/nm-setting-ip-tunnel.c index d87a59f4..38f9047d 100644 --- a/src/libnm-core-impl/nm-setting-ip-tunnel.c +++ b/src/libnm-core-impl/nm-setting-ip-tunnel.c @@ -44,7 +44,7 @@ typedef struct { NMIPTunnelMode mode; guint32 mtu; guint32 flags; - bool path_mtu_discovery : 1; + bool path_mtu_discovery; } NMSettingIPTunnelPrivate; /** @@ -615,11 +615,7 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps static void nm_setting_ip_tunnel_init(NMSettingIPTunnel *self) -{ - NMSettingIPTunnelPrivate *priv = NM_SETTING_IP_TUNNEL_GET_PRIVATE(self); - - priv->path_mtu_discovery = TRUE; -} +{} /** * nm_setting_ip_tunnel_new: @@ -636,21 +632,6 @@ nm_setting_ip_tunnel_new(void) return g_object_new(NM_TYPE_SETTING_IP_TUNNEL, NULL); } -static void -finalize(GObject *object) -{ - NMSettingIPTunnel * setting = NM_SETTING_IP_TUNNEL(object); - NMSettingIPTunnelPrivate *priv = NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting); - - g_free(priv->parent); - g_free(priv->local); - g_free(priv->remote); - g_free(priv->input_key); - g_free(priv->output_key); - - G_OBJECT_CLASS(nm_setting_ip_tunnel_parent_class)->finalize(object); -} - static void nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass) { @@ -662,7 +643,6 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass) object_class->get_property = get_property; object_class->set_property = set_property; - object_class->finalize = finalize; setting_class->verify = verify; @@ -675,12 +655,13 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass) * * Since: 1.2 **/ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_IP_TUNNEL_PARENT, - PROP_PARENT, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_ip_tunnel_get_parent); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_IP_TUNNEL_PARENT, + PROP_PARENT, + NM_SETTING_PARAM_INFERRABLE, + NMSettingIPTunnelPrivate, + parent); /** * NMSettingIPTunnel:mode: @@ -707,12 +688,13 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass) * * Since: 1.2 **/ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_IP_TUNNEL_LOCAL, - PROP_LOCAL, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_ip_tunnel_get_local); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_IP_TUNNEL_LOCAL, + PROP_LOCAL, + NM_SETTING_PARAM_INFERRABLE, + NMSettingIPTunnelPrivate, + local); /** * NMSettingIPTunnel:remote: @@ -722,12 +704,13 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass) * * Since: 1.2 **/ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_IP_TUNNEL_REMOTE, - PROP_REMOTE, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_ip_tunnel_get_remote); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_IP_TUNNEL_REMOTE, + PROP_REMOTE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingIPTunnelPrivate, + remote); /** * NMSettingIPTunnel:ttl @@ -770,13 +753,14 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass) * * Since: 1.2 **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY, - PROP_PATH_MTU_DISCOVERY, - TRUE, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_ip_tunnel_get_path_mtu_discovery); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY, + PROP_PATH_MTU_DISCOVERY, + TRUE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingIPTunnelPrivate, + path_mtu_discovery); /** * NMSettingIPTunnel:input-key: @@ -786,12 +770,13 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass) * * Since: 1.2 **/ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_IP_TUNNEL_INPUT_KEY, - PROP_INPUT_KEY, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_ip_tunnel_get_input_key); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_IP_TUNNEL_INPUT_KEY, + PROP_INPUT_KEY, + NM_SETTING_PARAM_INFERRABLE, + NMSettingIPTunnelPrivate, + input_key); /** * NMSettingIPTunnel:output-key: @@ -801,12 +786,13 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass) * * Since: 1.2 **/ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_IP_TUNNEL_OUTPUT_KEY, - PROP_OUTPUT_KEY, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_ip_tunnel_get_output_key); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_IP_TUNNEL_OUTPUT_KEY, + PROP_OUTPUT_KEY, + NM_SETTING_PARAM_INFERRABLE, + NMSettingIPTunnelPrivate, + output_key); /** * NMSettingIPTunnel:encapsulation-limit: @@ -881,8 +867,9 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_IP_TUNNEL, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_IP_TUNNEL, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-ip4-config.c b/src/libnm-core-impl/nm-setting-ip4-config.c index a24ebcfb..a7b3d68b 100644 --- a/src/libnm-core-impl/nm-setting-ip4-config.c +++ b/src/libnm-core-impl/nm-setting-ip4-config.c @@ -8,6 +8,7 @@ #include "nm-setting-ip4-config.h" #include "nm-setting-private.h" +#include "nm-utils-private.h" /** * SECTION:nm-setting-ip4-config @@ -40,6 +41,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_DHCP_CLIENT_ID, PROP_DHCP_VENDOR_CLASS_IDENTIFIER, ); typedef struct { + NMSettingIPConfigPrivate parent; + char *dhcp_client_id; char *dhcp_fqdn; char *dhcp_vendor_class_identifier; @@ -319,24 +322,26 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static GVariant * -ip4_dns_to_dbus(const GValue *prop_value) +ip4_dns_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { - return nm_utils_ip4_dns_to_variant(g_value_get_boxed(prop_value)); + GPtrArray *dns; + + dns = _nm_setting_ip_config_get_dns_array(NM_SETTING_IP_CONFIG(setting)); + + if (nm_g_ptr_array_len(dns) == 0) + return NULL; + + return _nm_utils_ip4_dns_to_variant((const char *const *) dns->pdata, dns->len); } static void -ip4_dns_from_dbus(GVariant *dbus_value, GValue *prop_value) +ip4_dns_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_GPROP_FCN_ARGS _nm_nil) { - g_value_take_boxed(prop_value, nm_utils_ip4_dns_from_variant(dbus_value)); + g_value_take_boxed(to, nm_utils_ip4_dns_from_variant(from)); } static GVariant * -ip4_addresses_get(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +ip4_addresses_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *addrs = NULL; const char * gateway; @@ -347,12 +352,7 @@ ip4_addresses_get(const NMSettInfoSetting * sett_info, } static gboolean -ip4_addresses_set(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +ip4_addresses_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GPtrArray *addrs; GVariant * s_ip4; @@ -361,8 +361,10 @@ ip4_addresses_set(NMSetting * setting, /* FIXME: properly handle errors */ - if (!_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) + if (!_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) { + *out_is_modified = FALSE; return TRUE; + } addrs = nm_utils_ip4_addresses_from_variant(value, &gateway); @@ -391,12 +393,7 @@ ip4_addresses_set(NMSetting * setting, } static GVariant * -ip4_address_labels_get(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +ip4_address_labels_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG(setting); gboolean have_labels = FALSE; @@ -435,12 +432,7 @@ ip4_address_labels_get(const NMSettInfoSetting * sett_info, } static GVariant * -ip4_address_data_get(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +ip4_address_data_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *addrs = NULL; @@ -452,20 +444,17 @@ ip4_address_data_get(const NMSettInfoSetting * sett_info, } static gboolean -ip4_address_data_set(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +ip4_address_data_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GPtrArray *addrs; /* FIXME: properly handle errors */ /* Ignore 'address-data' if we're going to process 'addresses' */ - if (_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) + if (_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) { + *out_is_modified = FALSE; return TRUE; + } addrs = nm_utils_ip_addresses_from_variant(value, AF_INET); g_object_set(setting, NM_SETTING_IP_CONFIG_ADDRESSES, addrs, NULL); @@ -474,12 +463,7 @@ ip4_address_data_set(NMSetting * setting, } static GVariant * -ip4_routes_get(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +ip4_routes_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *routes = NULL; @@ -488,33 +472,25 @@ ip4_routes_get(const NMSettInfoSetting * sett_info, } static gboolean -ip4_routes_set(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +ip4_routes_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GPtrArray *routes; /* FIXME: properly handle errors */ - if (!_nm_setting_use_legacy_property(setting, connection_dict, "routes", "route-data")) + if (!_nm_setting_use_legacy_property(setting, connection_dict, "routes", "route-data")) { + *out_is_modified = FALSE; return TRUE; + } routes = nm_utils_ip4_routes_from_variant(value); - g_object_set(setting, property, routes, NULL); + g_object_set(setting, property_info->name, routes, NULL); g_ptr_array_unref(routes); return TRUE; } static GVariant * -ip4_route_data_get(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +ip4_route_data_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *routes = NULL; @@ -526,20 +502,17 @@ ip4_route_data_get(const NMSettInfoSetting * sett_info, } static gboolean -ip4_route_data_set(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +ip4_route_data_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GPtrArray *routes; /* FIXME: properly handle errors */ /* Ignore 'route-data' if we're going to process 'routes' */ - if (_nm_setting_use_legacy_property(setting, connection_dict, "routes", "route-data")) + if (_nm_setting_use_legacy_property(setting, connection_dict, "routes", "route-data")) { + *out_is_modified = FALSE; return TRUE; + } routes = nm_utils_ip_routes_from_variant(value, AF_INET); g_object_set(setting, NM_SETTING_IP_CONFIG_ROUTES, routes, NULL); @@ -598,7 +571,11 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps static void nm_setting_ip4_config_init(NMSettingIP4Config *setting) -{} +{ + NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE(setting); + + _nm_setting_ip_config_private_init(setting, &priv->parent); +} /** * nm_setting_ip4_config_new: @@ -613,33 +590,23 @@ nm_setting_ip4_config_new(void) return g_object_new(NM_TYPE_SETTING_IP4_CONFIG, NULL); } -static void -finalize(GObject *object) -{ - NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE(object); - - g_free(priv->dhcp_client_id); - g_free(priv->dhcp_fqdn); - g_free(priv->dhcp_vendor_class_identifier); - - G_OBJECT_CLASS(nm_setting_ip4_config_parent_class)->finalize(object); -} - static void nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMSettingClass *setting_class = NM_SETTING_CLASS(klass); - GArray * properties_override = _nm_sett_info_property_override_create_array_ip_config(); + GObjectClass * object_class = G_OBJECT_CLASS(klass); + NMSettingClass * setting_class = NM_SETTING_CLASS(klass); + NMSettingIPConfigClass *setting_ip_config_class = NM_SETTING_IP_CONFIG_CLASS(klass); + GArray *properties_override = _nm_sett_info_property_override_create_array_ip_config(AF_INET); - g_type_class_add_private(setting_class, sizeof(NMSettingIP4ConfigPrivate)); + g_type_class_add_private(klass, sizeof(NMSettingIP4ConfigPrivate)); object_class->get_property = get_property; object_class->set_property = set_property; - object_class->finalize = finalize; setting_class->verify = verify; + setting_ip_config_class->private_offset = g_type_class_get_instance_private_offset(klass); + /* ---ifcfg-rh--- * property: method * variable: BOOTPROTO @@ -847,12 +814,13 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) * example: DHCP_CLIENT_ID=ax-srv-1; DHCP_CLIENT_ID=01:44:44:44:44:44:44 * ---end--- */ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, - PROP_DHCP_CLIENT_ID, - NM_SETTING_PARAM_NONE, - nm_setting_ip4_config_get_dhcp_client_id); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, + PROP_DHCP_CLIENT_ID, + NM_SETTING_PARAM_NONE, + NMSettingIP4ConfigPrivate, + dhcp_client_id); /* ---ifcfg-rh--- * property: dad-timeout @@ -898,12 +866,13 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) * example: DHCP_FQDN=foo.bar.com * ---end--- */ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_IP4_CONFIG_DHCP_FQDN, - PROP_DHCP_FQDN, - NM_SETTING_PARAM_NONE, - nm_setting_ip4_config_get_dhcp_fqdn); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_IP4_CONFIG_DHCP_FQDN, + PROP_DHCP_FQDN, + NM_SETTING_PARAM_NONE, + NMSettingIP4ConfigPrivate, + dhcp_fqdn); /** * NMSettingIP4Config:dhcp-vendor-class-identifier: @@ -924,12 +893,13 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) * example: DHCP_VENDOR_CLASS_IDENTIFIER=foo * ---end--- */ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER, - PROP_DHCP_VENDOR_CLASS_IDENTIFIER, - NM_SETTING_PARAM_NONE, - nm_setting_ip4_config_get_dhcp_vendor_class_identifier); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER, + PROP_DHCP_VENDOR_CLASS_IDENTIFIER, + NM_SETTING_PARAM_NONE, + NMSettingIP4ConfigPrivate, + dhcp_vendor_class_identifier); /* IP4-specific property overrides */ @@ -943,9 +913,12 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) _nm_properties_override_gobj( properties_override, g_object_class_find_property(G_OBJECT_CLASS(setting_class), NM_SETTING_IP_CONFIG_DNS), - NM_SETT_INFO_PROPERT_TYPE_GPROP(NM_G_VARIANT_TYPE("au"), - .gprop_from_dbus_fcn = ip4_dns_from_dbus, ), - .to_dbus_data.gprop_to_dbus_fcn = ip4_dns_to_dbus); + NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("au"), + .compare_fcn = _nm_setting_property_compare_fcn_default, + .to_dbus_fcn = ip4_dns_to_dbus, + .typdata_from_dbus.gprop_fcn = ip4_dns_from_dbus, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE), ); /* ---dbus--- * property: addresses @@ -976,12 +949,14 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) g_object_class_find_property(G_OBJECT_CLASS(setting_class), NM_SETTING_IP_CONFIG_ADDRESSES), NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aau"), .to_dbus_fcn = ip4_addresses_get, + .compare_fcn = _nm_setting_ip_config_compare_fcn_addresses, .from_dbus_fcn = ip4_addresses_set, )); _nm_properties_override_dbus( properties_override, "address-labels", NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_STRING_ARRAY, - .to_dbus_fcn = ip4_address_labels_get, )); + .to_dbus_fcn = ip4_address_labels_get, + .compare_fcn = _nm_setting_property_compare_fcn_ignore, )); /* ---dbus--- * property: address-data @@ -997,6 +972,7 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) "address-data", NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"), .to_dbus_fcn = ip4_address_data_get, + .compare_fcn = _nm_setting_property_compare_fcn_ignore, .from_dbus_fcn = ip4_address_data_set, )); /* ---dbus--- @@ -1030,6 +1006,7 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) g_object_class_find_property(G_OBJECT_CLASS(setting_class), NM_SETTING_IP_CONFIG_ROUTES), NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aau"), .to_dbus_fcn = ip4_routes_get, + .compare_fcn = _nm_setting_ip_config_compare_fcn_routes, .from_dbus_fcn = ip4_routes_set, )); /* ---dbus--- @@ -1050,12 +1027,14 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) "route-data", NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"), .to_dbus_fcn = ip4_route_data_get, + .compare_fcn = _nm_setting_property_compare_fcn_ignore, .from_dbus_fcn = ip4_route_data_set, )); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_IP4_CONFIG, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_IP4_CONFIG, + NULL, + properties_override, + setting_ip_config_class->private_offset); } diff --git a/src/libnm-core-impl/nm-setting-ip6-config.c b/src/libnm-core-impl/nm-setting-ip6-config.c index ee72de57..87b9d958 100644 --- a/src/libnm-core-impl/nm-setting-ip6-config.c +++ b/src/libnm-core-impl/nm-setting-ip6-config.c @@ -10,6 +10,7 @@ #include #include "nm-setting-private.h" +#include "nm-utils-private.h" #include "nm-core-enum-types.h" #include "libnm-core-intern/nm-core-internal.h" @@ -45,6 +46,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_IP6_PRIVACY, PROP_RA_TIMEOUT, ); typedef struct { + NMSettingIPConfigPrivate parent; + char * token; char * dhcp_duid; NMSettingIP6ConfigPrivacy ip6_privacy; @@ -360,24 +363,26 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static GVariant * -ip6_dns_to_dbus(const GValue *prop_value) +ip6_dns_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { - return nm_utils_ip6_dns_to_variant(g_value_get_boxed(prop_value)); + GPtrArray *dns; + + dns = _nm_setting_ip_config_get_dns_array(NM_SETTING_IP_CONFIG(setting)); + + if (nm_g_ptr_array_len(dns) == 0) + return NULL; + + return _nm_utils_ip6_dns_to_variant((const char *const *) dns->pdata, dns->len); } static void -ip6_dns_from_dbus(GVariant *dbus_value, GValue *prop_value) +ip6_dns_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_GPROP_FCN_ARGS _nm_nil) { - g_value_take_boxed(prop_value, nm_utils_ip6_dns_from_variant(dbus_value)); + g_value_take_boxed(to, nm_utils_ip6_dns_from_variant(from)); } static GVariant * -ip6_addresses_get(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +ip6_addresses_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *addrs = NULL; const char * gateway; @@ -388,20 +393,15 @@ ip6_addresses_get(const NMSettInfoSetting * sett_info, } static gboolean -ip6_addresses_set(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +ip6_addresses_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GPtrArray *addrs; char * gateway = NULL; - /* FIXME: properly handle errors */ - - if (!_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) + if (!_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) { + *out_is_modified = FALSE; return TRUE; + } addrs = nm_utils_ip6_addresses_from_variant(value, &gateway); @@ -417,12 +417,7 @@ ip6_addresses_set(NMSetting * setting, } static GVariant * -ip6_address_data_get(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +ip6_address_data_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *addrs = NULL; @@ -434,20 +429,15 @@ ip6_address_data_get(const NMSettInfoSetting * sett_info, } static gboolean -ip6_address_data_set(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +ip6_address_data_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GPtrArray *addrs; - /* FIXME: properly handle errors */ - /* Ignore 'address-data' if we're going to process 'addresses' */ - if (_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) + if (_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) { + *out_is_modified = FALSE; return TRUE; + } addrs = nm_utils_ip_addresses_from_variant(value, AF_INET6); g_object_set(setting, NM_SETTING_IP_CONFIG_ADDRESSES, addrs, NULL); @@ -456,12 +446,7 @@ ip6_address_data_set(NMSetting * setting, } static GVariant * -ip6_routes_get(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +ip6_routes_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *routes = NULL; @@ -470,33 +455,23 @@ ip6_routes_get(const NMSettInfoSetting * sett_info, } static gboolean -ip6_routes_set(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +ip6_routes_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GPtrArray *routes; - /* FIXME: properly handle errors */ - - if (!_nm_setting_use_legacy_property(setting, connection_dict, "routes", "route-data")) + if (!_nm_setting_use_legacy_property(setting, connection_dict, "routes", "route-data")) { + *out_is_modified = FALSE; return TRUE; + } routes = nm_utils_ip6_routes_from_variant(value); - g_object_set(setting, property, routes, NULL); + g_object_set(setting, property_info->name, routes, NULL); g_ptr_array_unref(routes); return TRUE; } static GVariant * -ip6_route_data_get(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +ip6_route_data_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *routes = NULL; @@ -508,20 +483,15 @@ ip6_route_data_get(const NMSettInfoSetting * sett_info, } static gboolean -ip6_route_data_set(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +ip6_route_data_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GPtrArray *routes; - /* FIXME: properly handle errors */ - /* Ignore 'route-data' if we're going to process 'routes' */ - if (_nm_setting_use_legacy_property(setting, connection_dict, "routes", "route-data")) + if (_nm_setting_use_legacy_property(setting, connection_dict, "routes", "route-data")) { + *out_is_modified = FALSE; return TRUE; + } routes = nm_utils_ip_routes_from_variant(value, AF_INET6); g_object_set(setting, NM_SETTING_IP_CONFIG_ROUTES, routes, NULL); @@ -594,6 +564,8 @@ nm_setting_ip6_config_init(NMSettingIP6Config *setting) { NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE(setting); + _nm_setting_ip_config_private_init(setting, &priv->parent); + priv->ip6_privacy = NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN; priv->addr_gen_mode = NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY; } @@ -611,33 +583,23 @@ nm_setting_ip6_config_new(void) return g_object_new(NM_TYPE_SETTING_IP6_CONFIG, NULL); } -static void -finalize(GObject *object) -{ - NMSettingIP6Config * self = NM_SETTING_IP6_CONFIG(object); - NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE(self); - - g_free(priv->token); - g_free(priv->dhcp_duid); - - G_OBJECT_CLASS(nm_setting_ip6_config_parent_class)->finalize(object); -} - static void nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMSettingClass *setting_class = NM_SETTING_CLASS(klass); - GArray * properties_override = _nm_sett_info_property_override_create_array_ip_config(); + GObjectClass * object_class = G_OBJECT_CLASS(klass); + NMSettingClass * setting_class = NM_SETTING_CLASS(klass); + NMSettingIPConfigClass *setting_ip_config_class = NM_SETTING_IP_CONFIG_CLASS(klass); + GArray *properties_override = _nm_sett_info_property_override_create_array_ip_config(AF_INET6); g_type_class_add_private(klass, sizeof(NMSettingIP6ConfigPrivate)); object_class->get_property = get_property; object_class->set_property = set_property; - object_class->finalize = finalize; setting_class->verify = verify; + setting_ip_config_class->private_offset = g_type_class_get_instance_private_offset(klass); + /* ---ifcfg-rh--- * property: method * variable: IPV6INIT, IPV6FORWARDING, IPV6_AUTOCONF, DHCPV6C, IPV6_DISABLED @@ -914,12 +876,13 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) * example: IPV6_TOKEN=::53 * ---end--- */ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_IP6_CONFIG_TOKEN, - PROP_TOKEN, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_ip6_config_get_token); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_IP6_CONFIG_TOKEN, + PROP_TOKEN, + NM_SETTING_PARAM_INFERRABLE, + NMSettingIP6ConfigPrivate, + token); /** * NMSettingIP6Config:ra-timeout: @@ -994,12 +957,13 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) * example: DHCPV6_DUID=LL; DHCPV6_DUID=0301deadbeef0001; DHCPV6_DUID=03:01:de:ad:be:ef:00:01 * ---end--- */ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_IP6_CONFIG_DHCP_DUID, - PROP_DHCP_DUID, - NM_SETTING_PARAM_NONE, - nm_setting_ip6_config_get_dhcp_duid); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_IP6_CONFIG_DHCP_DUID, + PROP_DHCP_DUID, + NM_SETTING_PARAM_NONE, + NMSettingIP6ConfigPrivate, + dhcp_duid); /* IP6-specific property overrides */ @@ -1012,9 +976,12 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) _nm_properties_override_gobj( properties_override, g_object_class_find_property(G_OBJECT_CLASS(setting_class), NM_SETTING_IP_CONFIG_DNS), - NM_SETT_INFO_PROPERT_TYPE_GPROP(NM_G_VARIANT_TYPE("aay"), - .gprop_from_dbus_fcn = ip6_dns_from_dbus, ), - .to_dbus_data.gprop_to_dbus_fcn = ip6_dns_to_dbus); + NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aay"), + .compare_fcn = _nm_setting_property_compare_fcn_default, + .to_dbus_fcn = ip6_dns_to_dbus, + .typdata_from_dbus.gprop_fcn = ip6_dns_from_dbus, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE)); /* ---dbus--- * property: addresses @@ -1044,6 +1011,7 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) g_object_class_find_property(G_OBJECT_CLASS(setting_class), NM_SETTING_IP_CONFIG_ADDRESSES), NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("a(ayuay)"), .to_dbus_fcn = ip6_addresses_get, + .compare_fcn = _nm_setting_ip_config_compare_fcn_addresses, .from_dbus_fcn = ip6_addresses_set, )); /* ---dbus--- @@ -1060,6 +1028,7 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) "address-data", NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"), .to_dbus_fcn = ip6_address_data_get, + .compare_fcn = _nm_setting_property_compare_fcn_ignore, .from_dbus_fcn = ip6_address_data_set, )); /* ---dbus--- @@ -1081,6 +1050,7 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) g_object_class_find_property(G_OBJECT_CLASS(setting_class), NM_SETTING_IP_CONFIG_ROUTES), NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("a(ayuayu)"), .to_dbus_fcn = ip6_routes_get, + .compare_fcn = _nm_setting_ip_config_compare_fcn_routes, .from_dbus_fcn = ip6_routes_set, )); /* ---dbus--- @@ -1101,12 +1071,14 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) "route-data", NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"), .to_dbus_fcn = ip6_route_data_get, + .compare_fcn = _nm_setting_property_compare_fcn_ignore, .from_dbus_fcn = ip6_route_data_set, )); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_IP6_CONFIG, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_IP6_CONFIG, + NULL, + properties_override, + setting_ip_config_class->private_offset); } diff --git a/src/libnm-core-impl/nm-setting-macsec.c b/src/libnm-core-impl/nm-setting-macsec.c index 55024bb4..1a9e9bd8 100644 --- a/src/libnm-core-impl/nm-setting-macsec.c +++ b/src/libnm-core-impl/nm-setting-macsec.c @@ -45,8 +45,8 @@ typedef struct { NMSettingMacsecMode mode; NMSettingSecretFlags mka_cak_flags; NMSettingMacsecValidation validation; - bool encrypt : 1; - bool send_sci : 1; + bool encrypt; + bool send_sci; } NMSettingMacsecPrivate; /** @@ -492,9 +492,7 @@ nm_setting_macsec_init(NMSettingMacsec *self) NMSettingMacsecPrivate *priv = NM_SETTING_MACSEC_GET_PRIVATE(self); nm_assert(priv->mode == NM_SETTING_MACSEC_MODE_PSK); - priv->encrypt = TRUE; priv->port = 1; - priv->send_sci = TRUE; priv->validation = NM_SETTING_MACSEC_VALIDATION_STRICT; } @@ -583,13 +581,14 @@ nm_setting_macsec_class_init(NMSettingMacsecClass *klass) * * Since: 1.6 **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_MACSEC_ENCRYPT, - PROP_ENCRYPT, - TRUE, - NM_SETTING_PARAM_NONE, - nm_setting_macsec_get_encrypt); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_MACSEC_ENCRYPT, + PROP_ENCRYPT, + TRUE, + NM_SETTING_PARAM_NONE, + NMSettingMacsecPrivate, + encrypt); /** * NMSettingMacsec:mka-cak: @@ -676,18 +675,20 @@ nm_setting_macsec_class_init(NMSettingMacsecClass *klass) * * Since: 1.12 **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_MACSEC_SEND_SCI, - PROP_SEND_SCI, - TRUE, - NM_SETTING_PARAM_NONE, - nm_setting_macsec_get_send_sci); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_MACSEC_SEND_SCI, + PROP_SEND_SCI, + TRUE, + NM_SETTING_PARAM_NONE, + NMSettingMacsecPrivate, + send_sci); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_MACSEC, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_MACSEC, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-macvlan.c b/src/libnm-core-impl/nm-setting-macvlan.c index 9cb2b262..32b30c2c 100644 --- a/src/libnm-core-impl/nm-setting-macvlan.c +++ b/src/libnm-core-impl/nm-setting-macvlan.c @@ -30,8 +30,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PARENT, PROP_MODE, PROP_PROMISCUOUS, PROP typedef struct { char * parent; NMSettingMacvlanMode mode; - bool promiscuous : 1; - bool tap : 1; + bool promiscuous; + bool tap; } NMSettingMacvlanPrivate; /** @@ -234,11 +234,7 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps static void nm_setting_macvlan_init(NMSettingMacvlan *self) -{ - NMSettingMacvlanPrivate *priv = NM_SETTING_MACVLAN_GET_PRIVATE(self); - - priv->promiscuous = TRUE; -} +{} /** * nm_setting_macvlan_new: @@ -322,13 +318,14 @@ nm_setting_macvlan_class_init(NMSettingMacvlanClass *klass) * * Since: 1.2 **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_MACVLAN_PROMISCUOUS, - PROP_PROMISCUOUS, - TRUE, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_macvlan_get_promiscuous); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_MACVLAN_PROMISCUOUS, + PROP_PROMISCUOUS, + TRUE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingMacvlanPrivate, + promiscuous); /** * NMSettingMacvlan:tap: @@ -337,18 +334,20 @@ nm_setting_macvlan_class_init(NMSettingMacvlanClass *klass) * * Since: 1.2 **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_MACVLAN_TAP, - PROP_TAP, - FALSE, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_macvlan_get_tap); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_MACVLAN_TAP, + PROP_TAP, + FALSE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingMacvlanPrivate, + tap); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_MACVLAN, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_MACVLAN, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-match.c b/src/libnm-core-impl/nm-setting-match.c index e4f7c1a8..20c6b798 100644 --- a/src/libnm-core-impl/nm-setting-match.c +++ b/src/libnm-core-impl/nm-setting-match.c @@ -901,5 +901,5 @@ nm_setting_match_class_init(NMSettingMatchClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_MATCH); + _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_MATCH, NULL, NULL, 0); } diff --git a/src/libnm-core-impl/nm-setting-olpc-mesh.c b/src/libnm-core-impl/nm-setting-olpc-mesh.c index 103f6195..0da1d5b4 100644 --- a/src/libnm-core-impl/nm-setting-olpc-mesh.c +++ b/src/libnm-core-impl/nm-setting-olpc-mesh.c @@ -147,53 +147,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingOlpcMesh *setting = NM_SETTING_OLPC_MESH(object); - - switch (prop_id) { - case PROP_SSID: - g_value_set_boxed(value, nm_setting_olpc_mesh_get_ssid(setting)); - break; - case PROP_CHANNEL: - g_value_set_uint(value, nm_setting_olpc_mesh_get_channel(setting)); - break; - case PROP_DHCP_ANYCAST_ADDRESS: - g_value_set_string(value, nm_setting_olpc_mesh_get_dhcp_anycast_address(setting)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingOlpcMeshPrivate *priv = NM_SETTING_OLPC_MESH_GET_PRIVATE(object); - - switch (prop_id) { - case PROP_SSID: - if (priv->ssid) - g_bytes_unref(priv->ssid); - priv->ssid = g_value_dup_boxed(value); - break; - case PROP_CHANNEL: - priv->channel = g_value_get_uint(value); - break; - case PROP_DHCP_ANYCAST_ADDRESS: - g_free(priv->dhcp_anycast_addr); - priv->dhcp_anycast_addr = g_value_dup_string(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - static void nm_setting_olpc_mesh_init(NMSettingOlpcMesh *setting) {} @@ -211,18 +164,6 @@ nm_setting_olpc_mesh_new(void) return g_object_new(NM_TYPE_SETTING_OLPC_MESH, NULL); } -static void -finalize(GObject *object) -{ - NMSettingOlpcMeshPrivate *priv = NM_SETTING_OLPC_MESH_GET_PRIVATE(object); - - if (priv->ssid) - g_bytes_unref(priv->ssid); - g_free(priv->dhcp_anycast_addr); - - G_OBJECT_CLASS(nm_setting_olpc_mesh_parent_class)->finalize(object); -} - static void nm_setting_olpc_mesh_class_init(NMSettingOlpcMeshClass *klass) { @@ -232,9 +173,8 @@ nm_setting_olpc_mesh_class_init(NMSettingOlpcMeshClass *klass) g_type_class_add_private(klass, sizeof(NMSettingOlpcMeshPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -243,26 +183,29 @@ nm_setting_olpc_mesh_class_init(NMSettingOlpcMeshClass *klass) * * SSID of the mesh network to join. **/ - obj_properties[PROP_SSID] = g_param_spec_boxed(NM_SETTING_OLPC_MESH_SSID, - "", - "", - G_TYPE_BYTES, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_bytes(properties_override, + obj_properties, + NM_SETTING_OLPC_MESH_SSID, + PROP_SSID, + NM_SETTING_PARAM_INFERRABLE, + NMSettingOlpcMeshPrivate, + ssid); /** * NMSettingOlpcMesh:channel: * * Channel on which the mesh network to join is located. **/ - obj_properties[PROP_CHANNEL] = - g_param_spec_uint(NM_SETTING_OLPC_MESH_CHANNEL, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_OLPC_MESH_CHANNEL, + PROP_CHANNEL, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingOlpcMeshPrivate, + channel); /** * NMSettingOlpcMesh:dhcp-anycast-address: @@ -273,20 +216,20 @@ nm_setting_olpc_mesh_class_init(NMSettingOlpcMeshClass *klass) * * This is currently only implemented by dhclient DHCP plugin. **/ - obj_properties[PROP_DHCP_ANYCAST_ADDRESS] = - g_param_spec_string(NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_DHCP_ANYCAST_ADDRESS], - &nm_sett_info_propert_type_mac_address); + _nm_setting_property_define_direct_mac_address(properties_override, + obj_properties, + NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS, + PROP_DHCP_ANYCAST_ADDRESS, + NM_SETTING_PARAM_NONE, + NMSettingOlpcMeshPrivate, + dhcp_anycast_addr, + .direct_set_string_mac_address_len = ETH_ALEN); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_OLPC_MESH, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_OLPC_MESH, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-ovs-bridge.c b/src/libnm-core-impl/nm-setting-ovs-bridge.c index 22738d20..711d5461 100644 --- a/src/libnm-core-impl/nm-setting-ovs-bridge.c +++ b/src/libnm-core-impl/nm-setting-ovs-bridge.c @@ -37,9 +37,9 @@ struct _NMSettingOvsBridge { char *fail_mode; char *datapath_type; - bool mcast_snooping_enable : 1; - bool rstp_enable : 1; - bool stp_enable : 1; + bool mcast_snooping_enable; + bool rstp_enable; + bool stp_enable; }; struct _NMSettingOvsBridgeClass { @@ -320,13 +320,14 @@ nm_setting_ovs_bridge_class_init(NMSettingOvsBridgeClass *klass) * * Since: 1.10 **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE, - PROP_MCAST_SNOOPING_ENABLE, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_ovs_bridge_get_mcast_snooping_enable); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE, + PROP_MCAST_SNOOPING_ENABLE, + FALSE, + NM_SETTING_PARAM_NONE, + NMSettingOvsBridge, + mcast_snooping_enable); /** * NMSettingOvsBridge:rstp-enable: @@ -335,13 +336,14 @@ nm_setting_ovs_bridge_class_init(NMSettingOvsBridgeClass *klass) * * Since: 1.10 **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_OVS_BRIDGE_RSTP_ENABLE, - PROP_RSTP_ENABLE, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_ovs_bridge_get_rstp_enable); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_OVS_BRIDGE_RSTP_ENABLE, + PROP_RSTP_ENABLE, + FALSE, + NM_SETTING_PARAM_NONE, + NMSettingOvsBridge, + rstp_enable); /** * NMSettingOvsBridge:stp-enable: @@ -350,13 +352,14 @@ nm_setting_ovs_bridge_class_init(NMSettingOvsBridgeClass *klass) * * Since: 1.10 **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_OVS_BRIDGE_STP_ENABLE, - PROP_STP_ENABLE, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_ovs_bridge_get_stp_enable); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_OVS_BRIDGE_STP_ENABLE, + PROP_STP_ENABLE, + FALSE, + NM_SETTING_PARAM_NONE, + NMSettingOvsBridge, + stp_enable); /** * NMSettingOvsBridge:datapath-type: @@ -374,8 +377,9 @@ nm_setting_ovs_bridge_class_init(NMSettingOvsBridgeClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_OVS_BRIDGE, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_OVS_BRIDGE, + NULL, + properties_override, + 0); } diff --git a/src/libnm-core-impl/nm-setting-ovs-dpdk.c b/src/libnm-core-impl/nm-setting-ovs-dpdk.c index 957b0f57..3107531b 100644 --- a/src/libnm-core-impl/nm-setting-ovs-dpdk.c +++ b/src/libnm-core-impl/nm-setting-ovs-dpdk.c @@ -148,5 +148,5 @@ nm_setting_ovs_dpdk_class_init(NMSettingOvsDpdkClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_OVS_DPDK); + _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_OVS_DPDK, NULL, NULL, 0); } diff --git a/src/libnm-core-impl/nm-setting-ovs-external-ids.c b/src/libnm-core-impl/nm-setting-ovs-external-ids.c index b73c1af4..ea4004f0 100644 --- a/src/libnm-core-impl/nm-setting-ovs-external-ids.c +++ b/src/libnm-core-impl/nm-setting-ovs-external-ids.c @@ -211,7 +211,7 @@ nm_setting_ovs_external_ids_get_data_keys(NMSettingOvsExternalIDs *setting, guin return priv->data_keys; } - priv->data_keys = nm_utils_strdict_get_keys(priv->data, TRUE, out_len); + priv->data_keys = nm_strdict_get_keys(priv->data, TRUE, out_len); /* don't return %NULL, but hijack the @data_keys fields as a pseudo * empty strv array. */ @@ -387,31 +387,20 @@ connection_type_is_good: } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_fcn_data(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) { NMSettingOvsExternalIDsPrivate *priv; NMSettingOvsExternalIDsPrivate *pri2; - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_OVS_EXTERNAL_IDS_DATA)) { - if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) - return NM_TERNARY_DEFAULT; + if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) + return NM_TERNARY_DEFAULT; - if (!set_b) - return TRUE; + if (!set_b) + return TRUE; - priv = NM_SETTING_OVS_EXTERNAL_IDS_GET_PRIVATE(NM_SETTING_OVS_EXTERNAL_IDS(set_a)); - pri2 = NM_SETTING_OVS_EXTERNAL_IDS_GET_PRIVATE(NM_SETTING_OVS_EXTERNAL_IDS(set_b)); - return nm_utils_hashtable_equal(priv->data, pri2->data, TRUE, g_str_equal); - } - - return NM_SETTING_CLASS(nm_setting_ovs_external_ids_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + priv = NM_SETTING_OVS_EXTERNAL_IDS_GET_PRIVATE(NM_SETTING_OVS_EXTERNAL_IDS(set_a)); + pri2 = NM_SETTING_OVS_EXTERNAL_IDS_GET_PRIVATE(NM_SETTING_OVS_EXTERNAL_IDS(set_b)); + return nm_utils_hashtable_equal(priv->data, pri2->data, TRUE, g_str_equal); } /*****************************************************************************/ @@ -523,8 +512,7 @@ nm_setting_ovs_external_ids_class_init(NMSettingOvsExternalIDsClass *klass) object_class->set_property = set_property; object_class->finalize = finalize; - setting_class->compare_property = compare_property; - setting_class->verify = verify; + setting_class->verify = verify; /** * NMSettingOvsExternalIDs:data: (type GHashTable(utf8,utf8)) @@ -538,14 +526,22 @@ nm_setting_ovs_external_ids_class_init(NMSettingOvsExternalIDsClass *klass) "", G_TYPE_HASH_TABLE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_DATA], - &nm_sett_info_propert_type_strdict); + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_DATA], + NM_SETT_INFO_PROPERT_TYPE_GPROP(NM_G_VARIANT_TYPE("a{ss}"), + .typdata_from_dbus.gprop_fcn = _nm_utils_strdict_from_dbus, + .typdata_to_dbus.gprop_type = + NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_STRDICT, + .compare_fcn = compare_fcn_data, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE)); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_OVS_EXTERNAL_IDS, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_OVS_EXTERNAL_IDS, + NULL, + properties_override, + G_STRUCT_OFFSET(NMSettingOvsExternalIDs, _priv)); } diff --git a/src/libnm-core-impl/nm-setting-ovs-interface.c b/src/libnm-core-impl/nm-setting-ovs-interface.c index 1fde9605..58a01fcc 100644 --- a/src/libnm-core-impl/nm-setting-ovs-interface.c +++ b/src/libnm-core-impl/nm-setting-ovs-interface.c @@ -423,5 +423,5 @@ nm_setting_ovs_interface_class_init(NMSettingOvsInterfaceClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_OVS_INTERFACE); + _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_OVS_INTERFACE, NULL, NULL, 0); } diff --git a/src/libnm-core-impl/nm-setting-ovs-patch.c b/src/libnm-core-impl/nm-setting-ovs-patch.c index a226a26d..578f5ee2 100644 --- a/src/libnm-core-impl/nm-setting-ovs-patch.c +++ b/src/libnm-core-impl/nm-setting-ovs-patch.c @@ -184,5 +184,5 @@ nm_setting_ovs_patch_class_init(NMSettingOvsPatchClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_OVS_PATCH); + _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_OVS_PATCH, NULL, NULL, 0); } diff --git a/src/libnm-core-impl/nm-setting-ovs-port.c b/src/libnm-core-impl/nm-setting-ovs-port.c index 821f29ab..fc593268 100644 --- a/src/libnm-core-impl/nm-setting-ovs-port.c +++ b/src/libnm-core-impl/nm-setting-ovs-port.c @@ -36,12 +36,12 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_VLAN_MODE, struct _NMSettingOvsPort { NMSetting parent; - char *vlan_mode; - char *lacp; - char *bond_mode; - guint tag; - guint bond_updelay; - guint bond_downdelay; + char * vlan_mode; + char * lacp; + char * bond_mode; + guint32 tag; + guint32 bond_updelay; + guint32 bond_downdelay; }; struct _NMSettingOvsPortClass { @@ -262,71 +262,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingOvsPort *self = NM_SETTING_OVS_PORT(object); - - switch (prop_id) { - case PROP_VLAN_MODE: - g_value_set_string(value, self->vlan_mode); - break; - case PROP_TAG: - g_value_set_uint(value, self->tag); - break; - case PROP_LACP: - g_value_set_string(value, self->lacp); - break; - case PROP_BOND_MODE: - g_value_set_string(value, self->bond_mode); - break; - case PROP_BOND_UPDELAY: - g_value_set_uint(value, self->bond_updelay); - break; - case PROP_BOND_DOWNDELAY: - g_value_set_uint(value, self->bond_downdelay); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingOvsPort *self = NM_SETTING_OVS_PORT(object); - - switch (prop_id) { - case PROP_VLAN_MODE: - g_free(self->vlan_mode); - self->vlan_mode = g_value_dup_string(value); - break; - case PROP_TAG: - self->tag = g_value_get_uint(value); - break; - case PROP_LACP: - g_free(self->lacp); - self->lacp = g_value_dup_string(value); - break; - case PROP_BOND_MODE: - g_free(self->bond_mode); - self->bond_mode = g_value_dup_string(value); - break; - case PROP_BOND_UPDELAY: - self->bond_updelay = g_value_get_uint(value); - break; - case PROP_BOND_DOWNDELAY: - self->bond_downdelay = g_value_get_uint(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - static void nm_setting_ovs_port_init(NMSettingOvsPort *self) {} @@ -346,27 +281,15 @@ nm_setting_ovs_port_new(void) return g_object_new(NM_TYPE_SETTING_OVS_PORT, NULL); } -static void -finalize(GObject *object) -{ - NMSettingOvsPort *self = NM_SETTING_OVS_PORT(object); - - g_free(self->vlan_mode); - g_free(self->lacp); - g_free(self->bond_mode); - - G_OBJECT_CLASS(nm_setting_ovs_port_parent_class)->finalize(object); -} - static void nm_setting_ovs_port_class_init(NMSettingOvsPortClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMSettingClass *setting_class = NM_SETTING_CLASS(klass); + GObjectClass * object_class = G_OBJECT_CLASS(klass); + NMSettingClass *setting_class = NM_SETTING_CLASS(klass); + GArray * properties_override = _nm_sett_info_property_override_create_array(); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -378,12 +301,13 @@ nm_setting_ovs_port_class_init(NMSettingOvsPortClass *klass) * * Since: 1.10 **/ - obj_properties[PROP_VLAN_MODE] = g_param_spec_string( - NM_SETTING_OVS_PORT_VLAN_MODE, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_OVS_PORT_VLAN_MODE, + PROP_VLAN_MODE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingOvsPort, + vlan_mode); /** * NMSettingOvsPort:tag: @@ -392,14 +316,16 @@ nm_setting_ovs_port_class_init(NMSettingOvsPortClass *klass) * * Since: 1.10 **/ - obj_properties[PROP_TAG] = - g_param_spec_uint(NM_SETTING_OVS_PORT_TAG, - "", - "", - 0, - 4095, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_OVS_PORT_TAG, + PROP_TAG, + 0, + 4095, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingOvsPort, + tag); /** * NMSettingOvsPort:lacp: @@ -408,12 +334,13 @@ nm_setting_ovs_port_class_init(NMSettingOvsPortClass *klass) * * Since: 1.10 **/ - obj_properties[PROP_LACP] = g_param_spec_string(NM_SETTING_OVS_PORT_LACP, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_OVS_PORT_LACP, + PROP_LACP, + NM_SETTING_PARAM_INFERRABLE, + NMSettingOvsPort, + lacp); /** * NMSettingOvsPort:bond-mode: @@ -422,12 +349,13 @@ nm_setting_ovs_port_class_init(NMSettingOvsPortClass *klass) * * Since: 1.10 **/ - obj_properties[PROP_BOND_MODE] = g_param_spec_string( - NM_SETTING_OVS_PORT_BOND_MODE, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_OVS_PORT_BOND_MODE, + PROP_BOND_MODE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingOvsPort, + bond_mode); /** * NMSettingOvsPort:bond-updelay: @@ -436,14 +364,16 @@ nm_setting_ovs_port_class_init(NMSettingOvsPortClass *klass) * * Since: 1.10 **/ - obj_properties[PROP_BOND_UPDELAY] = - g_param_spec_uint(NM_SETTING_OVS_PORT_BOND_UPDELAY, - "", - "", - 0, - G_MAXUINT, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_OVS_PORT_BOND_UPDELAY, + PROP_BOND_UPDELAY, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingOvsPort, + bond_updelay); /** * NMSettingOvsPort:bond-downdelay: @@ -452,16 +382,22 @@ nm_setting_ovs_port_class_init(NMSettingOvsPortClass *klass) * * Since: 1.10 **/ - obj_properties[PROP_BOND_DOWNDELAY] = - g_param_spec_uint(NM_SETTING_OVS_PORT_BOND_DOWNDELAY, - "", - "", - 0, - G_MAXUINT, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_OVS_PORT_BOND_DOWNDELAY, + PROP_BOND_DOWNDELAY, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingOvsPort, + bond_downdelay); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_OVS_PORT); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_OVS_PORT, + NULL, + properties_override, + 0); } diff --git a/src/libnm-core-impl/nm-setting-ppp.c b/src/libnm-core-impl/nm-setting-ppp.c index cc722c44..e4e4951e 100644 --- a/src/libnm-core-impl/nm-setting-ppp.c +++ b/src/libnm-core-impl/nm-setting-ppp.c @@ -47,19 +47,19 @@ typedef struct { guint32 mtu; guint32 lcp_echo_failure; guint32 lcp_echo_interval; - bool noauth : 1; - bool refuse_eap : 1; - bool refuse_pap : 1; - bool refuse_chap : 1; - bool refuse_mschap : 1; - bool refuse_mschapv2 : 1; - bool nobsdcomp : 1; - bool nodeflate : 1; - bool no_vj_comp : 1; - bool require_mppe : 1; - bool require_mppe_128 : 1; - bool mppe_stateful : 1; - bool crtscts : 1; + bool noauth; + bool refuse_eap; + bool refuse_pap; + bool refuse_chap; + bool refuse_mschap; + bool refuse_mschapv2; + bool nobsdcomp; + bool nodeflate; + bool no_vj_comp; + bool require_mppe; + bool require_mppe_128; + bool mppe_stateful; + bool crtscts; } NMSettingPppPrivate; /** @@ -337,6 +337,8 @@ nm_setting_ppp_get_lcp_echo_interval(NMSettingPpp *setting) return NM_SETTING_PPP_GET_PRIVATE(setting)->lcp_echo_interval; } +/*****************************************************************************/ + static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { @@ -376,147 +378,9 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingPpp *setting = NM_SETTING_PPP(object); - - switch (prop_id) { - case PROP_NOAUTH: - g_value_set_boolean(value, nm_setting_ppp_get_noauth(setting)); - break; - case PROP_REFUSE_EAP: - g_value_set_boolean(value, nm_setting_ppp_get_refuse_eap(setting)); - break; - case PROP_REFUSE_PAP: - g_value_set_boolean(value, nm_setting_ppp_get_refuse_pap(setting)); - break; - case PROP_REFUSE_CHAP: - g_value_set_boolean(value, nm_setting_ppp_get_refuse_chap(setting)); - break; - case PROP_REFUSE_MSCHAP: - g_value_set_boolean(value, nm_setting_ppp_get_refuse_mschap(setting)); - break; - case PROP_REFUSE_MSCHAPV2: - g_value_set_boolean(value, nm_setting_ppp_get_refuse_mschapv2(setting)); - break; - case PROP_NOBSDCOMP: - g_value_set_boolean(value, nm_setting_ppp_get_nobsdcomp(setting)); - break; - case PROP_NODEFLATE: - g_value_set_boolean(value, nm_setting_ppp_get_nodeflate(setting)); - break; - case PROP_NO_VJ_COMP: - g_value_set_boolean(value, nm_setting_ppp_get_no_vj_comp(setting)); - break; - case PROP_REQUIRE_MPPE: - g_value_set_boolean(value, nm_setting_ppp_get_require_mppe(setting)); - break; - case PROP_REQUIRE_MPPE_128: - g_value_set_boolean(value, nm_setting_ppp_get_require_mppe_128(setting)); - break; - case PROP_MPPE_STATEFUL: - g_value_set_boolean(value, nm_setting_ppp_get_mppe_stateful(setting)); - break; - case PROP_CRTSCTS: - g_value_set_boolean(value, nm_setting_ppp_get_crtscts(setting)); - break; - case PROP_BAUD: - g_value_set_uint(value, nm_setting_ppp_get_baud(setting)); - break; - case PROP_MRU: - g_value_set_uint(value, nm_setting_ppp_get_mru(setting)); - break; - case PROP_MTU: - g_value_set_uint(value, nm_setting_ppp_get_mtu(setting)); - break; - case PROP_LCP_ECHO_FAILURE: - g_value_set_uint(value, nm_setting_ppp_get_lcp_echo_failure(setting)); - break; - case PROP_LCP_ECHO_INTERVAL: - g_value_set_uint(value, nm_setting_ppp_get_lcp_echo_interval(setting)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingPppPrivate *priv = NM_SETTING_PPP_GET_PRIVATE(object); - - switch (prop_id) { - case PROP_NOAUTH: - priv->noauth = g_value_get_boolean(value); - break; - case PROP_REFUSE_EAP: - priv->refuse_eap = g_value_get_boolean(value); - break; - case PROP_REFUSE_PAP: - priv->refuse_pap = g_value_get_boolean(value); - break; - case PROP_REFUSE_CHAP: - priv->refuse_chap = g_value_get_boolean(value); - break; - case PROP_REFUSE_MSCHAP: - priv->refuse_mschap = g_value_get_boolean(value); - break; - case PROP_REFUSE_MSCHAPV2: - priv->refuse_mschapv2 = g_value_get_boolean(value); - break; - case PROP_NOBSDCOMP: - priv->nobsdcomp = g_value_get_boolean(value); - break; - case PROP_NODEFLATE: - priv->nodeflate = g_value_get_boolean(value); - break; - case PROP_NO_VJ_COMP: - priv->no_vj_comp = g_value_get_boolean(value); - break; - case PROP_REQUIRE_MPPE: - priv->require_mppe = g_value_get_boolean(value); - break; - case PROP_REQUIRE_MPPE_128: - priv->require_mppe_128 = g_value_get_boolean(value); - break; - case PROP_MPPE_STATEFUL: - priv->mppe_stateful = g_value_get_boolean(value); - break; - case PROP_CRTSCTS: - priv->crtscts = g_value_get_boolean(value); - break; - case PROP_BAUD: - priv->baud = g_value_get_uint(value); - break; - case PROP_MRU: - priv->mru = g_value_get_uint(value); - break; - case PROP_MTU: - priv->mtu = g_value_get_uint(value); - break; - case PROP_LCP_ECHO_FAILURE: - priv->lcp_echo_failure = g_value_get_uint(value); - break; - case PROP_LCP_ECHO_INTERVAL: - priv->lcp_echo_interval = g_value_get_uint(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - static void nm_setting_ppp_init(NMSettingPpp *self) -{ - NMSettingPppPrivate *priv = NM_SETTING_PPP_GET_PRIVATE(self); - - priv->noauth = TRUE; -} +{} /** * nm_setting_ppp_new: @@ -540,8 +404,8 @@ nm_setting_ppp_class_init(NMSettingPppClass *klass) g_type_class_add_private(klass, sizeof(NMSettingPppPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -552,117 +416,126 @@ nm_setting_ppp_class_init(NMSettingPppClass *klass) * authenticate itself to the client. If %FALSE, require authentication * from the remote side. In almost all cases, this should be %TRUE. **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_PPP_NOAUTH, - PROP_NOAUTH, - TRUE, - NM_SETTING_PARAM_NONE, - nm_setting_ppp_get_noauth); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_PPP_NOAUTH, + PROP_NOAUTH, + TRUE, + NM_SETTING_PARAM_NONE, + NMSettingPppPrivate, + noauth); /** * NMSettingPpp:refuse-eap: * * If %TRUE, the EAP authentication method will not be used. **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_PPP_REFUSE_EAP, - PROP_REFUSE_EAP, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_ppp_get_refuse_eap); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_PPP_REFUSE_EAP, + PROP_REFUSE_EAP, + FALSE, + NM_SETTING_PARAM_NONE, + NMSettingPppPrivate, + refuse_eap); /** * NMSettingPpp:refuse-pap: * * If %TRUE, the PAP authentication method will not be used. **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_PPP_REFUSE_PAP, - PROP_REFUSE_PAP, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_ppp_get_refuse_pap); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_PPP_REFUSE_PAP, + PROP_REFUSE_PAP, + FALSE, + NM_SETTING_PARAM_NONE, + NMSettingPppPrivate, + refuse_pap); /** * NMSettingPpp:refuse-chap: * * If %TRUE, the CHAP authentication method will not be used. **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_PPP_REFUSE_CHAP, - PROP_REFUSE_CHAP, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_ppp_get_refuse_chap); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_PPP_REFUSE_CHAP, + PROP_REFUSE_CHAP, + FALSE, + NM_SETTING_PARAM_NONE, + NMSettingPppPrivate, + refuse_chap); /** * NMSettingPpp:refuse-mschap: * * If %TRUE, the MSCHAP authentication method will not be used. **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_PPP_REFUSE_MSCHAP, - PROP_REFUSE_MSCHAP, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_ppp_get_refuse_mschap); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_PPP_REFUSE_MSCHAP, + PROP_REFUSE_MSCHAP, + FALSE, + NM_SETTING_PARAM_NONE, + NMSettingPppPrivate, + refuse_mschap); /** * NMSettingPpp:refuse-mschapv2: * * If %TRUE, the MSCHAPv2 authentication method will not be used. **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_PPP_REFUSE_MSCHAPV2, - PROP_REFUSE_MSCHAPV2, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_ppp_get_refuse_mschapv2); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_PPP_REFUSE_MSCHAPV2, + PROP_REFUSE_MSCHAPV2, + FALSE, + NM_SETTING_PARAM_NONE, + NMSettingPppPrivate, + refuse_mschapv2); /** * NMSettingPpp:nobsdcomp: * * If %TRUE, BSD compression will not be requested. **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_PPP_NOBSDCOMP, - PROP_NOBSDCOMP, - FALSE, - NM_SETTING_PARAM_FUZZY_IGNORE, - nm_setting_ppp_get_nobsdcomp); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_PPP_NOBSDCOMP, + PROP_NOBSDCOMP, + FALSE, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingPppPrivate, + nobsdcomp); /** * NMSettingPpp:nodeflate: * * If %TRUE, "deflate" compression will not be requested. **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_PPP_NODEFLATE, - PROP_NODEFLATE, - FALSE, - NM_SETTING_PARAM_FUZZY_IGNORE, - nm_setting_ppp_get_nodeflate); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_PPP_NODEFLATE, + PROP_NODEFLATE, + FALSE, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingPppPrivate, + nodeflate); /** * NMSettingPpp:no-vj-comp: * * If %TRUE, Van Jacobsen TCP header compression will not be requested. **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_PPP_NO_VJ_COMP, - PROP_NO_VJ_COMP, - FALSE, - NM_SETTING_PARAM_FUZZY_IGNORE, - nm_setting_ppp_get_no_vj_comp); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_PPP_NO_VJ_COMP, + PROP_NO_VJ_COMP, + FALSE, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingPppPrivate, + no_vj_comp); /** * NMSettingPpp:require-mppe: @@ -672,13 +545,14 @@ nm_setting_ppp_class_init(NMSettingPppClass *klass) * session will fail. Note that MPPE is not used on mobile broadband * connections. **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_PPP_REQUIRE_MPPE, - PROP_REQUIRE_MPPE, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_ppp_get_require_mppe); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_PPP_REQUIRE_MPPE, + PROP_REQUIRE_MPPE, + FALSE, + NM_SETTING_PARAM_NONE, + NMSettingPppPrivate, + require_mppe); /** * NMSettingPpp:require-mppe-128: @@ -687,13 +561,14 @@ nm_setting_ppp_class_init(NMSettingPppClass *klass) * required for the PPP session, and the "require-mppe" property must also * be set to %TRUE. If 128-bit MPPE is not available the session will fail. **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_PPP_REQUIRE_MPPE_128, - PROP_REQUIRE_MPPE_128, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_ppp_get_require_mppe_128); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_PPP_REQUIRE_MPPE_128, + PROP_REQUIRE_MPPE_128, + FALSE, + NM_SETTING_PARAM_NONE, + NMSettingPppPrivate, + require_mppe_128); /** * NMSettingPpp:mppe-stateful: @@ -701,13 +576,14 @@ nm_setting_ppp_class_init(NMSettingPppClass *klass) * If %TRUE, stateful MPPE is used. See pppd documentation for more * information on stateful MPPE. **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_PPP_MPPE_STATEFUL, - PROP_MPPE_STATEFUL, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_ppp_get_mppe_stateful); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_PPP_MPPE_STATEFUL, + PROP_MPPE_STATEFUL, + FALSE, + NM_SETTING_PARAM_NONE, + NMSettingPppPrivate, + mppe_stateful); /** * NMSettingPpp:crtscts: @@ -716,13 +592,14 @@ nm_setting_ppp_class_init(NMSettingPppClass *klass) * flow control with RTS and CTS signals. This value should normally be set * to %FALSE. **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_PPP_CRTSCTS, - PROP_CRTSCTS, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_ppp_get_crtscts); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_PPP_CRTSCTS, + PROP_CRTSCTS, + FALSE, + NM_SETTING_PARAM_NONE, + NMSettingPppPrivate, + crtscts); /** * NMSettingPpp:baud: @@ -731,14 +608,16 @@ nm_setting_ppp_class_init(NMSettingPppClass *klass) * baudrate. This value should normally be left as 0 to automatically * choose the speed. **/ - obj_properties[PROP_BAUD] = g_param_spec_uint(NM_SETTING_PPP_BAUD, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_PPP_BAUD, + PROP_BAUD, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingPppPrivate, + baud); /** * NMSettingPpp:mru: @@ -747,13 +626,16 @@ nm_setting_ppp_class_init(NMSettingPppClass *klass) * larger than the specified size. If non-zero, the MRU should be between * 128 and 16384. */ - obj_properties[PROP_MRU] = g_param_spec_uint(NM_SETTING_PPP_MRU, - "", - "", - 0, - 16384, - 0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_PPP_MRU, + PROP_MRU, + 0, + 16384, + 0, + NM_SETTING_PARAM_NONE, + NMSettingPppPrivate, + mru); /** * NMSettingPpp:mtu: @@ -761,14 +643,16 @@ nm_setting_ppp_class_init(NMSettingPppClass *klass) * If non-zero, instruct pppd to send packets no larger than the specified * size. **/ - obj_properties[PROP_MTU] = g_param_spec_uint(NM_SETTING_PPP_MTU, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_PPP_MTU, + PROP_MTU, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingPppPrivate, + mtu); /** * NMSettingPpp:lcp-echo-failure: @@ -778,14 +662,16 @@ nm_setting_ppp_class_init(NMSettingPppClass *klass) * peer. The "lcp-echo-interval" property must also be set to a non-zero * value if this property is used. **/ - obj_properties[PROP_LCP_ECHO_FAILURE] = g_param_spec_uint( - NM_SETTING_PPP_LCP_ECHO_FAILURE, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_PPP_LCP_ECHO_FAILURE, + PROP_LCP_ECHO_FAILURE, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingPppPrivate, + lcp_echo_failure); /** * NMSettingPpp:lcp-echo-interval: @@ -795,19 +681,22 @@ nm_setting_ppp_class_init(NMSettingPppClass *klass) * peers will respond to echo requests and some will not, and it is not * possible to autodetect this. **/ - obj_properties[PROP_LCP_ECHO_INTERVAL] = g_param_spec_uint( - NM_SETTING_PPP_LCP_ECHO_INTERVAL, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_PPP_LCP_ECHO_INTERVAL, + PROP_LCP_ECHO_INTERVAL, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingPppPrivate, + lcp_echo_interval); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_PPP, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_PPP, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-pppoe.c b/src/libnm-core-impl/nm-setting-pppoe.c index 12beb51a..3ae547a2 100644 --- a/src/libnm-core-impl/nm-setting-pppoe.c +++ b/src/libnm-core-impl/nm-setting-pppoe.c @@ -30,11 +30,11 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PARENT, PROP_PASSWORD_FLAGS, ); typedef struct { - char * parent; - char * service; - char * username; - char * password; - NMSettingSecretFlags password_flags; + char *parent; + char *service; + char *username; + char *password; + guint password_flags; } NMSettingPppoePrivate; /** @@ -138,23 +138,23 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) NMSettingPppoePrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE(setting); gs_free_error GError *local_error = NULL; - if (!priv->username) { - g_set_error_literal(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_MISSING_PROPERTY, - _("property is missing")); - g_prefix_error(error, "%s.%s: ", NM_SETTING_PPPOE_SETTING_NAME, NM_SETTING_PPPOE_USERNAME); - return FALSE; - } else if (!strlen(priv->username)) { - g_set_error_literal(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("property is empty")); + if (nm_str_is_empty(priv->username)) { + if (!priv->username) { + g_set_error_literal(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, + _("property is missing")); + } else { + g_set_error_literal(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("property is empty")); + } g_prefix_error(error, "%s.%s: ", NM_SETTING_PPPOE_SETTING_NAME, NM_SETTING_PPPOE_USERNAME); return FALSE; } - if (priv->service && !strlen(priv->service)) { + if (priv->service && nm_str_is_empty(priv->service)) { g_set_error_literal(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -196,66 +196,6 @@ need_secrets(NMSetting *setting) /*****************************************************************************/ -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingPppoe *setting = NM_SETTING_PPPOE(object); - - switch (prop_id) { - case PROP_PARENT: - g_value_set_string(value, nm_setting_pppoe_get_parent(setting)); - break; - case PROP_SERVICE: - g_value_set_string(value, nm_setting_pppoe_get_service(setting)); - break; - case PROP_USERNAME: - g_value_set_string(value, nm_setting_pppoe_get_username(setting)); - break; - case PROP_PASSWORD: - g_value_set_string(value, nm_setting_pppoe_get_password(setting)); - break; - case PROP_PASSWORD_FLAGS: - g_value_set_flags(value, nm_setting_pppoe_get_password_flags(setting)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingPppoePrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE(object); - - switch (prop_id) { - case PROP_PARENT: - g_free(priv->parent); - priv->parent = g_value_dup_string(value); - break; - case PROP_SERVICE: - g_free(priv->service); - priv->service = g_value_dup_string(value); - break; - case PROP_USERNAME: - g_free(priv->username); - priv->username = g_value_dup_string(value); - break; - case PROP_PASSWORD: - g_free(priv->password); - priv->password = g_value_dup_string(value); - break; - case PROP_PASSWORD_FLAGS: - priv->password_flags = g_value_get_flags(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - static void nm_setting_pppoe_init(NMSettingPppoe *setting) {} @@ -273,30 +213,17 @@ nm_setting_pppoe_new(void) return g_object_new(NM_TYPE_SETTING_PPPOE, NULL); } -static void -finalize(GObject *object) -{ - NMSettingPppoePrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE(object); - - g_free(priv->parent); - g_free(priv->username); - g_free(priv->password); - g_free(priv->service); - - G_OBJECT_CLASS(nm_setting_pppoe_parent_class)->finalize(object); -} - static void nm_setting_pppoe_class_init(NMSettingPppoeClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMSettingClass *setting_class = NM_SETTING_CLASS(klass); + GObjectClass * object_class = G_OBJECT_CLASS(klass); + NMSettingClass *setting_class = NM_SETTING_CLASS(klass); + GArray * properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(klass, sizeof(NMSettingPppoePrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; setting_class->need_secrets = need_secrets; @@ -311,12 +238,13 @@ nm_setting_pppoe_class_init(NMSettingPppoeClass *klass) * * Since: 1.10 **/ - obj_properties[PROP_PARENT] = g_param_spec_string( - NM_SETTING_PPPOE_PARENT, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_PPPOE_PARENT, + PROP_PARENT, + NM_SETTING_PARAM_INFERRABLE, + NMSettingPppoePrivate, + parent); /** * NMSettingPppoe:service: @@ -326,49 +254,57 @@ nm_setting_pppoe_class_init(NMSettingPppoeClass *klass) * this should be left blank. It is only required if there are multiple * access concentrators or a specific service is known to be required. **/ - obj_properties[PROP_SERVICE] = g_param_spec_string(NM_SETTING_PPPOE_SERVICE, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_PPPOE_SERVICE, + PROP_SERVICE, + NM_SETTING_PARAM_NONE, + NMSettingPppoePrivate, + service); /** * NMSettingPppoe:username: * * Username used to authenticate with the PPPoE service. **/ - obj_properties[PROP_USERNAME] = g_param_spec_string(NM_SETTING_PPPOE_USERNAME, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_PPPOE_USERNAME, + PROP_USERNAME, + NM_SETTING_PARAM_NONE, + NMSettingPppoePrivate, + username); /** * NMSettingPppoe:password: * * Password used to authenticate with the PPPoE service. **/ - obj_properties[PROP_PASSWORD] = - g_param_spec_string(NM_SETTING_PPPOE_PASSWORD, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_PPPOE_PASSWORD, + PROP_PASSWORD, + NM_SETTING_PARAM_SECRET, + NMSettingPppoePrivate, + password); /** * NMSettingPppoe:password-flags: * * Flags indicating how to handle the #NMSettingPppoe:password property. **/ - obj_properties[PROP_PASSWORD_FLAGS] = - g_param_spec_flags(NM_SETTING_PPPOE_PASSWORD_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_secret_flags(properties_override, + obj_properties, + NM_SETTING_PPPOE_PASSWORD_FLAGS, + PROP_PASSWORD_FLAGS, + NMSettingPppoePrivate, + password_flags); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_PPPOE); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_PPPOE, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-private.h b/src/libnm-core-impl/nm-setting-private.h index 061fc901..7faf5d1c 100644 --- a/src/libnm-core-impl/nm-setting-private.h +++ b/src/libnm-core-impl/nm-setting-private.h @@ -7,7 +7,7 @@ #define __NM_SETTING_PRIVATE_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #include "nm-setting.h" @@ -70,24 +70,12 @@ struct _NMSettingClass { GError ** error); gboolean (*clear_secrets)(const struct _NMSettInfoSetting *sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMSetting * setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data); - /* compare_property() returns a ternary, where DEFAULT means that the property should not - * be compared due to the compare @flags. A TRUE/FALSE result means that the property is - * equal/not-equal. - * - * @other may be %NULL, in which case the function only determines whether - * the setting should be compared (TRUE) or not (DEFAULT). */ - NMTernary (*compare_property)(const struct _NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags); + void (*padding_1)(void); void (*duplicate_copy_properties)(const struct _NMSettInfoSetting *sett_info, NMSetting * src, @@ -115,8 +103,6 @@ struct _NMSettingClass { guint /* NMSettingParseFlags */ parse_flags, GError ** error); - gpointer padding[1]; - const struct _NMMetaSettingInfo *setting_info; }; @@ -127,21 +113,54 @@ struct _NMSettingClass { */ struct _NMSettingIPConfig { NMSetting parent; + /* In the past, this struct was public API. Preserve ABI! */ }; struct _NMSettingIPConfigClass { NMSettingClass parent; - /* Padding for future expansion */ - gpointer padding[8]; + /* In the past, this struct was public API. Preserve ABI! */ + union { + gpointer _dummy; + int private_offset; + }; + gpointer padding[7]; }; +typedef struct { + GPtrArray *dns; /* array of IP address strings */ + GPtrArray *dns_search; /* array of domain name strings */ + GPtrArray *dns_options; /* array of DNS options */ + GPtrArray *addresses; /* array of NMIPAddress */ + GPtrArray *routes; /* array of NMIPRoute */ + GPtrArray *routing_rules; + GArray * dhcp_reject_servers; + char * method; + char * gateway; + char * dhcp_hostname; + char * dhcp_iaid; + gint64 route_metric; + guint dhcp_hostname_flags; + int dns_priority; + int dad_timeout; + int dhcp_timeout; + int required_timeout; + guint32 route_table; + bool ignore_auto_routes; + bool ignore_auto_dns; + bool dhcp_send_hostname; + bool never_default; + bool may_fail; +} NMSettingIPConfigPrivate; + +void _nm_setting_ip_config_private_init(gpointer self, NMSettingIPConfigPrivate *priv); + /*****************************************************************************/ NMSettingPriority _nm_setting_get_base_type_priority(NMSetting *setting); int _nm_setting_compare_priority(gconstpointer a, gconstpointer b); -int _nmtst_nm_setting_sort(NMSetting *a, NMSetting *b); +int _nm_setting_sort_for_nm_assert(NMSetting *a, NMSetting *b); /*****************************************************************************/ @@ -246,6 +265,7 @@ gboolean _nm_setting_clear_secrets(NMSetting * setting, */ #define NM_SETTING_PARAM_TO_DBUS_IGNORE_FLAGS (1 << (7 + G_PARAM_USER_SHIFT)) +extern const NMSettInfoPropertType nm_sett_info_propert_type_setting_name; extern const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_interface_name; extern const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_i; extern const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_u; @@ -253,8 +273,15 @@ extern const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_u extern const NMSettInfoPropertType nm_sett_info_propert_type_plain_i; extern const NMSettInfoPropertType nm_sett_info_propert_type_plain_u; -extern const NMSettInfoPropertType nm_sett_info_propert_type_boolean; -extern const NMSettInfoPropertType nm_sett_info_propert_type_string; +extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_boolean; +extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_int32; +extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_uint32; +extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_uint64; +extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_string; +extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_bytes; +extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_enum; +extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_flags; +extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_mac_address; NMSettingVerifyResult _nm_setting_verify(NMSetting *setting, NMConnection *connection, GError **error); @@ -268,28 +295,47 @@ gboolean _nm_setting_aggregate(NMSetting *setting, NMConnectionAggregateType typ gboolean _nm_setting_slave_type_is_valid(const char *slave_type, const char **out_port_type); -GVariant *_nm_setting_property_to_dbus_fcn_gprop(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options); +gboolean _nm_setting_compare_flags_check(const GParamSpec * param_spec, + NMSettingCompareFlags flags, + NMSetting * set_a, + NMSetting * set_b); -GVariant * -_nm_setting_property_to_dbus_fcn_get_boolean(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options); +NMTernary _nm_setting_property_compare_fcn_ignore(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil); + +NMTernary _nm_setting_property_compare_fcn_direct(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil); + +NMTernary _nm_setting_property_compare_fcn_default(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil); + +void _nm_setting_property_get_property_direct(GObject * object, + guint prop_id, + GValue * value, + GParamSpec *pspec); + +void _nm_setting_property_set_property_direct(GObject * object, + guint prop_id, + const GValue *value, + GParamSpec * pspec); + +GVariant *_nm_setting_property_to_dbus_fcn_ignore(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil); + +GVariant *_nm_setting_property_to_dbus_fcn_gprop(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil); + +GVariant *_nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil); GVariant * -_nm_setting_property_to_dbus_fcn_get_string(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options); +_nm_setting_property_to_dbus_fcn_direct_mac_address(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil); + +gboolean _nm_setting_property_from_dbus_fcn_ignore(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil); + +gboolean _nm_setting_property_from_dbus_fcn_direct_ip_config_gateway( + _NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil); + +gboolean _nm_setting_property_from_dbus_fcn_direct_mac_address( + _NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil); + +gboolean _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil); + +gboolean _nm_setting_property_from_dbus_fcn_gprop(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil); GVariant *_nm_setting_to_dbus(NMSetting * setting, NMConnection * connection, @@ -308,25 +354,33 @@ gboolean _nm_setting_property_is_regular_secret_flags(NMSetting * setting, /*****************************************************************************/ +const NMSettInfoProperty * +_nm_sett_info_property_lookup_by_param_spec(const NMSettInfoSetting *sett_info, + const GParamSpec * param_spec); + static inline GArray * -_nm_sett_info_property_override_create_array(void) +_nm_sett_info_property_override_create_array_sized(guint reserved_size) { - return g_array_new(FALSE, FALSE, sizeof(NMSettInfoProperty)); + return g_array_sized_new(FALSE, FALSE, sizeof(NMSettInfoProperty), reserved_size); } -GArray *_nm_sett_info_property_override_create_array_ip_config(void); - -void _nm_setting_class_commit_full(NMSettingClass * setting_class, - NMMetaSettingType meta_type, - const NMSettInfoSettDetail *detail, - GArray * properties_override); - -static inline void -_nm_setting_class_commit(NMSettingClass *setting_class, NMMetaSettingType meta_type) +static inline GArray * +_nm_sett_info_property_override_create_array(void) { - _nm_setting_class_commit_full(setting_class, meta_type, NULL, NULL); + /* pre-allocate a relatively large buffer to avoid frequent re-allocations. + * Note that the buffer is only short-lived and will be destroyed by + * _nm_setting_class_commit(). */ + return _nm_sett_info_property_override_create_array_sized(20); } +GArray *_nm_sett_info_property_override_create_array_ip_config(int addr_family); + +void _nm_setting_class_commit(NMSettingClass * setting_class, + NMMetaSettingType meta_type, + const NMSettInfoSettDetail *detail, + GArray * properties_override, + gint16 private_offset); + #define NM_SETT_INFO_SETT_GENDATA(...) \ ({ \ static const NMSettInfoSettGendata _g = {__VA_ARGS__}; \ @@ -341,11 +395,10 @@ _nm_setting_class_commit(NMSettingClass *setting_class, NMMetaSettingType meta_t .dbus_type = _dbus_type, __VA_ARGS__ \ } -#define NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(_dbus_type, ...) \ - { \ - .dbus_type = _dbus_type, .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_gprop, \ - __VA_ARGS__ \ - } +#define NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(_dbus_type, ...) \ + NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(_dbus_type, \ + .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_gprop, \ + __VA_ARGS__) #define NM_SETT_INFO_PROPERT_TYPE(init) \ ({ \ @@ -372,11 +425,14 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p g_array_append_vals(properties_override, prop_info, 1); } -#define _nm_properties_override_gobj(properties_override, p_param_spec, p_property_type, ...) \ - _nm_properties_override((properties_override), \ - NM_SETT_INFO_PROPERTY(.name = NULL, \ - .param_spec = (p_param_spec), \ - .property_type = (p_property_type), \ +#define _nm_properties_override_gobj(properties_override, \ + p_param_spec, \ + p_property_type, \ + ... /* extra NMSettInfoProperty fields */) \ + _nm_properties_override((properties_override), \ + NM_SETT_INFO_PROPERTY(.name = NULL, \ + .param_spec = (p_param_spec), \ + .property_type = (p_property_type), \ __VA_ARGS__)) #define _nm_properties_override_dbus(properties_override, p_name, p_property_type) \ @@ -386,123 +442,452 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p /*****************************************************************************/ -#define _nm_setting_property_define_boolean_full(properties_override, \ +/* Define "direct" properties. These are properties that have a GParamSpec and + * NMSettInfoPropertType.direct_type != NM_VALUE_TYPE_NONE. + * + * With this, the location of the data is known at + * + * _nm_setting_get_private(setting, sett_info, property_info->direct_offset) + * + * which allows to generically handle the property operations (like get, set, compare). + */ + +#define _nm_setting_property_define_direct_boolean(properties_override, \ + obj_properties, \ + prop_name, \ + prop_id, \ + default_value, \ + param_flags, \ + private_struct_type, \ + private_struct_field, \ + ... /* extra NMSettInfoProperty fields */) \ + G_STMT_START \ + { \ + const gboolean _default_value = (default_value); \ + GParamSpec * _param_spec; \ + \ + G_STATIC_ASSERT( \ + !NM_FLAGS_ANY((param_flags), \ + ~(NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_INFERRABLE \ + | NM_SETTING_PARAM_REAPPLY_IMMEDIATELY))); \ + \ + nm_assert(NM_IN_SET(_default_value, 0, 1)); \ + \ + _param_spec = \ + g_param_spec_boolean("" prop_name "", \ + "", \ + "", \ + _default_value, \ + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + \ + (obj_properties)[(prop_id)] = _param_spec; \ + \ + _nm_properties_override_gobj( \ + (properties_override), \ + _param_spec, \ + &nm_sett_info_propert_type_direct_boolean, \ + .direct_offset = \ + NM_STRUCT_OFFSET_ENSURE_TYPE(bool, private_struct_type, private_struct_field), \ + __VA_ARGS__); \ + } \ + G_STMT_END + +/*****************************************************************************/ + +#define _nm_setting_property_define_direct_uint32(properties_override, \ + obj_properties, \ + prop_name, \ + prop_id, \ + min_value, \ + max_value, \ + default_value, \ + param_flags, \ + private_struct_type, \ + private_struct_field, \ + ... /* extra NMSettInfoProperty fields */) \ + G_STMT_START \ + { \ + GParamSpec *_param_spec; \ + \ + G_STATIC_ASSERT( \ + !NM_FLAGS_ANY((param_flags), \ + ~(NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_INFERRABLE))); \ + G_STATIC_ASSERT((min_value) <= (guint64) (default_value)); \ + G_STATIC_ASSERT((default_value) <= (guint64) (max_value)); \ + G_STATIC_ASSERT((max_value) <= (guint64) G_MAXUINT32); \ + \ + _param_spec = \ + g_param_spec_uint("" prop_name "", \ + "", \ + "", \ + (min_value), \ + (max_value), \ + (default_value), \ + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + \ + (obj_properties)[(prop_id)] = _param_spec; \ + \ + _nm_properties_override_gobj( \ + (properties_override), \ + _param_spec, \ + &nm_sett_info_propert_type_direct_uint32, \ + .direct_offset = \ + NM_STRUCT_OFFSET_ENSURE_TYPE(guint32, private_struct_type, private_struct_field), \ + __VA_ARGS__); \ + } \ + G_STMT_END + +/*****************************************************************************/ + +#define _nm_setting_property_define_direct_int32(properties_override, \ + obj_properties, \ + prop_name, \ + prop_id, \ + min_value, \ + max_value, \ + default_value, \ + param_flags, \ + private_struct_type, \ + private_struct_field, \ + ... /* extra NMSettInfoProperty fields */) \ + G_STMT_START \ + { \ + GParamSpec *_param_spec; \ + \ + G_STATIC_ASSERT( \ + !NM_FLAGS_ANY((param_flags), \ + ~(NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_INFERRABLE))); \ + G_STATIC_ASSERT((min_value) >= (gint64) (G_MININT32)); \ + G_STATIC_ASSERT((min_value) <= (gint64) (default_value)); \ + G_STATIC_ASSERT((default_value) <= (gint64) (max_value)); \ + G_STATIC_ASSERT((max_value) <= (gint64) G_MAXUINT32); \ + \ + _param_spec = \ + g_param_spec_int("" prop_name "", \ + "", \ + "", \ + (min_value), \ + (max_value), \ + (default_value), \ + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + \ + (obj_properties)[(prop_id)] = _param_spec; \ + \ + _nm_properties_override_gobj( \ + (properties_override), \ + _param_spec, \ + &nm_sett_info_propert_type_direct_int32, \ + .direct_offset = \ + NM_STRUCT_OFFSET_ENSURE_TYPE(gint32, private_struct_type, private_struct_field), \ + __VA_ARGS__); \ + } \ + G_STMT_END + +/*****************************************************************************/ + +#define _nm_setting_property_define_direct_uint64(properties_override, \ + obj_properties, \ + prop_name, \ + prop_id, \ + min_value, \ + max_value, \ + default_value, \ + param_flags, \ + private_struct_type, \ + private_struct_field, \ + ... /* extra NMSettInfoProperty fields */) \ + G_STMT_START \ + { \ + GParamSpec *_param_spec; \ + \ + G_STATIC_ASSERT( \ + !NM_FLAGS_ANY((param_flags), \ + ~(NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_INFERRABLE))); \ + G_STATIC_ASSERT((min_value) <= (default_value)); \ + G_STATIC_ASSERT((default_value) == 0 || (default_value) -1u < (max_value)); \ + G_STATIC_ASSERT((max_value) <= G_MAXUINT64); \ + \ + _param_spec = \ + g_param_spec_uint64("" prop_name "", \ + "", \ + "", \ + (min_value), \ + (max_value), \ + (default_value), \ + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + \ + (obj_properties)[(prop_id)] = _param_spec; \ + \ + _nm_properties_override_gobj( \ + (properties_override), \ + _param_spec, \ + &nm_sett_info_propert_type_direct_uint64, \ + .direct_offset = \ + NM_STRUCT_OFFSET_ENSURE_TYPE(guint64, private_struct_type, private_struct_field), \ + __VA_ARGS__); \ + } \ + G_STMT_END + +/*****************************************************************************/ + +#define _nm_setting_property_define_direct_string_full(properties_override, \ + obj_properties, \ + prop_name, \ + prop_id, \ + param_flags, \ + property_type, \ + private_struct_type, \ + private_struct_field, \ + ... /* extra NMSettInfoProperty fields */) \ + G_STMT_START \ + { \ + GParamSpec * _param_spec; \ + const NMSettInfoPropertType *_property_type = (property_type); \ + \ + G_STATIC_ASSERT(!NM_FLAGS_ANY((param_flags), \ + ~(NM_SETTING_PARAM_SECRET | NM_SETTING_PARAM_FUZZY_IGNORE \ + | NM_SETTING_PARAM_INFERRABLE \ + | NM_SETTING_PARAM_REAPPLY_IMMEDIATELY))); \ + \ + nm_assert(_property_type); \ + nm_assert(g_variant_type_equal(_property_type->dbus_type, "s")); \ + nm_assert(_property_type->direct_type == NM_VALUE_TYPE_STRING); \ + nm_assert(_property_type->to_dbus_fcn == _nm_setting_property_to_dbus_fcn_direct); \ + \ + _param_spec = \ + g_param_spec_string("" prop_name "", \ + "", \ + "", \ + NULL, \ + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + \ + (obj_properties)[(prop_id)] = _param_spec; \ + \ + _nm_properties_override_gobj( \ + (properties_override), \ + _param_spec, \ + _property_type, \ + .direct_offset = \ + NM_STRUCT_OFFSET_ENSURE_TYPE(char *, private_struct_type, private_struct_field), \ + __VA_ARGS__); \ + } \ + G_STMT_END + +#define _nm_setting_property_define_direct_string(properties_override, \ + obj_properties, \ + prop_name, \ + prop_id, \ + param_flags, \ + private_struct_type, \ + private_struct_field, \ + ... /* extra NMSettInfoProperty fields */) \ + _nm_setting_property_define_direct_string_full((properties_override), \ + (obj_properties), \ + prop_name, \ + (prop_id), \ + (param_flags), \ + &nm_sett_info_propert_type_direct_string, \ + private_struct_type, \ + private_struct_field, \ + __VA_ARGS__) + +/*****************************************************************************/ + +#define _nm_setting_property_define_direct_bytes(properties_override, \ + obj_properties, \ + prop_name, \ + prop_id, \ + param_flags, \ + private_struct_type, \ + private_struct_field, \ + ... /* extra NMSettInfoProperty fields */) \ + G_STMT_START \ + { \ + GParamSpec *_param_spec; \ + \ + G_STATIC_ASSERT(!NM_FLAGS_ANY((param_flags), \ + ~(NM_SETTING_PARAM_SECRET | NM_SETTING_PARAM_INFERRABLE \ + | NM_SETTING_PARAM_FUZZY_IGNORE))); \ + \ + _param_spec = \ + g_param_spec_boxed("" prop_name "", \ + "", \ + "", \ + G_TYPE_BYTES, \ + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + \ + (obj_properties)[(prop_id)] = _param_spec; \ + \ + _nm_properties_override_gobj( \ + (properties_override), \ + _param_spec, \ + &nm_sett_info_propert_type_direct_bytes, \ + .direct_offset = \ + NM_STRUCT_OFFSET_ENSURE_TYPE(GBytes *, private_struct_type, private_struct_field), \ + __VA_ARGS__); \ + } \ + G_STMT_END + +/*****************************************************************************/ + +#define _nm_setting_property_define_direct_enum(properties_override, \ + obj_properties, \ + prop_name, \ + prop_id, \ + gtype_enum, \ + default_value, \ + param_flags, \ + private_struct_type, \ + private_struct_field, \ + ... /* extra NMSettInfoProperty fields */) \ + G_STMT_START \ + { \ + GParamSpec *_param_spec; \ + \ + G_STATIC_ASSERT( \ + !NM_FLAGS_ANY((param_flags), \ + ~(NM_SETTING_PARAM_REAPPLY_IMMEDIATELY | NM_SETTING_PARAM_FUZZY_IGNORE \ + | NM_SETTING_PARAM_INFERRABLE))); \ + \ + _param_spec = \ + g_param_spec_enum("" prop_name "", \ + "", \ + "", \ + (gtype_enum), \ + (default_value), \ + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + \ + (obj_properties)[(prop_id)] = _param_spec; \ + \ + _nm_properties_override_gobj( \ + (properties_override), \ + _param_spec, \ + &nm_sett_info_propert_type_direct_enum, \ + .direct_offset = \ + NM_STRUCT_OFFSET_ENSURE_TYPE(int, private_struct_type, private_struct_field), \ + __VA_ARGS__); \ + } \ + G_STMT_END + +/*****************************************************************************/ + +#define _nm_setting_property_define_direct_ternary_enum(properties_override, \ + obj_properties, \ + prop_name, \ + prop_id, \ + param_flags, \ + private_struct_type, \ + private_struct_field, \ + ...) \ + _nm_setting_property_define_direct_enum((properties_override), \ + (obj_properties), \ + prop_name, \ + (prop_id), \ + NM_TYPE_TERNARY, \ + NM_TERNARY_DEFAULT, \ + (param_flags), \ + private_struct_type, \ + private_struct_field, \ + __VA_ARGS__) + +/*****************************************************************************/ + +#define _nm_setting_property_define_direct_flags(properties_override, \ obj_properties, \ prop_name, \ prop_id, \ + gtype_flags, \ default_value, \ param_flags, \ - property_type, \ - get_fcn, \ - ...) \ + private_struct_type, \ + private_struct_field, \ + ... /* extra NMSettInfoProperty fields */) \ G_STMT_START \ { \ - const gboolean _default_value = (default_value); \ - GParamSpec * _param_spec; \ - const NMSettInfoPropertType *const _property_type = (property_type); \ + GParamSpec *_param_spec; \ \ G_STATIC_ASSERT( \ !NM_FLAGS_ANY((param_flags), \ - ~(NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_INFERRABLE \ - | NM_SETTING_PARAM_REAPPLY_IMMEDIATELY))); \ - \ - nm_assert(_property_type); \ - nm_assert(_property_type->to_dbus_fcn == _nm_setting_property_to_dbus_fcn_get_boolean); \ - \ - nm_assert(NM_IN_SET(_default_value, 0, 1)); \ + ~(NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_INFERRABLE))); \ \ _param_spec = \ - g_param_spec_boolean("" prop_name "", \ - "", \ - "", \ - _default_value, \ - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + g_param_spec_flags("" prop_name "", \ + "", \ + "", \ + (gtype_flags), \ + (default_value), \ + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ \ (obj_properties)[(prop_id)] = _param_spec; \ \ - _nm_properties_override_gobj((properties_override), \ - _param_spec, \ - _property_type, \ - .to_dbus_data.get_boolean = \ - (gboolean(*)(NMSetting *)) (get_fcn), \ - __VA_ARGS__); \ + _nm_properties_override_gobj( \ + (properties_override), \ + _param_spec, \ + &nm_sett_info_propert_type_direct_flags, \ + .direct_offset = \ + NM_STRUCT_OFFSET_ENSURE_TYPE(guint, private_struct_type, private_struct_field), \ + __VA_ARGS__); \ } \ G_STMT_END -#define _nm_setting_property_define_boolean(properties_override, \ - obj_properties, \ - prop_name, \ - prop_id, \ - default_value, \ - param_flags, \ - get_fcn, \ - ...) \ - _nm_setting_property_define_boolean_full((properties_override), \ - (obj_properties), \ - prop_name, \ - (prop_id), \ - (default_value), \ - (param_flags), \ - &nm_sett_info_propert_type_boolean, \ - (get_fcn), \ - __VA_ARGS__) +/*****************************************************************************/ + +#define _nm_setting_property_define_direct_secret_flags(properties_override, \ + obj_properties, \ + prop_name, \ + prop_id, \ + private_struct_type, \ + private_struct_field, \ + ... /* extra NMSettInfoProperty fields */) \ + _nm_setting_property_define_direct_flags((properties_override), \ + (obj_properties), \ + prop_name, \ + (prop_id), \ + NM_TYPE_SETTING_SECRET_FLAGS, \ + NM_SETTING_SECRET_FLAG_NONE, \ + NM_SETTING_PARAM_NONE, \ + private_struct_type, \ + private_struct_field, \ + ##__VA_ARGS__) /*****************************************************************************/ -#define _nm_setting_property_define_string_full(properties_override, \ - obj_properties, \ - prop_name, \ - prop_id, \ - param_flags, \ - property_type, \ - get_fcn, \ - ...) \ - G_STMT_START \ - { \ - GParamSpec * _param_spec; \ - const NMSettInfoPropertType *const _property_type = (property_type); \ - \ - G_STATIC_ASSERT(!NM_FLAGS_ANY((param_flags), \ - ~(NM_SETTING_PARAM_SECRET | NM_SETTING_PARAM_FUZZY_IGNORE \ - | NM_SETTING_PARAM_INFERRABLE \ - | NM_SETTING_PARAM_REAPPLY_IMMEDIATELY))); \ - nm_assert(_property_type); \ - nm_assert(_property_type->to_dbus_fcn == _nm_setting_property_to_dbus_fcn_get_string); \ - \ - _param_spec = \ - g_param_spec_string("" prop_name "", \ - "", \ - "", \ - NULL, \ - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ - \ - (obj_properties)[(prop_id)] = _param_spec; \ - \ - _nm_properties_override_gobj((properties_override), \ - _param_spec, \ - _property_type, \ - .to_dbus_data.get_string = \ - (const char *(*) (NMSetting *) ) (get_fcn), \ - __VA_ARGS__); \ - } \ +#define _nm_setting_property_define_direct_mac_address(properties_override, \ + obj_properties, \ + prop_name, \ + prop_id, \ + param_flags, \ + private_struct_type, \ + private_struct_field, \ + ... /* extra NMSettInfoProperty fields */) \ + G_STMT_START \ + { \ + GParamSpec *_param_spec; \ + \ + G_STATIC_ASSERT(!NM_FLAGS_ANY((param_flags), \ + ~(NM_SETTING_PARAM_SECRET | NM_SETTING_PARAM_FUZZY_IGNORE \ + | NM_SETTING_PARAM_INFERRABLE \ + | NM_SETTING_PARAM_REAPPLY_IMMEDIATELY))); \ + \ + _param_spec = \ + g_param_spec_string("" prop_name "", \ + "", \ + "", \ + NULL, \ + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \ + \ + (obj_properties)[(prop_id)] = _param_spec; \ + \ + _nm_properties_override_gobj( \ + (properties_override), \ + _param_spec, \ + &nm_sett_info_propert_type_direct_mac_address, \ + .direct_offset = \ + NM_STRUCT_OFFSET_ENSURE_TYPE(char *, private_struct_type, private_struct_field), \ + __VA_ARGS__); \ + } \ G_STMT_END -#define _nm_setting_property_define_string(properties_override, \ - obj_properties, \ - prop_name, \ - prop_id, \ - param_flags, \ - get_fcn, \ - ...) \ - _nm_setting_property_define_string_full((properties_override), \ - (obj_properties), \ - prop_name, \ - (prop_id), \ - (param_flags), \ - &nm_sett_info_propert_type_string, \ - (get_fcn), \ - __VA_ARGS__) - /*****************************************************************************/ gboolean _nm_setting_use_legacy_property(NMSetting * setting, @@ -520,6 +905,20 @@ gboolean _nm_setting_should_compare_secret_property(NMSetting * settin NMBridgeVlan *_nm_bridge_vlan_dup(const NMBridgeVlan *vlan); NMBridgeVlan *_nm_bridge_vlan_dup_and_seal(const NMBridgeVlan *vlan); +gboolean _nm_utils_bridge_vlans_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil); + +GVariant *_nm_utils_bridge_vlans_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil); + +NMTernary _nm_setting_ip_config_compare_fcn_addresses(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil); + +NMTernary _nm_setting_ip_config_compare_fcn_routes(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil); + +gboolean _nm_utils_hwaddr_cloned_not_set(_NM_SETT_INFO_PROP_MISSING_FROM_DBUS_FCN_ARGS _nm_nil); + +GVariant *_nm_utils_hwaddr_cloned_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil); + +gboolean _nm_utils_hwaddr_cloned_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil); + /*****************************************************************************/ #endif /* NM_SETTING_PRIVATE_H */ diff --git a/src/libnm-core-impl/nm-setting-proxy.c b/src/libnm-core-impl/nm-setting-proxy.c index fd09e1d4..0425ec45 100644 --- a/src/libnm-core-impl/nm-setting-proxy.c +++ b/src/libnm-core-impl/nm-setting-proxy.c @@ -29,10 +29,10 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_METHOD, PROP_BROWSER_ONLY, PROP_PAC_URL, PROP_PAC_SCRIPT, ); typedef struct { - char *pac_url; - char *pac_script; - int method; - bool browser_only : 1; + char * pac_url; + char * pac_script; + gint32 method; + bool browser_only; } NMSettingProxyPrivate; /** @@ -207,63 +207,9 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingProxy *setting = NM_SETTING_PROXY(object); - - switch (prop_id) { - case PROP_METHOD: - g_value_set_int(value, nm_setting_proxy_get_method(setting)); - break; - case PROP_BROWSER_ONLY: - g_value_set_boolean(value, nm_setting_proxy_get_browser_only(setting)); - break; - case PROP_PAC_URL: - g_value_set_string(value, nm_setting_proxy_get_pac_url(setting)); - break; - case PROP_PAC_SCRIPT: - g_value_set_string(value, nm_setting_proxy_get_pac_script(setting)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingProxyPrivate *priv = NM_SETTING_PROXY_GET_PRIVATE(object); - - switch (prop_id) { - case PROP_METHOD: - priv->method = g_value_get_int(value); - break; - case PROP_BROWSER_ONLY: - priv->browser_only = g_value_get_boolean(value); - break; - case PROP_PAC_URL: - g_free(priv->pac_url); - priv->pac_url = g_value_dup_string(value); - break; - case PROP_PAC_SCRIPT: - g_free(priv->pac_script); - priv->pac_script = g_value_dup_string(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - static void nm_setting_proxy_init(NMSettingProxy *self) -{ - nm_assert(NM_SETTING_PROXY_GET_PRIVATE(self)->method == NM_SETTING_PROXY_METHOD_NONE); -} +{} /** * nm_setting_proxy_new: @@ -280,18 +226,6 @@ nm_setting_proxy_new(void) return g_object_new(NM_TYPE_SETTING_PROXY, NULL); } -static void -finalize(GObject *object) -{ - NMSettingProxy * self = NM_SETTING_PROXY(object); - NMSettingProxyPrivate *priv = NM_SETTING_PROXY_GET_PRIVATE(self); - - g_free(priv->pac_url); - g_free(priv->pac_script); - - G_OBJECT_CLASS(nm_setting_proxy_parent_class)->finalize(object); -} - static void nm_setting_proxy_class_init(NMSettingProxyClass *klass) { @@ -301,9 +235,8 @@ nm_setting_proxy_class_init(NMSettingProxyClass *klass) g_type_class_add_private(klass, sizeof(NMSettingProxyPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -323,13 +256,16 @@ nm_setting_proxy_class_init(NMSettingProxyClass *klass) * values: none, auto * ---end--- */ - obj_properties[PROP_METHOD] = g_param_spec_int(NM_SETTING_PROXY_METHOD, - "", - "", - G_MININT32, - G_MAXINT32, - NM_SETTING_PROXY_METHOD_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_PROXY_METHOD, + PROP_METHOD, + G_MININT32, + G_MAXINT32, + NM_SETTING_PROXY_METHOD_NONE, + NM_SETTING_PARAM_NONE, + NMSettingProxyPrivate, + method); /** * NMSettingProxy:browser-only: @@ -345,13 +281,14 @@ nm_setting_proxy_class_init(NMSettingProxyClass *klass) * description: Whether the proxy configuration is for browser only. * ---end--- */ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_PROXY_BROWSER_ONLY, - PROP_BROWSER_ONLY, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_proxy_get_browser_only); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_PROXY_BROWSER_ONLY, + PROP_BROWSER_ONLY, + FALSE, + NM_SETTING_PARAM_NONE, + NMSettingProxyPrivate, + browser_only); /** * NMSettingProxy:pac-url: @@ -367,11 +304,13 @@ nm_setting_proxy_class_init(NMSettingProxyClass *klass) * example: PAC_URL=http://wpad.mycompany.com/wpad.dat * ---end--- */ - obj_properties[PROP_PAC_URL] = g_param_spec_string(NM_SETTING_PROXY_PAC_URL, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_PROXY_PAC_URL, + PROP_PAC_URL, + NM_SETTING_PARAM_NONE, + NMSettingProxyPrivate, + pac_url); /** * NMSettingProxy:pac-script: @@ -387,17 +326,19 @@ nm_setting_proxy_class_init(NMSettingProxyClass *klass) * example: PAC_SCRIPT=/home/joe/proxy.pac * ---end--- */ - obj_properties[PROP_PAC_SCRIPT] = - g_param_spec_string(NM_SETTING_PROXY_PAC_SCRIPT, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_PROXY_PAC_SCRIPT, + PROP_PAC_SCRIPT, + NM_SETTING_PARAM_NONE, + NMSettingProxyPrivate, + pac_script); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_PROXY, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_PROXY, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-serial.c b/src/libnm-core-impl/nm-setting-serial.c index c87de166..3ebcf062 100644 --- a/src/libnm-core-impl/nm-setting-serial.c +++ b/src/libnm-core-impl/nm-setting-serial.c @@ -30,9 +30,9 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_BAUD, typedef struct { guint64 send_delay; - guint baud; - guint bits; - guint stopbits; + guint32 baud; + guint32 bits; + guint32 stopbits; char parity; } NMSettingSerialPrivate; @@ -129,22 +129,26 @@ nm_setting_serial_get_send_delay(NMSettingSerial *setting) return NM_SETTING_SERIAL_GET_PRIVATE(setting)->send_delay; } +/*****************************************************************************/ + static GVariant * -parity_to_dbus(const GValue *from) +parity_to_dbus_fcn(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { - switch (g_value_get_enum(from)) { + switch (nm_setting_serial_get_parity(NM_SETTING_SERIAL(setting))) { case NM_SETTING_SERIAL_PARITY_EVEN: return g_variant_new_byte('E'); case NM_SETTING_SERIAL_PARITY_ODD: return g_variant_new_byte('o'); case NM_SETTING_SERIAL_PARITY_NONE: + /* the default, serializes to NULL. */ + return NULL; default: - return g_variant_new_byte('n'); + return NULL; } } static void -parity_from_dbus(GVariant *from, GValue *to) +parity_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_GPROP_FCN_ARGS _nm_nil) { switch (g_variant_get_byte(from)) { case 'E': @@ -168,23 +172,11 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) NMSettingSerial *setting = NM_SETTING_SERIAL(object); switch (prop_id) { - case PROP_BAUD: - g_value_set_uint(value, nm_setting_serial_get_baud(setting)); - break; - case PROP_BITS: - g_value_set_uint(value, nm_setting_serial_get_bits(setting)); - break; case PROP_PARITY: g_value_set_enum(value, nm_setting_serial_get_parity(setting)); break; - case PROP_STOPBITS: - g_value_set_uint(value, nm_setting_serial_get_stopbits(setting)); - break; - case PROP_SEND_DELAY: - g_value_set_uint64(value, nm_setting_serial_get_send_delay(setting)); - break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_get_property_direct(object, prop_id, value, pspec); break; } } @@ -195,23 +187,11 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps NMSettingSerialPrivate *priv = NM_SETTING_SERIAL_GET_PRIVATE(object); switch (prop_id) { - case PROP_BAUD: - priv->baud = g_value_get_uint(value); - break; - case PROP_BITS: - priv->bits = g_value_get_uint(value); - break; case PROP_PARITY: priv->parity = g_value_get_enum(value); break; - case PROP_STOPBITS: - priv->stopbits = g_value_get_uint(value); - break; - case PROP_SEND_DELAY: - priv->send_delay = g_value_get_uint64(value); - break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_set_property_direct(object, prop_id, value, pspec); break; } } @@ -224,9 +204,6 @@ nm_setting_serial_init(NMSettingSerial *self) NMSettingSerialPrivate *priv = NM_SETTING_SERIAL_GET_PRIVATE(self); nm_assert(priv->parity == NM_SETTING_SERIAL_PARITY_NONE); - priv->stopbits = 1; - priv->baud = 57600; - priv->bits = 8; } /** @@ -261,26 +238,32 @@ nm_setting_serial_class_init(NMSettingSerialClass *klass) * value usually has no effect for mobile broadband modems as they generally * ignore speed settings and use the highest available speed. **/ - obj_properties[PROP_BAUD] = g_param_spec_uint(NM_SETTING_SERIAL_BAUD, - "", - "", - 0, - G_MAXUINT, - 57600, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_SERIAL_BAUD, + PROP_BAUD, + 0, + G_MAXUINT32, + 57600, + NM_SETTING_PARAM_NONE, + NMSettingSerialPrivate, + baud); /** * NMSettingSerial:bits: * * Byte-width of the serial communication. The 8 in "8n1" for example. **/ - obj_properties[PROP_BITS] = g_param_spec_uint(NM_SETTING_SERIAL_BITS, - "", - "", - 5, - 8, - 8, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_SERIAL_BITS, + PROP_BITS, + 5, + 8, + 8, + NM_SETTING_PARAM_NONE, + NMSettingSerialPrivate, + bits); /** * NMSettingSerial:parity: @@ -311,9 +294,12 @@ nm_setting_serial_class_init(NMSettingSerialClass *klass) _nm_properties_override_gobj( properties_override, obj_properties[PROP_PARITY], - NM_SETT_INFO_PROPERT_TYPE_GPROP(G_VARIANT_TYPE_BYTE, - .gprop_from_dbus_fcn = parity_from_dbus, ), - .to_dbus_data.gprop_to_dbus_fcn = parity_to_dbus, ); + NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_BYTE, + .compare_fcn = _nm_setting_property_compare_fcn_default, + .to_dbus_fcn = parity_to_dbus_fcn, + .typdata_from_dbus.gprop_fcn = parity_from_dbus, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE)); /** * NMSettingSerial:stopbits: @@ -321,32 +307,38 @@ nm_setting_serial_class_init(NMSettingSerialClass *klass) * Number of stop bits for communication on the serial port. Either 1 or 2. * The 1 in "8n1" for example. **/ - obj_properties[PROP_STOPBITS] = g_param_spec_uint(NM_SETTING_SERIAL_STOPBITS, - "", - "", - 1, - 2, - 1, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_SERIAL_STOPBITS, + PROP_STOPBITS, + 1, + 2, + 1, + NM_SETTING_PARAM_NONE, + NMSettingSerialPrivate, + stopbits); /** * NMSettingSerial:send-delay: * * Time to delay between each byte sent to the modem, in microseconds. **/ - obj_properties[PROP_SEND_DELAY] = - g_param_spec_uint64(NM_SETTING_SERIAL_SEND_DELAY, - "", - "", - 0, - G_MAXUINT64, - 0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint64(properties_override, + obj_properties, + NM_SETTING_SERIAL_SEND_DELAY, + PROP_SEND_DELAY, + 0, + G_MAXUINT64, + 0, + NM_SETTING_PARAM_NONE, + NMSettingSerialPrivate, + send_delay); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_SERIAL, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_SERIAL, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-sriov.c b/src/libnm-core-impl/nm-setting-sriov.c index b18d184a..a024dba6 100644 --- a/src/libnm-core-impl/nm-setting-sriov.c +++ b/src/libnm-core-impl/nm-setting-sriov.c @@ -322,7 +322,7 @@ nm_sriov_vf_get_attribute_names(const NMSriovVF *vf) g_return_val_if_fail(vf, NULL); g_return_val_if_fail(vf->refcount > 0, NULL); - return nm_utils_strdict_get_keys(vf->attributes, TRUE, NULL); + return nm_strdict_get_keys(vf->attributes, TRUE, NULL); } /** @@ -471,7 +471,7 @@ _nm_sriov_vf_attribute_validate_all(const NMSriovVF *vf, GError **error) * @vf: the #NMSriovVF * @vlan_id: the VLAN id * - * Adds a VLAN to the VF. + * Adds a VLAN to the VF. Currently kernel only supports one VLAN per VF. * * Returns: %TRUE if the VLAN was added; %FALSE if it already existed * @@ -535,7 +535,8 @@ vlan_id_compare(gconstpointer a, gconstpointer b, gpointer user_data) * @vf: the #NMSriovVF * @length: (out) (allow-none): on return, the number of VLANs configured * - * Returns the VLANs currently configured on the VF. + * Returns the VLANs currently configured on the VF. Currently kernel only + * supports one VLAN per VF. * * Returns: (transfer none) (array length=length): a list of VLAN ids configured on the VF. * @@ -875,12 +876,7 @@ _nm_setting_sriov_sort_vfs(NMSettingSriov *setting) /*****************************************************************************/ static GVariant * -vfs_to_dbus(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +vfs_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *vfs = NULL; GVariantBuilder builder; @@ -904,7 +900,7 @@ vfs_to_dbus(const NMSettInfoSetting * sett_info, "index", g_variant_new_uint32(nm_sriov_vf_get_index(vf))); - attr_names = nm_utils_strdict_get_keys(vf->attributes, TRUE, NULL); + attr_names = nm_strdict_get_keys(vf->attributes, TRUE, NULL); if (attr_names) { for (name = attr_names; *name; name++) { g_variant_builder_add(&vf_builder, @@ -956,12 +952,7 @@ vfs_to_dbus(const NMSettInfoSetting * sett_info, } static gboolean -vfs_from_dbus(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +vfs_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GPtrArray * vfs; GVariantIter vf_iter; @@ -1119,35 +1110,24 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_fcn_vfs(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) { NMSettingSriov *a; NMSettingSriov *b; guint i; - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_SRIOV_VFS)) { - if (set_b) { - a = NM_SETTING_SRIOV(set_a); - b = NM_SETTING_SRIOV(set_b); + if (set_b) { + a = NM_SETTING_SRIOV(set_a); + b = NM_SETTING_SRIOV(set_b); - if (a->vfs->len != b->vfs->len) + if (a->vfs->len != b->vfs->len) + return FALSE; + for (i = 0; i < a->vfs->len; i++) { + if (!nm_sriov_vf_equal(a->vfs->pdata[i], b->vfs->pdata[i])) return FALSE; - for (i = 0; i < a->vfs->len; i++) { - if (!nm_sriov_vf_equal(a->vfs->pdata[i], b->vfs->pdata[i])) - return FALSE; - } } - return TRUE; } - - return NM_SETTING_CLASS(nm_setting_sriov_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + return TRUE; } /*****************************************************************************/ @@ -1246,8 +1226,7 @@ nm_setting_sriov_class_init(NMSettingSriovClass *klass) object_class->set_property = set_property; object_class->finalize = finalize; - setting_class->compare_property = compare_property; - setting_class->verify = verify; + setting_class->verify = verify; /** * NMSettingSriov:total-vfs @@ -1327,6 +1306,7 @@ nm_setting_sriov_class_init(NMSettingSriovClass *klass) obj_properties[PROP_VFS], NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"), .to_dbus_fcn = vfs_to_dbus, + .compare_fcn = compare_fcn_vfs, .from_dbus_fcn = vfs_from_dbus, )); /** @@ -1365,8 +1345,9 @@ nm_setting_sriov_class_init(NMSettingSriovClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_SRIOV, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_SRIOV, + NULL, + properties_override, + 0); } diff --git a/src/libnm-core-impl/nm-setting-tc-config.c b/src/libnm-core-impl/nm-setting-tc-config.c index f44c89cb..cd13709a 100644 --- a/src/libnm-core-impl/nm-setting-tc-config.c +++ b/src/libnm-core-impl/nm-setting-tc-config.c @@ -320,7 +320,7 @@ nm_tc_qdisc_get_attribute_names(NMTCQdisc *qdisc) { g_return_val_if_fail(qdisc, NULL); - return nm_utils_strdict_get_keys(qdisc->attributes, TRUE, NULL); + return nm_strdict_get_keys(qdisc->attributes, TRUE, NULL); } GHashTable * @@ -594,8 +594,8 @@ nm_tc_action_get_attribute_names(NMTCAction *action) g_return_val_if_fail(action, NULL); - names = nm_utils_strdict_get_keys(action->attributes, TRUE, NULL); - return nm_utils_strv_make_deep_copied_nonnull(names); + names = nm_strdict_get_keys(action->attributes, TRUE, NULL); + return nm_strv_make_deep_copied_nonnull(names); } GHashTable * @@ -1314,46 +1314,40 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_fcn_qdiscs(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) { NMSettingTCConfig *a_tc_config = NM_SETTING_TC_CONFIG(set_a); NMSettingTCConfig *b_tc_config = NM_SETTING_TC_CONFIG(set_b); guint i; - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_TC_CONFIG_QDISCS)) { - if (set_b) { - if (a_tc_config->qdiscs->len != b_tc_config->qdiscs->len) + if (set_b) { + if (a_tc_config->qdiscs->len != b_tc_config->qdiscs->len) + return FALSE; + for (i = 0; i < a_tc_config->qdiscs->len; i++) { + if (!nm_tc_qdisc_equal(a_tc_config->qdiscs->pdata[i], b_tc_config->qdiscs->pdata[i])) return FALSE; - for (i = 0; i < a_tc_config->qdiscs->len; i++) { - if (!nm_tc_qdisc_equal(a_tc_config->qdiscs->pdata[i], - b_tc_config->qdiscs->pdata[i])) - return FALSE; - } } - return TRUE; } + return TRUE; +} + +static NMTernary +compare_fcn_tfilter(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) +{ + NMSettingTCConfig *a_tc_config = NM_SETTING_TC_CONFIG(set_a); + NMSettingTCConfig *b_tc_config = NM_SETTING_TC_CONFIG(set_b); + guint i; - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_TC_CONFIG_TFILTERS)) { - if (set_b) { - if (a_tc_config->tfilters->len != b_tc_config->tfilters->len) + if (set_b) { + if (a_tc_config->tfilters->len != b_tc_config->tfilters->len) + return FALSE; + for (i = 0; i < a_tc_config->tfilters->len; i++) { + if (!nm_tc_tfilter_equal(a_tc_config->tfilters->pdata[i], + b_tc_config->tfilters->pdata[i])) return FALSE; - for (i = 0; i < a_tc_config->tfilters->len; i++) { - if (!nm_tc_tfilter_equal(a_tc_config->tfilters->pdata[i], - b_tc_config->tfilters->pdata[i])) - return FALSE; - } } - return TRUE; } - - return NM_SETTING_CLASS(nm_setting_tc_config_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + return TRUE; } /** @@ -1481,12 +1475,7 @@ next: } static GVariant * -tc_qdiscs_get(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +tc_qdiscs_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *qdiscs = NULL; @@ -1495,19 +1484,12 @@ tc_qdiscs_get(const NMSettInfoSetting * sett_info, } static gboolean -tc_qdiscs_set(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +tc_qdiscs_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { - GPtrArray *qdiscs; + gs_unref_ptrarray GPtrArray *qdiscs = NULL; qdiscs = _qdiscs_from_variant(value); g_object_set(setting, NM_SETTING_TC_CONFIG_QDISCS, qdiscs, NULL); - g_ptr_array_unref(qdiscs); - return TRUE; } @@ -1679,12 +1661,7 @@ next: } static GVariant * -tc_tfilters_get(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +tc_tfilters_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *tfilters = NULL; @@ -1693,12 +1670,7 @@ tc_tfilters_get(const NMSettInfoSetting * sett_info, } static gboolean -tc_tfilters_set(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +tc_tfilters_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *tfilters = NULL; @@ -1803,8 +1775,7 @@ nm_setting_tc_config_class_init(NMSettingTCConfigClass *klass) object_class->set_property = set_property; object_class->finalize = finalize; - setting_class->compare_property = compare_property; - setting_class->verify = verify; + setting_class->verify = verify; /** * NMSettingTCConfig:qdiscs: (type GPtrArray(NMTCQdisc)) @@ -1820,6 +1791,282 @@ nm_setting_tc_config_class_init(NMSettingTCConfigClass *klass) * If the #NMSettingTCConfig setting is not present, NetworkManager * doesn't touch the qdiscs present on the interface. **/ + /* ---nmcli--- + * property: qdiscs + * format: GPtrArray(NMTCQdisc) + * description-docbook: + * + * Array of TC queueing disciplines. qdisc is a basic block in the + * Linux traffic control subsystem + * + * + * Each qdisc can be specified by the following attributes: + * + * + * + * handle HANDLE + * + * + * specifies the qdisc handle. A qdisc, which potentially can have children, gets + * assigned a major number, called a 'handle', leaving the minor number namespace + * available for classes. The handle is expressed as '10:'. It is customary to + * explicitly assign a handle to qdiscs expected to have children. + * + * + * + * + * parent HANDLE + * + * + * specifies the handle of the parent qdisc the current qdisc must be + * attached to. + * + * + * + * + * root + * + * + * specifies that the qdisc is attached to the root of device. + * + * + * + * + * KIND + * + * + * this is the qdisc kind. NetworkManager currently supports the + * following kinds: fq_codel, sfq, tbf. Each qdisc kind has a + * different set of parameters, described below. There are also some + * kinds like pfifo, pfifo_fast, prio supported by NetworkManager + * but their parameters are not supported by NetworkManager. + * + * + * + * + * + * Parameters for 'fq_codel': + * + * + * + * limit U32 + * + * + * the hard limit on the real queue size. When this limit is + * reached, incoming packets are dropped. Default is 10240 packets. + * + * + * + * + * memory_limit U32 + * + * + * sets a limit on the total number of bytes that can be queued in + * this FQ-CoDel instance. The lower of the packet limit of the + * limit parameter and the memory limit will be enforced. Default is + * 32 MB. + * + * + * + * + * flows U32 + * + * + * the number of flows into which the incoming packets are + * classified. Due to the stochastic nature of hashing, multiple + * flows may end up being hashed into the same slot. Newer flows + * have priority over older ones. This parameter can be set only at + * load time since memory has to be allocated for the hash table. + * Default value is 1024. + * + * + * + * + * target U32 + * + * + * the acceptable minimum standing/persistent queue delay. This minimum + * delay is identified by tracking the local minimum queue delay that packets + * experience. The unit of measurement is microsecond(us). Default value is 5ms. + * + * + * + * + * interval U32 + * + * + * used to ensure that the measured minimum delay does not become too stale. + * The minimum delay must be experienced in the last epoch of length .B + * interval. It should be set on the order of the worst-case RTT + * through the bottleneck to give endpoints sufficient time to + * react. Default value is 100ms. + * + * + * + * + * quantum U32 + * + * + * the number of bytes used as 'deficit' in the fair queuing + * algorithm. Default is set to 1514 bytes which corresponds to the + * Ethernet MTU plus the hardware header length of 14 bytes. + * + * + * + * + * ecn BOOL + * + * + * can be used to mark packets instead of dropping them. ecn is turned + * on by default. + * + * + * + * + * ce_threshold U32 + * + * + * sets a threshold above which all packets are marked with ECN + * Congestion Experienced. This is useful for DCTCP-style congestion + * control algorithms that require marking at very shallow queueing + * thresholds. + * + * + * + * + * + * Parameters for 'sfq': + * + * + * + * divisor U32 + * + * + * can be used to set a different hash table size, available + * from kernel 2.6.39 onwards. The specified divisor must be + * a power of two and cannot be larger than 65536. Default + * value: 1024. + * + * + * + * + * limit U32 + * + * + * Upper limit of the SFQ. Can be used to reduce the default + * length of 127 packets. + * + * + * + * + * depth U32 + * + * + * Limit of packets per flow. Default to + * 127 and can be lowered. + * + * + * + * + * perturb_period U32 + * + * + * Interval in seconds for queue algorithm perturbation. + * Defaults to 0, which means that no perturbation occurs. Do + * not set too low for each perturbation may cause some + * packet reordering or losses. Advised value: 60 This value + * has no effect when external flow classification is used. + * Its better to increase divisor value to lower risk of hash + * collisions. + * + * + * + * + * quantum U32 + * + * + * Amount of bytes a flow is allowed to dequeue during a + * round of the round robin process. Defaults to the MTU of + * the interface which is also the advised value and the + * minimum value. + * + * + * + * + * flows U32 + * + * + * Default value is 127. + * + * + * + * + * + * Parameters for 'tbf': + * + * + * + * rate U64 + * + * + * Bandwidth or rate. These parameters accept a floating + * point number, possibly followed by either a unit (both SI + * and IEC units supported), or a float followed by a percent + * character to specify the rate as a percentage of the + * device's speed. + * + * + * + * + * burst U32 + * + * + * Also known as buffer or maxburst. Size of the bucket, in + * bytes. This is the maximum amount of bytes that tokens can + * be available for instantaneously. In general, larger + * shaping rates require a larger buffer. For 10mbit/s on + * Intel, you need at least 10kbyte buffer if you want to + * reach your configured rate! + * + * + * If your buffer is too small, packets may be dropped + * because more tokens arrive per timer tick than fit in your + * bucket. The minimum buffer size can be calculated by + * dividing the rate by HZ. + * + * + * Token usage calculations are performed using a table which + * by default has a resolution of 8 packets. This resolution + * can be changed by specifying the cell size with the burst. + * For example, to specify a 6000 byte buffer with a 16 byte + * cell size, set a burst of 6000/16. You will probably never + * have to set this. Must be an integral power of 2. + * + * + * + * + * limit U32 + * + * + * Limit is the number of bytes that can be queued waiting + * for tokens to become available. + * + * + * + * + * latency U32 + * + * + * specifies the maximum amount of time a packet can + * sit in the TBF. The latency calculation takes into account + * the size of the bucket, the rate and possibly the peakrate + * (if set). The latency and limit are mutually exclusive. + * + * + * + * + * ---end--- + **/ /* ---ifcfg-rh--- * property: qdiscs * variable: QDISC1(+), QDISC2(+), ..., TC_COMMIT(+) @@ -1840,6 +2087,7 @@ nm_setting_tc_config_class_init(NMSettingTCConfigClass *klass) obj_properties[PROP_QDISCS], NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"), .to_dbus_fcn = tc_qdiscs_get, + .compare_fcn = compare_fcn_qdiscs, .from_dbus_fcn = tc_qdiscs_set, )); /** @@ -1854,6 +2102,109 @@ nm_setting_tc_config_class_init(NMSettingTCConfigClass *klass) * If the #NMSettingTCConfig setting is not present, NetworkManager * doesn't touch the filters present on the interface. **/ + /* ---nmcli--- + * property: tfilters + * format: GPtrArray(NMTCTfilter) + * description-docbook: + * + * Array of TC traffic filters. Traffic control can manage the packet content during + * classification by using filters. + * + * + * Each tfilters can be specified by the following attributes: + * + * + * + * handle HANDLE + * + * + * specifies the tfilters handle. A filter is used by a classful qdisc to determine in which class + * a packet will be enqueued. It is important to notice that filters reside within qdiscs. Therefore, + * see qdiscs handle for detailed information. + * + * + * + * + * parent HANDLE + * + * + * specifies the handle of the parent qdisc the current qdisc must be + * attached to. + * + * + * + * + * root + * + * + * specifies that the qdisc is attached to the root of device. + * + * + * + * + * KIND + * + * + * this is the tfilters kind. NetworkManager currently supports + * following kinds: mirred, simple. Each filter kind has a + * different set of actions, described below. There are also some + * other kinds like matchall, basic, u32 supported by NetworkManager. + * + * + * + * + * + * Actions for 'mirred': + * + * + * + * egress bool + * + * + * Define whether the packet should exit from the interface. + * + * + * + * + * ingress bool + * + * + * Define whether the packet should come into the interface. + * + * + * + * + * mirror bool + * + * + * Define whether the packet should be copied to the destination space. + * + * + * + * + * redirect bool + * + * + * Define whether the packet should be moved to the destination space. + * + * + * + * + * + * Action for 'simple': + * + * + * + * sdata char[32] + * + * + * The actual string to print. + * + * + * + * + * ---end--- + **/ /* ---ifcfg-rh--- * property: qdiscs * variable: FILTER1(+), FILTER2(+), ..., TC_COMMIT(+) @@ -1875,12 +2226,14 @@ nm_setting_tc_config_class_init(NMSettingTCConfigClass *klass) obj_properties[PROP_TFILTERS], NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"), .to_dbus_fcn = tc_tfilters_get, + .compare_fcn = compare_fcn_tfilter, .from_dbus_fcn = tc_tfilters_set, )); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_TC_CONFIG, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_TC_CONFIG, + NULL, + properties_override, + 0); } diff --git a/src/libnm-core-impl/nm-setting-team-port.c b/src/libnm-core-impl/nm-setting-team-port.c index 316fc67c..5e5f8910 100644 --- a/src/libnm-core-impl/nm-setting-team-port.c +++ b/src/libnm-core-impl/nm-setting-team-port.c @@ -350,52 +350,45 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_fcn_link_watchers(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) { NMSettingTeamPortPrivate *a_priv; NMSettingTeamPortPrivate *b_priv; - if (nm_streq(sett_info->property_infos[property_idx].name, - NM_SETTING_TEAM_PORT_LINK_WATCHERS)) { - if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) - return NM_TERNARY_DEFAULT; - if (!set_b) - return TRUE; - a_priv = NM_SETTING_TEAM_PORT_GET_PRIVATE(set_a); - b_priv = NM_SETTING_TEAM_PORT_GET_PRIVATE(set_b); - return nm_team_link_watchers_equal(a_priv->team_setting->d.link_watchers, - b_priv->team_setting->d.link_watchers, - TRUE); - } + if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) + return NM_TERNARY_DEFAULT; + if (!set_b) + return TRUE; + a_priv = NM_SETTING_TEAM_PORT_GET_PRIVATE(set_a); + b_priv = NM_SETTING_TEAM_PORT_GET_PRIVATE(set_b); + return nm_team_link_watchers_equal(a_priv->team_setting->d.link_watchers, + b_priv->team_setting->d.link_watchers, + TRUE); +} + +static NMTernary +compare_fcn_config(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) +{ + NMSettingTeamPortPrivate *a_priv; + NMSettingTeamPortPrivate *b_priv; - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_TEAM_PORT_CONFIG)) { - if (set_b) { - if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) { - /* If we are trying to match a connection in order to assume it (and thus + if (set_b) { + if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) { + /* If we are trying to match a connection in order to assume it (and thus * @flags contains INFERRABLE), use the "relaxed" matching for team * configuration. Otherwise, for all other purposes (including connection * comparison before an update), resort to the default string comparison. */ - return TRUE; - } - - a_priv = NM_SETTING_TEAM_PORT_GET_PRIVATE(set_a); - b_priv = NM_SETTING_TEAM_PORT_GET_PRIVATE(set_b); - - return nm_streq0(nm_team_setting_config_get(a_priv->team_setting), - nm_team_setting_config_get(b_priv->team_setting)); + return TRUE; } - return TRUE; + a_priv = NM_SETTING_TEAM_PORT_GET_PRIVATE(set_a); + b_priv = NM_SETTING_TEAM_PORT_GET_PRIVATE(set_b); + + return nm_streq0(nm_team_setting_config_get(a_priv->team_setting), + nm_team_setting_config_get(b_priv->team_setting)); } - return NM_SETTING_CLASS(nm_setting_team_port_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + return TRUE; } static void @@ -545,7 +538,6 @@ nm_setting_team_port_class_init(NMSettingTeamPortClass *klass) object_class->set_property = set_property; object_class->finalize = finalize; - setting_class->compare_property = compare_property; setting_class->verify = verify; setting_class->duplicate_copy_properties = duplicate_copy_properties; setting_class->init_from_dbus = init_from_dbus; @@ -570,9 +562,14 @@ nm_setting_team_port_class_init(NMSettingTeamPortClass *klass) "", NULL, G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[NM_TEAM_ATTRIBUTE_CONFIG], - &nm_sett_info_propert_type_team_s); + _nm_properties_override_gobj( + properties_override, + obj_properties[NM_TEAM_ATTRIBUTE_CONFIG], + NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_STRING, + .compare_fcn = compare_fcn_config, + .to_dbus_fcn = _nm_team_settings_property_to_dbus, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE)); /** * NMSettingTeamPort:queue-id: @@ -688,14 +685,22 @@ nm_setting_team_port_class_init(NMSettingTeamPortClass *klass) "", G_TYPE_PTR_ARRAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[NM_TEAM_ATTRIBUTE_LINK_WATCHERS], - &nm_sett_info_propert_type_team_link_watchers); + _nm_properties_override_gobj( + properties_override, + obj_properties[NM_TEAM_ATTRIBUTE_LINK_WATCHERS], + NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"), + .compare_fcn = compare_fcn_link_watchers, + .to_dbus_fcn = _nm_team_settings_property_to_dbus, + .typdata_from_dbus.gprop_fcn = + _nm_team_settings_property_from_dbus_link_watchers, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE)); g_object_class_install_properties(object_class, G_N_ELEMENTS(obj_properties), obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_TEAM_PORT, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_TEAM_PORT, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-team.c b/src/libnm-core-impl/nm-setting-team.c index b9a368c5..1a11b043 100644 --- a/src/libnm-core-impl/nm-setting-team.c +++ b/src/libnm-core-impl/nm-setting-team.c @@ -1275,50 +1275,45 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_fcn_link_watchers(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) { - NMSettingTeamPrivate *a_priv, *b_priv; + NMSettingTeamPrivate *a_priv; + NMSettingTeamPrivate *b_priv; - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_TEAM_LINK_WATCHERS)) { - if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) - return NM_TERNARY_DEFAULT; - if (!set_b) - return TRUE; - a_priv = NM_SETTING_TEAM_GET_PRIVATE(set_a); - b_priv = NM_SETTING_TEAM_GET_PRIVATE(set_b); - return nm_team_link_watchers_equal(a_priv->team_setting->d.link_watchers, - b_priv->team_setting->d.link_watchers, - TRUE); - } + if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) + return NM_TERNARY_DEFAULT; + if (!set_b) + return TRUE; + a_priv = NM_SETTING_TEAM_GET_PRIVATE(set_a); + b_priv = NM_SETTING_TEAM_GET_PRIVATE(set_b); + return nm_team_link_watchers_equal(a_priv->team_setting->d.link_watchers, + b_priv->team_setting->d.link_watchers, + TRUE); +} - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_TEAM_CONFIG)) { - if (set_b) { - if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) { - /* If we are trying to match a connection in order to assume it (and thus +static NMTernary +compare_fcn_config(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) +{ + NMSettingTeamPrivate *a_priv; + NMSettingTeamPrivate *b_priv; + + if (set_b) { + if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) { + /* If we are trying to match a connection in order to assume it (and thus * @flags contains INFERRABLE), use the "relaxed" matching for team * configuration. Otherwise, for all other purposes (including connection * comparison before an update), resort to the default string comparison. */ - return TRUE; - } - - a_priv = NM_SETTING_TEAM_GET_PRIVATE(set_a); - b_priv = NM_SETTING_TEAM_GET_PRIVATE(set_b); - - return nm_streq0(nm_team_setting_config_get(a_priv->team_setting), - nm_team_setting_config_get(b_priv->team_setting)); + return TRUE; } - return TRUE; + a_priv = NM_SETTING_TEAM_GET_PRIVATE(set_a); + b_priv = NM_SETTING_TEAM_GET_PRIVATE(set_b); + + return nm_streq0(nm_team_setting_config_get(a_priv->team_setting), + nm_team_setting_config_get(b_priv->team_setting)); } - return NM_SETTING_CLASS(nm_setting_team_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + return TRUE; } static void @@ -1505,7 +1500,6 @@ nm_setting_team_class_init(NMSettingTeamClass *klass) object_class->set_property = set_property; object_class->finalize = finalize; - setting_class->compare_property = compare_property; setting_class->verify = verify; setting_class->duplicate_copy_properties = duplicate_copy_properties; setting_class->init_from_dbus = init_from_dbus; @@ -1530,9 +1524,14 @@ nm_setting_team_class_init(NMSettingTeamClass *klass) "", NULL, G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[NM_TEAM_ATTRIBUTE_CONFIG], - &nm_sett_info_propert_type_team_s); + _nm_properties_override_gobj( + properties_override, + obj_properties[NM_TEAM_ATTRIBUTE_CONFIG], + NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_STRING, + .compare_fcn = compare_fcn_config, + .to_dbus_fcn = _nm_team_settings_property_to_dbus, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE)); /** * NMSettingTeam:notify-peers-count: @@ -1809,9 +1808,16 @@ nm_setting_team_class_init(NMSettingTeamClass *klass) "", G_TYPE_PTR_ARRAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[NM_TEAM_ATTRIBUTE_LINK_WATCHERS], - &nm_sett_info_propert_type_team_link_watchers); + _nm_properties_override_gobj( + properties_override, + obj_properties[NM_TEAM_ATTRIBUTE_LINK_WATCHERS], + NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"), + .compare_fcn = compare_fcn_link_watchers, + .to_dbus_fcn = _nm_team_settings_property_to_dbus, + .typdata_from_dbus.gprop_fcn = + _nm_team_settings_property_from_dbus_link_watchers, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE)); /* ---dbus--- * property: interface-name @@ -1827,8 +1833,9 @@ nm_setting_team_class_init(NMSettingTeamClass *klass) g_object_class_install_properties(object_class, G_N_ELEMENTS(obj_properties), obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_TEAM, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_TEAM, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-tun.c b/src/libnm-core-impl/nm-setting-tun.c index d75dcf80..c2694847 100644 --- a/src/libnm-core-impl/nm-setting-tun.c +++ b/src/libnm-core-impl/nm-setting-tun.c @@ -32,12 +32,12 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_MODE, PROP_MULTI_QUEUE, ); typedef struct { - char * owner; - char * group; - NMSettingTunMode mode; - bool pi : 1; - bool vnet_hdr : 1; - bool multi_queue : 1; + char * owner; + char * group; + guint32 mode; + bool pi; + bool vnet_hdr; + bool multi_queue; } NMSettingTunPrivate; /** @@ -197,78 +197,9 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingTun * setting = NM_SETTING_TUN(object); - NMSettingTunPrivate *priv = NM_SETTING_TUN_GET_PRIVATE(setting); - - switch (prop_id) { - case PROP_MODE: - g_value_set_uint(value, priv->mode); - break; - case PROP_OWNER: - g_value_set_string(value, priv->owner); - break; - case PROP_GROUP: - g_value_set_string(value, priv->group); - break; - case PROP_PI: - g_value_set_boolean(value, priv->pi); - break; - case PROP_VNET_HDR: - g_value_set_boolean(value, priv->vnet_hdr); - break; - case PROP_MULTI_QUEUE: - g_value_set_boolean(value, priv->multi_queue); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingTun * setting = NM_SETTING_TUN(object); - NMSettingTunPrivate *priv = NM_SETTING_TUN_GET_PRIVATE(setting); - - switch (prop_id) { - case PROP_MODE: - priv->mode = g_value_get_uint(value); - break; - case PROP_OWNER: - g_free(priv->owner); - priv->owner = g_value_dup_string(value); - break; - case PROP_GROUP: - g_free(priv->group); - priv->group = g_value_dup_string(value); - break; - case PROP_PI: - priv->pi = g_value_get_boolean(value); - break; - case PROP_VNET_HDR: - priv->vnet_hdr = g_value_get_boolean(value); - break; - case PROP_MULTI_QUEUE: - priv->multi_queue = g_value_get_boolean(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} -/*****************************************************************************/ - static void nm_setting_tun_init(NMSettingTun *self) -{ - NMSettingTunPrivate *priv = NM_SETTING_TUN_GET_PRIVATE(self); - - priv->mode = NM_SETTING_TUN_MODE_TUN; -} +{} /** * nm_setting_tun_new: @@ -285,18 +216,6 @@ nm_setting_tun_new(void) return g_object_new(NM_TYPE_SETTING_TUN, NULL); } -static void -finalize(GObject *object) -{ - NMSettingTun * setting = NM_SETTING_TUN(object); - NMSettingTunPrivate *priv = NM_SETTING_TUN_GET_PRIVATE(setting); - - g_free(priv->owner); - g_free(priv->group); - - G_OBJECT_CLASS(nm_setting_tun_parent_class)->finalize(object); -} - static void nm_setting_tun_class_init(NMSettingTunClass *klass) { @@ -306,9 +225,8 @@ nm_setting_tun_class_init(NMSettingTunClass *klass) g_type_class_add_private(klass, sizeof(NMSettingTunPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -322,14 +240,16 @@ nm_setting_tun_class_init(NMSettingTunClass *klass) * * Since: 1.2 */ - obj_properties[PROP_MODE] = - g_param_spec_uint(NM_SETTING_TUN_MODE, - "", - "", - 0, - G_MAXUINT, - NM_SETTING_TUN_MODE_TUN, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_TUN_MODE, + PROP_MODE, + 0, + G_MAXUINT32, + NM_SETTING_TUN_MODE_TUN, + NM_SETTING_PARAM_INFERRABLE, + NMSettingTunPrivate, + mode); /** * NMSettingTun:owner: @@ -339,12 +259,13 @@ nm_setting_tun_class_init(NMSettingTunClass *klass) * * Since: 1.2 */ - obj_properties[PROP_OWNER] = g_param_spec_string(NM_SETTING_TUN_OWNER, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_TUN_OWNER, + PROP_OWNER, + NM_SETTING_PARAM_INFERRABLE, + NMSettingTunPrivate, + owner); /** * NMSettingTun:group: @@ -354,12 +275,13 @@ nm_setting_tun_class_init(NMSettingTunClass *klass) * * Since: 1.2 */ - obj_properties[PROP_GROUP] = g_param_spec_string(NM_SETTING_TUN_GROUP, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_TUN_GROUP, + PROP_GROUP, + NM_SETTING_PARAM_INFERRABLE, + NMSettingTunPrivate, + group); /** * NMSettingTun:pi: @@ -369,13 +291,14 @@ nm_setting_tun_class_init(NMSettingTunClass *klass) * * Since: 1.2 */ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_TUN_PI, - PROP_PI, - FALSE, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_tun_get_pi); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_TUN_PI, + PROP_PI, + FALSE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingTunPrivate, + pi); /** * NMSettingTun:vnet-hdr: @@ -385,13 +308,14 @@ nm_setting_tun_class_init(NMSettingTunClass *klass) * * Since: 1.2 */ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_TUN_VNET_HDR, - PROP_VNET_HDR, - FALSE, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_tun_get_vnet_hdr); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_TUN_VNET_HDR, + PROP_VNET_HDR, + FALSE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingTunPrivate, + vnet_hdr); /** * NMSettingTun:multi-queue: @@ -403,18 +327,20 @@ nm_setting_tun_class_init(NMSettingTunClass *klass) * * Since: 1.2 */ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_TUN_MULTI_QUEUE, - PROP_MULTI_QUEUE, - FALSE, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_tun_get_multi_queue); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_TUN_MULTI_QUEUE, + PROP_MULTI_QUEUE, + FALSE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingTunPrivate, + multi_queue); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_TUN, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_TUN, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-user.c b/src/libnm-core-impl/nm-setting-user.c index 0f99baa2..4068f337 100644 --- a/src/libnm-core-impl/nm-setting-user.c +++ b/src/libnm-core-impl/nm-setting-user.c @@ -232,7 +232,7 @@ nm_setting_user_get_keys(NMSettingUser *setting, guint *out_len) return priv->keys; } - priv->keys = nm_utils_strdict_get_keys(priv->data, TRUE, out_len); + priv->keys = nm_strdict_get_keys(priv->data, TRUE, out_len); /* don't return %NULL, but hijack the @keys fields as a pseudo * empty strv array. */ @@ -254,18 +254,10 @@ nm_setting_user_get_keys(NMSettingUser *setting, guint *out_len) const char * nm_setting_user_get_data(NMSettingUser *setting, const char *key) { - NMSettingUser * self = setting; - NMSettingUserPrivate *priv; - - g_return_val_if_fail(NM_IS_SETTING_USER(self), NULL); + g_return_val_if_fail(NM_IS_SETTING_USER(setting), NULL); g_return_val_if_fail(key, NULL); - priv = NM_SETTING_USER_GET_PRIVATE(self); - - if (!priv->data) - return NULL; - - return g_hash_table_lookup(priv->data, key); + return nm_g_hash_table_lookup(NM_SETTING_USER_GET_PRIVATE(setting)->data, key); } /** @@ -397,34 +389,21 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_fcn_data(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) { - NMSettingUserPrivate *priv, *pri2; + NMSettingUserPrivate *priv; + NMSettingUserPrivate *pri2; - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_USER_DATA)) { - if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) - return NM_TERNARY_DEFAULT; + if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) + return NM_TERNARY_DEFAULT; - if (!set_b) - return TRUE; - - priv = NM_SETTING_USER_GET_PRIVATE(NM_SETTING_USER(set_a)); - pri2 = NM_SETTING_USER_GET_PRIVATE(NM_SETTING_USER(set_b)); - return nm_utils_hashtable_equal(priv->data, pri2->data, TRUE, g_str_equal) - && nm_utils_hashtable_equal(priv->data_invalid, - pri2->data_invalid, - TRUE, - g_str_equal); - } + if (!set_b) + return TRUE; - return NM_SETTING_CLASS(nm_setting_user_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + priv = NM_SETTING_USER_GET_PRIVATE(NM_SETTING_USER(set_a)); + pri2 = NM_SETTING_USER_GET_PRIVATE(NM_SETTING_USER(set_b)); + return nm_utils_hashtable_equal(priv->data, pri2->data, TRUE, g_str_equal) + && nm_utils_hashtable_equal(priv->data_invalid, pri2->data_invalid, TRUE, g_str_equal); } /*****************************************************************************/ @@ -552,8 +531,7 @@ nm_setting_user_class_init(NMSettingUserClass *klass) object_class->set_property = set_property; object_class->finalize = finalize; - setting_class->compare_property = compare_property; - setting_class->verify = verify; + setting_class->verify = verify; /** * NMSettingUser:data: (type GHashTable(utf8,utf8)) @@ -581,14 +559,22 @@ nm_setting_user_class_init(NMSettingUserClass *klass) "", G_TYPE_HASH_TABLE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_DATA], - &nm_sett_info_propert_type_strdict); + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_DATA], + NM_SETT_INFO_PROPERT_TYPE_GPROP(NM_G_VARIANT_TYPE("a{ss}"), + .typdata_from_dbus.gprop_fcn = _nm_utils_strdict_from_dbus, + .typdata_to_dbus.gprop_type = + NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_STRDICT, + .compare_fcn = compare_fcn_data, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE)); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_USER, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_USER, + NULL, + properties_override, + G_STRUCT_OFFSET(NMSettingUser, _priv)); } diff --git a/src/libnm-core-impl/nm-setting-veth.c b/src/libnm-core-impl/nm-setting-veth.c index 70cfe50b..43d8da4f 100644 --- a/src/libnm-core-impl/nm-setting-veth.c +++ b/src/libnm-core-impl/nm-setting-veth.c @@ -190,5 +190,5 @@ nm_setting_veth_class_init(NMSettingVethClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_VETH); + _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_VETH, NULL, NULL, 0); } diff --git a/src/libnm-core-impl/nm-setting-vlan.c b/src/libnm-core-impl/nm-setting-vlan.c index e4e07e35..1124953e 100644 --- a/src/libnm-core-impl/nm-setting-vlan.c +++ b/src/libnm-core-impl/nm-setting-vlan.c @@ -90,6 +90,7 @@ guint32 nm_setting_vlan_get_id(NMSettingVlan *setting) { g_return_val_if_fail(NM_IS_SETTING_VLAN(setting), 0); + return NM_SETTING_VLAN_GET_PRIVATE(setting)->id; } @@ -676,22 +677,13 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static GVariant * -_override_flags_get(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +_override_flags_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { return g_variant_new_uint32(nm_setting_vlan_get_flags((NMSettingVlan *) setting)); } static gboolean -_override_flags_not_set(NMSetting * setting, - GVariant * connection_dict, - const char * property, - NMSettingParseFlags parse_flags, - GError ** error) +_override_flags_not_set(_NM_SETT_INFO_PROP_MISSING_FROM_DBUS_FCN_ARGS _nm_nil) { /* we changed the default value for FLAGS. When an older client * doesn't serialize the property, we assume it is the old default. */ @@ -747,9 +739,6 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) case PROP_PARENT: g_value_set_string(value, priv->parent); break; - case PROP_ID: - g_value_set_uint(value, priv->id); - break; case PROP_FLAGS: g_value_set_flags(value, priv->flags); break; @@ -760,7 +749,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) g_value_take_boxed(value, priority_maplist_to_strv(priv->egress_priority_map)); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_get_property_direct(object, prop_id, value, pspec); break; } } @@ -776,9 +765,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps g_free(priv->parent); priv->parent = g_value_dup_string(value); break; - case PROP_ID: - priv->id = g_value_get_uint(value); - break; case PROP_FLAGS: priv->flags = g_value_get_flags(value); break; @@ -793,7 +779,7 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps priority_strv_to_maplist(NM_VLAN_EGRESS_MAP, g_value_get_boxed(value)); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_set_property_direct(object, prop_id, value, pspec); break; } } @@ -885,14 +871,16 @@ nm_setting_vlan_class_init(NMSettingVlanClass *klass) * prefer the detected ID from the DEVICE over VLAN_ID. * ---end--- */ - obj_properties[PROP_ID] = - g_param_spec_uint(NM_SETTING_VLAN_ID, - "", - "", - 0, - 4095, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_VLAN_ID, + PROP_ID, + 0, + 4095, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVlanPrivate, + id); /** * NMSettingVlan:flags: @@ -927,8 +915,11 @@ nm_setting_vlan_class_init(NMSettingVlanClass *klass) properties_override, obj_properties[PROP_FLAGS], NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_UINT32, - .to_dbus_fcn = _override_flags_get, - .missing_from_dbus_fcn = _override_flags_not_set, )); + .to_dbus_fcn = _override_flags_get, + .compare_fcn = _nm_setting_property_compare_fcn_default, + .missing_from_dbus_fcn = _override_flags_not_set, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE)); /** * NMSettingVlan:ingress-priority-map: @@ -994,8 +985,9 @@ nm_setting_vlan_class_init(NMSettingVlanClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_VLAN, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_VLAN, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-vpn.c b/src/libnm-core-impl/nm-setting-vpn.c index 351f3fd7..a543051b 100644 --- a/src/libnm-core-impl/nm-setting-vpn.c +++ b/src/libnm-core-impl/nm-setting-vpn.c @@ -47,11 +47,6 @@ typedef struct { */ char *user_name; - /* Whether the VPN stays up across link changes, until the user - * explicitly disconnects it. - */ - gboolean persistent; - /* The hash table is created at setting object * init time and should not be replaced. It is * a char * -> char * mapping, and both the key @@ -72,6 +67,12 @@ typedef struct { /* Timeout for the VPN service to establish the connection */ guint32 timeout; + + /* Whether the VPN stays up across link changes, until the user + * explicitly disconnects it. + */ + bool persistent; + } NMSettingVpnPrivate; /** @@ -240,7 +241,7 @@ nm_setting_vpn_get_data_keys(NMSettingVpn *setting, guint *out_length) { g_return_val_if_fail(NM_IS_SETTING_VPN(setting), NULL); - return nm_utils_strdict_get_keys(NM_SETTING_VPN_GET_PRIVATE(setting)->data, TRUE, out_length); + return nm_strdict_get_keys(NM_SETTING_VPN_GET_PRIVATE(setting)->data, TRUE, out_length); } /** @@ -277,7 +278,7 @@ foreach_item_helper(NMSettingVpn *self, GHashTable **p_hash, NMVpnIterFunc func, nm_assert(NM_IS_SETTING_VPN(self)); nm_assert(func); - keys = nm_utils_strv_make_deep_copied(nm_utils_strdict_get_keys(*p_hash, TRUE, &len)); + keys = nm_strv_make_deep_copied(nm_strdict_get_keys(*p_hash, TRUE, &len)); if (len == 0u) { nm_assert(!keys); return; @@ -407,9 +408,7 @@ nm_setting_vpn_get_secret_keys(NMSettingVpn *setting, guint *out_length) { g_return_val_if_fail(NM_IS_SETTING_VPN(setting), NULL); - return nm_utils_strdict_get_keys(NM_SETTING_VPN_GET_PRIVATE(setting)->secrets, - TRUE, - out_length); + return nm_strdict_get_keys(NM_SETTING_VPN_GET_PRIVATE(setting)->secrets, TRUE, out_length); } /** @@ -850,41 +849,30 @@ compare_property_secrets(NMSettingVpn *a, NMSettingVpn *b, NMSettingCompareFlags } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_fcn_secrets(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) { - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_VPN_SECRETS)) { - if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) - return NM_TERNARY_DEFAULT; - return compare_property_secrets(NM_SETTING_VPN(set_a), NM_SETTING_VPN(set_b), flags); - } - - return NM_SETTING_CLASS(nm_setting_vpn_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) + return NM_TERNARY_DEFAULT; + return compare_property_secrets(NM_SETTING_VPN(set_a), NM_SETTING_VPN(set_b), flags); } static gboolean clear_secrets(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMSetting * setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data) { - NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(setting); - GParamSpec * prop_spec = sett_info->property_infos[property_idx].param_spec; + NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(setting); GHashTableIter iter; const char * secret; gboolean changed = TRUE; - if (!prop_spec || !NM_FLAGS_HAS(prop_spec->flags, NM_SETTING_PARAM_SECRET)) + if (!property_info->param_spec + || !NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_SECRET)) return FALSE; - nm_assert(nm_streq(prop_spec->name, NM_SETTING_VPN_SECRETS)); + nm_assert(nm_streq(property_info->param_spec->name, NM_SETTING_VPN_SECRETS)); if (!priv->secrets) return FALSE; @@ -913,12 +901,7 @@ clear_secrets(const NMSettInfoSetting * sett_info, } static gboolean -vpn_secrets_from_dbus(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +vpn_secrets_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { NMSettingVpn * self = NM_SETTING_VPN(setting); NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(self); @@ -941,12 +924,7 @@ vpn_secrets_from_dbus(NMSetting * setting, } static GVariant * -vpn_secrets_to_dbus(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +vpn_secrets_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(setting); GVariantBuilder builder; @@ -963,7 +941,7 @@ vpn_secrets_to_dbus(const NMSettInfoSetting * sett_info, g_variant_builder_init(&builder, G_VARIANT_TYPE("a{ss}")); - keys = nm_utils_strdict_get_keys(priv->secrets, TRUE, &len); + keys = nm_strdict_get_keys(priv->secrets, TRUE, &len); for (i = 0; i < len; i++) { const char * key = keys[i]; NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE; @@ -1130,7 +1108,6 @@ nm_setting_vpn_class_init(NMSettingVpnClass *klass) setting_class->get_secret_flags = get_secret_flags; setting_class->set_secret_flags = set_secret_flags; setting_class->need_secrets = need_secrets; - setting_class->compare_property = compare_property; setting_class->clear_secrets = clear_secrets; setting_class->aggregate = aggregate; @@ -1172,13 +1149,14 @@ nm_setting_vpn_class_init(NMSettingVpnClass *klass) * the VPN will attempt to stay connected across link changes and outages, * until explicitly disconnected. **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_VPN_PERSISTENT, - PROP_PERSISTENT, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_vpn_get_persistent); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_VPN_PERSISTENT, + PROP_PERSISTENT, + FALSE, + NM_SETTING_PARAM_NONE, + NMSettingVpnPrivate, + persistent); /** * NMSettingVpn:data: (type GHashTable(utf8,utf8)): @@ -1229,6 +1207,7 @@ nm_setting_vpn_class_init(NMSettingVpnClass *klass) obj_properties[PROP_SECRETS], NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("a{ss}"), .to_dbus_fcn = vpn_secrets_to_dbus, + .compare_fcn = compare_fcn_secrets, .from_dbus_fcn = vpn_secrets_from_dbus, )); /** @@ -1252,8 +1231,9 @@ nm_setting_vpn_class_init(NMSettingVpnClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_VPN, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_VPN, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-vrf.c b/src/libnm-core-impl/nm-setting-vrf.c index a5ee7395..f998a7dd 100644 --- a/src/libnm-core-impl/nm-setting-vrf.c +++ b/src/libnm-core-impl/nm-setting-vrf.c @@ -80,38 +80,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingVrf *self = NM_SETTING_VRF(object); - - switch (prop_id) { - case PROP_TABLE: - g_value_set_uint(value, self->table); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingVrf *self = NM_SETTING_VRF(object); - - switch (prop_id) { - case PROP_TABLE: - self->table = g_value_get_uint(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - static void nm_setting_vrf_init(NMSettingVrf *setting) {} @@ -134,11 +102,12 @@ nm_setting_vrf_new(void) static void nm_setting_vrf_class_init(NMSettingVrfClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMSettingClass *setting_class = NM_SETTING_CLASS(klass); + GObjectClass * object_class = G_OBJECT_CLASS(klass); + NMSettingClass *setting_class = NM_SETTING_CLASS(klass); + GArray * properties_override = _nm_sett_info_property_override_create_array(); - object_class->get_property = get_property; - object_class->set_property = set_property; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -149,16 +118,18 @@ nm_setting_vrf_class_init(NMSettingVrfClass *klass) * * Since: 1.24 **/ - obj_properties[PROP_TABLE] = - g_param_spec_uint(NM_SETTING_VRF_TABLE, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_VRF_TABLE, + PROP_TABLE, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVrf, + table); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_VRF); + _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_VRF, NULL, properties_override, 0); } diff --git a/src/libnm-core-impl/nm-setting-vxlan.c b/src/libnm-core-impl/nm-setting-vxlan.c index f2aeb66a..c2d23a7f 100644 --- a/src/libnm-core-impl/nm-setting-vxlan.c +++ b/src/libnm-core-impl/nm-setting-vxlan.c @@ -53,11 +53,11 @@ typedef struct { guint ttl; guint ageing; guint limit; - bool learning : 1; - bool proxy : 1; - bool rsc : 1; - bool l2_miss : 1; - bool l3_miss : 1; + bool proxy; + bool learning; + bool rsc; + bool l2_miss; + bool l3_miss; } NMSettingVxlanPrivate; /** @@ -536,7 +536,6 @@ nm_setting_vxlan_init(NMSettingVxlan *self) priv->destination_port = DST_PORT_DEFAULT; priv->ageing = 300; - priv->learning = TRUE; } /** @@ -595,6 +594,7 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass) "", NULL, G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + /** * NMSettingVxlan:id: * @@ -765,13 +765,14 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass) * * Since: 1.2 **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_VXLAN_PROXY, - PROP_PROXY, - FALSE, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_vxlan_get_proxy); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_VXLAN_PROXY, + PROP_PROXY, + FALSE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVxlanPrivate, + proxy); /** * NMSettingVxlan:learning: @@ -781,13 +782,14 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass) * * Since: 1.2 **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_VXLAN_LEARNING, - PROP_LEARNING, - TRUE, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_vxlan_get_learning); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_VXLAN_LEARNING, + PROP_LEARNING, + TRUE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVxlanPrivate, + learning); /** * NMSettingVxlan:rsc: @@ -796,13 +798,14 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass) * * Since: 1.2 **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_VXLAN_RSC, - PROP_RSC, - FALSE, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_vxlan_get_rsc); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_VXLAN_RSC, + PROP_RSC, + FALSE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVxlanPrivate, + rsc); /** * NMSettingVxlan:l2-miss: @@ -811,13 +814,14 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass) * * Since: 1.2 **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_VXLAN_L2_MISS, - PROP_L2_MISS, - FALSE, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_vxlan_get_l2_miss); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_VXLAN_L2_MISS, + PROP_L2_MISS, + FALSE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVxlanPrivate, + l2_miss); /** * NMSettingVxlan:l3-miss: @@ -826,18 +830,20 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass) * * Since: 1.2 **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_VXLAN_L3_MISS, - PROP_L3_MISS, - FALSE, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_vxlan_get_l3_miss); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_VXLAN_L3_MISS, + PROP_L3_MISS, + FALSE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVxlanPrivate, + l3_miss); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_VXLAN, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_VXLAN, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-wifi-p2p.c b/src/libnm-core-impl/nm-setting-wifi-p2p.c index 8f677479..06d450fc 100644 --- a/src/libnm-core-impl/nm-setting-wifi-p2p.c +++ b/src/libnm-core-impl/nm-setting-wifi-p2p.c @@ -35,10 +35,9 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PEER, PROP_WPS_METHOD, PROP_WFD_IES, ); typedef struct { - char * peer_mac_address; + char * peer; GBytes *wfd_ies; - - NMSettingWirelessSecurityWpsMethod wps_method; + guint32 wps_method; } NMSettingWifiP2PPrivate; struct _NMSettingWifiP2P { @@ -70,7 +69,7 @@ nm_setting_wifi_p2p_get_peer(NMSettingWifiP2P *setting) { g_return_val_if_fail(NM_IS_SETTING_WIFI_P2P(setting), NULL); - return NM_SETTING_WIFI_P2P_GET_PRIVATE(setting)->peer_mac_address; + return NM_SETTING_WIFI_P2P_GET_PRIVATE(setting)->peer; } /** @@ -113,7 +112,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingWifiP2PPrivate *priv = NM_SETTING_WIFI_P2P_GET_PRIVATE(setting); - if (!priv->peer_mac_address) { + if (!priv->peer) { g_set_error_literal(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_PROPERTY, @@ -125,7 +124,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } - if (!nm_utils_hwaddr_valid(priv->peer_mac_address, ETH_ALEN)) { + if (!nm_utils_hwaddr_valid(priv->peer, ETH_ALEN)) { g_set_error_literal(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -149,53 +148,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingWifiP2P *setting = NM_SETTING_WIFI_P2P(object); - - switch (prop_id) { - case PROP_PEER: - g_value_set_string(value, nm_setting_wifi_p2p_get_peer(setting)); - break; - case PROP_WPS_METHOD: - g_value_set_uint(value, nm_setting_wifi_p2p_get_wps_method(setting)); - break; - case PROP_WFD_IES: - g_value_set_boxed(value, nm_setting_wifi_p2p_get_wfd_ies(setting)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingWifiP2PPrivate *priv = NM_SETTING_WIFI_P2P_GET_PRIVATE(object); - - switch (prop_id) { - case PROP_PEER: - g_free(priv->peer_mac_address); - priv->peer_mac_address = - _nm_utils_hwaddr_canonical_or_invalid(g_value_get_string(value), ETH_ALEN); - break; - case PROP_WPS_METHOD: - priv->wps_method = g_value_get_uint(value); - break; - case PROP_WFD_IES: - nm_clear_pointer(&priv->wfd_ies, g_bytes_unref); - priv->wfd_ies = g_value_dup_boxed(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - static void nm_setting_wifi_p2p_init(NMSettingWifiP2P *setting) {} @@ -215,26 +167,15 @@ nm_setting_wifi_p2p_new(void) return g_object_new(NM_TYPE_SETTING_WIFI_P2P, NULL); } -static void -finalize(GObject *object) -{ - NMSettingWifiP2PPrivate *priv = NM_SETTING_WIFI_P2P_GET_PRIVATE(object); - - g_free(priv->peer_mac_address); - g_bytes_unref(priv->wfd_ies); - - G_OBJECT_CLASS(nm_setting_wifi_p2p_parent_class)->finalize(object); -} - static void nm_setting_wifi_p2p_class_init(NMSettingWifiP2PClass *setting_wifi_p2p_class) { - GObjectClass * object_class = G_OBJECT_CLASS(setting_wifi_p2p_class); - NMSettingClass *setting_class = NM_SETTING_CLASS(setting_wifi_p2p_class); + GObjectClass * object_class = G_OBJECT_CLASS(setting_wifi_p2p_class); + NMSettingClass *setting_class = NM_SETTING_CLASS(setting_wifi_p2p_class); + GArray * properties_override = _nm_sett_info_property_override_create_array(); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -254,11 +195,13 @@ nm_setting_wifi_p2p_class_init(NMSettingWifiP2PClass *setting_wifi_p2p_class) * (e.g. 0;34;104;18;121;162). * ---end--- */ - obj_properties[PROP_PEER] = g_param_spec_string(NM_SETTING_WIFI_P2P_PEER, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIFI_P2P_PEER, + PROP_PEER, + NM_SETTING_PARAM_NONE, + NMSettingWifiP2P, + _priv.peer); /** * NMSettingWifiP2P:wps-method: @@ -270,14 +213,16 @@ nm_setting_wifi_p2p_class_init(NMSettingWifiP2PClass *setting_wifi_p2p_class) * * Since: 1.16 */ - obj_properties[PROP_WPS_METHOD] = g_param_spec_uint( - NM_SETTING_WIFI_P2P_WPS_METHOD, - "", - "", - 0, - G_MAXUINT32, - NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DEFAULT, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_WIFI_P2P_WPS_METHOD, + PROP_WPS_METHOD, + 0, + G_MAXUINT32, + NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DEFAULT, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingWifiP2P, + _priv.wps_method); /** * NMSettingWifiP2P:wfd-ies: @@ -291,14 +236,19 @@ nm_setting_wifi_p2p_class_init(NMSettingWifiP2PClass *setting_wifi_p2p_class) * * Since: 1.16 */ - obj_properties[PROP_WFD_IES] = g_param_spec_boxed( - NM_SETTING_WIFI_P2P_WFD_IES, - "", - "", - G_TYPE_BYTES, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_bytes(properties_override, + obj_properties, + NM_SETTING_WIFI_P2P_WFD_IES, + PROP_WFD_IES, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingWifiP2P, + _priv.wfd_ies); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_WIFI_P2P); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_WIFI_P2P, + NULL, + properties_override, + 0); } diff --git a/src/libnm-core-impl/nm-setting-wimax.c b/src/libnm-core-impl/nm-setting-wimax.c index 6d9f3284..f7fed08e 100644 --- a/src/libnm-core-impl/nm-setting-wimax.c +++ b/src/libnm-core-impl/nm-setting-wimax.c @@ -208,7 +208,6 @@ finalize(GObject *object) NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE(object); g_free(priv->network_name); - g_free(priv->mac_address); G_OBJECT_CLASS(nm_setting_wimax_parent_class)->finalize(object); } @@ -252,20 +251,20 @@ nm_setting_wimax_class_init(NMSettingWimaxClass *klass) * * Deprecated: 1.2: WiMAX is no longer supported. **/ - obj_properties[PROP_MAC_ADDRESS] = - g_param_spec_string(NM_SETTING_WIMAX_MAC_ADDRESS, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_MAC_ADDRESS], - &nm_sett_info_propert_type_mac_address); + _nm_setting_property_define_direct_mac_address(properties_override, + obj_properties, + NM_SETTING_WIMAX_MAC_ADDRESS, + PROP_MAC_ADDRESS, + NM_SETTING_PARAM_NONE, + NMSettingWimaxPrivate, + mac_address, + .direct_set_string_mac_address_len = ETH_ALEN); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_WIMAX, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_WIMAX, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-wired.c b/src/libnm-core-impl/nm-setting-wired.c index 4acc5641..8c9bdcd4 100644 --- a/src/libnm-core-impl/nm-setting-wired.c +++ b/src/libnm-core-impl/nm-setting-wired.c @@ -66,7 +66,7 @@ typedef struct { NMTernary accept_all_mac_addresses; guint32 speed; guint32 mtu; - bool auto_negotiate : 1; + bool auto_negotiate; } NMSettingWiredPrivate; /** @@ -147,9 +147,9 @@ _nm_setting_wired_is_valid_s390_option(const char *option) } return option - && (nm_utils_strv_find_binary_search(valid_s390_opts, - G_N_ELEMENTS(valid_s390_opts) - 1, - option) + && (nm_strv_find_binary_search(valid_s390_opts, + G_N_ELEMENTS(valid_s390_opts) - 1, + option) >= 0); } @@ -626,7 +626,7 @@ nm_setting_wired_add_s390_option(NMSettingWired *setting, const char *key, const }; priv->s390_options.len++; } else { - if (!nm_utils_strdup_reset(&priv->s390_options.arr[idx].value_str_mutable, value)) + if (!nm_strdup_reset(&priv->s390_options.arr[idx].value_str_mutable, value)) return TRUE; } @@ -976,23 +976,11 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_fcn_cloned_mac_address(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) { - if (nm_streq(sett_info->property_infos[property_idx].name, - NM_SETTING_WIRED_CLONED_MAC_ADDRESS)) { - return !set_b - || nm_streq0(NM_SETTING_WIRED_GET_PRIVATE(set_a)->cloned_mac_address, - NM_SETTING_WIRED_GET_PRIVATE(set_b)->cloned_mac_address); - } - - return NM_SETTING_CLASS(nm_setting_wired_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + return !set_b + || nm_streq0(NM_SETTING_WIRED_GET_PRIVATE(set_a)->cloned_mac_address, + NM_SETTING_WIRED_GET_PRIVATE(set_b)->cloned_mac_address); } /*****************************************************************************/ @@ -1242,22 +1230,14 @@ finalize(GObject *object) { NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE(object); - g_free(priv->port); - g_free(priv->duplex); - g_free(priv->s390_nettype); - _s390_options_clear(priv); - g_free(priv->device_mac_address); g_free(priv->cloned_mac_address); - g_free(priv->generate_mac_address_mask); g_array_unref(priv->mac_address_blacklist); if (priv->s390_subchannels) g_strfreev(priv->s390_subchannels); - g_free(priv->wol_password); - G_OBJECT_CLASS(nm_setting_wired_parent_class)->finalize(object); } @@ -1274,8 +1254,7 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) object_class->set_property = set_property; object_class->finalize = finalize; - setting_class->verify = verify; - setting_class->compare_property = compare_property; + setting_class->verify = verify; /** * NMSettingWired:port: @@ -1291,12 +1270,13 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) * description: The property is not saved by the plugin. * ---end--- */ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_WIRED_PORT, - PROP_PORT, - NM_SETTING_PARAM_NONE, - nm_setting_wired_get_port); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIRED_PORT, + PROP_PORT, + NM_SETTING_PARAM_NONE, + NMSettingWiredPrivate, + port); /** * NMSettingWired:speed: @@ -1353,12 +1333,13 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) * "duplex" parameter in the ETHOOL_OPTS variable. * ---end--- */ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_WIRED_DUPLEX, - PROP_DUPLEX, - NM_SETTING_PARAM_NONE, - nm_setting_wired_get_duplex); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIRED_DUPLEX, + PROP_DUPLEX, + NM_SETTING_PARAM_NONE, + NMSettingWiredPrivate, + duplex); /** * NMSettingWired:auto-negotiate: @@ -1380,14 +1361,15 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) * "speed" and "duplex" parameters (skips link configuration). * ---end--- */ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_WIRED_AUTO_NEGOTIATE, - PROP_AUTO_NEGOTIATE, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_wired_get_auto_negotiate, - .to_dbus_data.including_default = TRUE); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_WIRED_AUTO_NEGOTIATE, + PROP_AUTO_NEGOTIATE, + FALSE, + NM_SETTING_PARAM_NONE, + NMSettingWiredPrivate, + auto_negotiate, + .to_dbus_including_default = TRUE); /** * NMSettingWired:mac-address: @@ -1413,15 +1395,14 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) * permanent MAC address exists, the MAC address initially configured on the device. * ---end--- */ - obj_properties[PROP_MAC_ADDRESS] = g_param_spec_string( - NM_SETTING_WIRED_MAC_ADDRESS, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_MAC_ADDRESS], - &nm_sett_info_propert_type_mac_address); + _nm_setting_property_define_direct_mac_address(properties_override, + obj_properties, + NM_SETTING_WIRED_MAC_ADDRESS, + PROP_MAC_ADDRESS, + NM_SETTING_PARAM_INFERRABLE, + NMSettingWiredPrivate, + device_mac_address, + .direct_set_string_mac_address_len = ETH_ALEN); /** * NMSettingWired:cloned-mac-address: @@ -1472,9 +1453,14 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) "", NULL, G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_CLONED_MAC_ADDRESS], - &nm_sett_info_propert_type_cloned_mac_address); + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_CLONED_MAC_ADDRESS], + NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_BYTESTRING, + .compare_fcn = compare_fcn_cloned_mac_address, + .to_dbus_fcn = _nm_utils_hwaddr_cloned_get, + .from_dbus_fcn = _nm_utils_hwaddr_cloned_set, + .missing_from_dbus_fcn = _nm_utils_hwaddr_cloned_not_set, )); /* ---dbus--- * property: assigned-mac-address @@ -1531,12 +1517,13 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) * cloned-mac-address. * ---end--- */ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK, - PROP_GENERATE_MAC_ADDRESS_MASK, - NM_SETTING_PARAM_FUZZY_IGNORE, - nm_setting_wired_get_generate_mac_address_mask); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK, + PROP_GENERATE_MAC_ADDRESS_MASK, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingWiredPrivate, + generate_mac_address_mask); /** * NMSettingWired:mac-address-blacklist: @@ -1627,12 +1614,13 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) * example: NETTYPE=qeth * ---end--- */ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_WIRED_S390_NETTYPE, - PROP_S390_NETTYPE, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_wired_get_s390_nettype); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIRED_S390_NETTYPE, + PROP_S390_NETTYPE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingWiredPrivate, + s390_nettype); /** * NMSettingWired:s390-options: (type GHashTable(utf8,utf8)): @@ -1641,6 +1629,10 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) * and values must be strings. Allowed keys include "portno", "layer2", * "portname", "protocol", among others. Key names must contain only * alphanumeric characters (ie, [a-zA-Z0-9]). + * + * Currently, NetworkManager itself does nothing with this information. + * However, s390utils ships a udev rule which parses this information + * and applies it to the interface. **/ /* ---ifcfg-rh--- * property: s390-options @@ -1708,12 +1700,13 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) * example: ETHTOOL_OPTS="wol gs sopass 00:11:22:33:44:55" * ---end--- */ - _nm_setting_property_define_string(properties_override, - obj_properties, - NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, - PROP_WAKE_ON_LAN_PASSWORD, - NM_SETTING_PARAM_NONE, - nm_setting_wired_get_wake_on_lan_password); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, + PROP_WAKE_ON_LAN_PASSWORD, + NM_SETTING_PARAM_NONE, + NMSettingWiredPrivate, + wol_password); /** * NMSettingWired:accept-all-mac-addresses: @@ -1741,8 +1734,9 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_WIRED, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_WIRED, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-wireguard.c b/src/libnm-core-impl/nm-setting-wireguard.c index 3290ff56..27b81488 100644 --- a/src/libnm-core-impl/nm-setting-wireguard.c +++ b/src/libnm-core-impl/nm-setting-wireguard.c @@ -902,8 +902,8 @@ typedef struct { guint32 fwmark; guint32 mtu; guint16 listen_port; + bool peer_routes; bool private_key_valid : 1; - bool peer_routes : 1; } NMSettingWireGuardPrivate; /** @@ -1460,12 +1460,7 @@ nm_setting_wireguard_clear_peers(NMSettingWireGuard *self) /*****************************************************************************/ static GVariant * -_peers_dbus_only_synth(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +_peers_dbus_only_synth(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { NMSettingWireGuard * self = NM_SETTING_WIREGUARD(setting); NMSettingWireGuardPrivate *priv; @@ -1563,12 +1558,7 @@ _peers_dbus_only_synth(const NMSettInfoSetting * sett_info, } static gboolean -_peers_dbus_only_set(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +_peers_dbus_only_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GVariantIter iter_peers; GVariant * peer_var; @@ -1687,6 +1677,7 @@ _peers_dbus_only_set(NMSetting * setting, success = TRUE; out: + *out_is_modified = peers_changed; if (peers_changed) _peers_notify(setting); return success; @@ -1842,12 +1833,12 @@ need_secrets(NMSetting *setting) static gboolean clear_secrets(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMSetting * setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data) { - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_WIREGUARD_PEERS)) { + if (nm_streq(property_info->name, NM_SETTING_WIREGUARD_PEERS)) { NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting); gboolean peers_changed = FALSE; guint i, j; @@ -1894,7 +1885,7 @@ clear_secrets(const NMSettInfoSetting * sett_info, } return NM_SETTING_CLASS(nm_setting_wireguard_parent_class) - ->clear_secrets(sett_info, property_idx, setting, func, user_data); + ->clear_secrets(sett_info, property_info, setting, func, user_data); } static int @@ -1997,43 +1988,32 @@ update_one_secret(NMSetting *setting, const char *key, GVariant *value, GError * } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_fcn_peers(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) { NMSettingWireGuardPrivate *a_priv; NMSettingWireGuardPrivate *b_priv; guint i; - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_WIREGUARD_PEERS)) { - if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) - return NM_TERNARY_DEFAULT; - - if (!set_b) - return TRUE; + if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) + return NM_TERNARY_DEFAULT; - a_priv = NM_SETTING_WIREGUARD_GET_PRIVATE(set_a); - b_priv = NM_SETTING_WIREGUARD_GET_PRIVATE(set_b); + if (!set_b) + return TRUE; - if (a_priv->peers_arr->len != b_priv->peers_arr->len) - return FALSE; - for (i = 0; i < a_priv->peers_arr->len; i++) { - NMWireGuardPeer *a_peer = _peers_get(a_priv, i)->peer; - NMWireGuardPeer *b_peer = _peers_get(b_priv, i)->peer; + a_priv = NM_SETTING_WIREGUARD_GET_PRIVATE(set_a); + b_priv = NM_SETTING_WIREGUARD_GET_PRIVATE(set_b); - if (nm_wireguard_peer_cmp(a_peer, b_peer, flags) != 0) - return FALSE; - } + if (a_priv->peers_arr->len != b_priv->peers_arr->len) + return FALSE; + for (i = 0; i < a_priv->peers_arr->len; i++) { + NMWireGuardPeer *a_peer = _peers_get(a_priv, i)->peer; + NMWireGuardPeer *b_peer = _peers_get(b_priv, i)->peer; - return TRUE; + if (nm_wireguard_peer_cmp(a_peer, b_peer, flags) != 0) + return FALSE; } - return NM_SETTING_CLASS(nm_setting_wireguard_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + return TRUE; } static void @@ -2372,7 +2352,6 @@ nm_setting_wireguard_init(NMSettingWireGuard *setting) priv->peers_arr = g_ptr_array_new(); priv->peers_hash = g_hash_table_new(nm_pstr_hash, nm_pstr_equal); - priv->peer_routes = TRUE; priv->ip4_auto_default_route = NM_TERNARY_DEFAULT; priv->ip6_auto_default_route = NM_TERNARY_DEFAULT; } @@ -2422,7 +2401,6 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass) setting_class->need_secrets = need_secrets; setting_class->clear_secrets = clear_secrets; setting_class->update_one_secret = update_one_secret; - setting_class->compare_property = compare_property; setting_class->duplicate_copy_properties = duplicate_copy_properties; setting_class->enumerate_values = enumerate_values; setting_class->aggregate = aggregate; @@ -2514,13 +2492,14 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass) * * Since: 1.16 **/ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_WIREGUARD_PEER_ROUTES, - PROP_PEER_ROUTES, - TRUE, - NM_SETTING_PARAM_INFERRABLE, - nm_setting_wireguard_get_peer_routes); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_WIREGUARD_PEER_ROUTES, + PROP_PEER_ROUTES, + TRUE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingWireGuardPrivate, + peer_routes); /** * NMSettingWireGuard:mtu: @@ -2597,12 +2576,14 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass) NM_SETTING_WIREGUARD_PEERS, NM_SETT_INFO_PROPERT_TYPE_DBUS(NM_G_VARIANT_TYPE("aa{sv}"), .to_dbus_fcn = _peers_dbus_only_synth, + .compare_fcn = compare_fcn_peers, .from_dbus_fcn = _peers_dbus_only_set, )); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_WIREGUARD, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_WIREGUARD, + NULL, + properties_override, + G_STRUCT_OFFSET(NMSettingWireGuard, _priv)); } diff --git a/src/libnm-core-impl/nm-setting-wireless-security.c b/src/libnm-core-impl/nm-setting-wireless-security.c index 9e3c8d81..0bfc30c8 100644 --- a/src/libnm-core-impl/nm-setting-wireless-security.c +++ b/src/libnm-core-impl/nm-setting-wireless-security.c @@ -1290,13 +1290,19 @@ set_secret_flags(NMSetting * setting, ->set_secret_flags(setting, secret_name, flags, error); } -/* NMSettingWirelessSecurity:wep-key-type is an enum, but needs to be marshalled - * as 'u', not 'i', for backward-compatibility. - */ static GVariant * -wep_key_type_to_dbus(const GValue *from) +wep_key_type_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { - return g_variant_new_uint32(g_value_get_enum(from)); + NMWepKeyType t; + + t = nm_setting_wireless_security_get_wep_key_type(NM_SETTING_WIRELESS_SECURITY(setting)); + if (t == NM_WEP_KEY_TYPE_UNKNOWN) + return NULL; + + /* NMSettingWirelessSecurity:wep-key-type is an enum, but needs to be marshalled + * as 'u', not 'i', for backward-compatibility. + */ + return g_variant_new_uint32(t); } /*****************************************************************************/ @@ -1397,15 +1403,15 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps break; case PROP_PROTO: g_slist_free_full(priv->proto, g_free); - priv->proto = _nm_utils_strv_to_slist(g_value_get_boxed(value), TRUE); + priv->proto = nm_strv_to_gslist(g_value_get_boxed(value), TRUE); break; case PROP_PAIRWISE: g_slist_free_full(priv->pairwise, g_free); - priv->pairwise = _nm_utils_strv_to_slist(g_value_get_boxed(value), TRUE); + priv->pairwise = nm_strv_to_gslist(g_value_get_boxed(value), TRUE); break; case PROP_GROUP: g_slist_free_full(priv->group, g_free); - priv->group = _nm_utils_strv_to_slist(g_value_get_boxed(value), TRUE); + priv->group = nm_strv_to_gslist(g_value_get_boxed(value), TRUE); break; case PROP_PMF: priv->pmf = g_value_get_int(value); @@ -1924,10 +1930,14 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) NM_TYPE_WEP_KEY_TYPE, NM_WEP_KEY_TYPE_UNKNOWN, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_WEP_KEY_TYPE], - &nm_sett_info_propert_type_plain_u, - .to_dbus_data.gprop_to_dbus_fcn = wep_key_type_to_dbus, ); + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_WEP_KEY_TYPE], + NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_UINT32, + .to_dbus_fcn = wep_key_type_to_dbus, + .compare_fcn = _nm_setting_property_compare_fcn_default, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE)); /** * NMSettingWirelessSecurity:wps-method: @@ -1993,8 +2003,9 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_WIRELESS_SECURITY, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_WIRELESS_SECURITY, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-wireless.c b/src/libnm-core-impl/nm-setting-wireless.c index 5bdedf9b..f5a4cb6a 100644 --- a/src/libnm-core-impl/nm-setting-wireless.c +++ b/src/libnm-core-impl/nm-setting-wireless.c @@ -63,7 +63,7 @@ typedef struct { guint32 mtu; guint32 powersave; guint32 wowl; - bool hidden : 1; + bool hidden; } NMSettingWirelessPrivate; /** @@ -690,10 +690,7 @@ nm_setting_wireless_add_seen_bssid(NMSettingWireless *setting, const char *bssid if (!priv->seen_bssids) { priv->seen_bssids = g_ptr_array_new_with_free_func(g_free); } else { - if (nm_utils_strv_find_first((char **) priv->seen_bssids->pdata, - priv->seen_bssids->len, - lower_bssid) - >= 0) + if (nm_strv_ptrarray_find_first(priv->seen_bssids, lower_bssid) >= 0) return FALSE; } @@ -743,12 +740,7 @@ nm_setting_wireless_get_seen_bssid(NMSettingWireless *setting, guint32 i) } static GVariant * -_to_dbus_fcn_seen_bssids(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +_to_dbus_fcn_seen_bssids(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { if (options && options->seen_bssids) return options->seen_bssids[0] ? g_variant_new_strv(options->seen_bssids, -1) : NULL; @@ -769,12 +761,7 @@ _to_dbus_fcn_seen_bssids(const NMSettInfoSetting * sett_info, } static gboolean -_from_dbus_fcn_seen_bssids(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +_from_dbus_fcn_seen_bssids(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { NMSettingWirelessPrivate *priv; gs_free const char ** s = NULL; @@ -784,6 +771,7 @@ _from_dbus_fcn_seen_bssids(NMSetting * setting, if (_nm_utils_is_manager_process) { /* in the manager process, we don't accept seen-bssid from the client. * Do nothing. */ + *out_is_modified = FALSE; return TRUE; } @@ -1102,40 +1090,26 @@ mac_addr_rand_ok: } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_fcn_cloned_mac_address(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) { - if (sett_info->property_infos[property_idx].param_spec - == obj_properties[PROP_CLONED_MAC_ADDRESS]) { - return !set_b - || nm_streq0(NM_SETTING_WIRELESS_GET_PRIVATE(set_a)->cloned_mac_address, - NM_SETTING_WIRELESS_GET_PRIVATE(set_b)->cloned_mac_address); - } - if (sett_info->property_infos[property_idx].param_spec == obj_properties[PROP_SEEN_BSSIDS]) { - return !set_b - || (nm_strv_ptrarray_cmp(NM_SETTING_WIRELESS_GET_PRIVATE(set_a)->seen_bssids, - NM_SETTING_WIRELESS_GET_PRIVATE(set_b)->seen_bssids) - == 0); - } + return !set_b + || nm_streq0(NM_SETTING_WIRELESS_GET_PRIVATE(set_a)->cloned_mac_address, + NM_SETTING_WIRELESS_GET_PRIVATE(set_b)->cloned_mac_address); +} - return NM_SETTING_CLASS(nm_setting_wireless_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); +static NMTernary +compare_fcn_seen_bssids(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) +{ + return !set_b + || (nm_strv_ptrarray_cmp(NM_SETTING_WIRELESS_GET_PRIVATE(set_a)->seen_bssids, + NM_SETTING_WIRELESS_GET_PRIVATE(set_b)->seen_bssids) + == 0); } /*****************************************************************************/ static GVariant * -nm_setting_wireless_get_security(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +nm_setting_wireless_get_security(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { if (!_nm_connection_serialize_non_secret(flags)) return NULL; @@ -1182,9 +1156,6 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE(object); switch (prop_id) { - case PROP_SSID: - g_value_set_boxed(value, nm_setting_wireless_get_ssid(setting)); - break; case PROP_MODE: g_value_set_string(value, nm_setting_wireless_get_mode(setting)); break; @@ -1194,18 +1165,12 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) case PROP_CHANNEL: g_value_set_uint(value, nm_setting_wireless_get_channel(setting)); break; - case PROP_BSSID: - g_value_set_string(value, nm_setting_wireless_get_bssid(setting)); - break; case PROP_RATE: g_value_set_uint(value, nm_setting_wireless_get_rate(setting)); break; case PROP_TX_POWER: g_value_set_uint(value, nm_setting_wireless_get_tx_power(setting)); break; - case PROP_MAC_ADDRESS: - g_value_set_string(value, nm_setting_wireless_get_mac_address(setting)); - break; case PROP_CLONED_MAC_ADDRESS: g_value_set_string(value, nm_setting_wireless_get_cloned_mac_address(setting)); break; @@ -1219,14 +1184,11 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) g_value_set_uint(value, nm_setting_wireless_get_mtu(setting)); break; case PROP_SEEN_BSSIDS: - g_value_take_boxed(value, - priv->seen_bssids ? nm_utils_strv_dup((char **) priv->seen_bssids->pdata, - priv->seen_bssids->len, - TRUE) - : NULL); - break; - case PROP_HIDDEN: - g_value_set_boolean(value, nm_setting_wireless_get_hidden(setting)); + g_value_take_boxed( + value, + priv->seen_bssids + ? nm_strv_dup((char **) priv->seen_bssids->pdata, priv->seen_bssids->len, TRUE) + : NULL); break; case PROP_POWERSAVE: g_value_set_uint(value, nm_setting_wireless_get_powersave(setting)); @@ -1241,7 +1203,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) g_value_set_enum(value, priv->ap_isolation); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_get_property_direct(object, prop_id, value, pspec); break; } } @@ -1255,11 +1217,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps gboolean bool_val; switch (prop_id) { - case PROP_SSID: - if (priv->ssid) - g_bytes_unref(priv->ssid); - priv->ssid = g_value_dup_boxed(value); - break; case PROP_MODE: g_free(priv->mode); priv->mode = g_value_dup_string(value); @@ -1271,21 +1228,12 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps case PROP_CHANNEL: priv->channel = g_value_get_uint(value); break; - case PROP_BSSID: - g_free(priv->bssid); - priv->bssid = g_value_dup_string(value); - break; case PROP_RATE: priv->rate = g_value_get_uint(value); break; case PROP_TX_POWER: priv->tx_power = g_value_get_uint(value); break; - case PROP_MAC_ADDRESS: - g_free(priv->device_mac_address); - priv->device_mac_address = - _nm_utils_hwaddr_canonical_or_invalid(g_value_get_string(value), ETH_ALEN); - break; case PROP_CLONED_MAC_ADDRESS: bool_val = !!priv->cloned_mac_address; g_free(priv->cloned_mac_address); @@ -1337,9 +1285,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps } break; } - case PROP_HIDDEN: - priv->hidden = g_value_get_boolean(value); - break; case PROP_POWERSAVE: priv->powersave = g_value_get_uint(value); break; @@ -1353,7 +1298,7 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps priv->ap_isolation = g_value_get_enum(value); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_set_property_direct(object, prop_id, value, pspec); break; } } @@ -1394,10 +1339,6 @@ finalize(GObject *object) g_free(priv->mode); g_free(priv->band); - if (priv->ssid) - g_bytes_unref(priv->ssid); - g_free(priv->bssid); - g_free(priv->device_mac_address); g_free(priv->cloned_mac_address); g_free(priv->generate_mac_address_mask); g_array_unref(priv->mac_address_blacklist); @@ -1419,8 +1360,7 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) object_class->get_property = get_property; object_class->finalize = finalize; - setting_class->verify = verify; - setting_class->compare_property = compare_property; + setting_class->verify = verify; /** * NMSettingWireless:ssid: @@ -1440,11 +1380,13 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) * example: ESSID="Quick Net" * ---end--- */ - obj_properties[PROP_SSID] = g_param_spec_boxed(NM_SETTING_WIRELESS_SSID, - "", - "", - G_TYPE_BYTES, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_bytes(properties_override, + obj_properties, + NM_SETTING_WIRELESS_SSID, + PROP_SSID, + NM_SETTING_PARAM_NONE, + NMSettingWirelessPrivate, + ssid); /** * NMSettingWireless:mode: @@ -1530,14 +1472,14 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) * example: BSSID=00:1E:BD:64:83:21 * ---end--- */ - obj_properties[PROP_BSSID] = g_param_spec_string(NM_SETTING_WIRELESS_BSSID, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_BSSID], - &nm_sett_info_propert_type_mac_address); + _nm_setting_property_define_direct_mac_address(properties_override, + obj_properties, + NM_SETTING_WIRELESS_BSSID, + PROP_BSSID, + NM_SETTING_PARAM_NONE, + NMSettingWirelessPrivate, + bssid, + .direct_set_string_mac_address_len = ETH_ALEN); /** * NMSettingWireless:rate: @@ -1608,15 +1550,14 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) * permanent MAC address exists, the MAC address initially configured on the device. * ---end--- */ - obj_properties[PROP_MAC_ADDRESS] = - g_param_spec_string(NM_SETTING_WIRELESS_MAC_ADDRESS, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_MAC_ADDRESS], - &nm_sett_info_propert_type_mac_address); + _nm_setting_property_define_direct_mac_address(properties_override, + obj_properties, + NM_SETTING_WIRELESS_MAC_ADDRESS, + PROP_MAC_ADDRESS, + NM_SETTING_PARAM_NONE, + NMSettingWirelessPrivate, + device_mac_address, + .direct_set_string_mac_address_len = ETH_ALEN); /** * NMSettingWireless:cloned-mac-address: @@ -1666,9 +1607,14 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) "", NULL, G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj(properties_override, - obj_properties[PROP_CLONED_MAC_ADDRESS], - &nm_sett_info_propert_type_cloned_mac_address); + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_CLONED_MAC_ADDRESS], + NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_BYTESTRING, + .compare_fcn = compare_fcn_cloned_mac_address, + .to_dbus_fcn = _nm_utils_hwaddr_cloned_get, + .from_dbus_fcn = _nm_utils_hwaddr_cloned_set, + .missing_from_dbus_fcn = _nm_utils_hwaddr_cloned_not_set, )); /* ---dbus--- * property: assigned-mac-address @@ -1786,7 +1732,8 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) obj_properties[PROP_SEEN_BSSIDS], NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_STRING_ARRAY, .to_dbus_fcn = _to_dbus_fcn_seen_bssids, - .from_dbus_fcn = _from_dbus_fcn_seen_bssids, )); + .from_dbus_fcn = _from_dbus_fcn_seen_bssids, + .compare_fcn = compare_fcn_seen_bssids, )); /** * NMSettingWireless:mtu: @@ -1833,13 +1780,14 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) * description: Whether the network hides the SSID. * ---end--- */ - _nm_setting_property_define_boolean(properties_override, - obj_properties, - NM_SETTING_WIRELESS_HIDDEN, - PROP_HIDDEN, - FALSE, - NM_SETTING_PARAM_NONE, - nm_setting_wireless_get_hidden); + _nm_setting_property_define_direct_boolean(properties_override, + obj_properties, + NM_SETTING_WIRELESS_HIDDEN, + PROP_HIDDEN, + FALSE, + NM_SETTING_PARAM_NONE, + NMSettingWirelessPrivate, + hidden); /** * NMSettingWireless:powersave: @@ -1916,7 +1864,8 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) properties_override, "security", NM_SETT_INFO_PROPERT_TYPE_DBUS(G_VARIANT_TYPE_STRING, - .to_dbus_fcn = nm_setting_wireless_get_security, )); + .to_dbus_fcn = nm_setting_wireless_get_security, + .compare_fcn = _nm_setting_property_compare_fcn_ignore, )); /** * NMSettingWireless:wake-on-wlan: @@ -1985,8 +1934,9 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit_full(setting_class, - NM_META_SETTING_TYPE_WIRELESS, - NULL, - properties_override); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_WIRELESS, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting-wpan.c b/src/libnm-core-impl/nm-setting-wpan.c index 28a6478f..78cdc036 100644 --- a/src/libnm-core-impl/nm-setting-wpan.c +++ b/src/libnm-core-impl/nm-setting-wpan.c @@ -22,15 +22,15 @@ /* Ideally we'll be able to get these from a public header. */ #ifndef IEEE802154_ADDR_LEN - #define IEEE802154_ADDR_LEN 8 +#define IEEE802154_ADDR_LEN 8 #endif #ifndef IEEE802154_MAX_PAGE - #define IEEE802154_MAX_PAGE 31 +#define IEEE802154_MAX_PAGE 31 #endif #ifndef IEEE802154_MAX_CHANNEL - #define IEEE802154_MAX_CHANNEL 26 +#define IEEE802154_MAX_CHANNEL 26 #endif /*****************************************************************************/ @@ -43,10 +43,10 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_MAC_ADDRESS, typedef struct { char * mac_address; - guint16 pan_id; - guint16 short_address; - gint16 page; - gint16 channel; + guint32 pan_id; + guint32 short_address; + gint32 page; + gint32 channel; } NMSettingWpanPrivate; /** @@ -200,74 +200,9 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingWpan *setting = NM_SETTING_WPAN(object); - - switch (prop_id) { - case PROP_MAC_ADDRESS: - g_value_set_string(value, nm_setting_wpan_get_mac_address(setting)); - break; - case PROP_PAN_ID: - g_value_set_uint(value, nm_setting_wpan_get_pan_id(setting)); - break; - case PROP_SHORT_ADDRESS: - g_value_set_uint(value, nm_setting_wpan_get_short_address(setting)); - break; - case PROP_PAGE: - g_value_set_int(value, nm_setting_wpan_get_page(setting)); - break; - case PROP_CHANNEL: - g_value_set_int(value, nm_setting_wpan_get_channel(setting)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingWpanPrivate *priv = NM_SETTING_WPAN_GET_PRIVATE(object); - - switch (prop_id) { - case PROP_MAC_ADDRESS: - g_free(priv->mac_address); - priv->mac_address = - _nm_utils_hwaddr_canonical_or_invalid(g_value_get_string(value), IEEE802154_ADDR_LEN); - break; - case PROP_PAN_ID: - priv->pan_id = g_value_get_uint(value); - break; - case PROP_SHORT_ADDRESS: - priv->short_address = g_value_get_uint(value); - break; - case PROP_PAGE: - priv->page = g_value_get_int(value); - break; - case PROP_CHANNEL: - priv->channel = g_value_get_int(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - static void nm_setting_wpan_init(NMSettingWpan *setting) -{ - NMSettingWpanPrivate *priv = NM_SETTING_WPAN_GET_PRIVATE(setting); - - priv->pan_id = G_MAXUINT16; - priv->short_address = G_MAXUINT16; - priv->page = NM_SETTING_WPAN_PAGE_DEFAULT; - priv->channel = NM_SETTING_WPAN_CHANNEL_DEFAULT; -} +{} /** * nm_setting_wpan_new: @@ -284,27 +219,17 @@ nm_setting_wpan_new(void) return g_object_new(NM_TYPE_SETTING_WPAN, NULL); } -static void -finalize(GObject *object) -{ - NMSettingWpanPrivate *priv = NM_SETTING_WPAN_GET_PRIVATE(object); - - g_free(priv->mac_address); - - G_OBJECT_CLASS(nm_setting_wpan_parent_class)->finalize(object); -} - static void nm_setting_wpan_class_init(NMSettingWpanClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMSettingClass *setting_class = NM_SETTING_CLASS(klass); + GObjectClass * object_class = G_OBJECT_CLASS(klass); + NMSettingClass *setting_class = NM_SETTING_CLASS(klass); + GArray * properties_override = _nm_sett_info_property_override_create_array(); g_type_class_add_private(setting_class, sizeof(NMSettingWpanPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -321,39 +246,47 @@ nm_setting_wpan_class_init(NMSettingWpanClass *klass) * (e.g. 76:d8:9b:87:66:60:84:ee). * ---end--- */ - obj_properties[PROP_MAC_ADDRESS] = - g_param_spec_string(NM_SETTING_WPAN_MAC_ADDRESS, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WPAN_MAC_ADDRESS, + PROP_MAC_ADDRESS, + NM_SETTING_PARAM_NONE, + NMSettingWpanPrivate, + mac_address, + .direct_set_string_mac_address_len = + IEEE802154_ADDR_LEN); /** * NMSettingWpan:pan-id: * * IEEE 802.15.4 Personal Area Network (PAN) identifier. **/ - obj_properties[PROP_PAN_ID] = g_param_spec_uint(NM_SETTING_WPAN_PAN_ID, - "", - "", - 0, - G_MAXUINT16, - G_MAXUINT16, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_WPAN_PAN_ID, + PROP_PAN_ID, + 0, + G_MAXUINT16, + G_MAXUINT16, + NM_SETTING_PARAM_NONE, + NMSettingWpanPrivate, + pan_id); /** * NMSettingWpan:short-address: * * Short IEEE 802.15.4 address to be used within a restricted environment. **/ - obj_properties[PROP_SHORT_ADDRESS] = - g_param_spec_uint(NM_SETTING_WPAN_SHORT_ADDRESS, - "", - "", - 0, - G_MAXUINT16, - G_MAXUINT16, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_WPAN_SHORT_ADDRESS, + PROP_SHORT_ADDRESS, + 0, + G_MAXUINT16, + G_MAXUINT16, + NM_SETTING_PARAM_NONE, + NMSettingWpanPrivate, + short_address); /** * NMSettingWpan:page: @@ -363,13 +296,16 @@ nm_setting_wpan_class_init(NMSettingWpanClass *klass) * * Since: 1.16 **/ - obj_properties[PROP_PAGE] = g_param_spec_int(NM_SETTING_WPAN_PAGE, - "", - "", - G_MININT16, - G_MAXINT16, - NM_SETTING_WPAN_PAGE_DEFAULT, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_WPAN_PAGE, + PROP_PAGE, + G_MININT16, + G_MAXINT16, + NM_SETTING_WPAN_PAGE_DEFAULT, + NM_SETTING_PARAM_NONE, + NMSettingWpanPrivate, + page); /** * NMSettingWpan:channel: @@ -379,15 +315,22 @@ nm_setting_wpan_class_init(NMSettingWpanClass *klass) * * Since: 1.16 **/ - obj_properties[PROP_CHANNEL] = g_param_spec_int(NM_SETTING_WPAN_CHANNEL, - "", - "", - G_MININT16, - G_MAXINT16, - NM_SETTING_WPAN_CHANNEL_DEFAULT, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_WPAN_CHANNEL, + PROP_CHANNEL, + G_MININT16, + G_MAXINT16, + NM_SETTING_WPAN_CHANNEL_DEFAULT, + NM_SETTING_PARAM_NONE, + NMSettingWpanPrivate, + channel); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_WPAN); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_WPAN, + NULL, + properties_override, + NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); } diff --git a/src/libnm-core-impl/nm-setting.c b/src/libnm-core-impl/nm-setting.c index 54e1a176..9ef9e96c 100644 --- a/src/libnm-core-impl/nm-setting.c +++ b/src/libnm-core-impl/nm-setting.c @@ -54,6 +54,9 @@ G_DEFINE_ABSTRACT_TYPE(NMSetting, nm_setting, G_TYPE_OBJECT) /*****************************************************************************/ static GenData *_gendata_hash(NMSetting *setting, gboolean create_if_necessary); +static gboolean set_property_from_dbus(const NMSettInfoProperty *property_info, + GVariant * src_value, + GValue * dst_value); /*****************************************************************************/ @@ -171,12 +174,15 @@ _nm_properties_override_assert(const NMSettInfoProperty *prop_info) /* we always require a dbus_type. */ nm_assert(property_type->dbus_type); - /* from_dbus_fcn and gprop_from_dbus_fcn cannot both be set. */ - nm_assert(!property_type->from_dbus_fcn || !property_type->gprop_from_dbus_fcn); + if (property_type->typdata_from_dbus.gprop_fcn) + nm_assert(property_type->from_dbus_fcn == _nm_setting_property_from_dbus_fcn_gprop); + + if (property_type->from_dbus_fcn == _nm_setting_property_from_dbus_fcn_gprop) + nm_assert(prop_info->param_spec); if (!prop_info->param_spec) { - /* if we don't have a param_spec, we cannot have gprop_from_dbus_fcn. */ - nm_assert(property_type->from_dbus_fcn || !property_type->gprop_from_dbus_fcn); + /* if we don't have a param_spec, we cannot have typdata_from_dbus.gprop_fcn. */ + nm_assert(property_type->from_dbus_fcn || !property_type->typdata_from_dbus.gprop_fcn); } } #endif @@ -227,11 +233,11 @@ _property_infos_sort_cmp_setting_connection(gconstpointer p_a, static const NMSettInfoProperty *const * _property_infos_sort(const NMSettInfoProperty *property_infos, - guint property_infos_len, + guint16 property_infos_len, NMSettingClass * setting_class) { const NMSettInfoProperty **arr; - guint i; + guint16 i; #if NM_MORE_ASSERTS > 5 /* assert that the property names are all unique and sorted. */ @@ -263,15 +269,30 @@ _property_infos_sort(const NMSettInfoProperty *property_infos, return arr; } +static int +_property_lookup_by_param_spec_sort(gconstpointer p_a, gconstpointer p_b, gpointer user_data) +{ + const NMSettInfoPropertLookupByParamSpec *a = p_a; + const NMSettInfoPropertLookupByParamSpec *b = p_b; + + NM_CMP_DIRECT(a->param_spec_as_uint, b->param_spec_as_uint); + return 0; +} + void -_nm_setting_class_commit_full(NMSettingClass * setting_class, - NMMetaSettingType meta_type, - const NMSettInfoSettDetail *detail, - GArray * properties_override) +_nm_setting_class_commit(NMSettingClass * setting_class, + NMMetaSettingType meta_type, + const NMSettInfoSettDetail *detail, + GArray * properties_override, + gint16 private_offset) { NMSettInfoSetting *sett_info; - gs_free GParamSpec **property_specs = NULL; - guint i, n_property_specs, override_len; + gs_free GParamSpec ** property_specs = NULL; + guint n_property_specs; + NMSettInfoPropertLookupByParamSpec *lookup_by_iter; + guint override_len; + guint i; + guint16 j; nm_assert(NM_IS_SETTING_CLASS(setting_class)); nm_assert(!setting_class->setting_info); @@ -284,25 +305,26 @@ _nm_setting_class_commit_full(NMSettingClass * setting_class, nm_assert(!sett_info->property_infos_len); nm_assert(!sett_info->property_infos); + property_specs = + g_object_class_list_properties(G_OBJECT_CLASS(setting_class), &n_property_specs); + if (!properties_override) { override_len = 0; - properties_override = _nm_sett_info_property_override_create_array(); - } else + properties_override = _nm_sett_info_property_override_create_array_sized(n_property_specs); + } else { override_len = properties_override->len; - property_specs = - g_object_class_list_properties(G_OBJECT_CLASS(setting_class), &n_property_specs); - - for (i = 0; i < properties_override->len; i++) { - NMSettInfoProperty *p = &g_array_index(properties_override, NMSettInfoProperty, i); + for (i = 0; i < override_len; i++) { + NMSettInfoProperty *p = &g_array_index(properties_override, NMSettInfoProperty, i); - nm_assert((!!p->name) != (!!p->param_spec)); + nm_assert((!!p->name) != (!!p->param_spec)); - if (!p->name) { - nm_assert(p->param_spec); - p->name = p->param_spec->name; - } else - nm_assert(!p->param_spec); + if (!p->name) { + nm_assert(p->param_spec); + p->name = p->param_spec->name; + } else + nm_assert(!p->param_spec); + } } #if NM_MORE_ASSERTS > 10 @@ -310,18 +332,18 @@ _nm_setting_class_commit_full(NMSettingClass * setting_class, for (i = 0; i < override_len; i++) { const NMSettInfoProperty *p = &g_array_index(properties_override, NMSettInfoProperty, i); gboolean found = FALSE; - guint j; + guint k; nm_assert( !_nm_sett_info_property_find_in_array((NMSettInfoProperty *) properties_override->data, i, p->name)); - for (j = 0; j < n_property_specs; j++) { - if (!nm_streq(property_specs[j]->name, p->name)) + for (k = 0; k < n_property_specs; k++) { + if (!nm_streq(property_specs[k]->name, p->name)) continue; nm_assert(!found); found = TRUE; - nm_assert(p->param_spec == property_specs[j]); + nm_assert(p->param_spec == property_specs[k]); } nm_assert(found == (p->param_spec != NULL)); } @@ -353,36 +375,54 @@ _nm_setting_class_commit_full(NMSettingClass * setting_class, nm_assert(p->param_spec); vtype = p->param_spec->value_type; - if (vtype == G_TYPE_BOOLEAN) - p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(G_VARIANT_TYPE_BOOLEAN); - else if (vtype == G_TYPE_UCHAR) - p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(G_VARIANT_TYPE_BYTE); - else if (vtype == G_TYPE_INT) + if (vtype == G_TYPE_INT) p->property_type = &nm_sett_info_propert_type_plain_i; else if (vtype == G_TYPE_UINT) p->property_type = &nm_sett_info_propert_type_plain_u; else if (vtype == G_TYPE_INT64) - p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(G_VARIANT_TYPE_INT64); - else if (vtype == G_TYPE_UINT64) - p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(G_VARIANT_TYPE_UINT64); - else if (vtype == G_TYPE_STRING) - p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(G_VARIANT_TYPE_STRING); - else if (vtype == G_TYPE_DOUBLE) - p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(G_VARIANT_TYPE_DOUBLE); + p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP( + G_VARIANT_TYPE_INT64, + .compare_fcn = _nm_setting_property_compare_fcn_default, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE); + else if (vtype == G_TYPE_STRING) { + nm_assert(nm_streq(p->name, NM_SETTING_NAME) + == (!NM_FLAGS_HAS(p->param_spec->flags, G_PARAM_WRITABLE))); + if (!NM_FLAGS_HAS(p->param_spec->flags, G_PARAM_WRITABLE)) + p->property_type = &nm_sett_info_propert_type_setting_name; + else { + p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP( + G_VARIANT_TYPE_STRING, + .compare_fcn = _nm_setting_property_compare_fcn_default, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE); + } + } else if (vtype == G_TYPE_DOUBLE) + p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP( + G_VARIANT_TYPE_DOUBLE, + .compare_fcn = _nm_setting_property_compare_fcn_default, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE); else if (vtype == G_TYPE_STRV) - p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(G_VARIANT_TYPE_STRING_ARRAY); - else if (vtype == G_TYPE_BYTES) { p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP( - G_VARIANT_TYPE_BYTESTRING, - .typdata_to_dbus.gprop_type = NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_BYTES); - } else if (g_type_is_a(vtype, G_TYPE_ENUM)) { + G_VARIANT_TYPE_STRING_ARRAY, + .compare_fcn = _nm_setting_property_compare_fcn_default, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE); + else if (g_type_is_a(vtype, G_TYPE_ENUM)) { p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP( G_VARIANT_TYPE_INT32, - .typdata_to_dbus.gprop_type = NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_ENUM); + .typdata_to_dbus.gprop_type = NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_ENUM, + .compare_fcn = _nm_setting_property_compare_fcn_default, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE); } else if (g_type_is_a(vtype, G_TYPE_FLAGS)) { p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP( G_VARIANT_TYPE_UINT32, - .typdata_to_dbus.gprop_type = NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_FLAGS); + .typdata_to_dbus.gprop_type = NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_FLAGS, + .compare_fcn = _nm_setting_property_compare_fcn_default, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE); } else nm_assert_not_reached(); @@ -397,9 +437,22 @@ has_property_type: setting_class->setting_info = &nm_meta_setting_infos[meta_type]; sett_info->setting_class = setting_class; + + if (private_offset == NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS) { + int o; + + o = g_type_class_get_instance_private_offset(setting_class); + nm_assert(o != NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); + nm_assert(o > G_MININT16); + nm_assert(o < 0); + private_offset = o; + } + sett_info->private_offset = private_offset; + if (detail) sett_info->detail = *detail; nm_assert(properties_override->len > 0); + nm_assert(properties_override->len < G_MAXUINT16); sett_info->property_infos_len = properties_override->len; sett_info->property_infos = nm_memdup(properties_override->data, sizeof(NMSettInfoProperty) * properties_override->len); @@ -408,6 +461,33 @@ has_property_type: sett_info->property_infos_len, setting_class); + nm_assert(sett_info->property_infos_len < G_MAXUINT16); + sett_info->property_lookup_by_param_spec_len = 0; + for (j = 0; j < sett_info->property_infos_len; j++) { + if (sett_info->property_infos[j].param_spec) { + sett_info->property_lookup_by_param_spec_len++; + } + } + sett_info->property_lookup_by_param_spec = + g_new(NMSettInfoPropertLookupByParamSpec, sett_info->property_lookup_by_param_spec_len); + lookup_by_iter = + (NMSettInfoPropertLookupByParamSpec *) sett_info->property_lookup_by_param_spec; + for (j = 0; j < sett_info->property_infos_len; j++) { + const NMSettInfoProperty *property_info = &sett_info->property_infos[j]; + + if (property_info->param_spec) { + *(lookup_by_iter++) = (NMSettInfoPropertLookupByParamSpec){ + .param_spec_as_uint = (uintptr_t) ((gpointer) property_info->param_spec), + .property_info = property_info, + }; + } + } + g_qsort_with_data(sett_info->property_lookup_by_param_spec, + sett_info->property_lookup_by_param_spec_len, + sizeof(NMSettInfoPropertLookupByParamSpec), + _property_lookup_by_param_spec_sort, + NULL); + g_array_free(properties_override, TRUE); } @@ -415,7 +495,7 @@ const NMSettInfoProperty * _nm_sett_info_setting_get_property_info(const NMSettInfoSetting *sett_info, const char * property_name) { - const NMSettInfoProperty *property; + const NMSettInfoProperty *property_info; gssize idx; nm_assert(property_name); @@ -434,13 +514,13 @@ _nm_sett_info_setting_get_property_info(const NMSettInfoSetting *sett_info, if (idx < 0) return NULL; - property = &sett_info->property_infos[idx]; + property_info = &sett_info->property_infos[idx]; - nm_assert(idx == 0 || strcmp(property[-1].name, property[0].name) < 0); + nm_assert(idx == 0 || strcmp(property_info[-1].name, property_info[0].name) < 0); nm_assert(idx == sett_info->property_infos_len - 1 - || strcmp(property[0].name, property[1].name) < 0); + || strcmp(property_info[0].name, property_info[1].name) < 0); - return property; + return property_info; } const NMSettInfoSetting * @@ -457,6 +537,47 @@ _nm_setting_class_get_sett_info(NMSettingClass *setting_class) return sett_info; } +const NMSettInfoProperty * +_nm_sett_info_property_lookup_by_param_spec(const NMSettInfoSetting *sett_info, + const GParamSpec * param_spec) +{ + NMSettInfoPropertLookupByParamSpec needle; + int imin; + int imax; + int imid; + int cmp; + + nm_assert(sett_info); + nm_assert(param_spec); + + /* ensure that "int" is large enough to contain the index variables. */ + G_STATIC_ASSERT_EXPR(sizeof(int) > sizeof(sett_info->property_lookup_by_param_spec_len)); + + if (sett_info->property_lookup_by_param_spec_len == 0) + return NULL; + + needle.param_spec_as_uint = (uintptr_t) ((gpointer) param_spec); + + imin = 0; + imax = sett_info->property_lookup_by_param_spec_len - 1; + while (imin <= imax) { + imid = imin + (imax - imin) / 2; + + cmp = _property_lookup_by_param_spec_sort(&sett_info->property_lookup_by_param_spec[imid], + &needle, + NULL); + if (cmp == 0) + return sett_info->property_lookup_by_param_spec[imid].property_info; + + if (cmp < 0) + imin = imid + 1; + else + imax = imid - 1; + } + + return NULL; +} + /*****************************************************************************/ void @@ -494,180 +615,1015 @@ _nm_setting_use_legacy_property(NMSetting * setting, const char *legacy_property, const char *new_property) { - GVariant *setting_dict, *value; + gs_unref_variant GVariant *setting_dict = NULL; + gs_unref_variant GVariant *value = NULL; + + if (!connection_dict) { + /* we also allow the caller to provide no connection_dict. + * + * We hit this code bug when being called by update_one_secret(). + * In this case, we use the legacy property, because we are not + * sophisticated enough to mediate between deprecated and legacy + * properties... + * + * However, in practice this code is unreachable, because update_one_secret() + * only ends up calling from_dbus_fcn() for certain properties, and none + * of those are actually deprecated (for now). So this cannot really happen. */ + return nm_assert_unreachable_val(FALSE); + } setting_dict = g_variant_lookup_value(connection_dict, nm_setting_get_name(NM_SETTING(setting)), NM_VARIANT_TYPE_SETTING); + g_return_val_if_fail(setting_dict != NULL, FALSE); /* If the new property isn't set, we have to use the legacy property. */ value = g_variant_lookup_value(setting_dict, new_property, NULL); - if (!value) { - g_variant_unref(setting_dict); + if (!value) return TRUE; + nm_clear_pointer(&value, g_variant_unref); + + /* Otherwise, clients always prefer new properties sent from the daemon. */ + if (!_nm_utils_is_manager_process) + return FALSE; + + /* The daemon prefers the legacy property if it exists. */ + value = g_variant_lookup_value(setting_dict, legacy_property, NULL); + return !!value; +} + +/*****************************************************************************/ + +static gboolean +_property_direct_set_string(const NMSettInfoProperty *property_info, char **dst, const char *src) +{ + if (property_info->direct_set_string_ascii_strdown) + return nm_strdup_reset_take(dst, src ? g_ascii_strdown(src, -1) : NULL); + if (property_info->direct_set_string_mac_address_len > 0) { + return nm_strdup_reset_take(dst, + _nm_utils_hwaddr_canonical_or_invalid( + src, + property_info->direct_set_string_mac_address_len)); + } + if (property_info->direct_set_string_ip_address_addr_family != 0) { + return nm_strdup_reset_take(dst, + _nm_utils_ipaddr_canonical_or_invalid( + property_info->direct_set_string_ip_address_addr_family, + src)); + } + return nm_strdup_reset(dst, src); +} + +void +_nm_setting_property_get_property_direct(GObject * object, + guint prop_id, + GValue * value, + GParamSpec *pspec) +{ + NMSetting * setting = NM_SETTING(object); + const NMSettInfoSetting * sett_info; + const NMSettInfoProperty *property_info; + + sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); + nm_assert(sett_info); + + property_info = _nm_sett_info_property_lookup_by_param_spec(sett_info, pspec); + if (!property_info) + goto out_fail; + + nm_assert(property_info->param_spec == pspec); + + switch (property_info->property_type->direct_type) { + case NM_VALUE_TYPE_BOOL: + { + const bool *p_val = + _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + + g_value_set_boolean(value, *p_val); + return; + } + case NM_VALUE_TYPE_INT32: + { + const gint32 *p_val = + _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + + g_value_set_int(value, *p_val); + return; + } + case NM_VALUE_TYPE_UINT32: + { + const guint32 *p_val = + _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + + g_value_set_uint(value, *p_val); + return; + } + case NM_VALUE_TYPE_UINT64: + { + const guint64 *p_val = + _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + + g_value_set_uint64(value, *p_val); + return; + } + case NM_VALUE_TYPE_ENUM: + { + const int *p_val = + _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + + g_value_set_enum(value, *p_val); + return; + } + case NM_VALUE_TYPE_FLAGS: + { + const guint *p_val = + _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + + g_value_set_flags(value, *p_val); + return; + } + case NM_VALUE_TYPE_STRING: + { + const char *const *p_val = + _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + + g_value_set_string(value, *p_val); + return; + } + case NM_VALUE_TYPE_BYTES: + { + const GBytes *const *p_val = + _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + + g_value_set_boxed(value, *p_val); + return; + } + default: + goto out_fail; + } + + return; + +out_fail: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); +} + +void +_nm_setting_property_set_property_direct(GObject * object, + guint prop_id, + const GValue *value, + GParamSpec * pspec) +{ + NMSetting * setting = NM_SETTING(object); + const NMSettInfoSetting * sett_info; + const NMSettInfoProperty *property_info; + + sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); + nm_assert(sett_info); + + property_info = _nm_sett_info_property_lookup_by_param_spec(sett_info, pspec); + if (!property_info) + goto out_fail; + + nm_assert(property_info->param_spec == pspec); + + switch (property_info->property_type->direct_type) { + case NM_VALUE_TYPE_BOOL: + { + bool * p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + gboolean v; + + v = g_value_get_boolean(value); + if (*p_val == v) + return; + *p_val = v; + goto out_notify; + } + case NM_VALUE_TYPE_INT32: + { + gint32 *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + int v; + + v = g_value_get_int(value); + if (*p_val == v) + return; + *p_val = v; + + /* truncation cannot happen, because the param_spec is supposed to have suitable + * minimum/maximum values so that we are in range for int32. */ + nm_assert(*p_val == v); + goto out_notify; + } + case NM_VALUE_TYPE_UINT32: + { + guint32 *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + guint v; + + v = g_value_get_uint(value); + if (*p_val == v) + return; + *p_val = v; + + /* truncation cannot happen, because the param_spec is supposed to have suitable + * minimum/maximum values so that we are in range for uint32. */ + nm_assert(*p_val == v); + goto out_notify; + } + case NM_VALUE_TYPE_UINT64: + { + guint64 *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + guint64 v; + + v = g_value_get_uint64(value); + if (*p_val == v) + return; + *p_val = v; + goto out_notify; + } + case NM_VALUE_TYPE_ENUM: + { + int *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + int v; + + v = g_value_get_enum(value); + if (*p_val == v) + return; + *p_val = v; + goto out_notify; + } + case NM_VALUE_TYPE_FLAGS: + { + guint *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + guint v; + + v = g_value_get_flags(value); + if (*p_val == v) + return; + *p_val = v; + goto out_notify; + } + case NM_VALUE_TYPE_STRING: + if (!_property_direct_set_string( + property_info, + _nm_setting_get_private(setting, sett_info, property_info->direct_offset), + g_value_get_string(value))) + return; + goto out_notify; + case NM_VALUE_TYPE_BYTES: + { + GBytes **p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + GBytes * v; + _nm_unused gs_unref_bytes GBytes *old = NULL; + + v = g_value_get_boxed(value); + if (nm_g_bytes_equal0(*p_val, v)) + return; + old = *p_val; + *p_val = v ? g_bytes_ref(v) : NULL; + goto out_notify; + } + default: + goto out_fail; + } + + return; + +out_notify: + /* If explicit-notify would be set, we would need to emit g_object_notify_by_pspec(). + * + * Currently we never set that, also because we still support glib 2.40. */ + nm_assert(!NM_FLAGS_HAS(pspec->flags, 1 << 30 /* G_PARAM_EXPLICIT_NOTIFY */)); + return; + +out_fail: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); +} + +/*****************************************************************************/ + +static void +_init_direct(NMSetting *setting) +{ + const NMSettInfoSetting *sett_info; + guint16 i; + + sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); + nm_assert(sett_info); + + for (i = 0; i < sett_info->property_infos_len; i++) { + const NMSettInfoProperty *property_info = &sett_info->property_infos[i]; + + /* We don't emit any g_object_notify_by_pspec(), because this is + * only supposed to be called during initialization of the GObject + * instance. */ + + switch (property_info->property_type->direct_type) { + case NM_VALUE_TYPE_NONE: + break; + case NM_VALUE_TYPE_BOOL: + { + bool *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + gboolean def_val; + + def_val = NM_G_PARAM_SPEC_GET_DEFAULT_BOOLEAN(property_info->param_spec); + nm_assert(*p_val == FALSE); + *p_val = def_val; + break; + } + case NM_VALUE_TYPE_INT32: + { + gint32 *p_val = + _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + int def_val; + + def_val = NM_G_PARAM_SPEC_GET_DEFAULT_INT(property_info->param_spec); + nm_assert(*p_val == 0); + *p_val = def_val; + break; + } + case NM_VALUE_TYPE_UINT32: + { + guint32 *p_val = + _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + guint def_val; + + def_val = NM_G_PARAM_SPEC_GET_DEFAULT_UINT(property_info->param_spec); + nm_assert(*p_val == 0); + *p_val = def_val; + break; + } + case NM_VALUE_TYPE_UINT64: + { + guint64 *p_val = + _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + guint64 def_val; + + def_val = NM_G_PARAM_SPEC_GET_DEFAULT_UINT64(property_info->param_spec); + nm_assert(*p_val == 0); + *p_val = def_val; + break; + } + case NM_VALUE_TYPE_ENUM: + { + int *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + int def_val; + + def_val = NM_G_PARAM_SPEC_GET_DEFAULT_ENUM(property_info->param_spec); + nm_assert(*p_val == 0); + *p_val = def_val; + break; + } + case NM_VALUE_TYPE_FLAGS: + { + guint *p_val = + _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + guint def_val; + + def_val = NM_G_PARAM_SPEC_GET_DEFAULT_FLAGS(property_info->param_spec); + nm_assert(*p_val == 0); + *p_val = def_val; + break; + } + case NM_VALUE_TYPE_STRING: + nm_assert(!NM_G_PARAM_SPEC_GET_DEFAULT_STRING(property_info->param_spec)); + nm_assert(!( + *((const char *const *) + _nm_setting_get_private(setting, sett_info, property_info->direct_offset)))); + break; + case NM_VALUE_TYPE_BYTES: + nm_assert(!( + *((const GBytes *const *) + _nm_setting_get_private(setting, sett_info, property_info->direct_offset)))); + break; + default: + nm_assert_not_reached(); + break; + } + } +} + +static void +_finalize_direct(NMSetting *setting) +{ + const NMSettInfoSetting *sett_info; + guint16 i; + + sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); + nm_assert(sett_info); + + for (i = 0; i < sett_info->property_infos_len; i++) { + const NMSettInfoProperty *property_info = &sett_info->property_infos[i]; + + /* We only: + * + * - reset fields where there is something to free. E.g. boolean + * properties are not reset to their default. + * - clear/free properties, without emitting g_object_notify_by_pspec(), + * because this is called only during finalization. */ + + switch (property_info->property_type->direct_type) { + case NM_VALUE_TYPE_NONE: + case NM_VALUE_TYPE_BOOL: + case NM_VALUE_TYPE_INT32: + case NM_VALUE_TYPE_UINT32: + case NM_VALUE_TYPE_UINT64: + case NM_VALUE_TYPE_ENUM: + case NM_VALUE_TYPE_FLAGS: + break; + case NM_VALUE_TYPE_STRING: + { + char **p_val = + _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + + nm_clear_g_free(p_val); + break; + } + case NM_VALUE_TYPE_BYTES: + { + GBytes **p_val = + _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + + nm_clear_pointer(p_val, g_bytes_unref); + break; + } + default: + nm_assert_not_reached(); + break; + } + } +} + +/*****************************************************************************/ + +GVariant * +_nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) +{ + switch (property_info->property_type->direct_type) { + case NM_VALUE_TYPE_BOOL: + { + gboolean val; + + val = *((bool *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset)); + if (!property_info->to_dbus_including_default + && val == NM_G_PARAM_SPEC_GET_DEFAULT_BOOLEAN(property_info->param_spec)) + return NULL; + return g_variant_ref(nm_g_variant_singleton_b(val)); + } + case NM_VALUE_TYPE_INT32: + { + gint32 val; + + val = + *((gint32 *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset)); + if (!property_info->to_dbus_including_default + && val == NM_G_PARAM_SPEC_GET_DEFAULT_INT(property_info->param_spec)) + return NULL; + return nm_g_variant_maybe_singleton_i(val); + } + case NM_VALUE_TYPE_UINT32: + { + guint32 val; + + val = *( + (guint32 *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset)); + if (!property_info->to_dbus_including_default + && val == NM_G_PARAM_SPEC_GET_DEFAULT_UINT(property_info->param_spec)) + return NULL; + return g_variant_new_uint32(val); + } + case NM_VALUE_TYPE_UINT64: + { + guint64 val; + + val = *( + (guint64 *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset)); + if (!property_info->to_dbus_including_default + && val == NM_G_PARAM_SPEC_GET_DEFAULT_UINT64(property_info->param_spec)) + return NULL; + return g_variant_new_uint64(val); + } + case NM_VALUE_TYPE_ENUM: + { + int val; + + val = *((int *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset)); + if (!property_info->to_dbus_including_default + && val == NM_G_PARAM_SPEC_GET_DEFAULT_ENUM(property_info->param_spec)) + return NULL; + return nm_g_variant_maybe_singleton_i(val); + } + case NM_VALUE_TYPE_FLAGS: + { + guint val; + + val = + *((guint *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset)); + if (!property_info->to_dbus_including_default + && val == NM_G_PARAM_SPEC_GET_DEFAULT_FLAGS(property_info->param_spec)) + return NULL; + return g_variant_new_uint32(val); + } + case NM_VALUE_TYPE_STRING: + { + const char *val; + + /* For string properties that are implemented via this function, the default is always NULL. + * In general, having strings default to NULL is most advisable. + * + * Setting "including_default" for a string makes no sense because a + * GVariant of type "s" cannot express NULL. */ + nm_assert(!NM_G_PARAM_SPEC_GET_DEFAULT_STRING(property_info->param_spec)); + nm_assert(!property_info->to_dbus_including_default); + + val = *((const char *const *) _nm_setting_get_private(setting, + sett_info, + property_info->direct_offset)); + if (!val) + return NULL; + if (!val[0]) + return g_variant_ref(nm_g_variant_singleton_s_empty()); + return g_variant_new_string(val); + } + case NM_VALUE_TYPE_BYTES: + { + const GBytes *val; + + /* Bytes have always NULL as default. Setting "including_default" has no defined meaning + * (but it could have). */ + nm_assert(!property_info->to_dbus_including_default); + + val = *((const GBytes *const *) _nm_setting_get_private(setting, + sett_info, + property_info->direct_offset)); + if (!val) + return NULL; + return nm_g_bytes_to_variant_ay(val); + } + default: + return nm_assert_unreachable_val(NULL); + } +} + +GVariant * +_nm_setting_property_to_dbus_fcn_direct_mac_address(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) +{ + const char *val; + + nm_assert(property_info->property_type == &nm_sett_info_propert_type_direct_mac_address); + nm_assert(property_info->property_type->direct_type == NM_VALUE_TYPE_STRING); + nm_assert(!NM_G_PARAM_SPEC_GET_DEFAULT_STRING(property_info->param_spec)); + nm_assert(!property_info->to_dbus_including_default); + + val = *((const char *const *) _nm_setting_get_private(setting, + sett_info, + property_info->direct_offset)); + return nm_utils_hwaddr_to_dbus(val); +} + +GVariant * +_nm_setting_property_to_dbus_fcn_ignore(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) +{ + return NULL; +} + +GVariant * +_nm_setting_property_to_dbus_fcn_gprop(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) +{ + nm_auto_unset_gvalue GValue prop_value = { + 0, + }; + GArray *tmp_array; + + nm_assert(property_info->param_spec); + nm_assert(property_info->property_type->to_dbus_fcn == _nm_setting_property_to_dbus_fcn_gprop); + + g_value_init(&prop_value, property_info->param_spec->value_type); + + g_object_get_property(G_OBJECT(setting), property_info->param_spec->name, &prop_value); + + if (!property_info->to_dbus_including_default + && g_param_value_defaults(property_info->param_spec, &prop_value)) + return NULL; + + switch (property_info->property_type->typdata_to_dbus.gprop_type) { + case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_DEFAULT: + return g_dbus_gvalue_to_gvariant(&prop_value, property_info->property_type->dbus_type); + case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_ENUM: + return nm_g_variant_maybe_singleton_i(g_value_get_enum(&prop_value)); + case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_FLAGS: + return g_variant_new_uint32(g_value_get_flags(&prop_value)); + case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_GARRAY_UINT: + G_STATIC_ASSERT_EXPR(sizeof(guint) == sizeof(guint32)); + nm_assert(G_VALUE_HOLDS(&prop_value, G_TYPE_ARRAY)); + tmp_array = g_value_get_boxed(&prop_value); + nm_assert(tmp_array); + return nm_g_variant_new_au((const guint32 *) tmp_array->data, tmp_array->len); + case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_STRDICT: + nm_assert(G_VALUE_HOLDS(&prop_value, G_TYPE_HASH_TABLE)); + return nm_strdict_to_variant_ass(g_value_get_boxed(&prop_value)); + } + + return nm_assert_unreachable_val(NULL); +} + +gboolean +_nm_setting_property_from_dbus_fcn_ignore(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) +{ + *out_is_modified = FALSE; + return TRUE; +} + +gboolean +_nm_setting_property_from_dbus_fcn_direct_mac_address(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) +{ + gsize length = 0; + const guint8 *array; + + nm_assert(property_info->param_spec); + nm_assert(property_info->property_type == &nm_sett_info_propert_type_direct_mac_address); + nm_assert(g_variant_type_equal(property_info->property_type->dbus_type, "ay")); + nm_assert( + g_variant_type_equal(g_variant_get_type(value), property_info->property_type->dbus_type)); + nm_assert(property_info->direct_set_string_mac_address_len > 0); + + array = g_variant_get_fixed_array(value, &length, 1); + + if (nm_strdup_reset_take( + _nm_setting_get_private(setting, sett_info, property_info->direct_offset), + length > 0 ? nm_utils_hwaddr_ntoa(array, length) : NULL)) { + g_object_notify_by_pspec(G_OBJECT(setting), property_info->param_spec); + } else + *out_is_modified = FALSE; + + return TRUE; +} + +gboolean +_nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) +{ + nm_assert(property_info->param_spec); + nm_assert(NM_FLAGS_HAS(property_info->param_spec->flags, G_PARAM_WRITABLE)); + nm_assert(!NM_FLAGS_HAS(property_info->param_spec->flags, G_PARAM_CONSTRUCT_ONLY)); + nm_assert(!property_info->property_type->typdata_from_dbus.gprop_fcn); + +#define _variant_get_value_transform(property_info, value, gtype, gvalue_get, out_val) \ + ({ \ + const NMSettInfoProperty const *_property_info = (property_info); \ + const GType _gtype = (gtype); \ + GVariant * _value = (value); \ + gboolean _success = FALSE; \ + \ + nm_assert(_property_info->param_spec->value_type == _gtype); \ + if (_property_info->property_type->from_dbus_direct_allow_transform) { \ + nm_auto_unset_gvalue GValue _gvalue = G_VALUE_INIT; \ + \ + g_value_init(&_gvalue, _gtype); \ + if (_nm_property_variant_to_gvalue(_value, &_gvalue)) { \ + *(out_val) = (gvalue_get(&_gvalue)); \ + _success = TRUE; \ + } \ + } \ + _success; \ + }) + + *out_is_modified = FALSE; + + switch (property_info->property_type->direct_type) { + case NM_VALUE_TYPE_BOOL: + { + bool * p_val; + gboolean v; + + if (g_variant_is_of_type(value, G_VARIANT_TYPE_BOOLEAN)) + v = g_variant_get_boolean(value); + else { + if (!_variant_get_value_transform(property_info, + value, + G_TYPE_BOOLEAN, + g_value_get_boolean, + &v)) + goto out_error_wrong_dbus_type; + v = !!v; + } + + p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + if (*p_val == v) + goto out_unchanged; + *p_val = v; + goto out_notify; + } + case NM_VALUE_TYPE_INT32: + { + const GParamSpecInt *param_spec; + gint32 * p_val; + int v; + + if (g_variant_is_of_type(value, G_VARIANT_TYPE_INT32)) { + G_STATIC_ASSERT(sizeof(int) >= sizeof(gint32)); + v = g_variant_get_int32(value); + } else { + if (!_variant_get_value_transform(property_info, + value, + G_TYPE_INT, + g_value_get_int, + &v)) + goto out_error_wrong_dbus_type; + } + + p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + if (*p_val == v) + goto out_unchanged; + + param_spec = NM_G_PARAM_SPEC_CAST_INT(property_info->param_spec); + if (v < param_spec->minimum || v > param_spec->maximum) + goto out_error_param_spec_validation; + *p_val = v; + goto out_notify; + } + case NM_VALUE_TYPE_UINT32: + { + const GParamSpecUInt *param_spec; + guint32 * p_val; + guint v; + + if (g_variant_is_of_type(value, G_VARIANT_TYPE_UINT32)) { + G_STATIC_ASSERT(sizeof(guint) >= sizeof(guint32)); + v = g_variant_get_uint32(value); + } else { + if (!_variant_get_value_transform(property_info, + value, + G_TYPE_UINT, + g_value_get_uint, + &v)) + goto out_error_wrong_dbus_type; + } + + p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + if (*p_val == v) + goto out_unchanged; + + param_spec = NM_G_PARAM_SPEC_CAST_UINT(property_info->param_spec); + if (v < param_spec->minimum || v > param_spec->maximum) + goto out_error_param_spec_validation; + *p_val = v; + goto out_notify; + } + case NM_VALUE_TYPE_UINT64: + { + const GParamSpecUInt64 *param_spec; + guint64 * p_val; + guint64 v; + + if (g_variant_is_of_type(value, G_VARIANT_TYPE_UINT64)) + v = g_variant_get_uint64(value); + else { + if (!_variant_get_value_transform(property_info, + value, + G_TYPE_UINT64, + g_value_get_uint64, + &v)) + goto out_error_wrong_dbus_type; + } + + p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + if (*p_val == v) + goto out_unchanged; + + param_spec = NM_G_PARAM_SPEC_CAST_UINT64(property_info->param_spec); + if (v < param_spec->minimum || v > param_spec->maximum) + goto out_error_param_spec_validation; + *p_val = v; + goto out_notify; + } + case NM_VALUE_TYPE_ENUM: + { + const GParamSpecEnum *param_spec; + int * p_val; + int v; + + param_spec = NM_G_PARAM_SPEC_CAST_ENUM(property_info->param_spec); + + if (g_variant_is_of_type(value, G_VARIANT_TYPE_INT32)) { + G_STATIC_ASSERT(sizeof(int) >= sizeof(gint32)); + v = g_variant_get_int32(value); + } else { + if (!_variant_get_value_transform(property_info, + value, + G_TYPE_FROM_CLASS(param_spec->enum_class), + g_value_get_flags, + &v)) + goto out_error_wrong_dbus_type; + } + + p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + if (*p_val == v) + goto out_unchanged; + + if (!g_enum_get_value(param_spec->enum_class, v)) + goto out_error_param_spec_validation; + *p_val = v; + goto out_notify; + } + case NM_VALUE_TYPE_FLAGS: + { + const GParamSpecFlags *param_spec; + guint * p_val; + guint v; + + param_spec = NM_G_PARAM_SPEC_CAST_FLAGS(property_info->param_spec); + + if (g_variant_is_of_type(value, G_VARIANT_TYPE_UINT32)) { + G_STATIC_ASSERT(sizeof(guint) >= sizeof(guint32)); + v = g_variant_get_uint32(value); + } else { + if (!_variant_get_value_transform(property_info, + value, + G_TYPE_FROM_CLASS(param_spec->flags_class), + g_value_get_flags, + &v)) + goto out_error_wrong_dbus_type; + } + + p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + if (*p_val == v) + goto out_unchanged; + + if ((v & param_spec->flags_class->mask) != v) + goto out_error_param_spec_validation; + *p_val = v; + goto out_notify; } - g_variant_unref(value); + case NM_VALUE_TYPE_STRING: + { + gs_free char *v_free = NULL; + char ** p_val; + const char * v; - /* Otherwise, clients always prefer new properties sent from the daemon. */ - if (!_nm_utils_is_manager_process) { - g_variant_unref(setting_dict); - return FALSE; + if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) { + v = g_variant_get_string(value, NULL); + } else { + if (!_variant_get_value_transform(property_info, + value, + G_TYPE_STRING, + g_value_dup_string, + &v_free)) + goto out_error_wrong_dbus_type; + v = v_free; + } + + p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + if (!_property_direct_set_string(property_info, p_val, v)) + goto out_unchanged; + + goto out_notify; } + case NM_VALUE_TYPE_BYTES: + { + gs_unref_bytes GBytes *v = NULL; + GBytes ** p_val; - /* The daemon prefers the legacy property if it exists. */ - value = g_variant_lookup_value(setting_dict, legacy_property, NULL); - g_variant_unref(setting_dict); + if (!g_variant_is_of_type(value, G_VARIANT_TYPE_BYTESTRING)) + goto out_error_wrong_dbus_type; - if (value) { - g_variant_unref(value); - return TRUE; - } else - return FALSE; -} + v = nm_g_bytes_new_from_variant_ay(value); -/*****************************************************************************/ + p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + if (nm_g_bytes_equal0(*p_val, v)) + goto out_unchanged; -GVariant * -_nm_setting_property_to_dbus_fcn_get_boolean(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) -{ - const NMSettInfoProperty *property_info = &sett_info->property_infos[property_idx]; - gboolean val; - - val = !!property_info->to_dbus_data.get_boolean(setting); - if (!property_info->to_dbus_data.including_default - && val == NM_G_PARAM_SPEC_GET_DEFAULT_BOOLEAN(property_info->param_spec)) - return NULL; - return g_variant_ref(nm_g_variant_singleton_b(val)); -} + NM_SWAP(p_val, &v); + goto out_notify; + } + default: + break; + } -GVariant * -_nm_setting_property_to_dbus_fcn_get_string(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) -{ - const NMSettInfoProperty *property_info = &sett_info->property_infos[property_idx]; - const char * val; - - /* For string properties that are implemented via this function, the default is always NULL. - * In general, having strings default to NULL is most advisable. - * - * Setting "including_default" for a string makes no sense because a - * GVariant of type "s" cannot express NULL. */ - nm_assert(!NM_G_PARAM_SPEC_GET_DEFAULT_STRING(property_info->param_spec)); - nm_assert(!property_info->to_dbus_data.including_default); + nm_assert_not_reached(); - val = property_info->to_dbus_data.get_string(setting); - if (!val) - return NULL; - if (!val[0]) - return g_variant_ref(nm_g_variant_singleton_s_empty()); - return g_variant_new_string(val); -} +out_unchanged: + return TRUE; -GVariant * -_nm_setting_property_to_dbus_fcn_gprop(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) -{ - const NMSettInfoProperty *const property = &sett_info->property_infos[property_idx]; - nm_auto_unset_gvalue GValue prop_value = { - 0, - }; - GArray *tmp_array; +out_notify: + *out_is_modified = TRUE; + g_object_notify_by_pspec(G_OBJECT(setting), property_info->param_spec); + return TRUE; - nm_assert(property->param_spec); - nm_assert(property->property_type->to_dbus_fcn == _nm_setting_property_to_dbus_fcn_gprop); - nm_assert(property->property_type->typdata_to_dbus.gprop_type - == NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_DEFAULT - || !property->to_dbus_data.gprop_to_dbus_fcn); +out_error_wrong_dbus_type: + if (NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT)) + return TRUE; + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("can't set property of type '%s' from value of type '%s'"), + property_info->property_type->dbus_type + ? g_variant_type_peek_string(property_info->property_type->dbus_type) + : (property_info->param_spec + ? g_type_name(property_info->param_spec->value_type) + : "(unknown)"), + g_variant_get_type_string(value)); + g_prefix_error(error, "%s.%s: ", nm_setting_get_name(setting), property_info->name); + return FALSE; - g_value_init(&prop_value, property->param_spec->value_type); +out_error_param_spec_validation: + if (NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT)) + return TRUE; + g_set_error(error, + NM_UTILS_ERROR, + NM_UTILS_ERROR_UNKNOWN, + _("value of type '%s' is invalid or out of range for property '%s'"), + g_variant_get_type_string(value), + property_info->name); + g_prefix_error(error, "%s.%s: ", nm_setting_get_name(setting), property_info->name); + return FALSE; +} - g_object_get_property(G_OBJECT(setting), property->param_spec->name, &prop_value); +gboolean +_nm_setting_property_from_dbus_fcn_gprop(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) +{ + nm_auto_unset_gvalue GValue object_value = G_VALUE_INIT; + gs_free_error GError *local = NULL; - if (!property->to_dbus_data.including_default - && g_param_value_defaults(property->param_spec, &prop_value)) - return NULL; + nm_assert(property_info->param_spec); - switch (property->property_type->typdata_to_dbus.gprop_type) { - case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_DEFAULT: - if (property->to_dbus_data.gprop_to_dbus_fcn) - return property->to_dbus_data.gprop_to_dbus_fcn(&prop_value); + g_value_init(&object_value, property_info->param_spec->value_type); + if (!set_property_from_dbus(property_info, value, &object_value)) { + /* for backward behavior, fail unless best-effort is chosen. */ + *out_is_modified = FALSE; + if (NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT)) + return TRUE; + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("can't set property of type '%s' from value of type '%s'"), + property_info->property_type->dbus_type + ? g_variant_type_peek_string(property_info->property_type->dbus_type) + : (property_info->param_spec + ? g_type_name(property_info->param_spec->value_type) + : "(unknown)"), + g_variant_get_type_string(value)); + g_prefix_error(error, "%s.%s: ", nm_setting_get_name(setting), property_info->name); + return FALSE; + } - return g_dbus_gvalue_to_gvariant(&prop_value, property->property_type->dbus_type); - case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_BYTES: - nm_assert(G_VALUE_HOLDS(&prop_value, G_TYPE_BYTES)); - return nm_utils_gbytes_to_variant_ay(g_value_get_boxed(&prop_value)); - case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_ENUM: - return g_variant_new_int32(g_value_get_enum(&prop_value)); - case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_FLAGS: - return g_variant_new_uint32(g_value_get_flags(&prop_value)); - case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_GARRAY_UINT: - G_STATIC_ASSERT_EXPR(sizeof(guint) == sizeof(guint32)); - nm_assert(G_VALUE_HOLDS(&prop_value, G_TYPE_ARRAY)); - tmp_array = g_value_get_boxed(&prop_value); - nm_assert(tmp_array); - return nm_g_variant_new_au((const guint32 *) tmp_array->data, tmp_array->len); - case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_STRDICT: - nm_assert(G_VALUE_HOLDS(&prop_value, G_TYPE_HASH_TABLE)); - return nm_utils_strdict_to_variant_ass(g_value_get_boxed(&prop_value)); - case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_MAC_ADDRESS: - return nm_utils_hwaddr_to_dbus(g_value_get_string(&prop_value)); + if (!nm_g_object_set_property(G_OBJECT(setting), + property_info->param_spec->name, + &object_value, + &local)) { + *out_is_modified = FALSE; + if (!NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_STRICT)) + return TRUE; + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("can not set property: %s"), + local->message); + g_prefix_error(error, "%s.%s: ", nm_setting_get_name(setting), property_info->name); + return FALSE; } - return nm_assert_unreachable_val(NULL); + return TRUE; } static GVariant * property_to_dbus(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, const NMConnectionSerializationOptions *options, gboolean ignore_flags) { - const NMSettInfoProperty *property = &sett_info->property_infos[property_idx]; - GVariant * variant; + GVariant *variant; - nm_assert(property->property_type->dbus_type); + nm_assert(property_info->property_type->dbus_type); - if (!property->property_type->to_dbus_fcn) { - nm_assert(!property->param_spec); - nm_assert(!property->to_dbus_data.none); + if (!property_info->property_type->to_dbus_fcn) { + nm_assert(!property_info->param_spec); return NULL; } - if (property->param_spec - && (!ignore_flags - && !NM_FLAGS_HAS(property->param_spec->flags, NM_SETTING_PARAM_TO_DBUS_IGNORE_FLAGS))) { - if (!NM_FLAGS_HAS(property->param_spec->flags, G_PARAM_WRITABLE)) - return NULL; + nm_assert(!property_info->param_spec + || NM_FLAGS_HAS(property_info->param_spec->flags, G_PARAM_WRITABLE) + || property_info->property_type == &nm_sett_info_propert_type_setting_name); - if (NM_FLAGS_HAS(property->param_spec->flags, NM_SETTING_PARAM_LEGACY) + if (property_info->param_spec && !ignore_flags + && !NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_TO_DBUS_IGNORE_FLAGS)) { + if (NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_LEGACY) && !_nm_utils_is_manager_process) return NULL; - if (NM_FLAGS_HAS(property->param_spec->flags, NM_SETTING_PARAM_SECRET)) { + if (NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_SECRET)) { NMSettingSecretFlags f = NM_SETTING_SECRET_FLAG_NONE; if (NM_FLAGS_ANY(flags, NM_CONNECTION_SERIALIZE_WITH_SECRETS_AGENT_OWNED | NM_CONNECTION_SERIALIZE_WITH_SECRETS_SYSTEM_OWNED | NM_CONNECTION_SERIALIZE_WITH_SECRETS_NOT_SAVED)) { - if (!nm_setting_get_secret_flags(setting, property->param_spec->name, &f, NULL)) + if (!nm_setting_get_secret_flags(setting, + property_info->param_spec->name, + &f, + NULL)) return NULL; } @@ -679,48 +1635,40 @@ property_to_dbus(const NMSettInfoSetting * sett_info, } } - variant = property->property_type - ->to_dbus_fcn(sett_info, property_idx, connection, setting, flags, options); + variant = property_info->property_type + ->to_dbus_fcn(sett_info, property_info, connection, setting, flags, options); nm_g_variant_take_ref(variant); - nm_assert(!variant || g_variant_is_of_type(variant, property->property_type->dbus_type)); + nm_assert(!variant || g_variant_is_of_type(variant, property_info->property_type->dbus_type)); return variant; } static gboolean -set_property_from_dbus(const NMSettInfoProperty *property, GVariant *src_value, GValue *dst_value) +set_property_from_dbus(const NMSettInfoProperty *property_info, + GVariant * src_value, + GValue * dst_value) { - nm_assert(property->param_spec); - nm_assert(property->property_type->dbus_type); + nm_assert(property_info->param_spec); + nm_assert(property_info->property_type->dbus_type); - if (property->property_type->gprop_from_dbus_fcn) { + if (property_info->property_type->typdata_from_dbus.gprop_fcn) { if (!g_variant_type_equal(g_variant_get_type(src_value), - property->property_type->dbus_type)) + property_info->property_type->dbus_type)) return FALSE; - property->property_type->gprop_from_dbus_fcn(src_value, dst_value); - } else if (dst_value->g_type == G_TYPE_BYTES) { + property_info->property_type->typdata_from_dbus.gprop_fcn(src_value, dst_value); + return TRUE; + } + + if (dst_value->g_type == G_TYPE_BYTES) { if (!g_variant_is_of_type(src_value, G_VARIANT_TYPE_BYTESTRING)) return FALSE; _nm_utils_bytes_from_dbus(src_value, dst_value); - } else { - GValue tmp = G_VALUE_INIT; - - g_dbus_gvariant_to_gvalue(src_value, &tmp); - if (G_VALUE_TYPE(&tmp) == G_VALUE_TYPE(dst_value)) - *dst_value = tmp; - else { - gboolean success; - - success = g_value_transform(&tmp, dst_value); - g_value_unset(&tmp); - if (!success) - return FALSE; - } + return TRUE; } - return TRUE; + return _nm_property_variant_to_gvalue(src_value, dst_value); } /** @@ -747,7 +1695,9 @@ _nm_setting_to_dbus(NMSetting * setting, NMSettingPrivate * priv; GVariantBuilder builder; const NMSettInfoSetting *sett_info; - guint n_properties, i; + guint n_properties; + guint i; + guint16 j; const char *const * gendata_keys; g_return_val_if_fail(NM_IS_SETTING(setting), NULL); @@ -765,12 +1715,14 @@ _nm_setting_to_dbus(NMSetting * setting, } sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); - for (i = 0; i < sett_info->property_infos_len; i++) { - gs_unref_variant GVariant *dbus_value = NULL; + for (j = 0; j < sett_info->property_infos_len; j++) { + const NMSettInfoProperty *property_info = &sett_info->property_infos[j]; + gs_unref_variant GVariant *dbus_value = NULL; - dbus_value = property_to_dbus(sett_info, i, connection, setting, flags, options, FALSE); + dbus_value = + property_to_dbus(sett_info, property_info, connection, setting, flags, options, FALSE); if (dbus_value) { - g_variant_builder_add(&builder, "{sv}", sett_info->property_infos[i].name, dbus_value); + g_variant_builder_add(&builder, "{sv}", property_info->name, dbus_value); } } @@ -877,6 +1829,80 @@ _nm_setting_new_from_dbus(GType setting_type, return g_steal_pointer(&setting); } +static gboolean +_property_set_from_dbus(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMSetting * setting, + GVariant * connection_dict, + GVariant * value, + NMSettingParseFlags parse_flags, + gboolean * out_is_modified, + GError ** error) +{ + gs_free_error GError *local = NULL; + NMTernary is_modified = NM_TERNARY_DEFAULT; + gboolean success; + + NM_SET_OUT(out_is_modified, FALSE); + + if (!property_info->property_type->from_dbus_fcn) { + nm_assert(!property_info->param_spec); + return TRUE; + } + + if (property_info->property_type->from_dbus_is_full) { + /* These hooks perform their own type checking, and can coerce/ignore + * a value regardless of the D-Bus type. */ + } else if (!g_variant_type_equal(g_variant_get_type(value), + property_info->property_type->dbus_type)) { + /* for backward behavior, fail unless best-effort is chosen. */ + if (NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT)) + return TRUE; + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("can't set property of type '%s' from value of type '%s'"), + property_info->property_type->dbus_type + ? g_variant_type_peek_string(property_info->property_type->dbus_type) + : property_info->param_spec ? g_type_name(property_info->param_spec->value_type) + : "(unknown)", + g_variant_get_type_string(value)); + g_prefix_error(error, "%s.%s: ", nm_setting_get_name(setting), property_info->name); + return FALSE; + } + + success = property_info->property_type->from_dbus_fcn(sett_info, + property_info, + setting, + connection_dict, + value, + parse_flags, + &is_modified, + &local); + + /* We allow the from_dbus_fcn() to leave is_modified at NM_TERNARY_DEFAULT, + * which we assume to also mean that it was modified. That is, we err on the + * side of assuming modification happened. */ + NM_SET_OUT(out_is_modified, is_modified != FALSE); + + if (!success) { + if (property_info->property_type->from_dbus_is_full) { + /* the error we received from from_dbus_fcn() should be propagated, even + * in non-strict mode. */ + } else if (!NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_STRICT)) + return TRUE; + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("failed to set property: %s"), + local->message); + g_prefix_error(error, "%s.%s: ", nm_setting_get_name(setting), property_info->name); + return FALSE; + } + + return TRUE; +} + static gboolean init_from_dbus(NMSetting * setting, GHashTable * keys, @@ -886,8 +1912,7 @@ init_from_dbus(NMSetting * setting, GError ** error) { const NMSettInfoSetting *sett_info; - - guint i; + guint16 i; nm_assert(NM_IS_SETTING(setting)); nm_assert(!NM_FLAGS_ANY(parse_flags, ~NM_SETTING_PARSE_FLAGS_ALL)); @@ -931,56 +1956,21 @@ init_from_dbus(NMSetting * setting, gs_unref_variant GVariant *value = NULL; gs_free_error GError *local = NULL; - if (property_info->param_spec && !(property_info->param_spec->flags & G_PARAM_WRITABLE)) + if (property_info->property_type == &nm_sett_info_propert_type_setting_name) continue; - value = g_variant_lookup_value(setting_dict, property_info->name, NULL); - - if (value && keys) - g_hash_table_remove(keys, property_info->name); + nm_assert(!property_info->param_spec + || NM_FLAGS_HAS(property_info->param_spec->flags, G_PARAM_WRITABLE)); - if (value && property_info->property_type->from_dbus_fcn) { - if (!g_variant_type_equal(g_variant_get_type(value), - property_info->property_type->dbus_type)) { - /* for backward behavior, fail unless best-effort is chosen. */ - if (NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT)) - continue; - g_set_error( - error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("can't set property of type '%s' from value of type '%s'"), - property_info->property_type->dbus_type - ? g_variant_type_peek_string(property_info->property_type->dbus_type) - : property_info->param_spec ? g_type_name(property_info->param_spec->value_type) - : "(unknown)", - g_variant_get_type_string(value)); - g_prefix_error(error, "%s.%s: ", nm_setting_get_name(setting), property_info->name); - return FALSE; - } + value = g_variant_lookup_value(setting_dict, property_info->name, NULL); - if (!property_info->property_type->from_dbus_fcn(setting, - connection_dict, - property_info->name, - value, - parse_flags, - &local)) { - if (!NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_STRICT)) - continue; - g_set_error(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("failed to set property: %s"), - local->message); - g_prefix_error(error, "%s.%s: ", nm_setting_get_name(setting), property_info->name); - return FALSE; - } - } else if (!value && property_info->property_type->missing_from_dbus_fcn) { - if (!property_info->property_type->missing_from_dbus_fcn(setting, - connection_dict, - property_info->name, - parse_flags, - &local)) { + if (!value) { + if (property_info->property_type->missing_from_dbus_fcn + && !property_info->property_type->missing_from_dbus_fcn(setting, + connection_dict, + property_info->name, + parse_flags, + &local)) { if (!NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_STRICT)) continue; g_set_error(error, @@ -991,44 +1981,21 @@ init_from_dbus(NMSetting * setting, g_prefix_error(error, "%s.%s: ", nm_setting_get_name(setting), property_info->name); return FALSE; } - } else if (value && property_info->param_spec) { - nm_auto_unset_gvalue GValue object_value = G_VALUE_INIT; + continue; + } - g_value_init(&object_value, property_info->param_spec->value_type); - if (!set_property_from_dbus(property_info, value, &object_value)) { - /* for backward behavior, fail unless best-effort is chosen. */ - if (NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_BEST_EFFORT)) - continue; - g_set_error( - error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("can't set property of type '%s' from value of type '%s'"), - property_info->property_type->dbus_type - ? g_variant_type_peek_string(property_info->property_type->dbus_type) - : (property_info->param_spec - ? g_type_name(property_info->param_spec->value_type) - : "(unknown)"), - g_variant_get_type_string(value)); - g_prefix_error(error, "%s.%s: ", nm_setting_get_name(setting), property_info->name); - return FALSE; - } + if (keys) + g_hash_table_remove(keys, property_info->name); - if (!nm_g_object_set_property(G_OBJECT(setting), - property_info->param_spec->name, - &object_value, - &local)) { - if (!NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_STRICT)) - continue; - g_set_error(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("can not set property: %s"), - local->message); - g_prefix_error(error, "%s.%s: ", nm_setting_get_name(setting), property_info->name); - return FALSE; - } - } + if (!_property_set_from_dbus(sett_info, + property_info, + setting, + connection_dict, + value, + parse_flags, + NULL, + error)) + return FALSE; } return TRUE; @@ -1047,19 +2014,21 @@ init_from_dbus(NMSetting * setting, const GVariantType * nm_setting_get_dbus_property_type(NMSetting *setting, const char *property_name) { - const NMSettInfoProperty *property; + const NMSettInfoProperty *property_info; g_return_val_if_fail(NM_IS_SETTING(setting), NULL); g_return_val_if_fail(property_name != NULL, NULL); - property = _nm_setting_class_get_property_info(NM_SETTING_GET_CLASS(setting), property_name); + property_info = + _nm_setting_class_get_property_info(NM_SETTING_GET_CLASS(setting), property_name); - g_return_val_if_fail(property != NULL, NULL); + g_return_val_if_fail(property_info != NULL, NULL); - nm_assert(property->property_type); - nm_assert(g_variant_type_string_is_valid((const char *) property->property_type->dbus_type)); + nm_assert(property_info->property_type); + nm_assert( + g_variant_type_string_is_valid((const char *) property_info->property_type->dbus_type)); - return property->property_type->dbus_type; + return property_info->property_type->dbus_type; } gboolean @@ -1117,6 +2086,9 @@ _gobject_copy_property(GObject *src, GObject *dst, const char *property_name, GT static void duplicate_copy_properties(const NMSettInfoSetting *sett_info, NMSetting *src, NMSetting *dst) { + gboolean frozen = FALSE; + guint16 i; + if (sett_info->detail.gendata_info) { GenData *gendata = _gendata_hash(src, FALSE); @@ -1135,33 +2107,30 @@ duplicate_copy_properties(const NMSettInfoSetting *sett_info, NMSetting *src, NM } } - if (sett_info->property_infos_len > 0) { - gboolean frozen = FALSE; - guint i; + for (i = 0; i < sett_info->property_infos_len; i++) { + const NMSettInfoProperty *property_info = &sett_info->property_infos[i]; - for (i = 0; i < sett_info->property_infos_len; i++) { - const NMSettInfoProperty *property_info = &sett_info->property_infos[i]; + if (!property_info->param_spec) + continue; - if (property_info->param_spec) { - if ((property_info->param_spec->flags & (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)) - != G_PARAM_WRITABLE) - continue; + nm_assert(!NM_FLAGS_HAS(property_info->param_spec->flags, G_PARAM_CONSTRUCT_ONLY)); + if (property_info->property_type == &nm_sett_info_propert_type_setting_name) + continue; - if (!frozen) { - g_object_freeze_notify(G_OBJECT(dst)); - frozen = TRUE; - } - _gobject_copy_property(G_OBJECT(src), - G_OBJECT(dst), - property_info->param_spec->name, - G_PARAM_SPEC_VALUE_TYPE(property_info->param_spec)); - continue; - } - } + nm_assert(NM_FLAGS_HAS(property_info->param_spec->flags, G_PARAM_WRITABLE)); - if (frozen) - g_object_thaw_notify(G_OBJECT(dst)); + if (!frozen) { + g_object_freeze_notify(G_OBJECT(dst)); + frozen = TRUE; + } + _gobject_copy_property(G_OBJECT(src), + G_OBJECT(dst), + property_info->param_spec->name, + G_PARAM_SPEC_VALUE_TYPE(property_info->param_spec)); } + + if (frozen) + g_object_thaw_notify(G_OBJECT(dst)); } /** @@ -1356,110 +2325,157 @@ _nm_setting_should_compare_secret_property(NMSetting * setting, return TRUE; } -static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) -{ - const NMSettInfoProperty *property_info = &sett_info->property_infos[property_idx]; - const GParamSpec * param_spec = property_info->param_spec; - - if (!param_spec) - return NM_TERNARY_DEFAULT; +/*****************************************************************************/ +gboolean +_nm_setting_compare_flags_check(const GParamSpec * param_spec, + NMSettingCompareFlags flags, + NMSetting * set_a, + NMSetting * set_b) +{ if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_FUZZY) && NM_FLAGS_ANY(param_spec->flags, NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_SECRET)) - return NM_TERNARY_DEFAULT; + return FALSE; if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE) && !NM_FLAGS_HAS(param_spec->flags, NM_SETTING_PARAM_INFERRABLE)) - return NM_TERNARY_DEFAULT; + return FALSE; if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_IGNORE_REAPPLY_IMMEDIATELY) && NM_FLAGS_HAS(param_spec->flags, NM_SETTING_PARAM_REAPPLY_IMMEDIATELY)) - return NM_TERNARY_DEFAULT; + return FALSE; if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS) && NM_FLAGS_HAS(param_spec->flags, NM_SETTING_PARAM_SECRET)) - return NM_TERNARY_DEFAULT; - - if (nm_streq(param_spec->name, NM_SETTING_NAME)) - return NM_TERNARY_DEFAULT; + return FALSE; if (NM_FLAGS_HAS(param_spec->flags, NM_SETTING_PARAM_SECRET) && !_nm_setting_should_compare_secret_property(set_a, set_b, param_spec->name, flags)) + return FALSE; + + return TRUE; +} + +NMTernary +_nm_setting_property_compare_fcn_ignore(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) +{ + return NM_TERNARY_DEFAULT; +} + +NMTernary +_nm_setting_property_compare_fcn_direct(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) +{ + gconstpointer p_a; + gconstpointer p_b; + + nm_assert(NM_IN_SET(property_info->property_type->to_dbus_fcn, + _nm_setting_property_to_dbus_fcn_direct, + _nm_setting_property_to_dbus_fcn_direct_mac_address)); + + if (!property_info->param_spec) + return nm_assert_unreachable_val(NM_TERNARY_DEFAULT); + + if (!_nm_setting_compare_flags_check(property_info->param_spec, flags, set_a, set_b)) + return NM_TERNARY_DEFAULT; + + if (!set_b) + return TRUE; + + p_a = _nm_setting_get_private(set_a, sett_info, property_info->direct_offset); + p_b = _nm_setting_get_private(set_b, sett_info, property_info->direct_offset); + + switch (property_info->property_type->direct_type) { + case NM_VALUE_TYPE_BOOL: + return *((const bool *) p_a) == *((const bool *) p_b); + case NM_VALUE_TYPE_INT32: + return *((const gint32 *) p_a) == *((const gint32 *) p_b); + case NM_VALUE_TYPE_UINT32: + return *((const guint32 *) p_a) == *((const guint32 *) p_b); + case NM_VALUE_TYPE_UINT64: + return *((const guint64 *) p_a) == *((const guint64 *) p_b); + case NM_VALUE_TYPE_ENUM: + return *((const int *) p_a) == *((const int *) p_b); + case NM_VALUE_TYPE_FLAGS: + return *((const guint *) p_a) == *((const guint *) p_b); + case NM_VALUE_TYPE_STRING: + return nm_streq0(*((const char *const *) p_a), *((const char *const *) p_b)); + case NM_VALUE_TYPE_BYTES: + return nm_g_bytes_equal0(*((const GBytes *const *) p_a), *((const GBytes *const *) p_b)); + default: + return nm_assert_unreachable_val(TRUE); + } +} + +NMTernary +_nm_setting_property_compare_fcn_default(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) +{ + nm_assert(property_info->property_type->direct_type == NM_VALUE_TYPE_NONE); + + if (!property_info->param_spec) + return nm_assert_unreachable_val(NM_TERNARY_DEFAULT); + + if (!_nm_setting_compare_flags_check(property_info->param_spec, flags, set_a, set_b)) return NM_TERNARY_DEFAULT; - if (set_b) { + if (!set_b) + return TRUE; + + { gs_unref_variant GVariant *value1 = NULL; gs_unref_variant GVariant *value2 = NULL; value1 = property_to_dbus(sett_info, - property_idx, + property_info, con_a, set_a, NM_CONNECTION_SERIALIZE_ALL, NULL, TRUE); value2 = property_to_dbus(sett_info, - property_idx, + property_info, con_b, set_b, NM_CONNECTION_SERIALIZE_ALL, NULL, TRUE); - if (nm_property_compare(value1, value2) != 0) - return NM_TERNARY_FALSE; + return nm_property_compare(value1, value2) == 0; } - - return NM_TERNARY_TRUE; } static NMTernary -_compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +_compare_property(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { NMTernary compare_result; nm_assert(sett_info); nm_assert(NM_IS_SETTING_CLASS(sett_info->setting_class)); - nm_assert(property_idx < sett_info->property_infos_len); + nm_assert(property_info); nm_assert(NM_SETTING_GET_CLASS(set_a) == sett_info->setting_class); nm_assert(!set_b || NM_SETTING_GET_CLASS(set_b) == sett_info->setting_class); - compare_result = - NM_SETTING_GET_CLASS(set_a) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + compare_result = property_info->property_type + ->compare_fcn(sett_info, property_info, con_a, set_a, con_b, set_b, flags); - nm_assert(NM_IN_SET(compare_result, NM_TERNARY_DEFAULT, NM_TERNARY_FALSE, NM_TERNARY_TRUE)); + nm_assert_is_ternary(compare_result); /* check that the inferable flag and the GObject property flag corresponds. */ - nm_assert(!NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE) - || !sett_info->property_infos[property_idx].param_spec - || NM_FLAGS_HAS(sett_info->property_infos[property_idx].param_spec->flags, - NM_SETTING_PARAM_INFERRABLE) + nm_assert(!NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE) || !property_info->param_spec + || NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_INFERRABLE) || compare_result == NM_TERNARY_DEFAULT); #if NM_MORE_ASSERTS > 10 - /* assert that compare_property() is symeric. */ - nm_assert(!set_b - || compare_result - == NM_SETTING_GET_CLASS(set_a)->compare_property(sett_info, - property_idx, - con_b, - set_b, - con_a, - set_a, - flags)); + /* assert that compare_fcn() is symeric. */ + nm_assert( + !set_b + || compare_result + == property_info->property_type + ->compare_fcn(sett_info, property_info, con_b, set_b, con_a, set_a, flags)); #endif return compare_result; @@ -1491,7 +2507,7 @@ _nm_setting_compare(NMConnection * con_a, NMSettingCompareFlags flags) { const NMSettInfoSetting *sett_info; - guint i; + guint16 i; g_return_val_if_fail(NM_IS_SETTING(a), FALSE); g_return_val_if_fail(NM_IS_SETTING(b), FALSE); @@ -1516,7 +2532,8 @@ _nm_setting_compare(NMConnection * con_a, } for (i = 0; i < sett_info->property_infos_len; i++) { - if (_compare_property(sett_info, i, con_a, a, con_b, b, flags) == NM_TERNARY_FALSE) + if (_compare_property(sett_info, &sett_info->property_infos[i], con_a, a, con_b, b, flags) + == NM_TERNARY_FALSE) return FALSE; } @@ -1581,7 +2598,6 @@ _nm_setting_diff(NMConnection * con_a, GHashTable ** results) { const NMSettInfoSetting *sett_info; - guint i; NMSettingDiffResult a_result = NM_SETTING_DIFF_RESULT_IN_A; NMSettingDiffResult b_result = NM_SETTING_DIFF_RESULT_IN_B; NMSettingDiffResult a_result_default = NM_SETTING_DIFF_RESULT_IN_A_DEFAULT; @@ -1589,6 +2605,7 @@ _nm_setting_diff(NMConnection * con_a, gboolean results_created = FALSE; gboolean compared_any = FALSE; gboolean diff_found = FALSE; + guint16 i; g_return_val_if_fail(results != NULL, FALSE); g_return_val_if_fail(NM_IS_SETTING(a), FALSE); @@ -1672,12 +2689,12 @@ _nm_setting_diff(NMConnection * con_a, } } else { for (i = 0; i < sett_info->property_infos_len; i++) { - NMSettingDiffResult r = NM_SETTING_DIFF_RESULT_UNKNOWN; - const NMSettInfoProperty *property_info; + NMSettingDiffResult r = NM_SETTING_DIFF_RESULT_UNKNOWN; + const NMSettInfoProperty *property_info = &sett_info->property_infos[i]; NMTernary compare_result; GParamSpec * prop_spec; - compare_result = _compare_property(sett_info, i, con_a, a, con_b, b, flags); + compare_result = _compare_property(sett_info, property_info, con_a, a, con_b, b, flags); if (compare_result == NM_TERNARY_DEFAULT) continue; @@ -1698,15 +2715,14 @@ _nm_setting_diff(NMConnection * con_a, * * We need to double-check whether the property should be ignored by * looking at @a alone. */ - if (_compare_property(sett_info, i, con_a, a, NULL, NULL, flags) + if (_compare_property(sett_info, property_info, con_a, a, NULL, NULL, flags) == NM_TERNARY_DEFAULT) continue; } compared_any = TRUE; - property_info = &sett_info->property_infos[i]; - prop_spec = property_info->param_spec; + prop_spec = property_info->param_spec; if (b) { if (compare_result == NM_TERNARY_FALSE) { @@ -1826,6 +2842,7 @@ nm_setting_enumerate_values(NMSetting *setting, NMSettingValueIterFn func, gpoin { const NMSettInfoSetting *sett_info; guint i; + guint16 j; g_return_if_fail(NM_IS_SETTING(setting)); g_return_if_fail(func != NULL); @@ -1864,9 +2881,9 @@ nm_setting_enumerate_values(NMSetting *setting, NMSettingValueIterFn func, gpoin return; } - for (i = 0; i < sett_info->property_infos_len; i++) { + for (j = 0; j < sett_info->property_infos_len; j++) { NM_SETTING_GET_CLASS(setting)->enumerate_values( - _nm_sett_info_property_info_get_sorted(sett_info, i), + _nm_sett_info_property_info_get_sorted(sett_info, j), setting, func, user_data); @@ -1878,7 +2895,7 @@ aggregate(NMSetting *setting, int type_i, gpointer arg) { NMConnectionAggregateType type = type_i; const NMSettInfoSetting * sett_info; - guint i; + guint16 i; nm_assert(NM_IN_SET(type, NM_CONNECTION_AGGREGATE_ANY_SECRETS, @@ -1953,13 +2970,13 @@ _nm_setting_aggregate(NMSetting *setting, NMConnectionAggregateType type, gpoint static gboolean clear_secrets(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMSetting * setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data) { NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE; - GParamSpec * param_spec = sett_info->property_infos[property_idx].param_spec; + GParamSpec * param_spec = property_info->param_spec; if (!param_spec) return FALSE; @@ -2008,20 +3025,20 @@ _nm_setting_clear_secrets(NMSetting * setting, { const NMSettInfoSetting *sett_info; gboolean changed = FALSE; - guint i; - gboolean (*my_clear_secrets)(const struct _NMSettInfoSetting *sett_info, - guint property_idx, - NMSetting * setting, - NMSettingClearSecretsWithFlagsFn func, - gpointer user_data); + NMSettingClass * klass; + guint16 i; g_return_val_if_fail(NM_IS_SETTING(setting), FALSE); - my_clear_secrets = NM_SETTING_GET_CLASS(setting)->clear_secrets; + klass = NM_SETTING_GET_CLASS(setting); sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); for (i = 0; i < sett_info->property_infos_len; i++) { - changed |= my_clear_secrets(sett_info, i, setting, func, user_data); + changed |= klass->clear_secrets(sett_info, + &sett_info->property_infos[i], + setting, + func, + user_data); } return changed; } @@ -2056,14 +3073,13 @@ _nm_setting_need_secrets(NMSetting *setting) static int update_one_secret(NMSetting *setting, const char *key, GVariant *value, GError **error) { - const NMSettInfoProperty *property; - GParamSpec * prop_spec; - GValue prop_value = { - 0, - }; + const NMSettInfoSetting * sett_info; + const NMSettInfoProperty *property_info; + gboolean is_modified; - property = _nm_setting_class_get_property_info(NM_SETTING_GET_CLASS(setting), key); - if (!property) { + sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); + property_info = _nm_sett_info_setting_get_property_info(sett_info, key); + if (!property_info) { g_set_error_literal(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND, @@ -2072,32 +3088,25 @@ update_one_secret(NMSetting *setting, const char *key, GVariant *value, GError * return NM_SETTING_UPDATE_SECRET_ERROR; } - /* Silently ignore non-secrets */ - prop_spec = property->param_spec; - if (!prop_spec || !(prop_spec->flags & NM_SETTING_PARAM_SECRET)) + if (!property_info->param_spec + || !NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_SECRET)) { + /* Silently ignore non-secrets */ return NM_SETTING_UPDATE_SECRET_SUCCESS_UNCHANGED; - - if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING) && G_IS_PARAM_SPEC_STRING(prop_spec)) { - /* String is expected to be a common case. Handle it specially and check - * whether the value is already set. Otherwise, we just reset the - * property and assume the value got modified. - */ - char *v; - - g_object_get(G_OBJECT(setting), prop_spec->name, &v, NULL); - if (g_strcmp0(v, g_variant_get_string(value, NULL)) == 0) { - g_free(v); - return NM_SETTING_UPDATE_SECRET_SUCCESS_UNCHANGED; - } - g_free(v); } - g_value_init(&prop_value, prop_spec->value_type); - set_property_from_dbus(property, value, &prop_value); - g_object_set_property(G_OBJECT(setting), prop_spec->name, &prop_value); - g_value_unset(&prop_value); + if (!_property_set_from_dbus(sett_info, + property_info, + setting, + NULL, + value, + NM_SETTING_PARSE_FLAGS_BEST_EFFORT, + &is_modified, + NULL)) { + /* Silently ignore errors. */ + } - return NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED; + return is_modified ? NM_SETTING_UPDATE_SECRET_SUCCESS_MODIFIED + : NM_SETTING_UPDATE_SECRET_SUCCESS_UNCHANGED; } /** @@ -2354,12 +3363,7 @@ nm_setting_to_string(NMSetting *setting) } static GVariant * -_nm_setting_get_deprecated_virtual_interface_name(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +_nm_setting_get_deprecated_virtual_interface_name(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { NMSettingConnection *s_con; @@ -2378,34 +3382,120 @@ _nm_setting_get_deprecated_virtual_interface_name(const NMSettInfoSetting * const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_interface_name = NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_STRING, + .compare_fcn = _nm_setting_property_compare_fcn_ignore, .to_dbus_fcn = _nm_setting_get_deprecated_virtual_interface_name, ); +const NMSettInfoPropertType nm_sett_info_propert_type_setting_name = + NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_STRING, + .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_ignore, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_ignore, + .from_dbus_is_full = TRUE, + .compare_fcn = _nm_setting_property_compare_fcn_ignore); + const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_i = NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT( G_VARIANT_TYPE_INT32, /* No functions set. This property type is to silently ignore the value on D-Bus. */ - ); + .compare_fcn = _nm_setting_property_compare_fcn_ignore); const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_u = NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT( G_VARIANT_TYPE_UINT32, /* No functions set. This property type is to silently ignore the value on D-Bus. */ - ); + .compare_fcn = _nm_setting_property_compare_fcn_ignore); const NMSettInfoPropertType nm_sett_info_propert_type_plain_i = - NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(G_VARIANT_TYPE_INT32); + NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(G_VARIANT_TYPE_INT32, + .compare_fcn = _nm_setting_property_compare_fcn_default, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE); const NMSettInfoPropertType nm_sett_info_propert_type_plain_u = - NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(G_VARIANT_TYPE_UINT32); - -const NMSettInfoPropertType nm_sett_info_propert_type_boolean = NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT( - G_VARIANT_TYPE_BOOLEAN, - .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_get_boolean); - -const NMSettInfoPropertType nm_sett_info_propert_type_string = + NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(G_VARIANT_TYPE_UINT32, + .compare_fcn = _nm_setting_property_compare_fcn_default, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE); + +const NMSettInfoPropertType nm_sett_info_propert_type_direct_boolean = + NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_BOOLEAN, + .direct_type = NM_VALUE_TYPE_BOOL, + .compare_fcn = _nm_setting_property_compare_fcn_direct, + .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_direct, + .from_dbus_is_full = TRUE, + .from_dbus_direct_allow_transform = TRUE); + +const NMSettInfoPropertType nm_sett_info_propert_type_direct_int32 = + NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_INT32, + .direct_type = NM_VALUE_TYPE_INT32, + .compare_fcn = _nm_setting_property_compare_fcn_direct, + .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_direct, + .from_dbus_is_full = TRUE, + .from_dbus_direct_allow_transform = TRUE); + +const NMSettInfoPropertType nm_sett_info_propert_type_direct_uint32 = + NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_UINT32, + .direct_type = NM_VALUE_TYPE_UINT32, + .compare_fcn = _nm_setting_property_compare_fcn_direct, + .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_direct, + .from_dbus_is_full = TRUE, + .from_dbus_direct_allow_transform = TRUE); + +const NMSettInfoPropertType nm_sett_info_propert_type_direct_uint64 = + NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_UINT64, + .direct_type = NM_VALUE_TYPE_UINT64, + .compare_fcn = _nm_setting_property_compare_fcn_direct, + .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_direct, + .from_dbus_is_full = TRUE, + .from_dbus_direct_allow_transform = TRUE); + +const NMSettInfoPropertType nm_sett_info_propert_type_direct_string = NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_STRING, - .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_get_string); + .direct_type = NM_VALUE_TYPE_STRING, + .compare_fcn = _nm_setting_property_compare_fcn_direct, + .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_direct, + .from_dbus_is_full = TRUE, + .from_dbus_direct_allow_transform = TRUE); + +const NMSettInfoPropertType nm_sett_info_propert_type_direct_bytes = + NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_BYTESTRING, + .direct_type = NM_VALUE_TYPE_BYTES, + .compare_fcn = _nm_setting_property_compare_fcn_direct, + .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_direct, + .from_dbus_is_full = TRUE, + .from_dbus_direct_allow_transform = TRUE); + +const NMSettInfoPropertType nm_sett_info_propert_type_direct_enum = + NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_INT32, + .direct_type = NM_VALUE_TYPE_ENUM, + .compare_fcn = _nm_setting_property_compare_fcn_direct, + .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_direct, + .from_dbus_is_full = TRUE, + .from_dbus_direct_allow_transform = TRUE); + +const NMSettInfoPropertType nm_sett_info_propert_type_direct_flags = + NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_UINT32, + .direct_type = NM_VALUE_TYPE_FLAGS, + .compare_fcn = _nm_setting_property_compare_fcn_direct, + .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_direct, + .from_dbus_is_full = TRUE, + .from_dbus_direct_allow_transform = TRUE); + +const NMSettInfoPropertType nm_sett_info_propert_type_direct_mac_address = + NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT( + G_VARIANT_TYPE_BYTESTRING, + .direct_type = NM_VALUE_TYPE_STRING, + .compare_fcn = _nm_setting_property_compare_fcn_direct, + .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct_mac_address, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_direct_mac_address); /*****************************************************************************/ @@ -2501,7 +3591,7 @@ _nm_setting_option_get_all(NMSetting * setting, return len; if (G_UNLIKELY(!gendata->names)) { - gendata->names = nm_utils_strdict_get_keys(hash, TRUE, NULL); + gendata->names = nm_strdict_get_keys(hash, TRUE, NULL); } if (out_values) { @@ -2843,10 +3933,37 @@ static void nm_setting_init(NMSetting *setting) {} +static void +constructed(GObject *object) +{ + NMSetting * self = NM_SETTING(object); + NMSettingClass *klass = NM_SETTING_GET_CLASS(self); + + /* we don't support that NMSetting subclasses override constructed. + * They all must have no G_PARAM_CONSTRUCT/G_PARAM_CONSTRUCT_ONLY + * properties, otherwise the automatism of _init_direct() needs + * careful adjustment. */ + nm_assert(G_OBJECT_CLASS(klass)->constructed == constructed); + + /* we always initialize the defaults of the (direct) properties. Note that: + * + * - we don't use CONSTRUCT properties, because they have an overhead during + * each object creation. Via _init_direct() we can do it more efficiently. + * + * - we always call this, because we want to get all default values right. + * We even call this for NMSetting subclasses that (historically) are not + * yet aware of this happening. + */ + _init_direct(self); + + G_OBJECT_CLASS(nm_setting_parent_class)->constructed(object); +} + static void finalize(GObject *object) { - NMSettingPrivate *priv = NM_SETTING_GET_PRIVATE(object); + NMSetting * self = NM_SETTING(object); + NMSettingPrivate *priv = NM_SETTING_GET_PRIVATE(self); if (priv->gendata) { g_free(priv->gendata->names); @@ -2856,6 +3973,8 @@ finalize(GObject *object) } G_OBJECT_CLASS(nm_setting_parent_class)->finalize(object); + + _finalize_direct(self); } static void @@ -2865,13 +3984,13 @@ nm_setting_class_init(NMSettingClass *setting_class) g_type_class_add_private(setting_class, sizeof(NMSettingPrivate)); + object_class->constructed = constructed; object_class->get_property = get_property; object_class->finalize = finalize; setting_class->update_one_secret = update_one_secret; setting_class->get_secret_flags = get_secret_flags; setting_class->set_secret_flags = set_secret_flags; - setting_class->compare_property = compare_property; setting_class->clear_secrets = clear_secrets; setting_class->for_each_secret = for_each_secret; setting_class->duplicate_copy_properties = duplicate_copy_properties; diff --git a/src/libnm-core-impl/nm-simple-connection.c b/src/libnm-core-impl/nm-simple-connection.c index 6b5b1184..f16d9d59 100644 --- a/src/libnm-core-impl/nm-simple-connection.c +++ b/src/libnm-core-impl/nm-simple-connection.c @@ -161,7 +161,7 @@ dispose(GObject *object) #if NM_MORE_ASSERTS g_signal_handlers_disconnect_by_data(object, - (gpointer) &_nmtst_connection_unchanging_user_data); + (gpointer) &_nm_assert_connection_unchanging_user_data); #endif nm_connection_clear_secrets(connection); diff --git a/src/libnm-core-impl/nm-team-utils.c b/src/libnm-core-impl/nm-team-utils.c index bd9ef510..f67c08be 100644 --- a/src/libnm-core-impl/nm-team-utils.c +++ b/src/libnm-core-impl/nm-team-utils.c @@ -523,11 +523,10 @@ _team_attr_data_cmp(const TeamAttrData *attr_data, } else if (!is_port && attr_data->team_attr == NM_TEAM_ATTRIBUTE_MASTER_RUNNER_TX_HASH) { v_ptrarray_a = *((const GPtrArray *const *) val_a); v_ptrarray_b = *((const GPtrArray *const *) val_b); - NM_CMP_RETURN( - nm_utils_strv_cmp_n(v_ptrarray_a ? (const char *const *) v_ptrarray_a->pdata : NULL, - v_ptrarray_a ? v_ptrarray_a->len : 0u, - v_ptrarray_b ? (const char *const *) v_ptrarray_b->pdata : NULL, - v_ptrarray_b ? v_ptrarray_b->len : 0u)); + NM_CMP_RETURN(nm_strv_cmp_n(v_ptrarray_a ? (const char *const *) v_ptrarray_a->pdata : NULL, + v_ptrarray_a ? v_ptrarray_a->len : 0u, + v_ptrarray_b ? (const char *const *) v_ptrarray_b->pdata : NULL, + v_ptrarray_b ? v_ptrarray_b->len : 0u)); } else nm_assert_not_reached(); return 0; @@ -1136,12 +1135,12 @@ _team_setting_value_master_runner_tx_hash_set_list(NMTeamSetting * self, gboolean changed; guint i; - if (nm_utils_strv_cmp_n(self->d.master.runner_tx_hash - ? (const char *const *) self->d.master.runner_tx_hash->pdata - : NULL, - self->d.master.runner_tx_hash ? self->d.master.runner_tx_hash->len : 0u, - arr, - len) + if (nm_strv_cmp_n(self->d.master.runner_tx_hash + ? (const char *const *) self->d.master.runner_tx_hash->pdata + : NULL, + self->d.master.runner_tx_hash ? self->d.master.runner_tx_hash->len : 0u, + arr, + len) == 0) { changed = FALSE; goto out; @@ -2245,8 +2244,7 @@ _team_setting_verify_properties(const NMTeamSetting *self, GError **error) } else if (attr_data->value_type == NM_VALUE_TYPE_STRING) { const char *v = *((const char *const *) p_field); - if (nm_utils_strv_find_first((char **) attr_data->range.r_string.valid_names, -1, v) - < 0) { + if (nm_strv_find_first(attr_data->range.r_string.valid_names, -1, v) < 0) { g_set_error(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING, @@ -2265,9 +2263,7 @@ _team_setting_verify_properties(const NMTeamSetting *self, GError **error) for (i = 0; i < self->d.master.runner_tx_hash->len; i++) { const char *val = self->d.master.runner_tx_hash->pdata[i]; - if (!val - || (nm_utils_strv_find_first((char **) _valid_names_runner_tx_hash, -1, val) - < 0)) { + if (!val || (nm_strv_find_first(_valid_names_runner_tx_hash, -1, val) < 0)) { g_set_error(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING, @@ -2293,8 +2289,7 @@ _team_setting_verify_properties(const NMTeamSetting *self, GError **error) if (!_team_setting_has_field(self, attr_data)) continue; if (self->d.master.runner - && (nm_utils_strv_find_first((char **) e->valid_runners, -1, self->d.master.runner) - >= 0)) + && (nm_strv_find_first(e->valid_runners, -1, self->d.master.runner) >= 0)) continue; if (e->valid_runners[1] == NULL) { g_set_error(error, @@ -2729,18 +2724,12 @@ _nm_setting_get_team_setting(struct _NMSetting *setting) return _nm_setting_team_port_get_team_setting(NM_SETTING_TEAM_PORT(setting)); } -static GVariant * -_nm_team_settings_property_to_dbus(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +GVariant * +_nm_team_settings_property_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { NMTeamSetting * self = _nm_setting_get_team_setting(setting); const TeamAttrData *attr_data = - _team_attr_data_get(self->d.is_port, - sett_info->property_infos[property_idx].param_spec->param_id); + _team_attr_data_get(self->d.is_port, property_info->param_spec->param_id); if (attr_data->team_attr == NM_TEAM_ATTRIBUTE_CONFIG) { const char *config; @@ -2779,34 +2768,40 @@ _nm_team_settings_property_to_dbus(const NMSettInfoSetting * sett_ return NULL; } -static void -_nm_team_settings_property_from_dbus_link_watchers(GVariant *dbus_value, GValue *prop_value) +void +_nm_team_settings_property_from_dbus_link_watchers( + _NM_SETT_INFO_PROP_FROM_DBUS_GPROP_FCN_ARGS _nm_nil) { - g_value_take_boxed(prop_value, - _nm_utils_team_link_watchers_from_variant(dbus_value, FALSE, NULL)); + g_value_take_boxed(to, _nm_utils_team_link_watchers_from_variant(from, FALSE, NULL)); } const NMSettInfoPropertType nm_sett_info_propert_type_team_b = NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_BOOLEAN, - .to_dbus_fcn = _nm_team_settings_property_to_dbus, ); + .compare_fcn = _nm_setting_property_compare_fcn_default, + .to_dbus_fcn = _nm_team_settings_property_to_dbus, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE); const NMSettInfoPropertType nm_sett_info_propert_type_team_i = NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_INT32, - .to_dbus_fcn = _nm_team_settings_property_to_dbus, ); + .compare_fcn = _nm_setting_property_compare_fcn_default, + .to_dbus_fcn = _nm_team_settings_property_to_dbus, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE); const NMSettInfoPropertType nm_sett_info_propert_type_team_s = NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_STRING, - .to_dbus_fcn = _nm_team_settings_property_to_dbus, ); + .compare_fcn = _nm_setting_property_compare_fcn_default, + .to_dbus_fcn = _nm_team_settings_property_to_dbus, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE); const NMSettInfoPropertType nm_sett_info_propert_type_team_as = NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(NM_G_VARIANT_TYPE("as"), - .to_dbus_fcn = _nm_team_settings_property_to_dbus, ); - -const NMSettInfoPropertType nm_sett_info_propert_type_team_link_watchers = - NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(NM_G_VARIANT_TYPE("aa{sv}"), - .to_dbus_fcn = _nm_team_settings_property_to_dbus, - .gprop_from_dbus_fcn = - _nm_team_settings_property_from_dbus_link_watchers, ); + .compare_fcn = _nm_setting_property_compare_fcn_default, + .to_dbus_fcn = _nm_team_settings_property_to_dbus, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE); /*****************************************************************************/ diff --git a/src/libnm-core-impl/nm-team-utils.h b/src/libnm-core-impl/nm-team-utils.h index 2039c16e..d888e191 100644 --- a/src/libnm-core-impl/nm-team-utils.h +++ b/src/libnm-core-impl/nm-team-utils.h @@ -7,7 +7,7 @@ #define __NM_TEAM_UITLS_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #include "libnm-glib-aux/nm-value-type.h" @@ -266,6 +266,5 @@ extern const NMSettInfoPropertType nm_sett_info_propert_type_team_b; extern const NMSettInfoPropertType nm_sett_info_propert_type_team_i; extern const NMSettInfoPropertType nm_sett_info_propert_type_team_s; extern const NMSettInfoPropertType nm_sett_info_propert_type_team_as; -extern const NMSettInfoPropertType nm_sett_info_propert_type_team_link_watchers; #endif /* __NM_TEAM_UITLS_H__ */ diff --git a/src/libnm-core-impl/nm-utils-private.h b/src/libnm-core-impl/nm-utils-private.h index eb545d0f..679fd6b4 100644 --- a/src/libnm-core-impl/nm-utils-private.h +++ b/src/libnm-core-impl/nm-utils-private.h @@ -7,7 +7,7 @@ #define __NM_UTILS_PRIVATE_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_PRIVATE) - #error Cannot use this header. +#error Cannot use this header. #endif #include "nm-setting-private.h" @@ -32,22 +32,20 @@ gboolean _nm_utils_wps_method_validate(NMSettingWirelessSecurityWpsMethod wps_me /* D-Bus transform funcs */ -extern const NMSettInfoPropertType nm_sett_info_propert_type_strdict; - -extern const NMSettInfoPropertType nm_sett_info_propert_type_mac_address; +gboolean _nm_property_variant_to_gvalue(GVariant *src_value, GValue *dst_value); -extern const NMSettInfoPropertType nm_sett_info_propert_type_cloned_mac_address; +extern const NMSettInfoPropertType nm_sett_info_propert_type_strdict; extern const NMSettInfoPropertType nm_sett_info_propert_type_assigned_mac_address; -extern const NMSettInfoPropertType nm_sett_info_propert_type_bridge_vlans; - -void _nm_utils_strdict_from_dbus(GVariant *dbus_value, GValue *prop_value); +void _nm_utils_strdict_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_GPROP_FCN_ARGS _nm_nil); void _nm_utils_bytes_from_dbus(GVariant *dbus_value, GValue *prop_value); char *_nm_utils_hwaddr_canonical_or_invalid(const char *mac, gssize length); +char *_nm_utils_ipaddr_canonical_or_invalid(int addr_family, const char *ip); + gboolean _nm_utils_hwaddr_link_local_valid(const char *mac); gboolean _nm_sriov_vf_parse_vlans(NMSriovVF *vf, const char *str, GError **error); @@ -58,4 +56,14 @@ gboolean _nm_utils_bridge_vlan_verify_list(GPtrArray * vlans, const char *setting, const char *property); +NMTernary _nm_utils_bridge_compare_vlans(GPtrArray *vlans_a, GPtrArray *vlans_b); + +GVariant *_nm_team_settings_property_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil); + +void _nm_team_settings_property_from_dbus_link_watchers( + _NM_SETT_INFO_PROP_FROM_DBUS_GPROP_FCN_ARGS _nm_nil); + +GVariant *_nm_utils_ip4_dns_to_variant(const char *const *dns, gssize len); +GVariant *_nm_utils_ip6_dns_to_variant(const char *const *dns, gssize len); + #endif diff --git a/src/libnm-core-impl/nm-utils.c b/src/libnm-core-impl/nm-utils.c index 12e3bd40..ccdd4b92 100644 --- a/src/libnm-core-impl/nm-utils.c +++ b/src/libnm-core-impl/nm-utils.c @@ -29,6 +29,7 @@ #include "nm-setting-private.h" #include "nm-crypto.h" #include "nm-setting-bond.h" +#include "nm-setting-bond-port.h" #include "nm-setting-bridge.h" #include "nm-setting-bridge-port.h" #include "nm-setting-infiniband.h" @@ -759,25 +760,28 @@ _nm_utils_hash_values_to_slist(GHashTable *hash) } void -_nm_utils_strdict_from_dbus(GVariant *dbus_value, GValue *prop_value) +_nm_utils_strdict_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_GPROP_FCN_ARGS _nm_nil) { GVariantIter iter; const char * key, *value; GHashTable * hash; hash = g_hash_table_new_full(nm_str_hash, g_str_equal, g_free, g_free); - g_variant_iter_init(&iter, dbus_value); + g_variant_iter_init(&iter, from); while (g_variant_iter_next(&iter, "{&s&s}", &key, &value)) g_hash_table_insert(hash, g_strdup(key), g_strdup(value)); - g_value_take_boxed(prop_value, hash); + g_value_take_boxed(to, hash); } const NMSettInfoPropertType nm_sett_info_propert_type_strdict = NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(NM_G_VARIANT_TYPE("a{ss}"), - .gprop_from_dbus_fcn = _nm_utils_strdict_from_dbus, + .typdata_from_dbus.gprop_fcn = _nm_utils_strdict_from_dbus, .typdata_to_dbus.gprop_type = - NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_STRDICT); + NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_STRDICT, + .compare_fcn = _nm_setting_property_compare_fcn_default, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, + .from_dbus_is_full = TRUE); GHashTable * _nm_utils_copy_strdict(GHashTable *strdict) @@ -835,7 +839,7 @@ _nm_utils_bytes_from_dbus(GVariant *dbus_value, GValue *prop_value) /*****************************************************************************/ GSList * -_nm_utils_strv_to_slist(char **strv, gboolean deep_copy) +nm_strv_to_gslist(char **strv, gboolean deep_copy) { GSList *list = NULL; gsize i; @@ -884,7 +888,7 @@ _nm_utils_slist_to_strv(const GSList *slist, gboolean deep_copy) } GPtrArray * -_nm_utils_strv_to_ptrarray(char **strv) +nm_strv_to_ptrarray(char **strv) { GPtrArray *ptrarray; gsize i, l; @@ -1282,19 +1286,29 @@ nm_utils_wpa_psk_valid(const char *psk) **/ GVariant * nm_utils_ip4_dns_to_variant(char **dns) +{ + return _nm_utils_ip4_dns_to_variant(NM_CAST_STRV_CC(dns), -1); +} + +GVariant * +_nm_utils_ip4_dns_to_variant(const char *const *dns, gssize len) { GVariantBuilder builder; + gsize l; gsize i; + if (len < 0) + l = NM_PTRARRAY_LEN(dns); + else + l = len; + g_variant_builder_init(&builder, G_VARIANT_TYPE("au")); - if (dns) { - for (i = 0; dns[i]; i++) { - guint32 ip = 0; + for (i = 0; i < l; i++) { + in_addr_t ip; - inet_pton(AF_INET, dns[i], &ip); + if (inet_pton(AF_INET, dns[i], &ip) == 1) g_variant_builder_add(&builder, "u", ip); - } } return g_variant_builder_end(&builder); @@ -1591,19 +1605,29 @@ nm_utils_ip4_get_default_prefix(guint32 ip) **/ GVariant * nm_utils_ip6_dns_to_variant(char **dns) +{ + return _nm_utils_ip6_dns_to_variant(NM_CAST_STRV_CC(dns), -1); +} + +GVariant * +_nm_utils_ip6_dns_to_variant(const char *const *dns, gssize len) { GVariantBuilder builder; gsize i; + gsize l; + + if (len < 0) + l = NM_PTRARRAY_LEN(dns); + else + l = len; g_variant_builder_init(&builder, G_VARIANT_TYPE("aay")); - if (dns) { - for (i = 0; dns[i]; i++) { - struct in6_addr ip; + for (i = 0; i < l; i++) { + struct in6_addr ip; - if (inet_pton(AF_INET6, dns[i], &ip) != 1) - continue; - g_variant_builder_add(&builder, "@ay", nm_g_variant_new_ay_in6addr(&ip)); - } + if (inet_pton(AF_INET6, dns[i], &ip) != 1) + continue; + g_variant_builder_add(&builder, "@ay", nm_g_variant_new_ay_in6addr(&ip)); } return g_variant_builder_end(&builder); } @@ -2859,7 +2883,7 @@ _nm_sriov_vf_parse_vlans(NMSriovVF *vf, const char *str, GError **error) gs_free const char **vlans = NULL; guint i; - vlans = nm_utils_strsplit_set(str, ";"); + vlans = nm_strsplit_set(str, ";"); if (!vlans) { g_set_error_literal(error, NM_CONNECTION_ERROR, @@ -3625,6 +3649,23 @@ nm_utils_wifi_strength_bars(guint8 strength) return " "; } +gboolean +_nm_property_variant_to_gvalue(GVariant *src_value, GValue *dst_value) +{ + GValue tmp = G_VALUE_INIT; + gboolean success; + + g_dbus_gvariant_to_gvalue(src_value, &tmp); + if (G_VALUE_TYPE(&tmp) == G_VALUE_TYPE(dst_value)) { + *dst_value = tmp; + return TRUE; + } + + success = g_value_transform(&tmp, dst_value); + g_value_unset(&tmp); + return success; +} + /** * nm_utils_hwaddr_len: * @type: the type of address; either ARPHRD_ETHER or @@ -3857,6 +3898,25 @@ _nm_utils_hwaddr_canonical_or_invalid(const char *mac, gssize length) return g_strdup(mac); } +char * +_nm_utils_ipaddr_canonical_or_invalid(int addr_family, const char *ip) +{ + NMIPAddr addr_bin; + + nm_assert_addr_family(addr_family); + + if (!ip) + return NULL; + + if (!nm_utils_parse_inaddr_bin(addr_family, ip, NULL, &addr_bin)) + return g_strdup(ip); + + if (nm_ip_addr_is_null(addr_family, &addr_bin)) + return NULL; + + return nm_utils_inet_ntop_dup(addr_family, &addr_bin); +} + /* * Determine if given Ethernet address is link-local * @@ -4002,47 +4062,41 @@ nm_utils_hwaddr_to_dbus(const char *str) return nm_g_variant_new_ay(buf, len); } -static GVariant * -_nm_utils_hwaddr_cloned_get(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +GVariant * +_nm_utils_hwaddr_cloned_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_free char *addr = NULL; - nm_assert(nm_streq(sett_info->property_infos[property_idx].name, "cloned-mac-address")); + nm_assert(nm_streq(property_info->name, "cloned-mac-address")); g_object_get(setting, "cloned-mac-address", &addr, NULL); return nm_utils_hwaddr_to_dbus(addr); } -static gboolean -_nm_utils_hwaddr_cloned_set(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +gboolean +_nm_utils_hwaddr_cloned_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { gsize length; const guint8 *array; char * str; - nm_assert(nm_streq0(property, "cloned-mac-address")); + nm_assert(nm_streq0(property_info->name, "cloned-mac-address")); if (!_nm_setting_use_legacy_property(setting, connection_dict, "cloned-mac-address", - "assigned-mac-address")) + "assigned-mac-address")) { + *out_is_modified = FALSE; return TRUE; + } length = 0; array = g_variant_get_fixed_array(value, &length, 1); - if (!length) + if (!length) { + *out_is_modified = FALSE; return TRUE; + } str = nm_utils_hwaddr_ntoa(array, length); g_object_set(setting, "cloned-mac-address", str, NULL); @@ -4050,37 +4104,22 @@ _nm_utils_hwaddr_cloned_set(NMSetting * setting, return TRUE; } -static gboolean -_nm_utils_hwaddr_cloned_not_set(NMSetting * setting, - GVariant * connection_dict, - const char * property, - NMSettingParseFlags parse_flags, - GError ** error) +gboolean +_nm_utils_hwaddr_cloned_not_set(_NM_SETT_INFO_PROP_MISSING_FROM_DBUS_FCN_ARGS _nm_nil) { nm_assert(nm_streq0(property, "cloned-mac-address")); return TRUE; } -const NMSettInfoPropertType nm_sett_info_propert_type_cloned_mac_address = - NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_BYTESTRING, - .to_dbus_fcn = _nm_utils_hwaddr_cloned_get, - .from_dbus_fcn = _nm_utils_hwaddr_cloned_set, - .missing_from_dbus_fcn = _nm_utils_hwaddr_cloned_not_set, ); - static GVariant * -_nm_utils_hwaddr_cloned_data_synth(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +_nm_utils_hwaddr_cloned_data_synth(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_free char *addr = NULL; if (!_nm_connection_serialize_non_secret(flags)) return NULL; - nm_assert(nm_streq0(sett_info->property_infos[property_idx].name, "assigned-mac-address")); + nm_assert(nm_streq0(property_info->name, "assigned-mac-address")); g_object_get(setting, "cloned-mac-address", &addr, NULL); @@ -4102,20 +4141,17 @@ _nm_utils_hwaddr_cloned_data_synth(const NMSettInfoSetting * sett_ } static gboolean -_nm_utils_hwaddr_cloned_data_set(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +_nm_utils_hwaddr_cloned_data_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { - nm_assert(nm_streq0(property, "assigned-mac-address")); + nm_assert(nm_streq0(property_info->name, "assigned-mac-address")); if (_nm_setting_use_legacy_property(setting, connection_dict, "cloned-mac-address", - "assigned-mac-address")) + "assigned-mac-address")) { + *out_is_modified = FALSE; return TRUE; + } g_object_set(setting, "cloned-mac-address", @@ -4126,26 +4162,10 @@ _nm_utils_hwaddr_cloned_data_set(NMSetting * setting, const NMSettInfoPropertType nm_sett_info_propert_type_assigned_mac_address = NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_STRING, + .compare_fcn = _nm_setting_property_compare_fcn_ignore, .to_dbus_fcn = _nm_utils_hwaddr_cloned_data_synth, .from_dbus_fcn = _nm_utils_hwaddr_cloned_data_set, ); -static void -_nm_utils_hwaddr_from_dbus(GVariant *dbus_value, GValue *prop_value) -{ - gsize length = 0; - const guint8 *array = g_variant_get_fixed_array(dbus_value, &length, 1); - char * str; - - str = length ? nm_utils_hwaddr_ntoa(array, length) : NULL; - g_value_take_string(prop_value, str); -} - -const NMSettInfoPropertType nm_sett_info_propert_type_mac_address = - NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT( - G_VARIANT_TYPE_BYTESTRING, - .gprop_from_dbus_fcn = _nm_utils_hwaddr_from_dbus, - .typdata_to_dbus.gprop_type = NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_MAC_ADDRESS); - /*****************************************************************************/ /* Validate secret-flags. Most settings don't validate them, which is a bug. @@ -4583,24 +4603,41 @@ nm_utils_check_virtual_device_compatibility(GType virtual_type, GType other_type FALSE); if (virtual_type == NM_TYPE_SETTING_BOND) { - return (other_type == NM_TYPE_SETTING_INFINIBAND || other_type == NM_TYPE_SETTING_WIRED - || other_type == NM_TYPE_SETTING_BRIDGE || other_type == NM_TYPE_SETTING_BOND - || other_type == NM_TYPE_SETTING_TEAM || other_type == NM_TYPE_SETTING_VLAN); - } else if (virtual_type == NM_TYPE_SETTING_BRIDGE) { - return (other_type == NM_TYPE_SETTING_WIRED || other_type == NM_TYPE_SETTING_BOND - || other_type == NM_TYPE_SETTING_TEAM || other_type == NM_TYPE_SETTING_VLAN); - } else if (virtual_type == NM_TYPE_SETTING_TEAM) { - return (other_type == NM_TYPE_SETTING_WIRED || other_type == NM_TYPE_SETTING_BRIDGE - || other_type == NM_TYPE_SETTING_BOND || other_type == NM_TYPE_SETTING_TEAM - || other_type == NM_TYPE_SETTING_VLAN); - } else if (virtual_type == NM_TYPE_SETTING_VLAN) { - return (other_type == NM_TYPE_SETTING_WIRED || other_type == NM_TYPE_SETTING_WIRELESS - || other_type == NM_TYPE_SETTING_BRIDGE || other_type == NM_TYPE_SETTING_BOND - || other_type == NM_TYPE_SETTING_TEAM || other_type == NM_TYPE_SETTING_VLAN); - } else { - g_warn_if_reached(); - return FALSE; + return NM_IN_SET(other_type, + NM_TYPE_SETTING_BOND, + NM_TYPE_SETTING_BRIDGE, + NM_TYPE_SETTING_INFINIBAND, + NM_TYPE_SETTING_TEAM, + NM_TYPE_SETTING_VLAN, + NM_TYPE_SETTING_WIRED, + NM_TYPE_SETTING_WIRELESS); + } + if (virtual_type == NM_TYPE_SETTING_BRIDGE) { + return NM_IN_SET(other_type, + NM_TYPE_SETTING_BOND, + NM_TYPE_SETTING_TEAM, + NM_TYPE_SETTING_VLAN, + NM_TYPE_SETTING_WIRED); + } + if (virtual_type == NM_TYPE_SETTING_TEAM) { + return NM_IN_SET(other_type, + NM_TYPE_SETTING_BOND, + NM_TYPE_SETTING_BRIDGE, + NM_TYPE_SETTING_TEAM, + NM_TYPE_SETTING_VLAN, + NM_TYPE_SETTING_WIRED); + } + if (virtual_type == NM_TYPE_SETTING_VLAN) { + return NM_IN_SET(other_type, + NM_TYPE_SETTING_BOND, + NM_TYPE_SETTING_BRIDGE, + NM_TYPE_SETTING_TEAM, + NM_TYPE_SETTING_VLAN, + NM_TYPE_SETTING_WIRED, + NM_TYPE_SETTING_WIRELESS); } + + return FALSE; } /*****************************************************************************/ @@ -5445,18 +5482,13 @@ nm_utils_base64secret_normalize(const char *base64_key, return TRUE; } -static GVariant * -_nm_utils_bridge_vlans_to_dbus(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +GVariant * +_nm_utils_bridge_vlans_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *vlans = NULL; GVariantBuilder builder; guint i; - const char * property_name = sett_info->property_infos[property_idx].name; + const char * property_name = property_info->name; nm_assert(property_name); @@ -5492,13 +5524,8 @@ _nm_utils_bridge_vlans_to_dbus(const NMSettInfoSetting * sett_info return g_variant_builder_end(&builder); } -static gboolean -_nm_utils_bridge_vlans_from_dbus(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error) +gboolean +_nm_utils_bridge_vlans_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *vlans = NULL; GVariantIter vlan_iter; @@ -5539,15 +5566,25 @@ _nm_utils_bridge_vlans_from_dbus(NMSetting * setting, g_ptr_array_add(vlans, vlan); } - g_object_set(setting, property, vlans, NULL); + g_object_set(setting, property_info->name, vlans, NULL); return TRUE; } -const NMSettInfoPropertType nm_sett_info_propert_type_bridge_vlans = - NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(NM_G_VARIANT_TYPE("aa{sv}"), - .to_dbus_fcn = _nm_utils_bridge_vlans_to_dbus, - .from_dbus_fcn = _nm_utils_bridge_vlans_from_dbus, ); +NMTernary +_nm_utils_bridge_compare_vlans(GPtrArray *vlans_a, GPtrArray *vlans_b) +{ + guint l = nm_g_ptr_array_len(vlans_a); + guint i; + + if (l != nm_g_ptr_array_len(vlans_b)) + return FALSE; + for (i = 0; i < l; i++) { + if (nm_bridge_vlan_cmp(vlans_a->pdata[i], vlans_b->pdata[i])) + return FALSE; + } + return TRUE; +} gboolean _nm_utils_bridge_vlan_verify_list(GPtrArray * vlans, diff --git a/src/libnm-core-impl/nm-vpn-plugin-info.c b/src/libnm-core-impl/nm-vpn-plugin-info.c index dc77dfd0..2ffb7774 100644 --- a/src/libnm-core-impl/nm-vpn-plugin-info.c +++ b/src/libnm-core-impl/nm-vpn-plugin-info.c @@ -337,7 +337,7 @@ nm_vpn_plugin_info_list_load() uid = getuid(); for (i = 0; i < G_N_ELEMENTS(dir); i++) { - if (!dir[i] || nm_utils_strv_find_first((char **) dir, i, dir[i]) >= 0) + if (!dir[i] || nm_strv_find_first(dir, i, dir[i]) >= 0) continue; infos = _nm_vpn_plugin_info_list_load_dir(dir[i], TRUE, uid, NULL, NULL); @@ -552,7 +552,7 @@ _list_find_by_service(GSList *list, const char *name, const char *service) if (name && !nm_streq(name, priv->name)) continue; if (service && !nm_streq(priv->service, service) - && (nm_utils_strv_find_first(priv->aliases, -1, service) < 0)) + && (nm_strv_find_first(priv->aliases, -1, service) < 0)) continue; return list->data; @@ -639,7 +639,7 @@ nm_vpn_plugin_info_list_find_service_type(GSList *list, const char *name) /* check the hard-coded list of short-names. They all have the same * well-known prefix org.freedesktop.NetworkManager and the name. */ - if (nm_utils_strv_find_first((char **) known_names, G_N_ELEMENTS(known_names), name) >= 0) + if (nm_strv_find_first(known_names, G_N_ELEMENTS(known_names), name) >= 0) return g_strdup_printf("%s.%s", NM_DBUS_INTERFACE, name); /* try, if there exists a plugin with @name under org.freedesktop.NetworkManager. @@ -1277,7 +1277,7 @@ finalize(GObject *object) g_free(priv->auth_dialog); g_strfreev(priv->aliases); g_free(priv->filename); - g_hash_table_unref(priv->keys); + nm_g_hash_table_unref(priv->keys); nm_clear_pointer(&priv->keyfile, g_key_file_unref); diff --git a/src/libnm-core-impl/tests/test-crypto.c b/src/libnm-core-impl/tests/test-crypto.c index bdbcd0f3..1c072f71 100644 --- a/src/libnm-core-impl/tests/test-crypto.c +++ b/src/libnm-core-impl/tests/test-crypto.c @@ -135,7 +135,7 @@ test_load_private_key(const char *path, /* Compare the crypto decrypted key against a known-good decryption */ if (!g_file_get_contents(decrypted_path, &contents, &length, NULL)) g_assert_not_reached(); - g_assert(nm_utils_gbytes_equal_mem(array, contents, length)); + g_assert(nm_g_bytes_equal_mem(array, contents, length)); } } diff --git a/src/libnm-core-impl/tests/test-general.c b/src/libnm-core-impl/tests/test-general.c index 57864948..5c831cb7 100644 --- a/src/libnm-core-impl/tests/test-general.c +++ b/src/libnm-core-impl/tests/test-general.c @@ -478,6 +478,38 @@ test_nm_hash(void) g_assert_cmpint(NM_HASH_COMBINE_BOOLS(guint16, 0, 0, 1, 1, 0, 0, 0, 1), ==, 0x031); g_assert_cmpint(NM_HASH_COMBINE_BOOLS(guint16, 0, 0, 0, 1, 1, 0, 0, 0, 1), ==, 0x031); g_assert_cmpint(NM_HASH_COMBINE_BOOLS(guint16, 1, 0, 0, 1, 1, 0, 0, 0, 1), ==, 0x131); + g_assert_cmpint(NM_HASH_COMBINE_BOOLS(guint16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1), + ==, + 0x131); + g_assert_cmpint(NM_HASH_COMBINE_BOOLS(guint16, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1), + ==, + 0x8131); + g_assert_cmpint( + NM_HASH_COMBINE_BOOLS(guint32, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1), + ==, + 0x8131); + g_assert_cmpint( + NM_HASH_COMBINE_BOOLS(guint32, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1), + ==, + 0x28131); + +#if _NM_CC_SUPPORT_AUTO_TYPE + { + _nm_auto_type x = NM_HASH_COMBINE_BOOLS(guint8, 0, 0, 1, 1, 0, 0, 0, 1); + + G_STATIC_ASSERT(sizeof(x) == 1); + g_assert(((typeof(x)) -1) > 0); + } + + { + _nm_auto_type x = NM_HASH_COMBINE_BOOLS(guint16, 0, 0, 1, 1, 0, 0, 0, 1); + + G_STATIC_ASSERT(sizeof(x) == 2); + g_assert(((typeof(x)) -1) > 0); + } +#endif + + NM_STATIC_ASSERT_EXPR_VOID(NM_HASH_COMBINE_BOOLS(int, 1, 0, 1) == 5); } /*****************************************************************************/ @@ -510,27 +542,25 @@ test_nm_g_slice_free_fcn(void) /*****************************************************************************/ static void -_do_test_nm_utils_strsplit_set_f_one(NMUtilsStrsplitSetFlags flags, - const char * str, - gsize words_len, - const char *const * exp_words) +_do_test_nm_strsplit_set_f_one(NMUtilsStrsplitSetFlags flags, + const char * str, + gsize words_len, + const char *const * exp_words) { #define DELIMITERS " \n" #define DELIMITERS_C ' ', '\n' gs_free const char **words = NULL; gsize i, j, k; - const gboolean f_allow_escaping = - NM_FLAGS_HAS(flags, NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING); - const gboolean f_preserve_empty = - NM_FLAGS_HAS(flags, NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY); + const gboolean f_allow_escaping = NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING); + const gboolean f_preserve_empty = NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY); const char * s1; gsize initial_offset; gs_strfreev char **words_g = NULL; - g_assert(!NM_FLAGS_ANY(flags, - ~(NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING - | NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY))); + g_assert(!NM_FLAGS_ANY( + flags, + ~(NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING | NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY))); /* assert that the expected words are valid (and don't contain unescaped delimiters). */ for (i = 0; i < words_len; i++) { @@ -587,16 +617,16 @@ _do_test_nm_utils_strsplit_set_f_one(NMUtilsStrsplitSetFlags flags, } g_assert(words_g[words_len] == NULL); g_assert_cmpint(NM_PTRARRAY_LEN(words_g), ==, words_len); - g_assert(nm_utils_strv_cmp_n(exp_words, words_len, words_g, -1) == 0); + g_assert(nm_strv_cmp_n(exp_words, words_len, words_g, -1) == 0); } } - if (flags == NM_UTILS_STRSPLIT_SET_FLAGS_NONE && nmtst_get_rand_bool()) - words = nm_utils_strsplit_set(str, DELIMITERS); - else if (flags == NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY && nmtst_get_rand_bool()) - words = nm_utils_strsplit_set_with_empty(str, DELIMITERS); + if (flags == NM_STRSPLIT_SET_FLAGS_NONE && nmtst_get_rand_bool()) + words = nm_strsplit_set(str, DELIMITERS); + else if (flags == NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY && nmtst_get_rand_bool()) + words = nm_strsplit_set_with_empty(str, DELIMITERS); else - words = nm_utils_strsplit_set_full(str, DELIMITERS, flags); + words = nm_strsplit_set_full(str, DELIMITERS, flags); g_assert_cmpint(NM_PTRARRAY_LEN(words), ==, words_len); @@ -611,7 +641,7 @@ _do_test_nm_utils_strsplit_set_f_one(NMUtilsStrsplitSetFlags flags, g_assert_cmpstr(exp_words[i], ==, words[i]); g_assert(words[words_len] == NULL); - g_assert(nm_utils_strv_cmp_n(exp_words, words_len, words, -1) == 0); + g_assert(nm_strv_cmp_n(exp_words, words_len, words, -1) == 0); s1 = words[0]; g_assert(s1 >= (char *) &words[words_len + 1]); @@ -719,14 +749,14 @@ _do_test_nm_utils_strsplit_set_f_one(NMUtilsStrsplitSetFlags flags, } static void -_do_test_nm_utils_strsplit_set_f(NMUtilsStrsplitSetFlags flags, - const char * str, - gsize words_len, - const char *const * exp_words) +_do_test_nm_strsplit_set_f(NMUtilsStrsplitSetFlags flags, + const char * str, + gsize words_len, + const char *const * exp_words) { - _do_test_nm_utils_strsplit_set_f_one(flags, str, words_len, exp_words); + _do_test_nm_strsplit_set_f_one(flags, str, words_len, exp_words); - if (NM_FLAGS_HAS(flags, NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY)) { + if (NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY)) { gs_unref_ptrarray GPtrArray *exp_words2 = NULL; gsize k; @@ -736,32 +766,32 @@ _do_test_nm_utils_strsplit_set_f(NMUtilsStrsplitSetFlags flags, g_ptr_array_add(exp_words2, (gpointer) exp_words[k]); } - _do_test_nm_utils_strsplit_set_f_one(flags & (~NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY), - str, - exp_words2->len, - (const char *const *) exp_words2->pdata); + _do_test_nm_strsplit_set_f_one(flags & (~NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY), + str, + exp_words2->len, + (const char *const *) exp_words2->pdata); } } -#define do_test_nm_utils_strsplit_set_f(flags, str, ...) \ - _do_test_nm_utils_strsplit_set_f(flags, str, NM_NARG(__VA_ARGS__), NM_MAKE_STRV(__VA_ARGS__)) +#define do_test_nm_strsplit_set_f(flags, str, ...) \ + _do_test_nm_strsplit_set_f(flags, str, NM_NARG(__VA_ARGS__), NM_MAKE_STRV(__VA_ARGS__)) -#define do_test_nm_utils_strsplit_set(allow_escaping, str, ...) \ - do_test_nm_utils_strsplit_set_f((allow_escaping) ? NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING \ - : NM_UTILS_STRSPLIT_SET_FLAGS_NONE, \ - str, \ - ##__VA_ARGS__) +#define do_test_nm_strsplit_set(allow_escaping, str, ...) \ + do_test_nm_strsplit_set_f((allow_escaping) ? NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING \ + : NM_STRSPLIT_SET_FLAGS_NONE, \ + str, \ + ##__VA_ARGS__) static void -_do_test_nm_utils_strsplit_set_simple(NMUtilsStrsplitSetFlags flags, - const char * str, - gsize words_len, - const char *const * exp_words) +_do_test_nm_strsplit_set_simple(NMUtilsStrsplitSetFlags flags, + const char * str, + gsize words_len, + const char *const * exp_words) { gs_free const char **tokens = NULL; gsize n_tokens; - tokens = nm_utils_strsplit_set_full(str, DELIMITERS, flags); + tokens = nm_strsplit_set_full(str, DELIMITERS, flags); if (!tokens) { g_assert_cmpint(words_len, ==, 0); @@ -772,7 +802,7 @@ _do_test_nm_utils_strsplit_set_simple(NMUtilsStrsplitSetFlags flags, g_assert_cmpint(words_len, >, 0); n_tokens = NM_PTRARRAY_LEN(tokens); - if (nm_utils_strv_cmp_n(exp_words, words_len, tokens, -1) != 0) { + if (nm_strv_cmp_n(exp_words, words_len, tokens, -1) != 0) { gsize i; g_print(">>> split \"%s\" (flags %x) got %zu tokens (%zu expected)\n", @@ -794,107 +824,87 @@ _do_test_nm_utils_strsplit_set_simple(NMUtilsStrsplitSetFlags flags, } g_assert_cmpint(words_len, ==, NM_PTRARRAY_LEN(tokens)); } -#define do_test_nm_utils_strsplit_set_simple(flags, str, ...) \ - _do_test_nm_utils_strsplit_set_simple((flags), \ - (str), \ - NM_NARG(__VA_ARGS__), \ - NM_MAKE_STRV(__VA_ARGS__)) +#define do_test_nm_strsplit_set_simple(flags, str, ...) \ + _do_test_nm_strsplit_set_simple((flags), (str), NM_NARG(__VA_ARGS__), NM_MAKE_STRV(__VA_ARGS__)) static void -test_nm_utils_strsplit_set(void) +test_nm_strsplit_set(void) { gs_unref_ptrarray GPtrArray *words_exp = NULL; guint test_run; - do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_NONE, NULL); - do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_NONE, ""); - do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_NONE, " "); - do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_NONE, "a b", "a", "b"); - - do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, NULL); - do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, ""); - do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, " ", "", ""); - do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, " ", "", "", ""); - do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, "a ", "a", "", ""); - do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, - "a b", - "a", - "", - "b"); - do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, - " ab b", - "", - "ab", - "", - "b"); - do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, - "ab b", - "ab", - "", - "b"); - do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, "abb", "abb"); - do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, - "abb bb ", - "abb", - "", - "bb", - ""); - do_test_nm_utils_strsplit_set_f(NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, - "abb bcb ", - "abb", - "bcb", - ""); - - do_test_nm_utils_strsplit_set(FALSE, NULL); - do_test_nm_utils_strsplit_set(FALSE, ""); - do_test_nm_utils_strsplit_set(FALSE, "\n"); - do_test_nm_utils_strsplit_set(TRUE, " \t\n", "\t"); - do_test_nm_utils_strsplit_set(FALSE, "a", "a"); - do_test_nm_utils_strsplit_set(FALSE, "a b", "a", "b"); - do_test_nm_utils_strsplit_set(FALSE, "a\rb", "a\rb"); - do_test_nm_utils_strsplit_set(FALSE, " a\rb ", "a\rb"); - do_test_nm_utils_strsplit_set(FALSE, " a bbbd afds ere", "a", "bbbd", "afds", "ere"); - do_test_nm_utils_strsplit_set(FALSE, - "1 2 3 4 5 6 7 8 9 0 " - "1 2 3 4 5 6 7 8 9 0 " - "1 2 3 4 5 6 7 8 9 0", - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "0", - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "0", - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "0"); - do_test_nm_utils_strsplit_set(TRUE, "\\", "\\"); - do_test_nm_utils_strsplit_set(TRUE, "\\ ", "\\ "); - do_test_nm_utils_strsplit_set(TRUE, "\\\\", "\\\\"); - do_test_nm_utils_strsplit_set(TRUE, "\\\t", "\\\t"); - do_test_nm_utils_strsplit_set(TRUE, "foo\\", "foo\\"); - do_test_nm_utils_strsplit_set(TRUE, "bar foo\\", "bar", "foo\\"); - do_test_nm_utils_strsplit_set(TRUE, "\\ a b\\ \\ c", "\\ a", "b\\ \\ ", "c"); + do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_NONE, NULL); + do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_NONE, ""); + do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_NONE, " "); + do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_NONE, "a b", "a", "b"); + + do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, NULL); + do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, ""); + do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, " ", "", ""); + do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, " ", "", "", ""); + do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, "a ", "a", "", ""); + do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, "a b", "a", "", "b"); + do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, " ab b", "", "ab", "", "b"); + do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, "ab b", "ab", "", "b"); + do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, "abb", "abb"); + do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, + "abb bb ", + "abb", + "", + "bb", + ""); + do_test_nm_strsplit_set_f(NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, "abb bcb ", "abb", "bcb", ""); + + do_test_nm_strsplit_set(FALSE, NULL); + do_test_nm_strsplit_set(FALSE, ""); + do_test_nm_strsplit_set(FALSE, "\n"); + do_test_nm_strsplit_set(TRUE, " \t\n", "\t"); + do_test_nm_strsplit_set(FALSE, "a", "a"); + do_test_nm_strsplit_set(FALSE, "a b", "a", "b"); + do_test_nm_strsplit_set(FALSE, "a\rb", "a\rb"); + do_test_nm_strsplit_set(FALSE, " a\rb ", "a\rb"); + do_test_nm_strsplit_set(FALSE, " a bbbd afds ere", "a", "bbbd", "afds", "ere"); + do_test_nm_strsplit_set(FALSE, + "1 2 3 4 5 6 7 8 9 0 " + "1 2 3 4 5 6 7 8 9 0 " + "1 2 3 4 5 6 7 8 9 0", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "0", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "0", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "0"); + do_test_nm_strsplit_set(TRUE, "\\", "\\"); + do_test_nm_strsplit_set(TRUE, "\\ ", "\\ "); + do_test_nm_strsplit_set(TRUE, "\\\\", "\\\\"); + do_test_nm_strsplit_set(TRUE, "\\\t", "\\\t"); + do_test_nm_strsplit_set(TRUE, "foo\\", "foo\\"); + do_test_nm_strsplit_set(TRUE, "bar foo\\", "bar", "foo\\"); + do_test_nm_strsplit_set(TRUE, "\\ a b\\ \\ c", "\\ a", "b\\ \\ ", "c"); words_exp = g_ptr_array_new_with_free_func(g_free); for (test_run = 0; test_run < 100; test_run++) { @@ -942,52 +952,40 @@ test_nm_utils_strsplit_set(void) words_len = 0; } - _do_test_nm_utils_strsplit_set_f((f_allow_escaping - ? NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING - : NM_UTILS_STRSPLIT_SET_FLAGS_NONE) - | NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, - str, - words_len, - (const char *const *) words_exp->pdata); + _do_test_nm_strsplit_set_f( + (f_allow_escaping ? NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING : NM_STRSPLIT_SET_FLAGS_NONE) + | NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, + str, + words_len, + (const char *const *) words_exp->pdata); } - do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED, "\t", "\t"); - do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED - | NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP, - "\t"); - do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED - | NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP - | NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, - "\t", - ""); - do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED - | NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP - | NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, - "\t\\\t\t\t\\\t", - "\t\t\t\t"); - - do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED, "\ta", "\ta"); - do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED - | NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP, - "\ta", - "a"); - do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED, - "\ta\\ b\t\\ ", - "\ta b\t "); - do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED - | NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP, - "\ta\\ b\t\\ \t", - "a b\t "); - do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED, "a\\ b", "a ", "b"); - do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED, - "\ta\\ b", - "\ta ", - "b"); - do_test_nm_utils_strsplit_set_simple(NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED - | NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP, - "\ta\\ b", - "a ", - "b"); + do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED, "\t", "\t"); + do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED | NM_STRSPLIT_SET_FLAGS_STRSTRIP, + "\t"); + do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED | NM_STRSPLIT_SET_FLAGS_STRSTRIP + | NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, + "\t", + ""); + do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED | NM_STRSPLIT_SET_FLAGS_STRSTRIP + | NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, + "\t\\\t\t\t\\\t", + "\t\t\t\t"); + + do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED, "\ta", "\ta"); + do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED | NM_STRSPLIT_SET_FLAGS_STRSTRIP, + "\ta", + "a"); + do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED, "\ta\\ b\t\\ ", "\ta b\t "); + do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED | NM_STRSPLIT_SET_FLAGS_STRSTRIP, + "\ta\\ b\t\\ \t", + "a b\t "); + do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED, "a\\ b", "a ", "b"); + do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED, "\ta\\ b", "\ta ", "b"); + do_test_nm_strsplit_set_simple(NM_STRSPLIT_SET_FLAGS_ESCAPED | NM_STRSPLIT_SET_FLAGS_STRSTRIP, + "\ta\\ b", + "a ", + "b"); } /*****************************************************************************/ @@ -3062,8 +3060,7 @@ test_setting_new_from_dbus_bad(void) "i", 10);); conn = _connection_new_from_dbus(dict, &error); - g_assert(conn); - g_assert_no_error(error); + nmtst_assert_success(conn, error); setting = nm_connection_get_setting(conn, NM_TYPE_SETTING_WIRELESS); g_assert(setting); g_assert_cmpint(nm_setting_wireless_get_rate(NM_SETTING_WIRELESS(setting)), ==, 10); @@ -3823,6 +3820,7 @@ test_connection_diff_a_only(void) {NM_SETTING_CONNECTION_AUTH_RETRIES, NM_SETTING_DIFF_RESULT_IN_A}, {NM_SETTING_CONNECTION_MDNS, NM_SETTING_DIFF_RESULT_IN_A}, {NM_SETTING_CONNECTION_LLMNR, NM_SETTING_DIFF_RESULT_IN_A}, + {NM_SETTING_CONNECTION_DNS_OVER_TLS, NM_SETTING_DIFF_RESULT_IN_A}, {NM_SETTING_CONNECTION_MUD_URL, NM_SETTING_DIFF_RESULT_IN_A}, {NM_SETTING_CONNECTION_WAIT_DEVICE_TIMEOUT, NM_SETTING_DIFF_RESULT_IN_A}, {NULL, NM_SETTING_DIFF_RESULT_UNKNOWN}}}, @@ -5016,7 +5014,7 @@ test_connection_changed_signal(void) connection = new_test_connection(); g_signal_connect(connection, NM_CONNECTION_CHANGED, - (GCallback) test_connection_changed_cb, + G_CALLBACK(test_connection_changed_cb), &changed); /* Add new setting */ @@ -5042,7 +5040,7 @@ test_setting_connection_changed_signal(void) connection = nm_simple_connection_new(); g_signal_connect(connection, NM_CONNECTION_CHANGED, - (GCallback) test_connection_changed_cb, + G_CALLBACK(test_connection_changed_cb), &changed); s_con = (NMSettingConnection *) nm_setting_connection_new(); @@ -5078,7 +5076,7 @@ test_setting_bond_changed_signal(void) connection = nm_simple_connection_new(); g_signal_connect(connection, NM_CONNECTION_CHANGED, - (GCallback) test_connection_changed_cb, + G_CALLBACK(test_connection_changed_cb), &changed); s_bond = (NMSettingBond *) nm_setting_bond_new(); @@ -5104,7 +5102,7 @@ test_setting_ip4_changed_signal(void) connection = nm_simple_connection_new(); g_signal_connect(connection, NM_CONNECTION_CHANGED, - (GCallback) test_connection_changed_cb, + G_CALLBACK(test_connection_changed_cb), &changed); s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); @@ -5180,7 +5178,7 @@ test_setting_ip6_changed_signal(void) connection = nm_simple_connection_new(); g_signal_connect(connection, NM_CONNECTION_CHANGED, - (GCallback) test_connection_changed_cb, + G_CALLBACK(test_connection_changed_cb), &changed); s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); @@ -5247,7 +5245,7 @@ test_setting_vlan_changed_signal(void) connection = nm_simple_connection_new(); g_signal_connect(connection, NM_CONNECTION_CHANGED, - (GCallback) test_connection_changed_cb, + G_CALLBACK(test_connection_changed_cb), &changed); s_vlan = (NMSettingVlan *) nm_setting_vlan_new(); @@ -5282,7 +5280,7 @@ test_setting_vpn_changed_signal(void) connection = nm_simple_connection_new(); g_signal_connect(connection, NM_CONNECTION_CHANGED, - (GCallback) test_connection_changed_cb, + G_CALLBACK(test_connection_changed_cb), &changed); s_vpn = (NMSettingVpn *) nm_setting_vpn_new(); @@ -5309,7 +5307,7 @@ test_setting_wired_changed_signal(void) connection = nm_simple_connection_new(); g_signal_connect(connection, NM_CONNECTION_CHANGED, - (GCallback) test_connection_changed_cb, + G_CALLBACK(test_connection_changed_cb), &changed); s_wired = (NMSettingWired *) nm_setting_wired_new(); @@ -5332,7 +5330,7 @@ test_setting_wireless_changed_signal(void) connection = nm_simple_connection_new(); g_signal_connect(connection, NM_CONNECTION_CHANGED, - (GCallback) test_connection_changed_cb, + G_CALLBACK(test_connection_changed_cb), &changed); s_wifi = (NMSettingWireless *) nm_setting_wireless_new(); @@ -5353,7 +5351,7 @@ test_setting_wireless_security_changed_signal(void) connection = nm_simple_connection_new(); g_signal_connect(connection, NM_CONNECTION_CHANGED, - (GCallback) test_connection_changed_cb, + G_CALLBACK(test_connection_changed_cb), &changed); s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new(); @@ -5420,7 +5418,7 @@ test_setting_802_1x_changed_signal(void) connection = nm_simple_connection_new(); g_signal_connect(connection, NM_CONNECTION_CHANGED, - (GCallback) test_connection_changed_cb, + G_CALLBACK(test_connection_changed_cb), &changed); s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); @@ -7121,7 +7119,7 @@ test_hexstr2bin(void) g_assert(b); else g_assert(!b); - g_assert(nm_utils_gbytes_equal_mem(b, items[i].expected, items[i].expected_len)); + g_assert(nm_g_bytes_equal_mem(b, items[i].expected, items[i].expected_len)); } } @@ -7209,11 +7207,10 @@ test_nm_strquote(void) /*****************************************************************************/ -#define UUID_NS_ZERO "00000000-0000-0000-0000-000000000000" -#define UUID_NS_DNS "6ba7b810-9dad-11d1-80b4-00c04fd430c8" -#define UUID_NS_URL "6ba7b811-9dad-11d1-80b4-00c04fd430c8" -#define UUID_NS_OID "6ba7b812-9dad-11d1-80b4-00c04fd430c8" -#define UUID_NS_X500 "6ba7b814-9dad-11d1-80b4-00c04fd430c8" +#define NM_UUID_NS_DNS "6ba7b810-9dad-11d1-80b4-00c04fd430c8" +#define NM_UUID_NS_URL "6ba7b811-9dad-11d1-80b4-00c04fd430c8" +#define NM_UUID_NS_OID "6ba7b812-9dad-11d1-80b4-00c04fd430c8" +#define NM_UUID_NS_X500 "6ba7b814-9dad-11d1-80b4-00c04fd430c8" static const NMUuid * _uuid(const char *str) @@ -7230,11 +7227,18 @@ _test_uuid(int uuid_type, const char *expected_uuid, const char *str, gssize slen, - gpointer type_args) + const char *type_args) { - gs_free char *uuid_test = NULL; + gs_free char *uuid_test = NULL; + NMUuid type_args_u = NM_UUID_INIT_ZERO(); - uuid_test = nm_uuid_generate_from_string_str(str, slen, uuid_type, type_args); + if (type_args) { + if (!nm_uuid_parse(type_args, &type_args_u)) + g_assert_not_reached(); + } + + uuid_test = + nm_uuid_generate_from_string_str(str, slen, uuid_type, type_args ? &type_args_u : NULL); g_assert(uuid_test); g_assert(nm_utils_is_uuid(uuid_test)); @@ -7245,7 +7249,7 @@ _test_uuid(int uuid_type, str, (long long) slen, NM_IN_SET(uuid_type, NM_UUID_TYPE_VERSION3, NM_UUID_TYPE_VERSION5) - ? (((const char *) type_args) ?: "(all-zero)") + ? (type_args ?: "(all-zero)") : (type_args ? "(unknown)" : "(null)"), uuid_test, expected_uuid); @@ -7260,8 +7264,8 @@ _test_uuid(int uuid_type, } if (NM_IN_SET(uuid_type, NM_UUID_TYPE_VERSION3, NM_UUID_TYPE_VERSION5) && !type_args) { - /* For version3 and version5, a missing @type_args is equal to UUID_NS_ZERO */ - _test_uuid(uuid_type, expected_uuid, str, slen, UUID_NS_ZERO); + /* For version3 and version5, a missing @type_args is equal to NM_UUID_NS_ZERO */ + _test_uuid(uuid_type, expected_uuid, str, slen, NM_UUID_NS_ZERO); } } @@ -7695,33 +7699,53 @@ test_nm_utils_uuid_generate_from_string(void) _test_uuid(NM_UUID_TYPE_VERSION3, "96e17d7a-ac89-38cf-95e1-bf5098da34e1", "test", -1, NULL); _test_uuid(NM_UUID_TYPE_VERSION3, "8156568e-4ae6-3f34-a93e-18e2c6cbbf78", "a\0b", 3, NULL); - _test_uuid(NM_UUID_TYPE_VERSION3, "c87ee674-4ddc-3efe-a74e-dfe25da5d7b3", "", -1, UUID_NS_DNS); - _test_uuid(NM_UUID_TYPE_VERSION3, "4c104dd0-4821-30d5-9ce3-0e7a1f8b7c0d", "a", -1, UUID_NS_DNS); + _test_uuid(NM_UUID_TYPE_VERSION3, + "c87ee674-4ddc-3efe-a74e-dfe25da5d7b3", + "", + -1, + NM_UUID_NS_DNS); + _test_uuid(NM_UUID_TYPE_VERSION3, + "4c104dd0-4821-30d5-9ce3-0e7a1f8b7c0d", + "a", + -1, + NM_UUID_NS_DNS); _test_uuid(NM_UUID_TYPE_VERSION3, "45a113ac-c7f2-30b0-90a5-a399ab912716", "test", -1, - UUID_NS_DNS); + NM_UUID_NS_DNS); _test_uuid(NM_UUID_TYPE_VERSION3, "002a0ada-f547-375a-bab5-896a11d1927e", "a\0b", 3, - UUID_NS_DNS); + NM_UUID_NS_DNS); _test_uuid(NM_UUID_TYPE_VERSION3, "9a75f5f2-195e-31a9-9d07-8c18b5d3b285", "test123", -1, - UUID_NS_DNS); - _test_uuid(NM_UUID_TYPE_VERSION3, "ec794efe-a384-3b11-a0b6-ec8995bc6acc", "x", -1, UUID_NS_DNS); + NM_UUID_NS_DNS); + _test_uuid(NM_UUID_TYPE_VERSION3, + "ec794efe-a384-3b11-a0b6-ec8995bc6acc", + "x", + -1, + NM_UUID_NS_DNS); _test_uuid(NM_UUID_TYPE_VERSION5, "a7650b9f-f19f-5300-8a13-91160ea8de2c", "a\0b", 3, NULL); - _test_uuid(NM_UUID_TYPE_VERSION5, "4f3f2898-69e3-5a0d-820a-c4e87987dbce", "a", -1, UUID_NS_DNS); - _test_uuid(NM_UUID_TYPE_VERSION5, "05b16a01-46c6-56dd-bd6e-c6dfb4a1427a", "x", -1, UUID_NS_DNS); + _test_uuid(NM_UUID_TYPE_VERSION5, + "4f3f2898-69e3-5a0d-820a-c4e87987dbce", + "a", + -1, + NM_UUID_NS_DNS); + _test_uuid(NM_UUID_TYPE_VERSION5, + "05b16a01-46c6-56dd-bd6e-c6dfb4a1427a", + "x", + -1, + NM_UUID_NS_DNS); _test_uuid(NM_UUID_TYPE_VERSION5, "c9ed566a-6b79-5d3a-b2b7-96a936b48cf3", "test123", -1, - UUID_NS_DNS); + NM_UUID_NS_DNS); for (i = 0; i < G_N_ELEMENTS(zero_uuids); i++) { nm_sprintf_buf(i_str, "%u", i), @@ -7730,8 +7754,8 @@ test_nm_utils_uuid_generate_from_string(void) } for (i = 0; i < G_N_ELEMENTS(dns_uuids); i++) { nm_sprintf_buf(i_str, "%u", i), - _test_uuid(NM_UUID_TYPE_VERSION3, dns_uuids[i].uuid3, i_str, -1, UUID_NS_DNS); - _test_uuid(NM_UUID_TYPE_VERSION5, dns_uuids[i].uuid5, i_str, -1, UUID_NS_DNS); + _test_uuid(NM_UUID_TYPE_VERSION3, dns_uuids[i].uuid3, i_str, -1, NM_UUID_NS_DNS); + _test_uuid(NM_UUID_TYPE_VERSION5, dns_uuids[i].uuid5, i_str, -1, NM_UUID_NS_DNS); } /* examples from cpython unit tests: */ @@ -7739,48 +7763,48 @@ test_nm_utils_uuid_generate_from_string(void) "6fa459ea-ee8a-3ca4-894e-db77e160355e", "python.org", -1, - UUID_NS_DNS); + NM_UUID_NS_DNS); _test_uuid(NM_UUID_TYPE_VERSION5, "886313e1-3b8a-5372-9b90-0c9aee199e5d", "python.org", -1, - UUID_NS_DNS); + NM_UUID_NS_DNS); _test_uuid(NM_UUID_TYPE_VERSION3, "9fe8e8c4-aaa8-32a9-a55c-4535a88b748d", "http://python.org/", -1, - UUID_NS_URL); + NM_UUID_NS_URL); _test_uuid(NM_UUID_TYPE_VERSION5, "4c565f0d-3f5a-5890-b41b-20cf47701c5e", "http://python.org/", -1, - UUID_NS_URL); + NM_UUID_NS_URL); _test_uuid(NM_UUID_TYPE_VERSION3, "dd1a1cef-13d5-368a-ad82-eca71acd4cd1", "1.3.6.1", -1, - UUID_NS_OID); + NM_UUID_NS_OID); _test_uuid(NM_UUID_TYPE_VERSION5, "1447fa61-5277-5fef-a9b3-fbc6e44f4af3", "1.3.6.1", -1, - UUID_NS_OID); + NM_UUID_NS_OID); _test_uuid(NM_UUID_TYPE_VERSION3, "658d3002-db6b-3040-a1d1-8ddd7d189a4d", "c=ca", -1, - UUID_NS_X500); + NM_UUID_NS_X500); _test_uuid(NM_UUID_TYPE_VERSION5, "cc957dd1-a972-5349-98cd-874190002798", "c=ca", -1, - UUID_NS_X500); + NM_UUID_NS_X500); _test_uuid(NM_UUID_TYPE_VERSION5, "74738ff5-5367-5958-9aee-98fffdcd1876", "www.example.org", -1, - UUID_NS_DNS); + NM_UUID_NS_DNS); } /*****************************************************************************/ @@ -7800,7 +7824,7 @@ __test_uuid(const char *expected_uuid, const char *str, gssize slen, char *uuid_ } g_free(uuid_test); - uuid_test = nm_uuid_generate_from_string_str(str, slen, NM_UUID_TYPE_VERSION3, NM_UUID_NS1); + uuid_test = nm_uuid_generate_from_string_str(str, slen, NM_UUID_TYPE_VERSION3, &nm_uuid_ns_1); g_assert(uuid_test); g_assert(nm_utils_is_uuid(uuid_test)); @@ -7821,15 +7845,23 @@ __test_uuid(const char *expected_uuid, const char *str, gssize slen, char *uuid_ static void test_nm_utils_uuid_generate_from_strings(void) { - const NMUuid uuid0 = {}; + const NMUuid uuid0 = NM_UUID_INIT_ZERO(); + const NMUuid uuid1 = {}; + char buf[37]; g_assert_cmpmem(&uuid0, sizeof(uuid0), _uuid("00000000-0000-0000-0000-000000000000"), 16); + g_assert_cmpmem(&uuid0, sizeof(NMUuid), &uuid1, sizeof(NMUuid)); + g_assert(nm_uuid_is_null(NULL)); g_assert(nm_uuid_is_null(&uuid0)); + g_assert(nm_uuid_is_null(&nm_uuid_ns_zero)); g_assert(nm_uuid_is_null(_uuid("00000000-0000-0000-0000-000000000000"))); g_assert(!nm_uuid_is_null(_uuid("10000000-0000-0000-0000-000000000000"))); + g_assert_cmpstr(NM_UUID_NS_1, ==, nm_uuid_unparse(&nm_uuid_ns_1, buf)); + g_assert_cmpstr(NM_UUID_NS_ZERO, ==, nm_uuid_unparse(&nm_uuid_ns_zero, buf)); + _test_uuid("b07c334a-399b-32de-8d50-58e4e08f98e3", "", 0, NULL); _test_uuid("b8a426cb-bcb5-30a3-bd8f-6786fea72df9", "\0", 1, ""); _test_uuid("12a4a982-7aae-39e1-951e-41aeb1250959", "a\0", 2, "a"); @@ -7846,6 +7878,32 @@ test_nm_utils_uuid_generate_from_strings(void) _test_uuid("dd265bf7-c05a-3037-9939-b9629858a477", "a\0b\0", 4, "a", "b"); } +static void +test_nm_uuid_init(void) +{ + char buf[37]; + + { + NMUuid u; + + u = NM_UUID_INIT(47, c4, d7, f9, 2c, 81, 4f, 7b, be, ed, 63, 0a, 7f, 65, cc, 02); + g_assert_cmpstr("47c4d7f9-2c81-4f7b-beed-630a7f65cc02", ==, nm_uuid_unparse(&u, buf)); + } + { + const NMUuid u = + NM_UUID_INIT(47, c4, d7, f9, 2c, 81, 4f, 7b, be, ed, 63, 0a, 7f, 65, cc, 02); + + g_assert_cmpstr("47c4d7f9-2c81-4f7b-beed-630a7f65cc02", ==, nm_uuid_unparse(&u, buf)); + } + { + const struct { + NMUuid u; + } u = {NM_UUID_INIT(47, c4, d7, f9, 2c, 81, 4f, 7b, be, ed, 63, 0a, 7f, 65, cc, 02)}; + + g_assert_cmpstr("47c4d7f9-2c81-4f7b-beed-630a7f65cc02", ==, nm_uuid_unparse(&u.u, buf)); + } +} + /*****************************************************************************/ static void @@ -9787,11 +9845,53 @@ test_nm_va_args_macros(void) g_assert_cmpint(7, ==, GET_NARG_1(x, x, x, x, x, x, x)); g_assert_cmpint(8, ==, GET_NARG_1(x, x, x, x, x, x, x, x)); g_assert_cmpint(9, ==, GET_NARG_1(x, x, x, x, x, x, x, x, x)); - g_assert_cmpint(10, ==, GET_NARG_1(x, x, x, x, x, x, x, x, x, x)); + g_assert_cmpint(10, ==, NM_NARG(x, x, x, x, x, x, x, x, x, x)); G_STATIC_ASSERT_EXPR(0 == GET_NARG_1()); G_STATIC_ASSERT_EXPR(1 == GET_NARG_1(x)); G_STATIC_ASSERT_EXPR(2 == GET_NARG_1(x, x)); + + /* clang-format off */ + G_STATIC_ASSERT_EXPR(NM_NARG( + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,20, + 1,2,3,4,5,6,7,8,9,30 + ) == 30); + G_STATIC_ASSERT_EXPR(NM_NARG( + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,20, + 1,2,3,4,5,6,7,8,9,30, + 1,2,3,4,5,6,7,8,9,40, + 1,2,3,4,5,6,7,8,9,50, + 1,2,3,4,5,6,7,8,9,60, + 1,2,3,4,5,6,7,8,9,70, + 1,2,3,4,5,6,7,8,9,80 + ) == 80); + G_STATIC_ASSERT_EXPR(NM_NARG( + 1,2,3,4,5,6,7,8,9,10, + 1,2,3,4,5,6,7,8,9,20, + 1,2,3,4,5,6,7,8,9,30, + 1,2,3,4,5,6,7,8,9,40, + 1,2,3,4,5,6,7,8,9,50, + 1,2,3,4,5,6,7,8,9,60, + 1,2,3,4,5,6,7,8,9,70, + 1,2,3,4,5,6,7,8,9,80, + 1,2,3,4,5,6,7,8,9,90, + 1,2,3,4,5,6,7,8,9,100, + 1,2,3,4,5,6,7,8,9,110, + 1,2,3,4,5,6,7,8,9,120 + ) == 120); + /* clang-format on */ + + G_STATIC_ASSERT_EXPR(NM_NARG_MAX1() == 0); + G_STATIC_ASSERT_EXPR(NM_NARG_MAX1(1) == 1); + G_STATIC_ASSERT_EXPR(NM_NARG_MAX1(1, 2) == 1); + G_STATIC_ASSERT_EXPR(NM_NARG_MAX1(1, 2, 3) == 1); + + G_STATIC_ASSERT_EXPR(NM_NARG_MAX2() == 0); + G_STATIC_ASSERT_EXPR(NM_NARG_MAX2(1) == 1); + G_STATIC_ASSERT_EXPR(NM_NARG_MAX2(1, 2) == 2); + G_STATIC_ASSERT_EXPR(NM_NARG_MAX2(1, 2, 3) == 2); } /*****************************************************************************/ @@ -10333,7 +10433,7 @@ _strsplit_quoted_assert_strv(const char * topic, g_assert(strv1); g_assert(strv2); - if (nm_utils_strv_equal(strv1, strv2)) + if (nm_strv_equal(strv1, strv2)) return; for (i = 0; strv1[i]; i++) { @@ -10424,6 +10524,60 @@ test_strsplit_quoted(void) /*****************************************************************************/ +static void +test_nm_property_variant_to_gvalue(void) +{ +#define _test_variant_to_gvalue_bad(variant, gtype) \ + G_STMT_START \ + { \ + gs_unref_variant GVariant * _variant = (variant); \ + GType _gtype = (gtype); \ + nm_auto_unset_gvalue GValue _gvalue = G_VALUE_INIT; \ + \ + g_value_init(&_gvalue, _gtype); \ + g_assert_cmpint(_nm_property_variant_to_gvalue(_variant, &_gvalue), ==, FALSE); \ + } \ + G_STMT_END + +#define _test_variant_to_gvalue(variant, gtype, check) \ + G_STMT_START \ + { \ + gs_unref_variant GVariant * _variant = (variant); \ + GType _gtype = (gtype); \ + nm_auto_unset_gvalue GValue _gvalue = G_VALUE_INIT; \ + _nm_unused GValue *const gg = &_gvalue; \ + \ + g_value_init(&_gvalue, _gtype); \ + g_assert_cmpint(_nm_property_variant_to_gvalue(_variant, &_gvalue), ==, TRUE); \ + check; \ + } \ + G_STMT_END + +#define _test_variant_to_gvalue_int(variant, gtype, gvalue_get, expected) \ + _test_variant_to_gvalue((variant), (gtype), g_assert_cmpint(gvalue_get(gg), ==, (expected))) + + _test_variant_to_gvalue_bad(g_variant_new_string(""), G_TYPE_BOOLEAN); + _test_variant_to_gvalue(g_variant_new_string(""), + G_TYPE_STRING, + g_assert_cmpstr(g_value_get_string(gg), ==, "")); + _test_variant_to_gvalue_int(g_variant_new_boolean(FALSE), + G_TYPE_BOOLEAN, + g_value_get_boolean, + FALSE); + _test_variant_to_gvalue_int(g_variant_new_boolean(TRUE), + G_TYPE_BOOLEAN, + g_value_get_boolean, + TRUE); + _test_variant_to_gvalue_int(g_variant_new_int32(0), G_TYPE_BOOLEAN, g_value_get_boolean, FALSE); + _test_variant_to_gvalue_int(g_variant_new_int32(1), G_TYPE_BOOLEAN, g_value_get_boolean, 1); + _test_variant_to_gvalue_int(g_variant_new_int32(2), G_TYPE_BOOLEAN, g_value_get_boolean, 1); + _test_variant_to_gvalue_int(g_variant_new_byte(0), G_TYPE_BOOLEAN, g_value_get_boolean, 0); + _test_variant_to_gvalue_int(g_variant_new_byte(1), G_TYPE_BOOLEAN, g_value_get_boolean, 1); + _test_variant_to_gvalue_int(g_variant_new_byte(2), G_TYPE_BOOLEAN, g_value_get_boolean, 1); +} + +/*****************************************************************************/ + static void _do_wifi_ghz_freqs(const guint *freqs, const char *band) { @@ -10531,7 +10685,7 @@ main(int argc, char **argv) g_test_add_func("/core/general/test_c_list_sort", test_c_list_sort); g_test_add_func("/core/general/test_dedup_multi", test_dedup_multi); g_test_add_func("/core/general/test_utils_str_utf8safe", test_utils_str_utf8safe); - g_test_add_func("/core/general/test_nm_utils_strsplit_set", test_nm_utils_strsplit_set); + g_test_add_func("/core/general/test_nm_strsplit_set", test_nm_strsplit_set); g_test_add_func("/core/general/test_nm_utils_escaped_tokens", test_nm_utils_escaped_tokens); g_test_add_func("/core/general/test_nm_in_set", test_nm_in_set); g_test_add_func("/core/general/test_nm_in_strset", test_nm_in_strset); @@ -10743,6 +10897,9 @@ main(int argc, char **argv) g_test_add_func("/core/general/test_setting_connection_permissions_property", test_setting_connection_permissions_property); + g_test_add_func("/core/general/test_nm_property_variant_to_gvalue", + test_nm_property_variant_to_gvalue); + g_test_add_func("/core/general/test_connection_compare_same", test_connection_compare_same); g_test_add_func("/core/general/test_connection_compare_key_only_in_a", test_connection_compare_key_only_in_a); @@ -10810,6 +10967,7 @@ main(int argc, char **argv) test_nm_utils_uuid_generate_from_string); g_test_add_func("/core/general/nm_uuid_generate_from_strings", test_nm_utils_uuid_generate_from_strings); + g_test_add_func("/core/general/test_nm_uuid_init", test_nm_uuid_init); g_test_add_func("/core/general/_nm_utils_ascii_str_to_int64", test_nm_utils_ascii_str_to_int64); g_test_add_func("/core/general/nm_utils_is_power_of_two", test_nm_utils_is_power_of_two); diff --git a/src/libnm-core-impl/tests/test-keyfile.c b/src/libnm-core-impl/tests/test-keyfile.c index ba7d783b..db193379 100644 --- a/src/libnm-core-impl/tests/test-keyfile.c +++ b/src/libnm-core-impl/tests/test-keyfile.c @@ -123,7 +123,7 @@ _assert_gbytes(GBytes *bytes, gconstpointer data, gssize len) if (!len) g_assert(!bytes); - g_assert(nm_utils_gbytes_equal_mem(bytes, data, len)); + g_assert(nm_g_bytes_equal_mem(bytes, data, len)); } static GKeyFile * @@ -350,7 +350,7 @@ _test_8021x_cert_check(NMConnection * con, } g_assert(blob); - g_assert(nm_utils_gbytes_equal_mem(blob, value, val_len)); + g_assert(nm_g_bytes_equal_mem(blob, value, val_len)); kval = g_key_file_get_string(keyfile, "802-1x", "ca-cert", NULL); g_assert(kval); diff --git a/src/libnm-core-impl/tests/test-setting.c b/src/libnm-core-impl/tests/test-setting.c index 6b65e98d..7444f2c1 100644 --- a/src/libnm-core-impl/tests/test-setting.c +++ b/src/libnm-core-impl/tests/test-setting.c @@ -7,6 +7,8 @@ #include #include +#include +#include #include "libnm-glib-aux/nm-uuid.h" #include "libnm-glib-aux/nm-json-aux.h" @@ -119,7 +121,7 @@ test_nm_meta_setting_types_by_priority(void) G_STATIC_ASSERT_EXPR(_NM_META_SETTING_TYPE_NUM == G_N_ELEMENTS(nm_meta_setting_types_by_priority)); - G_STATIC_ASSERT_EXPR(_NM_META_SETTING_TYPE_NUM == 51); + G_STATIC_ASSERT_EXPR(_NM_META_SETTING_TYPE_NUM == 52); arr = g_ptr_array_new_with_free_func(g_object_unref); @@ -150,7 +152,7 @@ test_nm_meta_setting_types_by_priority(void) for (j = 0; j < i; j++) { NMSetting *other = arr->pdata[j]; - if (_nmtst_nm_setting_sort(other, setting) >= 0) { + if (_nm_setting_sort_for_nm_assert(other, setting) >= 0) { g_error("sort order for nm_meta_setting_types_by_priority[%d vs %d] is wrong: %s " "should be before %s", j, @@ -874,6 +876,34 @@ test_bond_normalize(void) /*****************************************************************************/ +static void +test_dummy_normalize(void) +{ + gs_unref_object NMConnection *connection = NULL; + NMSettingConnection * s_con; + + connection = nm_simple_connection_new(); + s_con = NM_SETTING_CONNECTION(nm_setting_connection_new()); + nm_connection_add_setting(connection, NM_SETTING(s_con)); + + g_object_set(s_con, + NM_SETTING_CONNECTION_ID, + "dummy-test", + NM_SETTING_CONNECTION_UUID, + nm_uuid_generate_random_str_a(), + NM_SETTING_CONNECTION_TYPE, + NM_SETTING_DUMMY_SETTING_NAME, + NULL); + + nmtst_assert_connection_unnormalizable(connection, 0, 0); + + g_object_set(s_con, NM_SETTING_CONNECTION_INTERFACE_NAME, "dummy1", NULL); + + nmtst_connection_normalize(connection); +} + +/*****************************************************************************/ + #define DCB_FLAGS_ALL \ (NM_SETTING_DCB_FLAG_ENABLE | NM_SETTING_DCB_FLAG_ADVERTISE | NM_SETTING_DCB_FLAG_WILLING) @@ -1183,7 +1213,7 @@ test_nm_json(void) #endif #if WITH_JANSSON != defined(JANSSON_SONAME) - #error "WITH_JANSON and JANSSON_SONAME are defined inconsistently." +#error "WITH_JANSON and JANSSON_SONAME are defined inconsistently." #endif } @@ -3219,7 +3249,7 @@ _rndt_wired_add_s390_options(NMSettingWired *s_wired, char **out_keyfile_entries g_assert(k); g_assert(v); - idx = nm_utils_strv_find_first((char **) opt_keys, n_opts, k); + idx = nm_strv_find_first(opt_keys, n_opts, k); g_assert(idx >= 0); g_assert(!opt_found[idx]); opt_found[idx] = TRUE; @@ -3619,6 +3649,12 @@ test_roundtrip_conversion(gconstpointer test_data) s_wg = NM_SETTING_WIREGUARD(nm_connection_get_setting(con, NM_TYPE_SETTING_WIREGUARD)); + s_ip.s_4 = NM_SETTING_IP_CONFIG(nm_connection_get_setting(con, NM_TYPE_SETTING_IP4_CONFIG)); + g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip.s_4), ==, "disabled"); + + s_ip.s_6 = NM_SETTING_IP_CONFIG(nm_connection_get_setting(con, NM_TYPE_SETTING_IP6_CONFIG)); + g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip.s_6), ==, "disabled"); + g_ptr_array_add(kf_data_arr, g_strdup_printf("[connection]\n" "id=%s\n" @@ -3636,7 +3672,7 @@ test_roundtrip_conversion(gconstpointer test_data) "[ipv6]\n" "addr-gen-mode=stable-privacy\n" "dns-search=\n" - "method=ignore\n" + "method=disabled\n" "\n" "[proxy]\n" "", @@ -3693,7 +3729,7 @@ test_roundtrip_conversion(gconstpointer test_data) "[ipv6]\n" "addr-gen-mode=stable-privacy\n" "dns-search=\n" - "method=ignore\n" + "method=disabled\n" "\n" "[proxy]\n" "", @@ -4354,6 +4390,9 @@ test_setting_metadata(void) guint prop_idx; gs_free GParamSpec **property_specs = NULL; guint n_property_specs; + guint n_param_spec; + guint i; + guint j; g_assert(sis); @@ -4370,8 +4409,22 @@ test_setting_metadata(void) g_assert_cmpint(sis->property_infos_len, >, 0); g_assert(sis->property_infos); + { + int offset; + + if (sis->private_offset < 0) { + offset = g_type_class_get_instance_private_offset(sis->setting_class); + g_assert_cmpint(sis->private_offset, ==, offset); + } else { + /* it would be nice to assert that this class has no private data. + * But we cannot. */ + } + } + h_properties = g_hash_table_new(nm_str_hash, g_str_equal); + n_param_spec = 0; + for (prop_idx = 0; prop_idx < sis->property_infos_len; prop_idx++) { const NMSettInfoProperty *sip = &sis->property_infos[prop_idx]; GArray * property_types_data; @@ -4380,6 +4433,9 @@ test_setting_metadata(void) g_assert(sip->name); + if (sip->param_spec) + n_param_spec++; + if (prop_idx > 0) g_assert_cmpint(strcmp(sis->property_infos[prop_idx - 1].name, sip->name), <, 0); @@ -4387,17 +4443,152 @@ test_setting_metadata(void) g_assert(sip->property_type->dbus_type); g_assert(g_variant_type_string_is_valid((const char *) sip->property_type->dbus_type)); + if (sip->property_type->direct_type == NM_VALUE_TYPE_NONE) { + g_assert_cmpint(sip->direct_offset, ==, 0); + } else if (sip->property_type->direct_type == NM_VALUE_TYPE_BOOL) { + g_assert(sip->property_type == &nm_sett_info_propert_type_direct_boolean); + g_assert(g_variant_type_equal(sip->property_type->dbus_type, "b")); + g_assert(sip->property_type->to_dbus_fcn + == _nm_setting_property_to_dbus_fcn_direct); + g_assert(sip->param_spec); + g_assert(sip->param_spec->value_type == G_TYPE_BOOLEAN); + can_set_including_default = TRUE; + } else if (sip->property_type->direct_type == NM_VALUE_TYPE_INT32) { + const GParamSpecInt *pspec; + + g_assert(sip->property_type == &nm_sett_info_propert_type_direct_int32); + g_assert(g_variant_type_equal(sip->property_type->dbus_type, "i")); + g_assert(sip->property_type->to_dbus_fcn + == _nm_setting_property_to_dbus_fcn_direct); + g_assert(sip->param_spec); + g_assert(sip->param_spec->value_type == G_TYPE_INT); + + pspec = NM_G_PARAM_SPEC_CAST_INT(sip->param_spec); + g_assert_cmpint(pspec->minimum, <=, pspec->maximum); + g_assert_cmpint(pspec->default_value, >=, pspec->minimum); + g_assert_cmpint(pspec->default_value, <=, pspec->maximum); + + g_assert_cmpint(pspec->minimum, >=, (gint64) G_MININT32); + g_assert_cmpint(pspec->maximum, <=, (gint64) G_MAXINT32); + + can_set_including_default = TRUE; + } else if (sip->property_type->direct_type == NM_VALUE_TYPE_UINT32) { + const GParamSpecUInt *pspec; + + g_assert(sip->property_type == &nm_sett_info_propert_type_direct_uint32); + g_assert(g_variant_type_equal(sip->property_type->dbus_type, "u")); + g_assert(sip->property_type->to_dbus_fcn + == _nm_setting_property_to_dbus_fcn_direct); + g_assert(sip->param_spec); + g_assert(sip->param_spec->value_type == G_TYPE_UINT); + + pspec = NM_G_PARAM_SPEC_CAST_UINT(sip->param_spec); + g_assert_cmpint(pspec->minimum, <=, pspec->maximum); + g_assert_cmpint(pspec->default_value, >=, pspec->minimum); + g_assert_cmpint(pspec->default_value, <=, pspec->maximum); + + g_assert_cmpint(pspec->maximum, <=, (guint64) G_MAXUINT32); + + can_set_including_default = TRUE; + } else if (sip->property_type->direct_type == NM_VALUE_TYPE_UINT64) { + const GParamSpecUInt64 *pspec; + + g_assert(sip->property_type == &nm_sett_info_propert_type_direct_uint64); + g_assert(g_variant_type_equal(sip->property_type->dbus_type, "t")); + g_assert(sip->property_type->to_dbus_fcn + == _nm_setting_property_to_dbus_fcn_direct); + g_assert(sip->param_spec); + g_assert(sip->param_spec->value_type == G_TYPE_UINT64); + + pspec = NM_G_PARAM_SPEC_CAST_UINT64(sip->param_spec); + g_assert_cmpuint(pspec->minimum, <=, pspec->maximum); + g_assert_cmpuint(pspec->default_value, >=, pspec->minimum); + g_assert_cmpuint(pspec->default_value, <=, pspec->maximum); + + g_assert_cmpuint(pspec->maximum, <=, G_MAXUINT64); + + can_set_including_default = TRUE; + } else if (sip->property_type->direct_type == NM_VALUE_TYPE_ENUM) { + const GParamSpecEnum *pspec; + + g_assert(sip->property_type == &nm_sett_info_propert_type_direct_enum); + g_assert(g_variant_type_equal(sip->property_type->dbus_type, "i")); + g_assert(sip->property_type->to_dbus_fcn + == _nm_setting_property_to_dbus_fcn_direct); + g_assert(sip->param_spec); + g_assert(g_type_is_a(sip->param_spec->value_type, G_TYPE_ENUM)); + g_assert(sip->param_spec->value_type != G_TYPE_ENUM); + + pspec = NM_G_PARAM_SPEC_CAST_ENUM(sip->param_spec); + g_assert(G_TYPE_FROM_CLASS(pspec->enum_class) == sip->param_spec->value_type); + g_assert(g_enum_get_value(pspec->enum_class, pspec->default_value)); + + can_set_including_default = TRUE; + } else if (sip->property_type->direct_type == NM_VALUE_TYPE_FLAGS) { + const GParamSpecFlags *pspec; + + g_assert(sip->property_type == &nm_sett_info_propert_type_direct_flags); + g_assert(g_variant_type_equal(sip->property_type->dbus_type, "u")); + g_assert(sip->property_type->to_dbus_fcn + == _nm_setting_property_to_dbus_fcn_direct); + g_assert(sip->param_spec); + g_assert(g_type_is_a(sip->param_spec->value_type, G_TYPE_FLAGS)); + g_assert(sip->param_spec->value_type != G_TYPE_FLAGS); + + pspec = NM_G_PARAM_SPEC_CAST_FLAGS(sip->param_spec); + g_assert_cmpint(pspec->flags_class->mask, !=, 0); + g_assert_cmpint(pspec->default_value, + ==, + pspec->flags_class->mask & pspec->default_value); + + can_set_including_default = TRUE; + } else if (sip->property_type->direct_type == NM_VALUE_TYPE_STRING) { + if (sip->property_type == &nm_sett_info_propert_type_direct_mac_address) { + g_assert(g_variant_type_equal(sip->property_type->dbus_type, "ay")); + g_assert(sip->property_type->to_dbus_fcn + == _nm_setting_property_to_dbus_fcn_direct_mac_address); + g_assert(NM_IN_SET((guint) sip->direct_set_string_mac_address_len, + ETH_ALEN, + 8, + INFINIBAND_ALEN)); + } else { + g_assert(g_variant_type_equal(sip->property_type->dbus_type, "s")); + g_assert(sip->property_type->to_dbus_fcn + == _nm_setting_property_to_dbus_fcn_direct); + } + g_assert(sip->param_spec); + g_assert(sip->param_spec->value_type == G_TYPE_STRING); + } else if (sip->property_type->direct_type == NM_VALUE_TYPE_BYTES) { + g_assert(g_variant_type_equal(sip->property_type->dbus_type, "ay")); + g_assert(sip->property_type->to_dbus_fcn + == _nm_setting_property_to_dbus_fcn_direct); + g_assert(sip->param_spec); + g_assert(sip->param_spec->value_type == G_TYPE_BYTES); + } else + g_assert_not_reached(); + + if (sip->direct_set_string_ascii_strdown) + g_assert(sip->property_type->direct_type == NM_VALUE_TYPE_STRING); + + if (sip->direct_set_string_mac_address_len != 0) { + g_assert(NM_IN_SET(sip->property_type, + &nm_sett_info_propert_type_direct_string, + &nm_sett_info_propert_type_direct_mac_address)); + g_assert(sip->property_type->direct_type == NM_VALUE_TYPE_STRING); + } + + g_assert(((sip->direct_set_string_mac_address_len != 0) + + (!!sip->direct_set_string_ascii_strdown) + + (sip->direct_set_string_ip_address_addr_family != 0)) + <= 1); + if (!sip->property_type->to_dbus_fcn) { /* it's allowed to have no to_dbus_fcn(), to ignore a property. But such - * properties must not have a param_spec and no gprop_to_dbus_fcn. */ + * properties must not have a param_spec. */ g_assert(!sip->param_spec); - g_assert(!sip->to_dbus_data.none); } else if (sip->property_type->to_dbus_fcn == _nm_setting_property_to_dbus_fcn_gprop) { g_assert(sip->param_spec); switch (sip->property_type->typdata_to_dbus.gprop_type) { - case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_BYTES: - g_assert(sip->param_spec->value_type == G_TYPE_BYTES); - goto check_done; case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_ENUM: g_assert(g_type_is_a(sip->param_spec->value_type, G_TYPE_ENUM)); goto check_done; @@ -4410,40 +4601,82 @@ test_setting_metadata(void) case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_STRDICT: g_assert(sip->param_spec->value_type == G_TYPE_HASH_TABLE); goto check_done; - case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_MAC_ADDRESS: - g_assert(sip->param_spec->value_type == G_TYPE_STRING); - goto check_done; case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_DEFAULT: goto check_done; } g_assert_not_reached(); check_done:; - if (sip->property_type->typdata_to_dbus.gprop_type - != NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_DEFAULT) - g_assert(!sip->to_dbus_data.gprop_to_dbus_fcn); can_set_including_default = TRUE; - } else if (sip->property_type->to_dbus_fcn - == _nm_setting_property_to_dbus_fcn_get_boolean) { - g_assert(sip->param_spec); - g_assert(sip->param_spec->value_type == G_TYPE_BOOLEAN); - g_assert(sip->to_dbus_data.get_boolean); - can_set_including_default = TRUE; - } else if (sip->property_type->to_dbus_fcn - == _nm_setting_property_to_dbus_fcn_get_string) { - g_assert(sip->param_spec); - g_assert(sip->param_spec->value_type == G_TYPE_STRING); - g_assert(sip->to_dbus_data.get_string); } if (!can_set_including_default) - g_assert(!sip->to_dbus_data.including_default); + g_assert(!sip->to_dbus_including_default); - g_assert(!sip->property_type->from_dbus_fcn - || !sip->property_type->gprop_from_dbus_fcn); + g_assert(sip->property_type->from_dbus_fcn || !sip->param_spec); + if (sip->property_type->typdata_from_dbus.gprop_fcn) { + g_assert(sip->property_type->from_dbus_fcn + == _nm_setting_property_from_dbus_fcn_gprop); + } + if (sip->property_type->from_dbus_direct_allow_transform) { + g_assert(sip->property_type->from_dbus_fcn + == _nm_setting_property_from_dbus_fcn_direct); + } + if (sip->property_type->from_dbus_fcn == _nm_setting_property_from_dbus_fcn_direct) { + /* for the moment, all direct properties allow transformation. */ + g_assert(sip->property_type->from_dbus_direct_allow_transform); + } + + if (sip->property_type->from_dbus_fcn == _nm_setting_property_from_dbus_fcn_gprop) + g_assert(sip->param_spec); + if (sip->property_type->from_dbus_fcn) { + if (sip->property_type->direct_type != NM_VALUE_TYPE_NONE) { + g_assert(NM_IN_SET(sip->property_type->from_dbus_fcn, + _nm_setting_property_from_dbus_fcn_direct_ip_config_gateway, + _nm_setting_property_from_dbus_fcn_direct_mac_address, + _nm_setting_property_from_dbus_fcn_direct)); + } + } + + g_assert(sip->property_type->from_dbus_is_full + == NM_IN_SET(sip->property_type->from_dbus_fcn, + _nm_setting_property_from_dbus_fcn_direct, + _nm_setting_property_from_dbus_fcn_gprop, + _nm_setting_property_from_dbus_fcn_ignore)); if (!g_hash_table_insert(h_properties, (char *) sip->name, sip->param_spec)) g_assert_not_reached(); + if (sip->property_type->compare_fcn == _nm_setting_property_compare_fcn_default) { + g_assert(sip->param_spec); + g_assert_cmpstr(sip->name, !=, NM_SETTING_NAME); + } else if (sip->property_type->compare_fcn == _nm_setting_property_compare_fcn_direct) { + g_assert(sip->param_spec); + g_assert(sip->property_type->direct_type != NM_VALUE_TYPE_NONE); + g_assert(NM_IN_SET(sip->property_type->to_dbus_fcn, + _nm_setting_property_to_dbus_fcn_direct, + _nm_setting_property_to_dbus_fcn_direct_mac_address)); + } else if (sip->property_type->compare_fcn == _nm_setting_property_compare_fcn_ignore) { + if (NM_IN_SET(sip->property_type, + &nm_sett_info_propert_type_deprecated_ignore_i, + &nm_sett_info_propert_type_deprecated_ignore_u, + &nm_sett_info_propert_type_assigned_mac_address)) { + /* pass */ + } else if (!sip->param_spec) { + /* pass */ + } else if (nm_streq(sip->name, NM_SETTING_NAME)) { + /* pass */ + } else { + /* ignoring a property for comparison make only sense in very specific cases. */ + g_assert_not_reached(); + } + } else if (sip->property_type->compare_fcn) { + /* pass */ + } else { + g_assert_not_reached(); + } + g_assert((sip->property_type->compare_fcn != _nm_setting_property_compare_fcn_direct) + || (sip->property_type->direct_type != NM_VALUE_TYPE_NONE)); + property_types_data = g_hash_table_lookup(h_property_types, sip->property_type); if (!property_types_data) { property_types_data = g_array_new(FALSE, FALSE, sizeof(guint)); @@ -4460,32 +4693,51 @@ check_done:; g_assert_cmpstr(sip->name, ==, sip->param_spec->name); + g_assert(NM_FLAGS_HAS(sip->param_spec->flags, G_PARAM_WRITABLE) + != nm_streq(sip->name, NM_SETTING_NAME)); + g_assert((sip->property_type == &nm_sett_info_propert_type_setting_name) + == nm_streq(sip->name, NM_SETTING_NAME)); + g_value_init(&val, sip->param_spec->value_type); g_object_get_property(G_OBJECT(setting), sip->name, &val); if (sip->param_spec->value_type == G_TYPE_STRING) { - const char *default_value; - - default_value = ((const GParamSpecString *) sip->param_spec)->default_value; - if (default_value) { - /* having a string property with a default != NULL is really ugly. They - * should be best avoided... */ - if (meta_type == NM_META_SETTING_TYPE_DCB - && nm_streq(sip->name, NM_SETTING_DCB_APP_FCOE_MODE)) { - /* Whitelist the properties that have a non-NULL default value. */ - g_assert_cmpstr(default_value, ==, NM_SETTING_DCB_FCOE_MODE_FABRIC); - } else - g_assert_not_reached(); - } + /* String properties should all have a default value of NULL. Otherwise, + * it's ugly. */ + g_assert_cmpstr(((const GParamSpecString *) sip->param_spec)->default_value, + ==, + NULL); + g_assert(!NM_G_PARAM_SPEC_GET_DEFAULT_STRING(sip->param_spec)); if (nm_streq(sip->name, NM_SETTING_NAME)) g_assert_cmpstr(g_value_get_string(&val), ==, msi->setting_name); else - g_assert_cmpstr(g_value_get_string(&val), ==, default_value); + g_assert_cmpstr(g_value_get_string(&val), ==, NULL); } if (NM_FLAGS_HAS(sip->param_spec->flags, NM_SETTING_PARAM_TO_DBUS_IGNORE_FLAGS)) g_assert(sip->property_type->to_dbus_fcn); + + g_assert(!NM_FLAGS_HAS(sip->param_spec->flags, G_PARAM_CONSTRUCT)); + g_assert(!NM_FLAGS_HAS(sip->param_spec->flags, G_PARAM_CONSTRUCT_ONLY)); + + if (NM_FLAGS_HAS(sip->param_spec->flags, NM_SETTING_PARAM_SECRET)) { + if (sip->param_spec->value_type == G_TYPE_STRING) { + g_assert_cmpstr(NM_G_PARAM_SPEC_GET_DEFAULT_STRING(sip->param_spec), + ==, + NULL); + } else if (sip->param_spec->value_type == G_TYPE_BYTES) { + /* pass */ + } else if (sip->param_spec->value_type == G_TYPE_HASH_TABLE) { + g_assert(NM_IS_SETTING_VPN(setting)); + g_assert_cmpstr(sip->name, ==, NM_SETTING_VPN_SECRETS); + } else { + g_error("secret %s.%s is of unexpected property type %s", + nm_setting_get_name(setting), + sip->name, + g_type_name(sip->param_spec->value_type)); + } + } } } @@ -4533,6 +4785,44 @@ check_done:; g_assert_cmpstr(sis->property_infos[0].name, ==, NM_SETTING_NAME); } else g_assert_cmpint(meta_type, !=, NM_META_SETTING_TYPE_ETHTOOL); + + g_assert_cmpint(n_param_spec, >, 0); + g_assert_cmpint(n_param_spec, ==, sis->property_lookup_by_param_spec_len); + g_assert(sis->property_lookup_by_param_spec); + for (i = 0; i < sis->property_lookup_by_param_spec_len; i++) { + const NMSettInfoPropertLookupByParamSpec *p = &sis->property_lookup_by_param_spec[i]; + guint n_found; + + if (i > 0) { + g_assert_cmpint(sis->property_lookup_by_param_spec[i - 1].param_spec_as_uint, + <, + p->param_spec_as_uint); + } + g_assert(p->property_info); + g_assert(p->property_info >= sis->property_infos); + g_assert(p->property_info < &sis->property_infos[sis->property_infos_len]); + g_assert(p->property_info + == &sis->property_infos[p->property_info - sis->property_infos]); + + g_assert(p->property_info->param_spec); + g_assert(p->param_spec_as_uint + == ((uintptr_t) ((gpointer) p->property_info->param_spec))); + + g_assert(_nm_sett_info_property_lookup_by_param_spec(sis, p->property_info->param_spec) + == p->property_info); + + n_found = 0; + for (j = 0; j < sis->property_infos_len; j++) { + const NMSettInfoProperty *pip2 = &sis->property_infos[j]; + + if (pip2->param_spec + && p->param_spec_as_uint == ((uintptr_t) ((gpointer) pip2->param_spec))) { + g_assert(pip2 == p->property_info); + n_found++; + } + } + g_assert(n_found == 1); + } } { @@ -4552,10 +4842,14 @@ check_done:; const NMSettInfoPropertType *pt_2 = a_property_types[prop_idx_2]; if (!g_variant_type_equal(pt->dbus_type, pt_2->dbus_type) - || pt->to_dbus_fcn != pt_2->to_dbus_fcn + || pt->direct_type != pt_2->direct_type || pt->to_dbus_fcn != pt_2->to_dbus_fcn || pt->from_dbus_fcn != pt_2->from_dbus_fcn + || pt->compare_fcn != pt_2->compare_fcn || pt->missing_from_dbus_fcn != pt_2->missing_from_dbus_fcn - || pt->gprop_from_dbus_fcn != pt_2->gprop_from_dbus_fcn + || memcmp(&pt->typdata_from_dbus, + &pt_2->typdata_from_dbus, + sizeof(pt->typdata_from_dbus)) + != 0 || memcmp(&pt->typdata_to_dbus, &pt_2->typdata_to_dbus, sizeof(pt->typdata_to_dbus)) @@ -4632,44 +4926,44 @@ test_setting_connection_secondaries_verify(void) g_object_set(s_con, NM_SETTING_CONNECTION_SECONDARIES, arr->pdata, NULL); -#define _assert_secondaries(s_con, expected) \ - G_STMT_START \ - { \ - NMSettingConnection *const _s_con = (s_con); \ - const char *const * _expected = (expected); \ - GArray * _secondaries; \ - const guint _expected_len = NM_PTRARRAY_LEN(_expected); \ - gs_strfreev char ** _sec_strv = NULL; \ - guint _i; \ - \ - g_assert(_expected); \ - \ - if (nmtst_get_rand_bool()) { \ - _secondaries = _nm_setting_connection_get_secondaries(_s_con); \ - g_assert_cmpint(_expected_len, ==, nm_g_array_len(_secondaries)); \ - g_assert((_expected_len == 0) == (!_secondaries)); \ - g_assert(nm_utils_strv_equal(_expected, \ - _secondaries ? nm_strvarray_get_strv(&_secondaries, NULL) \ - : NM_PTRARRAY_EMPTY(const char *))); \ - } \ - \ - if (nmtst_get_rand_bool()) { \ - g_object_get(_s_con, NM_SETTING_CONNECTION_SECONDARIES, &_sec_strv, NULL); \ - g_assert_cmpint(_expected_len, ==, NM_PTRARRAY_LEN(_sec_strv)); \ - g_assert((_expected_len == 0) == (!_sec_strv)); \ - g_assert(nm_utils_strv_equal(_expected, _sec_strv ?: NM_STRV_EMPTY())); \ - } \ - \ - g_assert_cmpint(nm_setting_connection_get_num_secondaries(_s_con), ==, _expected_len); \ - if (nmtst_get_rand_bool()) { \ - for (_i = 0; _i < _expected_len; _i++) { \ - g_assert_cmpstr(nm_setting_connection_get_secondary(_s_con, _i), \ - ==, \ - _expected[_i]); \ - } \ - g_assert_null(nm_setting_connection_get_secondary(_s_con, _expected_len)); \ - } \ - } \ +#define _assert_secondaries(s_con, expected) \ + G_STMT_START \ + { \ + NMSettingConnection *const _s_con = (s_con); \ + const char *const * _expected = (expected); \ + GArray * _secondaries; \ + const guint _expected_len = NM_PTRARRAY_LEN(_expected); \ + gs_strfreev char ** _sec_strv = NULL; \ + guint _i; \ + \ + g_assert(_expected); \ + \ + if (nmtst_get_rand_bool()) { \ + _secondaries = _nm_setting_connection_get_secondaries(_s_con); \ + g_assert_cmpint(_expected_len, ==, nm_g_array_len(_secondaries)); \ + g_assert((_expected_len == 0) == (!_secondaries)); \ + g_assert(nm_strv_equal(_expected, \ + _secondaries ? nm_strvarray_get_strv(&_secondaries, NULL) \ + : NM_PTRARRAY_EMPTY(const char *))); \ + } \ + \ + if (nmtst_get_rand_bool()) { \ + g_object_get(_s_con, NM_SETTING_CONNECTION_SECONDARIES, &_sec_strv, NULL); \ + g_assert_cmpint(_expected_len, ==, NM_PTRARRAY_LEN(_sec_strv)); \ + g_assert((_expected_len == 0) == (!_sec_strv)); \ + g_assert(nm_strv_equal(_expected, _sec_strv ?: NM_STRV_EMPTY())); \ + } \ + \ + g_assert_cmpint(nm_setting_connection_get_num_secondaries(_s_con), ==, _expected_len); \ + if (nmtst_get_rand_bool()) { \ + for (_i = 0; _i < _expected_len; _i++) { \ + g_assert_cmpstr(nm_setting_connection_get_secondary(_s_con, _i), \ + ==, \ + _expected[_i]); \ + } \ + g_assert_null(nm_setting_connection_get_secondary(_s_con, _expected_len)); \ + } \ + } \ G_STMT_END _assert_secondaries(s_con, (const char *const *) arr->pdata); @@ -4688,14 +4982,14 @@ test_setting_connection_secondaries_verify(void) if (is_normalized) s = uuid_normalized; - if (nm_utils_strv_find_first((char **) arr_norm->pdata, arr_norm->len, s) >= 0) + if (nm_strv_ptrarray_find_first(arr_norm, s) >= 0) continue; g_ptr_array_add(arr_norm, g_strdup(s)); } g_ptr_array_add(arr_norm, NULL); - was_normalized = !nm_utils_strv_equal((char **) arr->pdata, (char **) arr_norm->pdata); + was_normalized = !nm_strv_equal((char **) arr->pdata, (char **) arr_norm->pdata); if (was_normalized) nmtst_assert_connection_verifies_and_normalizable(con); @@ -4713,6 +5007,38 @@ test_setting_connection_secondaries_verify(void) /*****************************************************************************/ +static void +test_6lowpan_1(void) +{ + gs_unref_object NMConnection *con = NULL; + NMSetting6Lowpan * s_6low; + gs_free char * value = NULL; + + con = nmtst_create_minimal_connection("test-sec", NULL, NM_SETTING_6LOWPAN_SETTING_NAME, NULL); + + s_6low = NM_SETTING_6LOWPAN(nm_connection_get_setting(con, NM_TYPE_SETTING_6LOWPAN)); + g_assert(s_6low); + + g_assert_cmpstr(nm_setting_6lowpan_get_parent(s_6low), ==, NULL); + g_object_get(s_6low, NM_SETTING_6LOWPAN_PARENT, &value, NULL); + g_assert_cmpstr(value, ==, NULL); + nm_clear_g_free(&value); + + g_object_set(s_6low, NM_SETTING_6LOWPAN_PARENT, "hello", NULL); + g_assert_cmpstr(nm_setting_6lowpan_get_parent(s_6low), ==, "hello"); + g_object_get(s_6low, NM_SETTING_6LOWPAN_PARENT, &value, NULL); + g_assert_cmpstr(value, ==, "hello"); + nm_clear_g_free(&value); + + g_object_set(s_6low, NM_SETTING_6LOWPAN_PARENT, "world", NULL); + g_assert_cmpstr(nm_setting_6lowpan_get_parent(s_6low), ==, "world"); + g_object_get(s_6low, NM_SETTING_6LOWPAN_PARENT, &value, NULL); + g_assert_cmpstr(value, ==, "world"); + nm_clear_g_free(&value); +} + +/*****************************************************************************/ + NMTST_DEFINE(); int @@ -4741,6 +5067,8 @@ main(int argc, char **argv) g_test_add_func("/libnm/settings/bond/compare", test_bond_compare); g_test_add_func("/libnm/settings/bond/normalize", test_bond_normalize); + g_test_add_func("/libnm/settings/dummy/normalize", test_dummy_normalize); + g_test_add_func("/libnm/settings/dcb/flags-valid", test_dcb_flags_valid); g_test_add_func("/libnm/settings/dcb/flags-invalid", test_dcb_flags_invalid); g_test_add_func("/libnm/settings/dcb/app-priorities", test_dcb_app_priorities); @@ -4752,6 +5080,8 @@ main(int argc, char **argv) g_test_add_func("/libnm/settings/ethtool/ring", test_ethtool_ring); g_test_add_func("/libnm/settings/ethtool/pause", test_ethtool_pause); + g_test_add_func("/libnm/settings/6lowpan/1", test_6lowpan_1); + g_test_add_func("/libnm/settings/sriov/vf", test_sriov_vf); g_test_add_func("/libnm/settings/sriov/vf-dup", test_sriov_vf_dup); g_test_add_func("/libnm/settings/sriov/vf-vlan", test_sriov_vf_vlan); diff --git a/src/libnm-core-intern/nm-core-internal.h b/src/libnm-core-intern/nm-core-internal.h index b1f084ed..93d75e44 100644 --- a/src/libnm-core-intern/nm-core-internal.h +++ b/src/libnm-core-intern/nm-core-internal.h @@ -17,7 +17,7 @@ * and some test programs. **/ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_INTERNAL) - #error Cannot use this header. +#error Cannot use this header. #endif #include "libnm-base/nm-base.h" @@ -29,6 +29,7 @@ #include "nm-setting-adsl.h" #include "nm-setting-bluetooth.h" #include "nm-setting-bond.h" +#include "nm-setting-bond-port.h" #include "nm-setting-bridge-port.h" #include "nm-setting-bridge.h" #include "nm-setting-cdma.h" @@ -79,6 +80,7 @@ #include "nm-vpn-dbus-interface.h" #include "nm-vpn-editor-plugin.h" #include "libnm-core-aux-intern/nm-libnm-core-utils.h" +#include "libnm-glib-aux/nm-value-type.h" #define NM_USER_TAG_ORIGIN "org.freedesktop.NetworkManager.origin" @@ -170,17 +172,17 @@ NM_VLAN_FLAGS_CAST(_NMVlanFlags v) static inline NMTernary NM_TERNARY_FROM_OPTION_BOOL(NMOptionBool v) { - nm_assert(NM_IN_SET(v, NM_OPTION_BOOL_DEFAULT, NM_OPTION_BOOL_TRUE, NM_OPTION_BOOL_FALSE)); + nm_assert_is_ternary(v); - return (NMTernary) v; + return (int) v; } static inline NMOptionBool NM_TERNARY_TO_OPTION_BOOL(NMTernary v) { - nm_assert(NM_IN_SET(v, NM_TERNARY_DEFAULT, NM_TERNARY_TRUE, NM_TERNARY_FALSE)); + nm_assert_is_ternary(v); - return (NMOptionBool) v; + return (int) v; } /*****************************************************************************/ @@ -270,11 +272,11 @@ gboolean _nm_connection_ensure_normalized(NMConnection * connection, gboolean _nm_connection_remove_setting(NMConnection *connection, GType setting_type); #if NM_MORE_ASSERTS -extern const char _nmtst_connection_unchanging_user_data; -void nmtst_connection_assert_unchanging(NMConnection *connection); +extern const char _nm_assert_connection_unchanging_user_data; +void nm_assert_connection_unchanging(NMConnection *connection); #else static inline void -nmtst_connection_assert_unchanging(NMConnection *connection) +nm_assert_connection_unchanging(NMConnection *connection) {} #endif @@ -340,10 +342,10 @@ GPtrArray * _nm_utils_copy_array(const GPtrArray *array, NMUtilsCopyFunc copy_func, GDestroyNotify free_func); GPtrArray *_nm_utils_copy_object_array(const GPtrArray *array); -GSList *_nm_utils_strv_to_slist(char **strv, gboolean deep_copy); +GSList *nm_strv_to_gslist(char **strv, gboolean deep_copy); char ** _nm_utils_slist_to_strv(const GSList *slist, gboolean deep_copy); -GPtrArray *_nm_utils_strv_to_ptrarray(char **strv); +GPtrArray *nm_strv_to_ptrarray(char **strv); char ** _nm_utils_ptrarray_to_strv(const GPtrArray *ptrarray); gboolean _nm_utils_check_file(const char * filename, @@ -654,48 +656,84 @@ GVariant *nm_utils_hwaddr_to_dbus(const char *str); typedef struct _NMSettInfoSetting NMSettInfoSetting; typedef struct _NMSettInfoProperty NMSettInfoProperty; -typedef GVariant *(*NMSettInfoPropToDBusFcn)(const NMSettInfoSetting * sett_info, - guint property_idx, - NMConnection * connection, - NMSetting * setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options); -typedef gboolean (*NMSettInfoPropFromDBusFcn)(NMSetting * setting, - GVariant * connection_dict, - const char * property, - GVariant * value, - NMSettingParseFlags parse_flags, - GError ** error); -typedef gboolean (*NMSettInfoPropMissingFromDBusFcn)(NMSetting * setting, - GVariant * connection_dict, - const char * property, - NMSettingParseFlags parse_flags, - GError ** error); -typedef GVariant *(*NMSettInfoPropGPropToDBusFcn)(const GValue *from); -typedef void (*NMSettInfoPropGPropFromDBusFcn)(GVariant *from, GValue *to); - const NMSettInfoSetting *nmtst_sett_info_settings(void); typedef enum _nm_packed { NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_DEFAULT = 0, - NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_BYTES, NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_ENUM, NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_FLAGS, NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_GARRAY_UINT, NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_STRDICT, - NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_MAC_ADDRESS, } NMSettingPropertyToDBusFcnGPropType; typedef struct { const GVariantType *dbus_type; - NMSettInfoPropToDBusFcn to_dbus_fcn; - NMSettInfoPropFromDBusFcn from_dbus_fcn; - NMSettInfoPropMissingFromDBusFcn missing_from_dbus_fcn; + /* If this is not NM_VALUE_TYPE_UNSPEC, then this is a "direct" property, + * meaning that _nm_setting_get_private() at NMSettInfoProperty.direct_offset + * gives direct access to the field. + * + * Direct properties can use this information to generically implement access + * to the property value. */ + NMValueType direct_type; + + /* Whether from_dbus_fcn() has special capabilities + * + * - whether the from_dbus_fcn expects to handle differences between + * the D-Bus types and can convert between them. Otherwise, the caller + * will already pre-validate that the D-Bus types match. + * - by default, with NM_SETTING_PARSE_FLAGS_BEST_EFFORT all errors from + * from_dbus_fcn() are ignored. If true, then error are propagated. */ + bool from_dbus_is_full : 1; + + /* Only if from_dbus_fcn is set to _nm_setting_property_from_dbus_fcn_direct. + * Historically, libnm used g_dbus_gvariant_to_gvalue() and g_value_transform() to + * convert from D-Bus to the GObject property. Thereby, various transformations are + * allowed and supported. If this is TRUE, then such transformations are still + * allowed for backward compatibility. */ + bool from_dbus_direct_allow_transform : 1; + +#define _NM_SETT_INFO_PROP_COMPARE_FCN_ARGS \ + const NMSettInfoSetting *sett_info, const NMSettInfoProperty *property_info, \ + NMConnection *con_a, NMSetting *set_a, NMConnection *con_b, NMSetting *set_b, \ + NMSettingCompareFlags flags + + /* compare_fcn() returns a ternary, where DEFAULT means that the property should not + * be compared due to the compare @flags. A TRUE/FALSE result means that the property is + * equal/not-equal. + * + * The "b" setting may be %NULL, in which case the function only determines whether + * the setting should be compared (TRUE) or not (DEFAULT). */ + NMTernary (*compare_fcn)(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil); + +#define _NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS \ + const NMSettInfoSetting *sett_info, const NMSettInfoProperty *property_info, \ + NMConnection *connection, NMSetting *setting, NMConnectionSerializationFlags flags, \ + const NMConnectionSerializationOptions *options + + GVariant *(*to_dbus_fcn)(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil); + +#define _NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS \ + const NMSettInfoSetting *sett_info, const NMSettInfoProperty *property_info, \ + NMSetting *setting, GVariant *connection_dict, GVariant *value, \ + NMSettingParseFlags parse_flags, NMTernary *out_is_modified, GError **error - /* Simpler variants of @from_dbus_fcn that operate solely - * on the GValue value of the GObject property. */ - NMSettInfoPropGPropFromDBusFcn gprop_from_dbus_fcn; + gboolean (*from_dbus_fcn)(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil); + +#define _NM_SETT_INFO_PROP_MISSING_FROM_DBUS_FCN_ARGS \ + NMSetting *setting, GVariant *connection_dict, const char *property, \ + NMSettingParseFlags parse_flags, GError **error + + gboolean (*missing_from_dbus_fcn)(_NM_SETT_INFO_PROP_MISSING_FROM_DBUS_FCN_ARGS _nm_nil); + + struct { +#define _NM_SETT_INFO_PROP_FROM_DBUS_GPROP_FCN_ARGS GVariant *from, GValue *to + + /* Only if from_dbus_fcn is set to _nm_setting_property_from_dbus_fcn_gprop. + * This is an optional handler for converting between GVariant and + * GValue. */ + void (*gprop_fcn)(_NM_SETT_INFO_PROP_FROM_DBUS_GPROP_FCN_ARGS _nm_nil); + } typdata_from_dbus; struct { union { @@ -712,22 +750,41 @@ struct _NMSettInfoProperty { const NMSettInfoPropertType *property_type; - struct { - union { - gpointer none; - NMSettInfoPropGPropToDBusFcn gprop_to_dbus_fcn; - gboolean (*get_boolean)(NMSetting *); - const char *(*get_string)(NMSetting *); - }; - - /* Usually, properties that are set to the default value for the GParamSpec - * are not serialized to GVariant (and NULL is returned by to_dbus_data(). - * Set this flag to force always converting the property even if the value - * is the default. */ - bool including_default : 1; - } to_dbus_data; + /* This only has meaning for direct properties (property_type->direct_type != NM_VALUE_TYPE_UNSPEC). + * In that case, this is the offset where _nm_setting_get_private() can find + * the direct location. */ + guint16 direct_offset; + + /* If TRUE, this is a NM_VALUE_TYPE_STRING direct property, and the setter will + * normalize the string via g_ascii_strdown(). */ + bool direct_set_string_ascii_strdown : 1; + + /* If non-zero, this is a NM_VALUE_TYPE_STRING direct property. Actually, it is + * a _nm_setting_property_define_direct_mac_address(), and the setter will + * call _nm_utils_hwaddr_canonical_or_invalid() on the string, with the specified + * MAC address length. */ + guint8 direct_set_string_mac_address_len : 5; + + /* If non-zero, this is the addr-family (AF_INET/AF_INET6) for normalizing an IP + * address. */ + guint8 direct_set_string_ip_address_addr_family : 5; + + /* Usually, properties that are set to the default value for the GParamSpec + * are not serialized to GVariant (and NULL is returned by to_dbus_data(). + * Set this flag to force always converting the property even if the value + * is the default. */ + bool to_dbus_including_default : 1; }; +typedef struct { + /* we want to do binary search by "GParamSpec *", but unrelated pointers + * are not directly comparable in C. No problem, we convert them to + * uintptr_t for the search, that is guaranteed to work. */ + uintptr_t param_spec_as_uint; + + const NMSettInfoProperty *property_info; +} NMSettInfoPropertLookupByParamSpec; + typedef struct { const GVariantType *(*get_variant_type)(const struct _NMSettInfoSetting *sett_info, const char * name, @@ -767,12 +824,32 @@ struct _NMSettInfoSetting { */ const NMSettInfoProperty *const *property_infos_sorted; - guint property_infos_len; + const NMSettInfoPropertLookupByParamSpec *property_lookup_by_param_spec; + + guint16 property_infos_len; + + guint16 property_lookup_by_param_spec_len; + + /* the offset in bytes to get the private data from the @self pointer. */ + gint16 private_offset; + NMSettInfoSettDetail detail; }; +#define NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS ((gint16) G_MININT16) + +static inline gpointer +_nm_setting_get_private(NMSetting *self, const NMSettInfoSetting *sett_info, guint16 offset) +{ + nm_assert(NM_IS_SETTING(self)); + nm_assert(sett_info); + nm_assert(NM_SETTING_GET_CLASS(self) == sett_info->setting_class); + + return ((((char *) ((gpointer) self)) + sett_info->private_offset) + offset); +} + static inline const NMSettInfoProperty * -_nm_sett_info_property_info_get_sorted(const NMSettInfoSetting *sett_info, guint idx) +_nm_sett_info_property_info_get_sorted(const NMSettInfoSetting *sett_info, guint16 idx) { nm_assert(sett_info); nm_assert(idx < sett_info->property_infos_len); @@ -906,4 +983,6 @@ _nm_variant_attribute_spec_find_binary_search(const NMVariantAttributeSpec *cons gboolean _nm_ip_tunnel_mode_is_layer2(NMIPTunnelMode mode); +GPtrArray *_nm_setting_ip_config_get_dns_array(NMSettingIPConfig *setting); + #endif diff --git a/src/libnm-core-intern/nm-keyfile-internal.h b/src/libnm-core-intern/nm-keyfile-internal.h index d8ccc609..d3fd77d2 100644 --- a/src/libnm-core-intern/nm-keyfile-internal.h +++ b/src/libnm-core-intern/nm-keyfile-internal.h @@ -8,7 +8,7 @@ #define __NM_KEYFILE_INTERNAL_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_INTERNAL) - #error Cannot use this header. +#error Cannot use this header. #endif #include diff --git a/src/libnm-core-intern/nm-keyfile-utils.h b/src/libnm-core-intern/nm-keyfile-utils.h index 450cc81c..4dde7029 100644 --- a/src/libnm-core-intern/nm-keyfile-utils.h +++ b/src/libnm-core-intern/nm-keyfile-utils.h @@ -7,7 +7,7 @@ #define __NM_KEYFILE_UTILS_H__ #if !((NETWORKMANAGER_COMPILATION) &NM_NETWORKMANAGER_COMPILATION_WITH_LIBNM_CORE_INTERNAL) - #error Cannot use this header. +#error Cannot use this header. #endif /*****************************************************************************/ diff --git a/src/libnm-core-intern/nm-meta-setting-base-impl.h b/src/libnm-core-intern/nm-meta-setting-base-impl.h index 44bd9024..eba1fb96 100644 --- a/src/libnm-core-intern/nm-meta-setting-base-impl.h +++ b/src/libnm-core-intern/nm-meta-setting-base-impl.h @@ -110,6 +110,7 @@ typedef enum _nm_packed { NM_META_SETTING_TYPE_ADSL, NM_META_SETTING_TYPE_BLUETOOTH, NM_META_SETTING_TYPE_BOND, + NM_META_SETTING_TYPE_BOND_PORT, NM_META_SETTING_TYPE_BRIDGE, NM_META_SETTING_TYPE_BRIDGE_PORT, NM_META_SETTING_TYPE_CDMA, @@ -159,9 +160,9 @@ typedef enum _nm_packed { } NMMetaSettingType; #if _NM_META_SETTING_BASE_IMPL_LIBNM - #define _NMMetaSettingInfo_Alias _NMMetaSettingInfo +#define _NMMetaSettingInfo_Alias _NMMetaSettingInfo #else - #define _NMMetaSettingInfo_Alias _NMMetaSettingInfoCli +#define _NMMetaSettingInfo_Alias _NMMetaSettingInfoCli #endif struct _NMMetaSettingInfo_Alias { diff --git a/src/libnm-core-public/meson.build b/src/libnm-core-public/meson.build index 6b8dad0f..f1da4d02 100644 --- a/src/libnm-core-public/meson.build +++ b/src/libnm-core-public/meson.build @@ -13,6 +13,7 @@ libnm_core_headers = files( 'nm-setting-adsl.h', 'nm-setting-bluetooth.h', 'nm-setting-bond.h', + 'nm-setting-bond-port.h', 'nm-setting-bridge-port.h', 'nm-setting-bridge.h', 'nm-setting-cdma.h', diff --git a/src/libnm-core-public/nm-connection.h b/src/libnm-core-public/nm-connection.h index 44d1568d..fb54ce88 100644 --- a/src/libnm-core-public/nm-connection.h +++ b/src/libnm-core-public/nm-connection.h @@ -8,7 +8,7 @@ #define __NM_CONNECTION_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-core-types.h" @@ -28,10 +28,21 @@ G_BEGIN_DECLS #define NM_CONNECTION_SECRETS_CLEARED "secrets-cleared" #define NM_CONNECTION_CHANGED "changed" +/* + * NM_CONNECTION_NORMALIZE_PARAM_IP4_CONFIG_METHOD: overwrite the ip4 method + * when normalizing ip4 configuration. This only takes effect, if the profile + * has no IPv4 settings and new settings are to be added. If omitted, this + * defaults depends on the profile type but usually it is "auto". + * + * Since: 1.34 + */ +#define NM_CONNECTION_NORMALIZE_PARAM_IP4_CONFIG_METHOD "ip4-config-method" + /* * NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD: overwrite the ip6 method - * when normalizing ip6 configuration. If omitted, this defaults to - * @NM_SETTING_IP6_CONFIG_METHOD_AUTO. + * when normalizing ip6 configuration. This only takes effect, if the profile + * has no IPv6 settings and new settings are to be added. If omitted, this + * defaults depends on the profile type but usually it is "auto". */ #define NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD "ip6-config-method" diff --git a/src/libnm-core-public/nm-core-types.h b/src/libnm-core-public/nm-core-types.h index bf0c2a99..c86c28fa 100644 --- a/src/libnm-core-public/nm-core-types.h +++ b/src/libnm-core-public/nm-core-types.h @@ -19,6 +19,7 @@ typedef struct _NMSetting8021x NMSetting8021x; typedef struct _NMSettingAdsl NMSettingAdsl; typedef struct _NMSettingBluetooth NMSettingBluetooth; typedef struct _NMSettingBond NMSettingBond; +typedef struct _NMSettingBondPort NMSettingBondPort; typedef struct _NMSettingBridge NMSettingBridge; typedef struct _NMSettingBridgePort NMSettingBridgePort; typedef struct _NMSettingCdma NMSettingCdma; diff --git a/src/libnm-core-public/nm-dbus-interface.h b/src/libnm-core-public/nm-dbus-interface.h index 626b2006..7fd228ca 100644 --- a/src/libnm-core-public/nm-dbus-interface.h +++ b/src/libnm-core-public/nm-dbus-interface.h @@ -15,8 +15,8 @@ /* This header must not include glib or libnm. */ #ifndef NM_VERSION_H - #define NM_AVAILABLE_IN_1_2 - #define NM_AVAILABLE_IN_1_8 +#define NM_AVAILABLE_IN_1_2 +#define NM_AVAILABLE_IN_1_8 #endif /* @@ -860,8 +860,8 @@ typedef enum /*< flags >*/ { } NMSecretAgentCapabilities; #ifndef NM_VERSION_H - #undef NM_AVAILABLE_IN_1_2 - #undef NM_AVAILABLE_IN_1_8 +#undef NM_AVAILABLE_IN_1_2 +#undef NM_AVAILABLE_IN_1_8 #endif #define NM_LLDP_ATTR_RAW "raw" diff --git a/src/libnm-core-public/nm-keyfile.h b/src/libnm-core-public/nm-keyfile.h index 28c052f9..e298aae8 100644 --- a/src/libnm-core-public/nm-keyfile.h +++ b/src/libnm-core-public/nm-keyfile.h @@ -4,7 +4,7 @@ #define __NM_KEYFILE_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-core-types.h" diff --git a/src/libnm-core-public/nm-setting-6lowpan.h b/src/libnm-core-public/nm-setting-6lowpan.h index 5a7c3986..358ccff6 100644 --- a/src/libnm-core-public/nm-setting-6lowpan.h +++ b/src/libnm-core-public/nm-setting-6lowpan.h @@ -7,7 +7,7 @@ #define __NM_SETTING_6LOWPAN_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-8021x.h b/src/libnm-core-public/nm-setting-8021x.h index 98e26d12..f9ebdd1c 100644 --- a/src/libnm-core-public/nm-setting-8021x.h +++ b/src/libnm-core-public/nm-setting-8021x.h @@ -8,7 +8,7 @@ #define __NM_SETTING_8021X_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-adsl.h b/src/libnm-core-public/nm-setting-adsl.h index c655d74c..8c584fed 100644 --- a/src/libnm-core-public/nm-setting-adsl.h +++ b/src/libnm-core-public/nm-setting-adsl.h @@ -7,7 +7,7 @@ #define __NM_SETTING_ADSL_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-bluetooth.h b/src/libnm-core-public/nm-setting-bluetooth.h index 69f921ee..6388430a 100644 --- a/src/libnm-core-public/nm-setting-bluetooth.h +++ b/src/libnm-core-public/nm-setting-bluetooth.h @@ -8,7 +8,7 @@ #define __NM_SETTING_BLUETOOTH_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-bond-port.h b/src/libnm-core-public/nm-setting-bond-port.h new file mode 100644 index 00000000..0b20e4a8 --- /dev/null +++ b/src/libnm-core-public/nm-setting-bond-port.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2012 Red Hat, Inc. + */ + +#ifndef __NM_SETTING_BOND_PORT_H__ +#define __NM_SETTING_BOND_PORT_H__ + +#if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) +#error "Only can be included directly." +#endif + +#include "nm-setting.h" +#include "nm-setting-bond.h" + +G_BEGIN_DECLS + +#define NM_TYPE_SETTING_BOND_PORT (nm_setting_bond_port_get_type()) +#define NM_SETTING_BOND_PORT(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_SETTING_BOND_PORT, NMSettingBondPort)) +#define NM_SETTING_BOND_PORT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_SETTING_BOND_PORT, NMSettingBondPortClass)) +#define NM_IS_SETTING_BOND_PORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_SETTING_BOND_PORT)) +#define NM_IS_SETTING_BOND_PORT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_SETTING_BOND_PORT)) +#define NM_SETTING_BOND_PORT_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_SETTING_BOND_PORT, NMSettingBondPortClass)) + +#define NM_SETTING_BOND_PORT_SETTING_NAME "bond-port" + +#define NM_SETTING_BOND_PORT_QUEUE_ID "queue-id" + +typedef struct _NMSettingBondPortClass NMSettingBondPortClass; + +NM_AVAILABLE_IN_1_34 +GType nm_setting_bond_port_get_type(void); + +NM_AVAILABLE_IN_1_34 +NMSetting *nm_setting_bond_port_new(void); + +NM_AVAILABLE_IN_1_34 +guint32 nm_setting_bond_port_get_queue_id(NMSettingBondPort *setting); + +G_END_DECLS + +#endif /* __NM_SETTING_BOND_PORT_H__ */ diff --git a/src/libnm-core-public/nm-setting-bond.h b/src/libnm-core-public/nm-setting-bond.h index c869e4c8..e819b4e1 100644 --- a/src/libnm-core-public/nm-setting-bond.h +++ b/src/libnm-core-public/nm-setting-bond.h @@ -7,7 +7,7 @@ #define __NM_SETTING_BOND_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-bridge-port.h b/src/libnm-core-public/nm-setting-bridge-port.h index 8e5c2b4a..61da5ba5 100644 --- a/src/libnm-core-public/nm-setting-bridge-port.h +++ b/src/libnm-core-public/nm-setting-bridge-port.h @@ -7,7 +7,7 @@ #define __NM_SETTING_BRIDGE_PORT_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-bridge.h b/src/libnm-core-public/nm-setting-bridge.h index cda18612..3a129811 100644 --- a/src/libnm-core-public/nm-setting-bridge.h +++ b/src/libnm-core-public/nm-setting-bridge.h @@ -7,7 +7,7 @@ #define __NM_SETTING_BRIDGE_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-cdma.h b/src/libnm-core-public/nm-setting-cdma.h index 9b72a839..1378f170 100644 --- a/src/libnm-core-public/nm-setting-cdma.h +++ b/src/libnm-core-public/nm-setting-cdma.h @@ -8,7 +8,7 @@ #define __NM_SETTING_CDMA_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-connection.h b/src/libnm-core-public/nm-setting-connection.h index 3b4da44a..54fc7929 100644 --- a/src/libnm-core-public/nm-setting-connection.h +++ b/src/libnm-core-public/nm-setting-connection.h @@ -8,7 +8,7 @@ #define __NM_SETTING_CONNECTION_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" @@ -56,6 +56,7 @@ G_BEGIN_DECLS #define NM_SETTING_CONNECTION_AUTH_RETRIES "auth-retries" #define NM_SETTING_CONNECTION_MDNS "mdns" #define NM_SETTING_CONNECTION_LLMNR "llmnr" +#define NM_SETTING_CONNECTION_DNS_OVER_TLS "dns-over-tls" #define NM_SETTING_CONNECTION_WAIT_DEVICE_TIMEOUT "wait-device-timeout" #define NM_SETTING_CONNECTION_MUD_URL "mud-url" @@ -127,6 +128,24 @@ typedef enum { NM_SETTING_CONNECTION_LLMNR_YES = 2, } NMSettingConnectionLlmnr; +/** + * NMSettingConnectionDnsOverTls: + * @NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT: default value + * @NM_SETTING_CONNECTION_DNS_OVER_TLS_NO: disable DNSOverTls + * @NM_SETTING_CONNECTION_DNS_OVER_TLS_OPPORTUNISTIC: enable opportunistic mode + * @NM_SETTING_CONNECTION_DNS_OVER_TLS_YES: enable strict mode + * + * #NMSettingConnectionDnsOverTls values indicate whether DNSOverTls should be enabled. + * + * Since: 1.34 + */ +typedef enum { + NM_SETTING_CONNECTION_DNS_OVER_TLS_DEFAULT = -1, + NM_SETTING_CONNECTION_DNS_OVER_TLS_NO = 0, + NM_SETTING_CONNECTION_DNS_OVER_TLS_OPPORTUNISTIC = 1, + NM_SETTING_CONNECTION_DNS_OVER_TLS_YES = 2, +} NMSettingConnectionDnsOverTls; + typedef struct _NMSettingConnectionClass NMSettingConnectionClass; GType nm_setting_connection_get_type(void); @@ -193,6 +212,8 @@ NM_AVAILABLE_IN_1_12 NMSettingConnectionMdns nm_setting_connection_get_mdns(NMSettingConnection *setting); NM_AVAILABLE_IN_1_14 NMSettingConnectionLlmnr nm_setting_connection_get_llmnr(NMSettingConnection *setting); +NM_AVAILABLE_IN_1_34 +NMSettingConnectionDnsOverTls nm_setting_connection_get_dns_over_tls(NMSettingConnection *setting); NM_AVAILABLE_IN_1_20 gint32 nm_setting_connection_get_wait_device_timeout(NMSettingConnection *setting); diff --git a/src/libnm-core-public/nm-setting-dcb.h b/src/libnm-core-public/nm-setting-dcb.h index b342c465..53786213 100644 --- a/src/libnm-core-public/nm-setting-dcb.h +++ b/src/libnm-core-public/nm-setting-dcb.h @@ -7,7 +7,7 @@ #define __NM_SETTING_DCB_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-dummy.h b/src/libnm-core-public/nm-setting-dummy.h index 2231ea17..85e8a260 100644 --- a/src/libnm-core-public/nm-setting-dummy.h +++ b/src/libnm-core-public/nm-setting-dummy.h @@ -7,7 +7,7 @@ #define __NM_SETTING_DUMMY_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-ethtool.h b/src/libnm-core-public/nm-setting-ethtool.h index eab447af..698dcebe 100644 --- a/src/libnm-core-public/nm-setting-ethtool.h +++ b/src/libnm-core-public/nm-setting-ethtool.h @@ -7,7 +7,7 @@ #define __NM_SETTING_ETHTOOL_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-generic.h b/src/libnm-core-public/nm-setting-generic.h index b5346abb..9bdcd11d 100644 --- a/src/libnm-core-public/nm-setting-generic.h +++ b/src/libnm-core-public/nm-setting-generic.h @@ -7,7 +7,7 @@ #define __NM_SETTING_GENERIC_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-gsm.h b/src/libnm-core-public/nm-setting-gsm.h index 59703c3c..0d57511d 100644 --- a/src/libnm-core-public/nm-setting-gsm.h +++ b/src/libnm-core-public/nm-setting-gsm.h @@ -8,7 +8,7 @@ #define __NM_SETTING_GSM_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-hostname.h b/src/libnm-core-public/nm-setting-hostname.h index 02b4e373..f93e0efe 100644 --- a/src/libnm-core-public/nm-setting-hostname.h +++ b/src/libnm-core-public/nm-setting-hostname.h @@ -7,7 +7,7 @@ #define NM_SETTING_HOSTNAME_H #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-infiniband.h b/src/libnm-core-public/nm-setting-infiniband.h index 3d422133..44f30839 100644 --- a/src/libnm-core-public/nm-setting-infiniband.h +++ b/src/libnm-core-public/nm-setting-infiniband.h @@ -7,7 +7,7 @@ #define __NM_SETTING_INFINIBAND_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-ip-config.h b/src/libnm-core-public/nm-setting-ip-config.h index 9a745cb2..126c4c11 100644 --- a/src/libnm-core-public/nm-setting-ip-config.h +++ b/src/libnm-core-public/nm-setting-ip-config.h @@ -8,7 +8,7 @@ #define NM_SETTING_IP_CONFIG_H #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" @@ -248,11 +248,11 @@ NM_AVAILABLE_IN_1_20 void nm_ip_routing_rule_set_suppress_prefixlength(NMIPRoutingRule *self, gint32 suppress_prefixlength); -NM_AVAILABLE_IN_1_32 +NM_AVAILABLE_IN_1_34 gboolean nm_ip_routing_rule_get_uid_range(const NMIPRoutingRule *self, guint32 * out_range_start, guint32 * out_range_end); -NM_AVAILABLE_IN_1_32 +NM_AVAILABLE_IN_1_34 void nm_ip_routing_rule_set_uid_range(NMIPRoutingRule *self, guint32 uid_range_start, guint32 uid_range_end); @@ -474,7 +474,7 @@ NM_AVAILABLE_IN_1_2 int nm_setting_ip_config_get_dad_timeout(NMSettingIPConfig *setting); NM_AVAILABLE_IN_1_2 int nm_setting_ip_config_get_dhcp_timeout(NMSettingIPConfig *setting); -NM_AVAILABLE_IN_1_32_4 +NM_AVAILABLE_IN_1_34 int nm_setting_ip_config_get_required_timeout(NMSettingIPConfig *setting); NM_AVAILABLE_IN_1_22 const char *nm_setting_ip_config_get_dhcp_iaid(NMSettingIPConfig *setting); diff --git a/src/libnm-core-public/nm-setting-ip-tunnel.h b/src/libnm-core-public/nm-setting-ip-tunnel.h index 0a83b0a2..4710411c 100644 --- a/src/libnm-core-public/nm-setting-ip-tunnel.h +++ b/src/libnm-core-public/nm-setting-ip-tunnel.h @@ -7,7 +7,7 @@ #define __NM_SETTING_IP_TUNNEL_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-ip4-config.h b/src/libnm-core-public/nm-setting-ip4-config.h index ce917b11..d0bd836d 100644 --- a/src/libnm-core-public/nm-setting-ip4-config.h +++ b/src/libnm-core-public/nm-setting-ip4-config.h @@ -8,7 +8,7 @@ #define __NM_SETTING_IP4_CONFIG_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting-ip-config.h" diff --git a/src/libnm-core-public/nm-setting-ip6-config.h b/src/libnm-core-public/nm-setting-ip6-config.h index 5e5d459d..c51a7438 100644 --- a/src/libnm-core-public/nm-setting-ip6-config.h +++ b/src/libnm-core-public/nm-setting-ip6-config.h @@ -7,7 +7,7 @@ #define __NM_SETTING_IP6_CONFIG_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting-ip-config.h" diff --git a/src/libnm-core-public/nm-setting-macsec.h b/src/libnm-core-public/nm-setting-macsec.h index 67801a64..52e4313d 100644 --- a/src/libnm-core-public/nm-setting-macsec.h +++ b/src/libnm-core-public/nm-setting-macsec.h @@ -7,7 +7,7 @@ #define __NM_SETTING_MACSEC_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-macvlan.h b/src/libnm-core-public/nm-setting-macvlan.h index 82a5b20d..88ee81e7 100644 --- a/src/libnm-core-public/nm-setting-macvlan.h +++ b/src/libnm-core-public/nm-setting-macvlan.h @@ -7,7 +7,7 @@ #define __NM_SETTING_MACVLAN_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-match.h b/src/libnm-core-public/nm-setting-match.h index 40d12b65..a4e283e2 100644 --- a/src/libnm-core-public/nm-setting-match.h +++ b/src/libnm-core-public/nm-setting-match.h @@ -7,7 +7,7 @@ #define NM_SETTING_MATCH_H #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-olpc-mesh.h b/src/libnm-core-public/nm-setting-olpc-mesh.h index f692d9a3..c9903f75 100644 --- a/src/libnm-core-public/nm-setting-olpc-mesh.h +++ b/src/libnm-core-public/nm-setting-olpc-mesh.h @@ -9,7 +9,7 @@ #define __NM_SETTING_OLPC_MESH_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-ovs-bridge.h b/src/libnm-core-public/nm-setting-ovs-bridge.h index b3078715..33e8dffb 100644 --- a/src/libnm-core-public/nm-setting-ovs-bridge.h +++ b/src/libnm-core-public/nm-setting-ovs-bridge.h @@ -7,7 +7,7 @@ #define __NM_SETTING_OVS_BRIDGE_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-ovs-dpdk.h b/src/libnm-core-public/nm-setting-ovs-dpdk.h index 72de2243..5d96aef4 100644 --- a/src/libnm-core-public/nm-setting-ovs-dpdk.h +++ b/src/libnm-core-public/nm-setting-ovs-dpdk.h @@ -7,7 +7,7 @@ #define __NM_SETTING_OVS_DPDK_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-ovs-external-ids.h b/src/libnm-core-public/nm-setting-ovs-external-ids.h index 906db392..3ae991a1 100644 --- a/src/libnm-core-public/nm-setting-ovs-external-ids.h +++ b/src/libnm-core-public/nm-setting-ovs-external-ids.h @@ -7,7 +7,7 @@ #define __NM_SETTING_OVS_EXTERNAL_IDS_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-ovs-interface.h b/src/libnm-core-public/nm-setting-ovs-interface.h index 47ad5817..a36a1a53 100644 --- a/src/libnm-core-public/nm-setting-ovs-interface.h +++ b/src/libnm-core-public/nm-setting-ovs-interface.h @@ -7,7 +7,7 @@ #define __NM_SETTING_OVS_INTERFACE_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-ovs-patch.h b/src/libnm-core-public/nm-setting-ovs-patch.h index fd80d45a..1d5f4843 100644 --- a/src/libnm-core-public/nm-setting-ovs-patch.h +++ b/src/libnm-core-public/nm-setting-ovs-patch.h @@ -7,7 +7,7 @@ #define __NM_SETTING_OVS_PATCH_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-ovs-port.h b/src/libnm-core-public/nm-setting-ovs-port.h index 06d3a2aa..eda23d3e 100644 --- a/src/libnm-core-public/nm-setting-ovs-port.h +++ b/src/libnm-core-public/nm-setting-ovs-port.h @@ -7,7 +7,7 @@ #define __NM_SETTING_OVS_PORT_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-ppp.h b/src/libnm-core-public/nm-setting-ppp.h index 2c85f3fd..d9f93a5b 100644 --- a/src/libnm-core-public/nm-setting-ppp.h +++ b/src/libnm-core-public/nm-setting-ppp.h @@ -8,7 +8,7 @@ #define __NM_SETTING_PPP_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-pppoe.h b/src/libnm-core-public/nm-setting-pppoe.h index b9eb34bb..5abf9c9f 100644 --- a/src/libnm-core-public/nm-setting-pppoe.h +++ b/src/libnm-core-public/nm-setting-pppoe.h @@ -8,7 +8,7 @@ #define __NM_SETTING_PPPOE_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-proxy.h b/src/libnm-core-public/nm-setting-proxy.h index a10786ab..f2863916 100644 --- a/src/libnm-core-public/nm-setting-proxy.h +++ b/src/libnm-core-public/nm-setting-proxy.h @@ -7,7 +7,7 @@ #define __NM_SETTING_PROXY_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-serial.h b/src/libnm-core-public/nm-setting-serial.h index b3b0421a..4f8ead82 100644 --- a/src/libnm-core-public/nm-setting-serial.h +++ b/src/libnm-core-public/nm-setting-serial.h @@ -8,7 +8,7 @@ #define __NM_SETTING_SERIAL_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-sriov.h b/src/libnm-core-public/nm-setting-sriov.h index fe5fc376..93afde98 100644 --- a/src/libnm-core-public/nm-setting-sriov.h +++ b/src/libnm-core-public/nm-setting-sriov.h @@ -7,7 +7,7 @@ #define NM_SETTING_SRIOV_H #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-tc-config.h b/src/libnm-core-public/nm-setting-tc-config.h index a2bc9a0d..7e8a44b5 100644 --- a/src/libnm-core-public/nm-setting-tc-config.h +++ b/src/libnm-core-public/nm-setting-tc-config.h @@ -7,7 +7,7 @@ #define NM_SETTING_TC_CONFIG_H #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-team-port.h b/src/libnm-core-public/nm-setting-team-port.h index 7acd9bf2..3e472257 100644 --- a/src/libnm-core-public/nm-setting-team-port.h +++ b/src/libnm-core-public/nm-setting-team-port.h @@ -7,7 +7,7 @@ #define __NM_SETTING_TEAM_PORT_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-team.h b/src/libnm-core-public/nm-setting-team.h index 5ed7ac36..82174152 100644 --- a/src/libnm-core-public/nm-setting-team.h +++ b/src/libnm-core-public/nm-setting-team.h @@ -7,7 +7,7 @@ #define __NM_SETTING_TEAM_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-tun.h b/src/libnm-core-public/nm-setting-tun.h index b7376995..8f808410 100644 --- a/src/libnm-core-public/nm-setting-tun.h +++ b/src/libnm-core-public/nm-setting-tun.h @@ -7,7 +7,7 @@ #define __NM_SETTING_TUN_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-user.h b/src/libnm-core-public/nm-setting-user.h index b151cd3e..7f44afae 100644 --- a/src/libnm-core-public/nm-setting-user.h +++ b/src/libnm-core-public/nm-setting-user.h @@ -7,7 +7,7 @@ #define __NM_SETTING_USER_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-veth.h b/src/libnm-core-public/nm-setting-veth.h index 5dbc1927..2609a2c6 100644 --- a/src/libnm-core-public/nm-setting-veth.h +++ b/src/libnm-core-public/nm-setting-veth.h @@ -7,7 +7,7 @@ #define __NM_SETTING_VETH_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-vlan.h b/src/libnm-core-public/nm-setting-vlan.h index 1d2470b6..09a407db 100644 --- a/src/libnm-core-public/nm-setting-vlan.h +++ b/src/libnm-core-public/nm-setting-vlan.h @@ -7,7 +7,7 @@ #define __NM_SETTING_VLAN_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-vpn.h b/src/libnm-core-public/nm-setting-vpn.h index 3a74d0b1..9fbb791b 100644 --- a/src/libnm-core-public/nm-setting-vpn.h +++ b/src/libnm-core-public/nm-setting-vpn.h @@ -8,7 +8,7 @@ #define __NM_SETTING_VPN_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-vrf.h b/src/libnm-core-public/nm-setting-vrf.h index afa044b8..01194863 100644 --- a/src/libnm-core-public/nm-setting-vrf.h +++ b/src/libnm-core-public/nm-setting-vrf.h @@ -4,7 +4,7 @@ #define __NM_SETTING_VRF_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-vxlan.h b/src/libnm-core-public/nm-setting-vxlan.h index 6531f1d2..0cf84eaf 100644 --- a/src/libnm-core-public/nm-setting-vxlan.h +++ b/src/libnm-core-public/nm-setting-vxlan.h @@ -7,7 +7,7 @@ #define __NM_SETTING_VXLAN_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-wifi-p2p.h b/src/libnm-core-public/nm-setting-wifi-p2p.h index 029b75f0..50cafad4 100644 --- a/src/libnm-core-public/nm-setting-wifi-p2p.h +++ b/src/libnm-core-public/nm-setting-wifi-p2p.h @@ -7,7 +7,7 @@ #define __NM_SETTING_WIFI_P2P_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-wimax.h b/src/libnm-core-public/nm-setting-wimax.h index 12125fb2..88c8588f 100644 --- a/src/libnm-core-public/nm-setting-wimax.h +++ b/src/libnm-core-public/nm-setting-wimax.h @@ -7,7 +7,7 @@ #define __NM_SETTING_WIMAX_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-wired.h b/src/libnm-core-public/nm-setting-wired.h index 33308604..54c8f9c0 100644 --- a/src/libnm-core-public/nm-setting-wired.h +++ b/src/libnm-core-public/nm-setting-wired.h @@ -8,7 +8,7 @@ #define __NM_SETTING_WIRED_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-wireguard.h b/src/libnm-core-public/nm-setting-wireguard.h index 3f046fc7..cb475d27 100644 --- a/src/libnm-core-public/nm-setting-wireguard.h +++ b/src/libnm-core-public/nm-setting-wireguard.h @@ -7,7 +7,7 @@ #define __NM_SETTING_WIREGUARD_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-wireless-security.h b/src/libnm-core-public/nm-setting-wireless-security.h index cf662a37..9686e7d5 100644 --- a/src/libnm-core-public/nm-setting-wireless-security.h +++ b/src/libnm-core-public/nm-setting-wireless-security.h @@ -8,7 +8,7 @@ #define __NM_SETTING_WIRELESS_SECURITY_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-wireless.h b/src/libnm-core-public/nm-setting-wireless.h index 0b45e2a3..4451785f 100644 --- a/src/libnm-core-public/nm-setting-wireless.h +++ b/src/libnm-core-public/nm-setting-wireless.h @@ -8,7 +8,7 @@ #define __NM_SETTING_WIRELESS_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting-wpan.h b/src/libnm-core-public/nm-setting-wpan.h index 2a09d49b..883b77e1 100644 --- a/src/libnm-core-public/nm-setting-wpan.h +++ b/src/libnm-core-public/nm-setting-wpan.h @@ -7,7 +7,7 @@ #define __NM_SETTING_WPAN_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-setting.h" diff --git a/src/libnm-core-public/nm-setting.h b/src/libnm-core-public/nm-setting.h index 6206a774..ea2525dc 100644 --- a/src/libnm-core-public/nm-setting.h +++ b/src/libnm-core-public/nm-setting.h @@ -8,7 +8,7 @@ #define __NM_SETTING_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-core-types.h" diff --git a/src/libnm-core-public/nm-simple-connection.h b/src/libnm-core-public/nm-simple-connection.h index 6586c922..cc20bd16 100644 --- a/src/libnm-core-public/nm-simple-connection.h +++ b/src/libnm-core-public/nm-simple-connection.h @@ -7,7 +7,7 @@ #define __NM_SIMPLE_CONNECTION_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include "nm-connection.h" diff --git a/src/libnm-core-public/nm-utils.h b/src/libnm-core-public/nm-utils.h index 0f8dcda0..5100b678 100644 --- a/src/libnm-core-public/nm-utils.h +++ b/src/libnm-core-public/nm-utils.h @@ -7,7 +7,7 @@ #define __NM_UTILS_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include diff --git a/src/libnm-core-public/nm-version-macros.h b/src/libnm-core-public/nm-version-macros.h index c3899eab..3063f2f4 100644 --- a/src/libnm-core-public/nm-version-macros.h +++ b/src/libnm-core-public/nm-version-macros.h @@ -22,7 +22,7 @@ * Evaluates to the minor version number of NetworkManager which this source * is compiled against. */ -#define NM_MINOR_VERSION (32) +#define NM_MINOR_VERSION (34) /** * NM_MICRO_VERSION: @@ -30,7 +30,7 @@ * Evaluates to the micro version number of NetworkManager which this source * compiled against. */ -#define NM_MICRO_VERSION (12) +#define NM_MICRO_VERSION (0) /** * NM_CHECK_VERSION: @@ -68,7 +68,7 @@ #define NM_VERSION_1_28 (NM_ENCODE_VERSION (1, 28, 0)) #define NM_VERSION_1_30 (NM_ENCODE_VERSION (1, 30, 0)) #define NM_VERSION_1_32 (NM_ENCODE_VERSION (1, 32, 0)) -#define NM_VERSION_1_32_4 (NM_ENCODE_VERSION (1, 32, 4)) +#define NM_VERSION_1_34 (NM_ENCODE_VERSION (1, 34, 0)) /* For releases, NM_API_VERSION is equal to NM_VERSION. * diff --git a/src/libnm-core-public/nm-version-macros.h.in b/src/libnm-core-public/nm-version-macros.h.in index 35e89287..8ec83436 100644 --- a/src/libnm-core-public/nm-version-macros.h.in +++ b/src/libnm-core-public/nm-version-macros.h.in @@ -68,7 +68,7 @@ #define NM_VERSION_1_28 (NM_ENCODE_VERSION (1, 28, 0)) #define NM_VERSION_1_30 (NM_ENCODE_VERSION (1, 30, 0)) #define NM_VERSION_1_32 (NM_ENCODE_VERSION (1, 32, 0)) -#define NM_VERSION_1_32_4 (NM_ENCODE_VERSION (1, 32, 4)) +#define NM_VERSION_1_34 (NM_ENCODE_VERSION (1, 34, 0)) /* For releases, NM_API_VERSION is equal to NM_VERSION. * diff --git a/src/libnm-core-public/nm-version.h b/src/libnm-core-public/nm-version.h index 10ceb581..f0f09fa8 100644 --- a/src/libnm-core-public/nm-version.h +++ b/src/libnm-core-public/nm-version.h @@ -13,282 +13,290 @@ /* Deprecation / Availability macros */ #if !defined(NM_VERSION_MIN_REQUIRED) || (NM_VERSION_MIN_REQUIRED == 0) - #undef NM_VERSION_MIN_REQUIRED - #define NM_VERSION_MIN_REQUIRED (NM_API_VERSION) +#undef NM_VERSION_MIN_REQUIRED +#define NM_VERSION_MIN_REQUIRED (NM_API_VERSION) #endif #if !defined(NM_VERSION_MAX_ALLOWED) || (NM_VERSION_MAX_ALLOWED == 0) - #undef NM_VERSION_MAX_ALLOWED - #define NM_VERSION_MAX_ALLOWED (NM_API_VERSION) +#undef NM_VERSION_MAX_ALLOWED +#define NM_VERSION_MAX_ALLOWED (NM_API_VERSION) #endif /* sanity checks */ #if NM_VERSION_MIN_REQUIRED > NM_API_VERSION - #error "NM_VERSION_MIN_REQUIRED must be <= NM_API_VERSION" +#error "NM_VERSION_MIN_REQUIRED must be <= NM_API_VERSION" #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_MIN_REQUIRED - #error "NM_VERSION_MAX_ALLOWED must be >= NM_VERSION_MIN_REQUIRED" +#error "NM_VERSION_MAX_ALLOWED must be >= NM_VERSION_MIN_REQUIRED" #endif #if NM_VERSION_MIN_REQUIRED < NM_VERSION_0_9_8 - #error "NM_VERSION_MIN_REQUIRED must be >= NM_VERSION_0_9_8" +#error "NM_VERSION_MIN_REQUIRED must be >= NM_VERSION_0_9_8" #endif #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_0_9_10 - #define NM_DEPRECATED_IN_0_9_10 G_DEPRECATED - #define NM_DEPRECATED_IN_0_9_10_FOR(f) G_DEPRECATED_FOR(f) +#define NM_DEPRECATED_IN_0_9_10 G_DEPRECATED +#define NM_DEPRECATED_IN_0_9_10_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_DEPRECATED_IN_0_9_10 - #define NM_DEPRECATED_IN_0_9_10_FOR(f) +#define NM_DEPRECATED_IN_0_9_10 +#define NM_DEPRECATED_IN_0_9_10_FOR(f) #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_0_9_10 - #define NM_AVAILABLE_IN_0_9_10 G_UNAVAILABLE(0.9, 10) +#define NM_AVAILABLE_IN_0_9_10 G_UNAVAILABLE(0.9, 10) #else - #define NM_AVAILABLE_IN_0_9_10 +#define NM_AVAILABLE_IN_0_9_10 #endif #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_0 - #define NM_DEPRECATED_IN_1_0 G_DEPRECATED - #define NM_DEPRECATED_IN_1_0_FOR(f) G_DEPRECATED_FOR(f) +#define NM_DEPRECATED_IN_1_0 G_DEPRECATED +#define NM_DEPRECATED_IN_1_0_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_DEPRECATED_IN_1_0 - #define NM_DEPRECATED_IN_1_0_FOR(f) +#define NM_DEPRECATED_IN_1_0 +#define NM_DEPRECATED_IN_1_0_FOR(f) #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_0 - #define NM_AVAILABLE_IN_1_0 G_UNAVAILABLE(1, 0) +#define NM_AVAILABLE_IN_1_0 G_UNAVAILABLE(1, 0) #else - #define NM_AVAILABLE_IN_1_0 +#define NM_AVAILABLE_IN_1_0 #endif #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_2 - #define NM_DEPRECATED_IN_1_2 G_DEPRECATED - #define NM_DEPRECATED_IN_1_2_FOR(f) G_DEPRECATED_FOR(f) +#define NM_DEPRECATED_IN_1_2 G_DEPRECATED +#define NM_DEPRECATED_IN_1_2_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_DEPRECATED_IN_1_2 - #define NM_DEPRECATED_IN_1_2_FOR(f) +#define NM_DEPRECATED_IN_1_2 +#define NM_DEPRECATED_IN_1_2_FOR(f) #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_2 - #define NM_AVAILABLE_IN_1_2 G_UNAVAILABLE(1, 2) +#define NM_AVAILABLE_IN_1_2 G_UNAVAILABLE(1, 2) #else - #define NM_AVAILABLE_IN_1_2 +#define NM_AVAILABLE_IN_1_2 #endif #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_4 - #define NM_DEPRECATED_IN_1_4 G_DEPRECATED - #define NM_DEPRECATED_IN_1_4_FOR(f) G_DEPRECATED_FOR(f) +#define NM_DEPRECATED_IN_1_4 G_DEPRECATED +#define NM_DEPRECATED_IN_1_4_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_DEPRECATED_IN_1_4 - #define NM_DEPRECATED_IN_1_4_FOR(f) +#define NM_DEPRECATED_IN_1_4 +#define NM_DEPRECATED_IN_1_4_FOR(f) #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_4 - #define NM_AVAILABLE_IN_1_4 G_UNAVAILABLE(1, 4) +#define NM_AVAILABLE_IN_1_4 G_UNAVAILABLE(1, 4) #else - #define NM_AVAILABLE_IN_1_4 +#define NM_AVAILABLE_IN_1_4 #endif #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_6 - #define NM_DEPRECATED_IN_1_6 G_DEPRECATED - #define NM_DEPRECATED_IN_1_6_FOR(f) G_DEPRECATED_FOR(f) +#define NM_DEPRECATED_IN_1_6 G_DEPRECATED +#define NM_DEPRECATED_IN_1_6_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_DEPRECATED_IN_1_6 - #define NM_DEPRECATED_IN_1_6_FOR(f) +#define NM_DEPRECATED_IN_1_6 +#define NM_DEPRECATED_IN_1_6_FOR(f) #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_6 - #define NM_AVAILABLE_IN_1_6 G_UNAVAILABLE(1, 6) +#define NM_AVAILABLE_IN_1_6 G_UNAVAILABLE(1, 6) #else - #define NM_AVAILABLE_IN_1_6 +#define NM_AVAILABLE_IN_1_6 #endif #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_8 - #define NM_DEPRECATED_IN_1_8 G_DEPRECATED - #define NM_DEPRECATED_IN_1_8_FOR(f) G_DEPRECATED_FOR(f) +#define NM_DEPRECATED_IN_1_8 G_DEPRECATED +#define NM_DEPRECATED_IN_1_8_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_DEPRECATED_IN_1_8 - #define NM_DEPRECATED_IN_1_8_FOR(f) +#define NM_DEPRECATED_IN_1_8 +#define NM_DEPRECATED_IN_1_8_FOR(f) #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_8 - #define NM_AVAILABLE_IN_1_8 G_UNAVAILABLE(1, 8) +#define NM_AVAILABLE_IN_1_8 G_UNAVAILABLE(1, 8) #else - #define NM_AVAILABLE_IN_1_8 +#define NM_AVAILABLE_IN_1_8 #endif #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_10 - #define NM_DEPRECATED_IN_1_10 G_DEPRECATED - #define NM_DEPRECATED_IN_1_10_FOR(f) G_DEPRECATED_FOR(f) +#define NM_DEPRECATED_IN_1_10 G_DEPRECATED +#define NM_DEPRECATED_IN_1_10_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_DEPRECATED_IN_1_10 - #define NM_DEPRECATED_IN_1_10_FOR(f) +#define NM_DEPRECATED_IN_1_10 +#define NM_DEPRECATED_IN_1_10_FOR(f) #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_10 - #define NM_AVAILABLE_IN_1_10 G_UNAVAILABLE(1, 10) +#define NM_AVAILABLE_IN_1_10 G_UNAVAILABLE(1, 10) #else - #define NM_AVAILABLE_IN_1_10 +#define NM_AVAILABLE_IN_1_10 #endif #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_12 - #define NM_DEPRECATED_IN_1_12 G_DEPRECATED - #define NM_DEPRECATED_IN_1_12_FOR(f) G_DEPRECATED_FOR(f) +#define NM_DEPRECATED_IN_1_12 G_DEPRECATED +#define NM_DEPRECATED_IN_1_12_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_DEPRECATED_IN_1_12 - #define NM_DEPRECATED_IN_1_12_FOR(f) +#define NM_DEPRECATED_IN_1_12 +#define NM_DEPRECATED_IN_1_12_FOR(f) #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_12 - #define NM_AVAILABLE_IN_1_12 G_UNAVAILABLE(1, 12) +#define NM_AVAILABLE_IN_1_12 G_UNAVAILABLE(1, 12) #else - #define NM_AVAILABLE_IN_1_12 +#define NM_AVAILABLE_IN_1_12 #endif #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_14 - #define NM_DEPRECATED_IN_1_14 G_DEPRECATED - #define NM_DEPRECATED_IN_1_14_FOR(f) G_DEPRECATED_FOR(f) +#define NM_DEPRECATED_IN_1_14 G_DEPRECATED +#define NM_DEPRECATED_IN_1_14_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_DEPRECATED_IN_1_14 - #define NM_DEPRECATED_IN_1_14_FOR(f) +#define NM_DEPRECATED_IN_1_14 +#define NM_DEPRECATED_IN_1_14_FOR(f) #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_14 - #define NM_AVAILABLE_IN_1_14 G_UNAVAILABLE(1, 14) +#define NM_AVAILABLE_IN_1_14 G_UNAVAILABLE(1, 14) #else - #define NM_AVAILABLE_IN_1_14 +#define NM_AVAILABLE_IN_1_14 #endif #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_16 - #define NM_DEPRECATED_IN_1_16 G_DEPRECATED - #define NM_DEPRECATED_IN_1_16_FOR(f) G_DEPRECATED_FOR(f) +#define NM_DEPRECATED_IN_1_16 G_DEPRECATED +#define NM_DEPRECATED_IN_1_16_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_DEPRECATED_IN_1_16 - #define NM_DEPRECATED_IN_1_16_FOR(f) +#define NM_DEPRECATED_IN_1_16 +#define NM_DEPRECATED_IN_1_16_FOR(f) #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_16 - #define NM_AVAILABLE_IN_1_16 G_UNAVAILABLE(1, 16) +#define NM_AVAILABLE_IN_1_16 G_UNAVAILABLE(1, 16) #else - #define NM_AVAILABLE_IN_1_16 +#define NM_AVAILABLE_IN_1_16 #endif #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_18 - #define NM_DEPRECATED_IN_1_18 G_DEPRECATED - #define NM_DEPRECATED_IN_1_18_FOR(f) G_DEPRECATED_FOR(f) +#define NM_DEPRECATED_IN_1_18 G_DEPRECATED +#define NM_DEPRECATED_IN_1_18_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_DEPRECATED_IN_1_18 - #define NM_DEPRECATED_IN_1_18_FOR(f) +#define NM_DEPRECATED_IN_1_18 +#define NM_DEPRECATED_IN_1_18_FOR(f) #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_18 - #define NM_AVAILABLE_IN_1_18 G_UNAVAILABLE(1, 18) +#define NM_AVAILABLE_IN_1_18 G_UNAVAILABLE(1, 18) #else - #define NM_AVAILABLE_IN_1_18 +#define NM_AVAILABLE_IN_1_18 #endif #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_20 - #define NM_DEPRECATED_IN_1_20 G_DEPRECATED - #define NM_DEPRECATED_IN_1_20_FOR(f) G_DEPRECATED_FOR(f) +#define NM_DEPRECATED_IN_1_20 G_DEPRECATED +#define NM_DEPRECATED_IN_1_20_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_DEPRECATED_IN_1_20 - #define NM_DEPRECATED_IN_1_20_FOR(f) +#define NM_DEPRECATED_IN_1_20 +#define NM_DEPRECATED_IN_1_20_FOR(f) #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_20 - #define NM_AVAILABLE_IN_1_20 G_UNAVAILABLE(1, 20) +#define NM_AVAILABLE_IN_1_20 G_UNAVAILABLE(1, 20) #else - #define NM_AVAILABLE_IN_1_20 +#define NM_AVAILABLE_IN_1_20 #endif #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_22 - #define NM_DEPRECATED_IN_1_22 G_DEPRECATED - #define NM_DEPRECATED_IN_1_22_FOR(f) G_DEPRECATED_FOR(f) +#define NM_DEPRECATED_IN_1_22 G_DEPRECATED +#define NM_DEPRECATED_IN_1_22_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_DEPRECATED_IN_1_22 - #define NM_DEPRECATED_IN_1_22_FOR(f) +#define NM_DEPRECATED_IN_1_22 +#define NM_DEPRECATED_IN_1_22_FOR(f) #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_22 - #define NM_AVAILABLE_IN_1_22 G_UNAVAILABLE(1, 22) +#define NM_AVAILABLE_IN_1_22 G_UNAVAILABLE(1, 22) #else - #define NM_AVAILABLE_IN_1_22 +#define NM_AVAILABLE_IN_1_22 #endif #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_24 - #define NM_DEPRECATED_IN_1_24 G_DEPRECATED - #define NM_DEPRECATED_IN_1_24_FOR(f) G_DEPRECATED_FOR(f) +#define NM_DEPRECATED_IN_1_24 G_DEPRECATED +#define NM_DEPRECATED_IN_1_24_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_DEPRECATED_IN_1_24 - #define NM_DEPRECATED_IN_1_24_FOR(f) +#define NM_DEPRECATED_IN_1_24 +#define NM_DEPRECATED_IN_1_24_FOR(f) #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_24 - #define NM_AVAILABLE_IN_1_24 G_UNAVAILABLE(1, 24) +#define NM_AVAILABLE_IN_1_24 G_UNAVAILABLE(1, 24) #else - #define NM_AVAILABLE_IN_1_24 +#define NM_AVAILABLE_IN_1_24 #endif #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_26 - #define NM_DEPRECATED_IN_1_26 G_DEPRECATED - #define NM_DEPRECATED_IN_1_26_FOR(f) G_DEPRECATED_FOR(f) +#define NM_DEPRECATED_IN_1_26 G_DEPRECATED +#define NM_DEPRECATED_IN_1_26_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_DEPRECATED_IN_1_26 - #define NM_DEPRECATED_IN_1_26_FOR(f) +#define NM_DEPRECATED_IN_1_26 +#define NM_DEPRECATED_IN_1_26_FOR(f) #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_26 - #define NM_AVAILABLE_IN_1_26 G_UNAVAILABLE(1, 26) +#define NM_AVAILABLE_IN_1_26 G_UNAVAILABLE(1, 26) #else - #define NM_AVAILABLE_IN_1_26 +#define NM_AVAILABLE_IN_1_26 #endif #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_28 - #define NM_DEPRECATED_IN_1_28 G_DEPRECATED - #define NM_DEPRECATED_IN_1_28_FOR(f) G_DEPRECATED_FOR(f) +#define NM_DEPRECATED_IN_1_28 G_DEPRECATED +#define NM_DEPRECATED_IN_1_28_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_DEPRECATED_IN_1_28 - #define NM_DEPRECATED_IN_1_28_FOR(f) +#define NM_DEPRECATED_IN_1_28 +#define NM_DEPRECATED_IN_1_28_FOR(f) #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_28 - #define NM_AVAILABLE_IN_1_28 G_UNAVAILABLE(1, 28) +#define NM_AVAILABLE_IN_1_28 G_UNAVAILABLE(1, 28) #else - #define NM_AVAILABLE_IN_1_28 +#define NM_AVAILABLE_IN_1_28 #endif #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_30 - #define NM_DEPRECATED_IN_1_30 G_DEPRECATED - #define NM_DEPRECATED_IN_1_30_FOR(f) G_DEPRECATED_FOR(f) +#define NM_DEPRECATED_IN_1_30 G_DEPRECATED +#define NM_DEPRECATED_IN_1_30_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_DEPRECATED_IN_1_30 - #define NM_DEPRECATED_IN_1_30_FOR(f) +#define NM_DEPRECATED_IN_1_30 +#define NM_DEPRECATED_IN_1_30_FOR(f) #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_30 - #define NM_AVAILABLE_IN_1_30 G_UNAVAILABLE(1, 30) +#define NM_AVAILABLE_IN_1_30 G_UNAVAILABLE(1, 30) #else - #define NM_AVAILABLE_IN_1_30 +#define NM_AVAILABLE_IN_1_30 #endif #if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_32 - #define NM_DEPRECATED_IN_1_32 G_DEPRECATED - #define NM_DEPRECATED_IN_1_32_FOR(f) G_DEPRECATED_FOR(f) +#define NM_DEPRECATED_IN_1_32 G_DEPRECATED +#define NM_DEPRECATED_IN_1_32_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_DEPRECATED_IN_1_32 - #define NM_DEPRECATED_IN_1_32_FOR(f) +#define NM_DEPRECATED_IN_1_32 +#define NM_DEPRECATED_IN_1_32_FOR(f) #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_32 - #define NM_AVAILABLE_IN_1_32 G_UNAVAILABLE(1, 32) +#define NM_AVAILABLE_IN_1_32 G_UNAVAILABLE(1, 32) #else - #define NM_AVAILABLE_IN_1_32 +#define NM_AVAILABLE_IN_1_32 #endif -#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_32_4 - #define NM_AVAILABLE_IN_1_32_4 G_UNAVAILABLE(1, 32.4) +#if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_34 +#define NM_DEPRECATED_IN_1_34 G_DEPRECATED +#define NM_DEPRECATED_IN_1_34_FOR(f) G_DEPRECATED_FOR(f) #else - #define NM_AVAILABLE_IN_1_32_4 +#define NM_DEPRECATED_IN_1_34 +#define NM_DEPRECATED_IN_1_34_FOR(f) +#endif + +#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_34 +#define NM_AVAILABLE_IN_1_34 G_UNAVAILABLE(1, 34) +#else +#define NM_AVAILABLE_IN_1_34 #endif /* diff --git a/src/libnm-core-public/nm-vpn-dbus-interface.h b/src/libnm-core-public/nm-vpn-dbus-interface.h index c0e23f6f..518999dd 100644 --- a/src/libnm-core-public/nm-vpn-dbus-interface.h +++ b/src/libnm-core-public/nm-vpn-dbus-interface.h @@ -15,7 +15,7 @@ #include "nm-dbus-interface.h" #ifndef NM_VERSION_H - #define NM_DEPRECATED_IN_1_8_FOR(n) +#define NM_DEPRECATED_IN_1_8_FOR(n) #endif /* @@ -171,7 +171,7 @@ typedef enum { } NMVpnPluginFailure; #ifndef NM_VERSION_H - #undef NM_DEPRECATED_IN_1_8_FOR +#undef NM_DEPRECATED_IN_1_8_FOR #endif /*** Generic config ***/ diff --git a/src/libnm-core-public/nm-vpn-editor-plugin.h b/src/libnm-core-public/nm-vpn-editor-plugin.h index e318da07..e25c358e 100644 --- a/src/libnm-core-public/nm-vpn-editor-plugin.h +++ b/src/libnm-core-public/nm-vpn-editor-plugin.h @@ -8,7 +8,7 @@ #define __NM_VPN_EDITOR_PLUGIN_H__ #if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) - #error "Only can be included directly." +#error "Only can be included directly." #endif #include diff --git a/src/libnm-glib-aux/nm-dbus-aux.c b/src/libnm-glib-aux/nm-dbus-aux.c index f4f53a7d..454bd2d8 100644 --- a/src/libnm-glib-aux/nm-dbus-aux.c +++ b/src/libnm-glib-aux/nm-dbus-aux.c @@ -403,3 +403,90 @@ _nm_dbus_error_is(GError *error, ...) return FALSE; } + +/*****************************************************************************/ + +typedef struct { + GDBusConnection **p_dbus_connection; + GError ** p_error; +} BusGetData; + +static void +_bus_get_cb(GObject *source, GAsyncResult *result, gpointer user_data) +{ + BusGetData *data = user_data; + + *data->p_dbus_connection = g_bus_get_finish(result, data->p_error); +} + +/** + * nm_g_bus_get_blocking: + * @cancellable: (allow-none): a #GCancellable to abort the operation. + * @error: (allow-none): the error. + * + * This calls g_bus_get(), but iterates the current (thread-default) GMainContext + * until the response is ready. As such, it's similar to g_bus_get_sync(), + * but it allows to cancel the operation (without having multiple threads). + * + * Returns: (transfer full): the new #GDBusConnection or %NULL on error. + */ +GDBusConnection * +nm_g_bus_get_blocking(GCancellable *cancellable, GError **error) +{ + gs_free_error GError *local_error = NULL; + gs_unref_object GDBusConnection *dbus_connection = NULL; + GMainContext * main_context = g_main_context_get_thread_default(); + BusGetData data = { + .p_dbus_connection = &dbus_connection, + .p_error = &local_error, + }; + + g_bus_get(G_BUS_TYPE_SYSTEM, cancellable, _bus_get_cb, &data); + + while (!dbus_connection && !local_error) + g_main_context_iteration(main_context, TRUE); + + if (!dbus_connection) { + g_propagate_error(error, g_steal_pointer(&local_error)); + return NULL; + } + + return g_steal_pointer(&dbus_connection); +} + +/*****************************************************************************/ + +void +nm_dbus_connection_call_blocking_callback(GObject *source, GAsyncResult *res, gpointer user_data) +{ + NMDBusConnectionCallBlockingData *data = user_data; + + nm_assert(data); + nm_assert(!data->result); + nm_assert(!data->error); + + data->result = g_dbus_connection_call_finish(G_DBUS_CONNECTION(source), res, &data->error); +} + +GVariant * +nm_dbus_connection_call_blocking(NMDBusConnectionCallBlockingData *data, GError **error) +{ + GMainContext *main_context = g_main_context_get_thread_default(); + gs_free_error GError *local_error = NULL; + gs_unref_variant GVariant *result = NULL; + + nm_assert(data); + + while (!data->result && !data->error) + g_main_context_iteration(main_context, TRUE); + + local_error = g_steal_pointer(&data->error); + result = g_steal_pointer(&data->result); + + if (!result) { + g_propagate_error(error, g_steal_pointer(&local_error)); + return NULL; + } + + return g_steal_pointer(&result); +} diff --git a/src/libnm-glib-aux/nm-dbus-aux.h b/src/libnm-glib-aux/nm-dbus-aux.h index 65a91311..420a0c55 100644 --- a/src/libnm-glib-aux/nm-dbus-aux.h +++ b/src/libnm-glib-aux/nm-dbus-aux.h @@ -84,6 +84,29 @@ void nm_dbus_connection_call_get_name_owner(GDBusConnection * d NMDBusConnectionCallGetNameOwnerCb callback, gpointer user_data); +static inline void +nm_dbus_connection_call_request_name(GDBusConnection * dbus_connection, + const char * name, + guint32 flags, + int timeout_msec, + GCancellable * cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_dbus_connection_call(dbus_connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, + "RequestName", + g_variant_new("(su)", name, flags), + G_VARIANT_TYPE("(u)"), + G_DBUS_CALL_FLAGS_NONE, + timeout_msec, + cancellable, + callback, + user_data); +} + static inline guint nm_dbus_connection_signal_subscribe_properties_changed(GDBusConnection * dbus_connection, const char * bus_name, @@ -215,4 +238,30 @@ gboolean _nm_dbus_error_is(GError *error, ...) G_GNUC_NULL_TERMINATED; /*****************************************************************************/ +GDBusConnection *nm_g_bus_get_blocking(GCancellable *cancellable, GError **error); + +/*****************************************************************************/ + +typedef struct { + GVariant *result; + GError * error; +} NMDBusConnectionCallBlockingData; + +void +nm_dbus_connection_call_blocking_callback(GObject *source, GAsyncResult *res, gpointer user_data); + +GVariant *nm_dbus_connection_call_blocking(NMDBusConnectionCallBlockingData *data, GError **error); + +/*****************************************************************************/ + +static inline gboolean +nm_g_variant_tuple_get_u(GVariant *v, guint32 *out_u) +{ + if (g_variant_is_of_type(v, G_VARIANT_TYPE("(u)"))) { + g_variant_get(v, "(u)", out_u); + return TRUE; + } + return FALSE; +} + #endif /* __NM_DBUS_AUX_H__ */ diff --git a/src/libnm-glib-aux/nm-default-glib.h b/src/libnm-glib-aux/nm-default-glib.h index e5ccd47f..9d04ddc4 100644 --- a/src/libnm-glib-aux/nm-default-glib.h +++ b/src/libnm-glib-aux/nm-default-glib.h @@ -18,21 +18,21 @@ #include #if defined(_NETWORKMANAGER_COMPILATION_GLIB_I18N_PROG) - #if defined(_NETWORKMANAGER_COMPILATION_GLIB_I18N_LIB) - #error Cannot define _NETWORKMANAGER_COMPILATION_GLIB_I18N_LIB and _NETWORKMANAGER_COMPILATION_GLIB_I18N_PROG together - #endif - #undef _NETWORKMANAGER_COMPILATION_GLIB_I18N_PROG - #include +#if defined(_NETWORKMANAGER_COMPILATION_GLIB_I18N_LIB) +#error Cannot define _NETWORKMANAGER_COMPILATION_GLIB_I18N_LIB and _NETWORKMANAGER_COMPILATION_GLIB_I18N_PROG together +#endif +#undef _NETWORKMANAGER_COMPILATION_GLIB_I18N_PROG +#include #elif defined(_NETWORKMANAGER_COMPILATION_GLIB_I18N_LIB) - #undef _NETWORKMANAGER_COMPILATION_GLIB_I18N_LIB - #include +#undef _NETWORKMANAGER_COMPILATION_GLIB_I18N_LIB +#include #endif /*****************************************************************************/ #if NM_MORE_ASSERTS == 0 - #ifndef G_DISABLE_CAST_CHECKS - /* Unless compiling with G_DISABLE_CAST_CHECKS, glib performs type checking +#ifndef G_DISABLE_CAST_CHECKS +/* Unless compiling with G_DISABLE_CAST_CHECKS, glib performs type checking * during G_VARIANT_TYPE() via g_variant_type_checked_(). This is not necessary * because commonly this cast is needed during something like * @@ -54,9 +54,9 @@ * * Just patch G_VARIANT_TYPE() to perform no check. */ - #undef G_VARIANT_TYPE - #define G_VARIANT_TYPE(type_string) ((const GVariantType *) (type_string)) - #endif +#undef G_VARIANT_TYPE +#define G_VARIANT_TYPE(type_string) ((const GVariantType *) (type_string)) +#endif #endif /*****************************************************************************/ diff --git a/src/libnm-glib-aux/nm-gassert-patch.h b/src/libnm-glib-aux/nm-gassert-patch.h index bac8697c..e4ea23e4 100644 --- a/src/libnm-glib-aux/nm-gassert-patch.h +++ b/src/libnm-glib-aux/nm-gassert-patch.h @@ -25,50 +25,50 @@ _nm_g_return_if_fail_warning(const char *log_domain, const char *file, int line) g_return_if_fail_warning(log_domain, file_buf, ""); } - #define g_return_if_fail_warning(log_domain, pretty_function, expression) \ - _nm_g_return_if_fail_warning(log_domain, __FILE__, __LINE__) +#define g_return_if_fail_warning(log_domain, pretty_function, expression) \ + _nm_g_return_if_fail_warning(log_domain, __FILE__, __LINE__) - #define g_assertion_message_expr(domain, file, line, func, expr) \ - g_assertion_message_expr(domain, file, line, "", (expr) ? "" : NULL) +#define g_assertion_message_expr(domain, file, line, func, expr) \ + g_assertion_message_expr(domain, file, line, "", (expr) ? "" : NULL) - #undef g_return_val_if_reached - #define g_return_val_if_reached(val) \ - G_STMT_START \ - { \ - g_log(G_LOG_DOMAIN, \ - G_LOG_LEVEL_CRITICAL, \ - "file %s: line %d (%s): should not be reached", \ - __FILE__, \ - __LINE__, \ - ""); \ - return (val); \ - } \ - G_STMT_END +#undef g_return_val_if_reached +#define g_return_val_if_reached(val) \ + G_STMT_START \ + { \ + g_log(G_LOG_DOMAIN, \ + G_LOG_LEVEL_CRITICAL, \ + "file %s: line %d (%s): should not be reached", \ + __FILE__, \ + __LINE__, \ + ""); \ + return (val); \ + } \ + G_STMT_END - #undef g_return_if_reached - #define g_return_if_reached() \ - G_STMT_START \ - { \ - g_log(G_LOG_DOMAIN, \ - G_LOG_LEVEL_CRITICAL, \ - "file %s: line %d (%s): should not be reached", \ - __FILE__, \ - __LINE__, \ - ""); \ - return; \ - } \ - G_STMT_END +#undef g_return_if_reached +#define g_return_if_reached() \ + G_STMT_START \ + { \ + g_log(G_LOG_DOMAIN, \ + G_LOG_LEVEL_CRITICAL, \ + "file %s: line %d (%s): should not be reached", \ + __FILE__, \ + __LINE__, \ + ""); \ + return; \ + } \ + G_STMT_END #endif /*****************************************************************************/ #if NM_MORE_ASSERTS == 0 - #define NM_ASSERT_G_RETURN_EXPR(expr) "" - #define NM_ASSERT_NO_MSG 1 +#define NM_ASSERT_G_RETURN_EXPR(expr) "" +#define NM_ASSERT_NO_MSG 1 #else - #define NM_ASSERT_G_RETURN_EXPR(expr) "" expr "" - #define NM_ASSERT_NO_MSG 0 +#define NM_ASSERT_G_RETURN_EXPR(expr) "" expr "" +#define NM_ASSERT_NO_MSG 0 #endif /*****************************************************************************/ diff --git a/src/libnm-glib-aux/nm-glib.h b/src/libnm-glib-aux/nm-glib.h index 66e5c16e..49470d92 100644 --- a/src/libnm-glib-aux/nm-glib.h +++ b/src/libnm-glib-aux/nm-glib.h @@ -9,21 +9,21 @@ /*****************************************************************************/ #ifndef __NM_MACROS_INTERNAL_H__ - #error "nm-glib.h requires nm-macros-internal.h. Do not include this directly" +#error "nm-glib.h requires nm-macros-internal.h. Do not include this directly" #endif /*****************************************************************************/ #ifdef __clang__ - #undef G_GNUC_BEGIN_IGNORE_DEPRECATIONS - #undef G_GNUC_END_IGNORE_DEPRECATIONS +#undef G_GNUC_BEGIN_IGNORE_DEPRECATIONS +#undef G_GNUC_END_IGNORE_DEPRECATIONS - #define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") - #define G_GNUC_END_IGNORE_DEPRECATIONS _Pragma("clang diagnostic pop") +#define G_GNUC_END_IGNORE_DEPRECATIONS _Pragma("clang diagnostic pop") #endif @@ -47,23 +47,23 @@ __g_type_ensure(GType type) #if !GLIB_CHECK_VERSION(2, 34, 0) - #define g_clear_pointer(pp, destroy) \ - G_STMT_START \ - { \ - G_STATIC_ASSERT(sizeof *(pp) == sizeof(gpointer)); \ - /* Only one access, please */ \ - gpointer *_pp = (gpointer *) (pp); \ - gpointer _p; \ - /* This assignment is needed to avoid a gcc warning */ \ - GDestroyNotify _destroy = (GDestroyNotify) (destroy); \ - \ - _p = *_pp; \ - if (_p) { \ - *_pp = NULL; \ - _destroy(_p); \ - } \ - } \ - G_STMT_END +#define g_clear_pointer(pp, destroy) \ + G_STMT_START \ + { \ + G_STATIC_ASSERT(sizeof *(pp) == sizeof(gpointer)); \ + /* Only one access, please */ \ + gpointer *_pp = (gpointer *) (pp); \ + gpointer _p; \ + /* This assignment is needed to avoid a gcc warning */ \ + GDestroyNotify _destroy = (GDestroyNotify) (destroy); \ + \ + _p = *_pp; \ + if (_p) { \ + *_pp = NULL; \ + _destroy(_p); \ + } \ + } \ + G_STMT_END #endif @@ -71,94 +71,94 @@ __g_type_ensure(GType type) #if !GLIB_CHECK_VERSION(2, 34, 0) - /* These are used to clean up the output of test programs; we can just let +/* These are used to clean up the output of test programs; we can just let * them no-op in older glib. */ - #define g_test_expect_message(log_domain, log_level, pattern) - #define g_test_assert_expected_messages() +#define g_test_expect_message(log_domain, log_level, pattern) +#define g_test_assert_expected_messages() #else - /* We build with -DGLIB_MAX_ALLOWED_VERSION set to 2.32 to make sure we don't +/* We build with -DGLIB_MAX_ALLOWED_VERSION set to 2.32 to make sure we don't * accidentally use new API that we shouldn't. But we don't want warnings for * the APIs that we emulate above. */ - #define g_test_expect_message(domain, level, format...) \ - G_STMT_START \ - { \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - g_test_expect_message(domain, level, format); \ - G_GNUC_END_IGNORE_DEPRECATIONS \ - } \ - G_STMT_END - - #define g_test_assert_expected_messages_internal(domain, file, line, func) \ - G_STMT_START \ - { \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - g_test_assert_expected_messages_internal(domain, file, line, func); \ - G_GNUC_END_IGNORE_DEPRECATIONS \ - } \ - G_STMT_END +#define g_test_expect_message(domain, level, format...) \ + G_STMT_START \ + { \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + g_test_expect_message(domain, level, format); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + } \ + G_STMT_END + +#define g_test_assert_expected_messages_internal(domain, file, line, func) \ + G_STMT_START \ + { \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + g_test_assert_expected_messages_internal(domain, file, line, func); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + } \ + G_STMT_END #endif /*****************************************************************************/ #if GLIB_CHECK_VERSION(2, 35, 0) - /* For glib >= 2.36, g_type_init() is deprecated. +/* For glib >= 2.36, g_type_init() is deprecated. * But since 2.35.1 (7c42ab23b55c43ab96d0ac2124b550bf1f49c1ec) this function * does nothing. Replace the call with empty statement. */ - #define nm_g_type_init() \ - G_STMT_START \ - { \ - (void) 0; \ - } \ - G_STMT_END +#define nm_g_type_init() \ + G_STMT_START \ + { \ + (void) 0; \ + } \ + G_STMT_END #else - #define nm_g_type_init() \ - G_STMT_START \ - { \ - g_type_init(); \ - } \ - G_STMT_END +#define nm_g_type_init() \ + G_STMT_START \ + { \ + g_type_init(); \ + } \ + G_STMT_END #endif /*****************************************************************************/ /* g_test_initialized() is only available since glib 2.36. */ #if !GLIB_CHECK_VERSION(2, 36, 0) - #define g_test_initialized() (g_test_config_vars->test_initialized) +#define g_test_initialized() (g_test_config_vars->test_initialized) #endif /*****************************************************************************/ /* g_assert_cmpmem() is only available since glib 2.46. */ #if !GLIB_CHECK_VERSION(2, 45, 7) - #define g_assert_cmpmem(m1, l1, m2, l2) \ - G_STMT_START \ - { \ - gconstpointer __m1 = m1, __m2 = m2; \ - int __l1 = l1, __l2 = l2; \ - if (__l1 != __l2) \ - g_assertion_message_cmpnum(G_LOG_DOMAIN, \ - __FILE__, \ - __LINE__, \ - G_STRFUNC, \ - #l1 " (len(" #m1 ")) == " #l2 " (len(" #m2 "))", \ - __l1, \ - "==", \ - __l2, \ - 'i'); \ - else if (memcmp(__m1, __m2, __l1) != 0) \ - g_assertion_message(G_LOG_DOMAIN, \ - __FILE__, \ - __LINE__, \ - G_STRFUNC, \ - "assertion failed (" #m1 " == " #m2 ")"); \ - } \ - G_STMT_END +#define g_assert_cmpmem(m1, l1, m2, l2) \ + G_STMT_START \ + { \ + gconstpointer __m1 = m1, __m2 = m2; \ + int __l1 = l1, __l2 = l2; \ + if (__l1 != __l2) \ + g_assertion_message_cmpnum(G_LOG_DOMAIN, \ + __FILE__, \ + __LINE__, \ + G_STRFUNC, \ + #l1 " (len(" #m1 ")) == " #l2 " (len(" #m2 "))", \ + __l1, \ + "==", \ + __l2, \ + 'i'); \ + else if (memcmp(__m1, __m2, __l1) != 0) \ + g_assertion_message(G_LOG_DOMAIN, \ + __FILE__, \ + __LINE__, \ + G_STRFUNC, \ + "assertion failed (" #m1 " == " #m2 ")"); \ + } \ + G_STMT_END #endif /*****************************************************************************/ @@ -288,21 +288,21 @@ _nm_g_ptr_array_insert(GPtrArray *array, int index_, gpointer data) #endif #if !GLIB_CHECK_VERSION(2, 40, 0) - #define g_ptr_array_insert(array, index, data) \ - G_STMT_START \ - { \ - _nm_g_ptr_array_insert(array, index, data); \ - } \ - G_STMT_END +#define g_ptr_array_insert(array, index, data) \ + G_STMT_START \ + { \ + _nm_g_ptr_array_insert(array, index, data); \ + } \ + G_STMT_END #else - #define g_ptr_array_insert(array, index, data) \ - G_STMT_START \ - { \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - g_ptr_array_insert(array, index, data); \ - G_GNUC_END_IGNORE_DEPRECATIONS \ - } \ - G_STMT_END +#define g_ptr_array_insert(array, index, data) \ + G_STMT_START \ + { \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + g_ptr_array_insert(array, index, data); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + } \ + G_STMT_END #endif /*****************************************************************************/ @@ -327,37 +327,37 @@ _g_key_file_save_to_file(GKeyFile *key_file, const char *filename, GError **erro return success; } - #define g_key_file_save_to_file(key_file, filename, error) \ - _g_key_file_save_to_file(key_file, filename, error) +#define g_key_file_save_to_file(key_file, filename, error) \ + _g_key_file_save_to_file(key_file, filename, error) #else - #define g_key_file_save_to_file(key_file, filename, error) \ - ({ \ - gboolean _success; \ - \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - _success = g_key_file_save_to_file(key_file, filename, error); \ - G_GNUC_END_IGNORE_DEPRECATIONS \ - _success; \ - }) +#define g_key_file_save_to_file(key_file, filename, error) \ + ({ \ + gboolean _success; \ + \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + _success = g_key_file_save_to_file(key_file, filename, error); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + _success; \ + }) #endif /*****************************************************************************/ #if GLIB_CHECK_VERSION(2, 36, 0) - #define g_credentials_get_unix_pid(creds, error) \ - ({ \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS(g_credentials_get_unix_pid)((creds), (error)); \ - G_GNUC_END_IGNORE_DEPRECATIONS \ - }) +#define g_credentials_get_unix_pid(creds, error) \ + ({ \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS(g_credentials_get_unix_pid)((creds), (error)); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + }) #else - #define g_credentials_get_unix_pid(creds, error) \ - ({ \ - struct ucred *native_creds; \ - \ - native_creds = g_credentials_get_native((creds), G_CREDENTIALS_TYPE_LINUX_UCRED); \ - g_assert(native_creds); \ - native_creds->pid; \ - }) +#define g_credentials_get_unix_pid(creds, error) \ + ({ \ + struct ucred *native_creds; \ + \ + native_creds = g_credentials_get_native((creds), G_CREDENTIALS_TYPE_LINUX_UCRED); \ + g_assert(native_creds); \ + native_creds->pid; \ + }) #endif /*****************************************************************************/ @@ -387,38 +387,39 @@ _nm_g_hash_table_get_keys_as_array(GHashTable *hash_table, guint *length) } #endif #if !GLIB_CHECK_VERSION(2, 40, 0) - #define g_hash_table_get_keys_as_array(hash_table, length) \ - ({ _nm_g_hash_table_get_keys_as_array(hash_table, length); }) +#define g_hash_table_get_keys_as_array(hash_table, length) \ + ({ _nm_g_hash_table_get_keys_as_array(hash_table, length); }) #else - #define g_hash_table_get_keys_as_array(hash_table, length) \ - ({ \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS(g_hash_table_get_keys_as_array) \ - ((hash_table), (length)); \ - G_GNUC_END_IGNORE_DEPRECATIONS \ - }) +#define g_hash_table_get_keys_as_array(hash_table, length) \ + ({ \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS(g_hash_table_get_keys_as_array) \ + ((hash_table), (length)); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + }) #endif /*****************************************************************************/ #ifndef g_info - /* g_info was only added with 2.39.2 */ - #define g_info(...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, __VA_ARGS__) +/* g_info was only added with 2.39.2 */ +#define g_info(...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, __VA_ARGS__) #endif /*****************************************************************************/ #ifdef g_steal_pointer - #undef g_steal_pointer +#undef g_steal_pointer #endif -#define g_steal_pointer(pp) \ - ({ \ - typeof(*(pp)) *const _pp = (pp); \ - typeof(*_pp) _p = *_pp; \ - _nm_unused const void *const _p_type_check = _p; \ - \ - *_pp = NULL; \ - _p; \ +#define g_steal_pointer(pp) \ + ({ \ + typeof(*(pp)) *const _pp = (pp); \ + typeof(*_pp) _p = *_pp; \ + \ + _NM_ENSURE_POINTER(_p); \ + \ + *_pp = NULL; \ + _p; \ }) /*****************************************************************************/ @@ -460,7 +461,7 @@ _nm_g_variant_new_take_string(char *string) return value; #elif !GLIB_CHECK_VERSION(2, 38, 0) GVariant *value; - GBytes * bytes; + GBytes *bytes; g_return_val_if_fail(string != NULL, NULL); g_return_val_if_fail(g_utf8_validate(string, -1, NULL), NULL); @@ -494,17 +495,17 @@ _nm_printf(1, 2) static inline GVariant *_nm_g_variant_new_printf(const char *fo return g_variant_new_take_string(string); } - #define g_variant_new_printf(...) _nm_g_variant_new_printf(__VA_ARGS__) +#define g_variant_new_printf(...) _nm_g_variant_new_printf(__VA_ARGS__) #else - #define g_variant_new_printf(...) \ - ({ \ - GVariant *_v; \ - \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - _v = g_variant_new_printf(__VA_ARGS__); \ - G_GNUC_END_IGNORE_DEPRECATIONS \ - _v; \ - }) +#define g_variant_new_printf(...) \ + ({ \ + GVariant *_v; \ + \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + _v = g_variant_new_printf(__VA_ARGS__); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + _v; \ + }) #endif /*****************************************************************************/ @@ -525,11 +526,11 @@ _nm_printf(1, 2) static inline GVariant *_nm_g_variant_new_printf(const char *fo /*****************************************************************************/ #ifndef g_autofree - /* we still don't rely on recent glib to provide g_autofree. Hence, we continue +/* we still don't rely on recent glib to provide g_autofree. Hence, we continue * to use our gs_* free macros that we took from libgsystem. * * To ease migration towards g_auto*, add a compat define for g_autofree. */ - #define g_autofree gs_free +#define g_autofree gs_free #endif /*****************************************************************************/ @@ -553,7 +554,7 @@ _nm_g_value_unset(GValue *value) if (value->g_type != 0) g_value_unset(value); } - #define g_value_unset _nm_g_value_unset +#define g_value_unset _nm_g_value_unset #endif /* G_PID_FORMAT was added only in 2.53.5. Define it ourself. @@ -571,7 +572,7 @@ _nm_g_value_unset(GValue *value) /* G_SOURCE_FUNC was added in 2.57.2. */ #undef G_SOURCE_FUNC -#define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void)) (f)) +#define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void))(f)) /*****************************************************************************/ @@ -666,30 +667,39 @@ g_hash_table_steal_extended(GHashTable * hash_table, return FALSE; } #else - #define g_hash_table_steal_extended(hash_table, lookup_key, stolen_key, stolen_value) \ - ({ \ - gpointer *_stolen_key = (stolen_key); \ - gpointer *_stolen_value = (stolen_value); \ - \ - /* we cannot allow NULL arguments, because then we would leak the values in +#define g_hash_table_steal_extended(hash_table, lookup_key, stolen_key, stolen_value) \ + ({ \ + gpointer *_stolen_key = (stolen_key); \ + gpointer *_stolen_value = (stolen_value); \ + \ + /* we cannot allow NULL arguments, because then we would leak the values in * the compat implementation. */ \ - g_assert(_stolen_key); \ - g_assert(_stolen_value); \ - \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - g_hash_table_steal_extended(hash_table, lookup_key, _stolen_key, _stolen_value); \ - G_GNUC_END_IGNORE_DEPRECATIONS \ - }) + g_assert(_stolen_key); \ + g_assert(_stolen_value); \ + \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + g_hash_table_steal_extended(hash_table, lookup_key, _stolen_key, _stolen_value); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + }) #endif /*****************************************************************************/ -__attribute__(( - __deprecated__("Don't use g_cancellable_reset(). Create a new cancellable instead."))) void -_nm_g_cancellable_reset(GCancellable *cancellable); +_nm_deprecated("Don't use this API") void _nm_forbidden_glib_api_0(void); +_nm_deprecated("Don't use this API") void _nm_forbidden_glib_api_n(gconstpointer arg0, ...); #undef g_cancellable_reset -#define g_cancellable_reset(cancellable) _nm_g_cancellable_reset(cancellable) +#define g_cancellable_reset(cancellable) _nm_forbidden_glib_api_n(cancellable) + +#undef g_idle_remove_by_data +#define g_idle_remove_by_data(data) _nm_forbidden_glib_api_n(data) + +#undef g_source_remove_by_funcs_user_data +#define g_source_remove_by_funcs_user_data(funcs, user_data) \ + _nm_forbidden_glib_api_n(funcs, user_data) + +#undef g_source_remove_by_user_data +#define g_source_remove_by_user_data(user_data) _nm_forbidden_glib_api_n(user_data) /*****************************************************************************/ diff --git a/src/libnm-glib-aux/nm-hash-utils.c b/src/libnm-glib-aux/nm-hash-utils.c index 10fc097c..a6949ebd 100644 --- a/src/libnm-glib-aux/nm-hash-utils.c +++ b/src/libnm-glib-aux/nm-hash-utils.c @@ -255,7 +255,7 @@ nm_ppdirect_equal(gconstpointer a, gconstpointer b) /*****************************************************************************/ guint -nm_gbytes_hash(gconstpointer p) +nm_g_bytes_hash(gconstpointer p) { GBytes * ptr = (GBytes *) p; gconstpointer arr; @@ -266,7 +266,7 @@ nm_gbytes_hash(gconstpointer p) } guint -nm_pgbytes_hash(gconstpointer p) +nm_pg_bytes_hash(gconstpointer p) { GBytes *const *ptr = p; gconstpointer arr; @@ -277,7 +277,7 @@ nm_pgbytes_hash(gconstpointer p) } gboolean -nm_pgbytes_equal(gconstpointer a, gconstpointer b) +nm_pg_bytes_equal(gconstpointer a, gconstpointer b) { GBytes *const *ptr_a = a; GBytes *const *ptr_b = b; diff --git a/src/libnm-glib-aux/nm-hash-utils.h b/src/libnm-glib-aux/nm-hash-utils.h index e79fb894..d7de2de4 100644 --- a/src/libnm-glib-aux/nm-hash-utils.h +++ b/src/libnm-glib-aux/nm-hash-utils.h @@ -122,138 +122,26 @@ nm_hash_update_bool(NMHashState *state, bool val) nm_hash_update(state, &val, sizeof(val)); } -#define _NM_HASH_COMBINE_BOOLS_x_1(t, y) ((y) ? ((t) (1ull << 0)) : ((t) 0ull)) -#define _NM_HASH_COMBINE_BOOLS_x_2(t, y, ...) \ - ((y) ? ((t) (1ull << 1)) : ((t) 0ull)) | _NM_HASH_COMBINE_BOOLS_x_1(t, __VA_ARGS__) -#define _NM_HASH_COMBINE_BOOLS_x_3(t, y, ...) \ - ((y) ? ((t) (1ull << 2)) : ((t) 0ull)) | _NM_HASH_COMBINE_BOOLS_x_2(t, __VA_ARGS__) -#define _NM_HASH_COMBINE_BOOLS_x_4(t, y, ...) \ - ((y) ? ((t) (1ull << 3)) : ((t) 0ull)) | _NM_HASH_COMBINE_BOOLS_x_3(t, __VA_ARGS__) -#define _NM_HASH_COMBINE_BOOLS_x_5(t, y, ...) \ - ((y) ? ((t) (1ull << 4)) : ((t) 0ull)) | _NM_HASH_COMBINE_BOOLS_x_4(t, __VA_ARGS__) -#define _NM_HASH_COMBINE_BOOLS_x_6(t, y, ...) \ - ((y) ? ((t) (1ull << 5)) : ((t) 0ull)) | _NM_HASH_COMBINE_BOOLS_x_5(t, __VA_ARGS__) -#define _NM_HASH_COMBINE_BOOLS_x_7(t, y, ...) \ - ((y) ? ((t) (1ull << 6)) : ((t) 0ull)) | _NM_HASH_COMBINE_BOOLS_x_6(t, __VA_ARGS__) -#define _NM_HASH_COMBINE_BOOLS_x_8(t, y, ...) \ - ((y) ? ((t) (1ull << 7)) : ((t) 0ull)) | _NM_HASH_COMBINE_BOOLS_x_7(t, __VA_ARGS__) -#define _NM_HASH_COMBINE_BOOLS_x_9(t, y, ...) \ - ((y) ? ((t) (1ull << 8)) : ((t) 0ull)) \ - | (G_STATIC_ASSERT_EXPR(sizeof(t) >= 2), (_NM_HASH_COMBINE_BOOLS_x_8(t, __VA_ARGS__))) -#define _NM_HASH_COMBINE_BOOLS_x_10(t, y, ...) \ - ((y) ? ((t) (1ull << 9)) : ((t) 0ull)) | _NM_HASH_COMBINE_BOOLS_x_9(t, __VA_ARGS__) -#define _NM_HASH_COMBINE_BOOLS_x_11(t, y, ...) \ - ((y) ? ((t) (1ull << 10)) : ((t) 0ull)) | _NM_HASH_COMBINE_BOOLS_x_10(t, __VA_ARGS__) -#define _NM_HASH_COMBINE_BOOLS_n2(t, n, ...) _NM_HASH_COMBINE_BOOLS_x_##n(t, __VA_ARGS__) -#define _NM_HASH_COMBINE_BOOLS_n(t, n, ...) _NM_HASH_COMBINE_BOOLS_n2(t, n, __VA_ARGS__) - -#define NM_HASH_COMBINE_BOOLS(type, ...) \ - ((type) (_NM_HASH_COMBINE_BOOLS_n(type, NM_NARG(__VA_ARGS__), __VA_ARGS__))) +#define _NM_HASH_COMBINE_BOOLS_OP(x, n) ((x) ? NM_BIT((n)) : 0u) + +#define NM_HASH_COMBINE_BOOLS(type, ...) \ + ((type) (NM_STATIC_ASSERT_EXPR_1(NM_NARG(__VA_ARGS__) <= 8 * sizeof(type)) \ + ? (NM_VA_ARGS_FOREACH(, , |, _NM_HASH_COMBINE_BOOLS_OP, __VA_ARGS__)) \ + : 0)) #define nm_hash_update_bools(state, ...) \ nm_hash_update_val(state, NM_HASH_COMBINE_BOOLS(guint8, __VA_ARGS__)) -#define _NM_HASH_COMBINE_VALS_typ_x_1(y) typeof(y) _v1; -#define _NM_HASH_COMBINE_VALS_typ_x_2(y, ...) \ - typeof(y) _v2; \ - _NM_HASH_COMBINE_VALS_typ_x_1(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_x_3(y, ...) \ - typeof(y) _v3; \ - _NM_HASH_COMBINE_VALS_typ_x_2(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_x_4(y, ...) \ - typeof(y) _v4; \ - _NM_HASH_COMBINE_VALS_typ_x_3(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_x_5(y, ...) \ - typeof(y) _v5; \ - _NM_HASH_COMBINE_VALS_typ_x_4(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_x_6(y, ...) \ - typeof(y) _v6; \ - _NM_HASH_COMBINE_VALS_typ_x_5(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_x_7(y, ...) \ - typeof(y) _v7; \ - _NM_HASH_COMBINE_VALS_typ_x_6(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_x_8(y, ...) \ - typeof(y) _v8; \ - _NM_HASH_COMBINE_VALS_typ_x_7(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_x_9(y, ...) \ - typeof(y) _v9; \ - _NM_HASH_COMBINE_VALS_typ_x_8(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_x_10(y, ...) \ - typeof(y) _v10; \ - _NM_HASH_COMBINE_VALS_typ_x_9(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_x_11(y, ...) \ - typeof(y) _v11; \ - _NM_HASH_COMBINE_VALS_typ_x_10(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_x_12(y, ...) \ - typeof(y) _v12; \ - _NM_HASH_COMBINE_VALS_typ_x_11(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_x_13(y, ...) \ - typeof(y) _v13; \ - _NM_HASH_COMBINE_VALS_typ_x_12(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_x_14(y, ...) \ - typeof(y) _v14; \ - _NM_HASH_COMBINE_VALS_typ_x_13(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_x_15(y, ...) \ - typeof(y) _v15; \ - _NM_HASH_COMBINE_VALS_typ_x_14(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_x_16(y, ...) \ - typeof(y) _v16; \ - _NM_HASH_COMBINE_VALS_typ_x_15(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_x_17(y, ...) \ - typeof(y) _v17; \ - _NM_HASH_COMBINE_VALS_typ_x_16(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_x_18(y, ...) \ - typeof(y) _v18; \ - _NM_HASH_COMBINE_VALS_typ_x_17(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_x_19(y, ...) \ - typeof(y) _v19; \ - _NM_HASH_COMBINE_VALS_typ_x_18(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_x_20(y, ...) \ - typeof(y) _v20; \ - _NM_HASH_COMBINE_VALS_typ_x_19(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_n2(n, ...) _NM_HASH_COMBINE_VALS_typ_x_##n(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_typ_n(n, ...) _NM_HASH_COMBINE_VALS_typ_n2(n, __VA_ARGS__) - -#define _NM_HASH_COMBINE_VALS_val_x_1(y) ._v1 = (y), -#define _NM_HASH_COMBINE_VALS_val_x_2(y, ...) ._v2 = (y), _NM_HASH_COMBINE_VALS_val_x_1(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_x_3(y, ...) ._v3 = (y), _NM_HASH_COMBINE_VALS_val_x_2(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_x_4(y, ...) ._v4 = (y), _NM_HASH_COMBINE_VALS_val_x_3(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_x_5(y, ...) ._v5 = (y), _NM_HASH_COMBINE_VALS_val_x_4(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_x_6(y, ...) ._v6 = (y), _NM_HASH_COMBINE_VALS_val_x_5(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_x_7(y, ...) ._v7 = (y), _NM_HASH_COMBINE_VALS_val_x_6(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_x_8(y, ...) ._v8 = (y), _NM_HASH_COMBINE_VALS_val_x_7(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_x_9(y, ...) ._v9 = (y), _NM_HASH_COMBINE_VALS_val_x_8(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_x_10(y, ...) \ - ._v10 = (y), _NM_HASH_COMBINE_VALS_val_x_9(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_x_11(y, ...) \ - ._v11 = (y), _NM_HASH_COMBINE_VALS_val_x_10(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_x_12(y, ...) \ - ._v12 = (y), _NM_HASH_COMBINE_VALS_val_x_11(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_x_13(y, ...) \ - ._v13 = (y), _NM_HASH_COMBINE_VALS_val_x_12(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_x_14(y, ...) \ - ._v14 = (y), _NM_HASH_COMBINE_VALS_val_x_13(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_x_15(y, ...) \ - ._v15 = (y), _NM_HASH_COMBINE_VALS_val_x_14(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_x_16(y, ...) \ - ._v16 = (y), _NM_HASH_COMBINE_VALS_val_x_15(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_x_17(y, ...) \ - ._v17 = (y), _NM_HASH_COMBINE_VALS_val_x_16(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_x_18(y, ...) \ - ._v18 = (y), _NM_HASH_COMBINE_VALS_val_x_17(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_x_19(y, ...) \ - ._v19 = (y), _NM_HASH_COMBINE_VALS_val_x_18(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_x_20(y, ...) \ - ._v20 = (y), _NM_HASH_COMBINE_VALS_val_x_19(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_n2(n, ...) _NM_HASH_COMBINE_VALS_val_x_##n(__VA_ARGS__) -#define _NM_HASH_COMBINE_VALS_val_n(n, ...) _NM_HASH_COMBINE_VALS_val_n2(n, __VA_ARGS__) +#define _NM_HASH_COMBINE_VALS_TYPE_OP(x, idx) typeof(x) _v##idx; +#define _NM_HASH_COMBINE_VALS_INIT_OP(x, idx) ._v##idx = (x), /* NM_HASH_COMBINE_VALS() is faster then nm_hash_update_val() as it combines multiple * calls to nm_hash_update() using a packed structure. */ -#define NM_HASH_COMBINE_VALS(var, ...) \ - const struct _nm_packed { \ - _NM_HASH_COMBINE_VALS_typ_n(NM_NARG(__VA_ARGS__), __VA_ARGS__) \ - } var _nm_alignas(guint64) = {_NM_HASH_COMBINE_VALS_val_n(NM_NARG(__VA_ARGS__), __VA_ARGS__)} +#define NM_HASH_COMBINE_VALS(var, ...) \ + const struct _nm_packed { \ + NM_VA_ARGS_FOREACH(, , , _NM_HASH_COMBINE_VALS_TYPE_OP, __VA_ARGS__) \ + } var _nm_alignas(guint64) = { \ + NM_VA_ARGS_FOREACH(, , , _NM_HASH_COMBINE_VALS_INIT_OP, __VA_ARGS__)} /* nm_hash_update_vals() is faster then nm_hash_update_val() as it combines multiple * calls to nm_hash_update() using a packed structure. */ @@ -301,15 +189,15 @@ nm_hash_update_str(NMHashState *state, const char *str) } #if _NM_CC_SUPPORT_GENERIC - /* Like nm_hash_update_str(), but restricted to arrays only. nm_hash_update_str() only works +/* Like nm_hash_update_str(), but restricted to arrays only. nm_hash_update_str() only works * with a @str argument that cannot be NULL. If you have a string pointer, that is never NULL, use * nm_hash_update() instead. */ - #define nm_hash_update_strarr(state, str) \ - (_Generic(&(str), const char(*)[sizeof(str)] \ - : nm_hash_update_str((state), (str)), char(*)[sizeof(str)] \ - : nm_hash_update_str((state), (str)))) +#define nm_hash_update_strarr(state, str) \ + (_Generic(&(str), const char(*)[sizeof(str)] \ + : nm_hash_update_str((state), (str)), char(*)[sizeof(str)] \ + : nm_hash_update_str((state), (str)))) #else - #define nm_hash_update_strarr(state, str) nm_hash_update_str((state), (str)) +#define nm_hash_update_strarr(state, str) nm_hash_update_str((state), (str)) #endif guint nm_hash_ptr(gconstpointer ptr); @@ -379,11 +267,11 @@ gboolean nm_ppdirect_equal(gconstpointer a, gconstpointer b); /*****************************************************************************/ -guint nm_gbytes_hash(gconstpointer p); -#define nm_gbytes_equal g_bytes_equal +guint nm_g_bytes_hash(gconstpointer p); +#define nm_g_bytes_equal g_bytes_equal -guint nm_pgbytes_hash(gconstpointer p); -gboolean nm_pgbytes_equal(gconstpointer a, gconstpointer b); +guint nm_pg_bytes_hash(gconstpointer p); +gboolean nm_pg_bytes_equal(gconstpointer a, gconstpointer b); /*****************************************************************************/ diff --git a/src/libnm-glib-aux/nm-io-utils.c b/src/libnm-glib-aux/nm-io-utils.c index 87478a2d..85a81f69 100644 --- a/src/libnm-glib-aux/nm-io-utils.c +++ b/src/libnm-glib-aux/nm-io-utils.c @@ -7,9 +7,11 @@ #include "nm-io-utils.h" -#include -#include #include +#include +#include +#include +#include #include "nm-str-buf.h" #include "nm-shared-utils.h" @@ -628,3 +630,96 @@ next:; g_ptr_array_add(arr, NULL); return (char **) g_ptr_array_free(arr, FALSE); } + +/*****************************************************************************/ + +/* taken from systemd's sockaddr_un_set_path(). */ +int +nm_io_sockaddr_un_set(struct sockaddr_un *ret, NMOptionBool is_abstract, const char *path) +{ + gsize l; + + g_return_val_if_fail(ret, -EINVAL); + g_return_val_if_fail(path, -EINVAL); + nm_assert_is_ternary(is_abstract); + + if (is_abstract == NM_OPTION_BOOL_DEFAULT) + is_abstract = nm_io_sockaddr_un_path_is_abstract(path, &path); + + l = strlen(path); + if (l < 1) + return -EINVAL; + if (l > sizeof(ret->sun_path) - 1) + return -EINVAL; + + if (!is_abstract) { + if (path[0] != '/') { + /* non-abstract paths must be absolute. */ + return -EINVAL; + } + } + + memset(ret, 0, nm_offsetof(struct sockaddr_un, sun_path)); + ret->sun_family = AF_UNIX; + + if (is_abstract) { + ret->sun_path[0] = '\0'; + memcpy(&ret->sun_path[1], path, NM_MIN(l + 1, sizeof(ret->sun_path) - 1)); + } else + memcpy(&ret->sun_path, path, l + 1); + + /* For pathname addresses, we return the size with the trailing NUL. + * For abstract addresses, we return the size without the trailing NUL + * (which may not be even written). But as abstract sockets also have + * a NUL at the beginning of sun_path, the total length is always + * calculated the same. */ + return (nm_offsetof(struct sockaddr_un, sun_path) + 1) + l; +} + +/*****************************************************************************/ + +/* taken from systemd's sd_notify(). */ +int +nm_sd_notify(const char *state) +{ + struct sockaddr_un sockaddr; + struct iovec iovec; + struct msghdr msghdr = { + .msg_iov = &iovec, + .msg_iovlen = 1, + .msg_name = &sockaddr, + }; + nm_auto_close int fd = -1; + const char * e; + int r; + + if (!state) + g_return_val_if_reached(-EINVAL); + + e = getenv("NOTIFY_SOCKET"); + if (!e) + return 0; + + r = nm_io_sockaddr_un_set(&sockaddr, NM_OPTION_BOOL_DEFAULT, e); + if (r < 0) + return r; + msghdr.msg_namelen = r; + + fd = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0); + if (fd < 0) + return -NM_ERRNO_NATIVE(errno); + + /* systemd calls here fd_set_sndbuf(fd, SNDBUF_SIZE) .We don't bother. */ + + iovec = (struct iovec){ + .iov_base = (gpointer) state, + .iov_len = strlen(state), + }; + + /* systemd sends ucred, if geteuid()/getegid() does not match getuid()/getgid(). We don't bother. */ + + if (sendmsg(fd, &msghdr, MSG_NOSIGNAL) < 0) + return -NM_ERRNO_NATIVE(errno); + + return 0; +} diff --git a/src/libnm-glib-aux/nm-io-utils.h b/src/libnm-glib-aux/nm-io-utils.h index 31ff6d05..479d0e51 100644 --- a/src/libnm-glib-aux/nm-io-utils.h +++ b/src/libnm-glib-aux/nm-io-utils.h @@ -60,4 +60,21 @@ void nm_g_subprocess_terminate_in_background(GSubprocess *subprocess, int timeou char **nm_utils_find_mkstemp_files(const char *dirname, const char *filename); +static inline gboolean +nm_io_sockaddr_un_path_is_abstract(const char *path, const char **out_path) +{ + if (path && path[0] == '@') { + NM_SET_OUT(out_path, &path[1]); + return TRUE; + } + NM_SET_OUT(out_path, path); + return FALSE; +} + +struct sockaddr_un; + +int nm_io_sockaddr_un_set(struct sockaddr_un *ret, NMOptionBool is_abstract, const char *path); + +int nm_sd_notify(const char *state); + #endif /* __NM_IO_UTILS_H__ */ diff --git a/src/libnm-glib-aux/nm-jansson.h b/src/libnm-glib-aux/nm-jansson.h index 6173a7ac..a907d2bb 100644 --- a/src/libnm-glib-aux/nm-jansson.h +++ b/src/libnm-glib-aux/nm-jansson.h @@ -10,20 +10,20 @@ #if WITH_JANSSON - #include - - /* Added in Jansson v2.8 */ - #ifndef json_object_foreach_safe - #define json_object_foreach_safe(object, n, key, value) \ - for (key = json_object_iter_key(json_object_iter(object)), \ - n = json_object_iter_next(object, json_object_key_to_iter(key)); \ - key && (value = json_object_iter_value(json_object_key_to_iter(key))); \ - key = json_object_iter_key(n), \ - n = json_object_iter_next(object, json_object_key_to_iter(key))) - #endif +#include + +/* Added in Jansson v2.8 */ +#ifndef json_object_foreach_safe +#define json_object_foreach_safe(object, n, key, value) \ + for (key = json_object_iter_key(json_object_iter(object)), \ + n = json_object_iter_next(object, json_object_key_to_iter(key)); \ + key && (value = json_object_iter_value(json_object_key_to_iter(key))); \ + key = json_object_iter_key(n), \ + n = json_object_iter_next(object, json_object_key_to_iter(key))) +#endif NM_AUTO_DEFINE_FCN0(json_t *, _nm_auto_decref_json, json_decref); - #define nm_auto_decref_json nm_auto(_nm_auto_decref_json) +#define nm_auto_decref_json nm_auto(_nm_auto_decref_json) #endif /* WITH_JANSON */ diff --git a/src/libnm-glib-aux/nm-json-aux.c b/src/libnm-glib-aux/nm-json-aux.c index dc67d6d5..0a3b25f8 100644 --- a/src/libnm-glib-aux/nm-json-aux.c +++ b/src/libnm-glib-aux/nm-json-aux.c @@ -16,7 +16,7 @@ * program). But that needs to be fixed by the json libraries, and it is by adding * symbol versioning in recent versions. */ #ifndef RTLD_DEEPBIND - #define RTLD_DEEPBIND 0 +#define RTLD_DEEPBIND 0 #endif /*****************************************************************************/ @@ -174,7 +174,7 @@ _nm_json_vt_internal_load(void) #elif !WITH_JANSSON && !defined(JANSSON_SONAME) soname = NULL; #else - #error "WITH_JANSON and JANSSON_SONAME are defined inconsistently." +#error "WITH_JANSON and JANSSON_SONAME are defined inconsistently." #endif if (!soname) diff --git a/src/libnm-glib-aux/nm-json-aux.h b/src/libnm-glib-aux/nm-json-aux.h index 936e9146..088d67a9 100644 --- a/src/libnm-glib-aux/nm-json-aux.h +++ b/src/libnm-glib-aux/nm-json-aux.h @@ -270,6 +270,49 @@ nm_jansson_json_as_int64(const NMJsonVt *vt, const nm_json_t *elem, gint64 *out_ return 1; } +static inline int +nm_jansson_json_as_uint32(const NMJsonVt *vt, const nm_json_t *elem, guint32 *out_val) +{ + nm_json_int_t v; + + if (!elem) + return 0; + + if (!nm_json_is_integer(elem)) + return -EINVAL; + + v = vt->nm_json_integer_value(elem); + if (v < 0) + return -ERANGE; + if (v > (guint64) G_MAXUINT32) + return -ERANGE; + + NM_SET_OUT(out_val, v); + return 1; +} + +static inline int +nm_jansson_json_as_uint(const NMJsonVt *vt, const nm_json_t *elem, guint *out_val) +{ + nm_json_int_t v; + + if (!elem) + return 0; + + if (!nm_json_is_integer(elem)) + return -EINVAL; + + v = vt->nm_json_integer_value(elem); + if (v < 0) + return -ERANGE; + + if (v > (guint64) G_MAXUINT) + return -ERANGE; + + NM_SET_OUT(out_val, v); + return 1; +} + static inline int nm_jansson_json_as_uint64(const NMJsonVt *vt, const nm_json_t *elem, guint64 *out_val) { @@ -328,17 +371,27 @@ nm_value_type_to_json(NMValueType value_type, GString *gstr, gconstpointer p_fie nm_json_gstr_append_int64(gstr, *((const gint32 *) p_field)); return; case NM_VALUE_TYPE_INT: + case NM_VALUE_TYPE_ENUM: nm_json_gstr_append_int64(gstr, *((const int *) p_field)); return; case NM_VALUE_TYPE_INT64: nm_json_gstr_append_int64(gstr, *((const gint64 *) p_field)); return; + case NM_VALUE_TYPE_UINT32: + nm_json_gstr_append_uint64(gstr, *((const guint32 *) p_field)); + return; + case NM_VALUE_TYPE_UINT: + case NM_VALUE_TYPE_FLAGS: + nm_json_gstr_append_uint64(gstr, *((const guint *) p_field)); + return; case NM_VALUE_TYPE_UINT64: nm_json_gstr_append_uint64(gstr, *((const guint64 *) p_field)); return; case NM_VALUE_TYPE_STRING: nm_json_gstr_append_string(gstr, *((const char *const *) p_field)); return; + case NM_VALUE_TYPE_BYTES: + case NM_VALUE_TYPE_NONE: case NM_VALUE_TYPE_UNSPEC: break; } @@ -357,9 +410,15 @@ nm_value_type_from_json(const NMJsonVt * vt, case NM_VALUE_TYPE_INT32: return (nm_jansson_json_as_int32(vt, elem, out_val) > 0); case NM_VALUE_TYPE_INT: + case NM_VALUE_TYPE_ENUM: return (nm_jansson_json_as_int(vt, elem, out_val) > 0); case NM_VALUE_TYPE_INT64: return (nm_jansson_json_as_int64(vt, elem, out_val) > 0); + case NM_VALUE_TYPE_UINT32: + return (nm_jansson_json_as_uint32(vt, elem, out_val) > 0); + case NM_VALUE_TYPE_UINT: + case NM_VALUE_TYPE_FLAGS: + return (nm_jansson_json_as_uint(vt, elem, out_val) > 0); case NM_VALUE_TYPE_UINT64: return (nm_jansson_json_as_uint64(vt, elem, out_val) > 0); @@ -368,6 +427,8 @@ nm_value_type_from_json(const NMJsonVt * vt, case NM_VALUE_TYPE_STRING: return (nm_jansson_json_as_string(vt, elem, out_val) > 0); + case NM_VALUE_TYPE_BYTES: + case NM_VALUE_TYPE_NONE: case NM_VALUE_TYPE_UNSPEC: break; } diff --git a/src/libnm-glib-aux/nm-logging-base.c b/src/libnm-glib-aux/nm-logging-base.c index e11bd9f3..cc19ef15 100644 --- a/src/libnm-glib-aux/nm-logging-base.c +++ b/src/libnm-glib-aux/nm-logging-base.c @@ -6,6 +6,8 @@ #include +#include "nm-time-utils.h" + /*****************************************************************************/ const LogLevelDesc nm_log_level_desc[_LOGL_N] = { @@ -77,3 +79,61 @@ _nm_log_parse_level(const char *level, NMLogLevel *out_level) return FALSE; } + +/*****************************************************************************/ + +volatile NMLogLevel _nm_logging_enabled_value = LOGL_TRACE; + +void +_nm_logging_enabled_init(const char *level_str) +{ + NMLogLevel level; + + if (!_nm_log_parse_level(level_str, &level)) + level = LOGL_WARN; + else if (level == _LOGL_KEEP) + level = LOGL_WARN; + + _nm_logging_enabled_value = level; +} + +/*****************************************************************************/ + +void +_nm_log_simple_printf(NMLogLevel level, const char *fmt, ...) +{ + gs_free char *msg_heap = NULL; + char msg_stack[700]; + const char * msg; + const char * level_str; + gint64 ts; + + ts = nm_utils_clock_gettime_nsec(CLOCK_BOOTTIME); + + msg = nm_vsprintf_buf_or_alloc(fmt, fmt, msg_stack, &msg_heap, NULL); + + switch (level) { + case LOGL_TRACE: + level_str = ""; + break; + case LOGL_DEBUG: + level_str = ""; + break; + case LOGL_INFO: + level_str = " "; + break; + case LOGL_WARN: + level_str = " "; + break; + default: + nm_assert(level == LOGL_ERR); + level_str = ""; + break; + } + + g_print("[%" G_GINT64_FORMAT ".%05" G_GINT64_FORMAT "] %s %s\n", + ts / NM_UTILS_NSEC_PER_SEC, + (ts / (NM_UTILS_NSEC_PER_SEC / 10000)) % 10000, + level_str, + msg); +} diff --git a/src/libnm-glib-aux/nm-logging-base.h b/src/libnm-glib-aux/nm-logging-base.h index 136f0c04..3d76b378 100644 --- a/src/libnm-glib-aux/nm-logging-base.h +++ b/src/libnm-glib-aux/nm-logging-base.h @@ -25,4 +25,20 @@ extern const LogLevelDesc nm_log_level_desc[_LOGL_N]; gboolean _nm_log_parse_level(const char *level, NMLogLevel *out_level); +/*****************************************************************************/ + +extern volatile NMLogLevel _nm_logging_enabled_value; + +static inline gboolean +_nm_logging_enabled(NMLogLevel level) +{ + return level >= _nm_logging_enabled_value; +} + +void _nm_logging_enabled_init(const char *level_str); + +/*****************************************************************************/ + +void _nm_log_simple_printf(NMLogLevel level, const char *fmt, ...) _nm_printf(2, 3); + #endif /* __NM_LOGGING_BASE_H__ */ diff --git a/src/libnm-glib-aux/nm-logging-fwd.h b/src/libnm-glib-aux/nm-logging-fwd.h index 0ede91b2..3e999c4a 100644 --- a/src/libnm-glib-aux/nm-logging-fwd.h +++ b/src/libnm-glib-aux/nm-logging-fwd.h @@ -182,28 +182,28 @@ extern void _nm_utils_monotonic_timestamp_initialized(const struct timespec *tp, /* _LOGT() and _LOGt() both log with level TRACE, but the latter is disabled by default, * unless building with --with-more-logging. */ #if NM_MORE_LOGGING - #define _LOGt_ENABLED(...) _NMLOG_ENABLED(_LOGL_TRACE, ##__VA_ARGS__) - #define _LOGt(...) _NMLOG(_LOGL_TRACE, __VA_ARGS__) - #define _LOGt_err(errsv, ...) _NMLOG_err(errsv, _LOGL_TRACE, __VA_ARGS__) +#define _LOGt_ENABLED(...) _NMLOG_ENABLED(_LOGL_TRACE, ##__VA_ARGS__) +#define _LOGt(...) _NMLOG(_LOGL_TRACE, __VA_ARGS__) +#define _LOGt_err(errsv, ...) _NMLOG_err(errsv, _LOGL_TRACE, __VA_ARGS__) #else - /* still call the logging macros to get compile time checks, but they will be optimized out. */ - #define _LOGt_ENABLED(...) (FALSE && (_NMLOG_ENABLED(_LOGL_TRACE, ##__VA_ARGS__))) - #define _LOGt(...) \ - G_STMT_START \ - { \ - if (FALSE) { \ - _NMLOG(_LOGL_TRACE, __VA_ARGS__); \ - } \ - } \ - G_STMT_END - #define _LOGt_err(errsv, ...) \ - G_STMT_START \ - { \ - if (FALSE) { \ - _NMLOG_err(errsv, _LOGL_TRACE, __VA_ARGS__); \ - } \ - } \ - G_STMT_END +/* still call the logging macros to get compile time checks, but they will be optimized out. */ +#define _LOGt_ENABLED(...) (FALSE && (_NMLOG_ENABLED(_LOGL_TRACE, ##__VA_ARGS__))) +#define _LOGt(...) \ + G_STMT_START \ + { \ + if (FALSE) { \ + _NMLOG(_LOGL_TRACE, __VA_ARGS__); \ + } \ + } \ + G_STMT_END +#define _LOGt_err(errsv, ...) \ + G_STMT_START \ + { \ + if (FALSE) { \ + _NMLOG_err(errsv, _LOGL_TRACE, __VA_ARGS__); \ + } \ + } \ + G_STMT_END #endif /*****************************************************************************/ @@ -236,28 +236,28 @@ extern void _nm_utils_monotonic_timestamp_initialized(const struct timespec *tp, #define _LOG2E_err(errsv, ...) _NMLOG2_err(errsv, _LOGL_ERR, __VA_ARGS__) #if NM_MORE_LOGGING - #define _LOG2t_ENABLED(...) _NMLOG2_ENABLED(_LOGL_TRACE, ##__VA_ARGS__) - #define _LOG2t(...) _NMLOG2(_LOGL_TRACE, __VA_ARGS__) - #define _LOG2t_err(errsv, ...) _NMLOG2_err(errsv, _LOGL_TRACE, __VA_ARGS__) +#define _LOG2t_ENABLED(...) _NMLOG2_ENABLED(_LOGL_TRACE, ##__VA_ARGS__) +#define _LOG2t(...) _NMLOG2(_LOGL_TRACE, __VA_ARGS__) +#define _LOG2t_err(errsv, ...) _NMLOG2_err(errsv, _LOGL_TRACE, __VA_ARGS__) #else - /* still call the logging macros to get compile time checks, but they will be optimized out. */ - #define _LOG2t_ENABLED(...) (FALSE && (_NMLOG2_ENABLED(_LOGL_TRACE, ##__VA_ARGS__))) - #define _LOG2t(...) \ - G_STMT_START \ - { \ - if (FALSE) { \ - _NMLOG2(_LOGL_TRACE, __VA_ARGS__); \ - } \ - } \ - G_STMT_END - #define _LOG2t_err(errsv, ...) \ - G_STMT_START \ - { \ - if (FALSE) { \ - _NMLOG2_err(errsv, _LOGL_TRACE, __VA_ARGS__); \ - } \ - } \ - G_STMT_END +/* still call the logging macros to get compile time checks, but they will be optimized out. */ +#define _LOG2t_ENABLED(...) (FALSE && (_NMLOG2_ENABLED(_LOGL_TRACE, ##__VA_ARGS__))) +#define _LOG2t(...) \ + G_STMT_START \ + { \ + if (FALSE) { \ + _NMLOG2(_LOGL_TRACE, __VA_ARGS__); \ + } \ + } \ + G_STMT_END +#define _LOG2t_err(errsv, ...) \ + G_STMT_START \ + { \ + if (FALSE) { \ + _NMLOG2_err(errsv, _LOGL_TRACE, __VA_ARGS__); \ + } \ + } \ + G_STMT_END #endif #define _NMLOG3_ENABLED(level) (nm_logging_enabled((level), (_NMLOG3_DOMAIN))) @@ -281,28 +281,28 @@ extern void _nm_utils_monotonic_timestamp_initialized(const struct timespec *tp, #define _LOG3E_err(errsv, ...) _NMLOG3_err(errsv, _LOGL_ERR, __VA_ARGS__) #if NM_MORE_LOGGING - #define _LOG3t_ENABLED(...) _NMLOG3_ENABLED(_LOGL_TRACE, ##__VA_ARGS__) - #define _LOG3t(...) _NMLOG3(_LOGL_TRACE, __VA_ARGS__) - #define _LOG3t_err(errsv, ...) _NMLOG3_err(errsv, _LOGL_TRACE, __VA_ARGS__) +#define _LOG3t_ENABLED(...) _NMLOG3_ENABLED(_LOGL_TRACE, ##__VA_ARGS__) +#define _LOG3t(...) _NMLOG3(_LOGL_TRACE, __VA_ARGS__) +#define _LOG3t_err(errsv, ...) _NMLOG3_err(errsv, _LOGL_TRACE, __VA_ARGS__) #else - /* still call the logging macros to get compile time checks, but they will be optimized out. */ - #define _LOG3t_ENABLED(...) (FALSE && (_NMLOG3_ENABLED(_LOGL_TRACE, ##__VA_ARGS__))) - #define _LOG3t(...) \ - G_STMT_START \ - { \ - if (FALSE) { \ - _NMLOG3(_LOGL_TRACE, __VA_ARGS__); \ - } \ - } \ - G_STMT_END - #define _LOG3t_err(errsv, ...) \ - G_STMT_START \ - { \ - if (FALSE) { \ - _NMLOG3_err(errsv, _LOGL_TRACE, __VA_ARGS__); \ - } \ - } \ - G_STMT_END +/* still call the logging macros to get compile time checks, but they will be optimized out. */ +#define _LOG3t_ENABLED(...) (FALSE && (_NMLOG3_ENABLED(_LOGL_TRACE, ##__VA_ARGS__))) +#define _LOG3t(...) \ + G_STMT_START \ + { \ + if (FALSE) { \ + _NMLOG3(_LOGL_TRACE, __VA_ARGS__); \ + } \ + } \ + G_STMT_END +#define _LOG3t_err(errsv, ...) \ + G_STMT_START \ + { \ + if (FALSE) { \ + _NMLOG3_err(errsv, _LOGL_TRACE, __VA_ARGS__); \ + } \ + } \ + G_STMT_END #endif /*****************************************************************************/ diff --git a/src/libnm-glib-aux/nm-macros-internal.h b/src/libnm-glib-aux/nm-macros-internal.h index f2d81e1c..e7ee7f38 100644 --- a/src/libnm-glib-aux/nm-macros-internal.h +++ b/src/libnm-glib-aux/nm-macros-internal.h @@ -13,6 +13,7 @@ #include #include +#include /*****************************************************************************/ @@ -42,10 +43,6 @@ /*****************************************************************************/ -#define nm_offsetofend(t, m) (G_STRUCT_OFFSET(t, m) + sizeof(((t *) NULL)->m)) - -/*****************************************************************************/ - #define gs_free nm_auto_g_free #define gs_unref_object nm_auto_unref_object #define gs_unref_variant nm_auto_unref_variant @@ -155,280 +152,6 @@ _nm_auto_freev(gpointer ptr) /*****************************************************************************/ -#define _NM_MACRO_SELECT_ARG_64(_1, \ - _2, \ - _3, \ - _4, \ - _5, \ - _6, \ - _7, \ - _8, \ - _9, \ - _10, \ - _11, \ - _12, \ - _13, \ - _14, \ - _15, \ - _16, \ - _17, \ - _18, \ - _19, \ - _20, \ - _21, \ - _22, \ - _23, \ - _24, \ - _25, \ - _26, \ - _27, \ - _28, \ - _29, \ - _30, \ - _31, \ - _32, \ - _33, \ - _34, \ - _35, \ - _36, \ - _37, \ - _38, \ - _39, \ - _40, \ - _41, \ - _42, \ - _43, \ - _44, \ - _45, \ - _46, \ - _47, \ - _48, \ - _49, \ - _50, \ - _51, \ - _52, \ - _53, \ - _54, \ - _55, \ - _56, \ - _57, \ - _58, \ - _59, \ - _60, \ - _61, \ - _62, \ - _63, \ - N, \ - ...) \ - N - -/* http://stackoverflow.com/a/2124385/354393 - * https://stackoverflow.com/questions/11317474/macro-to-count-number-of-arguments - */ - -#define NM_NARG(...) \ - _NM_MACRO_SELECT_ARG_64(, \ - ##__VA_ARGS__, \ - 62, \ - 61, \ - 60, \ - 59, \ - 58, \ - 57, \ - 56, \ - 55, \ - 54, \ - 53, \ - 52, \ - 51, \ - 50, \ - 49, \ - 48, \ - 47, \ - 46, \ - 45, \ - 44, \ - 43, \ - 42, \ - 41, \ - 40, \ - 39, \ - 38, \ - 37, \ - 36, \ - 35, \ - 34, \ - 33, \ - 32, \ - 31, \ - 30, \ - 29, \ - 28, \ - 27, \ - 26, \ - 25, \ - 24, \ - 23, \ - 22, \ - 21, \ - 20, \ - 19, \ - 18, \ - 17, \ - 16, \ - 15, \ - 14, \ - 13, \ - 12, \ - 11, \ - 10, \ - 9, \ - 8, \ - 7, \ - 6, \ - 5, \ - 4, \ - 3, \ - 2, \ - 1, \ - 0) -#define NM_NARG_MAX1(...) \ - _NM_MACRO_SELECT_ARG_64(, \ - ##__VA_ARGS__, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 1, \ - 0) -#define NM_NARG_MAX2(...) \ - _NM_MACRO_SELECT_ARG_64(, \ - ##__VA_ARGS__, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 2, \ - 1, \ - 0) - -#define _NM_MACRO_CALL(macro, ...) macro(__VA_ARGS__) - -/*****************************************************************************/ - #define _NM_MACRO_COMMA_IF_ARGS(...) \ _NM_MACRO_CALL(G_PASTE(__NM_MACRO_COMMA_IF_ARGS_, NM_NARG_MAX1(__VA_ARGS__)), __VA_ARGS__) #define __NM_MACRO_COMMA_IF_ARGS_0() @@ -449,9 +172,9 @@ _nm_auto_freev(gpointer ptr) /*****************************************************************************/ #if defined(__GNUC__) - #define _NM_PRAGMA_WARNING_DO(warning) G_STRINGIFY(GCC diagnostic ignored warning) +#define _NM_PRAGMA_WARNING_DO(warning) G_STRINGIFY(GCC diagnostic ignored warning) #elif defined(__clang__) - #define _NM_PRAGMA_WARNING_DO(warning) G_STRINGIFY(clang diagnostic ignored warning) +#define _NM_PRAGMA_WARNING_DO(warning) G_STRINGIFY(clang diagnostic ignored warning) #endif /* you can only suppress a specific warning that the compiler @@ -461,23 +184,22 @@ _nm_auto_freev(gpointer ptr) * same name for the same warning. */ #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) - #define NM_PRAGMA_WARNING_DISABLE(warning) \ - _Pragma("GCC diagnostic push") _Pragma(_NM_PRAGMA_WARNING_DO(warning)) +#define NM_PRAGMA_WARNING_DISABLE(warning) \ + _Pragma("GCC diagnostic push") _Pragma(_NM_PRAGMA_WARNING_DO(warning)) #elif defined(__clang__) - #define NM_PRAGMA_WARNING_DISABLE(warning) \ - _Pragma("clang diagnostic push") \ - _Pragma(_NM_PRAGMA_WARNING_DO("-Wunknown-warning-option")) \ - _Pragma(_NM_PRAGMA_WARNING_DO(warning)) +#define NM_PRAGMA_WARNING_DISABLE(warning) \ + _Pragma("clang diagnostic push") _Pragma(_NM_PRAGMA_WARNING_DO("-Wunknown-warning-option")) \ + _Pragma(_NM_PRAGMA_WARNING_DO(warning)) #else - #define NM_PRAGMA_WARNING_DISABLE(warning) +#define NM_PRAGMA_WARNING_DISABLE(warning) #endif #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) - #define NM_PRAGMA_WARNING_REENABLE _Pragma("GCC diagnostic pop") +#define NM_PRAGMA_WARNING_REENABLE _Pragma("GCC diagnostic pop") #elif defined(__clang__) - #define NM_PRAGMA_WARNING_REENABLE _Pragma("clang diagnostic pop") +#define NM_PRAGMA_WARNING_REENABLE _Pragma("clang diagnostic pop") #else - #define NM_PRAGMA_WARNING_REENABLE +#define NM_PRAGMA_WARNING_REENABLE #endif /*****************************************************************************/ @@ -502,37 +224,9 @@ NM_G_ERROR_MSG(GError *error) /*****************************************************************************/ -#ifndef _NM_CC_SUPPORT_AUTO_TYPE - #if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9))) - #define _NM_CC_SUPPORT_AUTO_TYPE 1 - #else - #define _NM_CC_SUPPORT_AUTO_TYPE 0 - #endif -#endif - -#ifndef _NM_CC_SUPPORT_GENERIC - /* In the meantime, NetworkManager requires C11 and _Generic() should always be available. - * However, shared/nm-utils may also be used in VPN/applet, which possibly did not yet - * bump the C standard requirement. Leave this for the moment, but eventually we can - * drop it. - * - * Technically, gcc 4.9 already has some support for _Generic(). But there seems - * to be issues with propagating "const char *[5]" to "const char **". Only assume - * we have _Generic() since gcc 5. */ - #if (defined(__GNUC__) && __GNUC__ >= 5) || (defined(__clang__)) - #define _NM_CC_SUPPORT_GENERIC 1 - #else - #define _NM_CC_SUPPORT_GENERIC 0 - #endif -#endif - -#if _NM_CC_SUPPORT_AUTO_TYPE - #define _nm_auto_type __auto_type -#endif - #if _NM_CC_SUPPORT_GENERIC - #define _NM_CONSTCAST_FULL_1(type, obj_expr, obj) \ - (_Generic ((obj_expr), \ +#define _NM_CONSTCAST_FULL_1(type, obj_expr, obj) \ + (_Generic ((obj_expr), \ const void *const: ((const type *) (obj)), \ const void * : ((const type *) (obj)), \ void *const: (( type *) (obj)), \ @@ -541,8 +235,8 @@ NM_G_ERROR_MSG(GError *error) const type * : ((const type *) (obj)), \ type *const: (( type *) (obj)), \ type * : (( type *) (obj)))) - #define _NM_CONSTCAST_FULL_2(type, obj_expr, obj, alias_type2) \ - (_Generic ((obj_expr), \ +#define _NM_CONSTCAST_FULL_2(type, obj_expr, obj, alias_type2) \ + (_Generic ((obj_expr), \ const void *const: ((const type *) (obj)), \ const void * : ((const type *) (obj)), \ void *const: (( type *) (obj)), \ @@ -555,8 +249,8 @@ NM_G_ERROR_MSG(GError *error) const type * : ((const type *) (obj)), \ type *const: (( type *) (obj)), \ type * : (( type *) (obj)))) - #define _NM_CONSTCAST_FULL_3(type, obj_expr, obj, alias_type2, alias_type3) \ - (_Generic ((obj_expr), \ +#define _NM_CONSTCAST_FULL_3(type, obj_expr, obj, alias_type2, alias_type3) \ + (_Generic ((obj_expr), \ const void *const: ((const type *) (obj)), \ const void * : ((const type *) (obj)), \ void *const: (( type *) (obj)), \ @@ -573,8 +267,8 @@ NM_G_ERROR_MSG(GError *error) const type * : ((const type *) (obj)), \ type *const: (( type *) (obj)), \ type * : (( type *) (obj)))) - #define _NM_CONSTCAST_FULL_4(type, obj_expr, obj, alias_type2, alias_type3, alias_type4) \ - (_Generic ((obj_expr), \ +#define _NM_CONSTCAST_FULL_4(type, obj_expr, obj, alias_type2, alias_type3, alias_type4) \ + (_Generic ((obj_expr), \ const void *const: ((const type *) (obj)), \ const void * : ((const type *) (obj)), \ void *const: (( type *) (obj)), \ @@ -595,34 +289,34 @@ NM_G_ERROR_MSG(GError *error) const type * : ((const type *) (obj)), \ type *const: (( type *) (obj)), \ type * : (( type *) (obj)))) - #define _NM_CONSTCAST_FULL_x(type, obj_expr, obj, n, ...) \ - (_NM_CONSTCAST_FULL_##n(type, obj_expr, obj, ##__VA_ARGS__)) - #define _NM_CONSTCAST_FULL_y(type, obj_expr, obj, n, ...) \ - (_NM_CONSTCAST_FULL_x(type, obj_expr, obj, n, ##__VA_ARGS__)) - #define NM_CONSTCAST_FULL(type, obj_expr, obj, ...) \ - (_NM_CONSTCAST_FULL_y(type, obj_expr, obj, NM_NARG(dummy, ##__VA_ARGS__), ##__VA_ARGS__)) +#define _NM_CONSTCAST_FULL_x(type, obj_expr, obj, n, ...) \ + (_NM_CONSTCAST_FULL_##n(type, obj_expr, obj, ##__VA_ARGS__)) +#define _NM_CONSTCAST_FULL_y(type, obj_expr, obj, n, ...) \ + (_NM_CONSTCAST_FULL_x(type, obj_expr, obj, n, ##__VA_ARGS__)) +#define NM_CONSTCAST_FULL(type, obj_expr, obj, ...) \ + (_NM_CONSTCAST_FULL_y(type, obj_expr, obj, NM_NARG(dummy, ##__VA_ARGS__), ##__VA_ARGS__)) #else - #define NM_CONSTCAST_FULL(type, obj_expr, obj, ...) ((type *) (obj)) +#define NM_CONSTCAST_FULL(type, obj_expr, obj, ...) ((type *) (obj)) #endif #define NM_CONSTCAST(type, obj, ...) NM_CONSTCAST_FULL(type, (obj), (obj), ##__VA_ARGS__) #if _NM_CC_SUPPORT_GENERIC - #define NM_UNCONST_PTR(type, arg) \ - _Generic((arg), const type * : ((type *) (arg)), type * : ((type *) (arg))) +#define NM_UNCONST_PTR(type, arg) \ + _Generic((arg), const type * : ((type *) (arg)), type * : ((type *) (arg))) #else - #define NM_UNCONST_PTR(type, arg) ((type *) (arg)) +#define NM_UNCONST_PTR(type, arg) ((type *) (arg)) #endif #if _NM_CC_SUPPORT_GENERIC - #define NM_UNCONST_PPTR(type, arg) \ - _Generic ((arg), \ +#define NM_UNCONST_PPTR(type, arg) \ + _Generic ((arg), \ const type * *: ((type **) (arg)), \ type * *: ((type **) (arg)), \ const type *const*: ((type **) (arg)), \ type *const*: ((type **) (arg))) #else - #define NM_UNCONST_PPTR(type, arg) ((type **) (arg)) +#define NM_UNCONST_PPTR(type, arg) ((type **) (arg)) #endif #define NM_GOBJECT_CAST(type, obj, is_check, ...) \ @@ -649,71 +343,42 @@ NM_G_ERROR_MSG(GError *error) _ptr; \ }) -#if _NM_CC_SUPPORT_GENERIC - /* returns @value, if the type of @value matches @type. - * This requires support for C11 _Generic(). If no support is - * present, this returns @value directly. - * - * It's useful to check the let the compiler ensure that @value is - * of a certain type. */ - #define _NM_ENSURE_TYPE(type, value) (_Generic((value), type : (value))) - #define _NM_ENSURE_TYPE_CONST(type, value) \ - (_Generic((value), const type \ - : ((const type) (value)), const type const \ - : ((const type) (value)), type \ - : ((const type) (value)), type const \ - : ((const type) (value)))) -#else - #define _NM_ENSURE_TYPE(type, value) (value) - #define _NM_ENSURE_TYPE_CONST(type, value) ((const type) (value)) -#endif - -#if _NM_CC_SUPPORT_GENERIC && (!defined(__clang__) || __clang_major__ > 3) - #define NM_STRUCT_OFFSET_ENSURE_TYPE(type, container, field) \ - (_Generic((&(((container *) NULL)->field))[0], type : G_STRUCT_OFFSET(container, field))) -#else - #define NM_STRUCT_OFFSET_ENSURE_TYPE(type, container, field) G_STRUCT_OFFSET(container, field) -#endif - /* Casts (arg) to (type**), but also having a compile time check that * the arg is some sort of pointer to a pointer. * * The only purpose of this macro is some additional compile time safety, * that the argument is a pointer to pointer. But then it will C cast any kind * of such argument. */ -#define NM_CAST_PPTR(type, arg) \ - ({ \ - typeof(*(arg)) *const _arg = (arg); \ - typeof(*_arg) _arg2 = _arg ? *_arg : NULL; \ - _nm_unused const void *const _arg3 = _arg2; \ - \ - (type **) _arg; \ +#define NM_CAST_PPTR(type, arg) \ + ({ \ + _NM_ENSURE_POINTER(*(arg)); \ + (type **) (arg); \ }) #if _NM_CC_SUPPORT_GENERIC - /* these macros cast (value) to - * - "const char **" (for "MC", mutable-const) - * - "const char *const*" (for "CC", const-const) - * The point is to do this cast, but only accepting pointers - * that are compatible already. - * - * The problem is, if you add a function like g_strdupv(), the input - * argument is not modified (CC), but you want to make it work also - * for "char **". C doesn't allow this form of casting (for good reasons), - * so the function makes a choice like g_strdupv(char**). That means, - * every time you want to call it with a const argument, you need to - * explicitly cast it. - * - * These macros do the cast, but they only accept a compatible input - * type, otherwise they will fail compilation. - */ - #define NM_CAST_STRV_MC(value) \ - (_Generic ((value), \ +/* these macros cast (value) to + * - "const char **" (for "MC", mutable-const) + * - "const char *const*" (for "CC", const-const) + * The point is to do this cast, but only accepting pointers + * that are compatible already. + * + * The problem is, if you add a function like g_strdupv(), the input + * argument is not modified (CC), but you want to make it work also + * for "char **". C doesn't allow this form of casting (for good reasons), + * so the function makes a choice like g_strdupv(char**). That means, + * every time you want to call it with a const argument, you need to + * explicitly cast it. + * + * These macros do the cast, but they only accept a compatible input + * type, otherwise they will fail compilation. + */ +#define NM_CAST_STRV_MC(value) \ + (_Generic ((value), \ const char * *: (const char * *) (value), \ char * *: (const char * *) (value), \ void *: (const char * *) (value))) - #define NM_CAST_STRV_CC(value) \ - (_Generic ((value), \ +#define NM_CAST_STRV_CC(value) \ + (_Generic ((value), \ const char *const*: (const char *const*) (value), \ const char * *: (const char *const*) (value), \ char *const*: (const char *const*) (value), \ @@ -727,18 +392,18 @@ NM_G_ERROR_MSG(GError *error) const void *const: (const char *const*) (value), \ void *const: (const char *const*) (value))) #else - #define NM_CAST_STRV_MC(value) ((const char **) (value)) - #define NM_CAST_STRV_CC(value) ((const char *const *) (value)) +#define NM_CAST_STRV_MC(value) ((const char **) (value)) +#define NM_CAST_STRV_CC(value) ((const char *const *) (value)) #endif #if _NM_CC_SUPPORT_GENERIC - #define NM_PROPAGATE_CONST(test_expr, ptr) \ - (_Generic ((test_expr), \ +#define NM_PROPAGATE_CONST(test_expr, ptr) \ + (_Generic ((test_expr), \ const typeof (*(test_expr)) *: ((const typeof (*(ptr)) *) (ptr)), \ default: (_Generic ((test_expr), \ typeof (*(test_expr)) *: (ptr))))) #else - #define NM_PROPAGATE_CONST(test_expr, ptr) (ptr) +#define NM_PROPAGATE_CONST(test_expr, ptr) (ptr) #endif /* with the way it is implemented, the caller may or may not pass a trailing @@ -958,16 +623,16 @@ nm_str_realloc(char *str) #define _NM_GET_PRIVATE(self, type, is_check, ...) \ (&(NM_GOBJECT_CAST_NON_NULL(type, (self), is_check, ##__VA_ARGS__)->_priv)) #if _NM_CC_SUPPORT_AUTO_TYPE - #define _NM_GET_PRIVATE_PTR(self, type, is_check, ...) \ - ({ \ - _nm_auto_type _self_get_private = \ - NM_GOBJECT_CAST_NON_NULL(type, (self), is_check, ##__VA_ARGS__); \ - \ - NM_PROPAGATE_CONST(_self_get_private, _self_get_private->_priv); \ - }) +#define _NM_GET_PRIVATE_PTR(self, type, is_check, ...) \ + ({ \ + _nm_auto_type _self_get_private = \ + NM_GOBJECT_CAST_NON_NULL(type, (self), is_check, ##__VA_ARGS__); \ + \ + NM_PROPAGATE_CONST(_self_get_private, _self_get_private->_priv); \ + }) #else - #define _NM_GET_PRIVATE_PTR(self, type, is_check, ...) \ - (NM_GOBJECT_CAST_NON_NULL(type, (self), is_check, ##__VA_ARGS__)->_priv) +#define _NM_GET_PRIVATE_PTR(self, type, is_check, ...) \ + (NM_GOBJECT_CAST_NON_NULL(type, (self), is_check, ##__VA_ARGS__)->_priv) #endif /*****************************************************************************/ @@ -1225,6 +890,12 @@ nm_g_variant_take_ref(GVariant *v) return v; } +static inline gboolean +nm_g_variant_equal(GVariant *a, GVariant *b) +{ + return (a == b) || (a && b && g_variant_equal(a, b)); +} + /*****************************************************************************/ #define NM_DIV_ROUND_UP(x, y) \ @@ -1245,27 +916,21 @@ nm_g_variant_take_ref(GVariant *v) return (v); \ } #define NM_UTILS_LOOKUP_ITEM(v, n) \ - (void) 0; \ -case v: \ - return (n); \ - (void) 0 + case v: \ + return (n); #define NM_UTILS_LOOKUP_STR_ITEM(v, n) NM_UTILS_LOOKUP_ITEM(v, "" n "") #define NM_UTILS_LOOKUP_ITEM_IGNORE(v) \ - (void) 0; \ -case v: \ - break; \ - (void) 0 + case v: \ + break; #define NM_UTILS_LOOKUP_ITEM_IGNORE_OTHER() \ - (void) 0; \ -default: \ - break; \ - (void) 0 + default: \ + break; #define NM_UTILS_LOOKUP_DEFINE(fcn_name, lookup_type, result_type, unknown_val, ...) \ result_type fcn_name(lookup_type val) \ { \ switch (val) { \ - (void) 0, __VA_ARGS__(void) 0; \ + NM_VA_ARGS_JOIN(, __VA_ARGS__) \ }; \ { \ unknown_val; \ @@ -1471,17 +1136,15 @@ nm_strcmp_p(gconstpointer a, gconstpointer b) /*****************************************************************************/ static inline int -_NM_IN_STRSET_ASCII_CASE_op_streq(const char *x, const char *s) +_NM_IN_STRSET_EVAL_op_streq_ascii_case(const char *x1, const char *x) { - return s && g_ascii_strcasecmp(x, s) == 0; + return x && g_ascii_strcasecmp(x1, x) == 0; } -#define NM_IN_STRSET_ASCII_CASE(x, ...) \ - _NM_IN_STRSET_EVAL_N(||, \ - _NM_IN_STRSET_ASCII_CASE_op_streq, \ - x, \ - NM_NARG(__VA_ARGS__), \ - __VA_ARGS__) +#define _NM_IN_STRSET_EVAL_OP_STREQ_ASCII_CASE(x, idx) \ + _NM_IN_STRSET_EVAL_op_streq_ascii_case(_x1, x) +#define NM_IN_STRSET_ASCII_CASE(x1, ...) \ + _NM_IN_STRSET_EVAL(||, _NM_IN_STRSET_EVAL_OP_STREQ_ASCII_CASE, x1, __VA_ARGS__) #define NM_STR_HAS_SUFFIX_ASCII_CASE(str, suffix) \ ({ \ @@ -1511,6 +1174,25 @@ _NM_IN_STRSET_ASCII_CASE_op_streq(const char *x, const char *s) /*****************************************************************************/ +static inline int +nm_memcmp_n(gconstpointer p1, gsize len1, gconstpointer p2, gsize len2, gsize element_size) +{ + nm_assert(element_size > 0); + + NM_CMP_DIRECT(len1, len2); + if (len1 > 0) + NM_CMP_DIRECT_MEMCMP(p1, p2, len1 * element_size); + return 0; +} + +static inline int +nm_memeq_n(gconstpointer p1, gsize len1, gconstpointer p2, gsize len2, gsize element_size) +{ + return nm_memcmp_n(p1, len1, p2, len2, element_size) == 0; +} + +/*****************************************************************************/ + /* like g_memdup(). The difference is that the @size argument is of type * gsize, while g_memdup() has type guint. Since, the size of container types * like GArray is guint as well, this means trying to g_memdup() an @@ -1668,28 +1350,28 @@ _nm_strndup_a_step(char *s, const char *str, gsize len) * * Instead, this generic macro is supposed to handle all integers correctly. */ #if _NM_CC_SUPPORT_GENERIC - #define nm_strdup_int(val) \ - _Generic((val), char \ - : g_strdup_printf("%d", (int) (val)), \ - \ - signed char \ - : g_strdup_printf("%d", (signed) (val)), signed short \ - : g_strdup_printf("%d", (signed) (val)), signed \ - : g_strdup_printf("%d", (signed) (val)), signed long \ - : g_strdup_printf("%ld", (signed long) (val)), signed long long \ - : g_strdup_printf("%lld", (signed long long) (val)), \ - \ - unsigned char \ - : g_strdup_printf("%u", (unsigned) (val)), unsigned short \ - : g_strdup_printf("%u", (unsigned) (val)), unsigned \ - : g_strdup_printf("%u", (unsigned) (val)), unsigned long \ - : g_strdup_printf("%lu", (unsigned long) (val)), unsigned long long \ - : g_strdup_printf("%llu", (unsigned long long) (val))) +#define nm_strdup_int(val) \ + _Generic((val), char \ + : g_strdup_printf("%d", (int) (val)), \ + \ + signed char \ + : g_strdup_printf("%d", (signed) (val)), signed short \ + : g_strdup_printf("%d", (signed) (val)), signed \ + : g_strdup_printf("%d", (signed) (val)), signed long \ + : g_strdup_printf("%ld", (signed long) (val)), signed long long \ + : g_strdup_printf("%lld", (signed long long) (val)), \ + \ + unsigned char \ + : g_strdup_printf("%u", (unsigned) (val)), unsigned short \ + : g_strdup_printf("%u", (unsigned) (val)), unsigned \ + : g_strdup_printf("%u", (unsigned) (val)), unsigned long \ + : g_strdup_printf("%lu", (unsigned long) (val)), unsigned long long \ + : g_strdup_printf("%llu", (unsigned long long) (val))) #else - #define nm_strdup_int(val) \ - ((sizeof(val) == sizeof(guint64) && ((typeof(val)) -1) > 0) \ - ? g_strdup_printf("%" G_GUINT64_FORMAT, (guint64) (val)) \ - : g_strdup_printf("%" G_GINT64_FORMAT, (gint64) (val))) +#define nm_strdup_int(val) \ + ((sizeof(val) == sizeof(guint64) && ((typeof(val)) -1) > 0) \ + ? g_strdup_printf("%" G_GUINT64_FORMAT, (guint64) (val)) \ + : g_strdup_printf("%" G_GINT64_FORMAT, (gint64) (val))) #endif /*****************************************************************************/ @@ -1877,7 +1559,7 @@ nm_decode_version(guint version, guint *major, guint *minor, guint *micro) /*****************************************************************************/ #ifdef _G_BOOLEAN_EXPR - /* g_assert() uses G_LIKELY(), which in turn uses _G_BOOLEAN_EXPR(). +/* g_assert() uses G_LIKELY(), which in turn uses _G_BOOLEAN_EXPR(). * As glib's implementation uses a local variable _g_boolean_var_, * we cannot do * g_assert (some_macro ()); @@ -1887,8 +1569,8 @@ nm_decode_version(guint version, guint *major, guint *minor, guint *micro) * * Workaround that by re-defining _G_BOOLEAN_EXPR() **/ - #undef _G_BOOLEAN_EXPR - #define _G_BOOLEAN_EXPR(expr) NM_BOOLEAN_EXPR(expr) +#undef _G_BOOLEAN_EXPR +#define _G_BOOLEAN_EXPR(expr) NM_BOOLEAN_EXPR(expr) #endif /*****************************************************************************/ @@ -1913,4 +1595,22 @@ NM_AUTO_DEFINE_FCN_VOID0(GMutex *, _nm_auto_unlock_g_mutex, g_mutex_unlock); /*****************************************************************************/ +static inline GObject * +nm_g_object_freeze_notify(gpointer obj) +{ + if (obj) + g_object_freeze_notify(obj); + return obj; +} + +static inline void +nm_g_object_thaw_notify_clear(GObject **p_obj) +{ + nm_clear_pointer(p_obj, g_object_thaw_notify); +} + +#define nm_auto_g_object_thaw_notify nm_auto(nm_g_object_thaw_notify_clear) + +/*****************************************************************************/ + #endif /* __NM_MACROS_INTERNAL_H__ */ diff --git a/src/libnm-glib-aux/nm-random-utils.c b/src/libnm-glib-aux/nm-random-utils.c index b055bc3f..2f42f3f6 100644 --- a/src/libnm-glib-aux/nm-random-utils.c +++ b/src/libnm-glib-aux/nm-random-utils.c @@ -12,9 +12,9 @@ #include #if USE_SYS_RANDOM_H - #include +#include #else - #include +#include #endif #include "nm-shared-utils.h" @@ -23,15 +23,15 @@ /*****************************************************************************/ #if !defined(SYS_getrandom) && defined(__NR_getrandom) - #define SYS_getrandom __NR_getrandom +#define SYS_getrandom __NR_getrandom #endif #ifndef GRND_NONBLOCK - #define GRND_NONBLOCK 0x01 +#define GRND_NONBLOCK 0x01 #endif #ifndef GRND_INSECURE - #define GRND_INSECURE 0x04 +#define GRND_INSECURE 0x04 #endif #if !HAVE_GETRANDOM && defined(SYS_getrandom) @@ -40,8 +40,8 @@ getrandom(void *buf, size_t buflen, unsigned flags) { return syscall(SYS_getrandom, buf, buflen, flags); } - #undef HAVE_GETRANDOM - #define HAVE_GETRANDOM 1 +#undef HAVE_GETRANDOM +#define HAVE_GETRANDOM 1 #endif /*****************************************************************************/ diff --git a/src/libnm-glib-aux/nm-ref-string.h b/src/libnm-glib-aux/nm-ref-string.h index df37d583..6950d1b9 100644 --- a/src/libnm-glib-aux/nm-ref-string.h +++ b/src/libnm-glib-aux/nm-ref-string.h @@ -152,6 +152,18 @@ NM_REF_STRING_UPCAST(const char *str) return rstr; } +static inline NMRefString * +nm_ref_string_ref_upcast(const char *str) +{ + return nm_ref_string_ref(NM_REF_STRING_UPCAST(str)); +} + +static inline void +nm_ref_string_unref_upcast(const char *str) +{ + nm_ref_string_unref(NM_REF_STRING_UPCAST(str)); +} + static inline gboolean nm_ref_string_reset_str(NMRefString **ptr, const char *str) { diff --git a/src/libnm-glib-aux/nm-shared-utils.c b/src/libnm-glib-aux/nm-shared-utils.c index 81852aea..9d1a1bf1 100644 --- a/src/libnm-glib-aux/nm-shared-utils.c +++ b/src/libnm-glib-aux/nm-shared-utils.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -100,6 +99,29 @@ nm_ip_addr_set_from_untrusted(int addr_family, return TRUE; } +gboolean +nm_ip_addr_set_from_variant(int addr_family, gpointer dst, GVariant *variant, int *out_addr_family) +{ + gconstpointer bytes; + gsize len; + + g_return_val_if_fail(dst, FALSE); + g_return_val_if_fail(variant, FALSE); + + /* This function always expects IP addressea a byte arrays ("ay"). Note that + * several NetworkManager API uses "u" (32 bit unsigned intergers) for IPv4 addresses. + * So this function won't work in those cases. + * + * Btw, using "u" for IPv4 address messes badly with the endianness (host + * vs network byte order). Don't do that. + */ + g_return_val_if_fail(g_variant_is_of_type(variant, G_VARIANT_TYPE("ay")), FALSE); + + bytes = g_variant_get_fixed_array(variant, &len, sizeof(guint8)); + + return nm_ip_addr_set_from_untrusted(addr_family, dst, bytes, len, out_addr_family); +} + /*****************************************************************************/ G_STATIC_ASSERT(ETH_ALEN == sizeof(struct ether_addr)); @@ -141,9 +163,9 @@ _nm_utils_inet6_is_token(const struct in6_addr *in6addr) * token. */ void -nm_utils_ipv6_addr_set_interface_identifier(struct in6_addr *addr, const NMUtilsIPv6IfaceId iid) +nm_utils_ipv6_addr_set_interface_identifier(struct in6_addr *addr, const NMUtilsIPv6IfaceId *iid) { - memcpy(addr->s6_addr + 8, &iid.id_u8, 8); + memcpy(addr->s6_addr + 8, &iid->id_u8, 8); } /** @@ -199,8 +221,8 @@ nm_utils_ipv6_interface_identifier_get_from_token(NMUtilsIPv6IfaceId *iid, const * Returns: the input buffer filled with the id as string. */ const char * -nm_utils_inet6_interface_identifier_to_token(NMUtilsIPv6IfaceId iid, - char buf[static INET6_ADDRSTRLEN]) +nm_utils_inet6_interface_identifier_to_token(const NMUtilsIPv6IfaceId *iid, + char buf[static INET6_ADDRSTRLEN]) { struct in6_addr i6_token = {.s6_addr = { 0, @@ -264,7 +286,7 @@ _nm_assert_on_main_thread(void) /*****************************************************************************/ void -nm_utils_strbuf_append_c(char **buf, gsize *len, char c) +nm_strbuf_append_c(char **buf, gsize *len, char c) { switch (*len) { case 0: @@ -284,7 +306,7 @@ nm_utils_strbuf_append_c(char **buf, gsize *len, char c) } void -nm_utils_strbuf_append_bin(char **buf, gsize *len, gconstpointer str, gsize str_len) +nm_strbuf_append_bin(char **buf, gsize *len, gconstpointer str, gsize str_len) { switch (*len) { case 0: @@ -319,7 +341,7 @@ nm_utils_strbuf_append_bin(char **buf, gsize *len, gconstpointer str, gsize str_ } void -nm_utils_strbuf_append_str(char **buf, gsize *len, const char *str) +nm_strbuf_append_str(char **buf, gsize *len, const char *str) { gsize src_len; @@ -353,7 +375,7 @@ nm_utils_strbuf_append_str(char **buf, gsize *len, const char *str) } void -nm_utils_strbuf_append(char **buf, gsize *len, const char *format, ...) +nm_strbuf_append(char **buf, gsize *len, const char *format, ...) { char * p = *buf; va_list args; @@ -376,25 +398,25 @@ nm_utils_strbuf_append(char **buf, gsize *len, const char *format, ...) } /** - * nm_utils_strbuf_seek_end: + * nm_strbuf_seek_end: * @buf: the input/output buffer * @len: the input/output length of the buffer. * - * Commonly, one uses nm_utils_strbuf_append*(), to incrementally + * Commonly, one uses nm_strbuf_append*(), to incrementally * append strings to the buffer. However, sometimes we need to use * existing API to write to the buffer. * After doing so, we want to adjust the buffer counter. * Essentially, * * g_snprintf (buf, len, ...); - * nm_utils_strbuf_seek_end (&buf, &len); + * nm_strbuf_seek_end (&buf, &len); * * is almost the same as * - * nm_utils_strbuf_append (&buf, &len, ...); + * nm_strbuf_append (&buf, &len, ...); * * The only difference is the behavior when the string got truncated: - * nm_utils_strbuf_append() will recognize that and set the remaining + * nm_strbuf_append() will recognize that and set the remaining * length to zero. * * In general, the behavior is: @@ -412,13 +434,13 @@ nm_utils_strbuf_append(char **buf, gsize *len, const char *format, ...) * the NUL byte. This would happen with * * strncpy (buf, long_str, len); - * nm_utils_strbuf_seek_end (&buf, &len). + * nm_strbuf_seek_end (&buf, &len). * * where strncpy() does truncate the string and not NUL terminate it. - * nm_utils_strbuf_seek_end() would then NUL terminate it. + * nm_strbuf_seek_end() would then NUL terminate it. */ void -nm_utils_strbuf_seek_end(char **buf, gsize *len) +nm_strbuf_seek_end(char **buf, gsize *len) { gsize l; char *end; @@ -455,7 +477,7 @@ truncate: /*****************************************************************************/ GBytes * -nm_gbytes_get_empty(void) +nm_g_bytes_get_empty(void) { static GBytes *bytes = NULL; GBytes * b; @@ -487,8 +509,18 @@ nm_g_bytes_new_from_str(const char *str) return g_bytes_new_take(nm_memdup(str, l + 1u), l); } +GBytes * +nm_g_bytes_new_from_variant_ay(GVariant *var) +{ + if (!var) + return NULL; + if (!g_variant_is_of_type(var, G_VARIANT_TYPE_BYTESTRING)) + g_return_val_if_reached(NULL); + return g_variant_get_data_as_bytes(var); +} + /** - * nm_utils_gbytes_equal_mem: + * nm_g_bytes_equal_mem: * @bytes: (allow-none): a #GBytes array to compare. Note that * %NULL is treated like an #GBytes array of length zero. * @mem_data: the data pointer with @mem_len bytes @@ -498,7 +530,7 @@ nm_g_bytes_new_from_str(const char *str) * special case, a %NULL @bytes is treated like an empty array. */ gboolean -nm_utils_gbytes_equal_mem(GBytes *bytes, gconstpointer mem_data, gsize mem_len) +nm_g_bytes_equal_mem(GBytes *bytes, gconstpointer mem_data, gsize mem_len) { gconstpointer p; gsize l; @@ -516,7 +548,7 @@ nm_utils_gbytes_equal_mem(GBytes *bytes, gconstpointer mem_data, gsize mem_len) } GVariant * -nm_utils_gbytes_to_variant_ay(GBytes *bytes) +nm_g_bytes_to_variant_ay(const GBytes *bytes) { const guint8 *p = NULL; gsize l = 0; @@ -524,7 +556,7 @@ nm_utils_gbytes_to_variant_ay(GBytes *bytes) if (!bytes) { /* for convenience, accept NULL to return an empty variant */ } else - p = g_bytes_get_data(bytes, &l); + p = g_bytes_get_data((GBytes *) bytes, &l); return nm_g_variant_new_ay(p, l); } @@ -559,6 +591,12 @@ nm_g_variant_singleton_u_0(void) return _variant_singleton_get(g_variant_new_uint32(0)); } +GVariant * +nm_g_variant_singleton_i_0(void) +{ + return _variant_singleton_get(g_variant_new_int32(0)); +} + GVariant * nm_g_variant_singleton_b(gboolean value) { @@ -602,6 +640,24 @@ _variant_singleton_get_array_init(GVariant **p_singleton, const char *variant_ty _v; \ }) +GVariant * +nm_g_variant_singleton_au(void) +{ + return _variant_singleton_get_array("u"); +} + +GVariant * +nm_g_variant_singleton_aay(void) +{ + return _variant_singleton_get_array("ay"); +} + +GVariant * +nm_g_variant_singleton_as(void) +{ + return _variant_singleton_get_array("s"); +} + GVariant * nm_g_variant_singleton_aLsvI(void) { @@ -620,10 +676,37 @@ nm_g_variant_singleton_aaLsvI(void) return _variant_singleton_get_array("a{sv}"); } +GVariant * +nm_g_variant_singleton_ao(void) +{ + return _variant_singleton_get_array("o"); +} + +GVariant * +nm_g_variant_maybe_singleton_i(gint32 value) +{ + /* Warning: this function always returns a non-floating reference + * that must be consumed (and later unrefed) by the caller. + * + * The instance is either a singleton instance or a newly created + * instance. + * + * The idea of this is that common values (zero) can use the immutable + * singleton/flyweight instance and avoid allocating a new instance in + * the (presumable) common case. + */ + switch (value) { + case 0: + return g_variant_ref(nm_g_variant_singleton_i_0()); + default: + return g_variant_take_ref(g_variant_new_int32(value)); + } +} + /*****************************************************************************/ GHashTable * -nm_utils_strdict_clone(GHashTable *src) +nm_strdict_clone(GHashTable *src) { GHashTable * dst; GHashTableIter iter; @@ -645,7 +728,7 @@ nm_utils_strdict_clone(GHashTable *src) * Returns a floating reference. */ GVariant * -nm_utils_strdict_to_variant_ass(GHashTable *strdict) +nm_strdict_to_variant_ass(GHashTable *strdict) { gs_free NMUtilsNamedValue *values_free = NULL; NMUtilsNamedValue values_prepared[20]; @@ -666,7 +749,7 @@ nm_utils_strdict_to_variant_ass(GHashTable *strdict) /*****************************************************************************/ GVariant * -nm_utils_strdict_to_variant_asv(GHashTable *strdict) +nm_strdict_to_variant_asv(GHashTable *strdict) { gs_free NMUtilsNamedValue *values_free = NULL; NMUtilsNamedValue values_prepared[20]; @@ -715,7 +798,7 @@ nm_strquote(char *buf, gsize buf_len, const char *str) const char *const buf0 = buf; if (!str) { - nm_utils_strbuf_append_str(&buf, &buf_len, "(null)"); + nm_strbuf_append_str(&buf, &buf_len, "(null)"); goto out; } @@ -734,7 +817,7 @@ nm_strquote(char *buf, gsize buf_len, const char *str) *(buf++) = '"'; buf_len--; - nm_utils_strbuf_append_str(&buf, &buf_len, str); + nm_strbuf_append_str(&buf, &buf_len, str); /* if the string was too long we indicate truncation with a * '^' instead of a closing quote. */ @@ -762,7 +845,7 @@ out: /*****************************************************************************/ -char _nm_utils_to_string_buffer[]; +_nm_thread_local char _nm_utils_to_string_buffer[] = {0}; void nm_utils_to_string_buffer_init(char **buf, gsize *len) @@ -818,7 +901,7 @@ nm_utils_flags2str(const NMUtilsFlags2StrDesc *descs, if (!flags) { for (i = 0; i < n_descs; i++) { if (!descs[i].flag) { - nm_utils_strbuf_append_str(&p, &len, descs[i].name); + nm_strbuf_append_str(&p, &len, descs[i].name); break; } } @@ -830,14 +913,14 @@ nm_utils_flags2str(const NMUtilsFlags2StrDesc *descs, flags &= ~descs[i].flag; if (buf[0] != '\0') - nm_utils_strbuf_append_c(&p, &len, ','); - nm_utils_strbuf_append_str(&p, &len, descs[i].name); + nm_strbuf_append_c(&p, &len, ','); + nm_strbuf_append_str(&p, &len, descs[i].name); } } if (flags) { if (buf[0] != '\0') - nm_utils_strbuf_append_c(&p, &len, ','); - nm_utils_strbuf_append(&p, &len, "0x%x", flags); + nm_strbuf_append_c(&p, &len, ','); + nm_strbuf_append(&p, &len, "0x%x", flags); } return buf; }; @@ -1733,7 +1816,7 @@ _char_lookup_has_all(const CharLookupTable *lookup, const char *candidates) } /** - * nm_utils_strsplit_set_full: + * nm_strsplit_set_full: * @str: the string to split. * @delimiters: the set of delimiters. * @flags: additional flags for controlling the operation. @@ -1747,7 +1830,7 @@ _char_lookup_has_all(const CharLookupTable *lookup, const char *candidates) * This never returns an empty array. * * Returns: %NULL if @str is %NULL or "". - * If @str only contains delimiters and %NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY + * If @str only contains delimiters and %NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY * is not set, it also returns %NULL. * Otherwise, a %NULL terminated strv array containing the split words. * (delimiter characters are removed). @@ -1758,7 +1841,7 @@ _char_lookup_has_all(const CharLookupTable *lookup, const char *candidates) * like "g_strstrip((char *) iter[0])". */ const char ** -nm_utils_strsplit_set_full(const char *str, const char *delimiters, NMUtilsStrsplitSetFlags flags) +nm_strsplit_set_full(const char *str, const char *delimiters, NMUtilsStrsplitSetFlags flags) { const char ** ptr; gsize num_tokens; @@ -1767,12 +1850,11 @@ nm_utils_strsplit_set_full(const char *str, const char *delimiters, NMUtilsStrsp const char * c_str; char * s; CharLookupTable ch_lookup; - const gboolean f_escaped = NM_FLAGS_HAS(flags, NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED); + const gboolean f_escaped = NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_ESCAPED); const gboolean f_allow_escaping = - f_escaped || NM_FLAGS_HAS(flags, NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING); - const gboolean f_preserve_empty = - NM_FLAGS_HAS(flags, NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY); - const gboolean f_strstrip = NM_FLAGS_HAS(flags, NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP); + f_escaped || NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING); + const gboolean f_preserve_empty = NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY); + const gboolean f_strstrip = NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_STRSTRIP); if (!str) return NULL; @@ -1791,8 +1873,8 @@ nm_utils_strsplit_set_full(const char *str, const char *delimiters, NMUtilsStrsp } if (!str[0]) { - /* We return %NULL here, also with NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY. - * That makes nm_utils_strsplit_set_full() with NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY + /* We return %NULL here, also with NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY. + * That makes nm_strsplit_set_full() with NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY * different from g_strsplit_set(), which would in this case return an empty array. * If you need to handle %NULL, and "" specially, then check the input string first. */ return NULL; @@ -2175,7 +2257,7 @@ nm_utils_escaped_tokens_options_split(char *str, const char **out_key, const cha * with the flags "EXTRACT_UNQUOTE | EXTRACT_RELAX". This is what * systemd uses to parse /proc/cmdline, and we do too. * - * Splits the string. We have nm_utils_strsplit_set() which + * Splits the string. We have nm_strsplit_set() which * supports a variety of flags. However, extending that already * complex code to also support quotation and escaping is hard. * Instead, add a naive implementation. @@ -2262,7 +2344,7 @@ nm_utils_strsplit_quoted(const char *str) /*****************************************************************************/ /** - * nm_utils_strv_find_first: + * _nm_strv_find_first: * @list: the strv list to search * @len: the length of the list, or a negative value if @list is %NULL terminated. * @needle: the value to search for. The search is done using strcmp(). @@ -2275,7 +2357,7 @@ nm_utils_strsplit_quoted(const char *str) * Returns: index of first occurrence or -1 if @needle is not found in @list. */ gssize -nm_utils_strv_find_first(char **list, gssize len, const char *needle) +_nm_strv_find_first(const char *const *list, gssize len, const char *needle) { gssize i; @@ -2337,13 +2419,80 @@ nm_strv_has_duplicate(const char *const *strv, gssize len, gboolean is_sorted) return FALSE; } +gboolean +nm_strv_is_same_unordered(const char *const *strv1, + gssize len1, + const char *const *strv2, + gssize len2) +{ + gs_free const char **ss1_free = NULL; + gs_free const char **ss2_free = NULL; + gsize l2; + gsize l; + gsize i; + + if (len1 < 0) + l = NM_PTRARRAY_LEN(strv1); + else + l = (gsize) len1; + + if (len2 < 0) + l2 = NM_PTRARRAY_LEN(strv2); + else + l2 = (gsize) len2; + + if (l != l2) + return FALSE; + + if (l == 0) { + /* An empty array. We treat (NULL, -1), (NULL, 0) and ([...], 0) + * all the same. */ + return TRUE; + } + + if (l > 1) { + strv1 = nm_memdup_maybe_a(300, strv1, sizeof(char *) * l, &ss1_free); + strv2 = nm_memdup_maybe_a(300, strv2, sizeof(char *) * l2, &ss2_free); + _nm_strv_sort((const char **) strv1, l); + _nm_strv_sort((const char **) strv2, l); + } + + for (i = 0; i < l; i++) { + if (!nm_streq0(strv1[i], strv2[i])) + return FALSE; + } + + return TRUE; +} + +const char ** +nm_strv_cleanup_const(const char **strv, gboolean skip_empty, gboolean skip_repeated) +{ + gsize i; + gsize j; + + if (!strv || !*strv) + return strv; + + if (!skip_empty && !skip_repeated) + return strv; + + j = 0; + for (i = 0; strv[i]; i++) { + if ((skip_empty && !*strv[i]) + || (skip_repeated && nm_strv_find_first(strv, j, strv[i]) >= 0)) + continue; + strv[j++] = strv[i]; + } + strv[j] = NULL; + return strv; +} + char ** -_nm_utils_strv_cleanup(char ** strv, - gboolean strip_whitespace, - gboolean skip_empty, - gboolean skip_repeated) +nm_strv_cleanup(char **strv, gboolean strip_whitespace, gboolean skip_empty, gboolean skip_repeated) { - guint i, j; + gsize i; + gsize j; if (!strv || !*strv) return strv; @@ -2359,7 +2508,7 @@ _nm_utils_strv_cleanup(char ** strv, j = 0; for (i = 0; strv[i]; i++) { if ((skip_empty && !*strv[i]) - || (skip_repeated && nm_utils_strv_find_first(strv, j, strv[i]) >= 0)) + || (skip_repeated && nm_strv_find_first(strv, j, strv[i]) >= 0)) g_free(strv[i]); else strv[j++] = strv[i]; @@ -3762,7 +3911,7 @@ nm_utils_hashtable_cmp(const GHashTable *a, } char ** -nm_utils_strv_make_deep_copied(const char **strv) +nm_strv_make_deep_copied(const char **strv) { gsize i; @@ -3779,7 +3928,7 @@ nm_utils_strv_make_deep_copied(const char **strv) } char ** -nm_utils_strv_make_deep_copied_n(const char **strv, gsize len) +nm_strv_make_deep_copied_n(const char **strv, gsize len) { gsize i; @@ -3822,7 +3971,7 @@ nm_utils_strv_make_deep_copied_n(const char **strv, gsize len) * cloned or not. */ char ** -_nm_utils_strv_dup(const char *const *strv, gssize len, gboolean deep_copied) +_nm_strv_dup(const char *const *strv, gssize len, gboolean deep_copied) { gsize i, l; char **v; @@ -3858,7 +4007,7 @@ _nm_utils_strv_dup(const char *const *strv, gssize len, gboolean deep_copied) } const char ** -_nm_utils_strv_dup_packed(const char *const *strv, gssize len) +_nm_strv_dup_packed(const char *const *strv, gssize len) { gs_free gsize *str_len_free = NULL; @@ -4219,7 +4368,7 @@ nm_utils_get_start_time_for_pid(pid_t pid, char *out_state, pid_t *out_ppid) state = p[0]; - tokens = nm_utils_strsplit_set(p, " "); + tokens = nm_strsplit_set(p, " "); if (NM_PTRARRAY_LEN(tokens) < 20) goto fail; @@ -4247,7 +4396,7 @@ fail: /*****************************************************************************/ /** - * _nm_utils_strv_sort: + * _nm_strv_sort: * @strv: pointer containing strings that will be sorted * in-place, %NULL is allowed, unless @len indicates * that there are more elements. @@ -4261,7 +4410,7 @@ fail: * comparison. */ void -_nm_utils_strv_sort(const char **strv, gssize len) +_nm_strv_sort(const char **strv, gssize len) { GCompareDataFunc cmp; gsize l; @@ -4283,7 +4432,7 @@ _nm_utils_strv_sort(const char **strv, gssize len) } /** - * _nm_utils_strv_cmp_n: + * _nm_strv_cmp_n: * @strv1: a string array * @len1: the length of @strv1, or -1 for NULL terminated array. * @strv2: a string array @@ -4306,7 +4455,7 @@ _nm_utils_strv_sort(const char **strv, gssize len) * Returns: 0 if the arrays are equal (using strcmp). **/ int -_nm_utils_strv_cmp_n(const char *const *strv1, gssize len1, const char *const *strv2, gssize len2) +_nm_strv_cmp_n(const char *const *strv1, gssize len1, const char *const *strv2, gssize len2) { gsize n, n2; @@ -5015,12 +5164,12 @@ nm_g_unix_signal_source_new(int signum, } GSource * -nm_g_unix_fd_source_new(int fd, - GIOCondition io_condition, - int priority, - gboolean (*source_func)(int fd, GIOCondition condition, gpointer user_data), - gpointer user_data, - GDestroyNotify destroy_notify) +nm_g_unix_fd_source_new(int fd, + GIOCondition io_condition, + int priority, + GUnixFDSourceFunc source_func, + gpointer user_data, + GDestroyNotify destroy_notify) { GSource *source; @@ -5032,6 +5181,23 @@ nm_g_unix_fd_source_new(int fd, return source; } +GSource * +nm_g_child_watch_source_new(GPid pid, + int priority, + GChildWatchFunc handler, + gpointer user_data, + GDestroyNotify notify) +{ + GSource *source; + + source = g_child_watch_source_new(pid); + + if (priority != G_PRIORITY_DEFAULT) + g_source_set_priority(source, priority); + g_source_set_callback(source, G_SOURCE_FUNC(handler), user_data, notify); + return source; +} + /*****************************************************************************/ #define _CTX_LOG(fmt, ...) \ @@ -6363,6 +6529,35 @@ nm_utils_get_process_exit_status_desc(int status) /*****************************************************************************/ +gboolean +nm_utils_validate_hostname(const char *hostname) +{ + const char *p; + gboolean dot = TRUE; + + if (!hostname || !hostname[0]) + return FALSE; + + for (p = hostname; *p; p++) { + if (*p == '.') { + if (dot) + return FALSE; + dot = TRUE; + } else { + if (!g_ascii_isalnum(*p) && (*p != '-') && (*p != '_')) + return FALSE; + dot = FALSE; + } + } + + if (dot) + return FALSE; + + return (p - hostname <= HOST_NAME_MAX); +} + +/*****************************************************************************/ + typedef struct { CList lst; gpointer tls_data; @@ -6437,3 +6632,33 @@ nm_utils_thread_local_register_destroy(gpointer tls_data, GDestroyNotify destroy entry->destroy_notify = destroy_notify; c_list_link_tail(lst_head, &entry->lst); } + +/*****************************************************************************/ + +static gboolean +_iterate_for_msec_timeout(gpointer user_data) +{ + GSource **p_source = user_data; + + nm_clear_g_source_inst(p_source); + return G_SOURCE_CONTINUE; +} + +void +nm_g_main_context_iterate_for_msec(GMainContext *context, guint timeout_msec) +{ + GSource *source; + + /* In production is this function not very useful. It is however useful to + * have in the toolbox for printf debugging. */ + + source = g_timeout_source_new(timeout_msec); + g_source_set_callback(source, _iterate_for_msec_timeout, &source, NULL); + + if (!context) + context = g_main_context_default(); + + g_source_attach(source, context); + while (source) + g_main_context_iteration(context, TRUE); +} diff --git a/src/libnm-glib-aux/nm-shared-utils.h b/src/libnm-glib-aux/nm-shared-utils.h index dcf37cd3..8dd53dcf 100644 --- a/src/libnm-glib-aux/nm-shared-utils.h +++ b/src/libnm-glib-aux/nm-shared-utils.h @@ -18,6 +18,7 @@ typedef enum _nm_packed { NM_OPTION_BOOL_TRUE = 1, } NMOptionBool; +#define nm_assert_is_bool(value) nm_assert(NM_IN_SET((value), 0, 1)) #define nm_assert_is_ternary(value) nm_assert(NM_IN_SET((value), -1, 0, 1)) /*****************************************************************************/ @@ -35,19 +36,19 @@ pid_t nm_utils_gettid(void); gboolean _nm_assert_on_main_thread(void); #if NM_MORE_ASSERTS > 5 - #define NM_ASSERT_ON_MAIN_THREAD() \ - G_STMT_START \ - { \ - nm_assert(_nm_assert_on_main_thread()); \ - } \ - G_STMT_END +#define NM_ASSERT_ON_MAIN_THREAD() \ + G_STMT_START \ + { \ + nm_assert(_nm_assert_on_main_thread()); \ + } \ + G_STMT_END #else - #define NM_ASSERT_ON_MAIN_THREAD() \ - G_STMT_START \ - { \ - ; \ - } \ - G_STMT_END +#define NM_ASSERT_ON_MAIN_THREAD() \ + G_STMT_START \ + { \ + ; \ + } \ + G_STMT_END #endif /*****************************************************************************/ @@ -79,20 +80,20 @@ _NM_INT_NOT_NEGATIVE(gssize val) * Together with the G_STATIC_ASSERT(), we make sure that this is always satisfied. */ G_STATIC_ASSERT(sizeof(int) == sizeof(gint32)); #if _NM_CC_SUPPORT_GENERIC - #define _NM_INT_LE_MAXINT32(value) \ - ({ \ - _nm_unused typeof(value) _value = (value); \ - \ - _Generic((value), int : TRUE); \ - }) +#define _NM_INT_LE_MAXINT32(value) \ + ({ \ + _nm_unused typeof(value) _value = (value); \ + \ + _Generic((value), int : TRUE); \ + }) #else - #define _NM_INT_LE_MAXINT32(value) \ - ({ \ - _nm_unused typeof(value) _value = (value); \ - _nm_unused const int * _p_value = &_value; \ - \ - TRUE; \ - }) +#define _NM_INT_LE_MAXINT32(value) \ + ({ \ + _nm_unused typeof(value) _value = (value); \ + _nm_unused const int * _p_value = &_value; \ + \ + TRUE; \ + }) #endif /*****************************************************************************/ @@ -247,7 +248,6 @@ extern const NMIPAddr nm_ip_addr_zero; static inline int nm_ip_addr_cmp(int addr_family, gconstpointer a, gconstpointer b) { - nm_assert_addr_family(addr_family); nm_assert(a); nm_assert(b); @@ -264,20 +264,27 @@ static inline gboolean nm_ip_addr_is_null(int addr_family, gconstpointer addr) { nm_assert(addr); - if (addr_family == AF_INET6) - return IN6_IS_ADDR_UNSPECIFIED((const struct in6_addr *) addr); - nm_assert(addr_family == AF_INET); - return ((const struct in_addr *) addr)->s_addr == 0; + + if (NM_IS_IPv4(addr_family)) { + in_addr_t t; + + /* also for in_addr_t type (AF_INET), we accept that the pointer might + * be unaligned. */ + memcpy(&t, addr, sizeof(t)); + return t == 0; + } + + return IN6_IS_ADDR_UNSPECIFIED((const struct in6_addr *) addr); } static inline void nm_ip_addr_set(int addr_family, gpointer dst, gconstpointer src) { - nm_assert_addr_family(addr_family); nm_assert(dst); nm_assert(src); - memcpy(dst, src, NM_IS_IPv4(addr_family) ? sizeof(in_addr_t) : sizeof(struct in6_addr)); + /* this MUST use memcpy() (or similar means) to support unaligned src/dst pointers. */ + memcpy(dst, src, nm_utils_addr_family_to_size(addr_family)); } static inline NMIPAddr @@ -308,6 +315,9 @@ gboolean nm_ip_addr_set_from_untrusted(int addr_family, gsize src_len, int * out_addr_family); +gboolean +nm_ip_addr_set_from_variant(int addr_family, gpointer dst, GVariant *variant, int *out_addr_family); + static inline gboolean nm_ip4_addr_is_localhost(in_addr_t addr4) { @@ -365,8 +375,8 @@ typedef struct _NMUtilsIPv6IfaceId { } \ } -void nm_utils_ipv6_addr_set_interface_identifier(struct in6_addr * addr, - const NMUtilsIPv6IfaceId iid); +void nm_utils_ipv6_addr_set_interface_identifier(struct in6_addr * addr, + const NMUtilsIPv6IfaceId *iid); void nm_utils_ipv6_interface_identifier_get_from_addr(NMUtilsIPv6IfaceId * iid, const struct in6_addr *addr); @@ -374,7 +384,7 @@ void nm_utils_ipv6_interface_identifier_get_from_addr(NMUtilsIPv6IfaceId * iid gboolean nm_utils_ipv6_interface_identifier_get_from_token(NMUtilsIPv6IfaceId *iid, const char * token); -const char *nm_utils_inet6_interface_identifier_to_token(NMUtilsIPv6IfaceId iid, +const char *nm_utils_inet6_interface_identifier_to_token(const NMUtilsIPv6IfaceId *iid, char buf[static INET6_ADDRSTRLEN]); gboolean nm_utils_get_ipv6_interface_identifier(NMLinkType link_type, @@ -559,25 +569,25 @@ extern const void *const _NM_PTRARRAY_EMPTY[1]; #define NM_STRV_EMPTY_CC() NM_PTRARRAY_EMPTY(const char *) static inline void -_nm_utils_strbuf_init(char *buf, gsize len, char **p_buf_ptr, gsize *p_buf_len) +nm_strbuf_init(char *buf, gsize len, char **p_buf_ptr, gsize *p_buf_len) { NM_SET_OUT(p_buf_len, len); NM_SET_OUT(p_buf_ptr, buf); buf[0] = '\0'; } -#define nm_utils_strbuf_init(buf, p_buf_ptr, p_buf_len) \ +#define nm_strbuf_init_arr(buf, p_buf_ptr, p_buf_len) \ G_STMT_START \ { \ G_STATIC_ASSERT(G_N_ELEMENTS(buf) == sizeof(buf) && sizeof(buf) > sizeof(char *)); \ - _nm_utils_strbuf_init((buf), sizeof(buf), (p_buf_ptr), (p_buf_len)); \ + nm_strbuf_init((buf), sizeof(buf), (p_buf_ptr), (p_buf_len)); \ } \ G_STMT_END -void nm_utils_strbuf_append(char **buf, gsize *len, const char *format, ...) _nm_printf(3, 4); -void nm_utils_strbuf_append_c(char **buf, gsize *len, char c); -void nm_utils_strbuf_append_str(char **buf, gsize *len, const char *str); -void nm_utils_strbuf_append_bin(char **buf, gsize *len, gconstpointer str, gsize str_len); -void nm_utils_strbuf_seek_end(char **buf, gsize *len); +void nm_strbuf_append(char **buf, gsize *len, const char *format, ...) _nm_printf(3, 4); +void nm_strbuf_append_c(char **buf, gsize *len, char c); +void nm_strbuf_append_str(char **buf, gsize *len, const char *str); +void nm_strbuf_append_bin(char **buf, gsize *len, gconstpointer str, gsize str_len); +void nm_strbuf_seek_end(char **buf, gsize *len); const char *nm_strquote(char *buf, gsize buf_len, const char *str); @@ -589,24 +599,25 @@ nm_utils_is_separator(const char c) /*****************************************************************************/ -GBytes *nm_gbytes_get_empty(void); +GBytes *nm_g_bytes_get_empty(void); GBytes *nm_g_bytes_new_from_str(const char *str); +GBytes *nm_g_bytes_new_from_variant_ay(GVariant *var); static inline gboolean -nm_gbytes_equal0(GBytes *a, GBytes *b) +nm_g_bytes_equal0(const GBytes *a, const GBytes *b) { return a == b || (a && b && g_bytes_equal(a, b)); } -gboolean nm_utils_gbytes_equal_mem(GBytes *bytes, gconstpointer mem_data, gsize mem_len); +gboolean nm_g_bytes_equal_mem(GBytes *bytes, gconstpointer mem_data, gsize mem_len); -GVariant *nm_utils_gbytes_to_variant_ay(GBytes *bytes); +GVariant *nm_g_bytes_to_variant_ay(const GBytes *bytes); -GHashTable *nm_utils_strdict_clone(GHashTable *src); +GHashTable *nm_strdict_clone(GHashTable *src); -GVariant *nm_utils_strdict_to_variant_ass(GHashTable *strdict); -GVariant *nm_utils_strdict_to_variant_asv(GHashTable *strdict); +GVariant *nm_strdict_to_variant_ass(GHashTable *strdict); +GVariant *nm_strdict_to_variant_asv(GHashTable *strdict); /*****************************************************************************/ @@ -650,95 +661,105 @@ int nm_utils_dbus_path_cmp(const char *dbus_path_a, const char *dbus_path_b); /*****************************************************************************/ typedef enum { - NM_UTILS_STRSPLIT_SET_FLAGS_NONE = 0, + NM_STRSPLIT_SET_FLAGS_NONE = 0, /* by default, strsplit will coalesce consecutive delimiters and remove * them from the result. If this flag is present, empty values are preserved * and returned. * - * When combined with %NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP, if a value gets + * When combined with %NM_STRSPLIT_SET_FLAGS_STRSTRIP, if a value gets * empty after strstrip(), it also gets removed. */ - NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY = (1u << 0), + NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY = (1u << 0), - /* %NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING means that delimiters prefixed + /* %NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING means that delimiters prefixed * by a backslash are not treated as a separator. Such delimiters and their escape * character are copied to the current word without unescaping them. In general, - * nm_utils_strsplit_set_full() does not remove any backslash escape characters + * nm_strsplit_set_full() does not remove any backslash escape characters * and does no unescaping. It only considers them for skipping to split at * an escaped delimiter. * - * If this is combined with (or implied by %NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED), then + * If this is combined with (or implied by %NM_STRSPLIT_SET_FLAGS_ESCAPED), then * the backslash escapes are removed from the result. */ - NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING = (1u << 1), + NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING = (1u << 1), /* If flag is set, does the same as g_strstrip() on the returned tokens. * This will remove leading and trailing ascii whitespaces (g_ascii_isspace() * and NM_ASCII_SPACES). * - * - when combined with !%NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, + * - when combined with !%NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, * empty tokens will be removed (and %NULL will be returned if that * results in an empty string array). - * - when combined with %NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING, + * - when combined with %NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING, * trailing whitespace escaped by backslash are not stripped. */ - NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP = (1u << 2), + NM_STRSPLIT_SET_FLAGS_STRSTRIP = (1u << 2), - /* This implies %NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING. + /* This implies %NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING. * * This will do a final run over all tokens and remove all backslash * escape characters that * - precede a delimiter. * - precede a backslash. - * - precede a whitespace (only with %NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP). + * - precede a whitespace (only with %NM_STRSPLIT_SET_FLAGS_STRSTRIP). * - * Note that with %NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP, it is only + * Note that with %NM_STRSPLIT_SET_FLAGS_STRSTRIP, it is only * necessary to escape the very last whitespace (if the delimiters * are not whitespace themself). So, technically, it would be sufficient * to only unescape a backslash before the last whitespace and the user * still could express everything. However, such a rule would be complicated - * to understand, so when using backslash escaping with nm_utils_strsplit_set_full(), + * to understand, so when using backslash escaping with nm_strsplit_set_full(), * then all characters (including backslash) are treated verbatim, except: * * - "\\$DELIMITER" (escaped delimiter) * - "\\\\" (escaped backslash) - * - "\\$SPACE" (escaped space) (only with %NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP). + * - "\\$SPACE" (escaped space) (only with %NM_STRSPLIT_SET_FLAGS_STRSTRIP). * * Note that all other escapes like "\\n" or "\\001" are left alone. * That makes the escaping/unescaping rules simple. Also, for the most part * a text is just taken as-is, with little additional rules. Only backslashes * need extra care, and then only if they proceed one of the relevant characters. */ - NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED = (1u << 3), + NM_STRSPLIT_SET_FLAGS_ESCAPED = (1u << 3), } NMUtilsStrsplitSetFlags; const char ** -nm_utils_strsplit_set_full(const char *str, const char *delimiter, NMUtilsStrsplitSetFlags flags); +nm_strsplit_set_full(const char *str, const char *delimiter, NMUtilsStrsplitSetFlags flags); static inline const char ** -nm_utils_strsplit_set_with_empty(const char *str, const char *delimiters) +nm_strsplit_set_with_empty(const char *str, const char *delimiters) { /* this returns the same result as g_strsplit_set(str, delimiters, -1), except * it does not deep-clone the strv array. * Also, for @str == "", this returns %NULL while g_strsplit_set() would return * an empty strv array. */ - return nm_utils_strsplit_set_full(str, delimiters, NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY); + return nm_strsplit_set_full(str, delimiters, NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY); } static inline const char ** -nm_utils_strsplit_set(const char *str, const char *delimiters) +nm_strsplit_set(const char *str, const char *delimiters) { - return nm_utils_strsplit_set_full(str, delimiters, NM_UTILS_STRSPLIT_SET_FLAGS_NONE); + return nm_strsplit_set_full(str, delimiters, NM_STRSPLIT_SET_FLAGS_NONE); } -gssize nm_utils_strv_find_first(char **list, gssize len, const char *needle); +gssize _nm_strv_find_first(const char *const *list, gssize len, const char *needle); + +#define nm_strv_find_first(list, len, needle) \ + _nm_strv_find_first(NM_CAST_STRV_CC(list), (len), (needle)) gboolean nm_strv_has_duplicate(const char *const *list, gssize len, gboolean is_sorted); -char **_nm_utils_strv_cleanup(char ** strv, - gboolean strip_whitespace, - gboolean skip_empty, - gboolean skip_repeated); +const char **nm_strv_cleanup_const(const char **strv, gboolean skip_empty, gboolean skip_repeated); + +char **nm_strv_cleanup(char ** strv, + gboolean strip_whitespace, + gboolean skip_empty, + gboolean skip_repeated); + +gboolean nm_strv_is_same_unordered(const char *const *strv1, + gssize len1, + const char *const *strv2, + gssize len2); /*****************************************************************************/ @@ -753,10 +774,9 @@ nm_copy_func_g_strdup(gconstpointer arg, gpointer user_data) static inline const char ** nm_utils_escaped_tokens_split(const char *str, const char *delimiters) { - return nm_utils_strsplit_set_full(str, - delimiters, - NM_UTILS_STRSPLIT_SET_FLAGS_ESCAPED - | NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP); + return nm_strsplit_set_full(str, + delimiters, + NM_STRSPLIT_SET_FLAGS_ESCAPED | NM_STRSPLIT_SET_FLAGS_STRSTRIP); } typedef enum { @@ -879,10 +899,10 @@ char **nm_utils_strsplit_quoted(const char *str); static inline const char ** nm_utils_escaped_tokens_options_split_list(const char *str) { - return nm_utils_strsplit_set_full(str, - ",", - NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP - | NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING); + return nm_strsplit_set_full(str, + ",", + NM_STRSPLIT_SET_FLAGS_STRSTRIP + | NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING); } void nm_utils_escaped_tokens_options_split(char *str, const char **out_key, const char **out_val); @@ -1033,7 +1053,7 @@ int _nm_utils_ascii_str_to_bool(const char *str, int default_value); /*****************************************************************************/ -extern char _nm_utils_to_string_buffer[2096]; +extern _nm_thread_local char _nm_utils_to_string_buffer[2096]; void nm_utils_to_string_buffer_init(char **buf, gsize *len); gboolean nm_utils_to_string_buffer_init_null(gconstpointer obj, char **buf, gsize *len); @@ -1069,16 +1089,12 @@ const char *nm_utils_flags2str(const NMUtilsFlags2StrDesc *descs, /*****************************************************************************/ #define NM_UTILS_ENUM2STR(v, n) \ - (void) 0; \ -case v: \ - s = "" n ""; \ - break; \ - (void) 0 + case v: \ + s = "" n ""; \ + break; #define NM_UTILS_ENUM2STR_IGNORE(v) \ - (void) 0; \ -case v: \ - break; \ - (void) 0 + case v: \ + break; #define NM_UTILS_ENUM2STR_DEFINE_FULL(fcn_name, lookup_type, int_fmt, ...) \ const char *fcn_name(lookup_type val, char *buf, gsize len) \ @@ -1087,7 +1103,7 @@ case v: \ if (len) { \ const char *s = NULL; \ switch (val) { \ - (void) 0, __VA_ARGS__(void) 0; \ + NM_VA_ARGS_JOIN(, __VA_ARGS__) \ }; \ if (s) \ g_strlcpy(buf, s, len); \ @@ -1107,14 +1123,26 @@ case v: \ static inline void _nm_g_slice_free_fcn_##mem_size(gpointer mem_block) \ { \ g_slice_free1(mem_size, mem_block); \ - } + } \ + _NM_DUMMY_STRUCT_FOR_TRAILING_SEMICOLON -_nm_g_slice_free_fcn_define(1) _nm_g_slice_free_fcn_define(2) _nm_g_slice_free_fcn_define(4) - _nm_g_slice_free_fcn_define(8) _nm_g_slice_free_fcn_define(10) _nm_g_slice_free_fcn_define(12) - _nm_g_slice_free_fcn_define(16) _nm_g_slice_free_fcn_define(32) +_nm_g_slice_free_fcn_define(1); +_nm_g_slice_free_fcn_define(2); +_nm_g_slice_free_fcn_define(4); +_nm_g_slice_free_fcn_define(8); +_nm_g_slice_free_fcn_define(10); +_nm_g_slice_free_fcn_define(12); +_nm_g_slice_free_fcn_define(16); +_nm_g_slice_free_fcn_define(32); + +_nm_warn_unused_result static inline GDestroyNotify +_nm_get_warn_unused_result_gdestroynotify(GDestroyNotify f) +{ + return f; +} #define nm_g_slice_free_fcn1(mem_size) \ - ({ \ + _nm_get_warn_unused_result_gdestroynotify(({ \ void (*_fcn)(gpointer); \ \ /* If mem_size is a compile time constant, the compiler @@ -1153,8 +1181,9 @@ _nm_g_slice_free_fcn_define(1) _nm_g_slice_free_fcn_define(2) _nm_g_slice_free_f _fcn = NULL; \ break; \ } \ + \ _fcn; \ - }) + })) /** * nm_g_slice_free_fcn: @@ -1185,7 +1214,8 @@ _nm_g_slice_free_fcn_define(1) _nm_g_slice_free_fcn_define(2) _nm_g_slice_free_f _error && _error->domain == (err_domain) && NM_IN_SET(_error->code, __VA_ARGS__); \ }) - static inline void nm_g_set_error_take(GError **error, GError *error_take) +static inline void +nm_g_set_error_take(GError **error, GError *error_take) { if (!error_take) g_return_if_reached(); @@ -1420,21 +1450,41 @@ GParamSpec *nm_g_object_class_find_property_from_gtype(GType gtype, const char * ((const _c_type *) _param_spec); \ }) +#define _NM_G_PARAM_SPEC_CAST_IS_A(param_spec, _value_type, _c_type) \ + ({ \ + const GParamSpec *const _param_spec = (param_spec); \ + \ + nm_assert(!_param_spec || g_type_is_a(_param_spec->value_type, _value_type)); \ + ((const _c_type *) _param_spec); \ + }) + #define NM_G_PARAM_SPEC_CAST_BOOLEAN(param_spec) \ _NM_G_PARAM_SPEC_CAST(param_spec, G_TYPE_BOOLEAN, GParamSpecBoolean) +#define NM_G_PARAM_SPEC_CAST_INT(param_spec) \ + _NM_G_PARAM_SPEC_CAST(param_spec, G_TYPE_INT, GParamSpecInt) #define NM_G_PARAM_SPEC_CAST_UINT(param_spec) \ _NM_G_PARAM_SPEC_CAST(param_spec, G_TYPE_UINT, GParamSpecUInt) #define NM_G_PARAM_SPEC_CAST_UINT64(param_spec) \ _NM_G_PARAM_SPEC_CAST(param_spec, G_TYPE_UINT64, GParamSpecUInt64) +#define NM_G_PARAM_SPEC_CAST_ENUM(param_spec) \ + _NM_G_PARAM_SPEC_CAST_IS_A(param_spec, G_TYPE_ENUM, GParamSpecEnum) +#define NM_G_PARAM_SPEC_CAST_FLAGS(param_spec) \ + _NM_G_PARAM_SPEC_CAST_IS_A(param_spec, G_TYPE_FLAGS, GParamSpecFlags) #define NM_G_PARAM_SPEC_CAST_STRING(param_spec) \ _NM_G_PARAM_SPEC_CAST(param_spec, G_TYPE_STRING, GParamSpecString) #define NM_G_PARAM_SPEC_GET_DEFAULT_BOOLEAN(param_spec) \ (NM_G_PARAM_SPEC_CAST_BOOLEAN(NM_ENSURE_NOT_NULL(param_spec))->default_value) +#define NM_G_PARAM_SPEC_GET_DEFAULT_INT(param_spec) \ + (NM_G_PARAM_SPEC_CAST_INT(NM_ENSURE_NOT_NULL(param_spec))->default_value) #define NM_G_PARAM_SPEC_GET_DEFAULT_UINT(param_spec) \ (NM_G_PARAM_SPEC_CAST_UINT(NM_ENSURE_NOT_NULL(param_spec))->default_value) #define NM_G_PARAM_SPEC_GET_DEFAULT_UINT64(param_spec) \ (NM_G_PARAM_SPEC_CAST_UINT64(NM_ENSURE_NOT_NULL(param_spec))->default_value) +#define NM_G_PARAM_SPEC_GET_DEFAULT_ENUM(param_spec) \ + (NM_G_PARAM_SPEC_CAST_ENUM(NM_ENSURE_NOT_NULL(param_spec))->default_value) +#define NM_G_PARAM_SPEC_GET_DEFAULT_FLAGS(param_spec) \ + (NM_G_PARAM_SPEC_CAST_FLAGS(NM_ENSURE_NOT_NULL(param_spec))->default_value) #define NM_G_PARAM_SPEC_GET_DEFAULT_STRING(param_spec) \ (NM_G_PARAM_SPEC_CAST_STRING(NM_ENSURE_NOT_NULL(param_spec))->default_value) @@ -1498,10 +1548,17 @@ char *nm_utils_str_utf8safe_escape_take(char *str, NMUtilsStrUtf8SafeFlags flags GVariant *nm_g_variant_singleton_b(gboolean value); GVariant *nm_g_variant_singleton_u_0(void); +GVariant *nm_g_variant_singleton_i_0(void); GVariant *nm_g_variant_singleton_s_empty(void); +GVariant *nm_g_variant_singleton_au(void); +GVariant *nm_g_variant_singleton_aay(void); +GVariant *nm_g_variant_singleton_as(void); GVariant *nm_g_variant_singleton_aLsvI(void); GVariant *nm_g_variant_singleton_aLsaLsvII(void); GVariant *nm_g_variant_singleton_aaLsvI(void); +GVariant *nm_g_variant_singleton_ao(void); + +GVariant *nm_g_variant_maybe_singleton_i(gint32 v); static inline void nm_g_variant_unref_floating(GVariant *var) @@ -1599,6 +1656,19 @@ nm_g_variant_builder_add_sv_str(GVariantBuilder *builder, const char *key, const static inline void nm_g_source_destroy_and_unref(GSource *source) { + /* Note that calling g_source_destroy() on a currently attached source, + * will destroy the user-data of the callback right away (and not only + * during the last g_source_unref()). + * + * It also means, that if the user data itself has the reference to the + * source, then this will lead to crash: + * + * g_source_destroy(user_data->my_source); + * // ups, user_data was destroyed (if source was attached). + * g_source_unref(user_data->my_source); + * + * nm_g_source_destroy_and_unref() and nm_clear_g_source_inst() does not + * suffer from this problem. */ g_source_destroy(source); g_source_unref(source); } @@ -1673,19 +1743,25 @@ GSource *nm_g_timeout_source_new_seconds(guint timeout_sec, gpointer user_data, GDestroyNotify destroy_notify); -GSource * - nm_g_unix_fd_source_new(int fd, - GIOCondition io_condition, - int priority, - gboolean (*source_func)(int fd, GIOCondition condition, gpointer user_data), - gpointer user_data, - GDestroyNotify destroy_notify); +GSource *nm_g_unix_fd_source_new(int fd, + GIOCondition io_condition, + int priority, + GUnixFDSourceFunc source_func, + gpointer user_data, + GDestroyNotify destroy_notify); + GSource *nm_g_unix_signal_source_new(int signum, int priority, GSourceFunc handler, gpointer user_data, GDestroyNotify notify); +GSource *nm_g_child_watch_source_new(GPid pid, + int priority, + GChildWatchFunc handler, + gpointer user_data, + GDestroyNotify notify); + static inline GSource * nm_g_source_attach(GSource *source, GMainContext *context) { @@ -1693,10 +1769,25 @@ nm_g_source_attach(GSource *source, GMainContext *context) return source; } +static inline void +nm_g_idle_add(GSourceFunc func, gpointer user_data) +{ + /* g_idle_add() is discouraged because it relies on the guint source IDs. + * + * Usually, you would want to use nm_g_idle_add_source() which returns a GSource* + * instance. + * + * However, if you don't care to ever call g_source_remove() on the source ID, then + * g_idle_add() is fine. But our checkpatch script would complain about it. In + * that case use nm_g_idle_add(), which makes it clear that you really want to + * use g_idle_add() and ignore the source ID. */ + g_idle_add(func, user_data); +} + static inline GSource * nm_g_idle_add_source(GSourceFunc func, gpointer user_data) { - /* G convenience function to attach a new timeout source to the default GMainContext. + /* A convenience function to attach a new timeout source to the default GMainContext. * In that sense it's very similar to g_idle_add() except that it returns a * reference to the new source. */ return nm_g_source_attach(nm_g_idle_source_new(G_PRIORITY_DEFAULT, func, user_data, NULL), @@ -1706,7 +1797,7 @@ nm_g_idle_add_source(GSourceFunc func, gpointer user_data) static inline GSource * nm_g_timeout_add_source(guint timeout_msec, GSourceFunc func, gpointer user_data) { - /* G convenience function to attach a new timeout source to the default GMainContext. + /* A convenience function to attach a new timeout source to the default GMainContext. * In that sense it's very similar to g_timeout_add() except that it returns a * reference to the new source. */ return nm_g_source_attach( @@ -1715,9 +1806,9 @@ nm_g_timeout_add_source(guint timeout_msec, GSourceFunc func, gpointer user_data } static inline GSource * -nm_g_timeout_add_source_seconds(guint timeout_sec, GSourceFunc func, gpointer user_data) +nm_g_timeout_add_seconds_source(guint timeout_sec, GSourceFunc func, gpointer user_data) { - /* G convenience function to attach a new timeout source to the default GMainContext. + /* A convenience function to attach a new timeout source to the default GMainContext. * In that sense it's very similar to g_timeout_add_seconds() except that it returns a * reference to the new source. */ return nm_g_source_attach( @@ -1746,6 +1837,36 @@ nm_g_timeout_add_source_approx(guint timeout_msec, return nm_g_source_attach(source, NULL); } +static inline GSource * +nm_g_unix_fd_add_source(int fd, + GIOCondition condition, + GUnixFDSourceFunc function, + gpointer user_data) +{ + /* A convenience function to attach a new unix-fd source to the default GMainContext. + * In that sense it's very similar to g_unix_fd_add() except that it returns a + * reference to the new source. */ + return nm_g_source_attach( + nm_g_unix_fd_source_new(fd, condition, G_PRIORITY_DEFAULT, function, user_data, NULL), + NULL); +} + +static inline GSource * +nm_g_unix_signal_add_source(int signum, GSourceFunc handler, gpointer user_data) +{ + return nm_g_source_attach( + nm_g_unix_signal_source_new(signum, G_PRIORITY_DEFAULT, handler, user_data, NULL), + NULL); +} + +static inline GSource * +nm_g_child_watch_add_source(GPid pid, GChildWatchFunc handler, gpointer user_data) +{ + return nm_g_source_attach( + nm_g_child_watch_source_new(pid, G_PRIORITY_DEFAULT, handler, user_data, NULL), + NULL); +} + NM_AUTO_DEFINE_FCN0(GMainContext *, _nm_auto_unref_gmaincontext, g_main_context_unref); #define nm_auto_unref_gmaincontext nm_auto(_nm_auto_unref_gmaincontext) @@ -1801,6 +1922,16 @@ nm_g_main_context_push_thread_default_if_necessary(GMainContext *context) return context; } +static inline void +nm_g_main_context_iterate_ready(GMainContext *context) +{ + while (g_main_context_iteration(context, FALSE)) { + ; + } +} + +void nm_g_main_context_iterate_for_msec(GMainContext *context, guint timeout_msec); + /*****************************************************************************/ static inline int @@ -1893,7 +2024,7 @@ gpointer *nm_utils_hash_values_to_array(GHashTable * hash, guint * out_len); static inline const char ** -nm_utils_strdict_get_keys(const GHashTable *hash, gboolean sorted, guint *out_length) +nm_strdict_get_keys(const GHashTable *hash, gboolean sorted, guint *out_length) { return (const char **) nm_utils_hash_keys_to_array((GHashTable *) hash, sorted ? nm_strcmp_p_with_data : NULL, @@ -1924,26 +2055,26 @@ int nm_utils_hashtable_cmp(const GHashTable *a, GCompareDataFunc cmp_values, gpointer user_data); -char **nm_utils_strv_make_deep_copied(const char **strv); +char **nm_strv_make_deep_copied(const char **strv); -char **nm_utils_strv_make_deep_copied_n(const char **strv, gsize len); +char **nm_strv_make_deep_copied_n(const char **strv, gsize len); static inline char ** -nm_utils_strv_make_deep_copied_nonnull(const char **strv) +nm_strv_make_deep_copied_nonnull(const char **strv) { - return nm_utils_strv_make_deep_copied(strv) ?: g_new0(char *, 1); + return nm_strv_make_deep_copied(strv) ?: g_new0(char *, 1); } -char **_nm_utils_strv_dup(const char *const *strv, gssize len, gboolean deep_copied); +char **_nm_strv_dup(const char *const *strv, gssize len, gboolean deep_copied); -#define nm_utils_strv_dup(strv, len, deep_copied) \ - _nm_utils_strv_dup(NM_CAST_STRV_CC(strv), (len), (deep_copied)) +#define nm_strv_dup(strv, len, deep_copied) \ + _nm_strv_dup(NM_CAST_STRV_CC(strv), (len), (deep_copied)) -const char **_nm_utils_strv_dup_packed(const char *const *strv, gssize len); +const char **_nm_strv_dup_packed(const char *const *strv, gssize len); -#define nm_utils_strv_dup_packed(strv, len) _nm_utils_strv_dup_packed(NM_CAST_STRV_CC(strv), (len)) +#define nm_strv_dup_packed(strv, len) _nm_strv_dup_packed(NM_CAST_STRV_CC(strv), (len)) -#define nm_utils_strv_dup_shallow_maybe_a(alloca_maxlen, strv, len, to_free) \ +#define nm_strv_dup_shallow_maybe_a(alloca_maxlen, strv, len, to_free) \ ({ \ const char *const *const _strv = NM_CAST_STRV_CC(strv); \ const gssize _len = (len); \ @@ -1994,6 +2125,28 @@ nm_g_array_unref(GArray *arr) g_array_unref(arr); } +#define nm_g_array_first(arr, type) \ + ({ \ + GArray *const _arr = (arr); \ + guint _len; \ + \ + nm_assert(_arr); \ + _len = _arr->len; \ + nm_assert(_len > 0); \ + &g_array_index(arr, type, 0); \ + }) + +#define nm_g_array_last(arr, type) \ + ({ \ + GArray *const _arr = (arr); \ + guint _len; \ + \ + nm_assert(_arr); \ + _len = _arr->len; \ + nm_assert(_len > 0); \ + &g_array_index(arr, type, _len - 1u); \ + }) + #define nm_g_array_append_new(arr, type) \ ({ \ GArray *const _arr = (arr); \ @@ -2091,17 +2244,17 @@ GPtrArray *_nm_g_ptr_array_copy(GPtrArray * array, * Note that the @element_free_func MUST correspond to free function set in @array. */ #if GLIB_CHECK_VERSION(2, 62, 0) - #define nm_g_ptr_array_copy(array, func, user_data, element_free_func) \ - ({ \ - _nm_unused GDestroyNotify const _element_free_func = (element_free_func); \ - \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS; \ - g_ptr_array_copy((array), (func), (user_data)); \ - G_GNUC_END_IGNORE_DEPRECATIONS; \ - }) +#define nm_g_ptr_array_copy(array, func, user_data, element_free_func) \ + ({ \ + _nm_unused GDestroyNotify const _element_free_func = (element_free_func); \ + \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; \ + g_ptr_array_copy((array), (func), (user_data)); \ + G_GNUC_END_IGNORE_DEPRECATIONS; \ + }) #else - #define nm_g_ptr_array_copy(array, func, user_data, element_free_func) \ - _nm_g_ptr_array_copy((array), (func), (user_data), (element_free_func)) +#define nm_g_ptr_array_copy(array, func, user_data, element_free_func) \ + _nm_g_ptr_array_copy((array), (func), (user_data), (element_free_func)) #endif /*****************************************************************************/ @@ -2165,7 +2318,7 @@ gssize nm_utils_ptrarray_find_binary_search_range(gconstpointer * list, gssize * out_idx_first, gssize * out_idx_last); -#define nm_utils_strv_find_binary_search(strv, len, needle) \ +#define nm_strv_find_binary_search(strv, len, needle) \ ({ \ const char *const *const _strv = NM_CAST_STRV_CC(strv); \ const gsize _len = (len); \ @@ -2192,16 +2345,89 @@ gssize nm_utils_ptrarray_find_first(gconstpointer *list, gssize len, gconstpoint /*****************************************************************************/ -void _nm_utils_strv_sort(const char **strv, gssize len); -#define nm_utils_strv_sort(strv, len) _nm_utils_strv_sort(NM_CAST_STRV_MC(strv), len) +void _nm_strv_sort(const char **strv, gssize len); +#define nm_strv_sort(strv, len) _nm_strv_sort(NM_CAST_STRV_MC(strv), len) + +int _nm_strv_cmp_n(const char *const *strv1, gssize len1, const char *const *strv2, gssize len2); + +#define nm_strv_cmp_n(strv1, len1, strv2, len2) \ + _nm_strv_cmp_n(NM_CAST_STRV_CC(strv1), (len1), NM_CAST_STRV_CC(strv2), (len2)) + +/* This is like nm_strv_cmp_n(). The difference is that a NULL strv array (strv=NULL,len=-1) + * is treated the same as an empty one (with len=0). */ +#define nm_strv_cmp_n_null(strv1, len1, strv2, len2) \ + ({ \ + const char *const *const _strv1 = NM_CAST_STRV_CC(strv1); \ + const char *const *const _strv2 = NM_CAST_STRV_CC(strv2); \ + const gssize _len1 = (len1); \ + const gssize _len2 = (len2); \ + \ + _nm_strv_cmp_n(_strv1, \ + (_len1 >= 0 ? _len1 : (_strv1 ? -1 : 0)), \ + _strv2, \ + (_len2 >= 0 ? _len2 : (_strv2 ? -1 : 0))); \ + }) + +#define nm_strv_equal_n(strv1, len1, strv2, len2) \ + (nm_strv_cmp_n((strv1), (len1), (strv2), (len2)) == 0) -int -_nm_utils_strv_cmp_n(const char *const *strv1, gssize len1, const char *const *strv2, gssize len2); +#define nm_strv_equal(strv1, strv2) nm_strv_equal_n((strv1), -1, (strv2), -1) -#define nm_utils_strv_cmp_n(strv1, len1, strv2, len2) \ - _nm_utils_strv_cmp_n(NM_CAST_STRV_CC(strv1), (len1), NM_CAST_STRV_CC(strv2), (len2)) +#define nm_strv_equal_n_null(strv1, len1, strv2, len2) \ + (nm_strv_cmp_n_null((strv1), (len1), (strv2), (len2)) == 0) -#define nm_utils_strv_equal(strv1, strv2) (nm_utils_strv_cmp_n((strv1), -1, (strv2), -1) == 0) +/*****************************************************************************/ + +/* nm_arr_insert_at() does @arr[@idx] = @value, but first memmove's + * the elements @arr[@idx..@len-1] one element up. That means, @arr currently + * has @len valid elements, but it must have space for one more element, + * which will be overwritten. + * + * The use case is to have a sorted array (nm_strv_find_binary_search()) and + * to insert the element at he desired index. The caller must make sure that + * @len is large enough to contain one more element. */ +#define nm_arr_insert_at(arr, len, idx, value) \ + G_STMT_START \ + { \ + typeof(*(arr)) *const _arr = (arr); \ + typeof(len) _len = (len); \ + typeof(idx) _idx = (idx); \ + const gsize _len2 = (_len); \ + const gsize _idx2 = (_idx); \ + \ + nm_assert(_arr); \ + nm_assert(_NM_INT_NOT_NEGATIVE(_len)); \ + nm_assert(_NM_INT_NOT_NEGATIVE(_idx)); \ + nm_assert(_idx <= _len); \ + \ + if (_idx2 != _len2) \ + memmove(&_arr[_idx2 + 1u], &_arr[_idx2], sizeof(_arr[0]) * (_len2 - _idx2)); \ + \ + _arr[_idx2] = (value); \ + } \ + G_STMT_END + +/* nm_arr_remove_at() removes the element at arr[idx], by memmove'ing + * the elements from arr[idx+1..len-1] down. All it does is one memmove(), + * if there is anything to move. */ +#define nm_arr_remove_at(arr, len, idx) \ + G_STMT_START \ + { \ + typeof(*(arr)) *const _arr = (arr); \ + typeof(len) _len = (len); \ + typeof(idx) _idx = (idx); \ + const gsize _len2 = (_len); \ + const gsize _idx2 = (_idx); \ + \ + nm_assert(_arr); \ + nm_assert(_len > 0); \ + nm_assert(_NM_INT_NOT_NEGATIVE(_idx)); \ + nm_assert(_idx < _len); \ + \ + if (_idx2 != _len2 - 1u) \ + memmove(&_arr[_idx2], &_arr[_idx2 + 1u], sizeof(_arr[0]) * ((_len2 - 1u) - _idx2)); \ + } \ + G_STMT_END /*****************************************************************************/ @@ -2406,7 +2632,7 @@ nm_strv_ptrarray_find_first(const GPtrArray *strv, const char *str) { if (!strv) return -1; - return nm_utils_strv_find_first((char **) strv->pdata, strv->len, str); + return nm_strv_find_first((const char *const *) strv->pdata, strv->len, str); } static inline gboolean @@ -2418,14 +2644,14 @@ nm_strv_ptrarray_contains(const GPtrArray *strv, const char *str) static inline int nm_strv_ptrarray_cmp(const GPtrArray *a, const GPtrArray *b) { - /* nm_utils_strv_cmp_n() will treat NULL and empty arrays the same. + /* nm_strv_cmp_n() will treat NULL and empty arrays the same. * That means, an empty strv array can both be represented by NULL * and an array of length zero. * If you need to distinguish between these case, do that yourself. */ - return nm_utils_strv_cmp_n((const char *const *) nm_g_ptr_array_pdata(a), - nm_g_ptr_array_len(a), - (const char *const *) nm_g_ptr_array_pdata(b), - nm_g_ptr_array_len(b)); + return nm_strv_cmp_n((const char *const *) nm_g_ptr_array_pdata(a), + nm_g_ptr_array_len(a), + (const char *const *) nm_g_ptr_array_pdata(b), + nm_g_ptr_array_len(b)); } /*****************************************************************************/ @@ -2750,7 +2976,7 @@ guint nm_utils_parse_debug_string(const char *string, const GDebugKey *keys, gui /*****************************************************************************/ static inline gboolean -nm_utils_strdup_reset(char **dst, const char *src) +nm_strdup_reset(char **dst, const char *src) { char *old; @@ -2765,12 +2991,12 @@ nm_utils_strdup_reset(char **dst, const char *src) } static inline gboolean -nm_utils_strdup_reset_take(char **dst, char *src) +nm_strdup_reset_take(char **dst, char *src) { char *old; nm_assert(dst); - nm_assert(src != *dst); + nm_assert(!src || src != *dst); if (nm_streq0(*dst, src)) { if (src) @@ -2854,7 +3080,7 @@ nm_strvarray_get_strv_non_empty_dup(GArray *arr, guint *length) NM_SET_OUT(length, arr->len); strv = &g_array_index(arr, const char *, 0); - return nm_utils_strv_dup(strv, arr->len, TRUE); + return nm_strv_dup(strv, arr->len, TRUE); } static inline const char *const * @@ -2988,6 +3214,8 @@ void nm_crypto_md5_hash(const guint8 *salt, char *nm_utils_get_process_exit_status_desc(int status); +gboolean nm_utils_validate_hostname(const char *hostname); + /*****************************************************************************/ void nm_utils_thread_local_register_destroy(gpointer tls_data, GDestroyNotify destroy_notify); diff --git a/src/libnm-glib-aux/nm-test-utils.h b/src/libnm-glib-aux/nm-test-utils.h index ff8eb606..253aaf0e 100644 --- a/src/libnm-glib-aux/nm-test-utils.h +++ b/src/libnm-glib-aux/nm-test-utils.h @@ -81,8 +81,8 @@ *******************************************************************************/ #if defined(NM_ASSERT_NO_MSG) && NM_ASSERT_NO_MSG - #undef g_return_if_fail_warning - #undef g_assertion_message_expr +#undef g_return_if_fail_warning +#undef g_assertion_message_expr #endif #include @@ -693,42 +693,42 @@ nmtst_test_quick(void) } #if GLIB_CHECK_VERSION(2, 34, 0) - #undef g_test_expect_message - #define g_test_expect_message(...) \ - G_STMT_START \ - { \ - g_assert(nmtst_initialized()); \ - if (__nmtst_internal.assert_logging && __nmtst_internal.no_expect_message) { \ - g_debug("nmtst: assert-logging: g_test_expect_message %s", \ - G_STRINGIFY((__VA_ARGS__))); \ - } else { \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - g_test_expect_message(__VA_ARGS__); \ - G_GNUC_END_IGNORE_DEPRECATIONS \ - } \ - } \ - G_STMT_END - #undef g_test_assert_expected_messages_internal - #define g_test_assert_expected_messages_internal(domain, file, line, func) \ - G_STMT_START \ - { \ - const char *_domain = (domain); \ - const char *_file = (file); \ - const char *_func = (func); \ - int _line = (line); \ - \ - if (__nmtst_internal.assert_logging && __nmtst_internal.no_expect_message) \ - g_debug("nmtst: assert-logging: g_test_assert_expected_messages(%s, %s:%d, %s)", \ - _domain ?: "", \ - _file ?: "", \ - _line, \ - _func ?: ""); \ - \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - g_test_assert_expected_messages_internal(_domain, _file, _line, _func); \ - G_GNUC_END_IGNORE_DEPRECATIONS \ - } \ - G_STMT_END +#undef g_test_expect_message +#define g_test_expect_message(...) \ + G_STMT_START \ + { \ + g_assert(nmtst_initialized()); \ + if (__nmtst_internal.assert_logging && __nmtst_internal.no_expect_message) { \ + g_debug("nmtst: assert-logging: g_test_expect_message %s", \ + G_STRINGIFY((__VA_ARGS__))); \ + } else { \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + g_test_expect_message(__VA_ARGS__); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + } \ + } \ + G_STMT_END +#undef g_test_assert_expected_messages_internal +#define g_test_assert_expected_messages_internal(domain, file, line, func) \ + G_STMT_START \ + { \ + const char *_domain = (domain); \ + const char *_file = (file); \ + const char *_func = (func); \ + int _line = (line); \ + \ + if (__nmtst_internal.assert_logging && __nmtst_internal.no_expect_message) \ + g_debug("nmtst: assert-logging: g_test_assert_expected_messages(%s, %s:%d, %s)", \ + _domain ?: "", \ + _file ?: "", \ + _line, \ + _func ?: ""); \ + \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + g_test_assert_expected_messages_internal(_domain, _file, _line, _func); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + } \ + G_STMT_END #endif #define NMTST_EXPECT(domain, level, msg) g_test_expect_message(domain, level, msg) @@ -1032,7 +1032,7 @@ nmtst_rand_perm_strv(const char *const *strv) /* this returns a (scrambled) SHALLOW copy of the strv array! */ n = NM_PTRARRAY_LEN(strv); - res = (const char **) (nm_utils_strv_dup(strv, n, FALSE) ?: g_new0(char *, 1)); + res = (const char **) (nm_strv_dup(strv, n, FALSE) ?: g_new0(char *, 1)); nmtst_rand_perm(NULL, res, res, sizeof(char *), n); return res; } @@ -1238,7 +1238,7 @@ _nmtst_main_loop_quit_on_notify(GObject *object, GParamSpec *pspec, gpointer use g_main_loop_quit(loop); } -#define nmtst_main_loop_quit_on_notify ((GCallback) _nmtst_main_loop_quit_on_notify) +#define nmtst_main_loop_quit_on_notify (G_CALLBACK(_nmtst_main_loop_quit_on_notify)) #define nmtst_main_context_iterate_until_full(context, timeout_msec, poll_msec, condition) \ ({ \ @@ -1458,6 +1458,19 @@ next:; /*****************************************************************************/ +/* uses an expression statement to copy and return @arg. The use is for functions + * like nmtst_inet4_from_string(), which return a static (thread-local) variable. + * If you use such a statement twice, the result will be overwritten. The macro + * prevents that. */ +#define NMTST_COPY(arg) \ + ({ \ + typeof(arg) _arg = (arg); \ + \ + _arg; \ + }) + +/*****************************************************************************/ + #define __define_nmtst_static(NUM, SIZE) \ static inline const char *nmtst_static_##SIZE##_##NUM(const char *str) \ { \ @@ -1475,9 +1488,9 @@ __define_nmtst_static(01, 1024) __define_nmtst_static(02, 1024) __define_nmtst_s #if defined(__NM_UTILS_H__) || defined(NM_UTILS_H) - #define NMTST_UUID_INIT(uuid) \ - gs_free char * _nmtst_hidden_##uuid = nm_utils_uuid_generate(); \ - const char *const uuid = _nmtst_hidden_##uuid +#define NMTST_UUID_INIT(uuid) \ + gs_free char * _nmtst_hidden_##uuid = nm_utils_uuid_generate(); \ + const char *const uuid = _nmtst_hidden_##uuid static inline const char *nmtst_uuid_generate(void) { @@ -1819,13 +1832,13 @@ _nmtst_assert_resolve_relative_path_equals(const char *f1, #ifdef __NETWORKMANAGER_LOGGING_H__ - #define NMTST_EXPECT_NM(level, msg) NMTST_EXPECT("NetworkManager", level, msg) +#define NMTST_EXPECT_NM(level, msg) NMTST_EXPECT("NetworkManager", level, msg) - #define NMTST_EXPECT_NM_ERROR(msg) NMTST_EXPECT_NM(G_LOG_LEVEL_MESSAGE, "* [*] " msg) - #define NMTST_EXPECT_NM_WARN(msg) NMTST_EXPECT_NM(G_LOG_LEVEL_MESSAGE, "* [*] " msg) - #define NMTST_EXPECT_NM_INFO(msg) NMTST_EXPECT_NM(G_LOG_LEVEL_INFO, "* [*] " msg) - #define NMTST_EXPECT_NM_DEBUG(msg) NMTST_EXPECT_NM(G_LOG_LEVEL_DEBUG, "* [*] " msg) - #define NMTST_EXPECT_NM_TRACE(msg) NMTST_EXPECT_NM(G_LOG_LEVEL_DEBUG, "* [*] " msg) +#define NMTST_EXPECT_NM_ERROR(msg) NMTST_EXPECT_NM(G_LOG_LEVEL_MESSAGE, "* [*] " msg) +#define NMTST_EXPECT_NM_WARN(msg) NMTST_EXPECT_NM(G_LOG_LEVEL_MESSAGE, "* [*] " msg) +#define NMTST_EXPECT_NM_INFO(msg) NMTST_EXPECT_NM(G_LOG_LEVEL_INFO, "* [*] " msg) +#define NMTST_EXPECT_NM_DEBUG(msg) NMTST_EXPECT_NM(G_LOG_LEVEL_DEBUG, "* [*] " msg) +#define NMTST_EXPECT_NM_TRACE(msg) NMTST_EXPECT_NM(G_LOG_LEVEL_DEBUG, "* [*] " msg) static inline void nmtst_init_with_logging(int *argc, char ***argv, const char *log_level, const char *log_domains) @@ -1982,16 +1995,38 @@ nmtst_assert_route_attribute_boolean(NMIPRoute *route, const char *name, gboolea #if (defined(__NM_SIMPLE_CONNECTION_H__) && defined(__NM_SETTING_CONNECTION_H__)) \ || (defined(NM_CONNECTION_H)) +#define nmtst_connection_assert_setting(connection, gtype) \ + ({ \ + const GType _gtype = (gtype); \ + gpointer _ptr; \ + \ + _ptr = nm_connection_get_setting((connection), (_gtype)); \ + g_assert(NM_IS_SETTING(_ptr)); \ + g_assert(G_OBJECT_TYPE(_ptr) == _gtype); \ + _ptr; \ + }) + +#define nmtst_connection_assert_no_setting(connection, gtype) \ + G_STMT_START \ + { \ + const GType _gtype = (gtype); \ + gpointer _ptr; \ + \ + _ptr = nm_connection_get_setting((connection), (_gtype)); \ + g_assert(!_ptr); \ + } \ + G_STMT_END + static inline NMConnection * nmtst_clone_connection(NMConnection *connection) { g_assert(NM_IS_CONNECTION(connection)); - #if defined(__NM_SIMPLE_CONNECTION_H__) +#if defined(__NM_SIMPLE_CONNECTION_H__) return nm_simple_connection_new_clone(connection); - #else +#else return nm_connection_duplicate(connection); - #endif +#endif } static inline NMConnection * @@ -2015,11 +2050,11 @@ nmtst_create_minimal_connection(const char * id, if (type) { GType type_g; - #if defined(__NM_SIMPLE_CONNECTION_H__) +#if defined(__NM_SIMPLE_CONNECTION_H__) type_g = nm_setting_lookup_type(type); - #else +#else type_g = nm_connection_lookup_setting_type(type); - #endif +#endif g_assert(type_g != G_TYPE_INVALID); @@ -2027,11 +2062,11 @@ nmtst_create_minimal_connection(const char * id, g_assert(NM_IS_SETTING(s_base)); } - #if defined(__NM_SIMPLE_CONNECTION_H__) +#if defined(__NM_SIMPLE_CONNECTION_H__) con = nm_simple_connection_new(); - #else +#else con = nm_connection_new(); - #endif +#endif g_assert(con); @@ -2096,8 +2131,8 @@ _nmtst_connection_normalize(NMConnection *connection, ...) return was_modified; } - #define nmtst_connection_normalize(connection, ...) \ - _nmtst_connection_normalize(connection, ##__VA_ARGS__, NULL) +#define nmtst_connection_normalize(connection, ...) \ + _nmtst_connection_normalize(connection, ##__VA_ARGS__, NULL) static inline NMConnection * _nmtst_connection_duplicate_and_normalize(NMConnection *connection, ...) @@ -2112,8 +2147,8 @@ _nmtst_connection_duplicate_and_normalize(NMConnection *connection, ...) return connection; } - #define nmtst_connection_duplicate_and_normalize(connection, ...) \ - _nmtst_connection_duplicate_and_normalize(connection, ##__VA_ARGS__, NULL) +#define nmtst_connection_duplicate_and_normalize(connection, ...) \ + _nmtst_connection_duplicate_and_normalize(connection, ##__VA_ARGS__, NULL) static inline void nmtst_assert_connection_equals(NMConnection *a, @@ -2152,7 +2187,7 @@ nmtst_assert_connection_equals(NMConnection *a, } } - #ifdef __NM_KEYFILE_INTERNAL_H__ +#ifdef __NM_KEYFILE_INTERNAL_H__ { nm_auto_unref_keyfile GKeyFile *kf_a = NULL, *kf_b = NULL; gs_free char * str_a = NULL, *str_b = NULL; @@ -2174,7 +2209,7 @@ nmtst_assert_connection_equals(NMConnection *a, "the difference*):\n%s", str_b); } - #endif +#endif } g_assert(compare); g_assert(!out_settings); @@ -2308,8 +2343,8 @@ nmtst_assert_setting_verifies(NMSetting *setting) g_assert(success); } - #if defined(__NM_SIMPLE_CONNECTION_H__) && NM_CHECK_VERSION(1, 10, 0) \ - && (!defined(NM_VERSION_MAX_ALLOWED) || NM_VERSION_MAX_ALLOWED >= NM_VERSION_1_10) +#if defined(__NM_SIMPLE_CONNECTION_H__) && NM_CHECK_VERSION(1, 10, 0) \ + && (!defined(NM_VERSION_MAX_ALLOWED) || NM_VERSION_MAX_ALLOWED >= NM_VERSION_1_10) static inline void _nmtst_assert_connection_has_settings(NMConnection *connection, gboolean has_at_least, @@ -2363,13 +2398,13 @@ _nmtst_assert_connection_has_settings(NMConnection *connection, has_str); } } - #define nmtst_assert_connection_has_settings(connection, ...) \ - _nmtst_assert_connection_has_settings((connection), TRUE, TRUE, __VA_ARGS__, NULL) - #define nmtst_assert_connection_has_settings_at_least(connection, ...) \ - _nmtst_assert_connection_has_settings((connection), TRUE, FALSE, __VA_ARGS__, NULL) - #define nmtst_assert_connection_has_settings_at_most(connection, ...) \ - _nmtst_assert_connection_has_settings((connection), FALSE, TRUE, __VA_ARGS__, NULL) - #endif +#define nmtst_assert_connection_has_settings(connection, ...) \ + _nmtst_assert_connection_has_settings((connection), TRUE, TRUE, __VA_ARGS__, NULL) +#define nmtst_assert_connection_has_settings_at_least(connection, ...) \ + _nmtst_assert_connection_has_settings((connection), TRUE, FALSE, __VA_ARGS__, NULL) +#define nmtst_assert_connection_has_settings_at_most(connection, ...) \ + _nmtst_assert_connection_has_settings((connection), FALSE, TRUE, __VA_ARGS__, NULL) +#endif static inline void nmtst_assert_setting_verify_fails(NMSetting *setting, @@ -2485,8 +2520,8 @@ nmtst_assert_hwaddr_equals(gconstpointer hwaddr1, hwaddr1_len); } } - #define nmtst_assert_hwaddr_equals(hwaddr1, hwaddr1_len, expected) \ - nmtst_assert_hwaddr_equals(hwaddr1, hwaddr1_len, expected, __FILE__, __LINE__) +#define nmtst_assert_hwaddr_equals(hwaddr1, hwaddr1_len, expected) \ + nmtst_assert_hwaddr_equals(hwaddr1, hwaddr1_len, expected, __FILE__, __LINE__) #endif #if defined(__NM_SIMPLE_CONNECTION_H__) && defined(__NM_SETTING_CONNECTION_H__) \ @@ -2547,89 +2582,89 @@ _nmtst_variant_new_vardict(int dummy, ...) return g_variant_builder_end(&builder); } - #define nmtst_variant_new_vardict(...) _nmtst_variant_new_vardict(0, __VA_ARGS__, NULL) - - #define nmtst_assert_variant_is_of_type(variant, type) \ - G_STMT_START \ - { \ - GVariant *_variantx = (variant); \ - \ - g_assert(_variantx); \ - g_assert(g_variant_is_of_type(_variantx, (type))); \ - } \ - G_STMT_END - - #define nmtst_assert_variant_uint32(variant, val) \ - G_STMT_START \ - { \ - GVariant *_variant = (variant); \ - \ - nmtst_assert_variant_is_of_type(_variant, G_VARIANT_TYPE_UINT32); \ - g_assert_cmpint(g_variant_get_uint32(_variant), ==, (val)); \ - } \ - G_STMT_END - - #define nmtst_assert_variant_string(variant, str) \ - G_STMT_START \ - { \ - gsize _l; \ - GVariant * _variant = (variant); \ - const char *_str = (str); \ +#define nmtst_variant_new_vardict(...) _nmtst_variant_new_vardict(0, __VA_ARGS__, NULL) + +#define nmtst_assert_variant_is_of_type(variant, type) \ + G_STMT_START \ + { \ + GVariant *_variantx = (variant); \ + \ + g_assert(_variantx); \ + g_assert(g_variant_is_of_type(_variantx, (type))); \ + } \ + G_STMT_END + +#define nmtst_assert_variant_uint32(variant, val) \ + G_STMT_START \ + { \ + GVariant *_variant = (variant); \ + \ + nmtst_assert_variant_is_of_type(_variant, G_VARIANT_TYPE_UINT32); \ + g_assert_cmpint(g_variant_get_uint32(_variant), ==, (val)); \ + } \ + G_STMT_END + +#define nmtst_assert_variant_string(variant, str) \ + G_STMT_START \ + { \ + gsize _l; \ + GVariant * _variant = (variant); \ + const char *_str = (str); \ + \ + nmtst_assert_variant_is_of_type(_variant, G_VARIANT_TYPE_STRING); \ + g_assert(_str); \ + g_assert_cmpstr(g_variant_get_string(_variant, &_l), ==, _str); \ + g_assert_cmpint(_l, ==, strlen(_str)); \ + } \ + G_STMT_END + +#ifdef __NM_SHARED_UTILS_H__ +#define _nmtst_assert_variant_bytestring_cmp_str(_ptr, _ptr2, _len) \ + G_STMT_START \ + { \ + if (memcmp(_ptr2, _ptr, _len) != 0) { \ + gs_free char *_x1 = NULL; \ + gs_free char *_x2 = NULL; \ + const char * _xx1; \ + const char * _xx2; \ + \ + _xx1 = nm_utils_buf_utf8safe_escape(_ptr, \ + _len, \ + NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_CTRL, \ + &_x1); \ + _xx2 = nm_utils_buf_utf8safe_escape(_ptr2, \ + _len, \ + NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_CTRL, \ + &_x2); \ + g_assert_cmpstr(_xx1, ==, _xx2); \ + g_assert_not_reached(); \ + } \ + } \ + G_STMT_END +#else +#define _nmtst_assert_variant_bytestring_cmp_str(_ptr, _ptr2, _len) \ + G_STMT_START {} \ + G_STMT_END +#endif + +#define nmtst_assert_variant_bytestring(variant, ptr, len) \ + G_STMT_START \ + { \ + GVariant * _variant = (variant); \ + gconstpointer _ptr = (ptr); \ + gconstpointer _ptr2; \ + gsize _len = (len); \ + gsize _len2; \ \ - nmtst_assert_variant_is_of_type(_variant, G_VARIANT_TYPE_STRING); \ - g_assert(_str); \ - g_assert_cmpstr(g_variant_get_string(_variant, &_l), ==, _str); \ - g_assert_cmpint(_l, ==, strlen(_str)); \ + nmtst_assert_variant_is_of_type(_variant, G_VARIANT_TYPE_BYTESTRING); \ + _ptr2 = g_variant_get_fixed_array(_variant, &_len2, 1); \ + g_assert_cmpint(_len2, ==, _len); \ + if (_len != 0 && _ptr) { \ + _nmtst_assert_variant_bytestring_cmp_str(_ptr, _ptr2, _len); \ + g_assert_cmpmem(_ptr2, _len2, _ptr, _len); \ } \ - G_STMT_END - - #ifdef __NM_SHARED_UTILS_H__ - #define _nmtst_assert_variant_bytestring_cmp_str(_ptr, _ptr2, _len) \ - G_STMT_START \ - { \ - if (memcmp(_ptr2, _ptr, _len) != 0) { \ - gs_free char *_x1 = NULL; \ - gs_free char *_x2 = NULL; \ - const char * _xx1; \ - const char * _xx2; \ - \ - _xx1 = nm_utils_buf_utf8safe_escape(_ptr, \ - _len, \ - NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_CTRL, \ - &_x1); \ - _xx2 = nm_utils_buf_utf8safe_escape(_ptr2, \ - _len, \ - NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_CTRL, \ - &_x2); \ - g_assert_cmpstr(_xx1, ==, _xx2); \ - g_assert_not_reached(); \ - } \ - } \ - G_STMT_END - #else - #define _nmtst_assert_variant_bytestring_cmp_str(_ptr, _ptr2, _len) \ - G_STMT_START {} \ - G_STMT_END - #endif - - #define nmtst_assert_variant_bytestring(variant, ptr, len) \ - G_STMT_START \ - { \ - GVariant * _variant = (variant); \ - gconstpointer _ptr = (ptr); \ - gconstpointer _ptr2; \ - gsize _len = (len); \ - gsize _len2; \ - \ - nmtst_assert_variant_is_of_type(_variant, G_VARIANT_TYPE_BYTESTRING); \ - _ptr2 = g_variant_get_fixed_array(_variant, &_len2, 1); \ - g_assert_cmpint(_len2, ==, _len); \ - if (_len != 0 && _ptr) { \ - _nmtst_assert_variant_bytestring_cmp_str(_ptr, _ptr2, _len); \ - g_assert_cmpmem(_ptr2, _len2, _ptr, _len); \ - } \ - } \ - G_STMT_END + } \ + G_STMT_END typedef enum { NMTST_VARIANT_EDITOR_CONNECTION, @@ -2637,120 +2672,117 @@ typedef enum { NMTST_VARIANT_EDITOR_PROPERTY } NmtstVariantEditorPhase; - #define NMTST_VARIANT_EDITOR(__connection_variant, __code) \ - G_STMT_START \ - { \ - GVariantIter __connection_iter, *__setting_iter; \ - GVariantBuilder __connection_builder, __setting_builder; \ - const char * __cur_setting_name, *__cur_property_name; \ - GVariant * __property_val; \ - NmtstVariantEditorPhase __phase; \ - \ - g_variant_builder_init(&__connection_builder, NM_VARIANT_TYPE_CONNECTION); \ - g_variant_iter_init(&__connection_iter, __connection_variant); \ - \ - __phase = NMTST_VARIANT_EDITOR_CONNECTION; \ - __cur_setting_name = NULL; \ - __cur_property_name = NULL; \ - __code; \ - while (g_variant_iter_next(&__connection_iter, \ - "{&sa{sv}}", \ - &__cur_setting_name, \ - &__setting_iter)) { \ - g_variant_builder_init(&__setting_builder, NM_VARIANT_TYPE_SETTING); \ - __phase = NMTST_VARIANT_EDITOR_SETTING; \ - __cur_property_name = NULL; \ - __code; \ - \ - while (__cur_setting_name \ - && g_variant_iter_next(__setting_iter, \ - "{&sv}", \ - &__cur_property_name, \ - &__property_val)) { \ - __phase = NMTST_VARIANT_EDITOR_PROPERTY; \ - __code; \ - \ - if (__cur_property_name) { \ - g_variant_builder_add(&__setting_builder, \ - "{sv}", \ - __cur_property_name, \ - __property_val); \ - } \ - g_variant_unref(__property_val); \ - } \ - \ - if (__cur_setting_name) \ - g_variant_builder_add(&__connection_builder, \ - "{sa{sv}}", \ - __cur_setting_name, \ - &__setting_builder); \ - else \ - g_variant_builder_clear(&__setting_builder); \ - g_variant_iter_free(__setting_iter); \ - } \ - \ - g_variant_unref(__connection_variant); \ - \ - __connection_variant = g_variant_builder_end(&__connection_builder); \ - } \ - G_STMT_END; - - #define NMTST_VARIANT_ADD_SETTING(__setting_name, __setting_variant) \ - G_STMT_START \ - { \ - if (__phase == NMTST_VARIANT_EDITOR_CONNECTION) \ - g_variant_builder_add(&__connection_builder, \ - "{s@a{sv}}", \ - __setting_name, \ - __setting_variant); \ - } \ - G_STMT_END - - #define NMTST_VARIANT_DROP_SETTING(__setting_name) \ - G_STMT_START \ - { \ - if (__phase == NMTST_VARIANT_EDITOR_SETTING && __cur_setting_name) { \ - if (!strcmp(__cur_setting_name, __setting_name)) \ - __cur_setting_name = NULL; \ - } \ - } \ - G_STMT_END - - #define NMTST_VARIANT_ADD_PROPERTY(__setting_name, __property_name, __format_string, __value) \ - G_STMT_START \ - { \ - if (__phase == NMTST_VARIANT_EDITOR_SETTING) { \ - if (!strcmp(__cur_setting_name, __setting_name)) { \ - g_variant_builder_add(&__setting_builder, \ - "{sv}", \ - __property_name, \ - g_variant_new(__format_string, __value)); \ - } \ - } \ - } \ - G_STMT_END - - #define NMTST_VARIANT_DROP_PROPERTY(__setting_name, __property_name) \ - G_STMT_START \ - { \ - if (__phase == NMTST_VARIANT_EDITOR_PROPERTY && __cur_property_name) { \ - if (!strcmp(__cur_setting_name, __setting_name) \ - && !strcmp(__cur_property_name, __property_name)) \ - __cur_property_name = NULL; \ +#define NMTST_VARIANT_EDITOR(__connection_variant, __code) \ + G_STMT_START \ + { \ + GVariantIter __connection_iter, *__setting_iter; \ + GVariantBuilder __connection_builder, __setting_builder; \ + const char * __cur_setting_name, *__cur_property_name; \ + GVariant * __property_val; \ + NmtstVariantEditorPhase __phase; \ + \ + g_variant_builder_init(&__connection_builder, NM_VARIANT_TYPE_CONNECTION); \ + g_variant_iter_init(&__connection_iter, __connection_variant); \ + \ + __phase = NMTST_VARIANT_EDITOR_CONNECTION; \ + __cur_setting_name = NULL; \ + __cur_property_name = NULL; \ + __code; \ + while (g_variant_iter_next(&__connection_iter, \ + "{&sa{sv}}", \ + &__cur_setting_name, \ + &__setting_iter)) { \ + g_variant_builder_init(&__setting_builder, NM_VARIANT_TYPE_SETTING); \ + __phase = NMTST_VARIANT_EDITOR_SETTING; \ + __cur_property_name = NULL; \ + __code; \ + \ + while (__cur_setting_name \ + && g_variant_iter_next(__setting_iter, \ + "{&sv}", \ + &__cur_property_name, \ + &__property_val)) { \ + __phase = NMTST_VARIANT_EDITOR_PROPERTY; \ + __code; \ + \ + if (__cur_property_name) { \ + g_variant_builder_add(&__setting_builder, \ + "{sv}", \ + __cur_property_name, \ + __property_val); \ + } \ + g_variant_unref(__property_val); \ } \ + \ + if (__cur_setting_name) \ + g_variant_builder_add(&__connection_builder, \ + "{sa{sv}}", \ + __cur_setting_name, \ + &__setting_builder); \ + else \ + g_variant_builder_clear(&__setting_builder); \ + g_variant_iter_free(__setting_iter); \ } \ - G_STMT_END - - #define NMTST_VARIANT_CHANGE_PROPERTY(__setting_name, \ - __property_name, \ - __format_string, \ - __value) \ - G_STMT_START \ - { \ - NMTST_VARIANT_DROP_PROPERTY(__setting_name, __property_name); \ - NMTST_VARIANT_ADD_PROPERTY(__setting_name, __property_name, __format_string, __value); \ - } \ - G_STMT_END + \ + g_variant_unref(__connection_variant); \ + \ + __connection_variant = g_variant_builder_end(&__connection_builder); \ + } \ + G_STMT_END; + +#define NMTST_VARIANT_ADD_SETTING(__setting_name, __setting_variant) \ + G_STMT_START \ + { \ + if (__phase == NMTST_VARIANT_EDITOR_CONNECTION) \ + g_variant_builder_add(&__connection_builder, \ + "{s@a{sv}}", \ + __setting_name, \ + __setting_variant); \ + } \ + G_STMT_END + +#define NMTST_VARIANT_DROP_SETTING(__setting_name) \ + G_STMT_START \ + { \ + if (__phase == NMTST_VARIANT_EDITOR_SETTING && __cur_setting_name) { \ + if (!strcmp(__cur_setting_name, __setting_name)) \ + __cur_setting_name = NULL; \ + } \ + } \ + G_STMT_END + +#define NMTST_VARIANT_ADD_PROPERTY(__setting_name, __property_name, __format_string, __value) \ + G_STMT_START \ + { \ + if (__phase == NMTST_VARIANT_EDITOR_SETTING) { \ + if (!strcmp(__cur_setting_name, __setting_name)) { \ + g_variant_builder_add(&__setting_builder, \ + "{sv}", \ + __property_name, \ + g_variant_new(__format_string, __value)); \ + } \ + } \ + } \ + G_STMT_END + +#define NMTST_VARIANT_DROP_PROPERTY(__setting_name, __property_name) \ + G_STMT_START \ + { \ + if (__phase == NMTST_VARIANT_EDITOR_PROPERTY && __cur_property_name) { \ + if (!strcmp(__cur_setting_name, __setting_name) \ + && !strcmp(__cur_property_name, __property_name)) \ + __cur_property_name = NULL; \ + } \ + } \ + G_STMT_END + +#define NMTST_VARIANT_CHANGE_PROPERTY(__setting_name, __property_name, __format_string, __value) \ + G_STMT_START \ + { \ + NMTST_VARIANT_DROP_PROPERTY(__setting_name, __property_name); \ + NMTST_VARIANT_ADD_PROPERTY(__setting_name, __property_name, __format_string, __value); \ + } \ + G_STMT_END #endif /* __NM_CONNECTION_H__ */ @@ -2857,4 +2889,20 @@ nmtst_ip_address_new(int addr_family, const char *str) /*****************************************************************************/ +#define nmtst_gbytes_from_arr(...) \ + ({ \ + const guint8 _arr[] = {__VA_ARGS__}; \ + \ + g_bytes_new(_arr, sizeof(_arr)); \ + }) + +#define nmtst_gbytes_from_str(str) \ + ({ \ + const char *const _str = (str); \ + \ + g_bytes_new(_str, strlen(_str)); \ + }) + +/*****************************************************************************/ + #endif /* __NM_TEST_UTILS_H__ */ diff --git a/src/libnm-glib-aux/nm-uuid.c b/src/libnm-glib-aux/nm-uuid.c index 2c6e218a..e7f67c70 100644 --- a/src/libnm-glib-aux/nm-uuid.c +++ b/src/libnm-glib-aux/nm-uuid.c @@ -9,6 +9,13 @@ /*****************************************************************************/ +const NMUuid nm_uuid_ns_zero = + NM_UUID_INIT(00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00); + +/* arbitrarily chosen namespace UUID for nm_uuid_generate_from_strings() */ +const NMUuid nm_uuid_ns_1 = + NM_UUID_INIT(b4, 25, e9, fb, 75, 98, 44, b4, 9e, 3b, 5a, 2e, 3a, aa, 49, 05); + char * nm_uuid_unparse_case(const NMUuid *uuid, char out_str[static 37], gboolean upper_case) { @@ -171,7 +178,7 @@ nm_uuid_is_valid_nmlegacy(const char *str) } /* While we accept here bogus strings as UUIDs, they must contain only - * hexdigits and '-', and they must be eithr 36 or 40 chars long. */ + * hexdigits and '-', and they must be either 36 or 40 chars long. */ if ((num_dashes == 4) && (p - str == 36)) return TRUE; @@ -234,16 +241,20 @@ nm_uuid_is_valid_nm(const char *str, nm_assert(strlen(str) < G_N_ELEMENTS(str_lower)); /* normalize first to lower-case. */ - g_strlcpy(str_lower, str, sizeof(str_lower)); - for (i = 0; str_lower[i]; i++) - str_lower[i] = g_ascii_tolower(str_lower[i]); + for (i = 0; str[i]; i++) { + nm_assert(i < G_N_ELEMENTS(str_lower)); + str_lower[i] = g_ascii_tolower(str[i]); + } + nm_assert(i < G_N_ELEMENTS(str_lower)); + str_lower[i] = '\0'; /* The namespace UUID is chosen randomly. */ - nm_uuid_generate_from_string(&uuid, - str_lower, - -1, - NM_UUID_TYPE_VERSION5, - "4e72f709-ca95-4405-9053-1f43294a618c"); + nm_uuid_generate_from_string( + &uuid, + str_lower, + -1, + NM_UUID_TYPE_VERSION5, + &NM_UUID_INIT(4e, 72, f7, 09, ca, 95, 44, 05, 90, 53, 1f, 43, 29, 4a, 61, 8c)); nm_uuid_unparse(&uuid, out_normalized_str); } return TRUE; @@ -299,11 +310,11 @@ nm_uuid_generate_random_str(char buf[static 37]) * Returns: the input @uuid. This function cannot fail. **/ NMUuid * -nm_uuid_generate_from_string(NMUuid * uuid, - const char *s, - gssize slen, - NMUuidType uuid_type, - gpointer type_args) +nm_uuid_generate_from_string(NMUuid * uuid, + const char * s, + gssize slen, + NMUuidType uuid_type, + const NMUuid *type_args) { g_return_val_if_fail(uuid, FALSE); g_return_val_if_fail(slen == 0 || s, FALSE); @@ -313,26 +324,20 @@ nm_uuid_generate_from_string(NMUuid * uuid, switch (uuid_type) { case NM_UUID_TYPE_LEGACY: - g_return_val_if_fail(!type_args, NULL); + nm_assert(!type_args); nm_crypto_md5_hash(NULL, 0, (guint8 *) s, slen, (guint8 *) uuid, sizeof(*uuid)); break; case NM_UUID_TYPE_VERSION3: case NM_UUID_TYPE_VERSION5: { - NMUuid ns_uuid; - - if (type_args) { - /* type_args can be a name space UUID. Interpret it as (char *) */ - if (!nm_uuid_parse(type_args, &ns_uuid)) - g_return_val_if_reached(NULL); - } else - ns_uuid = (NMUuid){}; + if (!type_args) + type_args = &nm_uuid_ns_zero; if (uuid_type == NM_UUID_TYPE_VERSION3) { nm_crypto_md5_hash((guint8 *) s, slen, - (guint8 *) &ns_uuid, - sizeof(ns_uuid), + (guint8 *) type_args, + sizeof(*type_args), (guint8 *) uuid, sizeof(*uuid)); } else { @@ -343,7 +348,7 @@ nm_uuid_generate_from_string(NMUuid * uuid, } digest; sum = g_checksum_new(G_CHECKSUM_SHA1); - g_checksum_update(sum, (guchar *) &ns_uuid, sizeof(ns_uuid)); + g_checksum_update(sum, (guchar *) type_args, sizeof(*type_args)); g_checksum_update(sum, (guchar *) s, slen); nm_utils_checksum_get_digest(sum, digest.sha1); @@ -377,10 +382,10 @@ nm_uuid_generate_from_string(NMUuid * uuid, * object's #NMSettingConnection:id: property **/ char * -nm_uuid_generate_from_string_str(const char *s, - gssize slen, - NMUuidType uuid_type, - gpointer type_args) +nm_uuid_generate_from_string_str(const char * s, + gssize slen, + NMUuidType uuid_type, + const NMUuid *type_args) { NMUuid uuid; @@ -405,7 +410,7 @@ char * nm_uuid_generate_from_strings(const char *string1, ...) { if (!string1) - return nm_uuid_generate_from_string_str(NULL, 0, NM_UUID_TYPE_VERSION3, NM_UUID_NS1); + return nm_uuid_generate_from_string_str(NULL, 0, NM_UUID_TYPE_VERSION3, &nm_uuid_ns_1); { nm_auto_str_buf NMStrBuf str = NM_STR_BUF_INIT(NM_UTILS_GET_NEXT_REALLOC_SIZE_104, FALSE); @@ -425,6 +430,6 @@ nm_uuid_generate_from_strings(const char *string1, ...) return nm_uuid_generate_from_string_str(nm_str_buf_get_str_unsafe(&str), str.len, NM_UUID_TYPE_VERSION3, - NM_UUID_NS1); + &nm_uuid_ns_1); } } diff --git a/src/libnm-glib-aux/nm-uuid.h b/src/libnm-glib-aux/nm-uuid.h index 10302bd8..504ec789 100644 --- a/src/libnm-glib-aux/nm-uuid.h +++ b/src/libnm-glib-aux/nm-uuid.h @@ -7,6 +7,28 @@ typedef struct _NMUuid { guint8 uuid[16]; } NMUuid; +#define NM_UUID_INIT_ZERO() ((NMUuid){.uuid = {0}}) + +#define NM_UUID_INIT(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) \ + ((NMUuid){ \ + .uuid = {(0x##a0), \ + (0x##a1), \ + (0x##a2), \ + (0x##a3), \ + (0x##a4), \ + (0x##a5), \ + (0x##a6), \ + (0x##a7), \ + (0x##a8), \ + (0x##a9), \ + (0x##a10), \ + (0x##a11), \ + (0x##a12), \ + (0x##a13), \ + (0x##a14), \ + (0x##a15)}, \ + }) + char *nm_uuid_unparse_case(const NMUuid *uuid, char out_str[static 37], gboolean upper_case); static inline char * @@ -73,25 +95,30 @@ char *nm_uuid_generate_random_str(char buf[static 37]); /*****************************************************************************/ +extern const NMUuid nm_uuid_ns_zero; +extern const NMUuid nm_uuid_ns_1; + +#define NM_UUID_NS_ZERO "00000000-0000-0000-0000-000000000000" +#define NM_UUID_NS_1 "b425e9fb-7598-44b4-9e3b-5a2e3aaa4905" + +/*****************************************************************************/ + typedef enum { NM_UUID_TYPE_LEGACY = 0, NM_UUID_TYPE_VERSION3 = 3, NM_UUID_TYPE_VERSION5 = 5, } NMUuidType; -NMUuid *nm_uuid_generate_from_string(NMUuid * uuid, - const char *s, - gssize slen, - NMUuidType uuid_type, - gpointer type_args); - -char *nm_uuid_generate_from_string_str(const char *s, - gssize slen, - NMUuidType uuid_type, - gpointer type_args); +NMUuid *nm_uuid_generate_from_string(NMUuid * uuid, + const char * s, + gssize slen, + NMUuidType uuid_type, + const NMUuid *type_args); -/* arbitrarily chosen namespace UUID for nm_uuid_generate_from_strings() */ -#define NM_UUID_NS1 "b425e9fb-7598-44b4-9e3b-5a2e3aaa4905" +char *nm_uuid_generate_from_string_str(const char * s, + gssize slen, + NMUuidType uuid_type, + const NMUuid *type_args); char *nm_uuid_generate_from_strings(const char *string1, ...) G_GNUC_NULL_TERMINATED; diff --git a/src/libnm-glib-aux/nm-value-type.h b/src/libnm-glib-aux/nm-value-type.h index f1cce480..0addeec6 100644 --- a/src/libnm-glib-aux/nm-value-type.h +++ b/src/libnm-glib-aux/nm-value-type.h @@ -7,13 +7,27 @@ #define __NM_VALUE_TYPE_H__ typedef enum _nm_packed { + NM_VALUE_TYPE_NONE = 0, NM_VALUE_TYPE_UNSPEC = 1, NM_VALUE_TYPE_BOOL = 2, NM_VALUE_TYPE_INT32 = 3, NM_VALUE_TYPE_INT = 4, NM_VALUE_TYPE_INT64 = 5, - NM_VALUE_TYPE_UINT64 = 6, - NM_VALUE_TYPE_STRING = 7, + NM_VALUE_TYPE_UINT32 = 6, + NM_VALUE_TYPE_UINT = 7, + NM_VALUE_TYPE_UINT64 = 8, + + /* Flags are for G_TYPE_FLAGS. That is, internally they are tracked + * as a guint, they have a g_param_spec_flags() property and they are + * serialized on D-Bus as "u". */ + NM_VALUE_TYPE_FLAGS = 9, + + /* G_TYPE_ENUM */ + NM_VALUE_TYPE_ENUM = 10, + + NM_VALUE_TYPE_STRING = 11, + + NM_VALUE_TYPE_BYTES = 12, } NMValueType; /*****************************************************************************/ @@ -35,37 +49,37 @@ typedef union { } NMValueTypUnion; - /* Set the NMValueTypUnion. You can also assign the member directly. +/* Set the NMValueTypUnion. You can also assign the member directly. * The only purpose of this is that it also returns a pointer to the * union. So, you can do * * ptr = NM_VALUE_TYP_UNION_SET (&value_typ_union_storage, v_bool, TRUE); */ - #define NM_VALUE_TYP_UNION_SET(_arg, _type, _val) \ - ({ \ - NMValueTypUnion *const _arg2 = (_arg); \ - \ - *_arg2 = (NMValueTypUnion){ \ - ._type = (_val), \ - }; \ - _arg2; \ - }) +#define NM_VALUE_TYP_UNION_SET(_arg, _type, _val) \ + ({ \ + NMValueTypUnion *const _arg2 = (_arg); \ + \ + *_arg2 = (NMValueTypUnion){ \ + ._type = (_val), \ + }; \ + _arg2; \ + }) typedef struct { bool has; NMValueTypUnion val; } NMValueTypUnioMaybe; - #define NM_VALUE_TYP_UNIO_MAYBE_SET(_arg, _type, _val) \ - ({ \ - NMValueTypUnioMaybe *const _arg2 = (_arg); \ - \ - *_arg2 = (NMValueTypUnioMaybe){ \ - .has = TRUE, \ - .val._type = (_val), \ - }; \ - _arg2; \ - }) +#define NM_VALUE_TYP_UNIO_MAYBE_SET(_arg, _type, _val) \ + ({ \ + NMValueTypUnioMaybe *const _arg2 = (_arg); \ + \ + *_arg2 = (NMValueTypUnioMaybe){ \ + .has = TRUE, \ + .val._type = (_val), \ + }; \ + _arg2; \ + }) /*****************************************************************************/ @@ -80,16 +94,27 @@ nm_value_type_cmp(NMValueType value_type, gconstpointer p_a, gconstpointer p_b) NM_CMP_DIRECT(*((const gint32 *) p_a), *((const gint32 *) p_b)); return 0; case NM_VALUE_TYPE_INT: + case NM_VALUE_TYPE_ENUM: NM_CMP_DIRECT(*((const int *) p_a), *((const int *) p_b)); return 0; case NM_VALUE_TYPE_INT64: NM_CMP_DIRECT(*((const gint64 *) p_a), *((const gint64 *) p_b)); return 0; + case NM_VALUE_TYPE_UINT32: + NM_CMP_DIRECT(*((const guint32 *) p_a), *((const guint32 *) p_b)); + return 0; + case NM_VALUE_TYPE_UINT: + case NM_VALUE_TYPE_FLAGS: + NM_CMP_DIRECT(*((const guint *) p_a), *((const guint *) p_b)); + return 0; case NM_VALUE_TYPE_UINT64: NM_CMP_DIRECT(*((const guint64 *) p_a), *((const guint64 *) p_b)); return 0; case NM_VALUE_TYPE_STRING: return nm_strcmp0(*((const char *const *) p_a), *((const char *const *) p_b)); + case NM_VALUE_TYPE_BYTES: + return nm_g_bytes_equal0(*((const GBytes *const *) p_a), *((const GBytes *const *) p_b)); + case NM_VALUE_TYPE_NONE: case NM_VALUE_TYPE_UNSPEC: break; } @@ -114,21 +139,39 @@ nm_value_type_copy(NMValueType value_type, gpointer dst, gconstpointer src) (*((gint32 *) dst) = *((const gint32 *) src)); return; case NM_VALUE_TYPE_INT: + case NM_VALUE_TYPE_ENUM: (*((int *) dst) = *((const int *) src)); return; case NM_VALUE_TYPE_INT64: (*((gint64 *) dst) = *((const gint64 *) src)); return; + case NM_VALUE_TYPE_UINT32: + (*((guint32 *) dst) = *((const guint32 *) src)); + return; + case NM_VALUE_TYPE_UINT: + case NM_VALUE_TYPE_FLAGS: + (*((guint *) dst) = *((const guint *) src)); + return; case NM_VALUE_TYPE_UINT64: (*((guint64 *) dst) = *((const guint64 *) src)); return; case NM_VALUE_TYPE_STRING: /* self assignment safe! */ if (*((char **) dst) != *((const char *const *) src)) { - g_free(*((char **) dst)); + _nm_unused char *old = *((char **) dst); + *((char **) dst) = g_strdup(*((const char *const *) src)); } return; + case NM_VALUE_TYPE_BYTES: + /* self assignment safe! */ + if (*((GBytes **) dst) != *((const GBytes *const *) src)) { + _nm_unused gs_unref_bytes GBytes *old = *((GBytes **) dst); + + *((GBytes **) dst) = g_bytes_ref(*((GBytes *const *) src)); + } + return; + case NM_VALUE_TYPE_NONE: case NM_VALUE_TYPE_UNSPEC: break; } @@ -151,12 +194,16 @@ nm_value_type_get_from_variant(NMValueType value_type, case NM_VALUE_TYPE_INT64: *((gint64 *) dst) = g_variant_get_int64(variant); return; + case NM_VALUE_TYPE_UINT32: + *((guint32 *) dst) = g_variant_get_uint32(variant); + return; case NM_VALUE_TYPE_UINT64: *((guint64 *) dst) = g_variant_get_uint64(variant); return; case NM_VALUE_TYPE_STRING: if (clone) { - g_free(*((char **) dst)); + _nm_unused gs_free char *old = *((char **) dst); + *((char **) dst) = g_variant_dup_string(variant, NULL); } else { /* we don't clone the string, nor free the previous value. */ @@ -164,11 +211,16 @@ nm_value_type_get_from_variant(NMValueType value_type, } return; + case NM_VALUE_TYPE_BYTES: case NM_VALUE_TYPE_INT: - /* "int" also does not have a define variant type, because it's not - * clear how many bits we would need. */ + case NM_VALUE_TYPE_UINT: + case NM_VALUE_TYPE_ENUM: + case NM_VALUE_TYPE_FLAGS: + /* These types don't have a defined variant type, because it's not + * clear how many bits we would need or how to handle the type. */ /* fall-through */ + case NM_VALUE_TYPE_NONE: case NM_VALUE_TYPE_UNSPEC: break; } @@ -178,7 +230,8 @@ nm_value_type_get_from_variant(NMValueType value_type, static inline GVariant * nm_value_type_to_variant(NMValueType value_type, gconstpointer src) { - const char *v_string; + const char * v_string; + const GBytes *v_bytes; switch (value_type) { case NM_VALUE_TYPE_BOOL: @@ -187,17 +240,26 @@ nm_value_type_to_variant(NMValueType value_type, gconstpointer src) return g_variant_new_int32(*((const gint32 *) src)); case NM_VALUE_TYPE_INT64: return g_variant_new_int64(*((const gint64 *) src)); + case NM_VALUE_TYPE_UINT32: + return g_variant_new_uint32(*((const guint32 *) src)); case NM_VALUE_TYPE_UINT64: return g_variant_new_uint64(*((const guint64 *) src)); case NM_VALUE_TYPE_STRING: v_string = *((const char *const *) src); return v_string ? g_variant_new_string(v_string) : NULL; + case NM_VALUE_TYPE_BYTES: + v_bytes = *((const GBytes *const *) src); + return v_bytes ? nm_g_bytes_to_variant_ay(v_bytes) : NULL; case NM_VALUE_TYPE_INT: - /* "int" also does not have a define variant type, because it's not - * clear how many bits we would need. */ + case NM_VALUE_TYPE_UINT: + case NM_VALUE_TYPE_ENUM: + case NM_VALUE_TYPE_FLAGS: + /* These types don't have a defined variant type, because it's not + * clear how many bits we would need or how to handle the type. */ /* fall-through */ + case NM_VALUE_TYPE_NONE: case NM_VALUE_TYPE_UNSPEC: break; } @@ -215,16 +277,24 @@ nm_value_type_get_variant_type(NMValueType value_type) return G_VARIANT_TYPE_INT32; case NM_VALUE_TYPE_INT64: return G_VARIANT_TYPE_INT64; + case NM_VALUE_TYPE_UINT32: + return G_VARIANT_TYPE_UINT32; case NM_VALUE_TYPE_UINT64: return G_VARIANT_TYPE_UINT64; case NM_VALUE_TYPE_STRING: return G_VARIANT_TYPE_STRING; + case NM_VALUE_TYPE_BYTES: + return G_VARIANT_TYPE_BYTESTRING; case NM_VALUE_TYPE_INT: - /* "int" also does not have a define variant type, because it's not - * clear how many bits we would need. */ + case NM_VALUE_TYPE_UINT: + case NM_VALUE_TYPE_ENUM: + case NM_VALUE_TYPE_FLAGS: + /* These types don't have a defined variant type, because it's not + * clear how many bits we would need or how to handle the type. */ /* fall-through */ + case NM_VALUE_TYPE_NONE: case NM_VALUE_TYPE_UNSPEC: break; } @@ -232,7 +302,7 @@ nm_value_type_get_variant_type(NMValueType value_type) return NULL; } - /*****************************************************************************/ +/*****************************************************************************/ #endif /* NM_VALUE_TYPE_DEFINE_FUNCTIONS */ diff --git a/src/libnm-glib-aux/tests/test-shared-general.c b/src/libnm-glib-aux/tests/test-shared-general.c index 4a7b6790..9674f228 100644 --- a/src/libnm-glib-aux/tests/test-shared-general.c +++ b/src/libnm-glib-aux/tests/test-shared-general.c @@ -30,6 +30,31 @@ G_STATIC_ASSERT(4 == _nm_alignof(NMIPAddr)); /*****************************************************************************/ +static void +test_nm_static_assert(void) +{ + int v1[NM_STATIC_ASSERT_EXPR_1(1)]; + typeof(NM_STATIC_ASSERT_EXPR_1(1)) v_int; + int * p_int; + + G_STATIC_ASSERT(sizeof(v1) == sizeof(int)); + G_STATIC_ASSERT(NM_STATIC_ASSERT_EXPR_1(1) == 1); + G_STATIC_ASSERT(NM_STATIC_ASSERT_EXPR_1(NM_STATIC_ASSERT_EXPR_1(1)) == 1); + G_STATIC_ASSERT(NM_STATIC_ASSERT_EXPR_1(NM_STATIC_ASSERT_EXPR_1(NM_STATIC_ASSERT_EXPR_1(1))) + == 1); + + g_assert(NM_STATIC_ASSERT_EXPR_1(2) == 1); + + p_int = &v_int; + g_assert(&v_int == p_int); + + (void) NM_STATIC_ASSERT_EXPR_1(2 > 1); + + NM_STATIC_ASSERT_EXPR_VOID(2 > 1); +} + +/*****************************************************************************/ + static void test_gpid(void) { @@ -390,8 +415,8 @@ test_strv_cmp(void) _strv_cmp_fuzz_input((a1), _l1, &_a1_free_shallow, &_a1_free_deep, &_a1, &_a1x); \ _strv_cmp_fuzz_input((a2), _l2, &_a2_free_shallow, &_a2_free_deep, &_a2, &_a2x); \ \ - _c1 = nm_utils_strv_cmp_n(_a1, _l1, _a2, _l2); \ - _c2 = nm_utils_strv_cmp_n(_a2, _l2, _a1, _l1); \ + _c1 = nm_strv_cmp_n(_a1, _l1, _a2, _l2); \ + _c2 = nm_strv_cmp_n(_a2, _l2, _a1, _l1); \ if (equal) { \ g_assert_cmpint(_c1, ==, 0); \ g_assert_cmpint(_c2, ==, 0); \ @@ -402,8 +427,8 @@ test_strv_cmp(void) \ /* Compare with self. _strv_cmp_fuzz_input() randomly swapped the arguments (_a1 and _a1x). * Either way, the arrays must compare equal to their semantically equal alternative. */ \ - g_assert_cmpint(nm_utils_strv_cmp_n(_a1, _l1, _a1x, _l1), ==, 0); \ - g_assert_cmpint(nm_utils_strv_cmp_n(_a2, _l2, _a2x, _l2), ==, 0); \ + g_assert_cmpint(nm_strv_cmp_n(_a1, _l1, _a1x, _l1), ==, 0); \ + g_assert_cmpint(nm_strv_cmp_n(_a2, _l2, _a2x, _l2), ==, 0); \ \ _strv_cmp_free_deep(_a1_free_deep, _l1); \ _strv_cmp_free_deep(_a2_free_deep, _l2); \ @@ -1006,10 +1031,10 @@ again: else g_assert(!data); - g_assert(nm_utils_strv_cmp_n((const char *const *) strv->pdata, - strv->len, - (const char *const *) strv2->pdata, - strv2->len) + g_assert(nm_strv_cmp_n((const char *const *) strv->pdata, + strv->len, + (const char *const *) strv2->pdata, + strv2->len) == 0); } } @@ -1097,15 +1122,14 @@ test_strv_dup_packed(void) g_assert(NM_PTRARRAY_LEN(strv_src) == strv_len); strv_cpy = - nm_utils_strv_dup_packed(strv_src, - nmtst_get_rand_bool() ? (gssize) strv_len : (gssize) -1); + nm_strv_dup_packed(strv_src, nmtst_get_rand_bool() ? (gssize) strv_len : (gssize) -1); if (strv_len == 0) g_assert(!strv_cpy); else g_assert(strv_cpy); g_assert(NM_PTRARRAY_LEN(strv_cpy) == strv_len); if (strv_cpy) - g_assert(nm_utils_strv_equal(strv_cpy, strv_src)); + g_assert(nm_strv_equal(strv_cpy, strv_src)); } } @@ -1395,6 +1419,7 @@ main(int argc, char **argv) { nmtst_init(&argc, &argv, TRUE); + g_test_add_func("/general/test_nm_static_assert", test_nm_static_assert); g_test_add_func("/general/test_gpid", test_gpid); g_test_add_func("/general/test_monotonic_timestamp", test_monotonic_timestamp); g_test_add_func("/general/test_nmhash", test_nmhash); diff --git a/src/libnm-log-core/nm-logging.c b/src/libnm-log-core/nm-logging.c index 2ab0d92e..6d2c085e 100644 --- a/src/libnm-log-core/nm-logging.c +++ b/src/libnm-log-core/nm-logging.c @@ -18,8 +18,8 @@ #include #if SYSTEMD_JOURNAL - #define SD_JOURNAL_SUPPRESS_LOCATION - #include +#define SD_JOURNAL_SUPPRESS_LOCATION +#include #endif #include "libnm-glib-aux/nm-logging-base.h" @@ -296,7 +296,7 @@ nm_logging_setup(const char *level, const char *domains, char **bad_domains, GEr } } - domains_v = nm_utils_strsplit_set(domains, ", "); + domains_v = nm_strsplit_set(domains, ", "); for (i_d = 0; domains_v && domains_v[i_d]; i_d++) { const char * s = domains_v[i_d]; const char * p; @@ -525,16 +525,16 @@ again: buf_p = _all_logging_domains_to_str; buf_l = sizeof(_all_logging_domains_to_str); - nm_utils_strbuf_append_str(&buf_p, &buf_l, LOGD_DEFAULT_STRING); + nm_strbuf_append_str(&buf_p, &buf_l, LOGD_DEFAULT_STRING); for (diter = &domain_desc[0]; diter->name; diter++) { - nm_utils_strbuf_append_c(&buf_p, &buf_l, ','); - nm_utils_strbuf_append_str(&buf_p, &buf_l, diter->name); + nm_strbuf_append_c(&buf_p, &buf_l, ','); + nm_strbuf_append_str(&buf_p, &buf_l, diter->name); if (diter->num == LOGD_DHCP6) - nm_utils_strbuf_append_str(&buf_p, &buf_l, "," LOGD_DHCP_STRING); + nm_strbuf_append_str(&buf_p, &buf_l, "," LOGD_DHCP_STRING); else if (diter->num == LOGD_IP6) - nm_utils_strbuf_append_str(&buf_p, &buf_l, "," LOGD_IP_STRING); + nm_strbuf_append_str(&buf_p, &buf_l, "," LOGD_IP_STRING); } - nm_utils_strbuf_append_str(&buf_p, &buf_l, LOGD_ALL_STRING); + nm_strbuf_append_str(&buf_p, &buf_l, LOGD_ALL_STRING); /* Did you modify the logging domains (or their names)? Adjust the size of * _all_logging_domains_to_str buffer above to have the exact size. */ @@ -600,7 +600,7 @@ _iovec_set_string(struct iovec *iov, const char *str) _iovec_set(iov, str, strlen(str)); } - #define _iovec_set_string_literal(iov, str) _iovec_set((iov), "" str "", NM_STRLEN(str)) +#define _iovec_set_string_literal(iov, str) _iovec_set((iov), "" str "", NM_STRLEN(str)) _nm_printf(3, 4) static void _iovec_set_format(struct iovec *iov, char ** iov_free, @@ -618,34 +618,34 @@ _nm_printf(3, 4) static void _iovec_set_format(struct iovec *iov, *iov_free = str; } - #define _iovec_set_format_a(iov, reserve_extra, format, ...) \ - G_STMT_START \ - { \ - const gsize _size = (reserve_extra) + (NM_STRLEN(format) + 3); \ - char *const _buf = g_alloca(_size); \ - int _len; \ - \ - G_STATIC_ASSERT_EXPR((reserve_extra) + (NM_STRLEN(format) + 3) <= 96); \ - \ - _len = g_snprintf(_buf, _size, "" format "", ##__VA_ARGS__); \ - \ - nm_assert(_len >= 0); \ - nm_assert(_len < _size); \ - nm_assert(_len == strlen(_buf)); \ - \ - _iovec_set((iov), _buf, _len); \ - } \ - G_STMT_END - - #define _iovec_set_format_str_a(iov, max_str_len, format, str_arg) \ - G_STMT_START \ - { \ - const char *_str_arg = (str_arg); \ - \ - nm_assert(_str_arg &&strlen(_str_arg) < (max_str_len)); \ - _iovec_set_format_a((iov), (max_str_len), format, str_arg); \ - } \ - G_STMT_END +#define _iovec_set_format_a(iov, reserve_extra, format, ...) \ + G_STMT_START \ + { \ + const gsize _size = (reserve_extra) + (NM_STRLEN(format) + 3); \ + char *const _buf = g_alloca(_size); \ + int _len; \ + \ + G_STATIC_ASSERT_EXPR((reserve_extra) + (NM_STRLEN(format) + 3) <= 96); \ + \ + _len = g_snprintf(_buf, _size, "" format "", ##__VA_ARGS__); \ + \ + nm_assert(_len >= 0); \ + nm_assert(_len < _size); \ + nm_assert(_len == strlen(_buf)); \ + \ + _iovec_set((iov), _buf, _len); \ + } \ + G_STMT_END + +#define _iovec_set_format_str_a(iov, max_str_len, format, str_arg) \ + G_STMT_START \ + { \ + const char *_str_arg = (str_arg); \ + \ + nm_assert(_str_arg &&strlen(_str_arg) < (max_str_len)); \ + _iovec_set_format_a((iov), (max_str_len), format, str_arg); \ + } \ + G_STMT_END #endif @@ -746,13 +746,13 @@ _nm_log_impl(const char *file, s_log_domains = s_log_domains_buf; l_log_domains = sizeof(s_log_domains_buf); - nm_utils_strbuf_append_str(&s_log_domains, &l_log_domains, "NM_LOG_DOMAINS="); + nm_strbuf_append_str(&s_log_domains, &l_log_domains, "NM_LOG_DOMAINS="); for (diter = &domain_desc[0]; dom_all != 0 && diter->name; diter++) { if (!NM_FLAGS_ANY(dom_all, diter->num)) continue; if (dom_all != domain) - nm_utils_strbuf_append_c(&s_log_domains, &l_log_domains, ','); - nm_utils_strbuf_append_str(&s_log_domains, &l_log_domains, diter->name); + nm_strbuf_append_c(&s_log_domains, &l_log_domains, ','); + nm_strbuf_append_str(&s_log_domains, &l_log_domains, diter->name); dom_all &= ~diter->num; } nm_assert(l_log_domains > 0); diff --git a/src/libnm-log-core/nm-logging.h b/src/libnm-log-core/nm-logging.h index 8eecb7e4..80719675 100644 --- a/src/libnm-log-core/nm-logging.h +++ b/src/libnm-log-core/nm-logging.h @@ -8,7 +8,7 @@ #define __NETWORKMANAGER_LOGGING_H__ #ifdef __NM_TEST_UTILS_H__ - #error nm-test-utils.h must be included as last header +#error nm-test-utils.h must be included as last header #endif #include "libnm-glib-aux/nm-logging-fwd.h" diff --git a/src/libnm-platform/nm-linux-platform.c b/src/libnm-platform/nm-linux-platform.c index bcf94200..78df53e7 100644 --- a/src/libnm-platform/nm-linux-platform.c +++ b/src/libnm-platform/nm-linux-platform.c @@ -80,7 +80,7 @@ enum { TCA_DEF_UNSPEC, TCA_DEF_TM, TCA_DEF_PARMS, TCA_DEF_DATA, TCA_DEF_PAD, __T /*****************************************************************************/ #ifndef IFLA_PROMISCUITY - #define IFLA_PROMISCUITY 30 +#define IFLA_PROMISCUITY 30 #endif #define IFLA_NUM_TX_QUEUES 31 #define IFLA_NUM_RX_QUEUES 32 @@ -114,7 +114,7 @@ enum { TCA_DEF_UNSPEC, TCA_DEF_TM, TCA_DEF_PARMS, TCA_DEF_DATA, TCA_DEF_PAD, __T #define IFLA_IPTUN_PMTUDISC 10 #define __IFLA_IPTUN_MAX 19 #ifndef IFLA_IPTUN_MAX - #define IFLA_IPTUN_MAX (__IFLA_IPTUN_MAX - 1) +#define IFLA_IPTUN_MAX (__IFLA_IPTUN_MAX - 1) #endif #define IFLA_TUN_UNSPEC 0 @@ -136,7 +136,7 @@ G_STATIC_ASSERT(RTA_MAX == (__RTA_MAX - 1)); #define RTA_MAX (MAX((__RTA_MAX - 1), RTA_PREF)) #ifndef MACVLAN_FLAG_NOPROMISC - #define MACVLAN_FLAG_NOPROMISC 1 +#define MACVLAN_FLAG_NOPROMISC 1 #endif #define IP6_FLOWINFO_TCLASS_MASK 0x0FF00000 @@ -145,11 +145,13 @@ G_STATIC_ASSERT(RTA_MAX == (__RTA_MAX - 1)); #define IFLA_BR_VLAN_STATS_ENABLED 41 +#define IFLA_PERM_ADDRESS 54 + /*****************************************************************************/ /* Appeared in the kernel prior to 3.13 dated 19 January, 2014 */ #ifndef ARPHRD_6LOWPAN - #define ARPHRD_6LOWPAN 825 +#define ARPHRD_6LOWPAN 825 #endif /*****************************************************************************/ @@ -267,8 +269,8 @@ struct _ifla_vf_vlan_info { /* Appeared in the kernel 4.0 dated April 12, 2015 */ #ifndef BRIDGE_VLAN_INFO_RANGE_BEGIN - #define BRIDGE_VLAN_INFO_RANGE_BEGIN (1 << 3) /* VLAN is start of vlan range */ - #define BRIDGE_VLAN_INFO_RANGE_END (1 << 4) /* VLAN is end of vlan range */ +#define BRIDGE_VLAN_INFO_RANGE_BEGIN (1 << 3) /* VLAN is start of vlan range */ +#define BRIDGE_VLAN_INFO_RANGE_END (1 << 4) /* VLAN is end of vlan range */ #endif /*****************************************************************************/ @@ -582,25 +584,25 @@ wait_for_nl_response_to_string(WaitForNlResponseResult seq_result, switch (seq_result) { case WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN: - nm_utils_strbuf_append_str(&buf, &buf_size, "unknown"); + nm_strbuf_append_str(&buf, &buf_size, "unknown"); break; case WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK: - nm_utils_strbuf_append_str(&buf, &buf_size, "success"); + nm_strbuf_append_str(&buf, &buf_size, "success"); break; case WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_UNKNOWN: - nm_utils_strbuf_append_str(&buf, &buf_size, "failure"); + nm_strbuf_append_str(&buf, &buf_size, "failure"); break; default: if (seq_result < 0) { - nm_utils_strbuf_append(&buf, - &buf_size, - "failure %d (%s%s%s)", - -((int) seq_result), - nm_strerror_native(-((int) seq_result)), - errmsg ? " - " : "", - errmsg ?: ""); + nm_strbuf_append(&buf, + &buf_size, + "failure %d (%s%s%s)", + -((int) seq_result), + nm_strerror_native(-((int) seq_result)), + errmsg ? " - " : "", + errmsg ?: ""); } else - nm_utils_strbuf_append(&buf, &buf_size, "internal failure %d", (int) seq_result); + nm_strbuf_append(&buf, &buf_size, "internal failure %d", (int) seq_result); break; } return buf0; @@ -1277,15 +1279,6 @@ _parse_af_inet6(NMPlatform * platform, token_valid = TRUE; } - /* Hack to detect support addrgenmode of the kernel. We only parse - * netlink messages that we receive from kernel, hence this check - * is valid. */ - if (!_nm_platform_kernel_support_detected(NM_PLATFORM_KERNEL_SUPPORT_TYPE_USER_IPV6LL)) { - /* IFLA_INET6_ADDR_GEN_MODE was added in kernel 3.17, dated 5 October, 2014. */ - _nm_platform_kernel_support_init(NM_PLATFORM_KERNEL_SUPPORT_TYPE_USER_IPV6LL, - tb[IFLA_INET6_ADDR_GEN_MODE] ? 1 : -1); - } - if (tb[IFLA_INET6_ADDR_GEN_MODE]) { i6_addr_gen_mode_inv = _nm_platform_uint8_inv(nla_get_u8(tb[IFLA_INET6_ADDR_GEN_MODE])); if (i6_addr_gen_mode_inv == 0) { @@ -2305,7 +2298,7 @@ _wireguard_get_device_cb(struct nl_msg *msg, void *arg) { static const struct nla_policy policy[] = { [WGDEVICE_A_IFINDEX] = {.type = NLA_U32}, - [WGDEVICE_A_IFNAME] = {.type = NLA_NUL_STRING, .maxlen = IFNAMSIZ}, + [WGDEVICE_A_IFNAME] = {.type = NLA_STRING, .maxlen = IFNAMSIZ}, [WGDEVICE_A_PRIVATE_KEY] = {}, [WGDEVICE_A_PUBLIC_KEY] = {}, [WGDEVICE_A_FLAGS] = {.type = NLA_U32}, @@ -2935,6 +2928,7 @@ _new_from_nl_link(NMPlatform * platform, [IFLA_NET_NS_PID] = {.type = NLA_U32}, [IFLA_NET_NS_FD] = {.type = NLA_U32}, [IFLA_LINK_NETNSID] = {}, + [IFLA_PERM_ADDRESS] = {.type = NLA_UNSPEC}, }; const struct ifinfomsg *ifi; struct nlattr * tb[G_N_ELEMENTS(policy)]; @@ -2945,12 +2939,13 @@ _new_from_nl_link(NMPlatform * platform, gboolean * completed_from_cache = cache ? &completed_from_cache_val : NULL; const NMPObject * link_cached = NULL; const NMPObject * lnk_data = NULL; - gboolean address_complete_from_cache = TRUE; - gboolean broadcast_complete_from_cache = TRUE; - gboolean lnk_data_complete_from_cache = TRUE; - gboolean need_ext_data = FALSE; - gboolean af_inet6_token_valid = FALSE; - gboolean af_inet6_addr_gen_mode_valid = FALSE; + gboolean address_complete_from_cache = TRUE; + gboolean perm_address_complete_from_cache = TRUE; + gboolean broadcast_complete_from_cache = TRUE; + gboolean lnk_data_complete_from_cache = TRUE; + gboolean need_ext_data = FALSE; + gboolean af_inet6_token_valid = FALSE; + gboolean af_inet6_addr_gen_mode_valid = FALSE; if (!nlmsg_valid_hdr(nlh, sizeof(*ifi))) return NULL; @@ -3053,6 +3048,20 @@ _new_from_nl_link(NMPlatform * platform, address_complete_from_cache = FALSE; } + if (tb[IFLA_PERM_ADDRESS]) { + if (!_nm_platform_kernel_support_detected( + NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_PERM_ADDRESS)) { + /* support for IFLA_PERM_ADDRESS was added in f74877a5457d34d604dba6dbbb13c4c05bac8b93, + * kernel 5.6, 30 March 2020. + * + * We can only detect support if the attribute is present. A missing attribute + * is not conclusive. */ + _nm_platform_kernel_support_init(NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_PERM_ADDRESS, 1); + } + _nmp_link_address_set(&obj->link.l_perm_address, tb[IFLA_PERM_ADDRESS]); + perm_address_complete_from_cache = FALSE; + } + if (tb[IFLA_BROADCAST]) { _nmp_link_address_set(&obj->link.l_broadcast, tb[IFLA_BROADCAST]); broadcast_complete_from_cache = FALSE; @@ -3135,8 +3144,8 @@ _new_from_nl_link(NMPlatform * platform, if (completed_from_cache && (lnk_data_complete_from_cache || need_ext_data || address_complete_from_cache - || broadcast_complete_from_cache || !af_inet6_token_valid - || !af_inet6_addr_gen_mode_valid || !tb[IFLA_STATS64])) { + || perm_address_complete_from_cache || broadcast_complete_from_cache + || !af_inet6_token_valid || !af_inet6_addr_gen_mode_valid || !tb[IFLA_STATS64])) { _lookup_cached_link(cache, obj->link.ifindex, completed_from_cache, &link_cached); if (link_cached && link_cached->_link.netlink.is_in_netlink) { if (lnk_data_complete_from_cache && link_cached->link.type == obj->link.type @@ -3160,6 +3169,8 @@ _new_from_nl_link(NMPlatform * platform, if (address_complete_from_cache) obj->link.l_address = link_cached->link.l_address; + if (perm_address_complete_from_cache) + obj->link.l_perm_address = link_cached->link.l_perm_address; if (broadcast_complete_from_cache) obj->link.l_broadcast = link_cached->link.l_broadcast; if (!af_inet6_token_valid) @@ -3572,13 +3583,6 @@ rta_multipath_done:; obj->ip_route.lock_mtu = NM_FLAGS_HAS(lock, 1 << RTAX_MTU); if (!is_v4) { - if (!_nm_platform_kernel_support_detected(NM_PLATFORM_KERNEL_SUPPORT_TYPE_RTA_PREF)) { - /* Detect support for RTA_PREF by inspecting the netlink message. - * RTA_PREF was added in kernel 4.1, dated 21 June, 2015. */ - _nm_platform_kernel_support_init(NM_PLATFORM_KERNEL_SUPPORT_TYPE_RTA_PREF, - tb[RTA_PREF] ? 1 : -1); - } - if (tb[RTA_PREF]) obj->ip6_route.rt_pref = nla_get_u8(tb[RTA_PREF]); } @@ -3876,6 +3880,9 @@ _new_from_nl_qdisc(NMPlatform *platform, struct nlmsghdr *nlh, gboolean id_only) const struct tcmsg *tcm; nm_auto_nmpobj NMPObject *obj = NULL; + if (!nm_platform_get_cache_tc(platform)) + return NULL; + if (nlmsg_parse_arr(nlh, sizeof(*tcm), tb, policy) < 0) return NULL; @@ -3976,7 +3983,7 @@ _new_from_nl_qdisc(NMPlatform *platform, struct nlmsghdr *nlh, gboolean id_only) } static NMPObject * -_new_from_nl_tfilter(struct nlmsghdr *nlh, gboolean id_only) +_new_from_nl_tfilter(NMPlatform *platform, struct nlmsghdr *nlh, gboolean id_only) { static const struct nla_policy policy[] = { [TCA_KIND] = {.type = NLA_STRING}, @@ -3985,6 +3992,9 @@ _new_from_nl_tfilter(struct nlmsghdr *nlh, gboolean id_only) NMPObject * obj = NULL; const struct tcmsg *tcm; + if (!nm_platform_get_cache_tc(platform)) + return NULL; + if (nlmsg_parse_arr(nlh, sizeof(*tcm), tb, policy) < 0) return NULL; @@ -4055,7 +4065,7 @@ nmp_object_new_from_nl(NMPlatform * platform, case RTM_NEWTFILTER: case RTM_DELTFILTER: case RTM_GETTFILTER: - return _new_from_nl_tfilter(msghdr, id_only); + return _new_from_nl_tfilter(platform, msghdr, id_only); default: return NULL; } @@ -4064,7 +4074,7 @@ nmp_object_new_from_nl(NMPlatform * platform, /*****************************************************************************/ static gboolean -_nl_msg_new_link_set_afspec(struct nl_msg *msg, int addr_gen_mode, NMUtilsIPv6IfaceId *iid) +_nl_msg_new_link_set_afspec(struct nl_msg *msg, int addr_gen_mode, const NMUtilsIPv6IfaceId *iid) { struct nlattr *af_spec; struct nlattr *af_attr; @@ -4082,11 +4092,9 @@ _nl_msg_new_link_set_afspec(struct nl_msg *msg, int addr_gen_mode, NMUtilsIPv6If NLA_PUT_U8(msg, IFLA_INET6_ADDR_GEN_MODE, addr_gen_mode); if (iid) { - struct in6_addr i6_token = {.s6_addr = { - 0, - }}; + struct in6_addr i6_token = IN6ADDR_ANY_INIT; - nm_utils_ipv6_addr_set_interface_identifier(&i6_token, *iid); + nm_utils_ipv6_addr_set_interface_identifier(&i6_token, iid); NLA_PUT(msg, IFLA_INET6_TOKEN, sizeof(struct in6_addr), &i6_token); } @@ -5811,13 +5819,13 @@ delayed_action_to_string_full(DelayedActionType action_type, char * buf0 = buf; const DelayedActionWaitForNlResponseData *data; - nm_utils_strbuf_append_str(&buf, &buf_size, delayed_action_to_string(action_type)); + nm_strbuf_append_str(&buf, &buf_size, delayed_action_to_string(action_type)); switch (action_type) { case DELAYED_ACTION_TYPE_MASTER_CONNECTED: - nm_utils_strbuf_append(&buf, &buf_size, " (master-ifindex %d)", GPOINTER_TO_INT(user_data)); + nm_strbuf_append(&buf, &buf_size, " (master-ifindex %d)", GPOINTER_TO_INT(user_data)); break; case DELAYED_ACTION_TYPE_REFRESH_LINK: - nm_utils_strbuf_append(&buf, &buf_size, " (ifindex %d)", GPOINTER_TO_INT(user_data)); + nm_strbuf_append(&buf, &buf_size, " (ifindex %d)", GPOINTER_TO_INT(user_data)); break; case DELAYED_ACTION_TYPE_WAIT_FOR_NL_RESPONSE: data = user_data; @@ -5826,7 +5834,7 @@ delayed_action_to_string_full(DelayedActionType action_type, gint64 timeout = data->timeout_abs_ns - nm_utils_get_monotonic_timestamp_nsec(); char b[255]; - nm_utils_strbuf_append( + nm_strbuf_append( &buf, &buf_size, " (seq %u, timeout in %s%" G_GINT64_FORMAT ".%09" G_GINT64_FORMAT @@ -5841,7 +5849,7 @@ delayed_action_to_string_full(DelayedActionType action_type, ? wait_for_nl_response_to_string(data->seq_result, NULL, b, sizeof(b)) : ""); } else - nm_utils_strbuf_append_str(&buf, &buf_size, " (any)"); + nm_strbuf_append_str(&buf, &buf_size, " (any)"); break; default: nm_assert(!user_data); @@ -5934,7 +5942,7 @@ delayed_action_wait_for_nl_response_complete_check(NMPlatform * platf guint i; guint32 next_seq_number = 0; gint64 next_timeout_abs_ns = 0; - int now_ns = 0; + gint64 now_ns = 0; for (i = 0; i < priv->delayed_action.list_wait_for_nl_response->len;) { const DelayedActionWaitForNlResponseData *data = @@ -6904,27 +6912,6 @@ event_valid_msg(NMPlatform *platform, struct nl_msg *msg, gboolean handle_events msghdr = nlmsg_hdr(msg); - if (!_nm_platform_kernel_support_detected(NM_PLATFORM_KERNEL_SUPPORT_TYPE_EXTENDED_IFA_FLAGS) - && msghdr->nlmsg_type == RTM_NEWADDR) { - /* IFA_FLAGS is set for IPv4 and IPv6 addresses. It was added first to IPv6, - * but if we encounter an IPv4 address with IFA_FLAGS, we surely have support. */ - if (nlmsg_valid_hdr(msghdr, sizeof(struct ifaddrmsg)) - && NM_IN_SET(((struct ifaddrmsg *) nlmsg_data(msghdr))->ifa_family, - AF_INET, - AF_INET6)) { - /* see if the nl_msg contains the IFA_FLAGS attribute. If it does, - * we assume, that the kernel supports extended flags, IFA_F_MANAGETEMPADDR - * and IFA_F_NOPREFIXROUTE for IPv6. They were added together in kernel 3.14, - * dated 30 March, 2014. - * - * For IPv4, IFA_F_NOPREFIXROUTE was added later, but there is no easy - * way to detect kernel support. */ - _nm_platform_kernel_support_init( - NM_PLATFORM_KERNEL_SUPPORT_TYPE_EXTENDED_IFA_FLAGS, - !!nlmsg_find_attr(msghdr, sizeof(struct ifaddrmsg), IFA_FLAGS) ? 1 : -1); - } - } - if (!handle_events) return; @@ -7487,19 +7474,14 @@ link_change_flags(NMPlatform *platform, int ifindex, unsigned flags_mask, unsign } static int -link_set_user_ipv6ll_enabled(NMPlatform *platform, int ifindex, gboolean enabled) +link_set_inet6_addr_gen_mode(NMPlatform *platform, int ifindex, guint8 mode) { nm_auto_nlmsg struct nl_msg *nlmsg = NULL; - guint8 mode = enabled ? NM_IN6_ADDR_GEN_MODE_NONE : NM_IN6_ADDR_GEN_MODE_EUI64; + char sbuf[100]; _LOGD("link: change %d: user-ipv6ll: set IPv6 address generation mode to %s", ifindex, - nm_platform_link_inet6_addrgenmode2str(mode, NULL, 0)); - - if (!nm_platform_kernel_support_get(NM_PLATFORM_KERNEL_SUPPORT_TYPE_USER_IPV6LL)) { - _LOGD("link: change %d: user-ipv6ll: not supported", ifindex); - return -NME_PL_OPNOTSUPP; - } + nm_platform_link_inet6_addrgenmode2str(mode, sbuf, sizeof(sbuf))); nlmsg = _nl_msg_new_link(RTM_NEWLINK, 0, ifindex, NULL); if (!nlmsg || !_nl_msg_new_link_set_afspec(nlmsg, mode, NULL)) @@ -7509,7 +7491,7 @@ link_set_user_ipv6ll_enabled(NMPlatform *platform, int ifindex, gboolean enabled } static gboolean -link_set_token(NMPlatform *platform, int ifindex, NMUtilsIPv6IfaceId iid) +link_set_token(NMPlatform *platform, int ifindex, const NMUtilsIPv6IfaceId *iid) { nm_auto_nlmsg struct nl_msg *nlmsg = NULL; char sbuf[NM_UTILS_INET_ADDRSTRLEN]; @@ -7519,7 +7501,7 @@ link_set_token(NMPlatform *platform, int ifindex, NMUtilsIPv6IfaceId iid) nm_utils_inet6_interface_identifier_to_token(iid, sbuf)); nlmsg = _nl_msg_new_link(RTM_NEWLINK, 0, ifindex, NULL); - if (!nlmsg || !_nl_msg_new_link_set_afspec(nlmsg, -1, &iid)) + if (!nlmsg || !_nl_msg_new_link_set_afspec(nlmsg, -1, iid)) g_return_val_if_reached(FALSE); return (do_change_link(platform, CHANGE_LINK_TYPE_UNSPEC, ifindex, nlmsg, NULL) >= 0); @@ -7625,14 +7607,21 @@ nla_put_failure: } static gboolean -link_get_permanent_address(NMPlatform *platform, int ifindex, guint8 *buf, size_t *length) +link_get_permanent_address_ethtool(NMPlatform *platform, int ifindex, NMPLinkAddress *out_address) { nm_auto_pop_netns NMPNetns *netns = NULL; + guint8 buffer[_NM_UTILS_HWADDR_LEN_MAX]; + gsize len; if (!nm_platform_netns_push(platform, &netns)) return FALSE; - return nmp_utils_ethtool_get_permanent_address(ifindex, buf, length); + if (!nmp_utils_ethtool_get_permanent_address(ifindex, buffer, &len)) + return FALSE; + nm_assert(len <= _NM_UTILS_HWADDR_LEN_MAX); + memcpy(out_address->data, buffer, len); + out_address->len = len; + return TRUE; } static int @@ -8867,7 +8856,79 @@ qdisc_add(NMPlatform *platform, NMPNlmFlags flags, const NMPlatformQdisc *qdisc) return -NME_UNSPEC; } -/*****************************************************************************/ +static int +tc_delete(NMPlatform *platform, int nlmsgtype, int ifindex, guint32 parent, gboolean log_error) +{ + WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN; + gs_free char * errmsg = NULL; + int nle; + char s_buf[256]; + const char * log_tag; + nm_auto_nlmsg struct nl_msg *msg = NULL; + const struct tcmsg tcm = { + .tcm_ifindex = ifindex, + .tcm_parent = parent, + }; + + switch (nlmsgtype) { + case RTM_DELQDISC: + log_tag = "do-delete-qdisc"; + break; + case RTM_DELTFILTER: + log_tag = "do-delete-tfilter"; + break; + default: + nm_assert_not_reached(); + log_tag = "do-delete-tc"; + } + + msg = nlmsg_alloc_simple(nlmsgtype, NMP_NLM_FLAG_F_ECHO); + + if (nlmsg_append_struct(msg, &tcm) < 0) + goto nla_put_failure; + + event_handler_read_netlink(platform, FALSE); + + nle = _nl_send_nlmsg(platform, + msg, + &seq_result, + &errmsg, + DELAYED_ACTION_RESPONSE_TYPE_VOID, + NULL); + if (nle < 0) { + _NMLOG(log_error ? LOGL_ERR : LOGL_DEBUG, + "%s: failed sending netlink request \"%s\" (%d)", + log_tag, + nm_strerror(nle), + -nle); + return -NME_PL_NETLINK; + } + + delayed_action_handle_all(platform, FALSE); + + nm_assert(seq_result); + + _NMLOG((seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK || !log_error) ? LOGL_DEBUG + : LOGL_WARN, + "%s: %s", + log_tag, + wait_for_nl_response_to_string(seq_result, errmsg, s_buf, sizeof(s_buf))); + + if (seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK) + return 0; + if (seq_result < 0) + return seq_result; + return -NME_UNSPEC; + +nla_put_failure: + g_return_val_if_reached(-NME_UNSPEC); +} + +static int +qdisc_delete(NMPlatform *platform, int ifindex, guint32 parent, gboolean log_error) +{ + return tc_delete(platform, RTM_DELQDISC, ifindex, parent, log_error); +} static int tfilter_add(NMPlatform *platform, NMPNlmFlags flags, const NMPlatformTfilter *tfilter) @@ -8910,6 +8971,12 @@ tfilter_add(NMPlatform *platform, NMPNlmFlags flags, const NMPlatformTfilter *tf return -NME_UNSPEC; } +static int +tfilter_delete(NMPlatform *platform, int ifindex, guint32 parent, gboolean log_error) +{ + return tc_delete(platform, RTM_DELTFILTER, ifindex, parent, log_error); +} + /*****************************************************************************/ static gboolean @@ -9405,7 +9472,7 @@ constructed(GObject *_object) priv->udev_client = nm_udev_client_new(NM_MAKE_STRV("net"), handle_udev_event, platform); } - _LOGD("create (%s netns, %s, %s udev)", + _LOGD("create (%s netns, %s, %s udev, %s tc-cache)", !platform->_netns ? "ignore" : "use", !platform->_netns && nmp_netns_is_initial() ? "initial netns" @@ -9416,7 +9483,8 @@ constructed(GObject *_object) nmp_netns_get_current(), nmp_netns_get_current() == nmp_netns_get_initial() ? "/main" : "")), - nm_platform_get_use_udev(platform) ? "use" : "no"); + nm_platform_get_use_udev(platform) ? "use" : "no", + nm_platform_get_cache_tc(platform) ? "use" : "no"); priv->genl = nl_socket_alloc(); g_assert(priv->genl); @@ -9462,10 +9530,14 @@ constructed(GObject *_object) RTNLGRP_IPV6_IFADDR, RTNLGRP_IPV6_ROUTE, RTNLGRP_LINK, - RTNLGRP_TC, 0); g_assert(!nle); + if (nm_platform_get_cache_tc(platform)) { + nle = nl_socket_add_memberships(priv->nlh, RTNLGRP_TC, 0); + nm_assert(!nle); + } + fd = nl_socket_get_fd(priv->nlh); _LOGD("Netlink socket for events established: port=%u, fd=%d", @@ -9549,7 +9621,7 @@ path_is_read_only_fs(const char *path) } NMPlatform * -nm_linux_platform_new(gboolean log_with_ptr, gboolean netns_support) +nm_linux_platform_new(gboolean log_with_ptr, gboolean netns_support, gboolean cache_tc) { gboolean use_udev = FALSE; @@ -9563,6 +9635,8 @@ nm_linux_platform_new(gboolean log_with_ptr, gboolean netns_support) use_udev, NM_PLATFORM_NETNS_SUPPORT, netns_support, + NM_PLATFORM_CACHE_TC, + cache_tc, NULL); } @@ -9639,16 +9713,16 @@ nm_linux_platform_class_init(NMLinuxPlatformClass *klass) platform_class->link_change_flags = link_change_flags; - platform_class->link_set_user_ipv6ll_enabled = link_set_user_ipv6ll_enabled; + platform_class->link_set_inet6_addr_gen_mode = link_set_inet6_addr_gen_mode; platform_class->link_set_token = link_set_token; - platform_class->link_set_address = link_set_address; - platform_class->link_get_permanent_address = link_get_permanent_address; - platform_class->link_set_mtu = link_set_mtu; - platform_class->link_set_name = link_set_name; - platform_class->link_set_sriov_params_async = link_set_sriov_params_async; - platform_class->link_set_sriov_vfs = link_set_sriov_vfs; - platform_class->link_set_bridge_vlans = link_set_bridge_vlans; + platform_class->link_set_address = link_set_address; + platform_class->link_get_permanent_address_ethtool = link_get_permanent_address_ethtool; + platform_class->link_set_mtu = link_set_mtu; + platform_class->link_set_name = link_set_name; + platform_class->link_set_sriov_params_async = link_set_sriov_params_async; + platform_class->link_set_sriov_vfs = link_set_sriov_vfs; + platform_class->link_set_bridge_vlans = link_set_bridge_vlans; platform_class->link_get_physical_port_id = link_get_physical_port_id; platform_class->link_get_dev_id = link_get_dev_id; @@ -9704,8 +9778,10 @@ nm_linux_platform_class_init(NMLinuxPlatformClass *klass) platform_class->routing_rule_add = routing_rule_add; - platform_class->qdisc_add = qdisc_add; - platform_class->tfilter_add = tfilter_add; + platform_class->qdisc_add = qdisc_add; + platform_class->qdisc_delete = qdisc_delete; + platform_class->tfilter_add = tfilter_add; + platform_class->tfilter_delete = tfilter_delete; platform_class->process_events = process_events; } diff --git a/src/libnm-platform/nm-linux-platform.h b/src/libnm-platform/nm-linux-platform.h index 26c31e3e..85e06934 100644 --- a/src/libnm-platform/nm-linux-platform.h +++ b/src/libnm-platform/nm-linux-platform.h @@ -23,6 +23,6 @@ typedef struct _NMLinuxPlatformClass NMLinuxPlatformClass; GType nm_linux_platform_get_type(void); -NMPlatform *nm_linux_platform_new(gboolean log_with_ptr, gboolean netns_support); +NMPlatform *nm_linux_platform_new(gboolean log_with_ptr, gboolean netns_support, gboolean cache_tc); #endif /* __NETWORKMANAGER_LINUX_PLATFORM_H__ */ diff --git a/src/libnm-platform/nm-netlink.c b/src/libnm-platform/nm-netlink.c index e92c4dfe..56cde50c 100644 --- a/src/libnm-platform/nm-netlink.c +++ b/src/libnm-platform/nm-netlink.c @@ -13,7 +13,7 @@ /*****************************************************************************/ #ifndef SOL_NETLINK - #define SOL_NETLINK 270 +#define SOL_NETLINK 270 #endif /*****************************************************************************/ @@ -24,7 +24,7 @@ #define NL_NO_AUTO_ACK (1 << 5) #ifndef NETLINK_EXT_ACK - #define NETLINK_EXT_ACK 11 +#define NETLINK_EXT_ACK 11 #endif struct nl_msg { @@ -162,28 +162,28 @@ nl_nlmsghdr_to_str(const struct nlmsghdr *hdr, char *buf, gsize len) } if (s) - nm_utils_strbuf_append_str(&buf, &len, s); + nm_strbuf_append_str(&buf, &len, s); else - nm_utils_strbuf_append(&buf, &len, "(%u)", (unsigned) hdr->nlmsg_type); + nm_strbuf_append(&buf, &len, "(%u)", (unsigned) hdr->nlmsg_type); flags = hdr->nlmsg_flags; if (!flags) { - nm_utils_strbuf_append_str(&buf, &len, ", flags 0"); + nm_strbuf_append_str(&buf, &len, ", flags 0"); goto flags_done; } -#define _F(f, n) \ - G_STMT_START \ - { \ - if (NM_FLAGS_ALL(flags, f)) { \ - flags &= ~(f); \ - nm_utils_strbuf_append(&buf, &len, "%s%s", prefix, n); \ - if (!flags) \ - goto flags_done; \ - prefix = ","; \ - } \ - } \ +#define _F(f, n) \ + G_STMT_START \ + { \ + if (NM_FLAGS_ALL(flags, f)) { \ + flags &= ~(f); \ + nm_strbuf_append(&buf, &len, "%s%s", prefix, n); \ + if (!flags) \ + goto flags_done; \ + prefix = ","; \ + } \ + } \ G_STMT_END prefix = ", flags "; @@ -225,11 +225,11 @@ nl_nlmsghdr_to_str(const struct nlmsghdr *hdr, char *buf, gsize len) if (flags_before != flags) prefix = ";"; - nm_utils_strbuf_append(&buf, &len, "%s0x%04x", prefix, flags); + nm_strbuf_append(&buf, &len, "%s0x%04x", prefix, flags); flags_done: - nm_utils_strbuf_append(&buf, &len, ", seq %u", (unsigned) hdr->nlmsg_seq); + nm_strbuf_append(&buf, &len, ", seq %u", (unsigned) hdr->nlmsg_seq); return b; } @@ -585,21 +585,21 @@ nla_nest_end(struct nl_msg *msg, struct nlattr *start) return _nest_end(msg, start, 0); } -static const uint16_t nla_attr_minlen[NLA_TYPE_MAX + 1] = { +static const uint8_t nla_attr_minlen[NLA_TYPE_MAX + 1] = { [NLA_U8] = sizeof(uint8_t), [NLA_U16] = sizeof(uint16_t), [NLA_U32] = sizeof(uint32_t), [NLA_U64] = sizeof(uint64_t), [NLA_STRING] = 1, - [NLA_FLAG] = 0, }; static int validate_nla(const struct nlattr *nla, int maxtype, const struct nla_policy *policy) { const struct nla_policy *pt; - unsigned int minlen = 0; - int type = nla_type(nla); + uint8_t minlen; + uint16_t len; + int type = nla_type(nla); if (type < 0 || type > maxtype) return 0; @@ -609,25 +609,30 @@ validate_nla(const struct nlattr *nla, int maxtype, const struct nla_policy *pol if (pt->type > NLA_TYPE_MAX) g_return_val_if_reached(-NME_BUG); - if (pt->minlen) + if (pt->minlen > 0) minlen = pt->minlen; - else if (pt->type != NLA_UNSPEC) + else minlen = nla_attr_minlen[pt->type]; - if (nla_len(nla) < minlen) + len = nla_len(nla); + + if (len < minlen) return -NME_UNSPEC; - if (pt->maxlen && nla_len(nla) > pt->maxlen) + if (pt->maxlen > 0 && len > pt->maxlen) return -NME_UNSPEC; - if (pt->type == NLA_STRING) { - const char *data; + switch (pt->type) { + case NLA_STRING: + { + const char *data = nla_data(nla); nm_assert(minlen > 0); - data = nla_data(nla); - if (data[nla_len(nla) - 1] != '\0') + if (data[len - 1u] != '\0') return -NME_UNSPEC; + break; + } } return 0; diff --git a/src/libnm-platform/nm-netlink.h b/src/libnm-platform/nm-netlink.h index ab355f74..00d817cd 100644 --- a/src/libnm-platform/nm-netlink.h +++ b/src/libnm-platform/nm-netlink.h @@ -21,7 +21,7 @@ #define NLMSGERR_ATTR_MAX 3 #ifndef NLM_F_ACK_TLVS - #define NLM_F_ACK_TLVS 0x200 +#define NLM_F_ACK_TLVS 0x200 #endif /*****************************************************************************/ @@ -35,15 +35,7 @@ enum { NLA_U64, /* 64 bit integer */ NLA_STRING, /* NUL terminated character string */ NLA_FLAG, /* Flag */ - NLA_MSECS, /* Micro seconds (64bit) */ NLA_NESTED, /* Nested attributes */ - NLA_NESTED_COMPAT, - NLA_NUL_STRING, - NLA_BINARY, - NLA_S8, - NLA_S16, - NLA_S32, - NLA_S64, __NLA_TYPE_MAX, }; @@ -63,10 +55,10 @@ const char *nl_nlmsghdr_to_str(const struct nlmsghdr *hdr, char *buf, gsize len) struct nla_policy { /* Type of attribute or NLA_UNSPEC */ - uint16_t type; + uint8_t type; /* Minimal length of payload required */ - uint16_t minlen; + uint8_t minlen; /* Maximal length of payload allowed */ uint16_t maxlen; @@ -75,18 +67,24 @@ struct nla_policy { /*****************************************************************************/ /* static asserts that @tb and @policy are suitable arguments to nla_parse(). */ -#define _nl_static_assert_tb(tb, policy) \ - G_STMT_START \ - { \ - G_STATIC_ASSERT_EXPR(G_N_ELEMENTS(tb) > 0); \ - \ +#if _NM_CC_SUPPORT_GENERIC +#define _nl_static_assert_tb(tb, policy) \ + G_STMT_START \ + { \ + G_STATIC_ASSERT_EXPR(G_N_ELEMENTS(tb) > 0); \ + \ /* We allow @policy to be either a C array or NULL. The sizeof() - * must either match the expected array size or the sizeof(NULL), - * but not both. */ \ - G_STATIC_ASSERT_EXPR((sizeof(policy) == G_N_ELEMENTS(tb) * sizeof(struct nla_policy)) \ - ^ (sizeof(policy) == sizeof(NULL))); \ - } \ + * must either match the expected array size or we check that + * "policy" has typeof(NULL). This isn't a perfect compile time check, + * but good enough. */ \ + G_STATIC_ASSERT_EXPR( \ + _Generic((policy), typeof(NULL) : 1, default \ + : (sizeof(policy) == G_N_ELEMENTS(tb) * sizeof(struct nla_policy)))); \ + } \ G_STMT_END +#else +#define _nl_static_assert_tb(tb, policy) G_STATIC_ASSERT_EXPR(G_N_ELEMENTS(tb) > 0) +#endif /*****************************************************************************/ @@ -112,28 +110,24 @@ nla_padlen(int payload) struct nlattr *nla_reserve(struct nl_msg *msg, int attrtype, int attrlen); -static inline int +static inline uint16_t nla_len(const struct nlattr *nla) { nm_assert(nla); nm_assert(nla->nla_len >= NLA_HDRLEN); - return ((int) nla->nla_len) - NLA_HDRLEN; + return nla->nla_len - ((uint16_t) NLA_HDRLEN); } static inline int nla_type(const struct nlattr *nla) { - nm_assert(nla_len(nla) >= 0); - return nla->nla_type & NLA_TYPE_MASK; } static inline void * nla_data(const struct nlattr *nla) { - nm_assert(nla_len(nla) >= 0); - return &(((char *) nla)[NLA_HDRLEN]); } @@ -219,9 +213,7 @@ nla_get_be64(const struct nlattr *nla) static inline char * nla_get_string(const struct nlattr *nla) { - nm_assert(nla_len(nla) >= 0); - - return (char *) nla_data(nla); + return nla_data(nla); } size_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t dstsize); diff --git a/src/libnm-platform/nm-platform-utils.c b/src/libnm-platform/nm-platform-utils.c index ce847451..f0522736 100644 --- a/src/libnm-platform/nm-platform-utils.c +++ b/src/libnm-platform/nm-platform-utils.c @@ -308,14 +308,14 @@ _ethtool_edata_to_string(gpointer edata, gsize edata_size, char *sbuf, gsize sbu /*****************************************************************************/ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) - #define ethtool_cmd_speed(pedata) ((pedata)->speed) - - #define ethtool_cmd_speed_set(pedata, speed) \ - G_STMT_START \ - { \ - (pedata)->speed = (guint16) (speed); \ - } \ - G_STMT_END +#define ethtool_cmd_speed(pedata) ((pedata)->speed) + +#define ethtool_cmd_speed_set(pedata, speed) \ + G_STMT_START \ + { \ + (pedata)->speed = (guint16) (speed); \ + } \ + G_STMT_END #endif static int @@ -554,7 +554,7 @@ _ASSERT_ethtool_feature_infos(void) for (k = 0; k < inf->n_kernel_names; k++) { const char *name = inf->kernel_names[k]; - g_assert(nm_utils_strv_find_first((char **) inf->kernel_names, k, name) < 0); + g_assert(nm_strv_find_first(inf->kernel_names, k, name) < 0); /* these offload features are only informational and cannot be set from user-space * (NETIF_F_NEVER_CHANGE). We should not track them in _ethtool_feature_infos. */ diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c index b7a65df5..5d4ec037 100644 --- a/src/libnm-platform/nm-platform.c +++ b/src/libnm-platform/nm-platform.c @@ -56,6 +56,7 @@ G_STATIC_ASSERT(_nm_alignof(NMPlatformIPAddress) == _nm_alignof(NMPlatformIPXAdd G_STATIC_ASSERT(sizeof(((NMPLinkAddress *) NULL)->data) == _NM_UTILS_HWADDR_LEN_MAX); G_STATIC_ASSERT(sizeof(((NMPlatformLink *) NULL)->l_address.data) == _NM_UTILS_HWADDR_LEN_MAX); +G_STATIC_ASSERT(sizeof(((NMPlatformLink *) NULL)->l_perm_address.data) == _NM_UTILS_HWADDR_LEN_MAX); G_STATIC_ASSERT(sizeof(((NMPlatformLink *) NULL)->l_broadcast.data) == _NM_UTILS_HWADDR_LEN_MAX); static const char * @@ -175,12 +176,14 @@ enum { PROP_NETNS_SUPPORT, PROP_USE_UDEV, PROP_LOG_WITH_PTR, + PROP_CACHE_TC, LAST_PROP, }; typedef struct _NMPlatformPrivate { bool use_udev : 1; bool log_with_ptr : 1; + bool cache_tc : 1; guint ip4_dev_route_blacklist_check_id; guint ip4_dev_route_blacklist_gc_timeout_id; @@ -211,6 +214,12 @@ nm_platform_get_log_with_ptr(NMPlatform *self) return NM_PLATFORM_GET_PRIVATE(self)->log_with_ptr; } +gboolean +nm_platform_get_cache_tc(NMPlatform *self) +{ + return NM_PLATFORM_GET_PRIVATE(self)->cache_tc; +} + /*****************************************************************************/ guint @@ -299,24 +308,6 @@ static const struct { const char *name; const char *desc; } _nm_platform_kernel_support_info[_NM_PLATFORM_KERNEL_SUPPORT_NUM] = { - [NM_PLATFORM_KERNEL_SUPPORT_TYPE_EXTENDED_IFA_FLAGS] = - { - .compile_time_default = TRUE, - .name = "EXTENDED_IFA_FLAGS", - .desc = "IPv6 temporary addresses support", - }, - [NM_PLATFORM_KERNEL_SUPPORT_TYPE_USER_IPV6LL] = - { - .compile_time_default = TRUE, - .name = "USER_IPV6LL", - .desc = "IFLA_INET6_ADDR_GEN_MODE support", - }, - [NM_PLATFORM_KERNEL_SUPPORT_TYPE_RTA_PREF] = - { - .compile_time_default = (RTA_MAX >= 20 /* RTA_PREF */), - .name = "RTA_PREF", - .desc = "ability to set router preference for IPv6 routes", - }, [NM_PLATFORM_KERNEL_SUPPORT_TYPE_FRA_L3MDEV] = { .compile_time_default = (FRA_MAX >= 19 /* FRA_L3MDEV */), @@ -348,6 +339,12 @@ static const struct { .name = "IFLA_BR_VLAN_STATS_ENABLE", .desc = "IFLA_BR_VLAN_STATS_ENABLE bridge link attribute", }, + [NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_PERM_ADDRESS] = + { + .compile_time_default = (IFLA_MAX >= 54 /* IFLA_PERM_ADDRESS */), + .name = "IFLA_PERM_ADDRESS", + .desc = "IFLA_PERM_ADDRESS netlink attribute", + }, }; int @@ -1229,25 +1226,25 @@ nm_platform_link_add(NMPlatform * self, switch (type) { case NM_LINK_TYPE_BRIDGE: - nm_utils_strbuf_append_str(&buf_p, &buf_len, ", "); + nm_strbuf_append_str(&buf_p, &buf_len, ", "); nm_platform_lnk_bridge_to_string((const NMPlatformLnkBridge *) extra_data, buf_p, buf_len); break; case NM_LINK_TYPE_VLAN: - nm_utils_strbuf_append_str(&buf_p, &buf_len, ", "); + nm_strbuf_append_str(&buf_p, &buf_len, ", "); nm_platform_lnk_vlan_to_string((const NMPlatformLnkVlan *) extra_data, buf_p, buf_len); break; case NM_LINK_TYPE_VRF: - nm_utils_strbuf_append_str(&buf_p, &buf_len, ", "); + nm_strbuf_append_str(&buf_p, &buf_len, ", "); nm_platform_lnk_vrf_to_string((const NMPlatformLnkVrf *) extra_data, buf_p, buf_len); break; case NM_LINK_TYPE_VXLAN: - nm_utils_strbuf_append_str(&buf_p, &buf_len, ", "); + nm_strbuf_append_str(&buf_p, &buf_len, ", "); nm_platform_lnk_vxlan_to_string((const NMPlatformLnkVxlan *) extra_data, buf_p, buf_len); @@ -1257,13 +1254,13 @@ nm_platform_link_add(NMPlatform * self, break; case NM_LINK_TYPE_GRE: case NM_LINK_TYPE_GRETAP: - nm_utils_strbuf_append_str(&buf_p, &buf_len, ", "); + nm_strbuf_append_str(&buf_p, &buf_len, ", "); nm_platform_lnk_gre_to_string((const NMPlatformLnkGre *) extra_data, buf_p, buf_len); break; case NM_LINK_TYPE_SIT: - nm_utils_strbuf_append_str(&buf_p, &buf_len, ", "); + nm_strbuf_append_str(&buf_p, &buf_len, ", "); nm_platform_lnk_sit_to_string((const NMPlatformLnkSit *) extra_data, buf_p, buf_len); @@ -1271,26 +1268,26 @@ nm_platform_link_add(NMPlatform * self, case NM_LINK_TYPE_IP6TNL: case NM_LINK_TYPE_IP6GRE: case NM_LINK_TYPE_IP6GRETAP: - nm_utils_strbuf_append_str(&buf_p, &buf_len, ", "); + nm_strbuf_append_str(&buf_p, &buf_len, ", "); nm_platform_lnk_ip6tnl_to_string((const NMPlatformLnkIp6Tnl *) extra_data, buf_p, buf_len); break; case NM_LINK_TYPE_IPIP: - nm_utils_strbuf_append_str(&buf_p, &buf_len, ", "); + nm_strbuf_append_str(&buf_p, &buf_len, ", "); nm_platform_lnk_ipip_to_string((const NMPlatformLnkIpIp *) extra_data, buf_p, buf_len); break; case NM_LINK_TYPE_MACSEC: - nm_utils_strbuf_append_str(&buf_p, &buf_len, ", "); + nm_strbuf_append_str(&buf_p, &buf_len, ", "); nm_platform_lnk_macsec_to_string((const NMPlatformLnkMacsec *) extra_data, buf_p, buf_len); break; case NM_LINK_TYPE_MACVLAN: case NM_LINK_TYPE_MACVTAP: - nm_utils_strbuf_append_str(&buf_p, &buf_len, ", "); + nm_strbuf_append_str(&buf_p, &buf_len, ", "); nm_platform_lnk_macvlan_to_string((const NMPlatformLnkMacvlan *) extra_data, buf_p, buf_len); @@ -1611,7 +1608,7 @@ nm_platform_link_uses_arp(NMPlatform *self, int ifindex) * Returns: %TRUE a tokenized identifier was available */ gboolean -nm_platform_link_set_ipv6_token(NMPlatform *self, int ifindex, NMUtilsIPv6IfaceId iid) +nm_platform_link_set_ipv6_token(NMPlatform *self, int ifindex, const NMUtilsIPv6IfaceId *iid) { _CHECK_SELF(self, klass, FALSE); @@ -1649,47 +1646,20 @@ nm_platform_link_get_udev_device(NMPlatform *self, int ifindex) return obj_cache ? obj_cache->_link.udev.device : NULL; } -/** - * nm_platform_link_get_user_ip6vll_enabled: - * @self: platform instance - * @ifindex: Interface index - * - * Check whether NM handles IPv6LL address creation for the link. If the - * platform or OS doesn't support changing the IPv6LL address mode, this call - * will fail and return %FALSE. - * - * Returns: %TRUE if NM handles the IPv6LL address for @ifindex - */ -gboolean -nm_platform_link_get_user_ipv6ll_enabled(NMPlatform *self, int ifindex) +int +nm_platform_link_get_inet6_addr_gen_mode(NMPlatform *self, int ifindex) { - const NMPlatformLink *pllink; - - pllink = nm_platform_link_get(self, ifindex); - if (pllink && pllink->inet6_addr_gen_mode_inv) - return _nm_platform_uint8_inv(pllink->inet6_addr_gen_mode_inv) == NM_IN6_ADDR_GEN_MODE_NONE; - return FALSE; + return _nm_platform_link_get_inet6_addr_gen_mode(nm_platform_link_get(self, ifindex)); } -/** - * nm_platform_link_set_user_ip6vll_enabled: - * @self: platform instance - * @ifindex: Interface index - * - * Set whether NM handles IPv6LL address creation for the link. If the - * platform or OS doesn't support changing the IPv6LL address mode, this call - * will fail and return %FALSE. - * - * Returns: the negative nm-error on failure. - */ int -nm_platform_link_set_user_ipv6ll_enabled(NMPlatform *self, int ifindex, gboolean enabled) +nm_platform_link_set_inet6_addr_gen_mode(NMPlatform *self, int ifindex, guint8 mode) { _CHECK_SELF(self, klass, -NME_BUG); g_return_val_if_fail(ifindex > 0, -NME_BUG); - return klass->link_set_user_ipv6ll_enabled(self, ifindex, enabled); + return klass->link_set_inet6_addr_gen_mode(self, ifindex, mode); } /** @@ -1736,7 +1706,7 @@ nm_platform_link_get_address(NMPlatform *self, int ifindex, size_t *length) } /** - * nm_platform_link_get_permanent_address: + * nm_platform_link_get_permanent_address_ethtool: * @self: platform instance * @ifindex: Interface index * @buf: buffer of at least %_NM_UTILS_HWADDR_LEN_MAX bytes, on success @@ -1747,22 +1717,47 @@ nm_platform_link_get_address(NMPlatform *self, int ifindex, size_t *length) * address. */ gboolean -nm_platform_link_get_permanent_address(NMPlatform *self, int ifindex, guint8 *buf, size_t *length) +nm_platform_link_get_permanent_address_ethtool(NMPlatform * self, + int ifindex, + NMPLinkAddress *out_address) { _CHECK_SELF(self, klass, FALSE); - if (length) - *length = 0; + if (out_address) + out_address->len = 0; g_return_val_if_fail(ifindex > 0, FALSE); - g_return_val_if_fail(buf, FALSE); - g_return_val_if_fail(length, FALSE); + g_return_val_if_fail(out_address, FALSE); - if (klass->link_get_permanent_address) - return klass->link_get_permanent_address(self, ifindex, buf, length); + if (klass->link_get_permanent_address_ethtool) + return klass->link_get_permanent_address_ethtool(self, ifindex, out_address); return FALSE; } +gboolean +nm_platform_link_get_permanent_address(NMPlatform * self, + const NMPlatformLink *plink, + NMPLinkAddress * out_address) +{ + _CHECK_SELF(self, klass, FALSE); + nm_assert(out_address); + + if (!plink) + return FALSE; + if (plink->l_perm_address.len > 0) { + *out_address = plink->l_perm_address; + return TRUE; + } + if (nm_platform_kernel_support_get_full(NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_PERM_ADDRESS, + FALSE) + == NM_OPTION_BOOL_TRUE) { + /* kernel supports the netlink API IFLA_PERM_ADDRESS, but we don't have the + * address cached. There is no need to fallback to ethtool ioctl. */ + return FALSE; + } + return nm_platform_link_get_permanent_address_ethtool(self, plink->ifindex, out_address); +} + gboolean nm_platform_link_supports_carrier_detect(NMPlatform *self, int ifindex) { @@ -2336,13 +2331,13 @@ nm_platform_link_wireguard_change(NMPlatform * self gsize len = sizeof(buf_peers); guint i; - nm_utils_strbuf_append_str(&b, &len, " { "); + nm_strbuf_append_str(&b, &len, " { "); for (i = 0; i < peers_len; i++) { - nm_utils_strbuf_append_str(&b, &len, " { "); + nm_strbuf_append_str(&b, &len, " { "); nm_platform_wireguard_peer_to_string(&peers[i], b, len); - nm_utils_strbuf_seek_end(&b, &len); + nm_strbuf_seek_end(&b, &len); if (peer_flags) { - nm_utils_strbuf_append( + nm_strbuf_append( &b, &len, " (%s)", @@ -2350,9 +2345,9 @@ nm_platform_link_wireguard_change(NMPlatform * self buf_change_flags, sizeof(buf_change_flags))); } - nm_utils_strbuf_append_str(&b, &len, " } "); + nm_strbuf_append_str(&b, &len, " } "); } - nm_utils_strbuf_append_str(&b, &len, "}"); + nm_strbuf_append_str(&b, &len, "}"); } _LOG3D("link: change wireguard ifindex %d, %s, (%s), %u peers%s", @@ -2531,6 +2526,8 @@ slave_category(NMPlatform *self, int slave) switch (nm_platform_link_get_type(self, master)) { case NM_LINK_TYPE_BRIDGE: return "brport"; + case NM_LINK_TYPE_BOND: + return "bonding_slave"; default: return NULL; } @@ -2620,30 +2617,30 @@ nm_platform_link_vlan_change(NMPlatform * self, len = sizeof(buf); if (flags_mask) - nm_utils_strbuf_append(&b, - &len, - " flags 0x%x/0x%x", - (unsigned) flags_set, - (unsigned) flags_mask); + nm_strbuf_append(&b, + &len, + " flags 0x%x/0x%x", + (unsigned) flags_set, + (unsigned) flags_mask); if (ingress_reset_all || n_ingress_map) { - nm_utils_strbuf_append_str(&b, &len, " ingress-qos-map"); + nm_strbuf_append_str(&b, &len, " ingress-qos-map"); nm_platform_vlan_qos_mapping_to_string("", ingress_map, n_ingress_map, b, len); i = strlen(b); b += i; len -= i; if (ingress_reset_all) - nm_utils_strbuf_append_str(&b, &len, " (reset-all)"); + nm_strbuf_append_str(&b, &len, " (reset-all)"); } if (egress_reset_all || n_egress_map) { - nm_utils_strbuf_append_str(&b, &len, " egress-qos-map"); + nm_strbuf_append_str(&b, &len, " egress-qos-map"); nm_platform_vlan_qos_mapping_to_string("", egress_map, n_egress_map, b, len); i = strlen(b); b += i; len -= i; if (egress_reset_all) - nm_utils_strbuf_append_str(&b, &len, " (reset-all)"); + nm_strbuf_append_str(&b, &len, " (reset-all)"); } _LOG3D("link: change vlan %s", buf); @@ -3668,7 +3665,7 @@ _addr_array_clean_expired(int addr_family, } #endif - if (!NM_IS_IPv4(addr_family) && NM_FLAGS_HAS(a->n_ifa_flags, IFA_F_TEMPORARY)) { + if (!NM_IS_IPv4(addr_family) && NM_FLAGS_HAS(a->n_ifa_flags, IFA_F_SECONDARY)) { /* temporary addresses are never added explicitly by NetworkManager but * kernel adds them via mngtempaddr flag. * @@ -3913,7 +3910,6 @@ nm_platform_ip_address_sync(NMPlatform *self, gs_unref_hashtable GHashTable *known_addresses_idx = NULL; GPtrArray * plat_addresses; GHashTable * known_subnets = NULL; - guint32 ifa_flags; guint i_plat; guint i_know; guint i; @@ -4140,10 +4136,6 @@ next_plat:; if (IS_IPv4) ip4_addr_subnets_destroy_index(known_subnets, known_addresses); - ifa_flags = nm_platform_kernel_support_get(NM_PLATFORM_KERNEL_SUPPORT_TYPE_EXTENDED_IFA_FLAGS) - ? IFA_F_NOPREFIXROUTE - : 0; - /* Add missing addresses. New addresses are added by kernel with top * priority. */ @@ -4178,7 +4170,7 @@ next_plat:; nm_platform_ip4_broadcast_address_from_addr(&known_address->a4), lifetime, preferred, - ifa_flags, + IFA_F_NOPREFIXROUTE, known_address->a4.label)) { /* ignore error, for unclear reasons. */ } @@ -4190,7 +4182,7 @@ next_plat:; known_address->a6.peer_address, lifetime, preferred, - ifa_flags | known_address->a6.n_ifa_flags)) + IFA_F_NOPREFIXROUTE | known_address->a6.n_ifa_flags)) return FALSE; } } @@ -4278,7 +4270,7 @@ nm_platform_ip_address_get_prune_list(NMPlatform *self, if (!IS_IPv4) { if (exclude_ipv6_temporary_addrs - && NM_FLAGS_HAS(NMP_OBJECT_CAST_IP_ADDRESS(obj)->n_ifa_flags, IFA_F_TEMPORARY)) + && NM_FLAGS_HAS(NMP_OBJECT_CAST_IP_ADDRESS(obj)->n_ifa_flags, IFA_F_SECONDARY)) continue; } @@ -5311,92 +5303,13 @@ nm_platform_qdisc_add(NMPlatform *self, NMPNlmFlags flags, const NMPlatformQdisc return klass->qdisc_add(self, flags, qdisc); } -/** - * nm_platform_qdisc_sync: - * @self: the #NMPlatform instance - * @ifindex: the ifindex where to configure the qdiscs. - * @known_qdiscs: the list of qdiscs (#NMPObject). - * - * The function promises not to take any reference to the qdisc - * instances from @known_qdiscs, nor to keep them around after - * the function returns. This is important, because it allows the - * caller to pass NMPlatformQdisc instances which "kind" string - * have a limited lifetime. - * - * Returns: %TRUE on success. - */ -gboolean -nm_platform_qdisc_sync(NMPlatform *self, int ifindex, GPtrArray *known_qdiscs) +int +nm_platform_qdisc_delete(NMPlatform *self, int ifindex, guint32 parent, gboolean log_error) { - gs_unref_ptrarray GPtrArray *plat_qdiscs = NULL; - NMPLookup lookup; - guint i; - gboolean success = TRUE; - gs_unref_hashtable GHashTable *known_qdiscs_idx = NULL; - - nm_assert(NM_IS_PLATFORM(self)); - nm_assert(ifindex > 0); - - known_qdiscs_idx = - g_hash_table_new((GHashFunc) nmp_object_id_hash, (GEqualFunc) nmp_object_id_equal); - if (known_qdiscs) { - for (i = 0; i < known_qdiscs->len; i++) { - const NMPObject *q = g_ptr_array_index(known_qdiscs, i); - - if (!g_hash_table_insert(known_qdiscs_idx, (gpointer) q, (gpointer) q)) { - _LOGW("duplicate qdisc %s", nm_platform_qdisc_to_string(&q->qdisc, NULL, 0)); - return FALSE; - } - } - } - - plat_qdiscs = - nm_platform_lookup_clone(self, - nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_QDISC, ifindex), - NULL, - NULL); - if (plat_qdiscs) { - for (i = 0; i < plat_qdiscs->len; i++) { - const NMPObject *p = g_ptr_array_index(plat_qdiscs, i); - const NMPObject *k; - - /* look up known qdisc with same parent */ - k = g_hash_table_lookup(known_qdiscs_idx, p); - - if (k) { - const NMPlatformQdisc *qdisc_k = NMP_OBJECT_CAST_QDISC(k); - const NMPlatformQdisc *qdisc_p = NMP_OBJECT_CAST_QDISC(p); - - /* check other fields */ - if (nm_platform_qdisc_cmp_full(qdisc_k, qdisc_p, FALSE) != 0 - || (qdisc_k->handle != qdisc_p->handle && qdisc_k != 0)) { - k = NULL; - } - } - - if (k) { - g_hash_table_remove(known_qdiscs_idx, k); - } else { - /* can't delete qdisc with zero handle */ - if (TC_H_MAJ(p->qdisc.handle) != 0) { - success &= nm_platform_object_delete(self, p); - } - } - } - } - - if (known_qdiscs) { - for (i = 0; i < known_qdiscs->len; i++) { - const NMPObject *q = g_ptr_array_index(known_qdiscs, i); - - if (g_hash_table_contains(known_qdiscs_idx, q)) { - success &= - (nm_platform_qdisc_add(self, NMP_NLM_FLAG_ADD, NMP_OBJECT_CAST_QDISC(q)) >= 0); - } - } - } + _CHECK_SELF(self, klass, -NME_BUG); - return success; + _LOG3D("deleting a qdisc: parent 0x%08x", parent); + return klass->qdisc_delete(self, ifindex, parent, log_error); } /*****************************************************************************/ @@ -5414,55 +5327,58 @@ nm_platform_tfilter_add(NMPlatform *self, NMPNlmFlags flags, const NMPlatformTfi return klass->tfilter_add(self, flags, tfilter); } +int +nm_platform_tfilter_delete(NMPlatform *self, int ifindex, guint32 parent, gboolean log_error) +{ + _CHECK_SELF(self, klass, -NME_BUG); + + _LOG3D("deleting a tfilter: parent 0x%08x", parent); + return klass->tfilter_delete(self, ifindex, parent, log_error); +} + /** - * nm_platform_qdisc_sync: + * nm_platform_tc_sync: * @self: the #NMPlatform instance - * @ifindex: the ifindex where to configure the qdiscs. + * @ifindex: the ifindex where to configure qdiscs and filters. + * @known_qdiscs: the list of qdiscs (#NMPObject). * @known_tfilters: the list of tfilters (#NMPObject). * - * The function promises not to take any reference to the tfilter - * instances from @known_tfilters, nor to keep them around after - * the function returns. This is important, because it allows the - * caller to pass NMPlatformTfilter instances which "kind" string - * have a limited lifetime. + * The function promises not to take any reference to the + * instances from @known_qdiscs and @known_tfilters, nor to + * keep them around after the function returns. This is important, + * because it allows the caller to pass NMPlatformQdisc and + * NMPlatformTfilter instances which "kind" string have a limited + * lifetime. * * Returns: %TRUE on success. */ gboolean -nm_platform_tfilter_sync(NMPlatform *self, int ifindex, GPtrArray *known_tfilters) +nm_platform_tc_sync(NMPlatform *self, + int ifindex, + GPtrArray * known_qdiscs, + GPtrArray * known_tfilters) { - gs_unref_ptrarray GPtrArray *plat_tfilters = NULL; - NMPLookup lookup; - guint i; - gboolean success = TRUE; - gs_unref_hashtable GHashTable *known_tfilters_idx = NULL; + guint i; + gboolean success = TRUE; nm_assert(NM_IS_PLATFORM(self)); nm_assert(ifindex > 0); - known_tfilters_idx = - g_hash_table_new((GHashFunc) nmp_object_id_hash, (GEqualFunc) nmp_object_id_equal); - - if (known_tfilters) { - for (i = 0; i < known_tfilters->len; i++) { - const NMPObject *q = g_ptr_array_index(known_tfilters, i); - - g_hash_table_insert(known_tfilters_idx, (gpointer) q, (gpointer) q); - } - } + nm_platform_qdisc_delete(self, ifindex, TC_H_ROOT, FALSE); + nm_platform_qdisc_delete(self, ifindex, TC_H_INGRESS, FALSE); - plat_tfilters = - nm_platform_lookup_clone(self, - nmp_lookup_init_object(&lookup, NMP_OBJECT_TYPE_TFILTER, ifindex), - NULL, - NULL); + /* At this point we can only have a root default qdisc + * (which can't be deleted). Ensure it doesn't have any + * filters attached. + */ + nm_platform_tfilter_delete(self, ifindex, TC_H_ROOT, FALSE); - if (plat_tfilters) { - for (i = 0; i < plat_tfilters->len; i++) { - const NMPObject *q = g_ptr_array_index(plat_tfilters, i); + if (known_qdiscs) { + for (i = 0; i < known_qdiscs->len; i++) { + const NMPObject *q = g_ptr_array_index(known_qdiscs, i); - if (!g_hash_table_lookup(known_tfilters_idx, q)) - success &= nm_platform_object_delete(self, q); + success &= + (nm_platform_qdisc_add(self, NMP_NLM_FLAG_ADD, NMP_OBJECT_CAST_QDISC(q)) >= 0); } } @@ -5493,7 +5409,7 @@ nm_platform_vlan_qos_mapping_to_string(const char * name, nm_utils_to_string_buffer_init(&buf, &len); if (!n_map) { - nm_utils_strbuf_append_str(&buf, &len, ""); + nm_strbuf_append_str(&buf, &len, ""); return buf; } @@ -5503,14 +5419,14 @@ nm_platform_vlan_qos_mapping_to_string(const char * name, b = buf; if (name) { - nm_utils_strbuf_append_str(&b, &len, name); - nm_utils_strbuf_append_str(&b, &len, " {"); + nm_strbuf_append_str(&b, &len, name); + nm_strbuf_append_str(&b, &len, " {"); } else - nm_utils_strbuf_append_c(&b, &len, '{'); + nm_strbuf_append_c(&b, &len, '{'); for (i = 0; i < n_map; i++) - nm_utils_strbuf_append(&b, &len, " %u:%u", map[i].from, map[i].to); - nm_utils_strbuf_append_str(&b, &len, " }"); + nm_strbuf_append(&b, &len, " %u:%u", map[i].from, map[i].to); + nm_strbuf_append_str(&b, &len, " }"); return buf; } @@ -5566,6 +5482,7 @@ nm_platform_link_to_string(const NMPlatformLink *link, char *buf, gsize len) gsize l; char str_addrmode[30]; char str_address[_NM_UTILS_HWADDR_LEN_MAX * 3]; + char str_perm_address[_NM_UTILS_HWADDR_LEN_MAX * 3]; char str_broadcast[_NM_UTILS_HWADDR_LEN_MAX * 3]; char str_inet6_token[NM_UTILS_INET_ADDRSTRLEN]; const char *str_link_type; @@ -5576,13 +5493,13 @@ nm_platform_link_to_string(const NMPlatformLink *link, char *buf, gsize len) s = str_highlighted_flags; l = sizeof(str_highlighted_flags); if (NM_FLAGS_HAS(link->n_ifi_flags, IFF_NOARP)) - nm_utils_strbuf_append_str(&s, &l, "NOARP,"); + nm_strbuf_append_str(&s, &l, "NOARP,"); if (NM_FLAGS_HAS(link->n_ifi_flags, IFF_UP)) - nm_utils_strbuf_append_str(&s, &l, "UP"); + nm_strbuf_append_str(&s, &l, "UP"); else - nm_utils_strbuf_append_str(&s, &l, "DOWN"); + nm_strbuf_append_str(&s, &l, "DOWN"); if (link->connected) - nm_utils_strbuf_append_str(&s, &l, ",LOWER_UP"); + nm_strbuf_append_str(&s, &l, ",LOWER_UP"); nm_assert(s > str_highlighted_flags && l > 0); if (link->n_ifi_flags) { @@ -5604,6 +5521,7 @@ nm_platform_link_to_string(const NMPlatformLink *link, char *buf, gsize len) parent[0] = 0; _nmp_link_address_to_string(&link->l_address, str_address); + _nmp_link_address_to_string(&link->l_perm_address, str_perm_address); _nmp_link_address_to_string(&link->l_broadcast, str_broadcast); str_link_type = nm_link_type_to_string(link->type); @@ -5623,6 +5541,7 @@ nm_platform_link_to_string(const NMPlatformLink *link, char *buf, gsize len) "%s" /* is-in-udev */ "%s%s" /* addr-gen-mode */ "%s%s" /* l_address */ + "%s%s" /* l_perm_address */ "%s%s" /* l_broadcast */ "%s%s" /* inet6_token */ "%s%s" /* driver */ @@ -5648,11 +5567,13 @@ nm_platform_link_to_string(const NMPlatformLink *link, char *buf, gsize len) : "", str_address[0] ? " addr " : "", str_address[0] ? str_address : "", + str_perm_address[0] ? " permaddr " : "", + str_perm_address[0] ? str_perm_address : "", str_broadcast[0] ? " brd " : "", str_broadcast[0] ? str_broadcast : "", link->inet6_token.id ? " inet6token " : "", link->inet6_token.id - ? nm_utils_inet6_interface_identifier_to_token(link->inet6_token, str_inet6_token) + ? nm_utils_inet6_interface_identifier_to_token(&link->inet6_token, str_inet6_token) : "", link->driver ? " driver " : "", link->driver ?: "", @@ -6067,9 +5988,9 @@ nm_platform_lnk_vlan_to_string(const NMPlatformLnkVlan *lnk, char *buf, gsize le b = buf; - nm_utils_strbuf_append(&b, &len, "vlan %u", lnk->id); + nm_strbuf_append(&b, &len, "vlan %u", lnk->id); if (lnk->flags) - nm_utils_strbuf_append(&b, &len, " flags 0x%x", lnk->flags); + nm_strbuf_append(&b, &len, " flags 0x%x", lnk->flags); return buf; } @@ -6083,7 +6004,7 @@ nm_platform_lnk_vrf_to_string(const NMPlatformLnkVrf *lnk, char *buf, gsize len) b = buf; - nm_utils_strbuf_append(&b, &len, "table %u", lnk->table); + nm_strbuf_append(&b, &len, "table %u", lnk->table); return buf; } @@ -6208,36 +6129,36 @@ nm_platform_wireguard_peer_to_string(const NMPWireGuardPeer *peer, char *buf, gs } else s_endpoint[0] = '\0'; - nm_utils_strbuf_append( - &buf, - &len, - "public-key %s" - "%s" /* preshared-key */ - "%s" /* endpoint */ - " rx %" G_GUINT64_FORMAT " tx %" G_GUINT64_FORMAT "%s" /* persistent-keepalive */ - "%s", /* allowed-ips */ - public_key_b64, - nm_utils_memeqzero_secret(peer->preshared_key, sizeof(peer->preshared_key)) - ? "" - : " preshared-key (hidden)", - s_endpoint, - peer->rx_bytes, - peer->tx_bytes, - peer->persistent_keepalive_interval > 0 - ? nm_sprintf_buf(s_keepalive, - " keepalive %u", - (guint) peer->persistent_keepalive_interval) - : "", - peer->allowed_ips_len > 0 ? " allowed-ips" : ""); + nm_strbuf_append(&buf, + &len, + "public-key %s" + "%s" /* preshared-key */ + "%s" /* endpoint */ + " rx %" G_GUINT64_FORMAT " tx %" G_GUINT64_FORMAT + "%s" /* persistent-keepalive */ + "%s", /* allowed-ips */ + public_key_b64, + nm_utils_memeqzero_secret(peer->preshared_key, sizeof(peer->preshared_key)) + ? "" + : " preshared-key (hidden)", + s_endpoint, + peer->rx_bytes, + peer->tx_bytes, + peer->persistent_keepalive_interval > 0 + ? nm_sprintf_buf(s_keepalive, + " keepalive %u", + (guint) peer->persistent_keepalive_interval) + : "", + peer->allowed_ips_len > 0 ? " allowed-ips" : ""); for (i = 0; i < peer->allowed_ips_len; i++) { const NMPWireGuardAllowedIP *allowed_ip = &peer->allowed_ips[i]; - nm_utils_strbuf_append(&buf, - &len, - " %s/%u", - nm_utils_inet_ntop(allowed_ip->family, &allowed_ip->addr, s_addr), - allowed_ip->mask); + nm_strbuf_append(&buf, + &len, + " %s/%u", + nm_utils_inet_ntop(allowed_ip->family, &allowed_ip->addr, s_addr), + allowed_ip->mask); } return buf0; @@ -6353,7 +6274,8 @@ nm_platform_ip4_address_to_string(const NMPlatformIP4Address *address, char *buf "%s" /* label */ " src %s" "%s" /* external */ - "%s" /* ip4acd_not_ready */ + "%s" /* a_acd_not_ready */ + "%s" /* a_assume_config_once */ "", s_address, address->plen, @@ -6372,7 +6294,8 @@ nm_platform_ip4_address_to_string(const NMPlatformIP4Address *address, char *buf str_label, nmp_utils_ip_config_source_to_string(address->addr_source, s_source, sizeof(s_source)), address->external ? " ext" : "", - address->ip4acd_not_ready ? " ip4acd-not-ready" : ""); + address->a_acd_not_ready ? " ip4acd-not-ready" : "", + address->a_assume_config_once ? " assume-config-once" : ""); g_free(str_peer); return buf; } @@ -6406,17 +6329,22 @@ NM_UTILS_ENUM2STR_DEFINE(nm_platform_link_inet6_addrgenmode2str, NM_UTILS_ENUM2STR(NM_IN6_ADDR_GEN_MODE_STABLE_PRIVACY, "stable-privacy"), NM_UTILS_ENUM2STR(NM_IN6_ADDR_GEN_MODE_RANDOM, "random"), ); +G_STATIC_ASSERT(IFA_F_SECONDARY == IFA_F_TEMPORARY); + NM_UTILS_FLAGS2STR_DEFINE(nm_platform_addr_flags2str, unsigned, NM_UTILS_FLAGS2STR(IFA_F_SECONDARY, "secondary"), NM_UTILS_FLAGS2STR(IFA_F_NODAD, "nodad"), NM_UTILS_FLAGS2STR(IFA_F_OPTIMISTIC, "optimistic"), + NM_UTILS_FLAGS2STR(IFA_F_DADFAILED, "dadfailed"), NM_UTILS_FLAGS2STR(IFA_F_HOMEADDRESS, "homeaddress"), NM_UTILS_FLAGS2STR(IFA_F_DEPRECATED, "deprecated"), + NM_UTILS_FLAGS2STR(IFA_F_TENTATIVE, "tentative"), NM_UTILS_FLAGS2STR(IFA_F_PERMANENT, "permanent"), NM_UTILS_FLAGS2STR(IFA_F_MANAGETEMPADDR, "mngtmpaddr"), NM_UTILS_FLAGS2STR(IFA_F_NOPREFIXROUTE, "noprefixroute"), - NM_UTILS_FLAGS2STR(IFA_F_TENTATIVE, "tentative"), ); + NM_UTILS_FLAGS2STR(IFA_F_MCAUTOJOIN, "mcautojoin"), + NM_UTILS_FLAGS2STR(IFA_F_STABLE_PRIVACY, "stable-privacy"), ); NM_UTILS_ENUM2STR_DEFINE(nm_platform_route_scope2str, int, @@ -6486,7 +6414,10 @@ nm_platform_ip6_address_to_string(const NMPlatformIP6Address *address, char *buf g_snprintf( buf, len, - "%s/%d lft %s pref %s%s%s%s%s src %s%s", + "%s/%d lft %s pref %s%s%s%s%s src %s" + "%s" /* external */ + "%s" /* a_assume_config_once */ + "", s_address, address->plen, str_lft_p, @@ -6496,7 +6427,8 @@ nm_platform_ip6_address_to_string(const NMPlatformIP6Address *address, char *buf str_dev, _to_string_ifa_flags(address->n_ifa_flags, s_flags, sizeof(s_flags)), nmp_utils_ip_config_source_to_string(address->addr_source, s_source, sizeof(s_source)), - address->external ? " ext" : ""); + address->external ? " external" : "", + address->a_assume_config_once ? " assume-config-once" : ""); g_free(str_peer); return buf; } @@ -6529,7 +6461,7 @@ _rtm_flags_to_string_full(char *buf, gsize buf_size, unsigned rtm_flags) if (!rtm_flags) return ""; - nm_utils_strbuf_append_str(&buf, &buf_size, " rtm_flags "); + nm_strbuf_append_str(&buf, &buf_size, " rtm_flags "); _rtm_flags_to_string(rtm_flags, buf, buf_size); nm_assert(strlen(buf) < buf_size); return buf0; @@ -6588,6 +6520,7 @@ nm_platform_ip4_route_to_string(const NMPlatformIP4Route *route, char *buf, gsiz "%s" /* initrwnd */ "%s" /* mtu */ "%s" /* is_external */ + "%s" /* r_assume_config_once */ "", nm_net_aux_rtnl_rtntype_n2a_maybe_buf(nm_platform_route_type_uncoerce(route->type_coerced), str_type), @@ -6644,7 +6577,8 @@ nm_platform_ip4_route_to_string(const NMPlatformIP4Route *route, char *buf, gsiz route->lock_mtu ? "lock " : "", route->mtu) : "", - route->is_external ? " (E)" : ""); + route->is_external ? " is-external" : "", + route->r_assume_config_once ? " assume-config-once" : ""); return buf; } @@ -6715,6 +6649,7 @@ nm_platform_ip6_route_to_string(const NMPlatformIP6Route *route, char *buf, gsiz "%s" /* mtu */ "%s" /* pref */ "%s" /* is_external */ + "%s" /* r_assume_config_once */ "", nm_net_aux_rtnl_rtntype_n2a_maybe_buf(nm_platform_route_type_uncoerce(route->type_coerced), str_type), @@ -6775,7 +6710,8 @@ nm_platform_ip6_route_to_string(const NMPlatformIP6Route *route, char *buf, gsiz " pref %s", nm_icmpv6_router_pref_to_string(route->rt_pref, str_pref2, sizeof(str_pref2))) : "", - route->is_external ? " (E)" : ""); + route->is_external ? " is-external" : "", + route->r_assume_config_once ? " assume-config-once" : ""); return buf; } @@ -6801,18 +6737,18 @@ _routing_rule_addr_to_string(char ** buf, if (plen == 0 && is_zero) { if (is_src) - nm_utils_strbuf_append_str(buf, len, " from all"); + nm_strbuf_append_str(buf, len, " from all"); else - nm_utils_strbuf_append_str(buf, len, ""); + nm_strbuf_append_str(buf, len, ""); return; } - nm_utils_strbuf_append_str(buf, len, is_src ? " from " : " to "); + nm_strbuf_append_str(buf, len, is_src ? " from " : " to "); - nm_utils_strbuf_append_str(buf, len, nm_utils_inet_ntop(addr_family, addr, s_addr)); + nm_strbuf_append_str(buf, len, nm_utils_inet_ntop(addr_family, addr, s_addr)); if (plen != (addr_size * 8)) - nm_utils_strbuf_append(buf, len, "/%u", plen); + nm_strbuf_append(buf, len, "/%u", plen); } static void @@ -6822,11 +6758,11 @@ _routing_rule_port_range_to_string(char ** buf, const char * name) { if (port_range->start == 0 && port_range->end == 0) - nm_utils_strbuf_append_str(buf, len, ""); + nm_strbuf_append_str(buf, len, ""); else { - nm_utils_strbuf_append(buf, len, " %s %u", name, port_range->start); + nm_strbuf_append(buf, len, " %s %u", name, port_range->start); if (port_range->start != port_range->end) - nm_utils_strbuf_append(buf, len, "-%u", port_range->end); + nm_strbuf_append(buf, len, "-%u", port_range->end); } } @@ -6853,14 +6789,14 @@ nm_platform_routing_rule_to_string(const NMPlatformRoutingRule *routing_rule, ch rr_flags = routing_rule->flags; rr_flags = NM_FLAGS_UNSET(rr_flags, FIB_RULE_INVERT); - nm_utils_strbuf_append(&buf, - &len, - "[%c] " /* addr-family */ - "%u:" /* priority */ - "%s", /* not/FIB_RULE_INVERT */ - nm_utils_addr_family_to_char(routing_rule->addr_family), - routing_rule->priority, - (NM_FLAGS_HAS(routing_rule->flags, FIB_RULE_INVERT) ? " not" : "")); + nm_strbuf_append(&buf, + &len, + "[%c] " /* addr-family */ + "%u:" /* priority */ + "%s", /* not/FIB_RULE_INVERT */ + nm_utils_addr_family_to_char(routing_rule->addr_family), + routing_rule->priority, + (NM_FLAGS_HAS(routing_rule->flags, FIB_RULE_INVERT) ? " not" : "")); _routing_rule_addr_to_string(&buf, &len, @@ -6877,53 +6813,53 @@ nm_platform_routing_rule_to_string(const NMPlatformRoutingRule *routing_rule, ch FALSE); if (routing_rule->tos) - nm_utils_strbuf_append(&buf, &len, " tos 0x%02x", routing_rule->tos); + nm_strbuf_append(&buf, &len, " tos 0x%02x", routing_rule->tos); if (routing_rule->fwmark != 0 || routing_rule->fwmask != 0) { - nm_utils_strbuf_append(&buf, &len, " fwmark %#x", (unsigned) routing_rule->fwmark); + nm_strbuf_append(&buf, &len, " fwmark %#x", (unsigned) routing_rule->fwmark); if (routing_rule->fwmark != 0xFFFFFFFFu) - nm_utils_strbuf_append(&buf, &len, "/%#x", (unsigned) routing_rule->fwmask); + nm_strbuf_append(&buf, &len, "/%#x", (unsigned) routing_rule->fwmask); } if (routing_rule->iifname[0]) { - nm_utils_strbuf_append(&buf, &len, " iif %s", routing_rule->iifname); + nm_strbuf_append(&buf, &len, " iif %s", routing_rule->iifname); rr_flags = NM_FLAGS_UNSET(rr_flags, FIB_RULE_IIF_DETACHED); if (NM_FLAGS_HAS(routing_rule->flags, FIB_RULE_IIF_DETACHED)) - nm_utils_strbuf_append_str(&buf, &len, " [detached]"); + nm_strbuf_append_str(&buf, &len, " [detached]"); } if (routing_rule->oifname[0]) { - nm_utils_strbuf_append(&buf, &len, " oif %s", routing_rule->oifname); + nm_strbuf_append(&buf, &len, " oif %s", routing_rule->oifname); rr_flags = NM_FLAGS_UNSET(rr_flags, FIB_RULE_OIF_DETACHED); if (NM_FLAGS_HAS(routing_rule->flags, FIB_RULE_OIF_DETACHED)) - nm_utils_strbuf_append_str(&buf, &len, " [detached]"); + nm_strbuf_append_str(&buf, &len, " [detached]"); } if (routing_rule->l3mdev != 0) { if (routing_rule->l3mdev == 1) - nm_utils_strbuf_append_str(&buf, &len, " lookup [l3mdev-table]"); + nm_strbuf_append_str(&buf, &len, " lookup [l3mdev-table]"); else { - nm_utils_strbuf_append(&buf, - &len, - " lookup [l3mdev-table/%u]", - (unsigned) routing_rule->l3mdev); + nm_strbuf_append(&buf, + &len, + " lookup [l3mdev-table/%u]", + (unsigned) routing_rule->l3mdev); } } if (routing_rule->uid_range_has || routing_rule->uid_range.start || routing_rule->uid_range.end) { - nm_utils_strbuf_append(&buf, - &len, - " uidrange %u-%u%s", - routing_rule->uid_range.start, - routing_rule->uid_range.end, - routing_rule->uid_range_has ? "" : "(?)"); + nm_strbuf_append(&buf, + &len, + " uidrange %u-%u%s", + routing_rule->uid_range.start, + routing_rule->uid_range.end, + routing_rule->uid_range_has ? "" : "(?)"); } if (routing_rule->ip_proto != 0) { /* we don't call getprotobynumber(), just print the numeric value. * This differs from what ip-rule prints. */ - nm_utils_strbuf_append(&buf, &len, " ipproto %u", routing_rule->ip_proto); + nm_strbuf_append(&buf, &len, " ipproto %u", routing_rule->ip_proto); } _routing_rule_port_range_to_string(&buf, &len, &routing_rule->sport_range, "sport"); @@ -6931,25 +6867,25 @@ nm_platform_routing_rule_to_string(const NMPlatformRoutingRule *routing_rule, ch _routing_rule_port_range_to_string(&buf, &len, &routing_rule->dport_range, "dport"); if (routing_rule->tun_id != 0) { - nm_utils_strbuf_append(&buf, &len, " tun_id %" G_GUINT64_FORMAT, routing_rule->tun_id); + nm_strbuf_append(&buf, &len, " tun_id %" G_GUINT64_FORMAT, routing_rule->tun_id); } if (routing_rule->table != 0) { - nm_utils_strbuf_append(&buf, &len, " lookup %u", routing_rule->table); + nm_strbuf_append(&buf, &len, " lookup %u", routing_rule->table); } if (routing_rule->suppress_prefixlen_inverse != 0) { - nm_utils_strbuf_append(&buf, - &len, - " suppress_prefixlen %d", - (int) (~routing_rule->suppress_prefixlen_inverse)); + nm_strbuf_append(&buf, + &len, + " suppress_prefixlen %d", + (int) (~routing_rule->suppress_prefixlen_inverse)); } if (routing_rule->suppress_ifgroup_inverse != 0) { - nm_utils_strbuf_append(&buf, - &len, - " suppress_ifgroup %d", - (int) (~routing_rule->suppress_ifgroup_inverse)); + nm_strbuf_append(&buf, + &len, + " suppress_ifgroup %d", + (int) (~routing_rule->suppress_ifgroup_inverse)); } if (routing_rule->flow) { @@ -6958,7 +6894,7 @@ nm_platform_routing_rule_to_string(const NMPlatformRoutingRule *routing_rule, ch * * We don't follow the style how ip-rule prints flow/realms. It's confusing. Just * print the value hex. */ - nm_utils_strbuf_append(&buf, &len, " realms 0x%08x", routing_rule->flow); + nm_strbuf_append(&buf, &len, " realms 0x%08x", routing_rule->flow); } if (routing_rule->action == RTN_NAT) { @@ -6966,36 +6902,36 @@ nm_platform_routing_rule_to_string(const NMPlatformRoutingRule *routing_rule, ch /* NAT is deprecated for many years. We don't support RTA_GATEWAY/FRA_UNUSED2 * for the gateway, and so do recent kernels ignore that parameter. */ - nm_utils_strbuf_append_str(&buf, &len, " masquerade"); + nm_strbuf_append_str(&buf, &len, " masquerade"); } else if (routing_rule->action == FR_ACT_GOTO) { if (routing_rule->goto_target != 0) - nm_utils_strbuf_append(&buf, &len, " goto %u", routing_rule->goto_target); + nm_strbuf_append(&buf, &len, " goto %u", routing_rule->goto_target); else - nm_utils_strbuf_append_str(&buf, &len, " goto none"); + nm_strbuf_append_str(&buf, &len, " goto none"); rr_flags = NM_FLAGS_UNSET(rr_flags, FIB_RULE_UNRESOLVED); if (NM_FLAGS_HAS(routing_rule->flags, FIB_RULE_UNRESOLVED)) - nm_utils_strbuf_append_str(&buf, &len, " unresolved"); + nm_strbuf_append_str(&buf, &len, " unresolved"); } else if (routing_rule->action != FR_ACT_TO_TBL) { char ss_buf[60]; - nm_utils_strbuf_append(&buf, - &len, - " %s", - nm_net_aux_rtnl_rtntype_n2a(routing_rule->action) - ?: nm_sprintf_buf(ss_buf, "action-%u", routing_rule->action)); + nm_strbuf_append(&buf, + &len, + " %s", + nm_net_aux_rtnl_rtntype_n2a(routing_rule->action) + ?: nm_sprintf_buf(ss_buf, "action-%u", routing_rule->action)); } if (routing_rule->protocol != RTPROT_UNSPEC) - nm_utils_strbuf_append(&buf, &len, " protocol %u", routing_rule->protocol); + nm_strbuf_append(&buf, &len, " protocol %u", routing_rule->protocol); if (routing_rule->goto_target != 0 && routing_rule->action != FR_ACT_GOTO) { /* a trailing target is set for an unexpected action. Print it. */ - nm_utils_strbuf_append(&buf, &len, " goto-target %u", routing_rule->goto_target); + nm_strbuf_append(&buf, &len, " goto-target %u", routing_rule->goto_target); } if (rr_flags != 0) { /* we have some flags we didn't print about yet. */ - nm_utils_strbuf_append(&buf, &len, " remaining-flags %x", rr_flags); + nm_strbuf_append(&buf, &len, " remaining-flags %x", rr_flags); } return buf0; @@ -7012,53 +6948,53 @@ nm_platform_qdisc_to_string(const NMPlatformQdisc *qdisc, char *buf, gsize len) buf0 = buf; - nm_utils_strbuf_append(&buf, - &len, - "%s%s family %u handle %x parent %x info %x", - qdisc->kind, - _to_string_dev(NULL, qdisc->ifindex, str_dev, sizeof(str_dev)), - qdisc->addr_family, - qdisc->handle, - qdisc->parent, - qdisc->info); + nm_strbuf_append(&buf, + &len, + "%s%s family %u handle %x parent %x info %x", + qdisc->kind, + _to_string_dev(NULL, qdisc->ifindex, str_dev, sizeof(str_dev)), + qdisc->addr_family, + qdisc->handle, + qdisc->parent, + qdisc->info); if (nm_streq0(qdisc->kind, "fq_codel")) { if (qdisc->fq_codel.limit) - nm_utils_strbuf_append(&buf, &len, " limit %u", qdisc->fq_codel.limit); + nm_strbuf_append(&buf, &len, " limit %u", qdisc->fq_codel.limit); if (qdisc->fq_codel.flows) - nm_utils_strbuf_append(&buf, &len, " flows %u", qdisc->fq_codel.flows); + nm_strbuf_append(&buf, &len, " flows %u", qdisc->fq_codel.flows); if (qdisc->fq_codel.target) - nm_utils_strbuf_append(&buf, &len, " target %u", qdisc->fq_codel.target); + nm_strbuf_append(&buf, &len, " target %u", qdisc->fq_codel.target); if (qdisc->fq_codel.interval) - nm_utils_strbuf_append(&buf, &len, " interval %u", qdisc->fq_codel.interval); + nm_strbuf_append(&buf, &len, " interval %u", qdisc->fq_codel.interval); if (qdisc->fq_codel.quantum) - nm_utils_strbuf_append(&buf, &len, " quantum %u", qdisc->fq_codel.quantum); + nm_strbuf_append(&buf, &len, " quantum %u", qdisc->fq_codel.quantum); if (qdisc->fq_codel.ce_threshold != NM_PLATFORM_FQ_CODEL_CE_THRESHOLD_DISABLED) - nm_utils_strbuf_append(&buf, &len, " ce_threshold %u", qdisc->fq_codel.ce_threshold); + nm_strbuf_append(&buf, &len, " ce_threshold %u", qdisc->fq_codel.ce_threshold); if (qdisc->fq_codel.memory_limit != NM_PLATFORM_FQ_CODEL_MEMORY_LIMIT_UNSET) - nm_utils_strbuf_append(&buf, &len, " memory_limit %u", qdisc->fq_codel.memory_limit); + nm_strbuf_append(&buf, &len, " memory_limit %u", qdisc->fq_codel.memory_limit); if (qdisc->fq_codel.ecn) - nm_utils_strbuf_append(&buf, &len, " ecn"); + nm_strbuf_append(&buf, &len, " ecn"); } else if (nm_streq0(qdisc->kind, "sfq")) { if (qdisc->sfq.quantum) - nm_utils_strbuf_append(&buf, &len, " quantum %u", qdisc->sfq.quantum); + nm_strbuf_append(&buf, &len, " quantum %u", qdisc->sfq.quantum); if (qdisc->sfq.perturb_period) - nm_utils_strbuf_append(&buf, &len, " perturb %d", qdisc->sfq.perturb_period); + nm_strbuf_append(&buf, &len, " perturb %d", qdisc->sfq.perturb_period); if (qdisc->sfq.limit) - nm_utils_strbuf_append(&buf, &len, " limit %u", (guint) qdisc->sfq.limit); + nm_strbuf_append(&buf, &len, " limit %u", (guint) qdisc->sfq.limit); if (qdisc->sfq.divisor) - nm_utils_strbuf_append(&buf, &len, " divisor %u", qdisc->sfq.divisor); + nm_strbuf_append(&buf, &len, " divisor %u", qdisc->sfq.divisor); if (qdisc->sfq.flows) - nm_utils_strbuf_append(&buf, &len, " flows %u", qdisc->sfq.flows); + nm_strbuf_append(&buf, &len, " flows %u", qdisc->sfq.flows); if (qdisc->sfq.depth) - nm_utils_strbuf_append(&buf, &len, " depth %u", qdisc->sfq.depth); + nm_strbuf_append(&buf, &len, " depth %u", qdisc->sfq.depth); } else if (nm_streq0(qdisc->kind, "tbf")) { - nm_utils_strbuf_append(&buf, &len, " rate %" G_GUINT64_FORMAT, qdisc->tbf.rate); - nm_utils_strbuf_append(&buf, &len, " burst %u", qdisc->tbf.burst); + nm_strbuf_append(&buf, &len, " rate %" G_GUINT64_FORMAT, qdisc->tbf.rate); + nm_strbuf_append(&buf, &len, " burst %u", qdisc->tbf.burst); if (qdisc->tbf.limit) - nm_utils_strbuf_append(&buf, &len, " limit %u", qdisc->tbf.limit); + nm_strbuf_append(&buf, &len, " limit %u", qdisc->tbf.limit); if (qdisc->tbf.latency) - nm_utils_strbuf_append(&buf, &len, " latency %uns", qdisc->tbf.latency); + nm_strbuf_append(&buf, &len, " latency %uns", qdisc->tbf.latency); } return buf0; @@ -7153,11 +7089,11 @@ nm_platform_tfilter_to_string(const NMPlatformTfilter *tfilter, char *buf, gsize p = act_buf; l = sizeof(act_buf); - nm_utils_strbuf_append(&p, &l, " \"%s\"", tfilter->action.kind); + nm_strbuf_append(&p, &l, " \"%s\"", tfilter->action.kind); if (nm_streq(tfilter->action.kind, NM_PLATFORM_ACTION_KIND_SIMPLE)) { gs_free char *t = NULL; - nm_utils_strbuf_append( + nm_strbuf_append( &p, &l, " (\"%s\")", @@ -7166,14 +7102,14 @@ nm_platform_tfilter_to_string(const NMPlatformTfilter *tfilter, char *buf, gsize | NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_NON_ASCII, &t)); } else if (nm_streq(tfilter->action.kind, NM_PLATFORM_ACTION_KIND_MIRRED)) { - nm_utils_strbuf_append(&p, - &l, - "%s%s%s%s dev %d", - tfilter->action.mirred.ingress ? " ingress" : "", - tfilter->action.mirred.egress ? " egress" : "", - tfilter->action.mirred.mirror ? " mirror" : "", - tfilter->action.mirred.redirect ? " redirect" : "", - tfilter->action.mirred.ifindex); + nm_strbuf_append(&p, + &l, + "%s%s%s%s dev %d", + tfilter->action.mirred.ingress ? " ingress" : "", + tfilter->action.mirred.egress ? " egress" : "", + tfilter->action.mirred.mirror ? " mirror" : "", + tfilter->action.mirred.redirect ? " redirect" : "", + tfilter->action.mirred.ifindex); } } else act_buf[0] = '\0'; @@ -7344,6 +7280,9 @@ nm_platform_link_hash_update(const NMPlatformLink *obj, NMHashState *h) nm_hash_update_mem(h, obj->l_address.data, NM_MIN(obj->l_address.len, sizeof(obj->l_address.data))); + nm_hash_update_mem(h, + obj->l_perm_address.data, + NM_MIN(obj->l_perm_address.len, sizeof(obj->l_perm_address.data))); nm_hash_update_mem(h, obj->l_broadcast.data, NM_MIN(obj->l_broadcast.len, sizeof(obj->l_broadcast.data))); @@ -7364,12 +7303,15 @@ nm_platform_link_cmp(const NMPlatformLink *a, const NMPlatformLink *b) NM_CMP_FIELD_BOOL(a, b, initialized); NM_CMP_FIELD(a, b, arptype); NM_CMP_FIELD(a, b, l_address.len); + NM_CMP_FIELD(a, b, l_perm_address.len); NM_CMP_FIELD(a, b, l_broadcast.len); NM_CMP_FIELD(a, b, inet6_addr_gen_mode_inv); NM_CMP_FIELD_STR_INTERNED(a, b, kind); NM_CMP_FIELD_STR_INTERNED(a, b, driver); if (a->l_address.len) NM_CMP_FIELD_MEMCMP_LEN(a, b, l_address.data, a->l_address.len); + if (a->l_perm_address.len) + NM_CMP_FIELD_MEMCMP_LEN(a, b, l_perm_address.data, a->l_perm_address.len); if (a->l_broadcast.len) NM_CMP_FIELD_MEMCMP_LEN(a, b, l_broadcast.data, a->l_broadcast.len); NM_CMP_FIELD_MEMCMP(a, b, inet6_token); @@ -7853,20 +7795,20 @@ nm_platform_ip6_address_pretty_sort_cmp(const NMPlatformIP6Address *a1, NM_CMP_DIRECT(_address_pretty_sort_get_prio_6(&a2->address), _address_pretty_sort_get_prio_6(&a1->address)); - ipv6_privacy1 = NM_FLAGS_ANY(a1->n_ifa_flags, IFA_F_MANAGETEMPADDR | IFA_F_TEMPORARY); - ipv6_privacy2 = NM_FLAGS_ANY(a2->n_ifa_flags, IFA_F_MANAGETEMPADDR | IFA_F_TEMPORARY); + ipv6_privacy1 = NM_FLAGS_ANY(a1->n_ifa_flags, IFA_F_MANAGETEMPADDR | IFA_F_SECONDARY); + ipv6_privacy2 = NM_FLAGS_ANY(a2->n_ifa_flags, IFA_F_MANAGETEMPADDR | IFA_F_SECONDARY); if (ipv6_privacy1 || ipv6_privacy2) { gboolean public1 = TRUE; gboolean public2 = TRUE; if (ipv6_privacy1) { - if (a1->n_ifa_flags & IFA_F_TEMPORARY) + if (a1->n_ifa_flags & IFA_F_SECONDARY) public1 = prefer_temp; else public1 = !prefer_temp; } if (ipv6_privacy2) { - if (a2->n_ifa_flags & IFA_F_TEMPORARY) + if (a2->n_ifa_flags & IFA_F_SECONDARY) public2 = prefer_temp; else public2 = !prefer_temp; @@ -7905,7 +7847,8 @@ nm_platform_ip4_address_hash_update(const NMPlatformIP4Address *obj, NMHashState NM_HASH_COMBINE_BOOLS(guint8, obj->external, obj->use_ip4_broadcast_address, - obj->ip4acd_not_ready)); + obj->a_acd_not_ready, + obj->a_assume_config_once)); nm_hash_update_strarr(h, obj->label); } @@ -7927,7 +7870,8 @@ nm_platform_ip4_address_cmp(const NMPlatformIP4Address *a, const NMPlatformIP4Ad NM_CMP_FIELD(a, b, n_ifa_flags); NM_CMP_FIELD_STR(a, b, label); NM_CMP_FIELD_UNSAFE(a, b, external); - NM_CMP_FIELD_UNSAFE(a, b, ip4acd_not_ready); + NM_CMP_FIELD_UNSAFE(a, b, a_acd_not_ready); + NM_CMP_FIELD_UNSAFE(a, b, a_assume_config_once); return 0; } @@ -7944,7 +7888,7 @@ nm_platform_ip6_address_hash_update(const NMPlatformIP6Address *obj, NMHashState obj->plen, obj->address, obj->peer_address, - NM_HASH_COMBINE_BOOLS(guint8, obj->external)); + NM_HASH_COMBINE_BOOLS(guint8, obj->external, obj->a_assume_config_once)); } int @@ -7965,6 +7909,7 @@ nm_platform_ip6_address_cmp(const NMPlatformIP6Address *a, const NMPlatformIP6Ad NM_CMP_FIELD(a, b, preferred); NM_CMP_FIELD(a, b, n_ifa_flags); NM_CMP_FIELD_UNSAFE(a, b, external); + NM_CMP_FIELD_UNSAFE(a, b, a_assume_config_once); return 0; } @@ -8065,7 +8010,7 @@ nm_platform_ip4_route_hash_update(const NMPlatformIP4Route *obj, obj->initrwnd, obj->mtu, obj->r_rtm_flags, - NM_HASH_COMBINE_BOOLS(guint8, + NM_HASH_COMBINE_BOOLS(guint16, obj->metric_any, obj->table_any, obj->lock_window, @@ -8073,7 +8018,8 @@ nm_platform_ip4_route_hash_update(const NMPlatformIP4Route *obj, obj->lock_initcwnd, obj->lock_initrwnd, obj->lock_mtu, - obj->is_external)); + obj->is_external, + obj->r_assume_config_once)); break; } } @@ -8163,8 +8109,10 @@ nm_platform_ip4_route_cmp(const NMPlatformIP4Route *a, NM_CMP_FIELD(a, b, initcwnd); NM_CMP_FIELD(a, b, initrwnd); NM_CMP_FIELD(a, b, mtu); - if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL) + if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL) { NM_CMP_FIELD_UNSAFE(a, b, is_external); + NM_CMP_FIELD_UNSAFE(a, b, r_assume_config_once); + } break; } return 0; @@ -8249,7 +8197,7 @@ nm_platform_ip6_route_hash_update(const NMPlatformIP6Route *obj, obj->rt_source, obj->mss, obj->r_rtm_flags, - NM_HASH_COMBINE_BOOLS(guint8, + NM_HASH_COMBINE_BOOLS(guint16, obj->metric_any, obj->table_any, obj->lock_window, @@ -8257,7 +8205,8 @@ nm_platform_ip6_route_hash_update(const NMPlatformIP6Route *obj, obj->lock_initcwnd, obj->lock_initrwnd, obj->lock_mtu, - obj->is_external), + obj->is_external, + obj->r_assume_config_once), obj->window, obj->cwnd, obj->initcwnd, @@ -8340,8 +8289,10 @@ nm_platform_ip6_route_cmp(const NMPlatformIP6Route *a, NM_CMP_DIRECT(_route_pref_normalize(a->rt_pref), _route_pref_normalize(b->rt_pref)); else NM_CMP_FIELD(a, b, rt_pref); - if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL) + if (cmp_type == NM_PLATFORM_IP_ROUTE_CMP_TYPE_FULL) { NM_CMP_FIELD_UNSAFE(a, b, is_external); + NM_CMP_FIELD_UNSAFE(a, b, r_assume_config_once); + } break; } return 0; @@ -8627,6 +8578,57 @@ nm_platform_ip4_address_addr_to_hash(NMPlatform *self, int ifindex) /*****************************************************************************/ +NMPlatformIP4Route * +nm_platform_ip4_address_generate_device_route(const NMPlatformIP4Address *addr, + int ifindex, + guint32 route_table, + guint32 route_metric, + NMPlatformIP4Route * dst) +{ + in_addr_t network_4; + + /* When you add an IPv4 address (without "noprefixroute" flag), then kernel will + * automatically add a device route for the IPv4 subnet. This function generates + * such a route for the given address. */ + + nm_assert(addr); + nm_assert(addr->plen <= 32); + if (addr->plen == 0) + return NULL; + + if (addr->plen == 0) + return NULL; + + network_4 = nm_utils_ip4_address_clear_host_address(addr->peer_address, addr->plen); + + if (nm_utils_ip4_address_is_zeronet(network_4)) { + /* Kernel doesn't add device-routes for destinations that + * start with 0.x.y.z. Skip them. */ + return NULL; + } + + if (addr->plen == 32 && addr->address == addr->peer_address) { + /* Kernel doesn't add device-routes for /32 addresses unless + * they have a peer. */ + return NULL; + } + + *dst = (NMPlatformIP4Route){ + .ifindex = ifindex, + .rt_source = NM_IP_CONFIG_SOURCE_KERNEL, + .network = network_4, + .plen = addr->plen, + .pref_src = addr->address, + .table_coerced = nm_platform_route_table_coerce(route_table), + .metric = route_metric, + .scope_inv = nm_platform_route_scope_inv(NM_RT_SCOPE_LINK), + }; + + nm_platform_ip_route_normalize(AF_INET, (NMPlatformIPRoute *) dst); + + return dst; +} + const char * nm_platform_signal_change_type_to_string(NMPlatformSignalChangeType change_type) { @@ -8918,6 +8920,10 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps /* construct-only */ priv->log_with_ptr = g_value_get_boolean(value); break; + case PROP_CACHE_TC: + /* construct-only */ + priv->cache_tc = g_value_get_boolean(value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -9003,6 +9009,15 @@ nm_platform_class_init(NMPlatformClass *platform_class) TRUE, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property( + object_class, + PROP_CACHE_TC, + g_param_spec_boolean(NM_PLATFORM_CACHE_TC, + "", + "", + FALSE, + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + #define SIGNAL(signal, signal_id, method) \ G_STMT_START \ { \ diff --git a/src/libnm-platform/nm-platform.h b/src/libnm-platform/nm-platform.h index 9d40cbbe..7101b48c 100644 --- a/src/libnm-platform/nm-platform.h +++ b/src/libnm-platform/nm-platform.h @@ -25,6 +25,7 @@ #define NM_PLATFORM_NETNS_SUPPORT "netns-support" #define NM_PLATFORM_USE_UDEV "use-udev" #define NM_PLATFORM_LOG_WITH_PTR "log-with-ptr" +#define NM_PLATFORM_CACHE_TC "cache-tc" /*****************************************************************************/ @@ -42,10 +43,10 @@ typedef gboolean (*NMPObjectPredicateFunc)(const NMPObject *obj, gpointer user_d /* workaround for older libnl version, that does not define these flags. */ #ifndef IFA_F_MANAGETEMPADDR - #define IFA_F_MANAGETEMPADDR 0x100 +#define IFA_F_MANAGETEMPADDR 0x100 #endif #ifndef IFA_F_NOPREFIXROUTE - #define IFA_F_NOPREFIXROUTE 0x200 +#define IFA_F_NOPREFIXROUTE 0x200 #endif #define NM_RT_SCOPE_LINK 253 /* RT_SCOPE_LINK */ @@ -231,6 +232,9 @@ struct _NMPlatformLink { /* IFLA_ADDRESS */ NMPLinkAddress l_address; + /* IFLA_PERM_ADDRESS */ + NMPLinkAddress l_perm_address; + /* IFLA_BROADCAST */ NMPLinkAddress l_broadcast; @@ -314,18 +318,18 @@ typedef enum { * IFA_FLAGS attribute. */ \ guint32 n_ifa_flags; \ \ - guint8 plen; \ - \ /* FIXME(l3cfg): the external marker won't be necessary anymore, because we only * merge addresses we care about, and ignore (don't remove) external addresses. */ \ bool external : 1; \ \ bool use_ip4_broadcast_address : 1; \ \ - /* Whether the address is ready to be configured. By default, an address is, but this - * flag may indicate that the address is just for tracking purpose only, but the ACD - * state is not yet ready for the address to be configured. */ \ - bool ip4acd_not_ready : 1; \ + /* Whether the address is should be configured once during assume. This is a meta flag + * that is not honored by NMPlatform (netlink code). Instead, it can be used by the upper + * layers which use NMPlatformIPAddress to track addresses that should be configured. */ \ + bool a_assume_config_once : 1; \ + \ + guint8 plen; \ ; /** @@ -348,6 +352,11 @@ typedef struct { struct _NMPlatformIP4Address { __NMPlatformIPAddress_COMMON; + /* Whether the address is ready to be configured. By default, an address is, but this + * flag may indicate that the address is just for tracking purpose only, but the ACD + * state is not yet ready for the address to be configured. */ + bool a_acd_not_ready : 1; + /* The local address IFA_LOCAL. */ in_addr_t address; @@ -470,6 +479,11 @@ typedef union { * and is not reflected on netlink. */ \ bool is_external : 1; \ \ + /* Whether the route is should be configured once during assume. This is a meta flag + * that is not honored by NMPlatform (netlink code). Instead, it can be used by the upper + * layers which use NMPlatformIPRoute to track routes that should be configured. */ \ + bool r_assume_config_once : 1; \ + \ /* rtnh_flags * * Routes with rtm_flags RTM_F_CLONED are hidden by platform and @@ -518,8 +532,7 @@ typedef union { * it means RTN_UNSPEC otherwise the type value is preserved. * */ \ guint8 type_coerced; \ - \ - /*end*/ + ; typedef struct { __NMPlatformIPRoute_COMMON; @@ -613,6 +626,10 @@ typedef union { #undef __NMPlatformIPRoute_COMMON +#define NM_PLATFORM_IP4_ROUTE_INIT(...) (&((const NMPlatformIP4Route){__VA_ARGS__})) + +#define NM_PLATFORM_IP6_ROUTE_INIT(...) (&((const NMPlatformIP6Route){__VA_ARGS__})) + typedef struct { /* struct fib_rule_uid_range */ guint32 start; @@ -1008,13 +1025,11 @@ typedef void (*NMPlatformAsyncCallback)(GError *error, gpointer user_data); /*****************************************************************************/ typedef enum { - NM_PLATFORM_KERNEL_SUPPORT_TYPE_EXTENDED_IFA_FLAGS, - NM_PLATFORM_KERNEL_SUPPORT_TYPE_USER_IPV6LL, - NM_PLATFORM_KERNEL_SUPPORT_TYPE_RTA_PREF, NM_PLATFORM_KERNEL_SUPPORT_TYPE_FRA_L3MDEV, NM_PLATFORM_KERNEL_SUPPORT_TYPE_FRA_UID_RANGE, NM_PLATFORM_KERNEL_SUPPORT_TYPE_FRA_PROTOCOL, NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_BR_VLAN_STATS_ENABLED, + NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_PERM_ADDRESS, /* this also includes FRA_SPORT_RANGE and FRA_DPORT_RANGE which * were added at the same time. */ @@ -1105,13 +1120,12 @@ typedef struct { unsigned flags_mask, unsigned flags_set); - int (*link_set_user_ipv6ll_enabled)(NMPlatform *self, int ifindex, gboolean enabled); - gboolean (*link_set_token)(NMPlatform *self, int ifindex, NMUtilsIPv6IfaceId iid); + int (*link_set_inet6_addr_gen_mode)(NMPlatform *self, int ifindex, guint8 enabled); + gboolean (*link_set_token)(NMPlatform *self, int ifindex, const NMUtilsIPv6IfaceId *iid); - gboolean (*link_get_permanent_address)(NMPlatform *self, - int ifindex, - guint8 * buf, - size_t * length); + gboolean (*link_get_permanent_address_ethtool)(NMPlatform * self, + int ifindex, + NMPLinkAddress *out_address); int (*link_set_address)(NMPlatform *self, int ifindex, gconstpointer address, size_t length); int (*link_set_mtu)(NMPlatform *self, int ifindex, guint32 mtu); gboolean (*link_set_name)(NMPlatform *self, int ifindex, const char *name); @@ -1253,8 +1267,10 @@ typedef struct { const NMPlatformRoutingRule *routing_rule); int (*qdisc_add)(NMPlatform *self, NMPNlmFlags flags, const NMPlatformQdisc *qdisc); + int (*qdisc_delete)(NMPlatform *self, int ifindex, guint32 parent, gboolean log_error); int (*tfilter_add)(NMPlatform *self, NMPNlmFlags flags, const NMPlatformTfilter *tfilter); + int (*tfilter_delete)(NMPlatform *self, int ifindex, guint32 parent, gboolean log_error); } NMPlatformClass; /* NMPlatform signals @@ -1391,6 +1407,14 @@ _nm_platform_uint8_inv(guint8 scope) return (guint8) ~scope; } +static inline int +_nm_platform_link_get_inet6_addr_gen_mode(const NMPlatformLink *pllink) +{ + if (!pllink) + return -ENODEV; + return _nm_platform_uint8_inv(pllink->inet6_addr_gen_mode_inv); +} + /** * nm_platform_route_type_coerce: * @table: the route type, in its original value. @@ -1426,6 +1450,7 @@ nm_platform_route_type_uncoerce(guint8 type_coerced) gboolean nm_platform_get_use_udev(NMPlatform *self); gboolean nm_platform_get_log_with_ptr(NMPlatform *self); +gboolean nm_platform_get_cache_tc(NMPlatform *self); NMPNetns *nm_platform_netns_get(NMPlatform *self); gboolean nm_platform_netns_push(NMPlatform *self, NMPNetns **netns); @@ -1808,7 +1833,7 @@ gboolean nm_platform_link_is_up(NMPlatform *self, int ifindex); gboolean nm_platform_link_is_connected(NMPlatform *self, int ifindex); gboolean nm_platform_link_uses_arp(NMPlatform *self, int ifindex); guint32 nm_platform_link_get_mtu(NMPlatform *self, int ifindex); -gboolean nm_platform_link_get_user_ipv6ll_enabled(NMPlatform *self, int ifindex); +int nm_platform_link_get_inet6_addr_gen_mode(NMPlatform *self, int ifindex); gconstpointer nm_platform_link_get_address(NMPlatform *self, int ifindex, size_t *length); @@ -1858,11 +1883,16 @@ const char *nm_platform_link_get_path(NMPlatform *self, int ifindex); struct udev_device *nm_platform_link_get_udev_device(NMPlatform *self, int ifindex); -int nm_platform_link_set_user_ipv6ll_enabled(NMPlatform *self, int ifindex, gboolean enabled); -gboolean nm_platform_link_set_ipv6_token(NMPlatform *self, int ifindex, NMUtilsIPv6IfaceId iid); - +int nm_platform_link_set_inet6_addr_gen_mode(NMPlatform *self, int ifindex, guint8 mode); gboolean -nm_platform_link_get_permanent_address(NMPlatform *self, int ifindex, guint8 *buf, size_t *length); +nm_platform_link_set_ipv6_token(NMPlatform *self, int ifindex, const NMUtilsIPv6IfaceId *iid); + +gboolean nm_platform_link_get_permanent_address_ethtool(NMPlatform * self, + int ifindex, + NMPLinkAddress *out_address); +gboolean nm_platform_link_get_permanent_address(NMPlatform * self, + const NMPlatformLink *plink, + NMPLinkAddress * out_address); int nm_platform_link_set_address(NMPlatform *self, int ifindex, const void *address, size_t length); int nm_platform_link_set_mtu(NMPlatform *self, int ifindex, guint32 mtu); gboolean nm_platform_link_set_name(NMPlatform *self, int ifindex, const char *name); @@ -2113,7 +2143,7 @@ nm_platform_ip6_address_sync(NMPlatform *self, gboolean nm_platform_ip_address_flush(NMPlatform *self, int addr_family, int ifindex); -static inline gconstpointer +static inline gpointer nm_platform_ip_address_get_peer_address(int addr_family, const NMPlatformIPAddress *addr) { nm_assert_addr_family(addr_family); @@ -2193,11 +2223,14 @@ int nm_platform_routing_rule_add(NMPlatform * self, NMPNlmFlags flags, const NMPlatformRoutingRule *routing_rule); -int nm_platform_qdisc_add(NMPlatform *self, NMPNlmFlags flags, const NMPlatformQdisc *qdisc); -gboolean nm_platform_qdisc_sync(NMPlatform *self, int ifindex, GPtrArray *known_qdiscs); - +int nm_platform_qdisc_add(NMPlatform *self, NMPNlmFlags flags, const NMPlatformQdisc *qdisc); +int nm_platform_qdisc_delete(NMPlatform *self, int ifindex, guint32 parent, gboolean log_error); int nm_platform_tfilter_add(NMPlatform *self, NMPNlmFlags flags, const NMPlatformTfilter *tfilter); -gboolean nm_platform_tfilter_sync(NMPlatform *self, int ifindex, GPtrArray *known_tfilters); +int nm_platform_tfilter_delete(NMPlatform *self, int ifindex, guint32 parent, gboolean log_error); +gboolean nm_platform_tc_sync(NMPlatform *self, + int ifindex, + GPtrArray * known_qdiscs, + GPtrArray * known_tfilters); const char *nm_platform_link_to_string(const NMPlatformLink *link, char *buf, gsize len); const char *nm_platform_lnk_bridge_to_string(const NMPlatformLnkBridge *lnk, char *buf, gsize len); @@ -2389,6 +2422,14 @@ struct _NMDedupMultiIndex *nm_platform_get_multi_idx(NMPlatform *self); /*****************************************************************************/ +NMPlatformIP4Route *nm_platform_ip4_address_generate_device_route(const NMPlatformIP4Address *addr, + int ifindex, + guint32 route_table, + guint32 route_metric, + NMPlatformIP4Route *dst); + +/*****************************************************************************/ + gboolean nm_platform_ip_address_match(int addr_family, const NMPlatformIPAddress *addr, NMPlatformMatchFlags match_flag); diff --git a/src/libnm-platform/nmp-netns.c b/src/libnm-platform/nmp-netns.c index 2b28a4cd..d06c3e11 100644 --- a/src/libnm-platform/nmp-netns.c +++ b/src/libnm-platform/nmp-netns.c @@ -43,22 +43,20 @@ __ns_types_to_str(int ns_types, int ns_types_already_set, char *buf, gsize len) const char *b = buf; char bb[200]; - nm_utils_strbuf_append_c(&buf, &len, '['); + nm_strbuf_append_c(&buf, &len, '['); if (ns_types & ~ns_types_already_set) { - nm_utils_strbuf_append_str( - &buf, - &len, - _clone_ns_to_str(ns_types & ~ns_types_already_set, bb, sizeof(bb))); + nm_strbuf_append_str(&buf, + &len, + _clone_ns_to_str(ns_types & ~ns_types_already_set, bb, sizeof(bb))); } if (ns_types & ns_types_already_set) { if (ns_types & ~ns_types_already_set) - nm_utils_strbuf_append_c(&buf, &len, '/'); - nm_utils_strbuf_append_str( - &buf, - &len, - _clone_ns_to_str(ns_types & ns_types_already_set, bb, sizeof(bb))); + nm_strbuf_append_c(&buf, &len, '/'); + nm_strbuf_append_str(&buf, + &len, + _clone_ns_to_str(ns_types & ns_types_already_set, bb, sizeof(bb))); } - nm_utils_strbuf_append_c(&buf, &len, ']'); + nm_strbuf_append_c(&buf, &len, ']'); return b; } #define _ns_types_to_str(ns_types, ns_types_already_set, buf) \ diff --git a/src/libnm-platform/nmp-object.c b/src/libnm-platform/nmp-object.c index a7a46ef0..559fd8d6 100644 --- a/src/libnm-platform/nmp-object.c +++ b/src/libnm-platform/nmp-object.c @@ -949,30 +949,30 @@ _vt_cmd_obj_to_string_link(const NMPObject * obj, case NMP_OBJECT_TO_STRING_ID: return klass->cmd_plobj_to_string_id(&obj->object, buf, buf_size); case NMP_OBJECT_TO_STRING_ALL: - nm_utils_strbuf_append(&b, - &buf_size, - "[%s,%p,%u,%calive,%cvisible,%cin-nl,%p; ", - klass->obj_type_name, - obj, - obj->parent._ref_count, - nmp_object_is_alive(obj) ? '+' : '-', - nmp_object_is_visible(obj) ? '+' : '-', - obj->_link.netlink.is_in_netlink ? '+' : '-', - obj->_link.udev.device); + nm_strbuf_append(&b, + &buf_size, + "[%s,%p,%u,%calive,%cvisible,%cin-nl,%p; ", + klass->obj_type_name, + obj, + obj->parent._ref_count, + nmp_object_is_alive(obj) ? '+' : '-', + nmp_object_is_visible(obj) ? '+' : '-', + obj->_link.netlink.is_in_netlink ? '+' : '-', + obj->_link.udev.device); NMP_OBJECT_GET_CLASS(obj)->cmd_plobj_to_string(&obj->object, b, buf_size); - nm_utils_strbuf_seek_end(&b, &buf_size); + nm_strbuf_seek_end(&b, &buf_size); if (obj->_link.netlink.lnk) { - nm_utils_strbuf_append_str(&b, &buf_size, "; "); + nm_strbuf_append_str(&b, &buf_size, "; "); nmp_object_to_string(obj->_link.netlink.lnk, NMP_OBJECT_TO_STRING_ALL, b, buf_size); - nm_utils_strbuf_seek_end(&b, &buf_size); + nm_strbuf_seek_end(&b, &buf_size); } - nm_utils_strbuf_append_c(&b, &buf_size, ']'); + nm_strbuf_append_c(&b, &buf_size, ']'); return buf; case NMP_OBJECT_TO_STRING_PUBLIC: NMP_OBJECT_GET_CLASS(obj)->cmd_plobj_to_string(&obj->object, b, buf_size); if (obj->_link.netlink.lnk) { - nm_utils_strbuf_seek_end(&b, &buf_size); - nm_utils_strbuf_append_str(&b, &buf_size, "; "); + nm_strbuf_seek_end(&b, &buf_size); + nm_strbuf_append_str(&b, &buf_size, "; "); nmp_object_to_string(obj->_link.netlink.lnk, NMP_OBJECT_TO_STRING_PUBLIC, b, buf_size); } return buf; @@ -1065,29 +1065,28 @@ _vt_cmd_obj_to_string_lnk_wireguard(const NMPObject * obj, case NMP_OBJECT_TO_STRING_ALL: b = buf; - nm_utils_strbuf_append( - &b, - &buf_size, - "[%s,%p,%u,%calive,%cvisible; %s" - "%s", - klass->obj_type_name, - obj, - obj->parent._ref_count, - nmp_object_is_alive(obj) ? '+' : '-', - nmp_object_is_visible(obj) ? '+' : '-', - nmp_object_to_string(obj, NMP_OBJECT_TO_STRING_PUBLIC, buf2, sizeof(buf2)), - obj->_lnk_wireguard.peers_len > 0 ? " peers {" : ""); + nm_strbuf_append(&b, + &buf_size, + "[%s,%p,%u,%calive,%cvisible; %s" + "%s", + klass->obj_type_name, + obj, + obj->parent._ref_count, + nmp_object_is_alive(obj) ? '+' : '-', + nmp_object_is_visible(obj) ? '+' : '-', + nmp_object_to_string(obj, NMP_OBJECT_TO_STRING_PUBLIC, buf2, sizeof(buf2)), + obj->_lnk_wireguard.peers_len > 0 ? " peers {" : ""); for (i = 0; i < obj->_lnk_wireguard.peers_len; i++) { const NMPWireGuardPeer *peer = &obj->_lnk_wireguard.peers[i]; - nm_utils_strbuf_append_str(&b, &buf_size, " { "); + nm_strbuf_append_str(&b, &buf_size, " { "); nm_platform_wireguard_peer_to_string(peer, b, buf_size); - nm_utils_strbuf_seek_end(&b, &buf_size); - nm_utils_strbuf_append_str(&b, &buf_size, " }"); + nm_strbuf_seek_end(&b, &buf_size); + nm_strbuf_append_str(&b, &buf_size, " }"); } if (obj->_lnk_wireguard.peers_len) - nm_utils_strbuf_append_str(&b, &buf_size, " }"); + nm_strbuf_append_str(&b, &buf_size, " }"); return buf; case NMP_OBJECT_TO_STRING_PUBLIC: @@ -1199,9 +1198,11 @@ _vt_cmd_obj_hash_update_lnk_wireguard(const NMPObject *obj, NMHashState *h) } int -nmp_object_cmp(const NMPObject *obj1, const NMPObject *obj2) +nmp_object_cmp_full(const NMPObject *obj1, const NMPObject *obj2, NMPObjectCmpFlags flags) { - const NMPClass *klass1, *klass2; + const NMPClass *klass1; + const NMPClass *klass2; + NMPObject obj_stackcopy; NM_CMP_SELF(obj1, obj2); @@ -1216,6 +1217,22 @@ nmp_object_cmp(const NMPObject *obj1, const NMPObject *obj2) return klass1->obj_type < klass2->obj_type ? -1 : 1; } + if (NM_FLAGS_HAS(flags, NMP_OBJECT_CMP_FLAGS_IGNORE_IFINDEX)) { + if (!NM_IN_SET(klass1, + nmp_class_from_type(NMP_OBJECT_TYPE_IP4_ADDRESS), + nmp_class_from_type(NMP_OBJECT_TYPE_IP6_ADDRESS), + nmp_class_from_type(NMP_OBJECT_TYPE_IP4_ROUTE), + nmp_class_from_type(NMP_OBJECT_TYPE_IP6_ROUTE))) { + /* This flag is currently only implemented for certain types. + * That is, because we just create a stack copy, and that naive + * approach only knows for types where we know that it works. */ + } else if (obj1->obj_with_ifindex.ifindex != obj2->obj_with_ifindex.ifindex) { + nmp_object_stackinit(&obj_stackcopy, klass1->obj_type, &obj2->obj_with_ifindex); + obj_stackcopy.obj_with_ifindex.ifindex = obj1->obj_with_ifindex.ifindex; + obj2 = &obj_stackcopy; + } + } + if (klass1->cmd_obj_cmp) return klass1->cmd_obj_cmp(obj1, obj2); return klass1->cmd_plobj_cmp(&obj1->object, &obj2->object); @@ -2079,6 +2096,9 @@ nmp_lookup_init_obj_type(NMPLookup *lookup, NMPObjectType obj_type) nm_assert(lookup); switch (obj_type) { + default: + nm_assert_not_reached(); + /* fall-through */ case NMP_OBJECT_TYPE_LINK: case NMP_OBJECT_TYPE_IP4_ADDRESS: case NMP_OBJECT_TYPE_IP6_ADDRESS: @@ -2090,9 +2110,6 @@ nmp_lookup_init_obj_type(NMPLookup *lookup, NMPObjectType obj_type) _nmp_object_stackinit_from_type(&lookup->selector_obj, obj_type); lookup->cache_id_type = NMP_CACHE_ID_TYPE_OBJECT_TYPE; return _L(lookup); - default: - nm_assert_not_reached(); - return NULL; } } @@ -2107,7 +2124,7 @@ nmp_lookup_init_link_by_ifname(NMPLookup *lookup, const char *ifname) o = _nmp_object_stackinit_from_type(&lookup->selector_obj, NMP_OBJECT_TYPE_LINK); if (g_strlcpy(o->link.name, ifname, sizeof(o->link.name)) >= sizeof(o->link.name)) - g_return_val_if_reached(NULL); + nm_assert_not_reached(); lookup->cache_id_type = NMP_CACHE_ID_TYPE_LINK_BY_IFNAME; return _L(lookup); } diff --git a/src/libnm-platform/nmp-object.h b/src/libnm-platform/nmp-object.h index 021829db..bf140d78 100644 --- a/src/libnm-platform/nmp-object.h +++ b/src/libnm-platform/nmp-object.h @@ -120,10 +120,10 @@ typedef enum { /*< skip >*/ * the index NMP_CACHE_ID_TYPE_OBJECT_BY_IFINDEX with * matching v4/v6 and ifindex -- or maybe not at all if it isn't visible. * */ -typedef enum { /*< skip >*/ - NMP_CACHE_ID_TYPE_NONE, +typedef enum { + NMP_CACHE_ID_TYPE_NONE, - /* all the objects of a certain type. + /* all the objects of a certain type. * * This index is special. It is the only one that contains *all* object. * Other indexes may consider some object as non "partitionable", hence @@ -136,20 +136,20 @@ typedef enum { /*< skip >*/ * expose all links, even invisible ones. For addresses/routes, this * distinction doesn't exist, as all addresses/routes that are alive * are visible as well. */ - NMP_CACHE_ID_TYPE_OBJECT_TYPE, + NMP_CACHE_ID_TYPE_OBJECT_TYPE, - /* index for the link objects by ifname. */ - NMP_CACHE_ID_TYPE_LINK_BY_IFNAME, + /* index for the link objects by ifname. */ + NMP_CACHE_ID_TYPE_LINK_BY_IFNAME, - /* indices for the visible default-routes, ignoring ifindex. + /* indices for the visible default-routes, ignoring ifindex. * This index only contains two partitions: all visible default-routes, * separate for IPv4 and IPv6. */ - NMP_CACHE_ID_TYPE_DEFAULT_ROUTES, + NMP_CACHE_ID_TYPE_DEFAULT_ROUTES, - /* all the objects that have an ifindex (by object-type) for an ifindex. */ - NMP_CACHE_ID_TYPE_OBJECT_BY_IFINDEX, + /* all the objects that have an ifindex (by object-type) for an ifindex. */ + NMP_CACHE_ID_TYPE_OBJECT_BY_IFINDEX, - /* Consider all the destination fields of a route, that is, the ID without the ifindex + /* Consider all the destination fields of a route, that is, the ID without the ifindex * and gateway (meaning: network/plen,metric). * The reason for this is that `ip route change` can replace an existing route * and modify its ifindex/gateway. Effectively, that means it deletes an existing @@ -157,15 +157,15 @@ typedef enum { /*< skip >*/ * sends one RTM_NEWADDR notification without notifying about the deletion. We detect * that by having this index to contain overlapping routes which require special * cache-resync. */ - NMP_CACHE_ID_TYPE_ROUTES_BY_WEAK_ID, + NMP_CACHE_ID_TYPE_ROUTES_BY_WEAK_ID, - /* a filter for objects that track an explicit address family. + /* a filter for objects that track an explicit address family. * * Note that currently on NMPObjectRoutingRule is indexed by this filter. */ - NMP_CACHE_ID_TYPE_OBJECT_BY_ADDR_FAMILY, + NMP_CACHE_ID_TYPE_OBJECT_BY_ADDR_FAMILY, - __NMP_CACHE_ID_TYPE_MAX, - NMP_CACHE_ID_TYPE_MAX = __NMP_CACHE_ID_TYPE_MAX - 1, + __NMP_CACHE_ID_TYPE_MAX, + NMP_CACHE_ID_TYPE_MAX = __NMP_CACHE_ID_TYPE_MAX - 1, } NMPCacheIdType; typedef struct { @@ -625,6 +625,20 @@ nmp_object_unref(const NMPObject *obj) _changed; \ }) +#define nm_clear_nmp_object_up_cast(ptr) \ + ({ \ + typeof(ptr) _ptr = (ptr); \ + typeof(*_ptr) _pptr; \ + gboolean _changed = FALSE; \ + \ + if (_ptr && (_pptr = *_ptr)) { \ + *_ptr = NULL; \ + nmp_object_unref(NMP_OBJECT_UP_CAST(_pptr)); \ + _changed = TRUE; \ + } \ + _changed; \ + }) + static inline gboolean nmp_object_ref_set(const NMPObject **pp, const NMPObject *obj) { @@ -643,6 +657,25 @@ nmp_object_ref_set(const NMPObject **pp, const NMPObject *obj) return _changed; } +static inline gboolean +nmp_object_ref_set_up_cast(gpointer pp, gconstpointer obj) +{ + gboolean _changed = FALSE; + const NMPObject *p; + gconstpointer * pp2 = pp; + + nm_assert(!pp2 || !*pp2 || NMP_OBJECT_IS_VALID(NMP_OBJECT_UP_CAST(*pp2))); + nm_assert(!obj || NMP_OBJECT_IS_VALID(NMP_OBJECT_UP_CAST(obj))); + + if (pp2 && ((p = *pp2) != obj)) { + nmp_object_ref(NMP_OBJECT_UP_CAST(obj)); + *pp2 = obj; + nmp_object_unref(NMP_OBJECT_UP_CAST(p)); + _changed = TRUE; + } + return _changed; +} + NMPObject *nmp_object_new(NMPObjectType obj_type, gconstpointer plobj); NMPObject *nmp_object_new_link(int ifindex); @@ -671,7 +704,22 @@ const char *nmp_object_to_string(const NMPObject * obj, char * buf, gsize buf_size); void nmp_object_hash_update(const NMPObject *obj, NMHashState *h); -int nmp_object_cmp(const NMPObject *obj1, const NMPObject *obj2); + +typedef enum { + NMP_OBJECT_CMP_FLAGS_NONE = 0, + + /* Warning: this flag is currently only implemented for certain object types + * (address and routes). */ + NMP_OBJECT_CMP_FLAGS_IGNORE_IFINDEX = (1llu << 0), +} NMPObjectCmpFlags; + +int nmp_object_cmp_full(const NMPObject *obj1, const NMPObject *obj2, NMPObjectCmpFlags flags); + +static inline int +nmp_object_cmp(const NMPObject *obj1, const NMPObject *obj2) +{ + return nmp_object_cmp_full(obj1, obj2, NMP_OBJECT_CMP_FLAGS_NONE); +} static inline gboolean nmp_object_equal(const NMPObject *obj1, const NMPObject *obj2) @@ -1049,6 +1097,21 @@ nm_platform_lookup_object_by_addr_family(NMPlatform * platform, /*****************************************************************************/ +static inline gboolean +nmp_object_get_assume_config_once(const NMPObject *obj) +{ + switch (NMP_OBJECT_GET_TYPE(obj)) { + case NMP_OBJECT_TYPE_IP4_ADDRESS: + case NMP_OBJECT_TYPE_IP6_ADDRESS: + return NMP_OBJECT_CAST_IP_ADDRESS(obj)->a_assume_config_once; + case NMP_OBJECT_TYPE_IP4_ROUTE: + case NMP_OBJECT_TYPE_IP6_ROUTE: + return NMP_OBJECT_CAST_IP_ROUTE(obj)->r_assume_config_once; + default: + return nm_assert_unreachable_val(FALSE); + } +} + static inline const char * nmp_object_link_get_ifname(const NMPObject *obj) { @@ -1058,7 +1121,7 @@ nmp_object_link_get_ifname(const NMPObject *obj) } static inline gboolean -nmp_object_ip_route_is_best_defaut_route(const NMPObject *obj) +nmp_object_ip_route_is_best_default_route(const NMPObject *obj) { const NMPlatformIPRoute *r = NMP_OBJECT_CAST_IP_ROUTE(obj); diff --git a/src/libnm-platform/wifi/nm-wifi-utils-wext.c b/src/libnm-platform/wifi/nm-wifi-utils-wext.c index 13b47c2c..6fb37c49 100644 --- a/src/libnm-platform/wifi/nm-wifi-utils-wext.c +++ b/src/libnm-platform/wifi/nm-wifi-utils-wext.c @@ -14,7 +14,7 @@ /* Hacks necessary to #include wireless.h; yay for WEXT */ #ifndef __user - #define __user +#define __user #endif #include #include diff --git a/src/libnm-platform/wifi/nm-wifi-utils.c b/src/libnm-platform/wifi/nm-wifi-utils.c index 3c952b6f..0b5f8d71 100644 --- a/src/libnm-platform/wifi/nm-wifi-utils.c +++ b/src/libnm-platform/wifi/nm-wifi-utils.c @@ -15,7 +15,7 @@ #include "nm-wifi-utils-private.h" #include "nm-wifi-utils-nl80211.h" #if HAVE_WEXT - #include "nm-wifi-utils-wext.h" +#include "nm-wifi-utils-wext.h" #endif #include "libnm-platform/nm-platform-utils.h" diff --git a/src/libnm-std-aux/nm-default-std.h b/src/libnm-std-aux/nm-default-std.h index 5f4af3a5..23f5fc60 100644 --- a/src/libnm-std-aux/nm-default-std.h +++ b/src/libnm-std-aux/nm-default-std.h @@ -9,11 +9,11 @@ #include "nm-networkmanager-compilation.h" #ifdef NETWORKMANAGER_COMPILATION - #error Dont define NETWORKMANAGER_COMPILATION +#error Dont define NETWORKMANAGER_COMPILATION #endif #ifndef G_LOG_DOMAIN - #define G_LOG_DOMAIN "nm" +#define G_LOG_DOMAIN "nm" #endif /*****************************************************************************/ @@ -25,8 +25,8 @@ /* always include these headers for our internal source files. */ #ifndef ___CONFIG_H__ - #define ___CONFIG_H__ - #include +#define ___CONFIG_H__ +#include #endif #include "config-extra.h" @@ -37,11 +37,11 @@ #define NM_VERSION_MIN_REQUIRED NM_VERSION_0_9_8 #ifndef NM_MORE_ASSERTS - #define NM_MORE_ASSERTS 0 +#define NM_MORE_ASSERTS 0 #endif #if NM_MORE_ASSERTS == 0 - /* The cast macros like NM_TYPE() are implemented via G_TYPE_CHECK_INSTANCE_CAST() +/* The cast macros like NM_TYPE() are implemented via G_TYPE_CHECK_INSTANCE_CAST() * and _G_TYPE_CIC(). The latter, by default performs runtime checks of the type * by calling g_type_check_instance_cast(). * This check has a certain overhead without being helpful. @@ -88,9 +88,9 @@ * Example 3 is how it should be done. Type checks in NM_TYPE() are pointless. * Disable them for our production builds. */ - #ifndef G_DISABLE_CAST_CHECKS - #define G_DISABLE_CAST_CHECKS - #endif +#ifndef G_DISABLE_CAST_CHECKS +#define G_DISABLE_CAST_CHECKS +#endif #endif /*****************************************************************************/ diff --git a/src/libnm-std-aux/nm-linux-compat.h b/src/libnm-std-aux/nm-linux-compat.h index 7492d527..7ca7ec78 100644 --- a/src/libnm-std-aux/nm-linux-compat.h +++ b/src/libnm-std-aux/nm-linux-compat.h @@ -16,7 +16,7 @@ #include #ifndef __KERNEL_DIV_ROUND_UP - #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) -1) / (d)) +#define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) -1) / (d)) #endif #include "linux-headers/ethtool.h" diff --git a/src/libnm-std-aux/nm-std-aux.h b/src/libnm-std-aux/nm-std-aux.h index 17b26881..b79b1c65 100644 --- a/src/libnm-std-aux/nm-std-aux.h +++ b/src/libnm-std-aux/nm-std-aux.h @@ -10,20 +10,49 @@ #include #include #include +#include /*****************************************************************************/ -#define _nm_packed __attribute__((__packed__)) -#define _nm_unused __attribute__((__unused__)) -#define _nm_used __attribute__((__used__)) -#define _nm_pure __attribute__((__pure__)) -#define _nm_const __attribute__((__const__)) -#define _nm_printf(a, b) __attribute__((__format__(__printf__, a, b))) -#define _nm_align(s) __attribute__((__aligned__(s))) -#define _nm_section(s) __attribute__((__section__(s))) -#define _nm_alignof(type) __alignof(type) -#define _nm_alignas(type) _nm_align(_nm_alignof(type)) -#define nm_auto(fcn) __attribute__((__cleanup__(fcn))) +#define _nm_packed __attribute__((__packed__)) +#define _nm_unused __attribute__((__unused__)) +#define _nm_used __attribute__((__used__)) +#define _nm_pure __attribute__((__pure__)) +#define _nm_const __attribute__((__const__)) +#define _nm_warn_unused_result __attribute__((__warn_unused_result__)) +#define _nm_printf(a, b) __attribute__((__format__(__printf__, a, b))) +#define _nm_align(s) __attribute__((__aligned__(s))) +#define _nm_section(s) __attribute__((__section__(s))) +#define _nm_alignof(type) __alignof(type) +#define _nm_alignas(type) _nm_align(_nm_alignof(type)) +#define _nm_deprecated(msg) __attribute__((__deprecated__(msg))) +#define _nm_retain + +#if defined(__clang__) && defined(__has_attribute) +#if __has_attribute(__retain__) +/* __attribute__((__retain__)) is supported in clang 13+, but is warned about + * as an unknown attribute in older versions. We assume older versions are used + * together with linkers that do not require the attribute. + * + * Ideally __has_attribute(__retain__) would be checked in other compilers as + * well, but it is broken in GCC (bug 99587). Limit it to clang for now, as it + * is only known to be needed for linking lld. */ +#undef _nm_retain +#define _nm_retain __attribute__((__retain__)) +#endif +#endif + +#if defined(__clang__) && __clang_major__ == 13 +/* Clang 13 can emit -Wunused-but-set-variable warning for cleanup variables + * that are only assigned (never used otherwise). Hack around */ +#define _nm_auto_extra _nm_unused +#else +#define _nm_auto_extra +#endif + +#define nm_auto(fcn) _nm_auto_extra __attribute__((__cleanup__(fcn))) + +#define _nm_nil /* This is required to make LTO working. * @@ -31,25 +60,55 @@ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48200#c28 */ #ifndef __clang__ - #define _nm_externally_visible __attribute__((__externally_visible__)) +#define _nm_externally_visible __attribute__((__externally_visible__)) #else - #define _nm_externally_visible +#define _nm_externally_visible #endif #if __GNUC__ >= 7 - #define _nm_fallthrough __attribute__((__fallthrough__)) +#define _nm_fallthrough __attribute__((__fallthrough__)) +#else +#define _nm_fallthrough +#endif + +/*****************************************************************************/ + +#ifndef _NM_CC_SUPPORT_AUTO_TYPE +#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9))) +#define _NM_CC_SUPPORT_AUTO_TYPE 1 +#else +#define _NM_CC_SUPPORT_AUTO_TYPE 0 +#endif +#endif + +#if _NM_CC_SUPPORT_AUTO_TYPE +#define _nm_auto_type __auto_type +#endif + +#ifndef _NM_CC_SUPPORT_GENERIC +/* In the meantime, NetworkManager requires C11 and _Generic() should always be available. + * However, shared/nm-utils may also be used in VPN/applet, which possibly did not yet + * bump the C standard requirement. Leave this for the moment, but eventually we can + * drop it. + * + * Technically, gcc 4.9 already has some support for _Generic(). But there seems + * to be issues with propagating "const char *[5]" to "const char **". Only assume + * we have _Generic() since gcc 5. */ +#if (defined(__GNUC__) && __GNUC__ >= 5) || (defined(__clang__)) +#define _NM_CC_SUPPORT_GENERIC 1 #else - #define _nm_fallthrough +#define _NM_CC_SUPPORT_GENERIC 0 +#endif #endif /*****************************************************************************/ #ifdef __CHECKER__ - #define _nm_bitwise __attribute__((__bitwise__)) - #define _nm_force __attribute__((__force__)) +#define _nm_bitwise __attribute__((__bitwise__)) +#define _nm_force __attribute__((__force__)) #else - #define _nm_bitwise - #define _nm_force +#define _nm_bitwise +#define _nm_force #endif typedef uint16_t _nm_bitwise nm_le16_t; @@ -62,7 +121,7 @@ typedef uint64_t _nm_bitwise nm_be64_t; /*****************************************************************************/ #ifdef thread_local - #define _nm_thread_local thread_local +#define _nm_thread_local thread_local /* * Don't break on glibc < 2.16 that doesn't define __STDC_NO_THREADS__ * see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53769 @@ -70,9 +129,9 @@ typedef uint64_t _nm_bitwise nm_be64_t; #elif __STDC_VERSION__ >= 201112L \ && !(defined(__STDC_NO_THREADS__) \ || (defined(__GNU_LIBRARY__) && __GLIBC__ == 2 && __GLIBC_MINOR__ < 16)) - #define _nm_thread_local _Thread_local +#define _nm_thread_local _Thread_local #else - #define _nm_thread_local __thread +#define _nm_thread_local __thread #endif /*****************************************************************************/ @@ -81,6 +140,10 @@ typedef uint64_t _nm_bitwise nm_be64_t; /*****************************************************************************/ +#define NM_BIT(n) (1ull << (n)) + +/*****************************************************************************/ + #define NM_PASTE_ARGS(identifier1, identifier2) identifier1##identifier2 #define NM_PASTE(identifier1, identifier2) NM_PASTE_ARGS(identifier1, identifier2) @@ -104,11 +167,11 @@ typedef uint64_t _nm_bitwise nm_be64_t; #define NM_BOOLEAN_EXPR(expr) _NM_BOOLEAN_EXPR_IMPL(NM_UNIQ, expr) #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) - #define NM_LIKELY(expr) (__builtin_expect(NM_BOOLEAN_EXPR(expr), 1)) - #define NM_UNLIKELY(expr) (__builtin_expect(NM_BOOLEAN_EXPR(expr), 0)) +#define NM_LIKELY(expr) (__builtin_expect(NM_BOOLEAN_EXPR(expr), 1)) +#define NM_UNLIKELY(expr) (__builtin_expect(NM_BOOLEAN_EXPR(expr), 0)) #else - #define NM_LIKELY(expr) NM_BOOLEAN_EXPR(expr) - #define NM_UNLIKELY(expr) NM_BOOLEAN_EXPR(expr) +#define NM_LIKELY(expr) NM_BOOLEAN_EXPR(expr) +#define NM_UNLIKELY(expr) NM_BOOLEAN_EXPR(expr) #endif /*****************************************************************************/ @@ -126,50 +189,59 @@ typedef uint64_t _nm_bitwise nm_be64_t; * depend less on runtime conditions (that is, are generally expected to be true). */ #ifndef NM_MORE_ASSERTS - #define NM_MORE_ASSERTS 0 +#define NM_MORE_ASSERTS 0 #endif #ifndef _nm_assert_call - #define _nm_assert_call(cond) assert(cond) - #define _nm_assert_call_not_reached() assert(0) +#define _nm_assert_call(cond) assert(cond) +#define _nm_assert_call_not_reached() assert(0) #endif #if NM_MORE_ASSERTS - #define nm_assert(cond) \ - do { \ - _nm_assert_call(cond); \ - } while (0) - #define nm_assert_se(cond) \ - do { \ - if (NM_LIKELY(cond)) { \ - ; \ - } else { \ - _nm_assert_call(0 && (cond)); \ - } \ - } while (0) - #define nm_assert_not_reached() \ - do { \ - _nm_assert_call_not_reached(); \ - } while (0) +#define nm_assert(cond) \ + ({ \ + _nm_assert_call(cond); \ + 1; \ + }) +#define nm_assert_se(cond) \ + ({ \ + if (NM_LIKELY(cond)) { \ + ; \ + } else { \ + _nm_assert_call(0 && (cond)); \ + } \ + 1; \ + }) +#define nm_assert_not_reached() \ + ({ \ + _nm_assert_call_not_reached(); \ + 1; \ + }) #else - #define nm_assert(cond) \ - do { \ - if (0) { \ - if (cond) {} \ - } \ - } while (0) - #define nm_assert_se(cond) \ - do { \ - if (NM_LIKELY(cond)) { \ - ; \ - } \ - } while (0) - #define nm_assert_not_reached() \ - do { \ - ; \ - } while (0) +#define nm_assert(cond) \ + ({ \ + if (0) { \ + if (cond) {} \ + } \ + 1; \ + }) +#define nm_assert_se(cond) \ + ({ \ + if (NM_LIKELY(cond)) { \ + ; \ + } \ + 1; \ + }) +#define nm_assert_not_reached() ({ 1; }) #endif +/* This is similar nm_assert_not_reached(), but it's supposed to be used only during + * development. Like _XXX_ comments, they can be used as a marker that something still + * needs to be done. */ +#define XXX(msg) \ + nm_assert(!"X" \ + "XX error: " msg "") + #define nm_assert_unreachable_val(val) \ ({ \ nm_assert_not_reached(); \ @@ -177,11 +249,10 @@ typedef uint64_t _nm_bitwise nm_be64_t; }) #define NM_STATIC_ASSERT(cond) static_assert(cond, "") -#define NM_STATIC_ASSERT_EXPR(cond) \ - ({ \ - NM_STATIC_ASSERT(cond); \ - 1; \ - }) +#define NM_STATIC_ASSERT_EXPR_1(cond) \ + (sizeof(struct { char __static_assert_expr_1[(cond) ? 1 : -1]; }) == 1) +#define NM_STATIC_ASSERT_EXPR_VOID(cond) \ + ((void) (sizeof(struct { char __static_assert_expr_void[(cond) ? 1 : -1]; }) == 1)) /*****************************************************************************/ @@ -189,6 +260,59 @@ typedef uint64_t _nm_bitwise nm_be64_t; /*****************************************************************************/ +#define nm_offsetof(t, m) offsetof(t, m) + +#define nm_offsetofend(t, m) (nm_offsetof(t, m) + sizeof(((t *) NULL)->m)) + +/*****************************************************************************/ + +/* This does a compile time check that "type" is a suitable C type. It either + * returns a compile time constant of 1 or it fails compilation. The point + * is only in macros to check that a macro parameter (what we might pass to + * sizeof() is really a type, and not a variable. */ +#define NM_ENSURE_IS_TYPE(type) (sizeof(void (*)(type[])) == sizeof(void (*)(void *))) + +/*****************************************************************************/ + +#if _NM_CC_SUPPORT_GENERIC +/* returns @value, if the type of @value matches @type. + * This requires support for C11 _Generic(). If no support is + * present, this returns @value directly. + * + * It's useful to check the let the compiler ensure that @value is + * of a certain type. */ +#define _NM_ENSURE_TYPE(type, value) (_Generic((value), type : (value))) +#define _NM_ENSURE_TYPE_CONST(type, value) \ + (_Generic((value), const type \ + : ((const type)(value)), const type const \ + : ((const type)(value)), type \ + : ((const type)(value)), type const \ + : ((const type)(value)))) +#else +#define _NM_ENSURE_TYPE(type, value) (value) +#define _NM_ENSURE_TYPE_CONST(type, value) ((const type)(value)) +#endif + +/* returns void, but does a compile time check that the argument is a pointer + * (that is, can be converted to (const void *)). It does not actually evaluate + * (value). That means, it's also safe to call _NM_ENSURE_POINTER(array[0]) if + * array might be NULL. It's also safe to call on a macro argument that is + * supposed to be evaluate at most once (this macro will not "execute" the + * argument). */ +#define _NM_ENSURE_POINTER(value) \ + do { \ + _nm_unused const void *const _unused_for_type_check = 0 ? (value) : NULL; \ + } while (0) + +#if _NM_CC_SUPPORT_GENERIC && (!defined(__clang__) || __clang_major__ > 3) +#define NM_STRUCT_OFFSET_ENSURE_TYPE(type, container, field) \ + (_Generic((&(((container *) NULL)->field))[0], type : nm_offsetof(container, field))) +#else +#define NM_STRUCT_OFFSET_ENSURE_TYPE(type, container, field) nm_offsetof(container, field) +#endif + +/*****************************************************************************/ + static inline uint32_t nm_add_clamped_u32(uint32_t a, uint32_t b) { @@ -305,22 +429,26 @@ nm_mult_clamped_u(unsigned a, unsigned b) /* macro to return strlen() of a compile time string. */ #define NM_STRLEN(str) (sizeof("" str "") - 1u) +static inline size_t +_nm_ptrarray_len_impl(const void *const *array) +{ + size_t n = 0; + + if (array) { + while (array[n]) + n++; + } + return n; +} + /* returns the length of a NULL terminated array of pointers, * like g_strv_length() does. The difference is: * - it operates on arrays of pointers (of any kind, requiring no cast). * - it accepts NULL to return zero. */ -#define NM_PTRARRAY_LEN(array) \ - ({ \ - typeof(*(array)) *const _array = (array); \ - size_t _n = 0; \ - \ - if (_array) { \ - _nm_unused const void *_type_check_is_pointer = _array[0]; \ - \ - while (_array[_n]) \ - _n++; \ - } \ - _n; \ +#define NM_PTRARRAY_LEN(array) \ + ({ \ + _NM_ENSURE_POINTER((array)[0]); \ + _nm_ptrarray_len_impl((const void *const *) (array)); \ }) /*****************************************************************************/ @@ -404,50 +532,230 @@ nm_streq0(const char *s1, const char *s2) /*****************************************************************************/ -#define _NM_IN_SET_EVAL_1(op, _x, y) (_x == (y)) -#define _NM_IN_SET_EVAL_2(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_1(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_3(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_2(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_4(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_3(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_5(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_4(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_6(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_5(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_7(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_6(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_8(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_7(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_9(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_8(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_10(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_9(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_11(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_10(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_12(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_11(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_13(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_12(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_14(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_13(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_15(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_14(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_16(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_15(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_17(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_16(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_18(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_17(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_19(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_18(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_20(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_19(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_21(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_20(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_22(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_21(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_23(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_22(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_24(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_23(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_25(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_24(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_26(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_25(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_27(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_26(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_28(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_27(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_29(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_28(op, _x, __VA_ARGS__) -#define _NM_IN_SET_EVAL_30(op, _x, y, ...) (_x == (y)) op _NM_IN_SET_EVAL_29(op, _x, __VA_ARGS__) - -#define _NM_IN_SET_EVAL_N2(op, _x, n, ...) (_NM_IN_SET_EVAL_##n(op, _x, __VA_ARGS__)) -#define _NM_IN_SET_EVAL_N(op, type, x, n, ...) \ - ({ \ - type _x = (x); \ - \ - /* trigger a -Wenum-compare warning */ \ - nm_assert(true || _x == (x)); \ - \ - !!_NM_IN_SET_EVAL_N2(op, _x, n, __VA_ARGS__); \ - }) +/* clang-format off */ +#define _NM_MACRO_SELECT_ARG_120(_empty, \ + _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, \ + _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \ + _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, \ + _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, \ + _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, \ + _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, \ + _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, \ + _71, _72, _73, _74, _75, _76, _77, _78, _79, _80, \ + _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, \ + _91, _92, _93, _94, _95, _96, _97, _98, _99, _100, \ + _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, \ + _111, _112, _113, _114, _115, _116, _117, _118, _119, _120, \ + N, \ + ...) \ + N + +#define NM_NARG(...) \ + _NM_MACRO_SELECT_ARG_120(, ##__VA_ARGS__, \ + 120, \ + 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, \ + 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, \ + 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, \ + 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, \ + 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, \ + 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, \ + 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, \ + 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, \ + 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, \ + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, \ + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, \ + 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) +#define NM_NARG_MAX1(...) \ + _NM_MACRO_SELECT_ARG_120(, ##__VA_ARGS__, \ + 1, \ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 110 */ \ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 100 */ \ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 90 */ \ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 80 */ \ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 70 */ \ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 60 */ \ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 50 */ \ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 40 */ \ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 30 */ \ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 20 */ \ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 10 */ \ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0) +#define NM_NARG_MAX2(...) \ + _NM_MACRO_SELECT_ARG_120(, ##__VA_ARGS__, \ + 2, \ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 110 */ \ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 100 */ \ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 90 */ \ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 80 */ \ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 70 */ \ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 60 */ \ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 50 */ \ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 40 */ \ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 30 */ \ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 20 */ \ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 10 */ \ + 2, 2, 2, 2, 2, 2, 2, 2, 1, 0) +/* clang-format on */ + +/*****************************************************************************/ + +#define _NM_MACRO_IDENTITY(...) __VA_ARGS__ + +#define _NM_MACRO_SELECT_FIRST(...) _NM_MACRO_SELECT_FIRST_IMPL(__VA_ARGS__, throwaway) +#define _NM_MACRO_SELECT_FIRST_IMPL(first, ...) first + +#define _NM_MACRO_CALL(macro, ...) macro(__VA_ARGS__) +#define _NM_MACRO_CALL2(macro, ...) macro(__VA_ARGS__) + +/*****************************************************************************/ -#define _NM_IN_SET(op, type, x, ...) \ - _NM_IN_SET_EVAL_N(op, type, x, NM_NARG(__VA_ARGS__), __VA_ARGS__) +/* clang-format off */ +#define _NM_VA_ARGS_FOREACH_0(prefix, postfix, sep, op) +#define _NM_VA_ARGS_FOREACH_1(prefix, postfix, sep, op, x) prefix _NM_MACRO_CALL2(op, x, 0 ) postfix +#define _NM_VA_ARGS_FOREACH_2(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 1 ) postfix sep _NM_VA_ARGS_FOREACH_1(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_3(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 2 ) postfix sep _NM_VA_ARGS_FOREACH_2(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_4(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 3 ) postfix sep _NM_VA_ARGS_FOREACH_3(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_5(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 4 ) postfix sep _NM_VA_ARGS_FOREACH_4(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_6(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 5 ) postfix sep _NM_VA_ARGS_FOREACH_5(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_7(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 6 ) postfix sep _NM_VA_ARGS_FOREACH_6(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_8(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 7 ) postfix sep _NM_VA_ARGS_FOREACH_7(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_9(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 8 ) postfix sep _NM_VA_ARGS_FOREACH_8(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_10(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 9 ) postfix sep _NM_VA_ARGS_FOREACH_9(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_11(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 10 ) postfix sep _NM_VA_ARGS_FOREACH_10(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_12(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 11 ) postfix sep _NM_VA_ARGS_FOREACH_11(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_13(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 12 ) postfix sep _NM_VA_ARGS_FOREACH_12(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_14(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 13 ) postfix sep _NM_VA_ARGS_FOREACH_13(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_15(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 14 ) postfix sep _NM_VA_ARGS_FOREACH_14(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_16(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 15 ) postfix sep _NM_VA_ARGS_FOREACH_15(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_17(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 16 ) postfix sep _NM_VA_ARGS_FOREACH_16(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_18(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 17 ) postfix sep _NM_VA_ARGS_FOREACH_17(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_19(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 18 ) postfix sep _NM_VA_ARGS_FOREACH_18(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_20(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 19 ) postfix sep _NM_VA_ARGS_FOREACH_19(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_21(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 20 ) postfix sep _NM_VA_ARGS_FOREACH_20(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_22(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 21 ) postfix sep _NM_VA_ARGS_FOREACH_21(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_23(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 22 ) postfix sep _NM_VA_ARGS_FOREACH_22(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_24(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 23 ) postfix sep _NM_VA_ARGS_FOREACH_23(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_25(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 24 ) postfix sep _NM_VA_ARGS_FOREACH_24(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_26(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 25 ) postfix sep _NM_VA_ARGS_FOREACH_25(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_27(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 26 ) postfix sep _NM_VA_ARGS_FOREACH_26(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_28(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 27 ) postfix sep _NM_VA_ARGS_FOREACH_27(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_29(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 28 ) postfix sep _NM_VA_ARGS_FOREACH_28(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_30(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 29 ) postfix sep _NM_VA_ARGS_FOREACH_29(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_31(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 30 ) postfix sep _NM_VA_ARGS_FOREACH_30(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_32(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 31 ) postfix sep _NM_VA_ARGS_FOREACH_31(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_33(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 32 ) postfix sep _NM_VA_ARGS_FOREACH_32(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_34(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 33 ) postfix sep _NM_VA_ARGS_FOREACH_33(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_35(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 34 ) postfix sep _NM_VA_ARGS_FOREACH_34(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_36(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 35 ) postfix sep _NM_VA_ARGS_FOREACH_35(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_37(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 36 ) postfix sep _NM_VA_ARGS_FOREACH_36(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_38(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 37 ) postfix sep _NM_VA_ARGS_FOREACH_37(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_39(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 38 ) postfix sep _NM_VA_ARGS_FOREACH_38(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_40(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 39 ) postfix sep _NM_VA_ARGS_FOREACH_39(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_41(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 40 ) postfix sep _NM_VA_ARGS_FOREACH_40(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_42(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 41 ) postfix sep _NM_VA_ARGS_FOREACH_41(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_43(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 42 ) postfix sep _NM_VA_ARGS_FOREACH_42(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_44(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 43 ) postfix sep _NM_VA_ARGS_FOREACH_43(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_45(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 44 ) postfix sep _NM_VA_ARGS_FOREACH_44(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_46(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 45 ) postfix sep _NM_VA_ARGS_FOREACH_45(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_47(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 46 ) postfix sep _NM_VA_ARGS_FOREACH_46(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_48(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 47 ) postfix sep _NM_VA_ARGS_FOREACH_47(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_49(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 48 ) postfix sep _NM_VA_ARGS_FOREACH_48(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_50(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 49 ) postfix sep _NM_VA_ARGS_FOREACH_49(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_51(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 50 ) postfix sep _NM_VA_ARGS_FOREACH_50(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_52(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 51 ) postfix sep _NM_VA_ARGS_FOREACH_51(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_53(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 52 ) postfix sep _NM_VA_ARGS_FOREACH_52(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_54(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 53 ) postfix sep _NM_VA_ARGS_FOREACH_53(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_55(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 54 ) postfix sep _NM_VA_ARGS_FOREACH_54(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_56(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 55 ) postfix sep _NM_VA_ARGS_FOREACH_55(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_57(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 56 ) postfix sep _NM_VA_ARGS_FOREACH_56(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_58(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 57 ) postfix sep _NM_VA_ARGS_FOREACH_57(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_59(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 58 ) postfix sep _NM_VA_ARGS_FOREACH_58(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_60(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 59 ) postfix sep _NM_VA_ARGS_FOREACH_59(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_61(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 10 ) postfix sep _NM_VA_ARGS_FOREACH_60(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_62(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 61 ) postfix sep _NM_VA_ARGS_FOREACH_61(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_63(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 62 ) postfix sep _NM_VA_ARGS_FOREACH_62(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_64(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 63 ) postfix sep _NM_VA_ARGS_FOREACH_63(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_65(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 64 ) postfix sep _NM_VA_ARGS_FOREACH_64(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_66(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 65 ) postfix sep _NM_VA_ARGS_FOREACH_65(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_67(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 66 ) postfix sep _NM_VA_ARGS_FOREACH_66(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_68(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 67 ) postfix sep _NM_VA_ARGS_FOREACH_67(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_69(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 68 ) postfix sep _NM_VA_ARGS_FOREACH_68(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_70(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 69 ) postfix sep _NM_VA_ARGS_FOREACH_69(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_71(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 70 ) postfix sep _NM_VA_ARGS_FOREACH_70(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_72(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 71 ) postfix sep _NM_VA_ARGS_FOREACH_71(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_73(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 72 ) postfix sep _NM_VA_ARGS_FOREACH_72(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_74(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 73 ) postfix sep _NM_VA_ARGS_FOREACH_73(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_75(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 74 ) postfix sep _NM_VA_ARGS_FOREACH_74(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_76(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 75 ) postfix sep _NM_VA_ARGS_FOREACH_75(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_77(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 76 ) postfix sep _NM_VA_ARGS_FOREACH_76(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_78(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 77 ) postfix sep _NM_VA_ARGS_FOREACH_77(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_79(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 78 ) postfix sep _NM_VA_ARGS_FOREACH_78(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_80(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 79 ) postfix sep _NM_VA_ARGS_FOREACH_79(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_81(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 80 ) postfix sep _NM_VA_ARGS_FOREACH_80(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_82(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 81 ) postfix sep _NM_VA_ARGS_FOREACH_81(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_83(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 82 ) postfix sep _NM_VA_ARGS_FOREACH_82(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_84(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 83 ) postfix sep _NM_VA_ARGS_FOREACH_83(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_85(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 84 ) postfix sep _NM_VA_ARGS_FOREACH_84(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_86(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 85 ) postfix sep _NM_VA_ARGS_FOREACH_85(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_87(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 86 ) postfix sep _NM_VA_ARGS_FOREACH_86(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_88(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 87 ) postfix sep _NM_VA_ARGS_FOREACH_87(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_89(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 88 ) postfix sep _NM_VA_ARGS_FOREACH_88(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_90(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 89 ) postfix sep _NM_VA_ARGS_FOREACH_89(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_91(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 90 ) postfix sep _NM_VA_ARGS_FOREACH_90(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_92(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 91 ) postfix sep _NM_VA_ARGS_FOREACH_91(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_93(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 92 ) postfix sep _NM_VA_ARGS_FOREACH_92(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_94(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 93 ) postfix sep _NM_VA_ARGS_FOREACH_93(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_95(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 94 ) postfix sep _NM_VA_ARGS_FOREACH_94(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_96(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 95 ) postfix sep _NM_VA_ARGS_FOREACH_95(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_97(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 96 ) postfix sep _NM_VA_ARGS_FOREACH_96(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_98(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 97 ) postfix sep _NM_VA_ARGS_FOREACH_97(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_99(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 98 ) postfix sep _NM_VA_ARGS_FOREACH_98(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_100(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 99 ) postfix sep _NM_VA_ARGS_FOREACH_99(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_101(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 100) postfix sep _NM_VA_ARGS_FOREACH_100(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_102(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 101) postfix sep _NM_VA_ARGS_FOREACH_101(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_103(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 102) postfix sep _NM_VA_ARGS_FOREACH_102(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_104(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 103) postfix sep _NM_VA_ARGS_FOREACH_103(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_105(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 104) postfix sep _NM_VA_ARGS_FOREACH_104(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_106(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 105) postfix sep _NM_VA_ARGS_FOREACH_105(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_107(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 106) postfix sep _NM_VA_ARGS_FOREACH_106(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_108(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 107) postfix sep _NM_VA_ARGS_FOREACH_107(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_109(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 108) postfix sep _NM_VA_ARGS_FOREACH_108(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_110(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 109) postfix sep _NM_VA_ARGS_FOREACH_109(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_111(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 100) postfix sep _NM_VA_ARGS_FOREACH_110(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_112(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 111) postfix sep _NM_VA_ARGS_FOREACH_111(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_113(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 112) postfix sep _NM_VA_ARGS_FOREACH_112(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_114(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 113) postfix sep _NM_VA_ARGS_FOREACH_113(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_115(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 114) postfix sep _NM_VA_ARGS_FOREACH_114(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_116(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 115) postfix sep _NM_VA_ARGS_FOREACH_115(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_117(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 116) postfix sep _NM_VA_ARGS_FOREACH_116(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_118(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 117) postfix sep _NM_VA_ARGS_FOREACH_117(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_119(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 118) postfix sep _NM_VA_ARGS_FOREACH_118(prefix, postfix, sep, op, __VA_ARGS__) +#define _NM_VA_ARGS_FOREACH_120(prefix, postfix, sep, op, x, ...) prefix _NM_MACRO_CALL2(op, x, 119) postfix sep _NM_VA_ARGS_FOREACH_119(prefix, postfix, sep, op, __VA_ARGS__) +/* clang-format on */ +#define NM_VA_ARGS_FOREACH(prefix, postfix, sep, op, ...) \ + _NM_MACRO_CALL(NM_PASTE(_NM_VA_ARGS_FOREACH_, NM_NARG(__VA_ARGS__)), \ + prefix, \ + postfix, \ + sep, \ + op, \ + ##__VA_ARGS__) + +/*****************************************************************************/ + +#define NM_VA_ARGS_JOIN(sep, ...) NM_VA_ARGS_FOREACH(, , sep, _NM_MACRO_SELECT_FIRST, __VA_ARGS__) + +/*****************************************************************************/ + +#define _NM_IN_SET_OP(x, idx) (_x == (x)) +#define _NM_IN_SET(op, type, x, ...) \ + ({ \ + type _x = (x); \ + \ + /* trigger a -Wenum-compare warning */ \ + nm_assert(true || _x == (x)); \ + \ + !!(NM_VA_ARGS_FOREACH(, , op, _NM_IN_SET_OP, __VA_ARGS__)); \ + }) /* Beware that this does short-circuit evaluation (use "||" instead of "|") * which has a possibly unexpected non-function-like behavior. @@ -468,96 +776,31 @@ nm_streq0(const char *s1, const char *s2) /*****************************************************************************/ -#define _NM_IN_SETOP_EVAL_1(op, op_eq, _x, y) (op_eq(_x, y)) -#define _NM_IN_SETOP_EVAL_2(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_1(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_3(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_2(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_4(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_3(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_5(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_4(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_6(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_5(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_7(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_6(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_8(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_7(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_9(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_8(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_10(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_9(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_11(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_10(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_12(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_11(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_13(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_12(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_14(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_13(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_15(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_14(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_16(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_15(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_17(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_16(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_18(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_17(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_19(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_18(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_20(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_19(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_21(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_20(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_22(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_21(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_23(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_22(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_24(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_23(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_25(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_24(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_26(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_25(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_27(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_26(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_28(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_27(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_29(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_28(op, op_eq, _x, __VA_ARGS__) -#define _NM_IN_SETOP_EVAL_30(op, op_eq, _x, y, ...) \ - (op_eq(_x, y)) op _NM_IN_SETOP_EVAL_29(op, op_eq, _x, __VA_ARGS__) - -/*****************************************************************************/ - -#define _NM_IN_STRSET_EVAL_N2(op, op_ed, _x, n, ...) \ - (_NM_IN_SETOP_EVAL_##n(op, op_ed, _x, __VA_ARGS__)) -#define _NM_IN_STRSET_EVAL_N(op, op_ed, x, n, ...) \ - ({ \ - const char *_x = (x); \ - (((_x == NULL) && _NM_IN_SET_EVAL_N2(op, ((const char *) NULL), n, __VA_ARGS__)) \ - || ((_x != NULL) && _NM_IN_STRSET_EVAL_N2(op, op_ed, _x, n, __VA_ARGS__))); \ - }) - -/*****************************************************************************/ - static inline int -_NM_IN_STRSET_op_streq(const char *x, const char *s) +_NM_IN_STRSET_EVAL_op_streq(const char *x1, const char *x) { - return s && strcmp(x, s) == 0; + return x && nm_streq(x1, x); } +#define _NM_IN_STRSET_EVAL_OP_NULL(x, idx) (((const char *) NULL) == (x)) +#define _NM_IN_STRSET_EVAL_OP_STREQ(x, idx) _NM_IN_STRSET_EVAL_op_streq(_x1, x) +#define _NM_IN_STRSET_EVAL(op, eval_op, x1, ...) \ + ({ \ + const char *const _x1 = (x1); \ + \ + !!(_x1 ? (NM_VA_ARGS_FOREACH(, , op, eval_op, __VA_ARGS__)) \ + : (NM_VA_ARGS_FOREACH(, , op, _NM_IN_STRSET_EVAL_OP_NULL, __VA_ARGS__))); \ + }) + /* Beware that this does short-circuit evaluation (use "||" instead of "|") * which has a possibly unexpected non-function-like behavior. * Use NM_IN_STRSET_SE if you need all arguments to be evaluated. */ -#define NM_IN_STRSET(x, ...) \ - _NM_IN_STRSET_EVAL_N(||, _NM_IN_STRSET_op_streq, x, NM_NARG(__VA_ARGS__), __VA_ARGS__) +#define NM_IN_STRSET(x1, ...) _NM_IN_STRSET_EVAL(||, _NM_IN_STRSET_EVAL_OP_STREQ, x1, __VA_ARGS__) /* "SE" stands for "side-effect". Contrary to NM_IN_STRSET(), this does not do * short-circuit evaluation, which can make a difference if the arguments have * side-effects. */ -#define NM_IN_STRSET_SE(x, ...) \ - _NM_IN_STRSET_EVAL_N(|, _NM_IN_STRSET_op_streq, x, NM_NARG(__VA_ARGS__), __VA_ARGS__) +#define NM_IN_STRSET_SE(x1, ...) _NM_IN_STRSET_EVAL(|, _NM_IN_STRSET_EVAL_OP_STREQ, x1, __VA_ARGS__) /*****************************************************************************/ @@ -626,6 +869,19 @@ nm_close(int fd) return r; } +static inline bool +nm_clear_fd(int *p_fd) +{ + int fd; + + if (!p_fd || (fd = *p_fd) < 0) + return false; + + *p_fd = -1; + nm_close(fd); + return true; +} + /*****************************************************************************/ /* Note: @value is only evaluated when *out_val is present. @@ -734,7 +990,7 @@ _nm_auto_fclose(FILE **pfd) int _changed = false; \ \ if (_pp && (_p = *_pp)) { \ - _nm_unused const void *_p_check_is_pointer = _p; \ + _NM_ENSURE_POINTER(_p); \ \ *_pp = NULL; \ \ @@ -757,14 +1013,15 @@ _nm_auto_fclose(FILE **pfd) /*****************************************************************************/ -#define nm_steal_pointer(pp) \ - ({ \ - typeof(*(pp)) *const _pp = (pp); \ - typeof(*_pp) _p = *_pp; \ - _nm_unused const void *const _p_type_check = _p; \ - \ - *_pp = NULL; \ - _p; \ +#define nm_steal_pointer(pp) \ + ({ \ + typeof(*(pp)) *const _pp = (pp); \ + typeof(*_pp) _p = *_pp; \ + \ + _NM_ENSURE_POINTER(_p); \ + \ + *_pp = NULL; \ + _p; \ }) /** @@ -774,15 +1031,15 @@ _nm_auto_fclose(FILE **pfd) * Returns: *p_val and sets *p_val to zero the same time. * Accepts %NULL, in which case also numeric 0 will be returned. */ -#define nm_steal_int(p_val) \ - ({ \ - typeof(p_val) const _p_val = (p_val); \ - typeof(*_p_val) _val = 0; \ - \ - if (_p_val && (_val = *_p_val)) { \ - *_p_val = 0; \ - } \ - _val; \ +#define nm_steal_int(p_val) \ + ({ \ + typeof(p_val) const _p_val = (p_val); \ + typeof(*_p_val) _val = 0; \ + \ + if (_p_val && ((_val = *_p_val) != 0)) { \ + *_p_val = 0; \ + } \ + _val; \ }) static inline int @@ -923,6 +1180,21 @@ nm_ptr_to_uintptr(const void *p) #define NM_AF_INET_SIZE 4 /* sizeof (in_addr_t) */ #define NM_AF_INET6_SIZE 16 /* sizeof (stuct in6_addr) */ +static inline const char * +nm_utils_addr_family_to_str(int addr_family) +{ + switch (addr_family) { + case NM_AF_UNSPEC: + return ""; + case NM_AF_INET: + return "4"; + case NM_AF_INET6: + return "6"; + } + nm_assert_not_reached(); + return "?"; +} + static inline char nm_utils_addr_family_to_char(int addr_family) { @@ -938,6 +1210,29 @@ nm_utils_addr_family_to_char(int addr_family) return '?'; } +#define nm_assert_addr_family(addr_family) \ + nm_assert(NM_IN_SET((addr_family), NM_AF_INET, NM_AF_INET6)) + +#define nm_assert_addr_family_or_unspec(addr_family) \ + nm_assert(NM_IN_SET((addr_family), NM_AF_UNSPEC, NM_AF_INET, NM_AF_INET6)) + +#define _NM_IS_IPv4(uniq, addr_family) \ + ({ \ + const int NM_UNIQ_T(_addr_family, uniq) = (addr_family); \ + \ + nm_assert_addr_family(NM_UNIQ_T(_addr_family, uniq)); \ + \ + (NM_UNIQ_T(_addr_family, uniq) == NM_AF_INET); \ + }) + +#define NM_IS_IPv4(addr_family) _NM_IS_IPv4(NM_UNIQ, addr_family) + +static inline int +nm_utils_addr_family_other(int addr_family) +{ + return NM_IS_IPv4(addr_family) ? NM_AF_INET6 : NM_AF_INET; +} + static inline size_t nm_utils_addr_family_to_size(int addr_family) { @@ -947,8 +1242,7 @@ nm_utils_addr_family_to_size(int addr_family) case NM_AF_INET6: return NM_AF_INET6_SIZE; } - nm_assert_not_reached(); - return 0; + return nm_assert_unreachable_val(0); } static inline int @@ -963,16 +1257,4 @@ nm_utils_addr_family_from_size(size_t len) return NM_AF_UNSPEC; } -#define nm_assert_addr_family(addr_family) \ - nm_assert(NM_IN_SET((addr_family), NM_AF_INET, NM_AF_INET6)) - -#define NM_IS_IPv4(addr_family) \ - ({ \ - const int _addr_family = (addr_family); \ - \ - nm_assert_addr_family(_addr_family); \ - \ - (_addr_family == NM_AF_INET); \ - }) - #endif /* __NM_STD_AUX_H__ */ diff --git a/src/libnm-systemd-core/meson.build b/src/libnm-systemd-core/meson.build index 7ecf3164..fb472a76 100644 --- a/src/libnm-systemd-core/meson.build +++ b/src/libnm-systemd-core/meson.build @@ -20,7 +20,7 @@ libnm_systemd_core = static_library( 'src/libsystemd-network/sd-dhcp6-lease.c', 'src/libsystemd-network/sd-ipv4acd.c', 'src/libsystemd-network/sd-ipv4ll.c', - 'src/libsystemd-network/sd-lldp.c', + 'src/libsystemd-network/sd-lldp-rx.c', 'src/libsystemd/sd-event/event-util.c', 'src/libsystemd/sd-event/sd-event.c', 'src/libsystemd/sd-id128/id128-util.c', diff --git a/src/libnm-systemd-core/nm-sd.h b/src/libnm-systemd-core/nm-sd.h index f3461974..0ec2f16e 100644 --- a/src/libnm-systemd-core/nm-sd.h +++ b/src/libnm-systemd-core/nm-sd.h @@ -8,8 +8,9 @@ #include "src/systemd/sd-dhcp-client.h" #include "src/systemd/sd-dhcp6-client.h" -#include "src/systemd/sd-lldp.h" #include "src/systemd/sd-ipv4ll.h" +#include "src/systemd/sd-lldp-rx.h" +#include "src/systemd/sd-lldp.h" /*****************************************************************************/ diff --git a/src/libnm-systemd-core/sd-adapt-core/nm-sd-adapt-core.h b/src/libnm-systemd-core/sd-adapt-core/nm-sd-adapt-core.h index 4aae34b8..7ce1f8c9 100644 --- a/src/libnm-systemd-core/sd-adapt-core/nm-sd-adapt-core.h +++ b/src/libnm-systemd-core/sd-adapt-core/nm-sd-adapt-core.h @@ -18,7 +18,7 @@ #define NETWORKMANAGER_COMPILATION NM_NETWORKMANAGER_COMPILATION_SYSTEMD #ifndef HAVE_SYS_AUXV_H - #define HAVE_SYS_AUXV_H 0 +#define HAVE_SYS_AUXV_H 0 #endif /***************************************************************************** @@ -28,62 +28,64 @@ #if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD - #include - #include - #include - #include - #include - #ifdef HAVE_SYS_AUXV_H - #include - #endif - #include - #include - #include - - /* Missing in Linux 3.2.0, in Ubuntu 12.04 */ - #ifndef BPF_XOR - #define BPF_XOR 0xa0 - #endif - - #ifndef ETHERTYPE_LLDP - #define ETHERTYPE_LLDP 0x88cc - #endif - - #ifndef HAVE_SECURE_GETENV - #ifdef HAVE___SECURE_GETENV - #define secure_getenv __secure_getenv - #else - #error neither secure_getenv nor __secure_getenv is available - #endif - #endif - - #include "libnm-base/nm-base.h" +#include +#include +#include +#include +#include +#ifdef HAVE_SYS_AUXV_H +#include +#endif +#include +#include +#include + +/* Missing in Linux 3.2.0, in Ubuntu 12.04 */ +#ifndef BPF_XOR +#define BPF_XOR 0xa0 +#endif + +#ifndef ETHERTYPE_LLDP +#define ETHERTYPE_LLDP 0x88cc +#endif + +#ifndef HAVE_SECURE_GETENV +#ifdef HAVE___SECURE_GETENV +#define secure_getenv __secure_getenv +#else +#error neither secure_getenv nor __secure_getenv is available +#endif +#endif + +#include "libnm-base/nm-base.h" /*****************************************************************************/ +#define HAVE_OPENSSL 0 + static inline int sd_notify(int unset_environment, const char *state) { return 0; } - /* Can't include both net/if.h and linux/if.h; so have to define this here */ - #ifndef IF_NAMESIZE - #define IF_NAMESIZE 16 - #endif +/* Can't include both net/if.h and linux/if.h; so have to define this here */ +#ifndef IF_NAMESIZE +#define IF_NAMESIZE 16 +#endif - #ifndef IFNAMSIZ - #define IFNAMSIZ IF_NAMESIZE - #endif +#ifndef IFNAMSIZ +#define IFNAMSIZ IF_NAMESIZE +#endif - #ifndef MAX_HANDLE_SZ - #define MAX_HANDLE_SZ 128 - #endif +#ifndef MAX_HANDLE_SZ +#define MAX_HANDLE_SZ 128 +#endif - #include "sd-id128.h" - #include "sparse-endian.h" - #include "async.h" - #include "util.h" +#include "sd-id128.h" +#include "sparse-endian.h" +#include "async.h" +#include "util.h" #endif /* (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD */ diff --git a/src/libnm-systemd-core/src/libsystemd-network/arp-util.c b/src/libnm-systemd-core/src/libsystemd-network/arp-util.c index 1c777d8a..46c4a8cb 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/arp-util.c +++ b/src/libnm-systemd-core/src/libsystemd-network/arp-util.c @@ -10,11 +10,13 @@ #include #include "arp-util.h" +#include "ether-addr-util.h" #include "fd-util.h" +#include "in-addr-util.h" #include "unaligned.h" #include "util.h" -int arp_network_bind_raw_socket(int ifindex, be32_t address, const struct ether_addr *eth_mac) { +int arp_update_filter(int fd, const struct in_addr *a, const struct ether_addr *eth_mac) { struct sock_filter filter[] = { BPF_STMT(BPF_LD + BPF_W + BPF_LEN, 0), /* A <- packet length */ BPF_JUMP(BPF_JMP + BPF_JGE + BPF_K, sizeof(struct ether_arp), 1, 0), /* packet >= arp packet ? */ @@ -48,13 +50,13 @@ int arp_network_bind_raw_socket(int ifindex, be32_t address, const struct ether_ BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 0, 0, 1), /* A == 0 ? */ BPF_STMT(BPF_RET + BPF_K, 0), /* ignore */ /* Sender Protocol Address or Target Protocol Address must be equal to the one we care about */ - BPF_STMT(BPF_LD + BPF_IMM, htobe32(address)), /* A <- clients IP */ + BPF_STMT(BPF_LD + BPF_IMM, htobe32(a->s_addr)), /* A <- clients IP */ BPF_STMT(BPF_MISC + BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD + BPF_W + BPF_ABS, offsetof(struct ether_arp, arp_spa)), /* A <- SPA */ BPF_STMT(BPF_ALU + BPF_XOR + BPF_X, 0), /* X xor A */ BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 0, 0, 1), /* A == 0 ? */ BPF_STMT(BPF_RET + BPF_K, 65535), /* return all */ - BPF_STMT(BPF_LD + BPF_IMM, htobe32(address)), /* A <- clients IP */ + BPF_STMT(BPF_LD + BPF_IMM, htobe32(a->s_addr)), /* A <- clients IP */ BPF_STMT(BPF_MISC + BPF_TAX, 0), /* X <- A */ BPF_STMT(BPF_LD + BPF_W + BPF_ABS, offsetof(struct ether_arp, arp_tpa)), /* A <- TPA */ BPF_STMT(BPF_ALU + BPF_XOR + BPF_X, 0), /* X xor A */ @@ -63,15 +65,25 @@ int arp_network_bind_raw_socket(int ifindex, be32_t address, const struct ether_ BPF_STMT(BPF_RET + BPF_K, 0), /* ignore */ }; struct sock_fprog fprog = { - .len = ELEMENTSOF(filter), - .filter = (struct sock_filter*) filter + .len = ELEMENTSOF(filter), + .filter = (struct sock_filter*) filter, }; + + assert(fd >= 0); + + if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &fprog, sizeof(fprog)) < 0) + return -errno; + + return 0; +} + +int arp_network_bind_raw_socket(int ifindex, const struct in_addr *a, const struct ether_addr *eth_mac) { union sockaddr_union link = { - .ll.sll_family = AF_PACKET, + .ll.sll_family = AF_PACKET, .ll.sll_protocol = htobe16(ETH_P_ARP), - .ll.sll_ifindex = ifindex, - .ll.sll_halen = ETH_ALEN, - .ll.sll_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, + .ll.sll_ifindex = ifindex, + .ll.sll_halen = ETH_ALEN, + .ll.sll_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, }; _cleanup_close_ int s = -1; int r; @@ -82,59 +94,57 @@ int arp_network_bind_raw_socket(int ifindex, be32_t address, const struct ether_ if (s < 0) return -errno; - r = setsockopt(s, SOL_SOCKET, SO_ATTACH_FILTER, &fprog, sizeof(fprog)); + r = arp_update_filter(s, a, eth_mac); if (r < 0) - return -errno; + return r; - r = bind(s, &link.sa, sizeof(link.ll)); - if (r < 0) + if (bind(s, &link.sa, sizeof(link.ll)) < 0) return -errno; return TAKE_FD(s); } -static int arp_send_packet(int fd, int ifindex, - be32_t pa, const struct ether_addr *ha, - bool announce) { +int arp_send_packet( + int fd, + int ifindex, + const struct in_addr *pa, + const struct ether_addr *ha, + bool announce) { + union sockaddr_union link = { - .ll.sll_family = AF_PACKET, + .ll.sll_family = AF_PACKET, .ll.sll_protocol = htobe16(ETH_P_ARP), - .ll.sll_ifindex = ifindex, - .ll.sll_halen = ETH_ALEN, - .ll.sll_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, + .ll.sll_ifindex = ifindex, + .ll.sll_halen = ETH_ALEN, + .ll.sll_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, }; struct ether_arp arp = { - .ea_hdr.ar_hrd = htobe16(ARPHRD_ETHER), /* HTYPE */ - .ea_hdr.ar_pro = htobe16(ETHERTYPE_IP), /* PTYPE */ - .ea_hdr.ar_hln = ETH_ALEN, /* HLEN */ - .ea_hdr.ar_pln = sizeof(be32_t), /* PLEN */ - .ea_hdr.ar_op = htobe16(ARPOP_REQUEST), /* REQUEST */ + .ea_hdr.ar_hrd = htobe16(ARPHRD_ETHER), /* HTYPE */ + .ea_hdr.ar_pro = htobe16(ETHERTYPE_IP), /* PTYPE */ + .ea_hdr.ar_hln = ETH_ALEN, /* HLEN */ + .ea_hdr.ar_pln = sizeof(struct in_addr), /* PLEN */ + .ea_hdr.ar_op = htobe16(ARPOP_REQUEST), /* REQUEST */ }; - int r; + ssize_t n; assert(fd >= 0); - assert(pa != 0); + assert(ifindex > 0); + assert(pa); + assert(in4_addr_is_set(pa)); assert(ha); + assert(!ether_addr_is_null(ha)); memcpy(&arp.arp_sha, ha, ETH_ALEN); - memcpy(&arp.arp_tpa, &pa, sizeof(pa)); + memcpy(&arp.arp_tpa, pa, sizeof(struct in_addr)); if (announce) - memcpy(&arp.arp_spa, &pa, sizeof(pa)); + memcpy(&arp.arp_spa, pa, sizeof(struct in_addr)); - r = sendto(fd, &arp, sizeof(struct ether_arp), 0, &link.sa, sizeof(link.ll)); - if (r < 0) + n = sendto(fd, &arp, sizeof(struct ether_arp), 0, &link.sa, sizeof(link.ll)); + if (n < 0) return -errno; + if (n != sizeof(struct ether_arp)) + return -EIO; return 0; } - -int arp_send_probe(int fd, int ifindex, - be32_t pa, const struct ether_addr *ha) { - return arp_send_packet(fd, ifindex, pa, ha, false); -} - -int arp_send_announcement(int fd, int ifindex, - be32_t pa, const struct ether_addr *ha) { - return arp_send_packet(fd, ifindex, pa, ha, true); -} diff --git a/src/libnm-systemd-core/src/libsystemd-network/arp-util.h b/src/libnm-systemd-core/src/libsystemd-network/arp-util.h index 2dac8cfb..e8615a15 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/arp-util.h +++ b/src/libnm-systemd-core/src/libsystemd-network/arp-util.h @@ -6,13 +6,31 @@ ***/ #include +#include #include "socket-util.h" #include "sparse-endian.h" -int arp_network_bind_raw_socket(int index, be32_t address, const struct ether_addr *eth_mac); +int arp_update_filter(int fd, const struct in_addr *a, const struct ether_addr *eth_mac); +int arp_network_bind_raw_socket(int ifindex, const struct in_addr *a, const struct ether_addr *eth_mac); -int arp_send_probe(int fd, int ifindex, - be32_t pa, const struct ether_addr *ha); -int arp_send_announcement(int fd, int ifindex, - be32_t pa, const struct ether_addr *ha); +int arp_send_packet( + int fd, + int ifindex, + const struct in_addr *pa, + const struct ether_addr *ha, + bool announce); +static inline int arp_send_probe( + int fd, + int ifindex, + const struct in_addr *pa, + const struct ether_addr *ha) { + return arp_send_packet(fd, ifindex, pa, ha, false); +} +static inline int arp_send_announcement( + int fd, + int ifindex, + const struct in_addr *pa, + const struct ether_addr *ha) { + return arp_send_packet(fd, ifindex, pa, ha, true); +} diff --git a/src/libnm-systemd-core/src/libsystemd-network/dhcp-identifier.c b/src/libnm-systemd-core/src/libsystemd-network/dhcp-identifier.c index 0720e381..bd47ff41 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/dhcp-identifier.c +++ b/src/libnm-systemd-core/src/libsystemd-network/dhcp-identifier.c @@ -14,6 +14,7 @@ #include "network-util.h" #include "siphash24.h" #include "sparse-endian.h" +#include "stat-util.h" #include "stdio-util.h" #include "udev-util.h" #include "virt.h" @@ -166,38 +167,40 @@ int dhcp_identifier_set_iaid( const uint8_t *mac, size_t mac_len, bool legacy_unstable_byteorder, + bool use_mac, void *_id) { #if 0 /* NM_IGNORED */ + /* name is a pointer to memory in the sd_device struct, so must * have the same scope */ _cleanup_(sd_device_unrefp) sd_device *device = NULL; const char *name = NULL; - uint64_t id; uint32_t id32; + uint64_t id; + int r; + + if (path_is_read_only_fs("/sys") <= 0 && !use_mac) { + /* udev should be around */ + + r = sd_device_new_from_ifindex(&device, ifindex); + if (r < 0) + return r; + + r = sd_device_get_is_initialized(device); + if (r < 0) + return r; + if (r == 0) + /* not yet ready */ + return -EBUSY; + + r = device_is_renaming(device); + if (r < 0) + return r; + if (r > 0) + /* device is under renaming */ + return -EBUSY; - if (detect_container() <= 0) { - /* not in a container, udev will be around */ - char ifindex_str[1 + DECIMAL_STR_MAX(int)]; - int r; - - xsprintf(ifindex_str, "n%d", ifindex); - if (sd_device_new_from_device_id(&device, ifindex_str) >= 0) { - r = sd_device_get_is_initialized(device); - if (r < 0) - return r; - if (r == 0) - /* not yet ready */ - return -EBUSY; - - r = device_is_renaming(device); - if (r < 0) - return r; - if (r > 0) - /* device is under renaming */ - return -EBUSY; - - name = net_get_name_persistent(device); - } + name = net_get_name_persistent(device); } if (name) diff --git a/src/libnm-systemd-core/src/libsystemd-network/dhcp-identifier.h b/src/libnm-systemd-core/src/libsystemd-network/dhcp-identifier.h index 1d9a9c55..6c24af03 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/dhcp-identifier.h +++ b/src/libnm-systemd-core/src/libsystemd-network/dhcp-identifier.h @@ -59,4 +59,4 @@ int dhcp_identifier_set_duid_llt(struct duid *duid, usec_t t, const uint8_t *add int dhcp_identifier_set_duid_ll(struct duid *duid, const uint8_t *addr, size_t addr_len, uint16_t arp_type, size_t *len); int dhcp_identifier_set_duid_en(struct duid *duid, size_t *len); int dhcp_identifier_set_duid_uuid(struct duid *duid, size_t *len); -int dhcp_identifier_set_iaid(int ifindex, const uint8_t *mac, size_t mac_len, bool legacy_unstable_byteorder, void *_id); +int dhcp_identifier_set_iaid(int ifindex, const uint8_t *mac, size_t mac_len, bool legacy_unstable_byteorder, bool use_mac, void *_id); diff --git a/src/libnm-systemd-core/src/libsystemd-network/dhcp-internal.h b/src/libnm-systemd-core/src/libsystemd-network/dhcp-internal.h index d8c42757..6538f05b 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/dhcp-internal.h +++ b/src/libnm-systemd-core/src/libsystemd-network/dhcp-internal.h @@ -12,7 +12,7 @@ #include "sd-dhcp-client.h" #include "dhcp-protocol.h" -#include "log-link.h" +#include "network-common.h" #include "socket-util.h" typedef struct sd_dhcp_option { @@ -30,6 +30,8 @@ typedef struct DHCPServerData { extern const struct hash_ops dhcp_option_hash_ops; +typedef struct sd_dhcp_client sd_dhcp_client; + int dhcp_network_bind_raw_socket(int ifindex, union sockaddr_union *link, uint32_t xid, const uint8_t *mac_addr, size_t mac_addr_len, const uint8_t *bcast_addr, size_t bcast_addr_len, @@ -62,6 +64,8 @@ void dhcp_packet_append_ip_headers(DHCPPacket *packet, be32_t source_addr, int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum, uint16_t port); +void dhcp_client_set_test_mode(sd_dhcp_client *client, bool test_mode); + /* If we are invoking callbacks of a dhcp-client, ensure unreffing the * client from the callback doesn't destroy the object we are working * on */ @@ -71,10 +75,10 @@ int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum, ui #define log_dhcp_client_errno(client, error, fmt, ...) \ log_interface_prefix_full_errno( \ "DHCPv4 client: ", \ - sd_dhcp_client_get_ifname(client), \ + sd_dhcp_client, client, \ error, fmt, ##__VA_ARGS__) #define log_dhcp_client(client, fmt, ...) \ log_interface_prefix_full_errno_zerook( \ "DHCPv4 client: ", \ - sd_dhcp_client_get_ifname(client), \ + sd_dhcp_client, client, \ 0, fmt, ##__VA_ARGS__) diff --git a/src/libnm-systemd-core/src/libsystemd-network/dhcp6-internal.h b/src/libnm-systemd-core/src/libsystemd-network/dhcp6-internal.h index 34e1f61c..4eb56aa8 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/dhcp6-internal.h +++ b/src/libnm-systemd-core/src/libsystemd-network/dhcp6-internal.h @@ -13,8 +13,8 @@ #include "hashmap.h" #include "list.h" -#include "log-link.h" #include "macro.h" +#include "network-common.h" #include "sparse-endian.h" typedef struct sd_dhcp6_option { @@ -91,6 +91,8 @@ typedef struct DHCP6IA { LIST_HEAD(DHCP6Address, addresses); } DHCP6IA; +typedef struct sd_dhcp6_client sd_dhcp6_client; + int dhcp6_option_append(uint8_t **buf, size_t *buflen, uint16_t code, size_t optlen, const void *optval); int dhcp6_option_append_ia(uint8_t **buf, size_t *buflen, const DHCP6IA *ia); @@ -99,15 +101,29 @@ int dhcp6_option_append_fqdn(uint8_t **buf, size_t *buflen, const char *fqdn); int dhcp6_option_append_user_class(uint8_t **buf, size_t *buflen, char * const *user_class); int dhcp6_option_append_vendor_class(uint8_t **buf, size_t *buflen, char * const *user_class); int dhcp6_option_append_vendor_option(uint8_t **buf, size_t *buflen, OrderedHashmap *vendor_options); -int dhcp6_option_parse(uint8_t **buf, size_t *buflen, uint16_t *optcode, - size_t *optlen, uint8_t **optvalue); -int dhcp6_option_parse_status(DHCP6Option *option, size_t len); -int dhcp6_option_parse_ia(sd_dhcp6_client *client, DHCP6Option *iaoption, DHCP6IA *ia, uint16_t *ret_status_code); -int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen, - struct in6_addr **addrs, size_t count); -int dhcp6_option_parse_domainname_list(const uint8_t *optval, uint16_t optlen, - char ***str_arr); -int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char **str); + +int dhcp6_option_parse( + const uint8_t *buf, + size_t buflen, + size_t *offset, + uint16_t *ret_option_code, + size_t *ret_option_data_len, + const uint8_t **ret_option_data); +int dhcp6_option_parse_status(const uint8_t *data, size_t data_len, char **ret_status_message); +int dhcp6_option_parse_ia( + sd_dhcp6_client *client, + be32_t iaid, + uint16_t option_code, + size_t option_data_len, + const uint8_t *option_data, + DHCP6IA *ret); +int dhcp6_option_parse_addresses( + const uint8_t *optval, + size_t optlen, + struct in6_addr **addrs, + size_t *count); +int dhcp6_option_parse_domainname_list(const uint8_t *optval, size_t optlen, char ***ret); +int dhcp6_option_parse_domainname(const uint8_t *optval, size_t optlen, char **ret); int dhcp6_network_bind_udp_socket(int ifindex, struct in6_addr *address); int dhcp6_network_send_udp_socket(int s, struct in6_addr *address, @@ -118,13 +134,15 @@ int dhcp6_message_type_from_string(const char *s) _pure_; const char *dhcp6_message_status_to_string(int s) _const_; int dhcp6_message_status_from_string(const char *s) _pure_; +void dhcp6_client_set_test_mode(sd_dhcp6_client *client, bool test_mode); + #define log_dhcp6_client_errno(client, error, fmt, ...) \ log_interface_prefix_full_errno( \ "DHCPv6 client: ", \ - sd_dhcp6_client_get_ifname(client), \ + sd_dhcp6_client, client, \ error, fmt, ##__VA_ARGS__) #define log_dhcp6_client(client, fmt, ...) \ log_interface_prefix_full_errno_zerook( \ "DHCPv6 client: ", \ - sd_dhcp6_client_get_ifname(client), \ + sd_dhcp6_client, client, \ 0, fmt, ##__VA_ARGS__) diff --git a/src/libnm-systemd-core/src/libsystemd-network/dhcp6-lease-internal.h b/src/libnm-systemd-core/src/libsystemd-network/dhcp6-lease-internal.h index 391b4f1f..8801497b 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/dhcp6-lease-internal.h +++ b/src/libnm-systemd-core/src/libsystemd-network/dhcp6-lease-internal.h @@ -28,11 +28,11 @@ struct sd_dhcp6_lease { struct in6_addr *dns; size_t dns_count; char **domains; - size_t domains_count; struct in6_addr *ntp; size_t ntp_count; char **ntp_fqdn; - size_t ntp_fqdn_count; + struct in6_addr *sntp; + size_t sntp_count; char *fqdn; }; @@ -50,12 +50,10 @@ int dhcp6_lease_get_rapid_commit(sd_dhcp6_lease *lease, bool *rapid_commit); int dhcp6_lease_get_iaid(sd_dhcp6_lease *lease, be32_t *iaid); int dhcp6_lease_get_pd_iaid(sd_dhcp6_lease *lease, be32_t *iaid); -int dhcp6_lease_set_dns(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen); -int dhcp6_lease_set_domains(sd_dhcp6_lease *lease, uint8_t *optval, - size_t optlen); -int dhcp6_lease_set_ntp(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen); -int dhcp6_lease_set_sntp(sd_dhcp6_lease *lease, uint8_t *optval, - size_t optlen) ; +int dhcp6_lease_add_dns(sd_dhcp6_lease *lease, const uint8_t *optval, size_t optlen); +int dhcp6_lease_add_domains(sd_dhcp6_lease *lease, const uint8_t *optval, size_t optlen); +int dhcp6_lease_add_ntp(sd_dhcp6_lease *lease, const uint8_t *optval, size_t optlen); +int dhcp6_lease_add_sntp(sd_dhcp6_lease *lease, const uint8_t *optval, size_t optlen) ; int dhcp6_lease_set_fqdn(sd_dhcp6_lease *lease, const uint8_t *optval, size_t optlen); int dhcp6_lease_new(sd_dhcp6_lease **ret); diff --git a/src/libnm-systemd-core/src/libsystemd-network/dhcp6-option.c b/src/libnm-systemd-core/src/libsystemd-network/dhcp6-option.c index d9e24585..4249f90d 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/dhcp6-option.c +++ b/src/libnm-systemd-core/src/libsystemd-network/dhcp6-option.c @@ -16,29 +16,12 @@ #include "dhcp6-lease-internal.h" #include "dhcp6-protocol.h" #include "dns-domain.h" +#include "escape.h" #include "memory-util.h" #include "sparse-endian.h" #include "strv.h" #include "unaligned.h" -typedef struct DHCP6StatusOption { - struct DHCP6Option option; - be16_t status; - char msg[]; -} _packed_ DHCP6StatusOption; - -typedef struct DHCP6AddressOption { - struct DHCP6Option option; - struct iaaddr iaaddr; - uint8_t options[]; -} _packed_ DHCP6AddressOption; - -typedef struct DHCP6PDPrefixOption { - struct DHCP6Option option; - struct iapdprefix iapdprefix; - uint8_t options[]; -} _packed_ DHCP6PDPrefixOption; - #define DHCP6_OPTION_IA_NA_LEN (sizeof(struct ia_na)) #define DHCP6_OPTION_IA_PD_LEN (sizeof(struct ia_pd)) #define DHCP6_OPTION_IA_TA_LEN (sizeof(struct ia_ta)) @@ -372,337 +355,410 @@ int dhcp6_option_append_vendor_class(uint8_t **buf, size_t *buflen, char * const return dhcp6_option_append(buf, buflen, SD_DHCP6_OPTION_VENDOR_CLASS, total, p); } -static int option_parse_hdr(uint8_t **buf, size_t *buflen, uint16_t *optcode, size_t *optlen) { - DHCP6Option *option = (DHCP6Option*) *buf; - uint16_t len; +int dhcp6_option_parse( + const uint8_t *buf, + size_t buflen, + size_t *offset, + uint16_t *ret_option_code, + size_t *ret_option_data_len, + const uint8_t **ret_option_data) { - assert_return(buf, -EINVAL); - assert_return(optcode, -EINVAL); - assert_return(optlen, -EINVAL); + const DHCP6Option *option; + size_t len; - if (*buflen < offsetof(DHCP6Option, data)) - return -ENOMSG; + assert(buf); + assert(offset); + assert(ret_option_code); + assert(ret_option_data_len); + assert(ret_option_data); - len = be16toh(option->len); + if (buflen < offsetof(DHCP6Option, data)) + return -EBADMSG; - if (len > *buflen) - return -ENOMSG; + if (*offset >= buflen - offsetof(DHCP6Option, data)) + return -EBADMSG; + + option = (const DHCP6Option*) (buf + *offset); + len = be16toh(option->len); - *optcode = be16toh(option->code); - *optlen = len; + if (len > buflen - offsetof(DHCP6Option, data) - *offset) + return -EBADMSG; - *buf += 4; - *buflen -= 4; + *offset += offsetof(DHCP6Option, data) + len; + *ret_option_code = be16toh(option->code); + *ret_option_data_len = len; + *ret_option_data = option->data; return 0; } -int dhcp6_option_parse(uint8_t **buf, size_t *buflen, uint16_t *optcode, - size_t *optlen, uint8_t **optvalue) { - int r; +int dhcp6_option_parse_status(const uint8_t *data, size_t data_len, char **ret_status_message) { + assert(data); - assert_return(buf && buflen && optcode && optlen && optvalue, -EINVAL); + if (data_len < sizeof(uint16_t)) + return -EBADMSG; - r = option_parse_hdr(buf, buflen, optcode, optlen); - if (r < 0) - return r; + if (ret_status_message) { + char *msg; - if (*optlen > *buflen) - return -ENOBUFS; + /* The status message MUST NOT be null-terminated. See section 21.13 of RFC8415. + * Let's escape unsafe characters for safety. */ + msg = cescape_length((const char*) (data + sizeof(uint16_t)), data_len - sizeof(uint16_t)); + if (!msg) + return -ENOMEM; - *optvalue = *buf; - *buflen -= *optlen; - *buf += *optlen; + *ret_status_message = msg; + } - return 0; + return unaligned_read_be16(data); } -int dhcp6_option_parse_status(DHCP6Option *option, size_t len) { - DHCP6StatusOption *statusopt = (DHCP6StatusOption *)option; +static int dhcp6_option_parse_ia_options(sd_dhcp6_client *client, const uint8_t *buf, size_t buflen) { + int r; - if (len < sizeof(DHCP6StatusOption) || - be16toh(option->len) + offsetof(DHCP6Option, data) < sizeof(DHCP6StatusOption)) - return -ENOBUFS; + assert(buf); + + for(size_t offset = 0; offset < buflen;) { + const uint8_t *data; + size_t data_len; + uint16_t code; + + r = dhcp6_option_parse(buf, buflen, &offset, &code, &data_len, &data); + if (r < 0) + return r; + + switch(code) { + case SD_DHCP6_OPTION_STATUS_CODE: { + _cleanup_free_ char *msg = NULL; + + r = dhcp6_option_parse_status(data, data_len, &msg); + if (r == -ENOMEM) + return r; + if (r < 0) + /* Let's log but ignore the invalid status option. */ + log_dhcp6_client_errno(client, r, + "Received an IA address or PD prefix option with an invalid status sub option, ignoring: %m"); + else if (r > 0) + return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), + "Received an IA address or PD prefix option with non-zero status: %s%s%s", + strempty(msg), isempty(msg) ? "" : ": ", + dhcp6_message_status_to_string(r)); + break; + } + default: + log_dhcp6_client(client, "Received an unknown sub option %u in IA address or PD prefix, ignoring.", code); + } + } - return be16toh(statusopt->status); + return 0; } -static int dhcp6_option_parse_address(sd_dhcp6_client *client, DHCP6Option *option, DHCP6IA *ia, uint32_t *ret_lifetime_valid) { - DHCP6AddressOption *addr_option = (DHCP6AddressOption *)option; - DHCP6Address *addr; +static int dhcp6_option_parse_ia_address(sd_dhcp6_client *client, const uint8_t *data, size_t len, DHCP6Address **ret) { uint32_t lt_valid, lt_pref; + DHCP6Address *a; int r; - if (be16toh(option->len) + offsetof(DHCP6Option, data) < sizeof(*addr_option)) - return -ENOBUFS; + assert(data); + assert(ret); + + if (len < sizeof(struct iaaddr)) + return -EBADMSG; - lt_valid = be32toh(addr_option->iaaddr.lifetime_valid); - lt_pref = be32toh(addr_option->iaaddr.lifetime_preferred); + lt_valid = be32toh(((const struct iaaddr*) data)->lifetime_valid); + lt_pref = be32toh(((const struct iaaddr*) data)->lifetime_preferred); - if (lt_valid == 0 || lt_pref > lt_valid) + if (lt_valid == 0) return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), - "Valid lifetime of an IA address is zero or " - "preferred lifetime %"PRIu32" > valid lifetime %"PRIu32, + "Received an IA address with zero valid lifetime, ignoring."); + if (lt_pref > lt_valid) + return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), + "Received an IA address with preferred lifetime %"PRIu32 + " larger than valid lifetime %"PRIu32", ignoring.", lt_pref, lt_valid); - if (be16toh(option->len) + offsetof(DHCP6Option, data) > sizeof(*addr_option)) { - r = dhcp6_option_parse_status((DHCP6Option *)addr_option->options, be16toh(option->len) + offsetof(DHCP6Option, data) - sizeof(*addr_option)); + if (len > sizeof(struct iaaddr)) { + r = dhcp6_option_parse_ia_options(client, data + sizeof(struct iaaddr), len - sizeof(struct iaaddr)); if (r < 0) return r; - if (r > 0) - return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), - "Non-zero status code '%s' for address is received", - dhcp6_message_status_to_string(r)); } - addr = new0(DHCP6Address, 1); - if (!addr) + a = new(DHCP6Address, 1); + if (!a) return -ENOMEM; - LIST_INIT(addresses, addr); - memcpy(&addr->iaaddr, option->data, sizeof(addr->iaaddr)); - - LIST_PREPEND(addresses, ia->addresses, addr); - - *ret_lifetime_valid = be32toh(addr->iaaddr.lifetime_valid); + LIST_INIT(addresses, a); + memcpy(&a->iaaddr, data, sizeof(struct iaaddr)); + *ret = a; return 0; } -static int dhcp6_option_parse_pdprefix(sd_dhcp6_client *client, DHCP6Option *option, DHCP6IA *ia, uint32_t *ret_lifetime_valid) { - DHCP6PDPrefixOption *pdprefix_option = (DHCP6PDPrefixOption *)option; - DHCP6Address *prefix; +static int dhcp6_option_parse_ia_pdprefix(sd_dhcp6_client *client, const uint8_t *data, size_t len, DHCP6Address **ret) { uint32_t lt_valid, lt_pref; + DHCP6Address *a; int r; - if (be16toh(option->len) + offsetof(DHCP6Option, data) < sizeof(*pdprefix_option)) - return -ENOBUFS; + if (len < sizeof(struct iapdprefix)) + return -ENOMSG; - lt_valid = be32toh(pdprefix_option->iapdprefix.lifetime_valid); - lt_pref = be32toh(pdprefix_option->iapdprefix.lifetime_preferred); + lt_valid = be32toh(((const struct iapdprefix*) data)->lifetime_valid); + lt_pref = be32toh(((const struct iapdprefix*) data)->lifetime_preferred); - if (lt_valid == 0 || lt_pref > lt_valid) + if (lt_valid == 0) + return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), + "Received a PD prefix with zero valid lifetime, ignoring."); + if (lt_pref > lt_valid) return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), - "Valid lifetieme of a PD prefix is zero or " - "preferred lifetime %"PRIu32" > valid lifetime %"PRIu32, + "Received a PD prefix with preferred lifetime %"PRIu32 + " larger than valid lifetime %"PRIu32", ignoring.", lt_pref, lt_valid); - if (be16toh(option->len) + offsetof(DHCP6Option, data) > sizeof(*pdprefix_option)) { - r = dhcp6_option_parse_status((DHCP6Option *)pdprefix_option->options, be16toh(option->len) + offsetof(DHCP6Option, data) - sizeof(*pdprefix_option)); + if (len > sizeof(struct iapdprefix)) { + r = dhcp6_option_parse_ia_options(client, data + sizeof(struct iapdprefix), len - sizeof(struct iapdprefix)); if (r < 0) return r; - if (r > 0) - return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), - "Non-zero status code '%s' for PD prefix is received", - dhcp6_message_status_to_string(r)); } - prefix = new0(DHCP6Address, 1); - if (!prefix) + a = new(DHCP6Address, 1); + if (!a) return -ENOMEM; - LIST_INIT(addresses, prefix); - memcpy(&prefix->iapdprefix, option->data, sizeof(prefix->iapdprefix)); - - LIST_PREPEND(addresses, ia->addresses, prefix); - - *ret_lifetime_valid = be32toh(prefix->iapdprefix.lifetime_valid); + LIST_INIT(addresses, a); + memcpy(&a->iapdprefix, data, sizeof(struct iapdprefix)); + *ret = a; return 0; } -int dhcp6_option_parse_ia(sd_dhcp6_client *client, DHCP6Option *iaoption, DHCP6IA *ia, uint16_t *ret_status_code) { - uint32_t lt_t1, lt_t2, lt_valid = 0, lt_min = UINT32_MAX; - uint16_t iatype, optlen; - size_t iaaddr_offset; - int r = 0, status; - size_t i, len; - uint16_t opt; +int dhcp6_option_parse_ia( + sd_dhcp6_client *client, + be32_t iaid, + uint16_t option_code, + size_t option_data_len, + const uint8_t *option_data, + DHCP6IA *ret) { + + _cleanup_(dhcp6_lease_free_ia) DHCP6IA ia = {}; + uint32_t lt_t1, lt_t2, lt_min = UINT32_MAX; + be32_t received_iaid; + size_t offset; + int r; - assert_return(ia, -EINVAL); - assert_return(!ia->addresses, -EINVAL); + assert(IN_SET(option_code, SD_DHCP6_OPTION_IA_NA, SD_DHCP6_OPTION_IA_TA, SD_DHCP6_OPTION_IA_PD)); + assert(option_data); + assert(ret); - iatype = be16toh(iaoption->code); - len = be16toh(iaoption->len); + /* This will return the following: + * -ENOMEM: memory allocation error, + * -ENOANO: unmatching IAID, + * -EINVAL: non-zero status code, or invalid lifetime, + * -EBADMSG: invalid message format, + * -ENODATA: no valid address or PD prefix, + * 0: success. */ - switch (iatype) { + switch (option_code) { case SD_DHCP6_OPTION_IA_NA: - if (len < DHCP6_OPTION_IA_NA_LEN) - return -ENOBUFS; - - iaaddr_offset = DHCP6_OPTION_IA_NA_LEN; - memcpy(&ia->ia_na, iaoption->data, sizeof(ia->ia_na)); - - lt_t1 = be32toh(ia->ia_na.lifetime_t1); - lt_t2 = be32toh(ia->ia_na.lifetime_t2); + if (option_data_len < DHCP6_OPTION_IA_NA_LEN) + return -EBADMSG; - if (lt_t1 > lt_t2) - return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), - "IA NA T1 %"PRIu32"sec > T2 %"PRIu32"sec", - lt_t1, lt_t2); + offset = DHCP6_OPTION_IA_NA_LEN; + received_iaid = ((const struct ia_na*) option_data)->id; + lt_t1 = be32toh(((const struct ia_na*) option_data)->lifetime_t1); + lt_t2 = be32toh(((const struct ia_na*) option_data)->lifetime_t2); break; case SD_DHCP6_OPTION_IA_PD: - if (len < sizeof(ia->ia_pd)) - return -ENOBUFS; - - iaaddr_offset = sizeof(ia->ia_pd); - memcpy(&ia->ia_pd, iaoption->data, sizeof(ia->ia_pd)); - - lt_t1 = be32toh(ia->ia_pd.lifetime_t1); - lt_t2 = be32toh(ia->ia_pd.lifetime_t2); + if (option_data_len < DHCP6_OPTION_IA_PD_LEN) + return -EBADMSG; - if (lt_t1 > lt_t2) - return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), - "IA PD T1 %"PRIu32"sec > T2 %"PRIu32"sec", - lt_t1, lt_t2); + offset = DHCP6_OPTION_IA_PD_LEN; + received_iaid = ((const struct ia_pd*) option_data)->id; + lt_t1 = be32toh(((const struct ia_pd*) option_data)->lifetime_t1); + lt_t2 = be32toh(((const struct ia_pd*) option_data)->lifetime_t2); break; case SD_DHCP6_OPTION_IA_TA: - if (len < DHCP6_OPTION_IA_TA_LEN) - return -ENOBUFS; + if (option_data_len < DHCP6_OPTION_IA_TA_LEN) + return -ENOMSG; - iaaddr_offset = DHCP6_OPTION_IA_TA_LEN; - memcpy(&ia->ia_ta.id, iaoption->data, sizeof(ia->ia_ta)); + offset = DHCP6_OPTION_IA_TA_LEN; + received_iaid = ((const struct ia_ta*) option_data)->id; + lt_t1 = lt_t2 = 0; /* No lifetime for IA_TA. */ break; default: - return -ENOMSG; + assert_not_reached(); } - ia->type = iatype; - i = iaaddr_offset; + /* According to RFC8415, IAs which do not match the client's IAID should be ignored, + * but not necessary to ignore or refuse the whole message. */ + if (received_iaid != iaid) + return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(ENOANO), + "Received an IA option with a different IAID " + "from the one chosen by the client, ignoring."); - while (i < len) { - DHCP6Option *option = (DHCP6Option *)&iaoption->data[i]; + if (lt_t1 > lt_t2) + return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), + "Received an IA option with T1 %"PRIu32"sec > T2 %"PRIu32"sec, ignoring.", + lt_t1, lt_t2); - if (len < i + sizeof(*option) || len < i + sizeof(*option) + be16toh(option->len)) - return -ENOBUFS; + for (; offset < option_data_len;) { + const uint8_t *subdata; + size_t subdata_len; + uint16_t subopt; - opt = be16toh(option->code); - optlen = be16toh(option->len); + r = dhcp6_option_parse(option_data, option_data_len, &offset, &subopt, &subdata_len, &subdata); + if (r < 0) + return r; - switch (opt) { - case SD_DHCP6_OPTION_IAADDR: + switch (subopt) { + case SD_DHCP6_OPTION_IAADDR: { + DHCP6Address *a; - if (!IN_SET(ia->type, SD_DHCP6_OPTION_IA_NA, SD_DHCP6_OPTION_IA_TA)) - return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), - "IA Address option not in IA NA or TA option"); + if (!IN_SET(option_code, SD_DHCP6_OPTION_IA_NA, SD_DHCP6_OPTION_IA_TA)) { + log_dhcp6_client(client, "Received an IA_PD option with an IA address, ignoring."); + continue; + } - r = dhcp6_option_parse_address(client, option, ia, <_valid); - if (r < 0 && r != -EINVAL) + r = dhcp6_option_parse_ia_address(client, subdata, subdata_len, &a); + if (r == -ENOMEM) return r; - if (r >= 0 && lt_valid < lt_min) - lt_min = lt_valid; + if (r < 0) + /* Ignore the sub-option on non-critical errors. */ + continue; + lt_min = MIN(lt_min, be32toh(a->iaaddr.lifetime_valid)); + LIST_PREPEND(addresses, ia.addresses, a); break; + } + case SD_DHCP6_OPTION_IA_PD_PREFIX: { + DHCP6Address *a; - case SD_DHCP6_OPTION_IA_PD_PREFIX: - - if (ia->type != SD_DHCP6_OPTION_IA_PD) - return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), - "IA PD Prefix option not in IA PD option"); + if (option_code != SD_DHCP6_OPTION_IA_PD) { + log_dhcp6_client(client, "Received an IA_NA or IA_TA option with an PD prefix, ignoring"); + continue; + } - r = dhcp6_option_parse_pdprefix(client, option, ia, <_valid); - if (r < 0 && r != -EINVAL) + r = dhcp6_option_parse_ia_pdprefix(client, subdata, subdata_len, &a); + if (r == -ENOMEM) return r; - if (r >= 0 && lt_valid < lt_min) - lt_min = lt_valid; + if (r < 0) + /* Ignore the sub-option on non-critical errors. */ + continue; + lt_min = MIN(lt_min, be32toh(a->iapdprefix.lifetime_valid)); + LIST_PREPEND(addresses, ia.addresses, a); break; + } + case SD_DHCP6_OPTION_STATUS_CODE: { + _cleanup_free_ char *msg = NULL; - case SD_DHCP6_OPTION_STATUS_CODE: - - status = dhcp6_option_parse_status(option, optlen + offsetof(DHCP6Option, data)); - if (status < 0) - return status; - - if (status > 0) { - if (ret_status_code) - *ret_status_code = status; - - log_dhcp6_client(client, "IA status %s", - dhcp6_message_status_to_string(status)); - - return 0; - } - + r = dhcp6_option_parse_status(subdata, subdata_len, &msg); + if (r == -ENOMEM) + return r; + if (r < 0) + log_dhcp6_client_errno(client, r, + "Received an IA option with an invalid status sub option, ignoring: %m"); + else if (r > 0) + return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), + "Received an IA option with non-zero status: %s%s%s", + strempty(msg), isempty(msg) ? "" : ": ", + dhcp6_message_status_to_string(r)); break; - + } default: - log_dhcp6_client(client, "Unknown IA option %d", opt); - break; + log_dhcp6_client(client, "Received an IA option with an unknown sub-option %u, ignoring", subopt); } + } - i += sizeof(*option) + optlen; + if (!ia.addresses) + return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(ENODATA), + "Received an IA option without valid IA addresses or PD prefixes, ignoring."); + + if (IN_SET(option_code, SD_DHCP6_OPTION_IA_NA, SD_DHCP6_OPTION_IA_PD) && + lt_t1 == 0 && lt_t2 == 0 && lt_min != UINT32_MAX) { + lt_t1 = lt_min / 2; + lt_t2 = lt_min / 10 * 8; + + log_dhcp6_client(client, "Received an IA option with both T1 and T2 equal to zero. " + "Adjusting them based on the minimum valid lifetime of IA addresses or PD prefixes: " + "T1=%"PRIu32"sec, T2=%"PRIu32"sec", lt_t1, lt_t2); } - switch(iatype) { + switch(option_code) { case SD_DHCP6_OPTION_IA_NA: - if (ia->ia_na.lifetime_t1 == 0 && ia->ia_na.lifetime_t2 == 0 && lt_min != UINT32_MAX) { - lt_t1 = lt_min / 2; - lt_t2 = lt_min / 10 * 8; - ia->ia_na.lifetime_t1 = htobe32(lt_t1); - ia->ia_na.lifetime_t2 = htobe32(lt_t2); - - log_dhcp6_client(client, "Computed IA NA T1 %"PRIu32"sec and T2 %"PRIu32"sec as both were zero", - lt_t1, lt_t2); - } - + *ret = (DHCP6IA) { + .type = option_code, + .ia_na.id = iaid, + .ia_na.lifetime_t1 = htobe32(lt_t1), + .ia_na.lifetime_t2 = htobe32(lt_t2), + .addresses = TAKE_PTR(ia.addresses), + }; + break; + case SD_DHCP6_OPTION_IA_TA: + *ret = (DHCP6IA) { + .type = option_code, + .ia_ta.id = iaid, + .addresses = TAKE_PTR(ia.addresses), + }; break; - case SD_DHCP6_OPTION_IA_PD: - if (ia->ia_pd.lifetime_t1 == 0 && ia->ia_pd.lifetime_t2 == 0 && lt_min != UINT32_MAX) { - lt_t1 = lt_min / 2; - lt_t2 = lt_min / 10 * 8; - ia->ia_pd.lifetime_t1 = htobe32(lt_t1); - ia->ia_pd.lifetime_t2 = htobe32(lt_t2); - - log_dhcp6_client(client, "Computed IA PD T1 %"PRIu32"sec and T2 %"PRIu32"sec as both were zero", - lt_t1, lt_t2); - } - + *ret = (DHCP6IA) { + .type = option_code, + .ia_pd.id = iaid, + .ia_pd.lifetime_t1 = htobe32(lt_t1), + .ia_pd.lifetime_t2 = htobe32(lt_t2), + .addresses = TAKE_PTR(ia.addresses), + }; break; - default: - break; + assert_not_reached(); } - if (ret_status_code) - *ret_status_code = 0; - - return 1; + return 0; } -int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen, - struct in6_addr **addrs, size_t count) { +int dhcp6_option_parse_addresses( + const uint8_t *optval, + size_t optlen, + struct in6_addr **addrs, + size_t *count) { + + assert(optval); + assert(addrs); + assert(count); if (optlen == 0 || optlen % sizeof(struct in6_addr) != 0) - return -EINVAL; + return -EBADMSG; - if (!GREEDY_REALLOC(*addrs, count * sizeof(struct in6_addr) + optlen)) + if (!GREEDY_REALLOC(*addrs, *count + optlen / sizeof(struct in6_addr))) return -ENOMEM; - memcpy(*addrs + count, optval, optlen); + memcpy(*addrs + *count, optval, optlen); + *count += optlen / sizeof(struct in6_addr); - count += optlen / sizeof(struct in6_addr); - - return count; + return 0; } -static int parse_domain(const uint8_t **data, uint16_t *len, char **out_domain) { - _cleanup_free_ char *ret = NULL; - const uint8_t *optval = *data; - uint16_t optlen = *len; - bool first = true; - size_t n = 0; +static int parse_domain(const uint8_t **data, size_t *len, char **ret) { + _cleanup_free_ char *domain = NULL; + const uint8_t *optval; + size_t optlen, n = 0; int r; + assert(data); + assert(*data); + assert(len); + assert(ret); + + optval = *data; + optlen = *len; + if (optlen <= 1) return -ENODATA; @@ -726,42 +782,44 @@ static int parse_domain(const uint8_t **data, uint16_t *len, char **out_domain) return -EMSGSIZE; /* Literal label */ - label = (const char *)optval; + label = (const char*) optval; optval += c; optlen -= c; - if (!GREEDY_REALLOC(ret, n + !first + DNS_LABEL_ESCAPED_MAX)) + if (!GREEDY_REALLOC(domain, n + (n != 0) + DNS_LABEL_ESCAPED_MAX)) return -ENOMEM; - if (first) - first = false; - else - ret[n++] = '.'; + if (n != 0) + domain[n++] = '.'; - r = dns_label_escape(label, c, ret + n, DNS_LABEL_ESCAPED_MAX); + r = dns_label_escape(label, c, domain + n, DNS_LABEL_ESCAPED_MAX); if (r < 0) return r; n += r; } - if (n) { - if (!GREEDY_REALLOC(ret, n + 1)) + if (n > 0) { + if (!GREEDY_REALLOC(domain, n + 1)) return -ENOMEM; - ret[n] = 0; + + domain[n] = '\0'; } - *out_domain = TAKE_PTR(ret); + *ret = TAKE_PTR(domain); *data = optval; *len = optlen; return n; } -int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char **str) { +int dhcp6_option_parse_domainname(const uint8_t *optval, size_t optlen, char **ret) { _cleanup_free_ char *domain = NULL; int r; + assert(optval); + assert(ret); + r = parse_domain(&optval, &optlen, &domain); if (r < 0) return r; @@ -770,39 +828,38 @@ int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char * if (optlen != 0) return -EINVAL; - *str = TAKE_PTR(domain); + *ret = TAKE_PTR(domain); return 0; } -int dhcp6_option_parse_domainname_list(const uint8_t *optval, uint16_t optlen, char ***str_arr) { - size_t idx = 0; +int dhcp6_option_parse_domainname_list(const uint8_t *optval, size_t optlen, char ***ret) { _cleanup_strv_free_ char **names = NULL; int r; + assert(optval); + assert(ret); + if (optlen <= 1) return -ENODATA; if (optval[optlen - 1] != '\0') return -EINVAL; while (optlen > 0) { - _cleanup_free_ char *ret = NULL; + _cleanup_free_ char *name = NULL; - r = parse_domain(&optval, &optlen, &ret); + r = parse_domain(&optval, &optlen, &name); if (r < 0) return r; if (r == 0) continue; - r = strv_extend(&names, ret); + r = strv_consume(&names, TAKE_PTR(name)); if (r < 0) return r; - - idx++; } - *str_arr = TAKE_PTR(names); - - return idx; + *ret = TAKE_PTR(names); + return 0; } static sd_dhcp6_option* dhcp6_option_free(sd_dhcp6_option *i) { diff --git a/src/libnm-systemd-core/src/libsystemd-network/lldp-internal.h b/src/libnm-systemd-core/src/libsystemd-network/lldp-internal.h deleted file mode 100644 index cf0578c5..00000000 --- a/src/libnm-systemd-core/src/libsystemd-network/lldp-internal.h +++ /dev/null @@ -1,48 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -#pragma once - -#include "sd-event.h" -#include "sd-lldp.h" - -#include "hashmap.h" -#include "log-link.h" -#include "prioq.h" - -struct sd_lldp { - unsigned n_ref; - - int ifindex; - char *ifname; - int fd; - - sd_event *event; - int64_t event_priority; - sd_event_source *io_event_source; - sd_event_source *timer_event_source; - - Prioq *neighbor_by_expiry; - Hashmap *neighbor_by_id; - - uint64_t neighbors_max; - - sd_lldp_callback_t callback; - void *userdata; - - uint16_t capability_mask; - - struct ether_addr filter_address; -}; - -const char* lldp_event_to_string(sd_lldp_event_t e) _const_; -sd_lldp_event_t lldp_event_from_string(const char *s) _pure_; - -#define log_lldp_errno(lldp, error, fmt, ...) \ - log_interface_prefix_full_errno( \ - "LLDP: ", \ - sd_lldp_get_ifname(lldp), \ - error, fmt, ##__VA_ARGS__) -#define log_lldp(lldp, fmt, ...) \ - log_interface_prefix_full_errno_zerook( \ - "LLDP: ", \ - sd_lldp_get_ifname(lldp), \ - 0, fmt, ##__VA_ARGS__) diff --git a/src/libnm-systemd-core/src/libsystemd-network/lldp-neighbor.c b/src/libnm-systemd-core/src/libsystemd-network/lldp-neighbor.c index 1b2108d8..3d6d7e42 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/lldp-neighbor.c +++ b/src/libnm-systemd-core/src/libsystemd-network/lldp-neighbor.c @@ -7,13 +7,15 @@ #include "ether-addr-util.h" #include "hexdecoct.h" #include "in-addr-util.h" -#include "lldp-internal.h" #include "lldp-neighbor.h" #include "memory-util.h" #include "missing_network.h" #include "unaligned.h" static void lldp_neighbor_id_hash_func(const LLDPNeighborID *id, struct siphash *state) { + assert(id); + assert(state); + siphash24_compress(id->chassis_id, id->chassis_id_size, state); siphash24_compress(&id->chassis_id_size, sizeof(id->chassis_id_size), state); siphash24_compress(id->port_id, id->port_id_size, state); @@ -21,16 +23,27 @@ static void lldp_neighbor_id_hash_func(const LLDPNeighborID *id, struct siphash } int lldp_neighbor_id_compare_func(const LLDPNeighborID *x, const LLDPNeighborID *y) { + assert(x); + assert(y); + return memcmp_nn(x->chassis_id, x->chassis_id_size, y->chassis_id, y->chassis_id_size) ?: memcmp_nn(x->port_id, x->port_id_size, y->port_id, y->port_id_size); } -DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(lldp_neighbor_hash_ops, LLDPNeighborID, lldp_neighbor_id_hash_func, lldp_neighbor_id_compare_func, - sd_lldp_neighbor, lldp_neighbor_unlink); +DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR( + lldp_neighbor_hash_ops, + LLDPNeighborID, + lldp_neighbor_id_hash_func, + lldp_neighbor_id_compare_func, + sd_lldp_neighbor, + lldp_neighbor_unlink); int lldp_neighbor_prioq_compare_func(const void *a, const void *b) { const sd_lldp_neighbor *x = a, *y = b; + assert(x); + assert(y); + return CMP(x->until, y->until); } @@ -38,14 +51,15 @@ _public_ sd_lldp_neighbor *sd_lldp_neighbor_ref(sd_lldp_neighbor *n) { if (!n) return NULL; - assert(n->n_ref > 0 || n->lldp); + assert(n->n_ref > 0 || n->lldp_rx); n->n_ref++; return n; } -static void lldp_neighbor_free(sd_lldp_neighbor *n) { - assert(n); +static sd_lldp_neighbor *lldp_neighbor_free(sd_lldp_neighbor *n) { + if (!n) + return NULL; free(n->id.port_id); free(n->id.chassis_id); @@ -55,7 +69,7 @@ static void lldp_neighbor_free(sd_lldp_neighbor *n) { free(n->mud_url); free(n->chassis_id_as_string); free(n->port_id_as_string); - free(n); + return mfree(n); } _public_ sd_lldp_neighbor *sd_lldp_neighbor_unref(sd_lldp_neighbor *n) { @@ -69,7 +83,7 @@ _public_ sd_lldp_neighbor *sd_lldp_neighbor_unref(sd_lldp_neighbor *n) { assert(n->n_ref > 0); n->n_ref--; - if (n->n_ref <= 0 && !n->lldp) + if (n->n_ref <= 0 && !n->lldp_rx) lldp_neighbor_free(n); return NULL; @@ -82,18 +96,18 @@ sd_lldp_neighbor *lldp_neighbor_unlink(sd_lldp_neighbor *n) { if (!n) return NULL; - if (!n->lldp) + if (!n->lldp_rx) return NULL; /* Only remove the neighbor object from the hash table if it's in there, don't complain if it isn't. This is * because we are used as destructor call for hashmap_clear() and thus sometimes are called to de-register * ourselves from the hashtable and sometimes are called after we already are de-registered. */ - (void) hashmap_remove_value(n->lldp->neighbor_by_id, &n->id, n); + (void) hashmap_remove_value(n->lldp_rx->neighbor_by_id, &n->id, n); - assert_se(prioq_remove(n->lldp->neighbor_by_expiry, n, &n->prioq_idx) >= 0); + assert_se(prioq_remove(n->lldp_rx->neighbor_by_expiry, n, &n->prioq_idx) >= 0); - n->lldp = NULL; + n->lldp_rx = NULL; if (n->n_ref <= 0) lldp_neighbor_free(n); @@ -114,7 +128,7 @@ sd_lldp_neighbor *lldp_neighbor_new(size_t raw_size) { return n; } -static int parse_string(sd_lldp *lldp, char **s, const void *q, size_t n) { +static int parse_string(sd_lldp_rx *lldp_rx, char **s, const void *q, size_t n) { const char *p = q; char *k; @@ -122,7 +136,7 @@ static int parse_string(sd_lldp *lldp, char **s, const void *q, size_t n) { assert(p || n == 0); if (*s) { - log_lldp(lldp, "Found duplicate string, ignoring field."); + log_lldp_rx(lldp_rx, "Found duplicate string, ignoring field."); return 0; } @@ -135,7 +149,7 @@ static int parse_string(sd_lldp *lldp, char **s, const void *q, size_t n) { /* Look for inner NULs */ if (memchr(p, 0, n)) { - log_lldp(lldp, "Found inner NUL in string, ignoring field."); + log_lldp_rx(lldp_rx, "Found inner NUL in string, ignoring field."); return 0; } @@ -159,14 +173,14 @@ int lldp_neighbor_parse(sd_lldp_neighbor *n) { assert(n); if (n->raw_size < sizeof(struct ether_header)) - return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG), - "Received truncated packet, ignoring."); + return log_lldp_rx_errno(n->lldp_rx, SYNTHETIC_ERRNO(EBADMSG), + "Received truncated packet, ignoring."); memcpy(&h, LLDP_NEIGHBOR_RAW(n), sizeof(h)); if (h.ether_type != htobe16(ETHERTYPE_LLDP)) - return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG), - "Received packet with wrong type, ignoring."); + return log_lldp_rx_errno(n->lldp_rx, SYNTHETIC_ERRNO(EBADMSG), + "Received packet with wrong type, ignoring."); if (h.ether_dhost[0] != 0x01 || h.ether_dhost[1] != 0x80 || @@ -174,8 +188,8 @@ int lldp_neighbor_parse(sd_lldp_neighbor *n) { h.ether_dhost[3] != 0x00 || h.ether_dhost[4] != 0x00 || !IN_SET(h.ether_dhost[5], 0x00, 0x03, 0x0e)) - return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG), - "Received packet with wrong destination address, ignoring."); + return log_lldp_rx_errno(n->lldp_rx, SYNTHETIC_ERRNO(EBADMSG), + "Received packet with wrong destination address, ignoring."); memcpy(&n->source_address, h.ether_shost, sizeof(struct ether_addr)); memcpy(&n->destination_address, h.ether_dhost, sizeof(struct ether_addr)); @@ -188,7 +202,7 @@ int lldp_neighbor_parse(sd_lldp_neighbor *n) { uint16_t length; if (left < 2) - return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG), + return log_lldp_rx_errno(n->lldp_rx, SYNTHETIC_ERRNO(EBADMSG), "TLV lacks header, ignoring."); type = p[0] >> 1; @@ -196,15 +210,15 @@ int lldp_neighbor_parse(sd_lldp_neighbor *n) { p += 2, left -= 2; if (left < length) - return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG), - "TLV truncated, ignoring datagram."); + return log_lldp_rx_errno(n->lldp_rx, SYNTHETIC_ERRNO(EBADMSG), + "TLV truncated, ignoring datagram."); switch (type) { case SD_LLDP_TYPE_END: if (length != 0) - return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG), - "End marker TLV not zero-sized, ignoring datagram."); + return log_lldp_rx_errno(n->lldp_rx, SYNTHETIC_ERRNO(EBADMSG), + "End marker TLV not zero-sized, ignoring datagram."); /* Note that after processing the SD_LLDP_TYPE_END left could still be > 0 * as the message may contain padding (see IEEE 802.1AB-2016, sec. 8.5.12) */ @@ -214,12 +228,12 @@ int lldp_neighbor_parse(sd_lldp_neighbor *n) { case SD_LLDP_TYPE_CHASSIS_ID: if (length < 2 || length > 256) /* includes the chassis subtype, hence one extra byte */ - return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG), - "Chassis ID field size out of range, ignoring datagram."); + return log_lldp_rx_errno(n->lldp_rx, SYNTHETIC_ERRNO(EBADMSG), + "Chassis ID field size out of range, ignoring datagram."); if (n->id.chassis_id) - return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG), - "Duplicate chassis ID field, ignoring datagram."); + return log_lldp_rx_errno(n->lldp_rx, SYNTHETIC_ERRNO(EBADMSG), + "Duplicate chassis ID field, ignoring datagram."); n->id.chassis_id = memdup(p, length); if (!n->id.chassis_id) @@ -231,12 +245,12 @@ int lldp_neighbor_parse(sd_lldp_neighbor *n) { case SD_LLDP_TYPE_PORT_ID: if (length < 2 || length > 256) /* includes the port subtype, hence one extra byte */ - return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG), - "Port ID field size out of range, ignoring datagram."); + return log_lldp_rx_errno(n->lldp_rx, SYNTHETIC_ERRNO(EBADMSG), + "Port ID field size out of range, ignoring datagram."); if (n->id.port_id) - return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG), - "Duplicate port ID field, ignoring datagram."); + return log_lldp_rx_errno(n->lldp_rx, SYNTHETIC_ERRNO(EBADMSG), + "Duplicate port ID field, ignoring datagram."); n->id.port_id = memdup(p, length); if (!n->id.port_id) @@ -247,39 +261,39 @@ int lldp_neighbor_parse(sd_lldp_neighbor *n) { case SD_LLDP_TYPE_TTL: if (length != 2) - return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG), - "TTL field has wrong size, ignoring datagram."); + return log_lldp_rx_errno(n->lldp_rx, SYNTHETIC_ERRNO(EBADMSG), + "TTL field has wrong size, ignoring datagram."); if (n->has_ttl) - return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG), - "Duplicate TTL field, ignoring datagram."); + return log_lldp_rx_errno(n->lldp_rx, SYNTHETIC_ERRNO(EBADMSG), + "Duplicate TTL field, ignoring datagram."); n->ttl = unaligned_read_be16(p); n->has_ttl = true; break; case SD_LLDP_TYPE_PORT_DESCRIPTION: - r = parse_string(n->lldp, &n->port_description, p, length); + r = parse_string(n->lldp_rx, &n->port_description, p, length); if (r < 0) return r; break; case SD_LLDP_TYPE_SYSTEM_NAME: - r = parse_string(n->lldp, &n->system_name, p, length); + r = parse_string(n->lldp_rx, &n->system_name, p, length); if (r < 0) return r; break; case SD_LLDP_TYPE_SYSTEM_DESCRIPTION: - r = parse_string(n->lldp, &n->system_description, p, length); + r = parse_string(n->lldp_rx, &n->system_description, p, length); if (r < 0) return r; break; case SD_LLDP_TYPE_SYSTEM_CAPABILITIES: if (length != 4) - return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG), - "System capabilities field has wrong size."); + return log_lldp_rx_errno(n->lldp_rx, SYNTHETIC_ERRNO(EBADMSG), + "System capabilities field has wrong size."); n->system_capabilities = unaligned_read_be16(p); n->enabled_capabilities = unaligned_read_be16(p + 2); @@ -288,14 +302,13 @@ int lldp_neighbor_parse(sd_lldp_neighbor *n) { case SD_LLDP_TYPE_PRIVATE: if (length < 4) - return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG), - "Found private TLV that is too short, ignoring."); + return log_lldp_rx_errno(n->lldp_rx, SYNTHETIC_ERRNO(EBADMSG), + "Found private TLV that is too short, ignoring."); /* RFC 8520: MUD URL */ - if (memcmp(p, SD_LLDP_OUI_MUD, sizeof(SD_LLDP_OUI_MUD)) == 0 && - p[sizeof(SD_LLDP_OUI_MUD)] == SD_LLDP_OUI_SUBTYPE_MUD_USAGE_DESCRIPTION) { - r = parse_string(n->lldp, &n->mud_url, p + sizeof(SD_LLDP_OUI_MUD) + 1, - length - 1 - sizeof(SD_LLDP_OUI_MUD)); + if (memcmp(p, SD_LLDP_OUI_IANA_MUD, sizeof(SD_LLDP_OUI_IANA_MUD)) == 0) { + r = parse_string(n->lldp_rx, &n->mud_url, p + sizeof(SD_LLDP_OUI_IANA_MUD), + length - sizeof(SD_LLDP_OUI_IANA_MUD)); if (r < 0) return r; } @@ -307,8 +320,8 @@ int lldp_neighbor_parse(sd_lldp_neighbor *n) { end_marker: if (!n->id.chassis_id || !n->id.port_id || !n->has_ttl) - return log_lldp_errno(n->lldp, SYNTHETIC_ERRNO(EBADMSG), - "One or more mandatory TLV missing in datagram. Ignoring."); + return log_lldp_rx_errno(n->lldp_rx, SYNTHETIC_ERRNO(EBADMSG), + "One or more mandatory TLV missing in datagram. Ignoring."); n->rindex = sizeof(struct ether_header); @@ -330,8 +343,8 @@ void lldp_neighbor_start_ttl(sd_lldp_neighbor *n) { } else n->until = 0; - if (n->lldp) - prioq_reshuffle(n->lldp->neighbor_by_expiry, n, &n->prioq_idx); + if (n->lldp_rx) + prioq_reshuffle(n->lldp_rx->neighbor_by_expiry, n, &n->prioq_idx); } bool lldp_neighbor_equal(const sd_lldp_neighbor *a, const sd_lldp_neighbor *b) { diff --git a/src/libnm-systemd-core/src/libsystemd-network/lldp-neighbor.h b/src/libnm-systemd-core/src/libsystemd-network/lldp-neighbor.h index a5718c8c..016286b1 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/lldp-neighbor.h +++ b/src/libnm-systemd-core/src/libsystemd-network/lldp-neighbor.h @@ -5,10 +5,10 @@ #include #include -#include "sd-lldp.h" +#include "sd-lldp-rx.h" #include "hash-funcs.h" -#include "lldp-internal.h" +#include "lldp-rx-internal.h" #include "time-util.h" typedef struct LLDPNeighborID { @@ -21,8 +21,8 @@ typedef struct LLDPNeighborID { } LLDPNeighborID; struct sd_lldp_neighbor { - /* Neighbor objects stay around as long as they are linked into an "sd_lldp" object or n_ref > 0. */ - sd_lldp *lldp; + /* Neighbor objects stay around as long as they are linked into an "sd_lldp_rx" object or n_ref > 0. */ + sd_lldp_rx *lldp_rx; unsigned n_ref; triple_timestamp timestamp; diff --git a/src/libnm-systemd-core/src/libsystemd-network/lldp-network.c b/src/libnm-systemd-core/src/libsystemd-network/lldp-network.c index e874e863..34a4f3f0 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/lldp-network.c +++ b/src/libnm-systemd-core/src/libsystemd-network/lldp-network.c @@ -58,15 +58,18 @@ int lldp_network_bind_raw_socket(int ifindex) { if (r < 0) return -errno; + /* customer bridge */ r = setsockopt(fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mreq, sizeof(mreq)); if (r < 0) return -errno; + /* non TPMR bridge */ mreq.mr_address[ETH_ALEN - 1] = 0x03; r = setsockopt(fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mreq, sizeof(mreq)); if (r < 0) return -errno; + /* nearest bridge */ mreq.mr_address[ETH_ALEN - 1] = 0x0E; r = setsockopt(fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mreq, sizeof(mreq)); if (r < 0) diff --git a/src/libnm-systemd-core/src/libsystemd-network/lldp-rx-internal.h b/src/libnm-systemd-core/src/libsystemd-network/lldp-rx-internal.h new file mode 100644 index 00000000..83d0bc46 --- /dev/null +++ b/src/libnm-systemd-core/src/libsystemd-network/lldp-rx-internal.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include "sd-event.h" +#include "sd-lldp-rx.h" + +#include "hashmap.h" +#include "network-common.h" +#include "prioq.h" + +struct sd_lldp_rx { + unsigned n_ref; + + int ifindex; + char *ifname; + int fd; + + sd_event *event; + int64_t event_priority; + sd_event_source *io_event_source; + sd_event_source *timer_event_source; + + Prioq *neighbor_by_expiry; + Hashmap *neighbor_by_id; + + uint64_t neighbors_max; + + sd_lldp_rx_callback_t callback; + void *userdata; + + uint16_t capability_mask; + + struct ether_addr filter_address; +}; + +const char* lldp_rx_event_to_string(sd_lldp_rx_event_t e) _const_; +sd_lldp_rx_event_t lldp_rx_event_from_string(const char *s) _pure_; + +#define log_lldp_rx_errno(lldp_rx, error, fmt, ...) \ + log_interface_prefix_full_errno( \ + "LLDP Rx: ", \ + sd_lldp_rx, lldp_rx, \ + error, fmt, ##__VA_ARGS__) +#define log_lldp_rx(lldp_rx, fmt, ...) \ + log_interface_prefix_full_errno_zerook( \ + "LLDP Rx: ", \ + sd_lldp_rx, lldp_rx, \ + 0, fmt, ##__VA_ARGS__) diff --git a/src/libnm-systemd-core/src/libsystemd-network/network-common.c b/src/libnm-systemd-core/src/libsystemd-network/network-common.c index b9494c15..bbc28941 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/network-common.c +++ b/src/libnm-systemd-core/src/libsystemd-network/network-common.c @@ -4,23 +4,14 @@ #include "format-util.h" #include "network-common.h" -#include "string-util.h" - -const char *get_ifname(int ifindex, char **ifname) { - char buf[IF_NAMESIZE + 1]; +int get_ifname(int ifindex, char **ifname) { assert(ifname); /* This sets ifname only when it is not set yet. */ if (*ifname) - return *ifname; - - if (ifindex <= 0) - return NULL; - - if (!format_ifname(ifindex, buf)) - return NULL; + return 0; - return *ifname = strdup(buf); + return format_ifname_alloc(ifindex, ifname); } diff --git a/src/libnm-systemd-core/src/libsystemd-network/network-common.h b/src/libnm-systemd-core/src/libsystemd-network/network-common.h index 76a6c4a9..d43b76d4 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/network-common.h +++ b/src/libnm-systemd-core/src/libsystemd-network/network-common.h @@ -1,4 +1,28 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -const char *get_ifname(int ifindex, char **ifname); +#include "log-link.h" + +#define log_interface_prefix_full_errno_zerook(prefix, type, val, error, fmt, ...) \ + ({ \ + int _e = (error); \ + if (DEBUG_LOGGING) { \ + const char *_n = NULL; \ + \ + (void) type##_get_ifname(val, &_n); \ + log_interface_full_errno_zerook( \ + _n, LOG_DEBUG, _e, prefix fmt, \ + ##__VA_ARGS__); \ + } \ + -ERRNO_VALUE(_e); \ + }) + +#define log_interface_prefix_full_errno(prefix, type, val, error, fmt, ...) \ + ({ \ + int _error = (error); \ + ASSERT_NON_ZERO(_error); \ + log_interface_prefix_full_errno_zerook( \ + prefix, type, val, _error, fmt, ##__VA_ARGS__); \ + }) + +int get_ifname(int ifindex, char **ifname); diff --git a/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp-client.c b/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp-client.c index 94e43da3..cb984b6e 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp-client.c @@ -119,6 +119,9 @@ struct sd_dhcp_client { sd_dhcp_lease *lease; usec_t start_delay; int ip_service_type; + + /* Ignore ifindex when generating iaid. See dhcp_identifier_set_iaid(). */ + bool test_mode; }; static const uint8_t default_req_opts[] = { @@ -191,7 +194,7 @@ int sd_dhcp_client_id_to_string(const void *data, size_t len, char **ret) { if (len != sizeof_field(sd_dhcp_client_id, eth)) return -EINVAL; - r = asprintf(&t, "%x:%x:%x:%x:%x:%x", + r = asprintf(&t, "%02x:%02x:%02x:%02x:%02x:%02x", client_id->eth.haddr[0], client_id->eth.haddr[1], client_id->eth.haddr[2], @@ -237,7 +240,7 @@ int sd_dhcp_client_set_callback( int sd_dhcp_client_set_request_broadcast(sd_dhcp_client *client, int broadcast) { assert_return(client, -EINVAL); - client->request_broadcast = !!broadcast; + client->request_broadcast = broadcast; return 0; } @@ -296,11 +299,19 @@ int sd_dhcp_client_set_ifname(sd_dhcp_client *client, const char *ifname) { return free_and_strdup(&client->ifname, ifname); } -const char *sd_dhcp_client_get_ifname(sd_dhcp_client *client) { - if (!client) - return NULL; +int sd_dhcp_client_get_ifname(sd_dhcp_client *client, const char **ret) { + int r; + + assert_return(client, -EINVAL); + + r = get_ifname(client->ifindex, &client->ifname); + if (r < 0) + return r; - return get_ifname(client->ifindex, &client->ifname); + if (ret) + *ret = client->ifname; + + return 0; } int sd_dhcp_client_set_mac( @@ -470,7 +481,8 @@ static int dhcp_client_set_iaid_duid_internal( else { r = dhcp_identifier_set_iaid(client->ifindex, client->mac_addr, client->mac_addr_len, - true, + /* legacy_unstable_byteorder = */ true, + /* use_mac = */ client->test_mode, &client->client_id.ns.iaid); if (r < 0) return log_dhcp_client_errno(client, r, "Failed to set IAID: %m"); @@ -560,6 +572,12 @@ int sd_dhcp_client_set_duid_llt( } #endif /* NM_IGNORED */ +void dhcp_client_set_test_mode(sd_dhcp_client *client, bool test_mode) { + assert(client); + + client->test_mode = test_mode; +} + int sd_dhcp_client_set_hostname( sd_dhcp_client *client, const char *hostname) { @@ -721,7 +739,7 @@ static int client_notify(sd_dhcp_client *client, int event) { static int client_initialize(sd_dhcp_client *client) { assert_return(client, -EINVAL); - client->receive_message = sd_event_source_unref(client->receive_message); + client->receive_message = sd_event_source_disable_unref(client->receive_message); client->fd = safe_close(client->fd); @@ -865,7 +883,9 @@ static int client_message_init( client->client_id.type = 255; r = dhcp_identifier_set_iaid(client->ifindex, client->mac_addr, client->mac_addr_len, - true, &client->client_id.ns.iaid); + /* legacy_unstable_byteorder = */ true, + /* use_mac = */ client->test_mode, + &client->client_id.ns.iaid); if (r < 0) return r; @@ -1301,7 +1321,7 @@ static int client_timeout_resend( goto error; default: - assert_not_reached("Unhandled choice"); + assert_not_reached(); } r = event_reset_time(client->event, &client->timeout_resend, @@ -1485,7 +1505,7 @@ static int client_timeout_t2(sd_event_source *s, uint64_t usec, void *userdata) assert(client); - client->receive_message = sd_event_source_unref(client->receive_message); + client->receive_message = sd_event_source_disable_unref(client->receive_message); client->fd = safe_close(client->fd); client->state = DHCP_STATE_REBINDING; @@ -1580,18 +1600,17 @@ static int client_handle_forcerenew(sd_dhcp_client *client, DHCPMessage *force, if (r != DHCP_FORCERENEW) return -ENOMSG; -#if 0 /* NM_IGNORED */ +#if 0 log_dhcp_client(client, "FORCERENEW"); return 0; -#else /* NM_IGNORED */ - /* NM: patch out the handling of FORCERENEW. We don't implement rfc3118 (Authentication - * for DHCP Messages) nor rfc6704 (Forcerenew Nonce Authentication) so accepting - * unauthenticated FORCERENEW requests is a security issue (CVE-2020-13529) - * See: https://github.com/systemd/systemd/issues/16774 */ - log_dhcp_client(client, "ignore FORCERENEW"); +#else + /* FIXME: Ignore FORCERENEW requests until we implement RFC3118 (Authentication for DHCP + * Messages) and/or RFC6704 (Forcerenew Nonce Authentication), as unauthenticated FORCERENEW + * requests causes a security issue (TALOS-2020-1142, CVE-2020-13529). */ + log_dhcp_client(client, "Received FORCERENEW, ignoring."); return -ENOMSG; -#endif /* NM_IGNORED */ +#endif } static bool lease_equal(const sd_dhcp_lease *a, const sd_dhcp_lease *b) { @@ -1680,7 +1699,6 @@ static int client_handle_ack(sd_dhcp_client *client, DHCPMessage *ack, size_t le static int client_set_lease_timeouts(sd_dhcp_client *client) { usec_t time_now; - char time_string[FORMAT_TIMESPAN_MAX]; int r; assert(client); @@ -1742,7 +1760,7 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) { return 0; log_dhcp_client(client, "lease expires in %s", - format_timespan(time_string, FORMAT_TIMESPAN_MAX, client->expire_time - time_now, USEC_PER_SEC)); + FORMAT_TIMESPAN(client->expire_time - time_now, USEC_PER_SEC)); /* arm T2 timeout */ r = event_reset_time(client->event, &client->timeout_t2, @@ -1758,7 +1776,7 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) { return 0; log_dhcp_client(client, "T2 expires in %s", - format_timespan(time_string, FORMAT_TIMESPAN_MAX, client->t2_time - time_now, USEC_PER_SEC)); + FORMAT_TIMESPAN(client->t2_time - time_now, USEC_PER_SEC)); /* arm T1 timeout */ r = event_reset_time(client->event, &client->timeout_t1, @@ -1771,15 +1789,14 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) { if (client->t1_time > time_now) log_dhcp_client(client, "T1 expires in %s", - format_timespan(time_string, FORMAT_TIMESPAN_MAX, client->t1_time - time_now, USEC_PER_SEC)); + FORMAT_TIMESPAN(client->t1_time - time_now, USEC_PER_SEC)); return 0; } static int client_handle_message(sd_dhcp_client *client, DHCPMessage *message, int len) { DHCP_CLIENT_DONT_DESTROY(client); - char time_string[FORMAT_TIMESPAN_MAX]; - int r = 0, notify_event = 0; + int r, notify_event; assert(client); assert(client->event); @@ -1789,22 +1806,19 @@ static int client_handle_message(sd_dhcp_client *client, DHCPMessage *message, i case DHCP_STATE_SELECTING: r = client_handle_offer(client, message, len); - if (r >= 0) { + if (r == -ENOMSG) + return 0; /* invalid message, let's ignore it */ + if (r < 0) + goto error; - client->state = DHCP_STATE_REQUESTING; - client->attempt = 0; - - r = event_reset_time(client->event, &client->timeout_resend, - clock_boottime_or_monotonic(), - 0, 0, - client_timeout_resend, client, - client->event_priority, "dhcp4-resend-timer", true); - if (r < 0) - goto error; - } else if (r == -ENOMSG) - /* invalid message, let's ignore it */ - return 0; + client->state = DHCP_STATE_REQUESTING; + client->attempt = 0; + r = event_reset_time(client->event, &client->timeout_resend, + clock_boottime_or_monotonic(), + 0, 0, + client_timeout_resend, client, + client->event_priority, "dhcp4-resend-timer", true); break; case DHCP_STATE_REBOOTING: @@ -1813,47 +1827,9 @@ static int client_handle_message(sd_dhcp_client *client, DHCPMessage *message, i case DHCP_STATE_REBINDING: r = client_handle_ack(client, message, len); - if (r >= 0) { - client->start_delay = 0; - (void) event_source_disable(client->timeout_resend); - client->receive_message = - sd_event_source_unref(client->receive_message); - client->fd = safe_close(client->fd); - - if (IN_SET(client->state, DHCP_STATE_REQUESTING, - DHCP_STATE_REBOOTING)) - notify_event = SD_DHCP_CLIENT_EVENT_IP_ACQUIRE; - else if (r != SD_DHCP_CLIENT_EVENT_IP_ACQUIRE) - notify_event = r; - - client->state = DHCP_STATE_BOUND; - client->attempt = 0; - - client->last_addr = client->lease->address; - - r = client_set_lease_timeouts(client); - if (r < 0) { - log_dhcp_client(client, "could not set lease timeouts"); - goto error; - } - - r = dhcp_network_bind_udp_socket(client->ifindex, client->lease->address, client->port, client->ip_service_type); - if (r < 0) { - log_dhcp_client(client, "could not bind UDP socket"); - goto error; - } - - client->fd = r; - - client_initialize_io_events(client, client_receive_message_udp); - - if (notify_event) { - client_notify(client, notify_event); - if (client->state == DHCP_STATE_STOPPED) - return 0; - } - - } else if (r == -EADDRNOTAVAIL) { + if (r == -ENOMSG) + return 0; /* invalid message, let's ignore it */ + if (r == -EADDRNOTAVAIL) { /* got a NAK, let's restart the client */ client_notify(client, SD_DHCP_CLIENT_EVENT_EXPIRED); @@ -1865,39 +1841,75 @@ static int client_handle_message(sd_dhcp_client *client, DHCPMessage *message, i if (r < 0) goto error; - log_dhcp_client(client, "REBOOT in %s", format_timespan(time_string, FORMAT_TIMESPAN_MAX, - client->start_delay, USEC_PER_SEC)); + log_dhcp_client(client, "REBOOT in %s", FORMAT_TIMESPAN(client->start_delay, USEC_PER_SEC)); client->start_delay = CLAMP(client->start_delay * 2, RESTART_AFTER_NAK_MIN_USEC, RESTART_AFTER_NAK_MAX_USEC); - - return 0; - } else if (r == -ENOMSG) - /* invalid message, let's ignore it */ return 0; + } + if (r < 0) + goto error; + + if (IN_SET(client->state, DHCP_STATE_REQUESTING, DHCP_STATE_REBOOTING)) + notify_event = SD_DHCP_CLIENT_EVENT_IP_ACQUIRE; + else + notify_event = r; + + client->start_delay = 0; + (void) event_source_disable(client->timeout_resend); + client->receive_message = sd_event_source_disable_unref(client->receive_message); + client->fd = safe_close(client->fd); + + client->state = DHCP_STATE_BOUND; + client->attempt = 0; + + client->last_addr = client->lease->address; + + r = client_set_lease_timeouts(client); + if (r < 0) { + log_dhcp_client(client, "could not set lease timeouts"); + goto error; + } + + r = dhcp_network_bind_udp_socket(client->ifindex, client->lease->address, client->port, client->ip_service_type); + if (r < 0) { + log_dhcp_client(client, "could not bind UDP socket"); + goto error; + } + + client->fd = r; + + client_initialize_io_events(client, client_receive_message_udp); + if (IN_SET(client->state, DHCP_STATE_RENEWING, DHCP_STATE_REBINDING) && + notify_event == SD_DHCP_CLIENT_EVENT_IP_ACQUIRE) + /* FIXME: hmm, maybe this is a bug... */ + log_dhcp_client(client, "client_handle_ack() returned SD_DHCP_CLIENT_EVENT_IP_ACQUIRE while DHCP client is %s the address, skipping callback.", + client->state == DHCP_STATE_RENEWING ? "renewing" : "rebinding"); + else + client_notify(client, notify_event); break; case DHCP_STATE_BOUND: r = client_handle_forcerenew(client, message, len); - if (r >= 0) { - r = client_timeout_t1(NULL, 0, client); - if (r < 0) - goto error; - } else if (r == -ENOMSG) - /* invalid message, let's ignore it */ - return 0; + if (r == -ENOMSG) + return 0; /* invalid message, let's ignore it */ + if (r < 0) + goto error; + r = client_timeout_t1(NULL, 0, client); break; case DHCP_STATE_INIT: case DHCP_STATE_INIT_REBOOT: - + r = 0; break; case DHCP_STATE_STOPPED: r = -EINVAL; goto error; + default: + assert_not_reached(); } error: @@ -2227,17 +2239,15 @@ static sd_dhcp_client *dhcp_client_free(sd_dhcp_client *client) { log_dhcp_client(client, "FREE"); + client_initialize(client); + client->timeout_resend = sd_event_source_unref(client->timeout_resend); client->timeout_t1 = sd_event_source_unref(client->timeout_t1); client->timeout_t2 = sd_event_source_unref(client->timeout_t2); client->timeout_expire = sd_event_source_unref(client->timeout_expire); - client_initialize(client); - sd_dhcp_client_detach_event(client); - sd_dhcp_lease_unref(client->lease); - set_free(client->req_opts); free(client->hostname); free(client->vendor_class_identifier); diff --git a/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-client.c b/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-client.c index 888dfa2d..5398bdff 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-client.c @@ -90,6 +90,9 @@ struct sd_dhcp6_client { usec_t information_refresh_time_usec; OrderedHashmap *extra_options; OrderedHashmap *vendor_options; + + /* Ignore ifindex when generating iaid. See dhcp_identifier_set_iaid(). */ + bool test_mode; }; static const uint16_t default_req_opts[] = { @@ -182,11 +185,19 @@ int sd_dhcp6_client_set_ifname(sd_dhcp6_client *client, const char *ifname) { return free_and_strdup(&client->ifname, ifname); } -const char *sd_dhcp6_client_get_ifname(sd_dhcp6_client *client) { - if (!client) - return NULL; +int sd_dhcp6_client_get_ifname(sd_dhcp6_client *client, const char **ret) { + int r; + + assert_return(client, -EINVAL); + + r = get_ifname(client->ifindex, &client->ifname); + if (r < 0) + return r; + + if (ret) + *ret = client->ifname; - return get_ifname(client->ifindex, &client->ifname); + return 0; } int sd_dhcp6_client_set_local_address( @@ -408,6 +419,12 @@ int sd_dhcp6_client_set_iaid(sd_dhcp6_client *client, uint32_t iaid) { return 0; } +void dhcp6_client_set_test_mode(sd_dhcp6_client *client, bool test_mode) { + assert(client); + + client->test_mode = test_mode; +} + int sd_dhcp6_client_get_iaid(sd_dhcp6_client *client, uint32_t *iaid) { assert_return(client, -EINVAL); assert_return(iaid, -EINVAL); @@ -947,7 +964,6 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, void *userda usec_t time_now, init_retransmit_time = 0, max_retransmit_time = 0; usec_t max_retransmit_duration = 0; uint8_t max_retransmit_count = 0; - char time_string[FORMAT_TIMESPAN_MAX]; assert(s); assert(client); @@ -1043,7 +1059,7 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, void *userda } log_dhcp6_client(client, "Next retransmission in %s", - format_timespan(time_string, FORMAT_TIMESPAN_MAX, client->retransmit_time, USEC_PER_SEC)); + FORMAT_TIMESPAN(client->retransmit_time, USEC_PER_SEC)); r = event_reset_time(client->event, &client->timeout_resend, clock_boottime_or_monotonic(), @@ -1083,7 +1099,10 @@ static int client_ensure_iaid(sd_dhcp6_client *client) { if (client->iaid_set) return 0; - r = dhcp_identifier_set_iaid(client->ifindex, client->mac_addr, client->mac_addr_len, true, &iaid); + r = dhcp_identifier_set_iaid(client->ifindex, client->mac_addr, client->mac_addr_len, + /* legacy_unstable_byteorder = */ true, + /* use_mac = */ client->test_mode, + &iaid); if (r < 0) return r; @@ -1100,11 +1119,9 @@ static int client_parse_message( size_t len, sd_dhcp6_lease *lease) { - uint16_t ia_na_status = 0, ia_pd_status = 0; - uint32_t lt_t1 = ~0, lt_t2 = ~0; + uint32_t lt_t1 = UINT32_MAX, lt_t2 = UINT32_MAX; usec_t irt = IRT_DEFAULT; bool clientid = false; - size_t pos = 0; int r; assert(client); @@ -1113,50 +1130,35 @@ static int client_parse_message( assert(lease); len -= sizeof(DHCP6Message); + for (size_t offset = 0; offset < len;) { + uint16_t optcode; + size_t optlen; + const uint8_t *optval; - while (pos < len) { - DHCP6Option *option = (DHCP6Option *) &message->options[pos]; - uint16_t optcode, optlen; - be32_t iaid_lease; - int status; - uint8_t *optval; - - if (len < pos + offsetof(DHCP6Option, data)) - return -ENOBUFS; - - optcode = be16toh(option->code); - optlen = be16toh(option->len); - optval = option->data; - - if (len < pos + offsetof(DHCP6Option, data) + optlen) - return -ENOBUFS; + r = dhcp6_option_parse(message->options, len, &offset, &optcode, &optlen, &optval); + if (r < 0) + return r; switch (optcode) { case SD_DHCP6_OPTION_CLIENTID: - if (clientid) { - log_dhcp6_client(client, "%s contains multiple clientids", - dhcp6_message_type_to_string(message->type)); - return -EINVAL; - } + if (clientid) + return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), "%s contains multiple clientids", + dhcp6_message_type_to_string(message->type)); if (optlen != client->duid_len || - memcmp(&client->duid, optval, optlen) != 0) { - log_dhcp6_client(client, "%s DUID does not match", - dhcp6_message_type_to_string(message->type)); + memcmp(&client->duid, optval, optlen) != 0) + return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), "%s DUID does not match", + dhcp6_message_type_to_string(message->type)); - return -EINVAL; - } clientid = true; break; case SD_DHCP6_OPTION_SERVERID: r = dhcp6_lease_get_serverid(lease, NULL, NULL); - if (r >= 0) { - log_dhcp6_client(client, "%s contains multiple serverids", - dhcp6_message_type_to_string(message->type)); - return -EINVAL; - } + if (r >= 0) + return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), "%s contains multiple serverids", + dhcp6_message_type_to_string(message->type)); r = dhcp6_lease_set_serverid(lease, optval, optlen); if (r < 0) @@ -1174,87 +1176,75 @@ static int client_parse_message( break; - case SD_DHCP6_OPTION_STATUS_CODE: - status = dhcp6_option_parse_status(option, optlen + sizeof(DHCP6Option)); - if (status < 0) - return status; - - if (status > 0) { - log_dhcp6_client(client, "%s Status %s", - dhcp6_message_type_to_string(message->type), - dhcp6_message_status_to_string(status)); + case SD_DHCP6_OPTION_STATUS_CODE: { + _cleanup_free_ char *msg = NULL; - return -EINVAL; - } + r = dhcp6_option_parse_status(optval, optlen, &msg); + if (r < 0) + return r; + if (r > 0) + return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), + "Received %s message with non-zero status: %s%s%s", + dhcp6_message_type_to_string(message->type), + strempty(msg), isempty(msg) ? "" : ": ", + dhcp6_message_status_to_string(r)); break; + } + case SD_DHCP6_OPTION_IA_NA: { + _cleanup_(dhcp6_lease_free_ia) DHCP6IA ia = {}; - case SD_DHCP6_OPTION_IA_NA: if (client->state == DHCP6_STATE_INFORMATION_REQUEST) { - log_dhcp6_client(client, "Information request ignoring IA NA option"); - + log_dhcp6_client(client, "Ignoring IA NA option in information requesting mode."); break; } - r = dhcp6_option_parse_ia(client, option, &lease->ia, &ia_na_status); - if (r < 0 && r != -ENOMSG) + r = dhcp6_option_parse_ia(client, client->ia_pd.ia_na.id, optcode, optlen, optval, &ia); + if (r == -ENOMEM) return r; + if (r < 0) + continue; - if (ia_na_status == DHCP6_STATUS_NO_ADDRS_AVAIL) { - pos += offsetof(DHCP6Option, data) + optlen; + if (lease->ia.addresses) { + log_dhcp6_client(client, "Received duplicate matching IA_NA option, ignoring."); continue; } - r = dhcp6_lease_get_iaid(lease, &iaid_lease); - if (r < 0) - return r; - - if (client->ia_na.ia_na.id != iaid_lease) { - log_dhcp6_client(client, "%s has wrong IAID for IA NA", - dhcp6_message_type_to_string(message->type)); - return -EINVAL; - } + lease->ia = ia; + ia = (DHCP6IA) {}; - if (lease->ia.addresses) { - lt_t1 = MIN(lt_t1, be32toh(lease->ia.ia_na.lifetime_t1)); - lt_t2 = MIN(lt_t2, be32toh(lease->ia.ia_na.lifetime_t1)); - } + lt_t1 = MIN(lt_t1, be32toh(lease->ia.ia_na.lifetime_t1)); + lt_t2 = MIN(lt_t2, be32toh(lease->ia.ia_na.lifetime_t2)); break; + } + case SD_DHCP6_OPTION_IA_PD: { + _cleanup_(dhcp6_lease_free_ia) DHCP6IA ia = {}; - case SD_DHCP6_OPTION_IA_PD: if (client->state == DHCP6_STATE_INFORMATION_REQUEST) { - log_dhcp6_client(client, "Information request ignoring IA PD option"); - + log_dhcp6_client(client, "Ignoring IA PD option in information requesting mode."); break; } - r = dhcp6_option_parse_ia(client, option, &lease->pd, &ia_pd_status); - if (r < 0 && r != -ENOMSG) + r = dhcp6_option_parse_ia(client, client->ia_pd.ia_pd.id, optcode, optlen, optval, &ia); + if (r == -ENOMEM) return r; + if (r < 0) + continue; - if (ia_pd_status == DHCP6_STATUS_NO_PREFIX_AVAIL) { - pos += offsetof(DHCP6Option, data) + optlen; + if (lease->pd.addresses) { + log_dhcp6_client(client, "Received duplicate matching IA_PD option, ignoring."); continue; } - r = dhcp6_lease_get_pd_iaid(lease, &iaid_lease); - if (r < 0) - return r; - - if (client->ia_pd.ia_pd.id != iaid_lease) { - log_dhcp6_client(client, "%s has wrong IAID for IA PD", - dhcp6_message_type_to_string(message->type)); - return -EINVAL; - } + lease->pd = ia; + ia = (DHCP6IA) {}; - if (lease->pd.addresses) { - lt_t1 = MIN(lt_t1, be32toh(lease->pd.ia_pd.lifetime_t1)); - lt_t2 = MIN(lt_t2, be32toh(lease->pd.ia_pd.lifetime_t2)); - } + lt_t1 = MIN(lt_t1, be32toh(lease->pd.ia_pd.lifetime_t1)); + lt_t2 = MIN(lt_t2, be32toh(lease->pd.ia_pd.lifetime_t2)); break; - + } case SD_DHCP6_OPTION_RAPID_COMMIT: r = dhcp6_lease_set_rapid_commit(lease); if (r < 0) @@ -1263,28 +1253,28 @@ static int client_parse_message( break; case SD_DHCP6_OPTION_DNS_SERVERS: - r = dhcp6_lease_set_dns(lease, optval, optlen); + r = dhcp6_lease_add_dns(lease, optval, optlen); if (r < 0) return r; break; case SD_DHCP6_OPTION_DOMAIN_LIST: - r = dhcp6_lease_set_domains(lease, optval, optlen); + r = dhcp6_lease_add_domains(lease, optval, optlen); if (r < 0) return r; break; case SD_DHCP6_OPTION_NTP_SERVER: - r = dhcp6_lease_set_ntp(lease, optval, optlen); + r = dhcp6_lease_add_ntp(lease, optval, optlen); if (r < 0) return r; break; case SD_DHCP6_OPTION_SNTP_SERVERS: - r = dhcp6_lease_set_sntp(lease, optval, optlen); + r = dhcp6_lease_add_sntp(lease, optval, optlen); if (r < 0) return r; @@ -1304,30 +1294,21 @@ static int client_parse_message( irt = unaligned_read_be32((be32_t *) optval) * USEC_PER_SEC; break; } - - pos += offsetof(DHCP6Option, data) + optlen; - } - - if (ia_na_status > 0 && ia_pd_status > 0) { - log_dhcp6_client(client, "No IA_PD prefix or IA_NA address received. Ignoring."); - return -EINVAL; } - if (!clientid) { - log_dhcp6_client(client, "%s has incomplete options", - dhcp6_message_type_to_string(message->type)); - return -EINVAL; - } + if (!clientid) + return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), "%s has incomplete options", + dhcp6_message_type_to_string(message->type)); if (client->state != DHCP6_STATE_INFORMATION_REQUEST) { r = dhcp6_lease_get_serverid(lease, NULL, NULL); - if (r < 0) { - log_dhcp6_client(client, "%s has no server id", - dhcp6_message_type_to_string(message->type)); - return -EINVAL; - } + if (r < 0) + return log_dhcp6_client_errno(client, r, "%s has no server id", + dhcp6_message_type_to_string(message->type)); + + if (!lease->ia.addresses && !lease->pd.addresses) + return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), "No IA_PD prefix or IA_NA address received. Ignoring."); - } else { if (lease->ia.addresses) { lease->ia.ia_na.lifetime_t1 = htobe32(lt_t1); lease->ia.ia_na.lifetime_t2 = htobe32(lt_t2); @@ -1478,15 +1459,16 @@ static int client_receive_message( return 0; } - if (client->transaction_id != (message->transaction_id & - htobe32(0x00ffffff))) + if (client->transaction_id != (message->transaction_id & htobe32(0x00ffffff))) return 0; switch (client->state) { case DHCP6_STATE_INFORMATION_REQUEST: r = client_receive_reply(client, message, len); - if (r < 0) + if (r < 0) { + log_dhcp6_client_errno(client, r, "Failed to process received reply message, ignoring: %m"); return 0; + } client_notify(client, SD_DHCP6_CLIENT_EVENT_INFORMATION_REQUEST); @@ -1496,10 +1478,13 @@ static int client_receive_message( case DHCP6_STATE_SOLICITATION: r = client_receive_advertise(client, message, len); + if (r < 0) { + log_dhcp6_client_errno(client, r, "Failed to process received advertise message, ignoring: %m"); + return 0; + } if (r == DHCP6_STATE_REQUEST) { client_start(client, r); - break; } @@ -1509,11 +1494,12 @@ static int client_receive_message( case DHCP6_STATE_REBIND: r = client_receive_reply(client, message, len); - if (r < 0) + if (r < 0) { + log_dhcp6_client_errno(client, r, "Failed to process received reply message, ignoring: %m"); return 0; + } if (r == DHCP6_STATE_BOUND) { - r = client_start(client, DHCP6_STATE_BOUND); if (r < 0) { client_stop(client, r); @@ -1564,7 +1550,6 @@ static int client_get_lifetime(sd_dhcp6_client *client, uint32_t *lifetime_t1, static int client_start(sd_dhcp6_client *client, enum DHCP6State state) { int r; usec_t timeout, time_now; - char time_string[FORMAT_TIMESPAN_MAX]; uint32_t lifetime_t1, lifetime_t2; assert_return(client, -EINVAL); @@ -1637,8 +1622,7 @@ static int client_start(sd_dhcp6_client *client, enum DHCP6State state) { timeout = client_timeout_compute_random(lifetime_t1 * USEC_PER_SEC); - log_dhcp6_client(client, "T1 expires in %s", - format_timespan(time_string, FORMAT_TIMESPAN_MAX, timeout, USEC_PER_SEC)); + log_dhcp6_client(client, "T1 expires in %s", FORMAT_TIMESPAN(timeout, USEC_PER_SEC)); r = event_reset_time(client->event, &client->timeout_t1, clock_boottime_or_monotonic(), @@ -1650,8 +1634,7 @@ static int client_start(sd_dhcp6_client *client, enum DHCP6State state) { timeout = client_timeout_compute_random(lifetime_t2 * USEC_PER_SEC); - log_dhcp6_client(client, "T2 expires in %s", - format_timespan(time_string, FORMAT_TIMESPAN_MAX, timeout, USEC_PER_SEC)); + log_dhcp6_client(client, "T2 expires in %s", FORMAT_TIMESPAN(timeout, USEC_PER_SEC)); r = event_reset_time(client->event, &client->timeout_t2, clock_boottime_or_monotonic(), diff --git a/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-lease.c b/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-lease.c index e37acfe8..85649d92 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-lease.c +++ b/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-lease.c @@ -195,86 +195,69 @@ void sd_dhcp6_lease_reset_pd_prefix_iter(sd_dhcp6_lease *lease) { lease->prefix_iter = lease->pd.addresses; } -int dhcp6_lease_set_dns(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen) { - int r; - +int dhcp6_lease_add_dns(sd_dhcp6_lease *lease, const uint8_t *optval, size_t optlen) { assert_return(lease, -EINVAL); assert_return(optval, -EINVAL); - if (!optlen) + if (optlen == 0) return 0; - r = dhcp6_option_parse_ip6addrs(optval, optlen, &lease->dns, - lease->dns_count); - if (r < 0) - return r; - - lease->dns_count = r; - - return 0; + return dhcp6_option_parse_addresses(optval, optlen, &lease->dns, &lease->dns_count); } -int sd_dhcp6_lease_get_dns(sd_dhcp6_lease *lease, const struct in6_addr **addrs) { +int sd_dhcp6_lease_get_dns(sd_dhcp6_lease *lease, const struct in6_addr **ret) { assert_return(lease, -EINVAL); - assert_return(addrs, -EINVAL); + assert_return(ret, -EINVAL); - if (lease->dns_count) { - *addrs = lease->dns; - return lease->dns_count; - } + if (!lease->dns) + return -ENOENT; - return -ENOENT; + *ret = lease->dns; + return lease->dns_count; } -int dhcp6_lease_set_domains(sd_dhcp6_lease *lease, uint8_t *optval, - size_t optlen) { +int dhcp6_lease_add_domains(sd_dhcp6_lease *lease, const uint8_t *optval, size_t optlen) { + _cleanup_strv_free_ char **domains = NULL; int r; - char **domains; assert_return(lease, -EINVAL); assert_return(optval, -EINVAL); - if (!optlen) + if (optlen == 0) return 0; r = dhcp6_option_parse_domainname_list(optval, optlen, &domains); if (r < 0) - return 0; - - strv_free_and_replace(lease->domains, domains); - lease->domains_count = r; + return r; - return r; + return strv_extend_strv(&lease->domains, domains, true); } -int sd_dhcp6_lease_get_domains(sd_dhcp6_lease *lease, char ***domains) { +int sd_dhcp6_lease_get_domains(sd_dhcp6_lease *lease, char ***ret) { assert_return(lease, -EINVAL); - assert_return(domains, -EINVAL); + assert_return(ret, -EINVAL); - if (lease->domains_count) { - *domains = lease->domains; - return lease->domains_count; - } + if (!lease->domains) + return -ENOENT; - return -ENOENT; + *ret = lease->domains; + return strv_length(lease->domains); } -int dhcp6_lease_set_ntp(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen) { +int dhcp6_lease_add_ntp(sd_dhcp6_lease *lease, const uint8_t *optval, size_t optlen) { int r; - uint16_t subopt; - size_t sublen; - uint8_t *subval; assert_return(lease, -EINVAL); assert_return(optval, -EINVAL); - lease->ntp = mfree(lease->ntp); - lease->ntp_count = 0; + for (size_t offset = 0; offset < optlen;) { + const uint8_t *subval; + size_t sublen; + uint16_t subopt; - while ((r = dhcp6_option_parse(&optval, &optlen, &subopt, &sublen, - &subval)) >= 0) { - int s; - char **servers; + r = dhcp6_option_parse(optval, optlen, &offset, &subopt, &sublen, &subval); + if (r < 0) + return r; switch(subopt) { case DHCP6_NTP_SUBOPTION_SRV_ADDR: @@ -282,86 +265,74 @@ int dhcp6_lease_set_ntp(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen) { if (sublen != 16) return 0; - s = dhcp6_option_parse_ip6addrs(subval, sublen, - &lease->ntp, - lease->ntp_count); - if (s < 0) - return s; - - lease->ntp_count = s; + r = dhcp6_option_parse_addresses(subval, sublen, &lease->ntp, &lease->ntp_count); + if (r < 0) + return r; break; - case DHCP6_NTP_SUBOPTION_SRV_FQDN: - r = dhcp6_option_parse_domainname_list(subval, sublen, - &servers); + case DHCP6_NTP_SUBOPTION_SRV_FQDN: { + _cleanup_free_ char *server = NULL; + + r = dhcp6_option_parse_domainname(subval, sublen, &server); if (r < 0) - return 0; + return r; + + if (strv_contains(lease->ntp_fqdn, server)) + continue; - strv_free_and_replace(lease->ntp_fqdn, servers); - lease->ntp_fqdn_count = r; + r = strv_consume(&lease->ntp_fqdn, TAKE_PTR(server)); + if (r < 0) + return r; break; - } + }} } - if (r != -ENOMSG) - return r; - return 0; } -int dhcp6_lease_set_sntp(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen) { - int r; - +int dhcp6_lease_add_sntp(sd_dhcp6_lease *lease, const uint8_t *optval, size_t optlen) { assert_return(lease, -EINVAL); assert_return(optval, -EINVAL); - if (!optlen) + if (optlen == 0) return 0; - if (lease->ntp || lease->ntp_fqdn) - return -EEXIST; - - /* Using deprecated SNTP information */ - - r = dhcp6_option_parse_ip6addrs(optval, optlen, &lease->ntp, - lease->ntp_count); - if (r < 0) - return r; - - lease->ntp_count = r; - - return 0; + /* SNTP option is defined in RFC4075, and deprecated by RFC5908. */ + return dhcp6_option_parse_addresses(optval, optlen, &lease->sntp, &lease->sntp_count); } -int sd_dhcp6_lease_get_ntp_addrs(sd_dhcp6_lease *lease, - const struct in6_addr **addrs) { +int sd_dhcp6_lease_get_ntp_addrs(sd_dhcp6_lease *lease, const struct in6_addr **ret) { assert_return(lease, -EINVAL); - assert_return(addrs, -EINVAL); + assert_return(ret, -EINVAL); - if (lease->ntp_count) { - *addrs = lease->ntp; + if (lease->ntp) { + *ret = lease->ntp; return lease->ntp_count; } + if (lease->sntp && !lease->ntp_fqdn) { + /* Fallback to the deprecated SNTP option. */ + *ret = lease->sntp; + return lease->sntp_count; + } + return -ENOENT; } -int sd_dhcp6_lease_get_ntp_fqdn(sd_dhcp6_lease *lease, char ***ntp_fqdn) { +int sd_dhcp6_lease_get_ntp_fqdn(sd_dhcp6_lease *lease, char ***ret) { assert_return(lease, -EINVAL); - assert_return(ntp_fqdn, -EINVAL); + assert_return(ret, -EINVAL); - if (lease->ntp_fqdn_count) { - *ntp_fqdn = lease->ntp_fqdn; - return lease->ntp_fqdn_count; - } + if (!lease->ntp_fqdn) + return -ENOENT; - return -ENOENT; + *ret = lease->ntp_fqdn; + return strv_length(lease->ntp_fqdn); } -int dhcp6_lease_set_fqdn(sd_dhcp6_lease *lease, const uint8_t *optval, - size_t optlen) { +int dhcp6_lease_set_fqdn(sd_dhcp6_lease *lease, const uint8_t *optval, size_t optlen) { int r; char *fqdn; @@ -380,33 +351,31 @@ int dhcp6_lease_set_fqdn(sd_dhcp6_lease *lease, const uint8_t *optval, return free_and_replace(lease->fqdn, fqdn); } -int sd_dhcp6_lease_get_fqdn(sd_dhcp6_lease *lease, const char **fqdn) { +int sd_dhcp6_lease_get_fqdn(sd_dhcp6_lease *lease, const char **ret) { assert_return(lease, -EINVAL); - assert_return(fqdn, -EINVAL); + assert_return(ret, -EINVAL); - if (lease->fqdn) { - *fqdn = lease->fqdn; - return 0; - } + if (!lease->fqdn) + return -ENOENT; - return -ENOENT; + *ret = lease->fqdn; + return 0; } static sd_dhcp6_lease *dhcp6_lease_free(sd_dhcp6_lease *lease) { - assert(lease); + if (!lease) + return NULL; free(lease->serverid); dhcp6_lease_free_ia(&lease->ia); dhcp6_lease_free_ia(&lease->pd); - free(lease->dns); free(lease->fqdn); - - lease->domains = strv_free(lease->domains); - + strv_free(lease->domains); free(lease->ntp); + strv_free(lease->ntp_fqdn); + free(lease->sntp); - lease->ntp_fqdn = strv_free(lease->ntp_fqdn); return mfree(lease); } diff --git a/src/libnm-systemd-core/src/libsystemd-network/sd-ipv4acd.c b/src/libnm-systemd-core/src/libsystemd-network/sd-ipv4acd.c index 031804ca..f0612ed5 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/sd-ipv4acd.c +++ b/src/libnm-systemd-core/src/libsystemd-network/sd-ipv4acd.c @@ -19,7 +19,7 @@ #include "event-util.h" #include "fd-util.h" #include "in-addr-util.h" -#include "log-link.h" +#include "memory-util.h" #include "network-common.h" #include "random-util.h" #include "siphash24.h" @@ -66,7 +66,7 @@ struct sd_ipv4acd { sd_event_source *timer_event_source; usec_t defend_window; - be32_t address; + struct in_addr address; /* External */ struct ether_addr mac_addr; @@ -74,18 +74,20 @@ struct sd_ipv4acd { sd_event *event; int event_priority; sd_ipv4acd_callback_t callback; - void* userdata; + void *userdata; + sd_ipv4acd_check_mac_callback_t check_mac_callback; + void *check_mac_userdata; }; #define log_ipv4acd_errno(acd, error, fmt, ...) \ log_interface_prefix_full_errno( \ "IPv4ACD: ", \ - sd_ipv4acd_get_ifname(acd), \ + sd_ipv4acd, acd, \ error, fmt, ##__VA_ARGS__) #define log_ipv4acd(acd, fmt, ...) \ log_interface_prefix_full_errno_zerook( \ "IPv4ACD: ", \ - sd_ipv4acd_get_ifname(acd), \ + sd_ipv4acd, acd, \ 0, fmt, ##__VA_ARGS__) static const char * const ipv4acd_state_table[_IPV4ACD_STATE_MAX] = { @@ -119,7 +121,7 @@ static void ipv4acd_reset(sd_ipv4acd *acd) { assert(acd); (void) event_source_disable(acd->timer_event_source); - acd->receive_message_event_source = sd_event_source_unref(acd->receive_message_event_source); + acd->receive_message_event_source = sd_event_source_disable_unref(acd->receive_message_event_source); acd->fd = safe_close(acd->fd); @@ -129,9 +131,8 @@ static void ipv4acd_reset(sd_ipv4acd *acd) { static sd_ipv4acd *ipv4acd_free(sd_ipv4acd *acd) { assert(acd); - acd->timer_event_source = sd_event_source_unref(acd->timer_event_source); - ipv4acd_reset(acd); + sd_event_source_unref(acd->timer_event_source); sd_ipv4acd_detach_event(acd); free(acd->ifname); return mfree(acd); @@ -210,18 +211,6 @@ static int ipv4acd_set_next_wakeup(sd_ipv4acd *acd, usec_t usec, usec_t random_u acd->event_priority, "ipv4acd-timer", true); } -static bool ipv4acd_arp_conflict(sd_ipv4acd *acd, struct ether_arp *arp) { - assert(acd); - assert(arp); - - /* see the BPF */ - if (memcmp(arp->arp_spa, &acd->address, sizeof(acd->address)) == 0) - return true; - - /* the TPA matched instead of the SPA, this is not a conflict */ - return false; -} - static int ipv4acd_on_timeout(sd_event_source *s, uint64_t usec, void *userdata) { sd_ipv4acd *acd = userdata; int r = 0; @@ -231,38 +220,32 @@ static int ipv4acd_on_timeout(sd_event_source *s, uint64_t usec, void *userdata) switch (acd->state) { case IPV4ACD_STATE_STARTED: + acd->defend_window = 0; + ipv4acd_set_state(acd, IPV4ACD_STATE_WAITING_PROBE, true); if (acd->n_conflict >= MAX_CONFLICTS) { - char ts[FORMAT_TIMESPAN_MAX]; - log_ipv4acd(acd, "Max conflicts reached, delaying by %s", format_timespan(ts, sizeof(ts), RATE_LIMIT_INTERVAL_USEC, 0)); - + log_ipv4acd(acd, "Max conflicts reached, delaying by %s", + FORMAT_TIMESPAN(RATE_LIMIT_INTERVAL_USEC, 0)); r = ipv4acd_set_next_wakeup(acd, RATE_LIMIT_INTERVAL_USEC, PROBE_WAIT_USEC); - if (r < 0) - goto fail; - } else { + } else r = ipv4acd_set_next_wakeup(acd, 0, PROBE_WAIT_USEC); - if (r < 0) - goto fail; - } + if (r < 0) + goto fail; break; case IPV4ACD_STATE_WAITING_PROBE: case IPV4ACD_STATE_PROBING: /* Send a probe */ - r = arp_send_probe(acd->fd, acd->ifindex, acd->address, &acd->mac_addr); + r = arp_send_probe(acd->fd, acd->ifindex, &acd->address, &acd->mac_addr); if (r < 0) { log_ipv4acd_errno(acd, r, "Failed to send ARP probe: %m"); goto fail; - } else { - _cleanup_free_ char *address = NULL; - union in_addr_union addr = { .in.s_addr = acd->address }; - - (void) in_addr_to_string(AF_INET, &addr, &address); - log_ipv4acd(acd, "Probing %s", strna(address)); } + log_ipv4acd(acd, "Probing "IPV4_ADDRESS_FMT_STR, IPV4_ADDRESS_FMT_VAL(acd->address)); + if (acd->n_iteration < PROBE_NUM - 2) { ipv4acd_set_state(acd, IPV4ACD_STATE_PROBING, false); @@ -288,12 +271,13 @@ static int ipv4acd_on_timeout(sd_event_source *s, uint64_t usec, void *userdata) _fallthrough_; case IPV4ACD_STATE_WAITING_ANNOUNCE: /* Send announcement packet */ - r = arp_send_announcement(acd->fd, acd->ifindex, acd->address, &acd->mac_addr); + r = arp_send_announcement(acd->fd, acd->ifindex, &acd->address, &acd->mac_addr); if (r < 0) { log_ipv4acd_errno(acd, r, "Failed to send ARP announcement: %m"); goto fail; - } else - log_ipv4acd(acd, "ANNOUNCE"); + } + + log_ipv4acd(acd, "Announcing "IPV4_ADDRESS_FMT_STR, IPV4_ADDRESS_FMT_VAL(acd->address)); ipv4acd_set_state(acd, IPV4ACD_STATE_ANNOUNCING, false); @@ -309,7 +293,7 @@ static int ipv4acd_on_timeout(sd_event_source *s, uint64_t usec, void *userdata) break; default: - assert_not_reached("Invalid state."); + assert_not_reached(); } return 0; @@ -319,16 +303,45 @@ fail: return 0; } -static void ipv4acd_on_conflict(sd_ipv4acd *acd) { - _cleanup_free_ char *address = NULL; - union in_addr_union addr = { .in.s_addr = acd->address }; +static bool ipv4acd_arp_conflict(sd_ipv4acd *acd, const struct ether_arp *arp, bool announced) { + assert(acd); + assert(arp); + + /* RFC 5227 section 2.1.1. + * "the host receives any ARP packet (Request *or* Reply) on the interface where the probe is + * being performed, where the packet's 'sender IP address' is the address being probed for, + * then the host MUST treat this address as being in use by some other host" */ + if (memcmp(arp->arp_spa, &acd->address, sizeof(struct in_addr)) == 0) + return true; + if (announced) + /* the TPA matched instead of SPA, this is not a conflict */ + return false; + + /* "any ARP Probe where the packet's 'target IP address' is the address being probed for, and + * the packet's 'sender hardware address' is not the hardware address of any of the host's + * interfaces, then the host SHOULD similarly treat this as an address conflict" */ + if (arp->ea_hdr.ar_op != htobe16(ARPOP_REQUEST)) + return false; /* not ARP Request, ignoring. */ + if (memeqzero(arp->arp_spa, sizeof(struct in_addr)) == 0) + return false; /* not ARP Probe, ignoring. */ + if (memcmp(arp->arp_tpa, &acd->address, sizeof(struct in_addr)) != 0) + return false; /* target IP address does not match, BPF code is broken? */ + + if (acd->check_mac_callback && + acd->check_mac_callback(acd, (const struct ether_addr*) arp->arp_sha, acd->check_mac_userdata) > 0) + /* sender hardware is one of the host's interfaces, ignoring. */ + return true; + + return true; /* conflict! */ +} + +static void ipv4acd_on_conflict(sd_ipv4acd *acd) { assert(acd); acd->n_conflict++; - (void) in_addr_to_string(AF_INET, &addr, &address); - log_ipv4acd(acd, "Conflict on %s (%u)", strna(address), acd->n_conflict); + log_ipv4acd(acd, "Conflict on "IPV4_ADDRESS_FMT_STR" (%u)", IPV4_ADDRESS_FMT_VAL(acd->address), acd->n_conflict); ipv4acd_reset(acd); ipv4acd_client_notify(acd, SD_IPV4ACD_EVENT_CONFLICT); @@ -367,7 +380,7 @@ static int ipv4acd_on_packet( case IPV4ACD_STATE_ANNOUNCING: case IPV4ACD_STATE_RUNNING: - if (ipv4acd_arp_conflict(acd, &packet)) { + if (ipv4acd_arp_conflict(acd, &packet, true)) { usec_t ts; assert_se(sd_event_now(acd->event, clock_boottime_or_monotonic(), &ts) >= 0); @@ -375,12 +388,13 @@ static int ipv4acd_on_packet( /* Defend address */ if (ts > acd->defend_window) { acd->defend_window = ts + DEFEND_INTERVAL_USEC; - r = arp_send_announcement(acd->fd, acd->ifindex, acd->address, &acd->mac_addr); + r = arp_send_announcement(acd->fd, acd->ifindex, &acd->address, &acd->mac_addr); if (r < 0) { log_ipv4acd_errno(acd, r, "Failed to send ARP announcement: %m"); goto fail; - } else - log_ipv4acd(acd, "DEFEND"); + } + + log_ipv4acd(acd, "Defending "IPV4_ADDRESS_FMT_STR, IPV4_ADDRESS_FMT_VAL(acd->address)); } else ipv4acd_on_conflict(acd); @@ -390,12 +404,12 @@ static int ipv4acd_on_packet( case IPV4ACD_STATE_WAITING_PROBE: case IPV4ACD_STATE_PROBING: case IPV4ACD_STATE_WAITING_ANNOUNCE: - /* BPF ensures this packet indicates a conflict */ - ipv4acd_on_conflict(acd); + if (ipv4acd_arp_conflict(acd, &packet, false)) + ipv4acd_on_conflict(acd); break; default: - assert_not_reached("Invalid state."); + assert_not_reached(); } return 0; @@ -432,20 +446,40 @@ int sd_ipv4acd_set_ifname(sd_ipv4acd *acd, const char *ifname) { return free_and_strdup(&acd->ifname, ifname); } -const char *sd_ipv4acd_get_ifname(sd_ipv4acd *acd) { - if (!acd) - return NULL; +int sd_ipv4acd_get_ifname(sd_ipv4acd *acd, const char **ret) { + int r; - return get_ifname(acd->ifindex, &acd->ifname); + assert_return(acd, -EINVAL); + + r = get_ifname(acd->ifindex, &acd->ifname); + if (r < 0) + return r; + + if (ret) + *ret = acd->ifname; + + return 0; } int sd_ipv4acd_set_mac(sd_ipv4acd *acd, const struct ether_addr *addr) { + int r; + assert_return(acd, -EINVAL); assert_return(addr, -EINVAL); - assert_return(acd->state == IPV4ACD_STATE_INIT, -EBUSY); + assert_return(!ether_addr_is_null(addr), -EINVAL); acd->mac_addr = *addr; + if (!sd_ipv4acd_is_running(acd)) + return 0; + + assert(acd->fd >= 0); + r = arp_update_filter(acd->fd, &acd->address, &acd->mac_addr); + if (r < 0) { + ipv4acd_reset(acd); + return r; + } + return 0; } @@ -485,21 +519,51 @@ int sd_ipv4acd_set_callback(sd_ipv4acd *acd, sd_ipv4acd_callback_t cb, void *use return 0; } +int sd_ipv4acd_set_check_mac_callback(sd_ipv4acd *acd, sd_ipv4acd_check_mac_callback_t cb, void *userdata) { + assert_return(acd, -EINVAL); + + acd->check_mac_callback = cb; + acd->check_mac_userdata = userdata; + return 0; +} + int sd_ipv4acd_set_address(sd_ipv4acd *acd, const struct in_addr *address) { + int r; + assert_return(acd, -EINVAL); assert_return(address, -EINVAL); - assert_return(acd->state == IPV4ACD_STATE_INIT, -EBUSY); + assert_return(in4_addr_is_set(address), -EINVAL); + + if (in4_addr_equal(&acd->address, address)) + return 0; - acd->address = address->s_addr; + acd->address = *address; + + if (!sd_ipv4acd_is_running(acd)) + return 0; + + assert(acd->fd >= 0); + r = arp_update_filter(acd->fd, &acd->address, &acd->mac_addr); + if (r < 0) + goto fail; + r = ipv4acd_set_next_wakeup(acd, 0, 0); + if (r < 0) + goto fail; + + ipv4acd_set_state(acd, IPV4ACD_STATE_STARTED, true); return 0; + +fail: + ipv4acd_reset(acd); + return r; } int sd_ipv4acd_get_address(sd_ipv4acd *acd, struct in_addr *address) { assert_return(acd, -EINVAL); assert_return(address, -EINVAL); - address->s_addr = acd->address; + *address = acd->address; return 0; } @@ -516,16 +580,15 @@ int sd_ipv4acd_start(sd_ipv4acd *acd, bool reset_conflicts) { assert_return(acd, -EINVAL); assert_return(acd->event, -EINVAL); assert_return(acd->ifindex > 0, -EINVAL); - assert_return(acd->address != 0, -EINVAL); + assert_return(in4_addr_is_set(&acd->address), -EINVAL); assert_return(!ether_addr_is_null(&acd->mac_addr), -EINVAL); assert_return(acd->state == IPV4ACD_STATE_INIT, -EBUSY); - r = arp_network_bind_raw_socket(acd->ifindex, acd->address, &acd->mac_addr); + r = arp_network_bind_raw_socket(acd->ifindex, &acd->address, &acd->mac_addr); if (r < 0) return r; CLOSE_AND_REPLACE(acd->fd, r); - acd->defend_window = 0; if (reset_conflicts) acd->n_conflict = 0; diff --git a/src/libnm-systemd-core/src/libsystemd-network/sd-ipv4ll.c b/src/libnm-systemd-core/src/libsystemd-network/sd-ipv4ll.c index 56275100..4a500dfc 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/sd-ipv4ll.c +++ b/src/libnm-systemd-core/src/libsystemd-network/sd-ipv4ll.c @@ -17,7 +17,7 @@ #include "alloc-util.h" #include "ether-addr-util.h" #include "in-addr-util.h" -#include "log-link.h" +#include "network-common.h" #include "random-util.h" #include "siphash24.h" #include "sparse-endian.h" @@ -48,21 +48,25 @@ struct sd_ipv4ll { be32_t claimed_address; sd_ipv4ll_callback_t callback; - void* userdata; + void *userdata; + + sd_ipv4ll_check_mac_callback_t check_mac_callback; + void *check_mac_userdata; }; #define log_ipv4ll_errno(ll, error, fmt, ...) \ log_interface_prefix_full_errno( \ "IPv4LL: ", \ - sd_ipv4ll_get_ifname(ll), \ + sd_ipv4ll, ll, \ error, fmt, ##__VA_ARGS__) #define log_ipv4ll(ll, fmt, ...) \ log_interface_prefix_full_errno_zerook( \ "IPv4LL: ", \ - sd_ipv4ll_get_ifname(ll), \ + sd_ipv4ll, ll, \ 0, fmt, ##__VA_ARGS__) -static void ipv4ll_on_acd(sd_ipv4acd *ll, int event, void *userdata); +static void ipv4ll_on_acd(sd_ipv4acd *acd, int event, void *userdata); +static int ipv4ll_check_mac(sd_ipv4acd *acd, const struct ether_addr *mac, void *userdata); static sd_ipv4ll *ipv4ll_free(sd_ipv4ll *ll) { assert(ll); @@ -93,6 +97,10 @@ int sd_ipv4ll_new(sd_ipv4ll **ret) { if (r < 0) return r; + r = sd_ipv4acd_set_check_mac_callback(ll->acd, ipv4ll_check_mac, ll); + if (r < 0) + return r; + *ret = TAKE_PTR(ll); return 0; @@ -127,11 +135,10 @@ int sd_ipv4ll_set_ifname(sd_ipv4ll *ll, const char *ifname) { return sd_ipv4acd_set_ifname(ll->acd, ifname); } -const char *sd_ipv4ll_get_ifname(sd_ipv4ll *ll) { - if (!ll) - return NULL; +int sd_ipv4ll_get_ifname(sd_ipv4ll *ll, const char **ret) { + assert_return(ll, -EINVAL); - return sd_ipv4acd_get_ifname(ll->acd); + return sd_ipv4acd_get_ifname(ll->acd, ret); } int sd_ipv4ll_set_mac(sd_ipv4ll *ll, const struct ether_addr *addr) { @@ -139,7 +146,7 @@ int sd_ipv4ll_set_mac(sd_ipv4ll *ll, const struct ether_addr *addr) { assert_return(ll, -EINVAL); assert_return(addr, -EINVAL); - assert_return(sd_ipv4ll_is_running(ll) == 0, -EBUSY); + assert_return(!ether_addr_is_null(addr), -EINVAL); r = sd_ipv4acd_set_mac(ll->acd, addr); if (r < 0) @@ -170,6 +177,15 @@ int sd_ipv4ll_set_callback(sd_ipv4ll *ll, sd_ipv4ll_callback_t cb, void *userdat return 0; } +int sd_ipv4ll_set_check_mac_callback(sd_ipv4ll *ll, sd_ipv4ll_check_mac_callback_t cb, void *userdata) { + assert_return(ll, -EINVAL); + + ll->check_mac_callback = cb; + ll->check_mac_userdata = userdata; + + return 0; +} + int sd_ipv4ll_get_address(sd_ipv4ll *ll, struct in_addr *address) { assert_return(ll, -EINVAL); assert_return(address, -EINVAL); @@ -345,7 +361,7 @@ void ipv4ll_on_acd(sd_ipv4acd *acd, int event, void *userdata) { break; default: - assert_not_reached("Invalid IPv4ACD event."); + assert_not_reached(); } return; @@ -353,3 +369,14 @@ void ipv4ll_on_acd(sd_ipv4acd *acd, int event, void *userdata) { error: ipv4ll_client_notify(ll, SD_IPV4LL_EVENT_STOP); } + +static int ipv4ll_check_mac(sd_ipv4acd *acd, const struct ether_addr *mac, void *userdata) { + sd_ipv4ll *ll = userdata; + + assert(ll); + + if (ll->check_mac_callback) + return ll->check_mac_callback(ll, mac, ll->check_mac_userdata); + + return 0; +} diff --git a/src/libnm-systemd-core/src/libsystemd-network/sd-lldp-rx.c b/src/libnm-systemd-core/src/libsystemd-network/sd-lldp-rx.c new file mode 100644 index 00000000..9da2b149 --- /dev/null +++ b/src/libnm-systemd-core/src/libsystemd-network/sd-lldp-rx.c @@ -0,0 +1,525 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include "nm-sd-adapt-core.h" + +#include +#include +#include + +#include "sd-lldp-rx.h" + +#include "alloc-util.h" +#include "ether-addr-util.h" +#include "event-util.h" +#include "fd-util.h" +#include "lldp-neighbor.h" +#include "lldp-network.h" +#include "lldp-rx-internal.h" +#include "memory-util.h" +#include "network-common.h" +#include "socket-util.h" +#include "sort-util.h" +#include "string-table.h" + +#define LLDP_DEFAULT_NEIGHBORS_MAX 128U + +static const char * const lldp_rx_event_table[_SD_LLDP_RX_EVENT_MAX] = { + [SD_LLDP_RX_EVENT_ADDED] = "added", + [SD_LLDP_RX_EVENT_REMOVED] = "removed", + [SD_LLDP_RX_EVENT_UPDATED] = "updated", + [SD_LLDP_RX_EVENT_REFRESHED] = "refreshed", +}; + +DEFINE_STRING_TABLE_LOOKUP(lldp_rx_event, sd_lldp_rx_event_t); + +static void lldp_rx_flush_neighbors(sd_lldp_rx *lldp_rx) { + assert(lldp_rx); + + hashmap_clear(lldp_rx->neighbor_by_id); +} + +static void lldp_rx_callback(sd_lldp_rx *lldp_rx, sd_lldp_rx_event_t event, sd_lldp_neighbor *n) { + assert(lldp_rx); + assert(event >= 0 && event < _SD_LLDP_RX_EVENT_MAX); + + if (!lldp_rx->callback) + return (void) log_lldp_rx(lldp_rx, "Received '%s' event.", lldp_rx_event_to_string(event)); + + log_lldp_rx(lldp_rx, "Invoking callback for '%s' event.", lldp_rx_event_to_string(event)); + lldp_rx->callback(lldp_rx, event, n, lldp_rx->userdata); +} + +static int lldp_rx_make_space(sd_lldp_rx *lldp_rx, size_t extra) { + usec_t t = USEC_INFINITY; + bool changed = false; + + assert(lldp_rx); + + /* Remove all entries that are past their TTL, and more until at least the specified number of extra entries + * are free. */ + + for (;;) { + _cleanup_(sd_lldp_neighbor_unrefp) sd_lldp_neighbor *n = NULL; + + n = prioq_peek(lldp_rx->neighbor_by_expiry); + if (!n) + break; + + sd_lldp_neighbor_ref(n); + + if (hashmap_size(lldp_rx->neighbor_by_id) > LESS_BY(lldp_rx->neighbors_max, extra)) + goto remove_one; + + if (t == USEC_INFINITY) + t = now(clock_boottime_or_monotonic()); + + if (n->until > t) + break; + + remove_one: + lldp_neighbor_unlink(n); + lldp_rx_callback(lldp_rx, SD_LLDP_RX_EVENT_REMOVED, n); + changed = true; + } + + return changed; +} + +static bool lldp_rx_keep_neighbor(sd_lldp_rx *lldp_rx, sd_lldp_neighbor *n) { + assert(lldp_rx); + assert(n); + + /* Don't keep data with a zero TTL */ + if (n->ttl <= 0) + return false; + + /* Filter out data from the filter address */ + if (!ether_addr_is_null(&lldp_rx->filter_address) && + ether_addr_equal(&lldp_rx->filter_address, &n->source_address)) + return false; + + /* Only add if the neighbor has a capability we are interested in. Note that we also store all neighbors with + * no caps field set. */ + if (n->has_capabilities && + (n->enabled_capabilities & lldp_rx->capability_mask) == 0) + return false; + + /* Keep everything else */ + return true; +} + +static int lldp_rx_start_timer(sd_lldp_rx *lldp_rx, sd_lldp_neighbor *neighbor); + +static int lldp_rx_add_neighbor(sd_lldp_rx *lldp_rx, sd_lldp_neighbor *n) { + _cleanup_(sd_lldp_neighbor_unrefp) sd_lldp_neighbor *old = NULL; + bool keep; + int r; + + assert(lldp_rx); + assert(n); + assert(!n->lldp_rx); + + keep = lldp_rx_keep_neighbor(lldp_rx, n); + + /* First retrieve the old entry for this MSAP */ + old = hashmap_get(lldp_rx->neighbor_by_id, &n->id); + if (old) { + sd_lldp_neighbor_ref(old); + + if (!keep) { + lldp_neighbor_unlink(old); + lldp_rx_callback(lldp_rx, SD_LLDP_RX_EVENT_REMOVED, old); + return 0; + } + + if (lldp_neighbor_equal(n, old)) { + /* Is this equal, then restart the TTL counter, but don't do anything else. */ + old->timestamp = n->timestamp; + lldp_rx_start_timer(lldp_rx, old); + lldp_rx_callback(lldp_rx, SD_LLDP_RX_EVENT_REFRESHED, old); + return 0; + } + + /* Data changed, remove the old entry, and add a new one */ + lldp_neighbor_unlink(old); + + } else if (!keep) + return 0; + + /* Then, make room for at least one new neighbor */ + lldp_rx_make_space(lldp_rx, 1); + + r = hashmap_ensure_put(&lldp_rx->neighbor_by_id, &lldp_neighbor_hash_ops, &n->id, n); + if (r < 0) + goto finish; + + r = prioq_ensure_put(&lldp_rx->neighbor_by_expiry, lldp_neighbor_prioq_compare_func, n, &n->prioq_idx); + if (r < 0) { + assert_se(hashmap_remove(lldp_rx->neighbor_by_id, &n->id) == n); + goto finish; + } + + n->lldp_rx = lldp_rx; + + lldp_rx_start_timer(lldp_rx, n); + lldp_rx_callback(lldp_rx, old ? SD_LLDP_RX_EVENT_UPDATED : SD_LLDP_RX_EVENT_ADDED, n); + + return 1; + +finish: + if (old) + lldp_rx_callback(lldp_rx, SD_LLDP_RX_EVENT_REMOVED, old); + + return r; +} + +static int lldp_rx_handle_datagram(sd_lldp_rx *lldp_rx, sd_lldp_neighbor *n) { + int r; + + assert(lldp_rx); + assert(n); + + r = lldp_neighbor_parse(n); + if (r < 0) + return r; + + r = lldp_rx_add_neighbor(lldp_rx, n); + if (r < 0) + return log_lldp_rx_errno(lldp_rx, r, "Failed to add datagram. Ignoring."); + + log_lldp_rx(lldp_rx, "Successfully processed LLDP datagram."); + return 0; +} + +static int lldp_rx_receive_datagram(sd_event_source *s, int fd, uint32_t revents, void *userdata) { + _cleanup_(sd_lldp_neighbor_unrefp) sd_lldp_neighbor *n = NULL; + ssize_t space, length; + sd_lldp_rx *lldp_rx = userdata; + struct timespec ts; + + assert(fd >= 0); + assert(lldp_rx); + + space = next_datagram_size_fd(fd); + if (space < 0) { + log_lldp_rx_errno(lldp_rx, space, "Failed to determine datagram size to read, ignoring: %m"); + return 0; + } + + n = lldp_neighbor_new(space); + if (!n) { + log_oom_debug(); + return 0; + } + + length = recv(fd, LLDP_NEIGHBOR_RAW(n), n->raw_size, MSG_DONTWAIT); + if (length < 0) { + if (IN_SET(errno, EAGAIN, EINTR)) + return 0; + + log_lldp_rx_errno(lldp_rx, errno, "Failed to read LLDP datagram, ignoring: %m"); + return 0; + } + + if ((size_t) length != n->raw_size) { + log_lldp_rx(lldp_rx, "Packet size mismatch, ignoring"); + return 0; + } + + /* Try to get the timestamp of this packet if it is known */ + if (ioctl(fd, SIOCGSTAMPNS, &ts) >= 0) + triple_timestamp_from_realtime(&n->timestamp, timespec_load(&ts)); + else + triple_timestamp_get(&n->timestamp); + + (void) lldp_rx_handle_datagram(lldp_rx, n); + return 0; +} + +static void lldp_rx_reset(sd_lldp_rx *lldp_rx) { + assert(lldp_rx); + + (void) event_source_disable(lldp_rx->timer_event_source); + lldp_rx->io_event_source = sd_event_source_disable_unref(lldp_rx->io_event_source); + lldp_rx->fd = safe_close(lldp_rx->fd); +} + +int sd_lldp_rx_is_running(sd_lldp_rx *lldp_rx) { + if (!lldp_rx) + return false; + + return lldp_rx->fd >= 0; +} + +_public_ int sd_lldp_rx_start(sd_lldp_rx *lldp_rx) { + int r; + + assert_return(lldp_rx, -EINVAL); + assert_return(lldp_rx->event, -EINVAL); + assert_return(lldp_rx->ifindex > 0, -EINVAL); + + if (sd_lldp_rx_is_running(lldp_rx)) + return 0; + + assert(!lldp_rx->io_event_source); + + lldp_rx->fd = lldp_network_bind_raw_socket(lldp_rx->ifindex); + if (lldp_rx->fd < 0) + return lldp_rx->fd; + + r = sd_event_add_io(lldp_rx->event, &lldp_rx->io_event_source, lldp_rx->fd, EPOLLIN, lldp_rx_receive_datagram, lldp_rx); + if (r < 0) + goto fail; + + r = sd_event_source_set_priority(lldp_rx->io_event_source, lldp_rx->event_priority); + if (r < 0) + goto fail; + + (void) sd_event_source_set_description(lldp_rx->io_event_source, "lldp-rx-io"); + + log_lldp_rx(lldp_rx, "Started LLDP client"); + return 1; + +fail: + lldp_rx_reset(lldp_rx); + return r; +} + +_public_ int sd_lldp_rx_stop(sd_lldp_rx *lldp_rx) { + if (!sd_lldp_rx_is_running(lldp_rx)) + return 0; + + log_lldp_rx(lldp_rx, "Stopping LLDP client"); + + lldp_rx_reset(lldp_rx); + lldp_rx_flush_neighbors(lldp_rx); + + return 1; +} + +_public_ int sd_lldp_rx_attach_event(sd_lldp_rx *lldp_rx, sd_event *event, int64_t priority) { + int r; + + assert_return(lldp_rx, -EINVAL); + assert_return(!sd_lldp_rx_is_running(lldp_rx), -EBUSY); + assert_return(!lldp_rx->event, -EBUSY); + + if (event) + lldp_rx->event = sd_event_ref(event); + else { + r = sd_event_default(&lldp_rx->event); + if (r < 0) + return r; + } + + lldp_rx->event_priority = priority; + + return 0; +} + +_public_ int sd_lldp_rx_detach_event(sd_lldp_rx *lldp_rx) { + assert_return(lldp_rx, -EINVAL); + assert_return(!sd_lldp_rx_is_running(lldp_rx), -EBUSY); + + lldp_rx->io_event_source = sd_event_source_disable_unref(lldp_rx->io_event_source); + lldp_rx->timer_event_source = sd_event_source_disable_unref(lldp_rx->timer_event_source); + lldp_rx->event = sd_event_unref(lldp_rx->event); + return 0; +} + +_public_ sd_event* sd_lldp_rx_get_event(sd_lldp_rx *lldp_rx) { + assert_return(lldp_rx, NULL); + + return lldp_rx->event; +} + +_public_ int sd_lldp_rx_set_callback(sd_lldp_rx *lldp_rx, sd_lldp_rx_callback_t cb, void *userdata) { + assert_return(lldp_rx, -EINVAL); + + lldp_rx->callback = cb; + lldp_rx->userdata = userdata; + + return 0; +} + +_public_ int sd_lldp_rx_set_ifindex(sd_lldp_rx *lldp_rx, int ifindex) { + assert_return(lldp_rx, -EINVAL); + assert_return(ifindex > 0, -EINVAL); + assert_return(!sd_lldp_rx_is_running(lldp_rx), -EBUSY); + + lldp_rx->ifindex = ifindex; + return 0; +} + +int sd_lldp_rx_set_ifname(sd_lldp_rx *lldp_rx, const char *ifname) { + assert_return(lldp_rx, -EINVAL); + assert_return(ifname, -EINVAL); + + if (!ifname_valid_full(ifname, IFNAME_VALID_ALTERNATIVE)) + return -EINVAL; + + return free_and_strdup(&lldp_rx->ifname, ifname); +} + +int sd_lldp_rx_get_ifname(sd_lldp_rx *lldp_rx, const char **ret) { + int r; + + assert_return(lldp_rx, -EINVAL); + + r = get_ifname(lldp_rx->ifindex, &lldp_rx->ifname); + if (r < 0) + return r; + + if (ret) + *ret = lldp_rx->ifname; + + return 0; +} + +static sd_lldp_rx *lldp_rx_free(sd_lldp_rx *lldp_rx) { + if (!lldp_rx) + return NULL; + + lldp_rx_reset(lldp_rx); + + sd_lldp_rx_detach_event(lldp_rx); + + lldp_rx_flush_neighbors(lldp_rx); + + hashmap_free(lldp_rx->neighbor_by_id); + prioq_free(lldp_rx->neighbor_by_expiry); + free(lldp_rx->ifname); + return mfree(lldp_rx); +} + +DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(sd_lldp_rx, sd_lldp_rx, lldp_rx_free); + +_public_ int sd_lldp_rx_new(sd_lldp_rx **ret) { + _cleanup_(sd_lldp_rx_unrefp) sd_lldp_rx *lldp_rx = NULL; + + assert_return(ret, -EINVAL); + + lldp_rx = new(sd_lldp_rx, 1); + if (!lldp_rx) + return -ENOMEM; + + *lldp_rx = (sd_lldp_rx) { + .n_ref = 1, + .fd = -1, + .neighbors_max = LLDP_DEFAULT_NEIGHBORS_MAX, + .capability_mask = UINT16_MAX, + }; + + *ret = TAKE_PTR(lldp_rx); + return 0; +} + +static int on_timer_event(sd_event_source *s, uint64_t usec, void *userdata) { + sd_lldp_rx *lldp_rx = userdata; + int r; + + r = lldp_rx_make_space(lldp_rx, 0); + if (r < 0) { + log_lldp_rx_errno(lldp_rx, r, "Failed to make space, ignoring: %m"); + return 0; + } + + r = lldp_rx_start_timer(lldp_rx, NULL); + if (r < 0) { + log_lldp_rx_errno(lldp_rx, r, "Failed to restart timer, ignoring: %m"); + return 0; + } + + return 0; +} + +static int lldp_rx_start_timer(sd_lldp_rx *lldp_rx, sd_lldp_neighbor *neighbor) { + sd_lldp_neighbor *n; + + assert(lldp_rx); + assert(lldp_rx->event); + + if (neighbor) + lldp_neighbor_start_ttl(neighbor); + + n = prioq_peek(lldp_rx->neighbor_by_expiry); + if (!n) + return event_source_disable(lldp_rx->timer_event_source); + + return event_reset_time(lldp_rx->event, &lldp_rx->timer_event_source, + clock_boottime_or_monotonic(), + n->until, 0, + on_timer_event, lldp_rx, + lldp_rx->event_priority, "lldp-rx-timer", true); +} + +static inline int neighbor_compare_func(sd_lldp_neighbor * const *a, sd_lldp_neighbor * const *b) { + assert(a); + assert(b); + assert(*a); + assert(*b); + + return lldp_neighbor_id_compare_func(&(*a)->id, &(*b)->id); +} + +_public_ int sd_lldp_rx_get_neighbors(sd_lldp_rx *lldp_rx, sd_lldp_neighbor ***ret) { + _cleanup_free_ sd_lldp_neighbor **l = NULL; + sd_lldp_neighbor *n; + int k = 0; + + assert_return(lldp_rx, -EINVAL); + assert_return(ret, -EINVAL); + + if (hashmap_isempty(lldp_rx->neighbor_by_id)) { /* Special shortcut */ + *ret = NULL; + return 0; + } + + l = new0(sd_lldp_neighbor*, hashmap_size(lldp_rx->neighbor_by_id)); + if (!l) + return -ENOMEM; + + HASHMAP_FOREACH(n, lldp_rx->neighbor_by_id) + l[k++] = sd_lldp_neighbor_ref(n); + + assert((size_t) k == hashmap_size(lldp_rx->neighbor_by_id)); + + /* Return things in a stable order */ + typesafe_qsort(l, k, neighbor_compare_func); + *ret = TAKE_PTR(l); + + return k; +} + +_public_ int sd_lldp_rx_set_neighbors_max(sd_lldp_rx *lldp_rx, uint64_t m) { + assert_return(lldp_rx, -EINVAL); + assert_return(m > 0, -EINVAL); + + lldp_rx->neighbors_max = m; + lldp_rx_make_space(lldp_rx, 0); + + return 0; +} + +_public_ int sd_lldp_rx_match_capabilities(sd_lldp_rx *lldp_rx, uint16_t mask) { + assert_return(lldp_rx, -EINVAL); + assert_return(mask != 0, -EINVAL); + + lldp_rx->capability_mask = mask; + + return 0; +} + +_public_ int sd_lldp_rx_set_filter_address(sd_lldp_rx *lldp_rx, const struct ether_addr *addr) { + assert_return(lldp_rx, -EINVAL); + + /* In order to deal nicely with bridges that send back our own packets, allow one address to be filtered, so + * that our own can be filtered out here. */ + + if (addr) + lldp_rx->filter_address = *addr; + else + zero(lldp_rx->filter_address); + + return 0; +} diff --git a/src/libnm-systemd-core/src/libsystemd-network/sd-lldp.c b/src/libnm-systemd-core/src/libsystemd-network/sd-lldp.c deleted file mode 100644 index 09c2052f..00000000 --- a/src/libnm-systemd-core/src/libsystemd-network/sd-lldp.c +++ /dev/null @@ -1,524 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ - -#include "nm-sd-adapt-core.h" - -#include -#include -#include - -#include "sd-lldp.h" - -#include "alloc-util.h" -#include "ether-addr-util.h" -#include "event-util.h" -#include "fd-util.h" -#include "lldp-internal.h" -#include "lldp-neighbor.h" -#include "lldp-network.h" -#include "memory-util.h" -#include "network-common.h" -#include "socket-util.h" -#include "sort-util.h" -#include "string-table.h" - -#define LLDP_DEFAULT_NEIGHBORS_MAX 128U - -static const char * const lldp_event_table[_SD_LLDP_EVENT_MAX] = { - [SD_LLDP_EVENT_ADDED] = "added", - [SD_LLDP_EVENT_REMOVED] = "removed", - [SD_LLDP_EVENT_UPDATED] = "updated", - [SD_LLDP_EVENT_REFRESHED] = "refreshed", -}; - -DEFINE_STRING_TABLE_LOOKUP(lldp_event, sd_lldp_event_t); - -static void lldp_flush_neighbors(sd_lldp *lldp) { - assert(lldp); - - hashmap_clear(lldp->neighbor_by_id); -} - -static void lldp_callback(sd_lldp *lldp, sd_lldp_event_t event, sd_lldp_neighbor *n) { - assert(lldp); - assert(event >= 0 && event < _SD_LLDP_EVENT_MAX); - - if (!lldp->callback) - return (void) log_lldp(lldp, "Received '%s' event.", lldp_event_to_string(event)); - - log_lldp(lldp, "Invoking callback for '%s' event.", lldp_event_to_string(event)); - lldp->callback(lldp, event, n, lldp->userdata); -} - -static int lldp_make_space(sd_lldp *lldp, size_t extra) { - usec_t t = USEC_INFINITY; - bool changed = false; - - assert(lldp); - - /* Remove all entries that are past their TTL, and more until at least the specified number of extra entries - * are free. */ - - for (;;) { - _cleanup_(sd_lldp_neighbor_unrefp) sd_lldp_neighbor *n = NULL; - - n = prioq_peek(lldp->neighbor_by_expiry); - if (!n) - break; - - sd_lldp_neighbor_ref(n); - - if (hashmap_size(lldp->neighbor_by_id) > LESS_BY(lldp->neighbors_max, extra)) - goto remove_one; - - if (t == USEC_INFINITY) - t = now(clock_boottime_or_monotonic()); - - if (n->until > t) - break; - - remove_one: - lldp_neighbor_unlink(n); - lldp_callback(lldp, SD_LLDP_EVENT_REMOVED, n); - changed = true; - } - - return changed; -} - -static bool lldp_keep_neighbor(sd_lldp *lldp, sd_lldp_neighbor *n) { - assert(lldp); - assert(n); - - /* Don't keep data with a zero TTL */ - if (n->ttl <= 0) - return false; - - /* Filter out data from the filter address */ - if (!ether_addr_is_null(&lldp->filter_address) && - ether_addr_equal(&lldp->filter_address, &n->source_address)) - return false; - - /* Only add if the neighbor has a capability we are interested in. Note that we also store all neighbors with - * no caps field set. */ - if (n->has_capabilities && - (n->enabled_capabilities & lldp->capability_mask) == 0) - return false; - - /* Keep everything else */ - return true; -} - -static int lldp_start_timer(sd_lldp *lldp, sd_lldp_neighbor *neighbor); - -static int lldp_add_neighbor(sd_lldp *lldp, sd_lldp_neighbor *n) { - _cleanup_(sd_lldp_neighbor_unrefp) sd_lldp_neighbor *old = NULL; - bool keep; - int r; - - assert(lldp); - assert(n); - assert(!n->lldp); - - keep = lldp_keep_neighbor(lldp, n); - - /* First retrieve the old entry for this MSAP */ - old = hashmap_get(lldp->neighbor_by_id, &n->id); - if (old) { - sd_lldp_neighbor_ref(old); - - if (!keep) { - lldp_neighbor_unlink(old); - lldp_callback(lldp, SD_LLDP_EVENT_REMOVED, old); - return 0; - } - - if (lldp_neighbor_equal(n, old)) { - /* Is this equal, then restart the TTL counter, but don't do anything else. */ - old->timestamp = n->timestamp; - lldp_start_timer(lldp, old); - lldp_callback(lldp, SD_LLDP_EVENT_REFRESHED, old); - return 0; - } - - /* Data changed, remove the old entry, and add a new one */ - lldp_neighbor_unlink(old); - - } else if (!keep) - return 0; - - /* Then, make room for at least one new neighbor */ - lldp_make_space(lldp, 1); - - r = hashmap_put(lldp->neighbor_by_id, &n->id, n); - if (r < 0) - goto finish; - - r = prioq_put(lldp->neighbor_by_expiry, n, &n->prioq_idx); - if (r < 0) { - assert_se(hashmap_remove(lldp->neighbor_by_id, &n->id) == n); - goto finish; - } - - n->lldp = lldp; - - lldp_start_timer(lldp, n); - lldp_callback(lldp, old ? SD_LLDP_EVENT_UPDATED : SD_LLDP_EVENT_ADDED, n); - - return 1; - -finish: - if (old) - lldp_callback(lldp, SD_LLDP_EVENT_REMOVED, old); - - return r; -} - -static int lldp_handle_datagram(sd_lldp *lldp, sd_lldp_neighbor *n) { - int r; - - assert(lldp); - assert(n); - - r = lldp_neighbor_parse(n); - if (r == -EBADMSG) /* Ignore bad messages */ - return 0; - if (r < 0) - return r; - - r = lldp_add_neighbor(lldp, n); - if (r < 0) { - log_lldp_errno(lldp, r, "Failed to add datagram. Ignoring."); - return 0; - } - - log_lldp(lldp, "Successfully processed LLDP datagram."); - return 0; -} - -static int lldp_receive_datagram(sd_event_source *s, int fd, uint32_t revents, void *userdata) { - _cleanup_(sd_lldp_neighbor_unrefp) sd_lldp_neighbor *n = NULL; - ssize_t space, length; - sd_lldp *lldp = userdata; - struct timespec ts; - - assert(fd >= 0); - assert(lldp); - - space = next_datagram_size_fd(fd); - if (space < 0) { - log_lldp_errno(lldp, space, "Failed to determine datagram size to read, ignoring: %m"); - return 0; - } - - n = lldp_neighbor_new(space); - if (!n) - return -ENOMEM; - - length = recv(fd, LLDP_NEIGHBOR_RAW(n), n->raw_size, MSG_DONTWAIT); - if (length < 0) { - if (IN_SET(errno, EAGAIN, EINTR)) - return 0; - - log_lldp_errno(lldp, errno, "Failed to read LLDP datagram, ignoring: %m"); - return 0; - } - - if ((size_t) length != n->raw_size) { - log_lldp(lldp, "Packet size mismatch, ignoring"); - return 0; - } - - /* Try to get the timestamp of this packet if it is known */ - if (ioctl(fd, SIOCGSTAMPNS, &ts) >= 0) - triple_timestamp_from_realtime(&n->timestamp, timespec_load(&ts)); - else - triple_timestamp_get(&n->timestamp); - - return lldp_handle_datagram(lldp, n); -} - -static void lldp_reset(sd_lldp *lldp) { - assert(lldp); - - (void) event_source_disable(lldp->timer_event_source); - lldp->io_event_source = sd_event_source_unref(lldp->io_event_source); - lldp->fd = safe_close(lldp->fd); -} - -_public_ int sd_lldp_start(sd_lldp *lldp) { - int r; - - assert_return(lldp, -EINVAL); - assert_return(lldp->event, -EINVAL); - assert_return(lldp->ifindex > 0, -EINVAL); - - if (lldp->fd >= 0) - return 0; - - assert(!lldp->io_event_source); - - lldp->fd = lldp_network_bind_raw_socket(lldp->ifindex); - if (lldp->fd < 0) - return lldp->fd; - - r = sd_event_add_io(lldp->event, &lldp->io_event_source, lldp->fd, EPOLLIN, lldp_receive_datagram, lldp); - if (r < 0) - goto fail; - - r = sd_event_source_set_priority(lldp->io_event_source, lldp->event_priority); - if (r < 0) - goto fail; - - (void) sd_event_source_set_description(lldp->io_event_source, "lldp-io"); - - log_lldp(lldp, "Started LLDP client"); - return 1; - -fail: - lldp_reset(lldp); - return r; -} - -_public_ int sd_lldp_stop(sd_lldp *lldp) { - if (!lldp) - return 0; - - if (lldp->fd < 0) - return 0; - - log_lldp(lldp, "Stopping LLDP client"); - - lldp_reset(lldp); - lldp_flush_neighbors(lldp); - - return 1; -} - -_public_ int sd_lldp_attach_event(sd_lldp *lldp, sd_event *event, int64_t priority) { - int r; - - assert_return(lldp, -EINVAL); - assert_return(lldp->fd < 0, -EBUSY); - assert_return(!lldp->event, -EBUSY); - - if (event) - lldp->event = sd_event_ref(event); - else { - r = sd_event_default(&lldp->event); - if (r < 0) - return r; - } - - lldp->event_priority = priority; - - return 0; -} - -_public_ int sd_lldp_detach_event(sd_lldp *lldp) { - - assert_return(lldp, -EINVAL); - assert_return(lldp->fd < 0, -EBUSY); - - lldp->event = sd_event_unref(lldp->event); - return 0; -} - -_public_ sd_event* sd_lldp_get_event(sd_lldp *lldp) { - assert_return(lldp, NULL); - - return lldp->event; -} - -_public_ int sd_lldp_set_callback(sd_lldp *lldp, sd_lldp_callback_t cb, void *userdata) { - assert_return(lldp, -EINVAL); - - lldp->callback = cb; - lldp->userdata = userdata; - - return 0; -} - -_public_ int sd_lldp_set_ifindex(sd_lldp *lldp, int ifindex) { - assert_return(lldp, -EINVAL); - assert_return(ifindex > 0, -EINVAL); - assert_return(lldp->fd < 0, -EBUSY); - - lldp->ifindex = ifindex; - return 0; -} - -int sd_lldp_set_ifname(sd_lldp *lldp, const char *ifname) { - assert_return(lldp, -EINVAL); - assert_return(ifname, -EINVAL); - - if (!ifname_valid_full(ifname, IFNAME_VALID_ALTERNATIVE)) - return -EINVAL; - - return free_and_strdup(&lldp->ifname, ifname); -} - -const char *sd_lldp_get_ifname(sd_lldp *lldp) { - if (!lldp) - return NULL; - - return get_ifname(lldp->ifindex, &lldp->ifname); -} - -static sd_lldp* lldp_free(sd_lldp *lldp) { - assert(lldp); - - lldp->timer_event_source = sd_event_source_unref(lldp->timer_event_source); - - lldp_reset(lldp); - sd_lldp_detach_event(lldp); - lldp_flush_neighbors(lldp); - - hashmap_free(lldp->neighbor_by_id); - prioq_free(lldp->neighbor_by_expiry); - free(lldp->ifname); - return mfree(lldp); -} - -DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(sd_lldp, sd_lldp, lldp_free); - -_public_ int sd_lldp_new(sd_lldp **ret) { - _cleanup_(sd_lldp_unrefp) sd_lldp *lldp = NULL; - int r; - - assert_return(ret, -EINVAL); - - lldp = new(sd_lldp, 1); - if (!lldp) - return -ENOMEM; - - *lldp = (sd_lldp) { - .n_ref = 1, - .fd = -1, - .neighbors_max = LLDP_DEFAULT_NEIGHBORS_MAX, - .capability_mask = UINT16_MAX, - }; - - lldp->neighbor_by_id = hashmap_new(&lldp_neighbor_hash_ops); - if (!lldp->neighbor_by_id) - return -ENOMEM; - - r = prioq_ensure_allocated(&lldp->neighbor_by_expiry, lldp_neighbor_prioq_compare_func); - if (r < 0) - return r; - - *ret = TAKE_PTR(lldp); - - return 0; -} - -static int neighbor_compare_func(sd_lldp_neighbor * const *a, sd_lldp_neighbor * const *b) { - return lldp_neighbor_id_compare_func(&(*a)->id, &(*b)->id); -} - -static int on_timer_event(sd_event_source *s, uint64_t usec, void *userdata) { - sd_lldp *lldp = userdata; - int r; - - r = lldp_make_space(lldp, 0); - if (r < 0) { - log_lldp_errno(lldp, r, "Failed to make space, ignoring: %m"); - return 0; - } - - r = lldp_start_timer(lldp, NULL); - if (r < 0) { - log_lldp_errno(lldp, r, "Failed to restart timer, ignoring: %m"); - return 0; - } - - return 0; -} - -static int lldp_start_timer(sd_lldp *lldp, sd_lldp_neighbor *neighbor) { - sd_lldp_neighbor *n; - - assert(lldp); - - if (neighbor) - lldp_neighbor_start_ttl(neighbor); - - n = prioq_peek(lldp->neighbor_by_expiry); - if (!n) - return event_source_disable(lldp->timer_event_source); - - if (!lldp->event) - return 0; - - return event_reset_time(lldp->event, &lldp->timer_event_source, - clock_boottime_or_monotonic(), - n->until, 0, - on_timer_event, lldp, - lldp->event_priority, "lldp-timer", true); -} - -_public_ int sd_lldp_get_neighbors(sd_lldp *lldp, sd_lldp_neighbor ***ret) { - sd_lldp_neighbor **l = NULL, *n; - int k = 0, r; - - assert_return(lldp, -EINVAL); - assert_return(ret, -EINVAL); - - if (hashmap_isempty(lldp->neighbor_by_id)) { /* Special shortcut */ - *ret = NULL; - return 0; - } - - l = new0(sd_lldp_neighbor*, hashmap_size(lldp->neighbor_by_id)); - if (!l) - return -ENOMEM; - - r = lldp_start_timer(lldp, NULL); - if (r < 0) { - free(l); - return r; - } - - HASHMAP_FOREACH(n, lldp->neighbor_by_id) - l[k++] = sd_lldp_neighbor_ref(n); - - assert((size_t) k == hashmap_size(lldp->neighbor_by_id)); - - /* Return things in a stable order */ - typesafe_qsort(l, k, neighbor_compare_func); - *ret = l; - - return k; -} - -_public_ int sd_lldp_set_neighbors_max(sd_lldp *lldp, uint64_t m) { - assert_return(lldp, -EINVAL); - assert_return(m > 0, -EINVAL); - - lldp->neighbors_max = m; - lldp_make_space(lldp, 0); - - return 0; -} - -_public_ int sd_lldp_match_capabilities(sd_lldp *lldp, uint16_t mask) { - assert_return(lldp, -EINVAL); - assert_return(mask != 0, -EINVAL); - - lldp->capability_mask = mask; - - return 0; -} - -_public_ int sd_lldp_set_filter_address(sd_lldp *lldp, const struct ether_addr *addr) { - assert_return(lldp, -EINVAL); - - /* In order to deal nicely with bridges that send back our own packets, allow one address to be filtered, so - * that our own can be filtered out here. */ - - if (addr) - lldp->filter_address = *addr; - else - zero(lldp->filter_address); - - return 0; -} diff --git a/src/libnm-systemd-core/src/libsystemd/sd-event/event-source.h b/src/libnm-systemd-core/src/libsystemd/sd-event/event-source.h index d2dc2147..08b409fe 100644 --- a/src/libnm-systemd-core/src/libsystemd/sd-event/event-source.h +++ b/src/libnm-systemd-core/src/libsystemd/sd-event/event-source.h @@ -7,8 +7,8 @@ #include "sd-event.h" -#include "fs-util.h" #include "hashmap.h" +#include "inotify-util.h" #include "list.h" #include "prioq.h" #include "ratelimit.h" diff --git a/src/libnm-systemd-core/src/libsystemd/sd-event/sd-event.c b/src/libnm-systemd-core/src/libsystemd/sd-event/sd-event.c index 44926744..0acbdd54 100644 --- a/src/libnm-systemd-core/src/libsystemd/sd-event/sd-event.c +++ b/src/libnm-systemd-core/src/libsystemd/sd-event/sd-event.c @@ -87,6 +87,11 @@ DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(event_source_type, int); SOURCE_DEFER, \ SOURCE_INOTIFY) +/* This is used to assert that we didn't pass an unexpected source type to event_source_time_prioq_put(). + * Time sources and ratelimited sources can be passed, so effectively this is the same as the + * EVENT_SOURCE_CAN_RATE_LIMIT() macro. */ +#define EVENT_SOURCE_USES_TIME_PRIOQ(t) EVENT_SOURCE_CAN_RATE_LIMIT(t) + struct sd_event { unsigned n_ref; @@ -170,10 +175,9 @@ static int pending_prioq_compare(const void *a, const void *b) { assert(y->pending); /* Enabled ones first */ - if (x->enabled != SD_EVENT_OFF && y->enabled == SD_EVENT_OFF) - return -1; - if (x->enabled == SD_EVENT_OFF && y->enabled != SD_EVENT_OFF) - return 1; + r = CMP(x->enabled == SD_EVENT_OFF, y->enabled == SD_EVENT_OFF); + if (r != 0) + return r; /* Non rate-limited ones first. */ r = CMP(!!x->ratelimited, !!y->ratelimited); @@ -197,10 +201,9 @@ static int prepare_prioq_compare(const void *a, const void *b) { assert(y->prepare); /* Enabled ones first */ - if (x->enabled != SD_EVENT_OFF && y->enabled == SD_EVENT_OFF) - return -1; - if (x->enabled == SD_EVENT_OFF && y->enabled != SD_EVENT_OFF) - return 1; + r = CMP(x->enabled == SD_EVENT_OFF, y->enabled == SD_EVENT_OFF); + if (r != 0) + return r; /* Non rate-limited ones first. */ r = CMP(!!x->ratelimited, !!y->ratelimited); @@ -239,25 +242,6 @@ static usec_t time_event_source_next(const sd_event_source *s) { return USEC_INFINITY; } -static int earliest_time_prioq_compare(const void *a, const void *b) { - const sd_event_source *x = a, *y = b; - - /* Enabled ones first */ - if (x->enabled != SD_EVENT_OFF && y->enabled == SD_EVENT_OFF) - return -1; - if (x->enabled == SD_EVENT_OFF && y->enabled != SD_EVENT_OFF) - return 1; - - /* Move the pending ones to the end */ - if (!x->pending && y->pending) - return -1; - if (x->pending && !y->pending) - return 1; - - /* Order by time */ - return CMP(time_event_source_next(x), time_event_source_next(y)); -} - static usec_t time_event_source_latest(const sd_event_source *s) { assert(s); @@ -276,36 +260,51 @@ static usec_t time_event_source_latest(const sd_event_source *s) { return USEC_INFINITY; } -static int latest_time_prioq_compare(const void *a, const void *b) { +static bool event_source_timer_candidate(const sd_event_source *s) { + assert(s); + + /* Returns true for event sources that either are not pending yet (i.e. where it's worth to mark them pending) + * or which are currently ratelimited (i.e. where it's worth leaving the ratelimited state) */ + return !s->pending || s->ratelimited; +} + +static int time_prioq_compare(const void *a, const void *b, usec_t (*time_func)(const sd_event_source *s)) { const sd_event_source *x = a, *y = b; + int r; /* Enabled ones first */ - if (x->enabled != SD_EVENT_OFF && y->enabled == SD_EVENT_OFF) - return -1; - if (x->enabled == SD_EVENT_OFF && y->enabled != SD_EVENT_OFF) - return 1; + r = CMP(x->enabled == SD_EVENT_OFF, y->enabled == SD_EVENT_OFF); + if (r != 0) + return r; - /* Move the pending ones to the end */ - if (!x->pending && y->pending) - return -1; - if (x->pending && !y->pending) - return 1; + /* Order "non-pending OR ratelimited" before "pending AND not-ratelimited" */ + r = CMP(!event_source_timer_candidate(x), !event_source_timer_candidate(y)); + if (r != 0) + return r; /* Order by time */ - return CMP(time_event_source_latest(x), time_event_source_latest(y)); + return CMP(time_func(x), time_func(y)); +} + +static int earliest_time_prioq_compare(const void *a, const void *b) { + return time_prioq_compare(a, b, time_event_source_next); +} + +static int latest_time_prioq_compare(const void *a, const void *b) { + return time_prioq_compare(a, b, time_event_source_latest); } static int exit_prioq_compare(const void *a, const void *b) { const sd_event_source *x = a, *y = b; + int r; assert(x->type == SOURCE_EXIT); assert(y->type == SOURCE_EXIT); /* Enabled ones first */ - if (x->enabled != SD_EVENT_OFF && y->enabled == SD_EVENT_OFF) - return -1; - if (x->enabled == SD_EVENT_OFF && y->enabled != SD_EVENT_OFF) - return 1; + r = CMP(x->enabled == SD_EVENT_OFF, y->enabled == SD_EVENT_OFF); + if (r != 0) + return r; /* Lower priority values first */ return CMP(x->priority, y->priority); @@ -779,14 +778,15 @@ static void event_source_time_prioq_reshuffle(sd_event_source *s) { assert(s); /* Called whenever the event source's timer ordering properties changed, i.e. time, accuracy, - * pending, enable state. Makes sure the two prioq's are ordered properly again. */ + * pending, enable state, and ratelimiting state. Makes sure the two prioq's are ordered + * properly again. */ if (s->ratelimited) d = &s->event->monotonic; - else { - assert(EVENT_SOURCE_IS_TIME(s->type)); + else if (EVENT_SOURCE_IS_TIME(s->type)) assert_se(d = event_get_clock_data(s->event, s->type)); - } + else + return; /* no-op for an event source which is neither a timer nor ratelimited. */ prioq_reshuffle(d->earliest, s, &s->earliest_index); prioq_reshuffle(d->latest, s, &s->latest_index); @@ -917,7 +917,7 @@ static void source_disconnect(sd_event_source *s) { } default: - assert_not_reached("Wut? I shouldn't exist."); + assert_not_reached(); } if (s->pending) @@ -1205,6 +1205,7 @@ static int event_source_time_prioq_put( assert(s); assert(d); + assert(EVENT_SOURCE_USES_TIME_PRIOQ(s->type)); r = prioq_put(d->earliest, s, &s->earliest_index); if (r < 0) @@ -2379,14 +2380,6 @@ static int event_source_offline( source_io_unregister(s); break; - case SOURCE_TIME_REALTIME: - case SOURCE_TIME_BOOTTIME: - case SOURCE_TIME_MONOTONIC: - case SOURCE_TIME_REALTIME_ALARM: - case SOURCE_TIME_BOOTTIME_ALARM: - event_source_time_prioq_reshuffle(s); - break; - case SOURCE_SIGNAL: event_gc_signal_data(s->event, &s->priority, s->signal.sig); break; @@ -2407,15 +2400,23 @@ static int event_source_offline( prioq_reshuffle(s->event->exit, s, &s->exit.prioq_index); break; + case SOURCE_TIME_REALTIME: + case SOURCE_TIME_BOOTTIME: + case SOURCE_TIME_MONOTONIC: + case SOURCE_TIME_REALTIME_ALARM: + case SOURCE_TIME_BOOTTIME_ALARM: case SOURCE_DEFER: case SOURCE_POST: case SOURCE_INOTIFY: break; default: - assert_not_reached("Wut? I shouldn't exist."); + assert_not_reached(); } + /* Always reshuffle time prioq, as the ratelimited flag may be changed. */ + event_source_time_prioq_reshuffle(s); + return 1; } @@ -2498,29 +2499,18 @@ static int event_source_online( break; default: - assert_not_reached("Wut? I shouldn't exist."); + assert_not_reached(); } s->enabled = enabled; s->ratelimited = ratelimited; /* Non-failing operations below */ - switch (s->type) { - case SOURCE_TIME_REALTIME: - case SOURCE_TIME_BOOTTIME: - case SOURCE_TIME_MONOTONIC: - case SOURCE_TIME_REALTIME_ALARM: - case SOURCE_TIME_BOOTTIME_ALARM: - event_source_time_prioq_reshuffle(s); - break; - - case SOURCE_EXIT: + if (s->type == SOURCE_EXIT) prioq_reshuffle(s->event->exit, s, &s->exit.prioq_index); - break; - default: - break; - } + /* Always reshuffle time prioq, as the ratelimited flag may be changed. */ + event_source_time_prioq_reshuffle(s); return 1; } @@ -2990,10 +2980,11 @@ static int event_arm_timer( if (!d->needs_rearm) return 0; - else - d->needs_rearm = false; + + d->needs_rearm = false; a = prioq_peek(d->earliest); + assert(!a || EVENT_SOURCE_USES_TIME_PRIOQ(a->type)); if (!a || a->enabled == SD_EVENT_OFF || time_event_source_next(a) == USEC_INFINITY) { if (d->fd < 0) @@ -3011,7 +3002,8 @@ static int event_arm_timer( } b = prioq_peek(d->latest); - assert_se(b && b->enabled != SD_EVENT_OFF); + assert(!b || EVENT_SOURCE_USES_TIME_PRIOQ(b->type)); + assert(b && b->enabled != SD_EVENT_OFF); t = sleep_between(e, time_event_source_next(a), time_event_source_latest(b)); if (d->next == t) @@ -3091,6 +3083,8 @@ static int process_timer( for (;;) { s = prioq_peek(d->earliest); + assert(!s || EVENT_SOURCE_USES_TIME_PRIOQ(s->type)); + if (!s || time_event_source_next(s) > n) break; @@ -3579,7 +3573,7 @@ static int source_dispatch(sd_event_source *s) { case SOURCE_WATCHDOG: case _SOURCE_EVENT_SOURCE_TYPE_MAX: case _SOURCE_EVENT_SOURCE_TYPE_INVALID: - assert_not_reached("Wut? I shouldn't exist."); + assert_not_reached(); } s->dispatching = false; @@ -3651,6 +3645,8 @@ static int dispatch_exit(sd_event *e) { assert(e); p = prioq_peek(e->exit); + assert(!p || p->type == SOURCE_EXIT); + if (!p || event_source_is_offline(p)) { e->state = SD_EVENT_FINISHED; return 0; @@ -3687,8 +3683,8 @@ static int arm_watchdog(sd_event *e) { assert(e->watchdog_fd >= 0); t = sleep_between(e, - e->watchdog_last + (e->watchdog_period / 2), - e->watchdog_last + (e->watchdog_period * 3 / 4)); + usec_add(e->watchdog_last, (e->watchdog_period / 2)), + usec_add(e->watchdog_last, (e->watchdog_period * 3 / 4))); timespec_store(&its.it_value, t); @@ -3937,7 +3933,7 @@ static int process_epoll(sd_event *e, usec_t timeout, int64_t threshold, int64_t break; default: - assert_not_reached("Unexpected event source type"); + assert_not_reached(); } break; @@ -3961,7 +3957,7 @@ static int process_epoll(sd_event *e, usec_t timeout, int64_t threshold, int64_t break; default: - assert_not_reached("Invalid wake-up pointer"); + assert_not_reached(); } } if (r < 0) @@ -4162,7 +4158,7 @@ _public_ int sd_event_loop(sd_event *e) { assert_return(!event_pid_changed(e), -ECHILD); assert_return(e->state == SD_EVENT_INITIAL, -EBUSY); - _unused_ _cleanup_(sd_event_unrefp) sd_event *ref = NULL; + _unused_ _cleanup_(sd_event_unrefp) sd_event *ref = sd_event_ref(e); while (e->state != SD_EVENT_FINISHED) { r = sd_event_run(e, UINT64_MAX); diff --git a/src/libnm-systemd-core/src/libsystemd/sd-id128/id128-util.c b/src/libnm-systemd-core/src/libsystemd/sd-id128/id128-util.c index 3a2bffab..d80145a8 100644 --- a/src/libnm-systemd-core/src/libsystemd/sd-id128/id128-util.c +++ b/src/libnm-systemd-core/src/libsystemd/sd-id128/id128-util.c @@ -7,12 +7,12 @@ #include #include "fd-util.h" -#include "fs-util.h" #include "hexdecoct.h" #include "id128-util.h" #include "io-util.h" #include "stdio-util.h" #include "string-util.h" +#include "sync-util.h" #if 0 /* NM_IGNORED */ char *id128_to_uuid_string(sd_id128_t id, char s[static ID128_UUID_STRING_MAX]) { @@ -172,10 +172,7 @@ int id128_write_fd(int fd, Id128Format f, sd_id128_t id, bool do_sync) { return r; if (do_sync) { - if (fsync(fd) < 0) - return -errno; - - r = fsync_directory_of_file(fd); + r = fsync_full(fd); if (r < 0) return r; } diff --git a/src/libnm-systemd-core/src/libsystemd/sd-id128/id128-util.h b/src/libnm-systemd-core/src/libsystemd/sd-id128/id128-util.h index 053ef0a6..b7327a1f 100644 --- a/src/libnm-systemd-core/src/libsystemd/sd-id128/id128-util.h +++ b/src/libnm-systemd-core/src/libsystemd/sd-id128/id128-util.h @@ -12,6 +12,8 @@ char *id128_to_uuid_string(sd_id128_t id, char s[static ID128_UUID_STRING_MAX]); +#define ID128_TO_UUID_STRING(id) id128_to_uuid_string((id), (char[ID128_UUID_STRING_MAX]) {}) + bool id128_is_valid(const char *s) _pure_; typedef enum Id128Format { diff --git a/src/libnm-systemd-core/src/libsystemd/sd-id128/sd-id128.c b/src/libnm-systemd-core/src/libsystemd/sd-id128/sd-id128.c index 64b8c787..0860f493 100644 --- a/src/libnm-systemd-core/src/libsystemd/sd-id128/sd-id128.c +++ b/src/libnm-systemd-core/src/libsystemd/sd-id128/sd-id128.c @@ -6,6 +6,11 @@ #include #include +#if HAVE_OPENSSL +#include +#include +#endif + #include "sd-id128.h" #include "alloc-util.h" @@ -13,7 +18,9 @@ #include "hexdecoct.h" #include "id128-util.h" #include "io-util.h" +#if !HAVE_OPENSSL #include "khash.h" +#endif #include "macro.h" #include "missing_syscall.h" #include "random-util.h" @@ -276,13 +283,28 @@ _public_ int sd_id128_randomize(sd_id128_t *ret) { } static int get_app_specific(sd_id128_t base, sd_id128_t app_id, sd_id128_t *ret) { - _cleanup_(khash_unrefp) khash *h = NULL; sd_id128_t result; - const void *p; - int r; assert(ret); +#if HAVE_OPENSSL + /* We prefer doing this in-process, since we this means we are not dependent on kernel configuration, + * and this also works in locked down container environments. But some distros don't like OpenSSL's + * license and its (in-) compatibility with GPL2, hence also support khash */ + uint8_t md[256/8]; + if (!HMAC(EVP_sha256(), + &base, sizeof(base), + (const unsigned char*) &app_id, sizeof(app_id), + md, NULL)) + return -ENOTRECOVERABLE; + + /* Take only the first half. */ + memcpy(&result, md, MIN(sizeof(md), sizeof(result))); +#else + _cleanup_(khash_unrefp) khash *h = NULL; + const void *p; + int r; + r = khash_new_with_key(&h, "hmac(sha256)", &base, sizeof(base)); if (r < 0) return r; @@ -297,6 +319,7 @@ static int get_app_specific(sd_id128_t base, sd_id128_t app_id, sd_id128_t *ret) /* We chop off the trailing 16 bytes */ memcpy(&result, p, MIN(khash_get_size(h), sizeof(result))); +#endif *ret = id128_make_v4_uuid(result); return 0; diff --git a/src/libnm-systemd-core/src/systemd/sd-dhcp-client.h b/src/libnm-systemd-core/src/systemd/sd-dhcp-client.h index 53002340..23979b12 100644 --- a/src/libnm-systemd-core/src/systemd/sd-dhcp-client.h +++ b/src/libnm-systemd-core/src/systemd/sd-dhcp-client.h @@ -135,7 +135,7 @@ int sd_dhcp_client_set_ifindex( int sd_dhcp_client_set_ifname( sd_dhcp_client *client, const char *interface_name); -const char *sd_dhcp_client_get_ifname(sd_dhcp_client *client); +int sd_dhcp_client_get_ifname(sd_dhcp_client *client, const char **ret); int sd_dhcp_client_set_mac( sd_dhcp_client *client, const uint8_t *addr, diff --git a/src/libnm-systemd-core/src/systemd/sd-dhcp6-client.h b/src/libnm-systemd-core/src/systemd/sd-dhcp6-client.h index e02d6763..f3889782 100644 --- a/src/libnm-systemd-core/src/systemd/sd-dhcp6-client.h +++ b/src/libnm-systemd-core/src/systemd/sd-dhcp6-client.h @@ -94,7 +94,7 @@ int sd_dhcp6_client_set_ifindex( int sd_dhcp6_client_set_ifname( sd_dhcp6_client *client, const char *interface_name); -const char * sd_dhcp6_client_get_ifname(sd_dhcp6_client *client); +int sd_dhcp6_client_get_ifname(sd_dhcp6_client *client, const char **ret); int sd_dhcp6_client_set_local_address( sd_dhcp6_client *client, const struct in6_addr *local_address); diff --git a/src/libnm-systemd-core/src/systemd/sd-dhcp6-lease.h b/src/libnm-systemd-core/src/systemd/sd-dhcp6-lease.h index f77b31ac..a10901e5 100644 --- a/src/libnm-systemd-core/src/systemd/sd-dhcp6-lease.h +++ b/src/libnm-systemd-core/src/systemd/sd-dhcp6-lease.h @@ -39,11 +39,11 @@ int sd_dhcp6_lease_get_pd(sd_dhcp6_lease *lease, struct in6_addr *prefix, uint32_t *lifetime_preferred, uint32_t *lifetime_valid); -int sd_dhcp6_lease_get_dns(sd_dhcp6_lease *lease, const struct in6_addr **addrs); -int sd_dhcp6_lease_get_domains(sd_dhcp6_lease *lease, char ***domains); -int sd_dhcp6_lease_get_ntp_addrs(sd_dhcp6_lease *lease, const struct in6_addr **addrs); -int sd_dhcp6_lease_get_ntp_fqdn(sd_dhcp6_lease *lease, char ***ntp_fqdn); -int sd_dhcp6_lease_get_fqdn(sd_dhcp6_lease *lease, const char **fqdn); +int sd_dhcp6_lease_get_dns(sd_dhcp6_lease *lease, const struct in6_addr **ret); +int sd_dhcp6_lease_get_domains(sd_dhcp6_lease *lease, char ***ret); +int sd_dhcp6_lease_get_ntp_addrs(sd_dhcp6_lease *lease, const struct in6_addr **ret); +int sd_dhcp6_lease_get_ntp_fqdn(sd_dhcp6_lease *lease, char ***ret); +int sd_dhcp6_lease_get_fqdn(sd_dhcp6_lease *lease, const char **ret); sd_dhcp6_lease *sd_dhcp6_lease_ref(sd_dhcp6_lease *lease); sd_dhcp6_lease *sd_dhcp6_lease_unref(sd_dhcp6_lease *lease); diff --git a/src/libnm-systemd-core/src/systemd/sd-id128.h b/src/libnm-systemd-core/src/systemd/sd-id128.h index ab209c8c..e64f3200 100644 --- a/src/libnm-systemd-core/src/systemd/sd-id128.h +++ b/src/libnm-systemd-core/src/systemd/sd-id128.h @@ -34,11 +34,13 @@ union sd_id128 { uint64_t qwords[2]; }; -#define SD_ID128_STRING_MAX 33 +#define SD_ID128_STRING_MAX 33U char *sd_id128_to_string(sd_id128_t id, char s[_SD_ARRAY_STATIC SD_ID128_STRING_MAX]); int sd_id128_from_string(const char *s, sd_id128_t *ret); +#define SD_ID128_TO_STRING(id) sd_id128_to_string((id), (char[SD_ID128_STRING_MAX]) {}) + int sd_id128_randomize(sd_id128_t *ret); int sd_id128_get_machine(sd_id128_t *ret); @@ -63,7 +65,9 @@ int sd_id128_get_boot_app_specific(sd_id128_t app_id, sd_id128_t *ret); #define SD_ID128_FORMAT_STR "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" #define SD_ID128_FORMAT_VAL(x) (x).bytes[0], (x).bytes[1], (x).bytes[2], (x).bytes[3], (x).bytes[4], (x).bytes[5], (x).bytes[6], (x).bytes[7], (x).bytes[8], (x).bytes[9], (x).bytes[10], (x).bytes[11], (x).bytes[12], (x).bytes[13], (x).bytes[14], (x).bytes[15] -/* Like SD_ID128_FORMAT_STR, but formats as UUID, not in plain format */ +/* Like SD_ID128_FORMAT_STR, but formats as UUID, not in plain format (Strictly Big Endian byte order, + * i.e. treats everything as RFC4122 Variant 1 UUIDs, even if variant says otherwise, but matching other + * Linux userspace behaviour.) */ #define SD_ID128_UUID_FORMAT_STR "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x" #define SD_ID128_CONST_STR(x) \ @@ -105,6 +109,9 @@ int sd_id128_get_boot_app_specific(sd_id128_t app_id, sd_id128_t *ret); #define SD_ID128_MAKE_STR(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \ #a #b #c #d #e #f #g #h #i #j #k #l #m #n #o #p +#define SD_ID128_MAKE_UUID_STR(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \ + #a #b #c #d "-" #e #f "-" #g #h "-" #i #j "-" #k #l #m #n #o #p + _sd_pure_ static __inline__ int sd_id128_equal(sd_id128_t a, sd_id128_t b) { return memcmp(&a, &b, 16) == 0; } diff --git a/src/libnm-systemd-core/src/systemd/sd-ipv4acd.h b/src/libnm-systemd-core/src/systemd/sd-ipv4acd.h index 1e89a81b..90d3f0a0 100644 --- a/src/libnm-systemd-core/src/systemd/sd-ipv4acd.h +++ b/src/libnm-systemd-core/src/systemd/sd-ipv4acd.h @@ -36,16 +36,18 @@ enum { typedef struct sd_ipv4acd sd_ipv4acd; typedef void (*sd_ipv4acd_callback_t)(sd_ipv4acd *acd, int event, void *userdata); +typedef int (*sd_ipv4acd_check_mac_callback_t)(sd_ipv4acd *acd, const struct ether_addr *mac, void *userdata); int sd_ipv4acd_detach_event(sd_ipv4acd *acd); int sd_ipv4acd_attach_event(sd_ipv4acd *acd, sd_event *event, int64_t priority); int sd_ipv4acd_get_address(sd_ipv4acd *acd, struct in_addr *address); int sd_ipv4acd_set_callback(sd_ipv4acd *acd, sd_ipv4acd_callback_t cb, void *userdata); +int sd_ipv4acd_set_check_mac_callback(sd_ipv4acd *acd, sd_ipv4acd_check_mac_callback_t cb, void *userdata); int sd_ipv4acd_set_mac(sd_ipv4acd *acd, const struct ether_addr *addr); int sd_ipv4acd_set_ifindex(sd_ipv4acd *acd, int interface_index); int sd_ipv4acd_get_ifindex(sd_ipv4acd *acd); int sd_ipv4acd_set_ifname(sd_ipv4acd *acd, const char *interface_name); -const char *sd_ipv4acd_get_ifname(sd_ipv4acd *acd); +int sd_ipv4acd_get_ifname(sd_ipv4acd *acd, const char **ret); int sd_ipv4acd_set_address(sd_ipv4acd *acd, const struct in_addr *address); int sd_ipv4acd_is_running(sd_ipv4acd *acd); int sd_ipv4acd_start(sd_ipv4acd *acd, bool reset_conflicts); diff --git a/src/libnm-systemd-core/src/systemd/sd-ipv4ll.h b/src/libnm-systemd-core/src/systemd/sd-ipv4ll.h index bf5596ab..ed014b53 100644 --- a/src/libnm-systemd-core/src/systemd/sd-ipv4ll.h +++ b/src/libnm-systemd-core/src/systemd/sd-ipv4ll.h @@ -36,16 +36,18 @@ enum { typedef struct sd_ipv4ll sd_ipv4ll; typedef void (*sd_ipv4ll_callback_t)(sd_ipv4ll *ll, int event, void *userdata); +typedef int (*sd_ipv4ll_check_mac_callback_t)(sd_ipv4ll *ll, const struct ether_addr *mac, void *userdata); int sd_ipv4ll_detach_event(sd_ipv4ll *ll); int sd_ipv4ll_attach_event(sd_ipv4ll *ll, sd_event *event, int64_t priority); int sd_ipv4ll_get_address(sd_ipv4ll *ll, struct in_addr *address); int sd_ipv4ll_set_callback(sd_ipv4ll *ll, sd_ipv4ll_callback_t cb, void *userdata); +int sd_ipv4ll_set_check_mac_callback(sd_ipv4ll *ll, sd_ipv4ll_check_mac_callback_t cb, void *userdata); int sd_ipv4ll_set_mac(sd_ipv4ll *ll, const struct ether_addr *addr); int sd_ipv4ll_set_ifindex(sd_ipv4ll *ll, int interface_index); int sd_ipv4ll_get_ifindex(sd_ipv4ll *ll); int sd_ipv4ll_set_ifname(sd_ipv4ll *ll, const char *interface_name); -const char *sd_ipv4ll_get_ifname(sd_ipv4ll *ll); +int sd_ipv4ll_get_ifname(sd_ipv4ll *ll, const char **ret); int sd_ipv4ll_set_address(sd_ipv4ll *ll, const struct in_addr *address); int sd_ipv4ll_set_address_seed(sd_ipv4ll *ll, uint64_t seed); int sd_ipv4ll_is_running(sd_ipv4ll *ll); diff --git a/src/libnm-systemd-core/src/systemd/sd-lldp-rx.h b/src/libnm-systemd-core/src/systemd/sd-lldp-rx.h new file mode 100644 index 00000000..bfeac14c --- /dev/null +++ b/src/libnm-systemd-core/src/systemd/sd-lldp-rx.h @@ -0,0 +1,109 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#ifndef foosdlldprxhfoo +#define foosdlldprxhfoo + +/*** + systemd is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + systemd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with systemd; If not, see . +***/ + +#include +#include +#include +#include + +#include "sd-event.h" +#include "sd-lldp.h" + +#include "_sd-common.h" + +_SD_BEGIN_DECLARATIONS; + +typedef struct sd_lldp_rx sd_lldp_rx; +typedef struct sd_lldp_neighbor sd_lldp_neighbor; + +typedef enum sd_lldp_rx_event_t { + SD_LLDP_RX_EVENT_ADDED, + SD_LLDP_RX_EVENT_REMOVED, + SD_LLDP_RX_EVENT_UPDATED, + SD_LLDP_RX_EVENT_REFRESHED, + _SD_LLDP_RX_EVENT_MAX, + _SD_LLDP_RX_EVENT_INVALID = -EINVAL, + _SD_ENUM_FORCE_S64(LLDP_RX_EVENT), +} sd_lldp_rx_event_t; + +typedef void (*sd_lldp_rx_callback_t)(sd_lldp_rx *lldp_rx, sd_lldp_rx_event_t event, sd_lldp_neighbor *n, void *userdata); + +int sd_lldp_rx_new(sd_lldp_rx **ret); +sd_lldp_rx *sd_lldp_rx_ref(sd_lldp_rx *lldp_rx); +sd_lldp_rx *sd_lldp_rx_unref(sd_lldp_rx *lldp_rx); + +int sd_lldp_rx_start(sd_lldp_rx *lldp_rx); +int sd_lldp_rx_stop(sd_lldp_rx *lldp_rx); +int sd_lldp_rx_is_running(sd_lldp_rx *lldp_rx); + +int sd_lldp_rx_attach_event(sd_lldp_rx *lldp_rx, sd_event *event, int64_t priority); +int sd_lldp_rx_detach_event(sd_lldp_rx *lldp_rx); +sd_event *sd_lldp_rx_get_event(sd_lldp_rx *lldp_rx); + +int sd_lldp_rx_set_callback(sd_lldp_rx *lldp_rx, sd_lldp_rx_callback_t cb, void *userdata); +int sd_lldp_rx_set_ifindex(sd_lldp_rx *lldp_rx, int ifindex); +int sd_lldp_rx_set_ifname(sd_lldp_rx *lldp_rx, const char *ifname); +int sd_lldp_rx_get_ifname(sd_lldp_rx *lldp_rx, const char **ret); + +/* Controls how much and what to store in the neighbors database */ +int sd_lldp_rx_set_neighbors_max(sd_lldp_rx *lldp_rx, uint64_t n); +int sd_lldp_rx_match_capabilities(sd_lldp_rx *lldp_rx, uint16_t mask); +int sd_lldp_rx_set_filter_address(sd_lldp_rx *lldp_rx, const struct ether_addr *address); + +int sd_lldp_rx_get_neighbors(sd_lldp_rx *lldp_rx, sd_lldp_neighbor ***neighbors); + +int sd_lldp_neighbor_from_raw(sd_lldp_neighbor **ret, const void *raw, size_t raw_size); +sd_lldp_neighbor *sd_lldp_neighbor_ref(sd_lldp_neighbor *n); +sd_lldp_neighbor *sd_lldp_neighbor_unref(sd_lldp_neighbor *n); + +/* Access to LLDP frame metadata */ +int sd_lldp_neighbor_get_source_address(sd_lldp_neighbor *n, struct ether_addr* address); +int sd_lldp_neighbor_get_destination_address(sd_lldp_neighbor *n, struct ether_addr* address); +int sd_lldp_neighbor_get_timestamp(sd_lldp_neighbor *n, clockid_t clock, uint64_t *ret); +int sd_lldp_neighbor_get_raw(sd_lldp_neighbor *n, const void **ret, size_t *size); + +/* High-level, direct, parsed out field access. These fields exist at most once, hence may be queried directly. */ +int sd_lldp_neighbor_get_chassis_id(sd_lldp_neighbor *n, uint8_t *type, const void **ret, size_t *size); +int sd_lldp_neighbor_get_chassis_id_as_string(sd_lldp_neighbor *n, const char **ret); +int sd_lldp_neighbor_get_port_id(sd_lldp_neighbor *n, uint8_t *type, const void **ret, size_t *size); +int sd_lldp_neighbor_get_port_id_as_string(sd_lldp_neighbor *n, const char **ret); +int sd_lldp_neighbor_get_ttl(sd_lldp_neighbor *n, uint16_t *ret_sec); +int sd_lldp_neighbor_get_system_name(sd_lldp_neighbor *n, const char **ret); +int sd_lldp_neighbor_get_system_description(sd_lldp_neighbor *n, const char **ret); +int sd_lldp_neighbor_get_port_description(sd_lldp_neighbor *n, const char **ret); +int sd_lldp_neighbor_get_mud_url(sd_lldp_neighbor *n, const char **ret); +int sd_lldp_neighbor_get_system_capabilities(sd_lldp_neighbor *n, uint16_t *ret); +int sd_lldp_neighbor_get_enabled_capabilities(sd_lldp_neighbor *n, uint16_t *ret); + +/* Low-level, iterative TLV access. This is for everything else, it iteratively goes through all available TLVs + * (including the ones covered with the calls above), and allows multiple TLVs for the same fields. */ +int sd_lldp_neighbor_tlv_rewind(sd_lldp_neighbor *n); +int sd_lldp_neighbor_tlv_next(sd_lldp_neighbor *n); +int sd_lldp_neighbor_tlv_get_type(sd_lldp_neighbor *n, uint8_t *type); +int sd_lldp_neighbor_tlv_is_type(sd_lldp_neighbor *n, uint8_t type); +int sd_lldp_neighbor_tlv_get_oui(sd_lldp_neighbor *n, uint8_t oui[_SD_ARRAY_STATIC 3], uint8_t *subtype); +int sd_lldp_neighbor_tlv_is_oui(sd_lldp_neighbor *n, const uint8_t oui[_SD_ARRAY_STATIC 3], uint8_t subtype); +int sd_lldp_neighbor_tlv_get_raw(sd_lldp_neighbor *n, const void **ret, size_t *size); + +_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_lldp_rx, sd_lldp_rx_unref); +_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_lldp_neighbor, sd_lldp_neighbor_unref); + +_SD_END_DECLARATIONS; + +#endif diff --git a/src/libnm-systemd-core/src/systemd/sd-lldp.h b/src/libnm-systemd-core/src/systemd/sd-lldp.h index 64047ee8..c32d7894 100644 --- a/src/libnm-systemd-core/src/systemd/sd-lldp.h +++ b/src/libnm-systemd-core/src/systemd/sd-lldp.h @@ -17,12 +17,7 @@ along with systemd; If not, see . ***/ -#include #include -#include -#include - -#include "sd-event.h" #include "_sd-common.h" @@ -85,20 +80,24 @@ enum { #define SD_LLDP_SYSTEM_CAPABILITIES_ALL_ROUTERS \ ((uint16_t) \ - (SD_LLDP_SYSTEM_CAPABILITIES_REPEATER| \ - SD_LLDP_SYSTEM_CAPABILITIES_BRIDGE| \ - SD_LLDP_SYSTEM_CAPABILITIES_WLAN_AP| \ - SD_LLDP_SYSTEM_CAPABILITIES_ROUTER| \ - SD_LLDP_SYSTEM_CAPABILITIES_DOCSIS| \ - SD_LLDP_SYSTEM_CAPABILITIES_CVLAN| \ - SD_LLDP_SYSTEM_CAPABILITIES_SVLAN| \ + (SD_LLDP_SYSTEM_CAPABILITIES_REPEATER | \ + SD_LLDP_SYSTEM_CAPABILITIES_BRIDGE | \ + SD_LLDP_SYSTEM_CAPABILITIES_WLAN_AP | \ + SD_LLDP_SYSTEM_CAPABILITIES_ROUTER | \ + SD_LLDP_SYSTEM_CAPABILITIES_DOCSIS | \ + SD_LLDP_SYSTEM_CAPABILITIES_CVLAN | \ + SD_LLDP_SYSTEM_CAPABILITIES_SVLAN | \ SD_LLDP_SYSTEM_CAPABILITIES_TPMR)) -#define SD_LLDP_OUI_802_1 (uint8_t[]) { 0x00, 0x80, 0xc2 } -#define SD_LLDP_OUI_802_3 (uint8_t[]) { 0x00, 0x12, 0x0f } +#define SD_LLDP_OUI_802_1 (const uint8_t[]) { 0x00, 0x80, 0xc2 } +#define SD_LLDP_OUI_802_3 (const uint8_t[]) { 0x00, 0x12, 0x0f } + +#define _SD_LLDP_OUI_IANA 0x00, 0x00, 0x5E +#define SD_LLDP_OUI_IANA (const uint8_t[]) { _SD_LLDP_OUI_IANA } -#define SD_LLDP_OUI_MUD (uint8_t[]) { 0x00, 0x00, 0x5E } -#define SD_LLDP_OUI_SUBTYPE_MUD_USAGE_DESCRIPTION 0x01 +#define SD_LLDP_OUI_IANA_SUBTYPE_MUD 0x01 +#define SD_LLDP_OUI_IANA_MUD \ + (const uint8_t[]) { _SD_LLDP_OUI_IANA, SD_LLDP_OUI_IANA_SUBTYPE_MUD } /* IEEE 802.1AB-2009 Annex E */ enum { @@ -119,80 +118,6 @@ enum { SD_LLDP_OUI_802_3_SUBTYPE_MAXIMUM_FRAME_SIZE = 4, }; -typedef struct sd_lldp sd_lldp; -typedef struct sd_lldp_neighbor sd_lldp_neighbor; - -typedef enum sd_lldp_event_t { - SD_LLDP_EVENT_ADDED, - SD_LLDP_EVENT_REMOVED, - SD_LLDP_EVENT_UPDATED, - SD_LLDP_EVENT_REFRESHED, - _SD_LLDP_EVENT_MAX, - _SD_LLDP_EVENT_INVALID = -EINVAL, - _SD_ENUM_FORCE_S64(LLDP_EVENT), -} sd_lldp_event_t; - -typedef void (*sd_lldp_callback_t)(sd_lldp *lldp, sd_lldp_event_t event, sd_lldp_neighbor *n, void *userdata); - -int sd_lldp_new(sd_lldp **ret); -sd_lldp* sd_lldp_ref(sd_lldp *lldp); -sd_lldp* sd_lldp_unref(sd_lldp *lldp); - -int sd_lldp_start(sd_lldp *lldp); -int sd_lldp_stop(sd_lldp *lldp); - -int sd_lldp_attach_event(sd_lldp *lldp, sd_event *event, int64_t priority); -int sd_lldp_detach_event(sd_lldp *lldp); -sd_event *sd_lldp_get_event(sd_lldp *lldp); - -int sd_lldp_set_callback(sd_lldp *lldp, sd_lldp_callback_t cb, void *userdata); -int sd_lldp_set_ifindex(sd_lldp *lldp, int ifindex); -int sd_lldp_set_ifname(sd_lldp *lldp, const char *ifname); -const char *sd_lldp_get_ifname(sd_lldp *lldp); - -/* Controls how much and what to store in the neighbors database */ -int sd_lldp_set_neighbors_max(sd_lldp *lldp, uint64_t n); -int sd_lldp_match_capabilities(sd_lldp *lldp, uint16_t mask); -int sd_lldp_set_filter_address(sd_lldp *lldp, const struct ether_addr *address); - -int sd_lldp_get_neighbors(sd_lldp *lldp, sd_lldp_neighbor ***neighbors); - -int sd_lldp_neighbor_from_raw(sd_lldp_neighbor **ret, const void *raw, size_t raw_size); -sd_lldp_neighbor *sd_lldp_neighbor_ref(sd_lldp_neighbor *n); -sd_lldp_neighbor *sd_lldp_neighbor_unref(sd_lldp_neighbor *n); - -/* Access to LLDP frame metadata */ -int sd_lldp_neighbor_get_source_address(sd_lldp_neighbor *n, struct ether_addr* address); -int sd_lldp_neighbor_get_destination_address(sd_lldp_neighbor *n, struct ether_addr* address); -int sd_lldp_neighbor_get_timestamp(sd_lldp_neighbor *n, clockid_t clock, uint64_t *ret); -int sd_lldp_neighbor_get_raw(sd_lldp_neighbor *n, const void **ret, size_t *size); - -/* High-level, direct, parsed out field access. These fields exist at most once, hence may be queried directly. */ -int sd_lldp_neighbor_get_chassis_id(sd_lldp_neighbor *n, uint8_t *type, const void **ret, size_t *size); -int sd_lldp_neighbor_get_chassis_id_as_string(sd_lldp_neighbor *n, const char **ret); -int sd_lldp_neighbor_get_port_id(sd_lldp_neighbor *n, uint8_t *type, const void **ret, size_t *size); -int sd_lldp_neighbor_get_port_id_as_string(sd_lldp_neighbor *n, const char **ret); -int sd_lldp_neighbor_get_ttl(sd_lldp_neighbor *n, uint16_t *ret_sec); -int sd_lldp_neighbor_get_system_name(sd_lldp_neighbor *n, const char **ret); -int sd_lldp_neighbor_get_system_description(sd_lldp_neighbor *n, const char **ret); -int sd_lldp_neighbor_get_port_description(sd_lldp_neighbor *n, const char **ret); -int sd_lldp_neighbor_get_mud_url(sd_lldp_neighbor *n, const char **ret); -int sd_lldp_neighbor_get_system_capabilities(sd_lldp_neighbor *n, uint16_t *ret); -int sd_lldp_neighbor_get_enabled_capabilities(sd_lldp_neighbor *n, uint16_t *ret); - -/* Low-level, iterative TLV access. This is for everything else, it iteratively goes through all available TLVs - * (including the ones covered with the calls above), and allows multiple TLVs for the same fields. */ -int sd_lldp_neighbor_tlv_rewind(sd_lldp_neighbor *n); -int sd_lldp_neighbor_tlv_next(sd_lldp_neighbor *n); -int sd_lldp_neighbor_tlv_get_type(sd_lldp_neighbor *n, uint8_t *type); -int sd_lldp_neighbor_tlv_is_type(sd_lldp_neighbor *n, uint8_t type); -int sd_lldp_neighbor_tlv_get_oui(sd_lldp_neighbor *n, uint8_t oui[_SD_ARRAY_STATIC 3], uint8_t *subtype); -int sd_lldp_neighbor_tlv_is_oui(sd_lldp_neighbor *n, const uint8_t oui[_SD_ARRAY_STATIC 3], uint8_t subtype); -int sd_lldp_neighbor_tlv_get_raw(sd_lldp_neighbor *n, const void **ret, size_t *size); - -_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_lldp, sd_lldp_unref); -_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_lldp_neighbor, sd_lldp_neighbor_unref); - _SD_END_DECLARATIONS; #endif diff --git a/src/libnm-systemd-core/src/systemd/sd-ndisc.h b/src/libnm-systemd-core/src/systemd/sd-ndisc.h index 6088def1..f45b2ad6 100644 --- a/src/libnm-systemd-core/src/systemd/sd-ndisc.h +++ b/src/libnm-systemd-core/src/systemd/sd-ndisc.h @@ -79,7 +79,7 @@ sd_event *sd_ndisc_get_event(sd_ndisc *nd); int sd_ndisc_set_callback(sd_ndisc *nd, sd_ndisc_callback_t cb, void *userdata); int sd_ndisc_set_ifindex(sd_ndisc *nd, int interface_index); int sd_ndisc_set_ifname(sd_ndisc *nd, const char *interface_name); -const char *sd_ndisc_get_ifname(sd_ndisc *nd); +int sd_ndisc_get_ifname(sd_ndisc *nd, const char **ret); int sd_ndisc_set_mac(sd_ndisc *nd, const struct ether_addr *mac_addr); int sd_ndisc_get_mtu(sd_ndisc *nd, uint32_t *ret); diff --git a/src/libnm-systemd-shared/meson.build b/src/libnm-systemd-shared/meson.build index 68daa20e..05c81faf 100644 --- a/src/libnm-systemd-shared/meson.build +++ b/src/libnm-systemd-shared/meson.build @@ -19,6 +19,7 @@ libnm_systemd_shared = static_library( 'src/basic/hexdecoct.c', 'src/basic/hostname-util.c', 'src/basic/in-addr-util.c', + 'src/basic/inotify-util.c', 'src/basic/io-util.c', 'src/basic/memory-util.c', 'src/basic/mempool.c', diff --git a/src/libnm-systemd-shared/sd-adapt-shared/chase-symlinks.h b/src/libnm-systemd-shared/sd-adapt-shared/chase-symlinks.h new file mode 100644 index 00000000..637892c2 --- /dev/null +++ b/src/libnm-systemd-shared/sd-adapt-shared/chase-symlinks.h @@ -0,0 +1,3 @@ +#pragma once + +/* dummy header */ diff --git a/src/libnm-systemd-shared/sd-adapt-shared/missing_ioprio.h b/src/libnm-systemd-shared/sd-adapt-shared/missing_ioprio.h new file mode 100644 index 00000000..637892c2 --- /dev/null +++ b/src/libnm-systemd-shared/sd-adapt-shared/missing_ioprio.h @@ -0,0 +1,3 @@ +#pragma once + +/* dummy header */ diff --git a/src/libnm-systemd-shared/sd-adapt-shared/nm-sd-adapt-shared.h b/src/libnm-systemd-shared/sd-adapt-shared/nm-sd-adapt-shared.h index 2f6188dc..586c3a7e 100644 --- a/src/libnm-systemd-shared/sd-adapt-shared/nm-sd-adapt-shared.h +++ b/src/libnm-systemd-shared/sd-adapt-shared/nm-sd-adapt-shared.h @@ -29,7 +29,7 @@ /*****************************************************************************/ #ifndef VALGRIND - #define VALGRIND 0 +#define VALGRIND 0 #endif #define ENABLE_DEBUG_HASHMAP 0 @@ -41,17 +41,17 @@ #if (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD - #include - #include - #include +#include +#include +#include - #define ENABLE_GSHADOW FALSE +#define ENABLE_GSHADOW FALSE - #define HAVE_SECCOMP 0 +#define HAVE_SECCOMP 0 - #define LOG_TRACE 0 +#define LOG_TRACE 0 - #define BUILD_MODE_DEVELOPER (NM_MORE_ASSERTS > 0) +#define BUILD_MODE_DEVELOPER (NM_MORE_ASSERTS > 0) /*****************************************************************************/ @@ -68,63 +68,63 @@ struct statx; static inline pid_t raw_getpid(void) { - #if defined(__alpha__) +#if defined(__alpha__) return (pid_t) syscall(__NR_getxpid); - #else +#else return (pid_t) syscall(__NR_getpid); - #endif +#endif } - #define gettid() nm_utils_gettid() - - /* we build with C11 and thus provides char32_t,char16_t. */ - #define HAVE_CHAR32_T 1 - #define HAVE_CHAR16_T 1 - - #if defined(HAVE_DECL_REALLOCARRAY) && HAVE_DECL_REALLOCARRAY == 1 - #define HAVE_REALLOCARRAY 1 - #else - #define HAVE_REALLOCARRAY 0 - #endif - - #if defined(HAVE_DECL_EXPLICIT_BZERO) && HAVE_DECL_EXPLICIT_BZERO == 1 - #define HAVE_EXPLICIT_BZERO 1 - #else - #define HAVE_EXPLICIT_BZERO 0 - #endif - - #if defined(HAVE_DECL_PIDFD_OPEN) && HAVE_DECL_PIDFD_OPEN == 1 - #define HAVE_PIDFD_OPEN 1 - #else - #define HAVE_PIDFD_OPEN 0 - #endif - - #if defined(HAVE_DECL_PIDFD_SEND_SIGNAL) && HAVE_DECL_PIDFD_SEND_SIGNAL == 1 - #define HAVE_PIDFD_SEND_SIGNAL 1 - #else - #define HAVE_PIDFD_SEND_SIGNAL 0 - #endif - - #if defined(HAVE_DECL_RT_SIGQUEUEINFO) && HAVE_DECL_RT_SIGQUEUEINFO == 1 - #define HAVE_RT_SIGQUEUEINFO 1 - #else - #define HAVE_RT_SIGQUEUEINFO 0 - #endif - - #ifndef ALTIFNAMSIZ - #define ALTIFNAMSIZ 128 - #endif - - #define HAVE_LINUX_TIME_TYPES_H 0 - - #ifndef __COMPAR_FN_T - #define __COMPAR_FN_T +#define gettid() nm_utils_gettid() + +/* we build with C11 and thus provides char32_t,char16_t. */ +#define HAVE_CHAR32_T 1 +#define HAVE_CHAR16_T 1 + +#if defined(HAVE_DECL_REALLOCARRAY) && HAVE_DECL_REALLOCARRAY == 1 +#define HAVE_REALLOCARRAY 1 +#else +#define HAVE_REALLOCARRAY 0 +#endif + +#if defined(HAVE_DECL_EXPLICIT_BZERO) && HAVE_DECL_EXPLICIT_BZERO == 1 +#define HAVE_EXPLICIT_BZERO 1 +#else +#define HAVE_EXPLICIT_BZERO 0 +#endif + +#if defined(HAVE_DECL_PIDFD_OPEN) && HAVE_DECL_PIDFD_OPEN == 1 +#define HAVE_PIDFD_OPEN 1 +#else +#define HAVE_PIDFD_OPEN 0 +#endif + +#if defined(HAVE_DECL_PIDFD_SEND_SIGNAL) && HAVE_DECL_PIDFD_SEND_SIGNAL == 1 +#define HAVE_PIDFD_SEND_SIGNAL 1 +#else +#define HAVE_PIDFD_SEND_SIGNAL 0 +#endif + +#if defined(HAVE_DECL_RT_SIGQUEUEINFO) && HAVE_DECL_RT_SIGQUEUEINFO == 1 +#define HAVE_RT_SIGQUEUEINFO 1 +#else +#define HAVE_RT_SIGQUEUEINFO 0 +#endif + +#ifndef ALTIFNAMSIZ +#define ALTIFNAMSIZ 128 +#endif + +#define HAVE_LINUX_TIME_TYPES_H 0 + +#ifndef __COMPAR_FN_T +#define __COMPAR_FN_T typedef int (*__compar_fn_t)(const void *, const void *); typedef __compar_fn_t comparison_fn_t; typedef int (*__compar_d_fn_t)(const void *, const void *, void *); - #endif +#endif - #ifndef __GLIBC__ +#ifndef __GLIBC__ static inline int __register_atfork(void (*prepare)(void), void (*parent)(void), @@ -133,7 +133,7 @@ __register_atfork(void (*prepare)(void), { return pthread_atfork(prepare, parent, child); } - #endif +#endif #endif /* (NETWORKMANAGER_COMPILATION) & NM_NETWORKMANAGER_COMPILATION_WITH_SYSTEMD */ diff --git a/src/libnm-systemd-shared/sd-adapt-shared/sync-util.h b/src/libnm-systemd-shared/sd-adapt-shared/sync-util.h new file mode 100644 index 00000000..637892c2 --- /dev/null +++ b/src/libnm-systemd-shared/sd-adapt-shared/sync-util.h @@ -0,0 +1,3 @@ +#pragma once + +/* dummy header */ diff --git a/src/libnm-systemd-shared/src/basic/alloc-util.h b/src/libnm-systemd-shared/src/basic/alloc-util.h index 99fbd3a8..e587fe79 100644 --- a/src/libnm-systemd-shared/src/basic/alloc-util.h +++ b/src/libnm-systemd-shared/src/basic/alloc-util.h @@ -44,16 +44,19 @@ typedef void (*free_func_t)(void *p); #define malloc0(n) (calloc(1, (n) ?: 1)) -static inline void *mfree(void *memory) { - free(memory); - return NULL; -} +#define mfree(memory) \ + ({ \ + free(memory); \ + (typeof(memory)) NULL; \ + }) #define free_and_replace(a, b) \ ({ \ - free(a); \ - (a) = (b); \ - (b) = NULL; \ + typeof(a)* _a = &(a); \ + typeof(b)* _b = &(b); \ + free(*_a); \ + (*_a) = (*_b); \ + (*_b) = NULL; \ 0; \ }) @@ -79,6 +82,13 @@ void* memdup_suffix0(const void *p, size_t l); /* We can't use _alloc_() here, s memcpy_safe(_q_, p, _l_); \ }) +static inline void unsetp(void *p) { + /* A trivial "destructor" that can be used in cases where we want to + * unset a pointer from a _cleanup_ function. */ + + *(void**)p = NULL; +} + static inline void freep(void *p) { *(void**)p = mfree(*(void**) p); } diff --git a/src/libnm-systemd-shared/src/basic/cgroup-util.h b/src/libnm-systemd-shared/src/basic/cgroup-util.h index ce2f4c65..90ccd2c0 100644 --- a/src/libnm-systemd-shared/src/basic/cgroup-util.h +++ b/src/libnm-systemd-shared/src/basic/cgroup-util.h @@ -32,6 +32,7 @@ typedef enum CGroupController { CGROUP_CONTROLLER_BPF_DEVICES, CGROUP_CONTROLLER_BPF_FOREIGN, CGROUP_CONTROLLER_BPF_SOCKET_BIND, + CGROUP_CONTROLLER_BPF_RESTRICT_NETWORK_INTERFACES, _CGROUP_CONTROLLER_MAX, _CGROUP_CONTROLLER_INVALID = -EINVAL, @@ -53,6 +54,7 @@ typedef enum CGroupMask { CGROUP_MASK_BPF_DEVICES = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_DEVICES), CGROUP_MASK_BPF_FOREIGN = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_FOREIGN), CGROUP_MASK_BPF_SOCKET_BIND = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_SOCKET_BIND), + CGROUP_MASK_BPF_RESTRICT_NETWORK_INTERFACES = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_RESTRICT_NETWORK_INTERFACES), /* All real cgroup v1 controllers */ CGROUP_MASK_V1 = CGROUP_MASK_CPU|CGROUP_MASK_CPUACCT|CGROUP_MASK_BLKIO|CGROUP_MASK_MEMORY|CGROUP_MASK_DEVICES|CGROUP_MASK_PIDS, @@ -61,7 +63,7 @@ typedef enum CGroupMask { CGROUP_MASK_V2 = CGROUP_MASK_CPU|CGROUP_MASK_CPUSET|CGROUP_MASK_IO|CGROUP_MASK_MEMORY|CGROUP_MASK_PIDS, /* All cgroup v2 BPF pseudo-controllers */ - CGROUP_MASK_BPF = CGROUP_MASK_BPF_FIREWALL|CGROUP_MASK_BPF_DEVICES|CGROUP_MASK_BPF_FOREIGN|CGROUP_MASK_BPF_SOCKET_BIND, + CGROUP_MASK_BPF = CGROUP_MASK_BPF_FIREWALL|CGROUP_MASK_BPF_DEVICES|CGROUP_MASK_BPF_FOREIGN|CGROUP_MASK_BPF_SOCKET_BIND|CGROUP_MASK_BPF_RESTRICT_NETWORK_INTERFACES, _CGROUP_MASK_ALL = CGROUP_CONTROLLER_TO_MASK(_CGROUP_CONTROLLER_MAX) - 1 } CGroupMask; @@ -172,6 +174,7 @@ typedef enum CGroupFlags { typedef int (*cg_kill_log_func_t)(pid_t pid, int sig, void *userdata); int cg_kill(const char *controller, const char *path, int sig, CGroupFlags flags, Set *s, cg_kill_log_func_t kill_log, void *userdata); +int cg_kill_kernel_sigkill(const char *controller, const char *path); int cg_kill_recursive(const char *controller, const char *path, int sig, CGroupFlags flags, Set *s, cg_kill_log_func_t kill_log, void *userdata); int cg_split_spec(const char *spec, char **ret_controller, char **ret_path); @@ -272,6 +275,7 @@ int cg_kernel_controllers(Set **controllers); bool cg_ns_supported(void); bool cg_freezer_supported(void); +bool cg_kill_supported(void); int cg_all_unified(void); int cg_hybrid_unified(void); diff --git a/src/libnm-systemd-shared/src/basic/env-util.c b/src/libnm-systemd-shared/src/basic/env-util.c index 849ee47e..431862f6 100644 --- a/src/libnm-systemd-shared/src/basic/env-util.c +++ b/src/libnm-systemd-shared/src/basic/env-util.c @@ -186,39 +186,51 @@ static int env_append(char **r, char ***k, char **a) { return 0; } -char **strv_env_merge(size_t n_lists, ...) { - _cleanup_strv_free_ char **ret = NULL; - size_t n = 0; - char **l, **k; +char** _strv_env_merge(char **first, ...) { + _cleanup_strv_free_ char **merged = NULL; + char **k; va_list ap; /* Merges an arbitrary number of environment sets */ - va_start(ap, n_lists); - for (size_t i = 0; i < n_lists; i++) { + size_t n = strv_length(first); + + va_start(ap, first); + for (;;) { + char **l; + l = va_arg(ap, char**); + if (l == POINTER_MAX) + break; + n += strv_length(l); } va_end(ap); - ret = new(char*, n+1); - if (!ret) + k = merged = new(char*, n + 1); + if (!merged) + return NULL; + merged[0] = NULL; + + if (env_append(merged, &k, first) < 0) return NULL; - *ret = NULL; - k = ret; + va_start(ap, first); + for (;;) { + char **l; - va_start(ap, n_lists); - for (size_t i = 0; i < n_lists; i++) { l = va_arg(ap, char**); - if (env_append(ret, &k, l) < 0) { + if (l == POINTER_MAX) + break; + + if (env_append(merged, &k, l) < 0) { va_end(ap); return NULL; } } va_end(ap); - return TAKE_PTR(ret); + return TAKE_PTR(merged); } static bool env_match(const char *t, const char *pattern) { @@ -412,6 +424,32 @@ int strv_env_replace_strdup(char ***l, const char *assignment) { return strv_env_replace_consume(l, p); } +int strv_env_replace_strdup_passthrough(char ***l, const char *assignment) { + /* Like strv_env_replace_strdup(), but pulls the variable from the environment of + * the calling program, if a variable name without value is specified. + */ + char *p; + + if (strchr(assignment, '=')) { + if (!env_assignment_is_valid(assignment)) + return -EINVAL; + + p = strdup(assignment); + } else { + if (!env_name_is_valid(assignment)) + return -EINVAL; + + /* If we can't find the variable in our environment, we will use + * the empty string. This way "passthrough" is equivalent to passing + * --setenv=FOO=$FOO in the shell. */ + p = strjoin(assignment, "=", secure_getenv(assignment)); + } + if (!p) + return -ENOMEM; + + return strv_env_replace_consume(l, p); +} + int strv_env_assign(char ***l, const char *key, const char *value) { if (!env_name_is_valid(key)) return -EINVAL; @@ -580,6 +618,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) { word = e+1; state = WORD; + nest--; } else if (*e == ':') { if (flags & REPLACE_ENV_ALLOW_EXTENDED) { len = e - word - 2; @@ -837,4 +876,21 @@ int getenv_path_list(const char *name, char ***ret_paths) { *ret_paths = TAKE_PTR(l); return 1; } + +int unsetenv_erase(const char *name) { + char *p; + + assert(name); + + p = getenv(name); + if (!p) + return 0; + + string_erase(p); + + if (unsetenv(name) < 0) + return -errno; + + return 1; +} #endif /* NM_IGNORED */ diff --git a/src/libnm-systemd-shared/src/basic/env-util.h b/src/libnm-systemd-shared/src/basic/env-util.h index 1fbe7e42..38bfc8a3 100644 --- a/src/libnm-systemd-shared/src/basic/env-util.h +++ b/src/libnm-systemd-shared/src/basic/env-util.h @@ -39,13 +39,15 @@ char **strv_env_clean_with_callback(char **l, void (*invalid_callback)(const cha bool strv_env_name_is_valid(char **l); bool strv_env_name_or_assignment_is_valid(char **l); -char **strv_env_merge(size_t n_lists, ...); +char** _strv_env_merge(char **first, ...); +#define strv_env_merge(first, ...) _strv_env_merge(first, __VA_ARGS__, POINTER_MAX) char **strv_env_delete(char **x, size_t n_lists, ...); /* New copy */ char **strv_env_unset(char **l, const char *p); /* In place ... */ char **strv_env_unset_many(char **l, ...) _sentinel_; int strv_env_replace_consume(char ***l, char *p); /* In place ... */ int strv_env_replace_strdup(char ***l, const char *assignment); +int strv_env_replace_strdup_passthrough(char ***l, const char *assignment); int strv_env_assign(char ***l, const char *key, const char *value); char *strv_env_get_n(char **l, const char *name, size_t k, unsigned flags) _pure_; @@ -66,3 +68,5 @@ int setenv_systemd_exec_pid(bool update_only); /* Parses and does sanity checks on an environment variable containing * PATH-like colon-separated absolute paths */ int getenv_path_list(const char *name, char ***ret_paths); + +int unsetenv_erase(const char *name); diff --git a/src/libnm-systemd-shared/src/basic/escape.c b/src/libnm-systemd-shared/src/basic/escape.c index 6a138020..93288563 100644 --- a/src/libnm-systemd-shared/src/basic/escape.c +++ b/src/libnm-systemd-shared/src/basic/escape.c @@ -10,6 +10,7 @@ #include "escape.h" #include "hexdecoct.h" #include "macro.h" +#include "strv.h" #include "utf8.h" int cescape_char(char c, char *buf) { @@ -291,10 +292,12 @@ int cunescape_one(const char *p, size_t length, char32_t *ret, bool *eight_bit, } #if 0 /* NM_IGNORED */ -int cunescape_length_with_prefix(const char *s, size_t length, const char *prefix, UnescapeFlags flags, char **ret) { - char *r, *t; +ssize_t cunescape_length_with_prefix(const char *s, size_t length, const char *prefix, UnescapeFlags flags, char **ret) { + _cleanup_free_ char *ans = NULL; + char *t; const char *f; size_t pl; + int r; assert(s); assert(ret); @@ -303,18 +306,17 @@ int cunescape_length_with_prefix(const char *s, size_t length, const char *prefi pl = strlen_ptr(prefix); - r = new(char, pl+length+1); - if (!r) + ans = new(char, pl+length+1); + if (!ans) return -ENOMEM; if (prefix) - memcpy(r, prefix, pl); + memcpy(ans, prefix, pl); - for (f = s, t = r + pl; f < s + length; f++) { + for (f = s, t = ans + pl; f < s + length; f++) { size_t remaining; bool eight_bit = false; char32_t u; - int k; remaining = s + length - f; assert(remaining > 0); @@ -332,23 +334,21 @@ int cunescape_length_with_prefix(const char *s, size_t length, const char *prefi continue; } - free(r); return -EINVAL; } - k = cunescape_one(f + 1, remaining - 1, &u, &eight_bit, flags & UNESCAPE_ACCEPT_NUL); - if (k < 0) { + r = cunescape_one(f + 1, remaining - 1, &u, &eight_bit, flags & UNESCAPE_ACCEPT_NUL); + if (r < 0) { if (flags & UNESCAPE_RELAX) { /* Invalid escape code, let's take it literal then */ *(t++) = '\\'; continue; } - free(r); - return k; + return r; } - f += k; + f += r; if (eight_bit) /* One byte? Set directly as specified */ *(t++) = u; @@ -359,8 +359,9 @@ int cunescape_length_with_prefix(const char *s, size_t length, const char *prefi *t = 0; - *ret = r; - return t - r; + assert(t >= ans); /* Let static analyzers know that the answer is non-negative. */ + *ret = TAKE_PTR(ans); + return t - *ret; } char* xescape_full(const char *s, const char *bad, size_t console_width, XEscapeFlags flags) { @@ -445,7 +446,6 @@ char* escape_non_printable_full(const char *str, size_t console_width, XEscapeFl console_width, FLAGS_SET(flags, XESCAPE_FORCE_ELLIPSIS)); } -#endif /* NM_IGNORED */ char* octescape(const char *s, size_t len) { char *r, *t; @@ -546,3 +546,24 @@ char* shell_maybe_quote(const char *s, ShellEscapeFlags flags) { return str_realloc(buf); } + +char* quote_command_line(char **argv) { + _cleanup_free_ char *result = NULL; + + assert(argv); + + char **a; + STRV_FOREACH(a, argv) { + _cleanup_free_ char *t = NULL; + + t = shell_maybe_quote(*a, SHELL_ESCAPE_EMPTY); + if (!t) + return NULL; + + if (!strextend_with_separator(&result, " ", t)) + return NULL; + } + + return TAKE_PTR(result); +} +#endif /* NM_IGNORED */ diff --git a/src/libnm-systemd-shared/src/basic/escape.h b/src/libnm-systemd-shared/src/basic/escape.h index 907b572b..d490510d 100644 --- a/src/libnm-systemd-shared/src/basic/escape.h +++ b/src/libnm-systemd-shared/src/basic/escape.h @@ -45,14 +45,15 @@ char* cescape(const char *s); char* cescape_length(const char *s, size_t n); int cescape_char(char c, char *buf); -int cunescape_length_with_prefix(const char *s, size_t length, const char *prefix, UnescapeFlags flags, char **ret); -static inline int cunescape_length(const char *s, size_t length, UnescapeFlags flags, char **ret) { +int cunescape_one(const char *p, size_t length, char32_t *ret, bool *eight_bit, bool accept_nul); + +ssize_t cunescape_length_with_prefix(const char *s, size_t length, const char *prefix, UnescapeFlags flags, char **ret); +static inline ssize_t cunescape_length(const char *s, size_t length, UnescapeFlags flags, char **ret) { return cunescape_length_with_prefix(s, length, NULL, flags, ret); } -static inline int cunescape(const char *s, UnescapeFlags flags, char **ret) { +static inline ssize_t cunescape(const char *s, UnescapeFlags flags, char **ret) { return cunescape_length(s, strlen(s), flags, ret); } -int cunescape_one(const char *p, size_t length, char32_t *ret, bool *eight_bit, bool accept_nul); typedef enum XEscapeFlags { XESCAPE_8_BIT = 1 << 0, @@ -68,3 +69,4 @@ char* escape_non_printable_full(const char *str, size_t console_width, XEscapeFl char* shell_escape(const char *s, const char *bad); char* shell_maybe_quote(const char *s, ShellEscapeFlags flags); +char* quote_command_line(char **argv); diff --git a/src/libnm-systemd-shared/src/basic/ether-addr-util.c b/src/libnm-systemd-shared/src/basic/ether-addr-util.c index f60e1042..c73dcff1 100644 --- a/src/libnm-systemd-shared/src/basic/ether-addr-util.c +++ b/src/libnm-systemd-shared/src/basic/ether-addr-util.c @@ -12,13 +12,13 @@ #include "macro.h" #include "string-util.h" -char* hw_addr_to_string(const hw_addr_data *addr, char buffer[HW_ADDR_TO_STRING_MAX]) { +char* hw_addr_to_string(const struct hw_addr_data *addr, char buffer[HW_ADDR_TO_STRING_MAX]) { assert(addr); assert(buffer); assert(addr->length <= HW_ADDR_MAX_SIZE); for (size_t i = 0; i < addr->length; i++) { - sprintf(&buffer[3*i], "%02"PRIx8, addr->addr.bytes[i]); + sprintf(&buffer[3*i], "%02"PRIx8, addr->bytes[i]); if (i < addr->length - 1) buffer[3*i + 2] = ':'; } @@ -26,6 +26,29 @@ char* hw_addr_to_string(const hw_addr_data *addr, char buffer[HW_ADDR_TO_STRING_ return buffer; } +int hw_addr_compare(const struct hw_addr_data *a, const struct hw_addr_data *b) { + int r; + + assert(a); + assert(b); + + r = CMP(a->length, b->length); + if (r != 0) + return r; + + return memcmp(a->bytes, b->bytes, a->length); +} + +static void hw_addr_hash_func(const struct hw_addr_data *p, struct siphash *state) { + assert(p); + assert(state); + + siphash24_compress(&p->length, sizeof(p->length), state); + siphash24_compress(p->bytes, p->length, state); +} + +DEFINE_HASH_OPS(hw_addr_hash_ops, struct hw_addr_data, hw_addr_hash_func, hw_addr_compare); + char* ether_addr_to_string(const struct ether_addr *addr, char buffer[ETHER_ADDR_TO_STRING_MAX]) { assert(addr); assert(buffer); diff --git a/src/libnm-systemd-shared/src/basic/ether-addr-util.h b/src/libnm-systemd-shared/src/basic/ether-addr-util.h index 712c9277..794fc55b 100644 --- a/src/libnm-systemd-shared/src/basic/ether-addr-util.h +++ b/src/libnm-systemd-shared/src/basic/ether-addr-util.h @@ -11,24 +11,34 @@ * defines a macro of the same name with a much lower size. */ #define HW_ADDR_MAX_SIZE 32 -union hw_addr_union { - struct ether_addr ether; - uint8_t infiniband[INFINIBAND_ALEN]; - uint8_t bytes[HW_ADDR_MAX_SIZE]; -}; - -typedef struct hw_addr_data { - union hw_addr_union addr; +struct hw_addr_data { size_t length; -} hw_addr_data; + union { + struct ether_addr ether; + uint8_t infiniband[INFINIBAND_ALEN]; + uint8_t bytes[HW_ADDR_MAX_SIZE]; + }; +}; #define HW_ADDR_TO_STRING_MAX (3*HW_ADDR_MAX_SIZE) -char* hw_addr_to_string(const hw_addr_data *addr, char buffer[HW_ADDR_TO_STRING_MAX]); +char* hw_addr_to_string(const struct hw_addr_data *addr, char buffer[HW_ADDR_TO_STRING_MAX]); -/* Use only as function argument, never stand-alone! */ +/* Note: the lifetime of the compound literal is the immediately surrounding block, + * see C11 §6.5.2.5, and + * https://stackoverflow.com/questions/34880638/compound-literal-lifetime-and-if-blocks */ #define HW_ADDR_TO_STR(hw_addr) hw_addr_to_string((hw_addr), (char[HW_ADDR_TO_STRING_MAX]){}) -#define HW_ADDR_NULL ((const hw_addr_data){}) +#define HW_ADDR_NULL ((const struct hw_addr_data){}) + +int hw_addr_compare(const struct hw_addr_data *a, const struct hw_addr_data *b); +static inline bool hw_addr_equal(const struct hw_addr_data *a, const struct hw_addr_data *b) { + return hw_addr_compare(a, b) == 0; +} +static inline bool hw_addr_is_null(const struct hw_addr_data *addr) { + return hw_addr_equal(addr, &HW_ADDR_NULL); +} + +extern const struct hash_ops hw_addr_hash_ops; #define ETHER_ADDR_FORMAT_STR "%02X%02X%02X%02X%02X%02X" #define ETHER_ADDR_FORMAT_VAL(x) (x).ether_addr_octet[0], (x).ether_addr_octet[1], (x).ether_addr_octet[2], (x).ether_addr_octet[3], (x).ether_addr_octet[4], (x).ether_addr_octet[5] @@ -36,6 +46,8 @@ char* hw_addr_to_string(const hw_addr_data *addr, char buffer[HW_ADDR_TO_STRING_ #define ETHER_ADDR_TO_STRING_MAX (3*6) char* ether_addr_to_string(const struct ether_addr *addr, char buffer[ETHER_ADDR_TO_STRING_MAX]); int ether_addr_to_string_alloc(const struct ether_addr *addr, char **ret); +/* Use only as function argument, never stand-alone! */ +#define ETHER_ADDR_TO_STR(addr) ether_addr_to_string((addr), (char[ETHER_ADDR_TO_STRING_MAX]){}) int ether_addr_compare(const struct ether_addr *a, const struct ether_addr *b); static inline bool ether_addr_equal(const struct ether_addr *a, const struct ether_addr *b) { diff --git a/src/libnm-systemd-shared/src/basic/extract-word.c b/src/libnm-systemd-shared/src/basic/extract-word.c index b339eae2..6781fb55 100644 --- a/src/libnm-systemd-shared/src/basic/extract-word.c +++ b/src/libnm-systemd-shared/src/basic/extract-word.c @@ -29,6 +29,7 @@ int extract_first_word(const char **p, char **ret, const char *separators, Extra assert(p); assert(ret); + assert(!FLAGS_SET(flags, EXTRACT_KEEP_QUOTE | EXTRACT_UNQUOTE)); /* Bail early if called after last value or with no input */ if (!*p) @@ -52,7 +53,8 @@ int extract_first_word(const char **p, char **ret, const char *separators, Extra goto finish_force_terminate; else if (strchr(separators, c)) { if (flags & EXTRACT_DONT_COALESCE_SEPARATORS) { - (*p)++; + if (!(flags & EXTRACT_RETAIN_SEPARATORS)) + (*p)++; goto finish_force_next; } } else { @@ -125,48 +127,58 @@ int extract_first_word(const char **p, char **ret, const char *separators, Extra return -EINVAL; } else if (c == quote) { /* found the end quote */ quote = 0; - break; + if (flags & EXTRACT_UNQUOTE) + break; } else if (c == '\\' && !(flags & EXTRACT_RETAIN_ESCAPE)) { backslash = true; break; - } else { - if (!GREEDY_REALLOC(s, sz+2)) - return -ENOMEM; - - s[sz++] = c; } + + if (!GREEDY_REALLOC(s, sz+2)) + return -ENOMEM; + + s[sz++] = c; + + if (quote == 0) + break; } } else { for (;; (*p)++, c = **p) { if (c == 0) goto finish_force_terminate; - else if (IN_SET(c, '\'', '"') && (flags & EXTRACT_UNQUOTE)) { + else if (IN_SET(c, '\'', '"') && (flags & (EXTRACT_KEEP_QUOTE | EXTRACT_UNQUOTE))) { quote = c; - break; + if (flags & EXTRACT_UNQUOTE) + break; } else if (c == '\\' && !(flags & EXTRACT_RETAIN_ESCAPE)) { backslash = true; break; } else if (strchr(separators, c)) { if (flags & EXTRACT_DONT_COALESCE_SEPARATORS) { - (*p)++; + if (!(flags & EXTRACT_RETAIN_SEPARATORS)) + (*p)++; goto finish_force_next; } - /* Skip additional coalesced separators. */ - for (;; (*p)++, c = **p) { - if (c == 0) - goto finish_force_terminate; - if (!strchr(separators, c)) - break; - } + if (!(flags & EXTRACT_RETAIN_SEPARATORS)) + /* Skip additional coalesced separators. */ + for (;; (*p)++, c = **p) { + if (c == 0) + goto finish_force_terminate; + if (!strchr(separators, c)) + break; + } goto finish; - } else { - if (!GREEDY_REALLOC(s, sz+2)) - return -ENOMEM; - - s[sz++] = c; } + + if (!GREEDY_REALLOC(s, sz+2)) + return -ENOMEM; + + s[sz++] = c; + + if (quote != 0) + break; } } } diff --git a/src/libnm-systemd-shared/src/basic/extract-word.h b/src/libnm-systemd-shared/src/basic/extract-word.h index 0e9e77e9..c82ad761 100644 --- a/src/libnm-systemd-shared/src/basic/extract-word.h +++ b/src/libnm-systemd-shared/src/basic/extract-word.h @@ -8,9 +8,11 @@ typedef enum ExtractFlags { EXTRACT_CUNESCAPE = 1 << 1, /* Unescape known escape sequences. */ EXTRACT_UNESCAPE_RELAX = 1 << 2, /* Allow and keep unknown escape sequences, allow and keep trailing backslash. */ EXTRACT_UNESCAPE_SEPARATORS = 1 << 3, /* Unescape separators (those specified, or whitespace by default). */ - EXTRACT_UNQUOTE = 1 << 4, /* Remove quoting with "" and ''. */ - EXTRACT_DONT_COALESCE_SEPARATORS = 1 << 5, /* Don't treat multiple adjacent separators as one */ - EXTRACT_RETAIN_ESCAPE = 1 << 6, /* Treat escape character '\' as any other character without special meaning */ + EXTRACT_KEEP_QUOTE = 1 << 4, /* Ignore separators in quoting with "" and ''. */ + EXTRACT_UNQUOTE = 1 << 5, /* Ignore separators in quoting with "" and '', and remove the quotes. */ + EXTRACT_DONT_COALESCE_SEPARATORS = 1 << 6, /* Don't treat multiple adjacent separators as one */ + EXTRACT_RETAIN_ESCAPE = 1 << 7, /* Treat escape character '\' as any other character without special meaning */ + EXTRACT_RETAIN_SEPARATORS = 1 << 8, /* Do not advance the original string pointer past the separator(s) */ /* Note that if no flags are specified, escaped escape characters will be silently stripped. */ } ExtractFlags; diff --git a/src/libnm-systemd-shared/src/basic/fd-util.c b/src/libnm-systemd-shared/src/basic/fd-util.c index 670b72ff..ee2a4caf 100644 --- a/src/libnm-systemd-shared/src/basic/fd-util.c +++ b/src/libnm-systemd-shared/src/basic/fd-util.c @@ -4,19 +4,20 @@ #include #include +#include +#include +#include #include #include #include #include "alloc-util.h" -#include "copy.h" #include "dirent-util.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" #include "io-util.h" #include "macro.h" -#include "memfd-util.h" #include "missing_fcntl.h" #include "missing_syscall.h" #include "parse-util.h" @@ -210,10 +211,9 @@ static int get_max_fd(void) { return (int) (m - 1); } -int close_all_fds(const int except[], size_t n_except) { +int close_all_fds_full(int except[], size_t n_except, bool allow_alloc) { static bool have_close_range = true; /* Assume we live in the future */ _cleanup_closedir_ DIR *d = NULL; - struct dirent *de; int r = 0; assert(n_except == 0 || except); @@ -229,129 +229,104 @@ int close_all_fds(const int except[], size_t n_except) { /* Close everything. Yay! */ if (close_range(3, -1, 0) >= 0) - return 1; + return 0; - if (!ERRNO_IS_NOT_SUPPORTED(errno) && !ERRNO_IS_PRIVILEGE(errno)) + if (ERRNO_IS_NOT_SUPPORTED(errno) || ERRNO_IS_PRIVILEGE(errno)) + have_close_range = false; + else return -errno; - have_close_range = false; } else { - _cleanup_free_ int *sorted_malloc = NULL; - size_t n_sorted; - int *sorted; - - assert(n_except < SIZE_MAX); - n_sorted = n_except + 1; - - if (n_sorted > 64) /* Use heap for large numbers of fds, stack otherwise */ - sorted = sorted_malloc = new(int, n_sorted); - else - sorted = newa(int, n_sorted); - - if (sorted) { - int c = 0; - - memcpy(sorted, except, n_except * sizeof(int)); + typesafe_qsort(except, n_except, cmp_int); - /* Let's add fd 2 to the list of fds, to simplify the loop below, as this - * allows us to cover the head of the array the same way as the body */ - sorted[n_sorted-1] = 2; + for (size_t i = 0; i < n_except; i++) { + int start = i == 0 ? 2 : MAX(except[i-1], 2); /* The first three fds shall always remain open */ + int end = MAX(except[i], 2); - typesafe_qsort(sorted, n_sorted, cmp_int); + assert(end >= start); - for (size_t i = 0; i < n_sorted-1; i++) { - int start, end; - - start = MAX(sorted[i], 2); /* The first three fds shall always remain open */ - end = MAX(sorted[i+1], 2); - - assert(end >= start); - - if (end - start <= 1) - continue; - - /* Close everything between the start and end fds (both of which shall stay open) */ - if (close_range(start + 1, end - 1, 0) < 0) { - if (!ERRNO_IS_NOT_SUPPORTED(errno) && !ERRNO_IS_PRIVILEGE(errno)) - return -errno; + if (end - start <= 1) + continue; + /* Close everything between the start and end fds (both of which shall stay open) */ + if (close_range(start + 1, end - 1, 0) < 0) { + if (ERRNO_IS_NOT_SUPPORTED(errno) || ERRNO_IS_PRIVILEGE(errno)) have_close_range = false; - break; - } - - c += end - start - 1; + else + return -errno; + goto opendir_fallback; } + } - if (have_close_range) { - /* The loop succeeded. Let's now close everything beyond the end */ + /* The loop succeeded. Let's now close everything beyond the end */ - if (sorted[n_sorted-1] >= INT_MAX) /* Dont let the addition below overflow */ - return c; + if (except[n_except-1] >= INT_MAX) /* Don't let the addition below overflow */ + return 0; - if (close_range(sorted[n_sorted-1] + 1, -1, 0) >= 0) - return c + 1; + int start = MAX(except[n_except-1], 2); - if (!ERRNO_IS_NOT_SUPPORTED(errno) && !ERRNO_IS_PRIVILEGE(errno)) - return -errno; + if (close_range(start + 1, -1, 0) >= 0) + return 0; - have_close_range = false; - } - } + if (ERRNO_IS_NOT_SUPPORTED(errno) || ERRNO_IS_PRIVILEGE(errno)) + have_close_range = false; + else + return -errno; } - - /* Fallback on OOM or if close_range() is not supported */ } - d = opendir("/proc/self/fd"); - if (!d) { - int fd, max_fd; + /* Fallback for when close_range() is not supported */ + opendir_fallback: + d = allow_alloc ? opendir("/proc/self/fd") : NULL; + if (d) { + struct dirent *de; - /* When /proc isn't available (for example in chroots) the fallback is brute forcing through - * the fd table */ + FOREACH_DIRENT(de, d, return -errno) { + int fd = -1, q; - max_fd = get_max_fd(); - if (max_fd < 0) - return max_fd; + if (safe_atoi(de->d_name, &fd) < 0) + /* Let's better ignore this, just in case */ + continue; - /* Refuse to do the loop over more too many elements. It's better to fail immediately than to - * spin the CPU for a long time. */ - if (max_fd > MAX_FD_LOOP_LIMIT) - return log_debug_errno(SYNTHETIC_ERRNO(EPERM), - "/proc/self/fd is inaccessible. Refusing to loop over %d potential fds.", - max_fd); + if (fd < 3) + continue; - for (fd = 3; fd >= 0; fd = fd < max_fd ? fd + 1 : -1) { - int q; + if (fd == dirfd(d)) + continue; if (fd_in_set(fd, except, n_except)) continue; q = close_nointr(fd); - if (q < 0 && q != -EBADF && r >= 0) + if (q < 0 && q != -EBADF && r >= 0) /* Valgrind has its own FD and doesn't want to have it closed */ r = q; } return r; } - FOREACH_DIRENT(de, d, return -errno) { - int fd = -1, q; + /* Fallback for when /proc isn't available (for example in chroots) or when we cannot allocate by + * brute-forcing through the file descriptor table. */ - if (safe_atoi(de->d_name, &fd) < 0) - /* Let's better ignore this, just in case */ - continue; + int max_fd = get_max_fd(); + if (max_fd < 0) + return max_fd; - if (fd < 3) - continue; + /* Refuse to do the loop over more too many elements. It's better to fail immediately than to + * spin the CPU for a long time. */ + if (max_fd > MAX_FD_LOOP_LIMIT) + return log_debug_errno(SYNTHETIC_ERRNO(EPERM), + "/proc/self/fd is inaccessible. Refusing to loop over %d potential fds.", + max_fd); - if (fd == dirfd(d)) - continue; + for (int fd = 3; fd >= 0; fd = fd < max_fd ? fd + 1 : -1) { + int q; if (fd_in_set(fd, except, n_except)) continue; q = close_nointr(fd); - if (q < 0 && q != -EBADF && r >= 0) /* Valgrind has its own FD and doesn't want to have it closed */ + if (q < 0 && q != -EBADF && r >= 0) r = q; } @@ -463,11 +438,9 @@ bool fdname_is_valid(const char *s) { #if 0 /* NM_IGNORED */ int fd_get_path(int fd, char **ret) { - char procfs_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; int r; - xsprintf(procfs_path, "/proc/self/fd/%i", fd); - r = readlink_malloc(procfs_path, ret); + r = readlink_malloc(FORMAT_PROC_FD_PATH(fd), ret); if (r == -ENOENT) { /* ENOENT can mean two things: that the fd does not exist or that /proc is not mounted. Let's make * things debuggable and distinguish the two. */ @@ -524,343 +497,6 @@ int move_fd(int from, int to, int cloexec) { return to; } - -int acquire_data_fd(const void *data, size_t size, unsigned flags) { - - _cleanup_close_pair_ int pipefds[2] = { -1, -1 }; - char pattern[] = "/dev/shm/data-fd-XXXXXX"; - _cleanup_close_ int fd = -1; - int isz = 0, r; - ssize_t n; - off_t f; - - assert(data || size == 0); - - /* Acquire a read-only file descriptor that when read from returns the specified data. This is much more - * complex than I wish it was. But here's why: - * - * a) First we try to use memfds. They are the best option, as we can seal them nicely to make them - * read-only. Unfortunately they require kernel 3.17, and – at the time of writing – we still support 3.14. - * - * b) Then, we try classic pipes. They are the second best options, as we can close the writing side, retaining - * a nicely read-only fd in the reading side. However, they are by default quite small, and unprivileged - * clients can only bump their size to a system-wide limit, which might be quite low. - * - * c) Then, we try an O_TMPFILE file in /dev/shm (that dir is the only suitable one known to exist from - * earliest boot on). To make it read-only we open the fd a second time with O_RDONLY via - * /proc/self/. Unfortunately O_TMPFILE is not available on older kernels on tmpfs. - * - * d) Finally, we try creating a regular file in /dev/shm, which we then delete. - * - * It sucks a bit that depending on the situation we return very different objects here, but that's Linux I - * figure. */ - - if (size == 0 && ((flags & ACQUIRE_NO_DEV_NULL) == 0)) { - /* As a special case, return /dev/null if we have been called for an empty data block */ - r = open("/dev/null", O_RDONLY|O_CLOEXEC|O_NOCTTY); - if (r < 0) - return -errno; - - return r; - } - - if ((flags & ACQUIRE_NO_MEMFD) == 0) { - fd = memfd_new("data-fd"); - if (fd < 0) - goto try_pipe; - - n = write(fd, data, size); - if (n < 0) - return -errno; - if ((size_t) n != size) - return -EIO; - - f = lseek(fd, 0, SEEK_SET); - if (f != 0) - return -errno; - - r = memfd_set_sealed(fd); - if (r < 0) - return r; - - return TAKE_FD(fd); - } - -try_pipe: - if ((flags & ACQUIRE_NO_PIPE) == 0) { - if (pipe2(pipefds, O_CLOEXEC|O_NONBLOCK) < 0) - return -errno; - - isz = fcntl(pipefds[1], F_GETPIPE_SZ, 0); - if (isz < 0) - return -errno; - - if ((size_t) isz < size) { - isz = (int) size; - if (isz < 0 || (size_t) isz != size) - return -E2BIG; - - /* Try to bump the pipe size */ - (void) fcntl(pipefds[1], F_SETPIPE_SZ, isz); - - /* See if that worked */ - isz = fcntl(pipefds[1], F_GETPIPE_SZ, 0); - if (isz < 0) - return -errno; - - if ((size_t) isz < size) - goto try_dev_shm; - } - - n = write(pipefds[1], data, size); - if (n < 0) - return -errno; - if ((size_t) n != size) - return -EIO; - - (void) fd_nonblock(pipefds[0], false); - - return TAKE_FD(pipefds[0]); - } - -try_dev_shm: - if ((flags & ACQUIRE_NO_TMPFILE) == 0) { - fd = open("/dev/shm", O_RDWR|O_TMPFILE|O_CLOEXEC, 0500); - if (fd < 0) - goto try_dev_shm_without_o_tmpfile; - - n = write(fd, data, size); - if (n < 0) - return -errno; - if ((size_t) n != size) - return -EIO; - - /* Let's reopen the thing, in order to get an O_RDONLY fd for the original O_RDWR one */ - return fd_reopen(fd, O_RDONLY|O_CLOEXEC); - } - -try_dev_shm_without_o_tmpfile: - if ((flags & ACQUIRE_NO_REGULAR) == 0) { - fd = mkostemp_safe(pattern); - if (fd < 0) - return fd; - - n = write(fd, data, size); - if (n < 0) { - r = -errno; - goto unlink_and_return; - } - if ((size_t) n != size) { - r = -EIO; - goto unlink_and_return; - } - - /* Let's reopen the thing, in order to get an O_RDONLY fd for the original O_RDWR one */ - r = open(pattern, O_RDONLY|O_CLOEXEC); - if (r < 0) - r = -errno; - - unlink_and_return: - (void) unlink(pattern); - return r; - } - - return -EOPNOTSUPP; -} - -/* When the data is smaller or equal to 64K, try to place the copy in a memfd/pipe */ -#define DATA_FD_MEMORY_LIMIT (64U*1024U) - -/* If memfd/pipe didn't work out, then let's use a file in /tmp up to a size of 1M. If it's large than that use /var/tmp instead. */ -#define DATA_FD_TMP_LIMIT (1024U*1024U) - -int fd_duplicate_data_fd(int fd) { - - _cleanup_close_ int copy_fd = -1, tmp_fd = -1; - _cleanup_free_ void *remains = NULL; - size_t remains_size = 0; - const char *td; - struct stat st; - int r; - - /* Creates a 'data' fd from the specified source fd, containing all the same data in a read-only fashion, but - * independent of it (i.e. the source fd can be closed and unmounted after this call succeeded). Tries to be - * somewhat smart about where to place the data. In the best case uses a memfd(). If memfd() are not supported - * uses a pipe instead. For larger data will use an unlinked file in /tmp, and for even larger data one in - * /var/tmp. */ - - if (fstat(fd, &st) < 0) - return -errno; - - /* For now, let's only accept regular files, sockets, pipes and char devices */ - if (S_ISDIR(st.st_mode)) - return -EISDIR; - if (S_ISLNK(st.st_mode)) - return -ELOOP; - if (!S_ISREG(st.st_mode) && !S_ISSOCK(st.st_mode) && !S_ISFIFO(st.st_mode) && !S_ISCHR(st.st_mode)) - return -EBADFD; - - /* If we have reason to believe the data is bounded in size, then let's use memfds or pipes as backing fd. Note - * that we use the reported regular file size only as a hint, given that there are plenty special files in - * /proc and /sys which report a zero file size but can be read from. */ - - if (!S_ISREG(st.st_mode) || st.st_size < DATA_FD_MEMORY_LIMIT) { - - /* Try a memfd first */ - copy_fd = memfd_new("data-fd"); - if (copy_fd >= 0) { - off_t f; - - r = copy_bytes(fd, copy_fd, DATA_FD_MEMORY_LIMIT, 0); - if (r < 0) - return r; - - f = lseek(copy_fd, 0, SEEK_SET); - if (f != 0) - return -errno; - - if (r == 0) { - /* Did it fit into the limit? If so, we are done. */ - r = memfd_set_sealed(copy_fd); - if (r < 0) - return r; - - return TAKE_FD(copy_fd); - } - - /* Hmm, pity, this didn't fit. Let's fall back to /tmp then, see below */ - - } else { - _cleanup_(close_pairp) int pipefds[2] = { -1, -1 }; - int isz; - - /* If memfds aren't available, use a pipe. Set O_NONBLOCK so that we will get EAGAIN rather - * then block indefinitely when we hit the pipe size limit */ - - if (pipe2(pipefds, O_CLOEXEC|O_NONBLOCK) < 0) - return -errno; - - isz = fcntl(pipefds[1], F_GETPIPE_SZ, 0); - if (isz < 0) - return -errno; - - /* Try to enlarge the pipe size if necessary */ - if ((size_t) isz < DATA_FD_MEMORY_LIMIT) { - - (void) fcntl(pipefds[1], F_SETPIPE_SZ, DATA_FD_MEMORY_LIMIT); - - isz = fcntl(pipefds[1], F_GETPIPE_SZ, 0); - if (isz < 0) - return -errno; - } - - if ((size_t) isz >= DATA_FD_MEMORY_LIMIT) { - - r = copy_bytes_full(fd, pipefds[1], DATA_FD_MEMORY_LIMIT, 0, &remains, &remains_size, NULL, NULL); - if (r < 0 && r != -EAGAIN) - return r; /* If we get EAGAIN it could be because of the source or because of - * the destination fd, we can't know, as sendfile() and friends won't - * tell us. Hence, treat this as reason to fall back, just to be - * sure. */ - if (r == 0) { - /* Everything fit in, yay! */ - (void) fd_nonblock(pipefds[0], false); - - return TAKE_FD(pipefds[0]); - } - - /* Things didn't fit in. But we read data into the pipe, let's remember that, so that - * when writing the new file we incorporate this first. */ - copy_fd = TAKE_FD(pipefds[0]); - } - } - } - - /* If we have reason to believe this will fit fine in /tmp, then use that as first fallback. */ - if ((!S_ISREG(st.st_mode) || st.st_size < DATA_FD_TMP_LIMIT) && - (DATA_FD_MEMORY_LIMIT + remains_size) < DATA_FD_TMP_LIMIT) { - off_t f; - - tmp_fd = open_tmpfile_unlinkable(NULL /* NULL as directory means /tmp */, O_RDWR|O_CLOEXEC); - if (tmp_fd < 0) - return tmp_fd; - - if (copy_fd >= 0) { - /* If we tried a memfd/pipe first and it ended up being too large, then copy this into the - * temporary file first. */ - - r = copy_bytes(copy_fd, tmp_fd, UINT64_MAX, 0); - if (r < 0) - return r; - - assert(r == 0); - } - - if (remains_size > 0) { - /* If there were remaining bytes (i.e. read into memory, but not written out yet) from the - * failed copy operation, let's flush them out next. */ - - r = loop_write(tmp_fd, remains, remains_size, false); - if (r < 0) - return r; - } - - r = copy_bytes(fd, tmp_fd, DATA_FD_TMP_LIMIT - DATA_FD_MEMORY_LIMIT - remains_size, COPY_REFLINK); - if (r < 0) - return r; - if (r == 0) - goto finish; /* Yay, it fit in */ - - /* It didn't fit in. Let's not forget to use what we already used */ - f = lseek(tmp_fd, 0, SEEK_SET); - if (f != 0) - return -errno; - - CLOSE_AND_REPLACE(copy_fd, tmp_fd); - - remains = mfree(remains); - remains_size = 0; - } - - /* As last fallback use /var/tmp */ - r = var_tmp_dir(&td); - if (r < 0) - return r; - - tmp_fd = open_tmpfile_unlinkable(td, O_RDWR|O_CLOEXEC); - if (tmp_fd < 0) - return tmp_fd; - - if (copy_fd >= 0) { - /* If we tried a memfd/pipe first, or a file in /tmp, and it ended up being too large, than copy this - * into the temporary file first. */ - r = copy_bytes(copy_fd, tmp_fd, UINT64_MAX, COPY_REFLINK); - if (r < 0) - return r; - - assert(r == 0); - } - - if (remains_size > 0) { - /* Then, copy in any read but not yet written bytes. */ - r = loop_write(tmp_fd, remains, remains_size, false); - if (r < 0) - return r; - } - - /* Copy in the rest */ - r = copy_bytes(fd, tmp_fd, UINT64_MAX, COPY_REFLINK); - if (r < 0) - return r; - - assert(r == 0); - -finish: - /* Now convert the O_RDWR file descriptor into an O_RDONLY one (and as side effect seek to the beginning of the - * file again */ - - return fd_reopen(tmp_fd, O_RDONLY|O_CLOEXEC); -} #endif /* NM_IGNORED */ int fd_move_above_stdio(int fd) { @@ -1016,7 +652,6 @@ finish: } int fd_reopen(int fd, int flags) { - char procfs_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; int new_fd; /* Reopens the specified fd with new flags. This is useful for convert an O_PATH fd into a regular one, or to @@ -1026,8 +661,7 @@ int fd_reopen(int fd, int flags) { * * This implicitly resets the file read index to 0. */ - xsprintf(procfs_path, "/proc/self/fd/%i", fd); - new_fd = open(procfs_path, flags); + new_fd = open(FORMAT_PROC_FD_PATH(fd), flags); if (new_fd < 0) { if (errno != ENOENT) return -errno; @@ -1064,4 +698,21 @@ int read_nr_open(void) { /* If we fail, fall back to the hard-coded kernel limit of 1024 * 1024. */ return 1024 * 1024; } + +/* This is here because it's fd-related and is called from sd-journal code. Other btrfs-related utilities are + * in src/shared, but libsystemd must not link to libsystemd-shared, see docs/ARCHITECTURE.md. */ +int btrfs_defrag_fd(int fd) { + int r; + + assert(fd >= 0); + + r = fd_verify_regular(fd); + if (r < 0) + return r; + + if (ioctl(fd, BTRFS_IOC_DEFRAG, NULL) < 0) + return -errno; + + return 0; +} #endif /* NM_IGNORED */ diff --git a/src/libnm-systemd-shared/src/basic/fd-util.h b/src/libnm-systemd-shared/src/basic/fd-util.h index aa8e082b..2382d52d 100644 --- a/src/libnm-systemd-shared/src/basic/fd-util.h +++ b/src/libnm-systemd-shared/src/basic/fd-util.h @@ -7,6 +7,7 @@ #include #include "macro.h" +#include "stdio-util.h" /* maximum length of fdname */ #define FDNAME_MAX 255 @@ -56,7 +57,10 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(DIR*, closedir, NULL); int fd_nonblock(int fd, bool nonblock); int fd_cloexec(int fd, bool cloexec); -int close_all_fds(const int except[], size_t n_except); +int close_all_fds_full(int except[], size_t n_except, bool allow_alloc); +static inline int close_all_fds(int except[], size_t n_except) { + return close_all_fds_full(except, n_except, true); +} int same_fd(int a, int b); @@ -76,10 +80,6 @@ enum { ACQUIRE_NO_REGULAR = 1 << 4, }; -int acquire_data_fd(const void *data, size_t size, unsigned flags); - -int fd_duplicate_data_fd(int fd); - int fd_move_above_stdio(int fd); int rearrange_stdio(int original_input_fd, int original_output_fd, int original_error_fd); @@ -105,7 +105,20 @@ static inline int make_null_stdio(void) { 0; \ }) - int fd_reopen(int fd, int flags); - int read_nr_open(void); +int btrfs_defrag_fd(int fd); + +/* The maximum length a buffer for a /proc/self/fd/ path needs */ +#define PROC_FD_PATH_MAX \ + (STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)) + +static inline char *format_proc_fd_path(char buf[static PROC_FD_PATH_MAX], int fd) { + assert(buf); + assert(fd >= 0); + assert_se(snprintf_ok(buf, PROC_FD_PATH_MAX, "/proc/self/fd/%i", fd)); + return buf; +} + +#define FORMAT_PROC_FD_PATH(fd) \ + format_proc_fd_path((char[PROC_FD_PATH_MAX]) {}, (fd)) diff --git a/src/libnm-systemd-shared/src/basic/fileio.c b/src/libnm-systemd-shared/src/basic/fileio.c index de78f70e..322638a2 100644 --- a/src/libnm-systemd-shared/src/basic/fileio.c +++ b/src/libnm-systemd-shared/src/basic/fileio.c @@ -15,6 +15,7 @@ #include #include "alloc-util.h" +#include "chase-symlinks.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" @@ -27,10 +28,22 @@ #include "socket-util.h" #include "stdio-util.h" #include "string-util.h" +#include "sync-util.h" #include "tmpfile-util.h" -/* The maximum size of the file we'll read in one go. */ -#define READ_FULL_BYTES_MAX (4U*1024U*1024U - 1) +/* The maximum size of the file we'll read in one go in read_full_file() (64M). */ +#define READ_FULL_BYTES_MAX (64U*1024U*1024U - 1U) + +/* The maximum size of virtual files (i.e. procfs, sysfs, and other virtual "API" files) we'll read in one go + * in read_virtual_file(). Note that this limit is different (and much lower) than the READ_FULL_BYTES_MAX + * limit. This reflects the fact that we use different strategies for reading virtual and regular files: + * virtual files we generally have to read in a single read() syscall since the kernel doesn't support + * continuation read()s for them. Thankfully they are somewhat size constrained. Thus we can allocate the + * full potential buffer in advance. Regular files OTOH can be much larger, and there we grow the allocations + * exponentially in a loop. We use a size limit of 4M-2 because 4M-1 is the maximum buffer that /proc/sys/ + * allows us to read() (larger reads will fail with ENOMEM), and we want to read one extra byte so that we + * can detect EOFs. */ +#define READ_VIRTUAL_BYTES_MAX (4U*1024U*1024U - 2U) int fopen_unlocked(const char *path, const char *options, FILE **ret) { assert(ret); @@ -140,6 +153,30 @@ int write_string_stream_ts( return -EBADF; } + if (flags & WRITE_STRING_FILE_SUPPRESS_REDUNDANT_VIRTUAL) { + _cleanup_free_ char *t = NULL; + + /* If value to be written is same as that of the existing value, then suppress the write. */ + + if (fd < 0) { + fd = fileno(f); + if (fd < 0) + return -EBADF; + } + + /* Read an additional byte to detect cases where the prefix matches but the rest + * doesn't. Also, 0 returned by read_virtual_file_fd() means the read was truncated and + * it won't be equal to the new value. */ + if (read_virtual_file_fd(fd, strlen(line)+1, &t, NULL) > 0 && + streq_skip_trailing_chars(line, t, NEWLINE)) { + log_debug("No change in value '%s', supressing write", line); + return 0; + } + + if (lseek(fd, 0, SEEK_SET) < 0) + return -errno; + } + needs_nl = !(flags & WRITE_STRING_FILE_AVOID_NEWLINE) && !endswith(line, "\n"); if (needs_nl && (flags & WRITE_STRING_FILE_DISABLE_BUFFER)) { @@ -255,10 +292,11 @@ int write_string_file_ts( assert(!ts); /* We manually build our own version of fopen(..., "we") that works without O_CREAT and with O_NOFOLLOW if needed. */ - fd = open(fn, O_WRONLY|O_CLOEXEC|O_NOCTTY | + fd = open(fn, O_CLOEXEC|O_NOCTTY | (FLAGS_SET(flags, WRITE_STRING_FILE_NOFOLLOW) ? O_NOFOLLOW : 0) | (FLAGS_SET(flags, WRITE_STRING_FILE_CREATE) ? O_CREAT : 0) | - (FLAGS_SET(flags, WRITE_STRING_FILE_TRUNCATE) ? O_TRUNC : 0), + (FLAGS_SET(flags, WRITE_STRING_FILE_TRUNCATE) ? O_TRUNC : 0) | + (FLAGS_SET(flags, WRITE_STRING_FILE_SUPPRESS_REDUNDANT_VIRTUAL) ? O_RDWR : O_WRONLY), (FLAGS_SET(flags, WRITE_STRING_FILE_MODE_0600) ? 0600 : 0666)); if (fd < 0) { r = -errno; @@ -368,9 +406,8 @@ int verify_file(const char *fn, const char *blob, bool accept_extra_nl) { } #endif /* NM_IGNORED */ -int read_virtual_file(const char *filename, size_t max_size, char **ret_contents, size_t *ret_size) { +int read_virtual_file_fd(int fd, size_t max_size, char **ret_contents, size_t *ret_size) { _cleanup_free_ char *buf = NULL; - _cleanup_close_ int fd = -1; size_t n, size; int n_retries; bool truncated = false; @@ -388,11 +425,8 @@ int read_virtual_file(const char *filename, size_t max_size, char **ret_contents * contents* may be returned. (Though the read is still done using one syscall.) Returns 0 on * partial success, 1 if untruncated contents were read. */ - fd = open(filename, O_RDONLY|O_CLOEXEC); - if (fd < 0) - return -errno; - - assert(max_size <= READ_FULL_BYTES_MAX || max_size == SIZE_MAX); + assert(fd >= 0); + assert(max_size <= READ_VIRTUAL_BYTES_MAX || max_size == SIZE_MAX); /* Limit the number of attempts to read the number of bytes returned by fstat(). */ n_retries = 3; @@ -407,7 +441,7 @@ int read_virtual_file(const char *filename, size_t max_size, char **ret_contents return -EBADF; /* Be prepared for files from /proc which generally report a file size of 0. */ - assert_cc(READ_FULL_BYTES_MAX < SSIZE_MAX); + assert_cc(READ_VIRTUAL_BYTES_MAX < SSIZE_MAX); if (st.st_size > 0 && n_retries > 1) { /* Let's use the file size if we have more than 1 attempt left. On the last attempt * we'll ignore the file size */ @@ -421,13 +455,18 @@ int read_virtual_file(const char *filename, size_t max_size, char **ret_contents } else { size = MIN((size_t) st.st_size, max_size); - if (size > READ_FULL_BYTES_MAX) + if (size > READ_VIRTUAL_BYTES_MAX) return -EFBIG; } n_retries--; + } else if (n_retries > 1) { + /* Files in /proc are generally smaller than the page size so let's start with + * a page size buffer from malloc and only use the max buffer on the final try. */ + size = MIN3(page_size() - 1, READ_VIRTUAL_BYTES_MAX, max_size); + n_retries = 1; } else { - size = MIN(READ_FULL_BYTES_MAX, max_size); + size = MIN(READ_VIRTUAL_BYTES_MAX, max_size); n_retries = 0; } @@ -436,7 +475,7 @@ int read_virtual_file(const char *filename, size_t max_size, char **ret_contents return -ENOMEM; /* Use a bigger allocation if we got it anyway, but not more than the limit. */ - size = MIN3(MALLOC_SIZEOF_SAFE(buf) - 1, max_size, READ_FULL_BYTES_MAX); + size = MIN3(MALLOC_SIZEOF_SAFE(buf) - 1, max_size, READ_VIRTUAL_BYTES_MAX); for (;;) { ssize_t k; @@ -458,9 +497,14 @@ int read_virtual_file(const char *filename, size_t max_size, char **ret_contents if (n <= size) break; - /* If a maximum size is specified and we already read as much, no need to try again */ - if (max_size != SIZE_MAX && n >= max_size) { - n = max_size; + /* If a maximum size is specified and we already read more we know the file is larger, and + * can handle this as truncation case. Note that if the size of what we read equals the + * maximum size then this doesn't mean truncation, the file might or might not end on that + * byte. We need to rerun the loop in that case, with a larger buffer size, so that we read + * at least one more byte to be able to distinguish EOF from truncation. */ + if (max_size != SIZE_MAX && n > max_size) { + n = size; /* Make sure we never use more than what we sized the buffer for (so that + * we have one free byte in it for the trailing NUL we add below).*/ truncated = true; break; } @@ -507,6 +551,18 @@ int read_virtual_file(const char *filename, size_t max_size, char **ret_contents return !truncated; } +int read_virtual_file(const char *filename, size_t max_size, char **ret_contents, size_t *ret_size) { + _cleanup_close_ int fd = -1; + + assert(filename); + + fd = open(filename, O_RDONLY | O_NOCTTY | O_CLOEXEC); + if (fd < 0) + return -errno; + + return read_virtual_file_fd(fd, max_size, ret_contents, ret_size); +} + int read_full_stream_full( FILE *f, const char *filename, @@ -517,18 +573,17 @@ int read_full_stream_full( size_t *ret_size) { _cleanup_free_ char *buf = NULL; - size_t n, n_next, l; + size_t n, n_next = 0, l; int fd, r; assert(f); assert(ret_contents); assert(!FLAGS_SET(flags, READ_FULL_FILE_UNBASE64 | READ_FULL_FILE_UNHEX)); + assert(size != SIZE_MAX || !FLAGS_SET(flags, READ_FULL_FILE_FAIL_WHEN_LARGER)); - if (offset != UINT64_MAX && offset > LONG_MAX) + if (offset != UINT64_MAX && offset > LONG_MAX) /* fseek() can only deal with "long" offsets */ return -ERANGE; - n_next = size != SIZE_MAX ? size : LINE_MAX; /* Start size */ - fd = fileno(f); if (fd >= 0) { /* If the FILE* object is backed by an fd (as opposed to memory or such, see * fmemopen()), let's optimize our buffering */ @@ -538,20 +593,20 @@ int read_full_stream_full( return -errno; if (S_ISREG(st.st_mode)) { - if (size == SIZE_MAX) { + + /* Try to start with the right file size if we shall read the file in full. Note + * that we increase the size to read here by one, so that the first read attempt + * already makes us notice the EOF. If the reported size of the file is zero, we + * avoid this logic however, since quite likely it might be a virtual file in procfs + * that all report a zero file size. */ + + if (st.st_size > 0 && + (size == SIZE_MAX || FLAGS_SET(flags, READ_FULL_FILE_FAIL_WHEN_LARGER))) { + uint64_t rsize = LESS_BY((uint64_t) st.st_size, offset == UINT64_MAX ? 0 : offset); - /* Safety check */ - if (rsize > READ_FULL_BYTES_MAX) - return -E2BIG; - - /* Start with the right file size. Note that we increase the size to read - * here by one, so that the first read attempt already makes us notice the - * EOF. If the reported size of the file is zero, we avoid this logic - * however, since quite likely it might be a virtual file in procfs that all - * report a zero file size. */ - if (st.st_size > 0) + if (rsize < SIZE_MAX) /* overflow check */ n_next = rsize + 1; } @@ -560,6 +615,17 @@ int read_full_stream_full( } } + /* If we don't know how much to read, figure it out now. If we shall read a part of the file, then + * allocate the requested size. If we shall load the full file start with LINE_MAX. Note that if + * READ_FULL_FILE_FAIL_WHEN_LARGER we consider the specified size a safety limit, and thus also start + * with LINE_MAX, under assumption the file is most likely much shorter. */ + if (n_next == 0) + n_next = size != SIZE_MAX && !FLAGS_SET(flags, READ_FULL_FILE_FAIL_WHEN_LARGER) ? size : LINE_MAX; + + /* Never read more than we need to determine that our own limit is hit */ + if (n_next > READ_FULL_BYTES_MAX) + n_next = READ_FULL_BYTES_MAX + 1; + if (offset != UINT64_MAX && fseek(f, offset, SEEK_SET) < 0) return -errno; @@ -568,6 +634,11 @@ int read_full_stream_full( char *t; size_t k; + /* If we shall fail when reading overly large data, then read exactly one byte more than the + * specified size at max, since that'll tell us if there's anymore data beyond the limit*/ + if (FLAGS_SET(flags, READ_FULL_FILE_FAIL_WHEN_LARGER) && n_next > size) + n_next = size + 1; + if (flags & READ_FULL_FILE_SECURE) { t = malloc(n_next + 1); if (!t) { @@ -576,7 +647,7 @@ int read_full_stream_full( } memcpy_safe(t, buf, n); explicit_bzero_safe(buf, n); - buf = mfree(buf); + free(buf); } else { t = realloc(buf, n_next + 1); if (!t) @@ -601,14 +672,18 @@ int read_full_stream_full( if (feof(f)) break; - if (size != SIZE_MAX) { /* If we got asked to read some specific size, we already sized the buffer right, hence leave */ + if (size != SIZE_MAX && !FLAGS_SET(flags, READ_FULL_FILE_FAIL_WHEN_LARGER)) { /* If we got asked to read some specific size, we already sized the buffer right, hence leave */ assert(l == size); break; } assert(k > 0); /* we can't have read zero bytes because that would have been EOF */ - /* Safety check */ + if (FLAGS_SET(flags, READ_FULL_FILE_FAIL_WHEN_LARGER) && l > size) { + r = -E2BIG; + goto finalize; + } + if (n >= READ_FULL_BYTES_MAX) { r = -E2BIG; goto finalize; @@ -697,8 +772,6 @@ int read_full_file_full( if (dir_fd == AT_FDCWD) r = sockaddr_un_set_path(&sa.un, filename); else { - char procfs_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; - /* If we shall operate relative to some directory, then let's use O_PATH first to * open the socket inode, and then connect to it via /proc/self/fd/. We have to do * this since there's not connectat() that takes a directory fd as first arg. */ @@ -707,8 +780,7 @@ int read_full_file_full( if (dfd < 0) return -errno; - xsprintf(procfs_path, "/proc/self/fd/%i", dfd); - r = sockaddr_un_set_path(&sa.un, procfs_path); + r = sockaddr_un_set_path(&sa.un, FORMAT_PROC_FD_PATH(dfd)); } if (r < 0) return r; @@ -875,10 +947,12 @@ DIR *xopendirat(int fd, const char *name, int flags) { return d; } -static int mode_to_flags(const char *mode) { +int fopen_mode_to_flags(const char *mode) { const char *p; int flags; + assert(mode); + if ((p = startswith(mode, "r+"))) flags = O_RDWR; else if ((p = startswith(mode, "r"))) @@ -931,7 +1005,7 @@ int xfopenat(int dir_fd, const char *path, const char *mode, int flags, FILE **r } else { int fd, mode_flags; - mode_flags = mode_to_flags(mode); + mode_flags = fopen_mode_to_flags(mode); if (mode_flags < 0) return mode_flags; @@ -1071,39 +1145,6 @@ int search_and_fopen_nulstr( return search_and_fopen_internal(filename, mode, root, s, ret, ret_path); } - -int chase_symlinks_and_fopen_unlocked( - const char *path, - const char *root, - unsigned chase_flags, - const char *open_flags, - FILE **ret_file, - char **ret_path) { - - _cleanup_close_ int fd = -1; - _cleanup_free_ char *final_path = NULL; - int mode_flags, r; - - assert(path); - assert(open_flags); - assert(ret_file); - - mode_flags = mode_to_flags(open_flags); - if (mode_flags < 0) - return mode_flags; - - fd = chase_symlinks_and_open(path, root, chase_flags, mode_flags, ret_path ? &final_path : NULL); - if (fd < 0) - return fd; - - r = take_fdopen_unlocked(&fd, open_flags, ret_file); - if (r < 0) - return r; - - if (ret_path) - *ret_path = TAKE_PTR(final_path); - return 0; -} #endif /* NM_IGNORED */ int fflush_and_check(FILE *f) { @@ -1134,10 +1175,7 @@ int fflush_sync_and_check(FILE *f) { if (fd < 0) return 0; - if (fsync(fd) < 0) - return -errno; - - r = fsync_directory_of_file(fd); + r = fsync_full(fd); if (r < 0) return r; @@ -1409,18 +1447,3 @@ int warn_file_is_world_accessible(const char *filename, struct stat *st, const c filename, st->st_mode & 07777); return 0; } - -#if 0 /* NM_IGNORED */ -int rename_and_apply_smack_floor_label(const char *from, const char *to) { - int r = 0; - if (rename(from, to) < 0) - return -errno; - -#if HAVE_SMACK_RUN_LABEL - r = mac_smack_apply(to, SMACK_ATTR_ACCESS, SMACK_FLOOR_LABEL); - if (r < 0) - return r; -#endif - return r; -} -#endif /* NM_IGNORED */ diff --git a/src/libnm-systemd-shared/src/basic/fileio.h b/src/libnm-systemd-shared/src/basic/fileio.h index 1a8b7dec..899def94 100644 --- a/src/libnm-systemd-shared/src/basic/fileio.h +++ b/src/libnm-systemd-shared/src/basic/fileio.h @@ -2,15 +2,11 @@ #pragma once #include +#include #include #include #include #include -#if 0 /* NM_IGNORED */ -#include -#else /* NM_IGNORED */ -#include -#endif /* NM_IGNORED */ #include #include "macro.h" @@ -19,17 +15,18 @@ #define LONG_LINE_MAX (1U*1024U*1024U) typedef enum { - WRITE_STRING_FILE_CREATE = 1 << 0, - WRITE_STRING_FILE_TRUNCATE = 1 << 1, - WRITE_STRING_FILE_ATOMIC = 1 << 2, - WRITE_STRING_FILE_AVOID_NEWLINE = 1 << 3, - WRITE_STRING_FILE_VERIFY_ON_FAILURE = 1 << 4, - WRITE_STRING_FILE_VERIFY_IGNORE_NEWLINE = 1 << 5, - WRITE_STRING_FILE_SYNC = 1 << 6, - WRITE_STRING_FILE_DISABLE_BUFFER = 1 << 7, - WRITE_STRING_FILE_NOFOLLOW = 1 << 8, - WRITE_STRING_FILE_MKDIR_0755 = 1 << 9, - WRITE_STRING_FILE_MODE_0600 = 1 << 10, + WRITE_STRING_FILE_CREATE = 1 << 0, + WRITE_STRING_FILE_TRUNCATE = 1 << 1, + WRITE_STRING_FILE_ATOMIC = 1 << 2, + WRITE_STRING_FILE_AVOID_NEWLINE = 1 << 3, + WRITE_STRING_FILE_VERIFY_ON_FAILURE = 1 << 4, + WRITE_STRING_FILE_VERIFY_IGNORE_NEWLINE = 1 << 5, + WRITE_STRING_FILE_SYNC = 1 << 6, + WRITE_STRING_FILE_DISABLE_BUFFER = 1 << 7, + WRITE_STRING_FILE_NOFOLLOW = 1 << 8, + WRITE_STRING_FILE_MKDIR_0755 = 1 << 9, + WRITE_STRING_FILE_MODE_0600 = 1 << 10, + WRITE_STRING_FILE_SUPPRESS_REDUNDANT_VIRTUAL = 1 << 11, /* And before you wonder, why write_string_file_atomic_label_ts() is a separate function instead of just one more flag here: it's about linking: we don't want to pull -lselinux into all users of write_string_file() @@ -43,6 +40,7 @@ typedef enum { READ_FULL_FILE_UNHEX = 1 << 2, /* hex decode what we read */ READ_FULL_FILE_WARN_WORLD_READABLE = 1 << 3, /* if regular file, log at LOG_WARNING level if access mode above 0700 */ READ_FULL_FILE_CONNECT_SOCKET = 1 << 4, /* if socket inode, connect to it and read off it */ + READ_FULL_FILE_FAIL_WHEN_LARGER = 1 << 5, /* fail loading if file is larger than specified size */ } ReadFullFileFlags; int fopen_unlocked(const char *path, const char *options, FILE **ret); @@ -70,6 +68,7 @@ static inline int read_full_file(const char *filename, char **ret_contents, size return read_full_file_full(AT_FDCWD, filename, UINT64_MAX, SIZE_MAX, 0, NULL, ret_contents, ret_size); } +int read_virtual_file_fd(int fd, size_t max_size, char **ret_contents, size_t *ret_size); int read_virtual_file(const char *filename, size_t max_size, char **ret_contents, size_t *ret_size); static inline int read_full_virtual_file(const char *filename, char **ret_contents, size_t *ret_size) { return read_virtual_file(filename, SIZE_MAX, ret_contents, ret_size); @@ -92,14 +91,6 @@ int xfopenat(int dir_fd, const char *path, const char *mode, int flags, FILE **r int search_and_fopen(const char *path, const char *mode, const char *root, const char **search, FILE **ret, char **ret_path); int search_and_fopen_nulstr(const char *path, const char *mode, const char *root, const char *search, FILE **ret, char **ret_path); -int chase_symlinks_and_fopen_unlocked( - const char *path, - const char *root, - unsigned chase_flags, - const char *open_flags, - FILE **ret_file, - char **ret_path); - int fflush_and_check(FILE *f); int fflush_sync_and_check(FILE *f); @@ -128,4 +119,4 @@ int safe_fgetc(FILE *f, char *ret); int warn_file_is_world_accessible(const char *filename, struct stat *st, const char *unit, unsigned line); -int rename_and_apply_smack_floor_label(const char *temp_path, const char *dest_path); +int fopen_mode_to_flags(const char *mode); diff --git a/src/libnm-systemd-shared/src/basic/format-util.c b/src/libnm-systemd-shared/src/basic/format-util.c index 398a1815..ebe52713 100644 --- a/src/libnm-systemd-shared/src/basic/format-util.c +++ b/src/libnm-systemd-shared/src/basic/format-util.c @@ -5,23 +5,43 @@ #include "format-util.h" #include "memory-util.h" #include "stdio-util.h" +#include "strxcpyx.h" + +assert_cc(STRLEN("%") + DECIMAL_STR_MAX(int) <= IF_NAMESIZE); +int format_ifname_full(int ifindex, FormatIfnameFlag flag, char buf[static IF_NAMESIZE]) { + if (ifindex <= 0) + return -EINVAL; -assert_cc(DECIMAL_STR_MAX(int) + 1 <= IF_NAMESIZE + 1); -char *format_ifname_full(int ifindex, char buf[static IF_NAMESIZE + 1], FormatIfnameFlag flag) { - /* Buffer is always cleared */ - memzero(buf, IF_NAMESIZE + 1); if (if_indextoname(ifindex, buf)) - return buf; + return 0; if (!FLAGS_SET(flag, FORMAT_IFNAME_IFINDEX)) - return NULL; + return -errno; if (FLAGS_SET(flag, FORMAT_IFNAME_IFINDEX_WITH_PERCENT)) - snprintf(buf, IF_NAMESIZE + 1, "%%%d", ifindex); + assert(snprintf_ok(buf, IF_NAMESIZE, "%%%d", ifindex)); else - snprintf(buf, IF_NAMESIZE + 1, "%d", ifindex); + assert(snprintf_ok(buf, IF_NAMESIZE, "%d", ifindex)); - return buf; + return 0; +} + +int format_ifname_full_alloc(int ifindex, FormatIfnameFlag flag, char **ret) { + char buf[IF_NAMESIZE], *copy; + int r; + + assert(ret); + + r = format_ifname_full(ifindex, flag, buf); + if (r < 0) + return r; + + copy = strdup(buf); + if (!copy) + return -ENOMEM; + + *ret = copy; + return 0; } char *format_bytes_full(char *buf, size_t l, uint64_t t, FormatBytesFlag flag) { @@ -58,23 +78,23 @@ char *format_bytes_full(char *buf, size_t l, uint64_t t, FormatBytesFlag flag) { for (size_t i = 0; i < n; i++) if (t >= table[i].factor) { if (flag & FORMAT_BYTES_BELOW_POINT) { - snprintf(buf, l, - "%" PRIu64 ".%" PRIu64 "%s", - t / table[i].factor, - i != n - 1 ? - (t / table[i + 1].factor * UINT64_C(10) / table[n - 1].factor) % UINT64_C(10): - (t * UINT64_C(10) / table[i].factor) % UINT64_C(10), - table[i].suffix); + (void) snprintf(buf, l, + "%" PRIu64 ".%" PRIu64 "%s", + t / table[i].factor, + i != n - 1 ? + (t / table[i + 1].factor * UINT64_C(10) / table[n - 1].factor) % UINT64_C(10): + (t * UINT64_C(10) / table[i].factor) % UINT64_C(10), + table[i].suffix); } else - snprintf(buf, l, - "%" PRIu64 "%s", - t / table[i].factor, - table[i].suffix); + (void) snprintf(buf, l, + "%" PRIu64 "%s", + t / table[i].factor, + table[i].suffix); goto finish; } - snprintf(buf, l, "%" PRIu64 "%s", t, flag & FORMAT_BYTES_TRAILING_B ? "B" : ""); + (void) snprintf(buf, l, "%" PRIu64 "%s", t, flag & FORMAT_BYTES_TRAILING_B ? "B" : ""); finish: buf[l-1] = 0; diff --git a/src/libnm-systemd-shared/src/basic/format-util.h b/src/libnm-systemd-shared/src/basic/format-util.h index b7e18768..7dd422b9 100644 --- a/src/libnm-systemd-shared/src/basic/format-util.h +++ b/src/libnm-systemd-shared/src/basic/format-util.h @@ -61,11 +61,24 @@ typedef enum { FORMAT_IFNAME_IFINDEX_WITH_PERCENT = (1 << 1) | FORMAT_IFNAME_IFINDEX, } FormatIfnameFlag; -char *format_ifname_full(int ifindex, char buf[static IF_NAMESIZE + 1], FormatIfnameFlag flag); -static inline char *format_ifname(int ifindex, char buf[static IF_NAMESIZE + 1]) { - return format_ifname_full(ifindex, buf, 0); +int format_ifname_full(int ifindex, FormatIfnameFlag flag, char buf[static IF_NAMESIZE]); +int format_ifname_full_alloc(int ifindex, FormatIfnameFlag flag, char **ret); + +static inline int format_ifname(int ifindex, char buf[static IF_NAMESIZE]) { + return format_ifname_full(ifindex, 0, buf); +} +static inline int format_ifname_alloc(int ifindex, char **ret) { + return format_ifname_full_alloc(ifindex, 0, ret); +} + +static inline char *_format_ifname_full(int ifindex, FormatIfnameFlag flag, char buf[static IF_NAMESIZE]) { + (void) format_ifname_full(ifindex, flag, buf); + return buf; } +#define FORMAT_IFNAME_FULL(index, flag) _format_ifname_full(index, flag, (char[IF_NAMESIZE]){}) +#define FORMAT_IFNAME(index) _format_ifname_full(index, 0, (char[IF_NAMESIZE]){}) + typedef enum { FORMAT_BYTES_USE_IEC = 1 << 0, FORMAT_BYTES_BELOW_POINT = 1 << 1, @@ -74,16 +87,17 @@ typedef enum { #define FORMAT_BYTES_MAX 16U -char *format_bytes_full(char *buf, size_t l, uint64_t t, FormatBytesFlag flag); +char *format_bytes_full(char *buf, size_t l, uint64_t t, FormatBytesFlag flag) _warn_unused_result_; +_warn_unused_result_ static inline char *format_bytes(char *buf, size_t l, uint64_t t) { return format_bytes_full(buf, l, t, FORMAT_BYTES_USE_IEC | FORMAT_BYTES_BELOW_POINT | FORMAT_BYTES_TRAILING_B); } -static inline char *format_bytes_cgroup_protection(char *buf, size_t l, uint64_t t) { - if (t == CGROUP_LIMIT_MAX) { - (void) snprintf(buf, l, "%s", "infinity"); - return buf; - } - return format_bytes(buf, l, t); -} +/* Note: the lifetime of the compound literal is the immediately surrounding block, + * see C11 §6.5.2.5, and + * https://stackoverflow.com/questions/34880638/compound-literal-lifetime-and-if-blocks */ +#define FORMAT_BYTES(t) format_bytes((char[FORMAT_BYTES_MAX]){}, FORMAT_BYTES_MAX, t) +#define FORMAT_BYTES_FULL(t, flag) format_bytes_full((char[FORMAT_BYTES_MAX]){}, FORMAT_BYTES_MAX, t, flag) + +#define FORMAT_BYTES_CGROUP_PROTECTION(t) (t == CGROUP_LIMIT_MAX ? "infinity" : FORMAT_BYTES(t)) diff --git a/src/libnm-systemd-shared/src/basic/fs-util.c b/src/libnm-systemd-shared/src/basic/fs-util.c index ee8eec90..3f309868 100644 --- a/src/libnm-systemd-shared/src/basic/fs-util.c +++ b/src/libnm-systemd-shared/src/basic/fs-util.c @@ -10,12 +10,10 @@ #include #include "alloc-util.h" -#include "blockdev-util.h" #include "dirent-util.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" -#include "locale-util.h" #include "log.h" #include "macro.h" #include "missing_fcntl.h" @@ -49,50 +47,39 @@ int unlink_noerrno(const char *path) { #if 0 /* NM_IGNORED */ int rmdir_parents(const char *path, const char *stop) { - size_t l; - int r = 0; + char *p; + int r; assert(path); assert(stop); - l = strlen(path); - - /* Skip trailing slashes */ - while (l > 0 && path[l-1] == '/') - l--; + if (!path_is_safe(path)) + return -EINVAL; - while (l > 0) { - char *t; + if (!path_is_safe(stop)) + return -EINVAL; - /* Skip last component */ - while (l > 0 && path[l-1] != '/') - l--; + p = strdupa(path); - /* Skip trailing slashes */ - while (l > 0 && path[l-1] == '/') - l--; + for (;;) { + char *slash = NULL; - if (l <= 0) - break; + /* skip the last component. */ + r = path_find_last_component(p, /* accept_dot_dot= */ false, (const char **) &slash, NULL); + if (r <= 0) + return r; + if (slash == p) + return 0; - t = strndup(path, l); - if (!t) - return -ENOMEM; + assert(*slash == '/'); + *slash = '\0'; - if (path_startswith(stop, t)) { - free(t); + if (path_startswith_full(stop, p, /* accept_dot_dot= */ false)) return 0; - } - - r = rmdir(t); - free(t); - if (r < 0) - if (errno != ENOENT) - return -errno; + if (rmdir(p) < 0 && errno != ENOENT) + return -errno; } - - return 0; } int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char *newpath) { @@ -314,14 +301,11 @@ int fchmod_umask(int fd, mode_t m) { } int fchmod_opath(int fd, mode_t m) { - char procfs_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; - /* This function operates also on fd that might have been opened with * O_PATH. Indeed fchmodat() doesn't have the AT_EMPTY_PATH flag like * fchownat() does. */ - xsprintf(procfs_path, "/proc/self/fd/%i", fd); - if (chmod(procfs_path, m) < 0) { + if (chmod(FORMAT_PROC_FD_PATH(fd), m) < 0) { if (errno != ENOENT) return -errno; @@ -335,12 +319,9 @@ int fchmod_opath(int fd, mode_t m) { } int futimens_opath(int fd, const struct timespec ts[2]) { - char procfs_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; - /* Similar to fchmod_path() but for futimens() */ - xsprintf(procfs_path, "/proc/self/fd/%i", fd); - if (utimensat(AT_FDCWD, procfs_path, ts, 0) < 0) { + if (utimensat(AT_FDCWD, FORMAT_PROC_FD_PATH(fd), ts, 0) < 0) { if (errno != ENOENT) return -errno; @@ -386,9 +367,8 @@ int fd_warn_permissions(const char *path, int fd) { } int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode) { - char fdpath[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; _cleanup_close_ int fd = -1; - int r, ret = 0; + int r, ret; assert(path); @@ -418,8 +398,6 @@ int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gi /* Let's make a path from the fd, and operate on that. With this logic, we can adjust the access mode, * ownership and time of the file node in all cases, even if the fd refers to an O_PATH object — which is * something fchown(), fchmod(), futimensat() don't allow. */ - xsprintf(fdpath, "/proc/self/fd/%i", fd); - ret = fchmod_and_chown(fd, mode, uid, gid); if (stamp != USEC_INFINITY) { @@ -427,11 +405,11 @@ int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gi timespec_store(&ts[0], stamp); ts[1] = ts[0]; - r = utimensat(AT_FDCWD, fdpath, ts, 0); + r = futimens_opath(fd, ts); } else - r = utimensat(AT_FDCWD, fdpath, NULL, 0); + r = futimens_opath(fd, NULL); if (r < 0 && ret >= 0) - return -errno; + return r; return ret; } @@ -586,8 +564,6 @@ int get_files_in_directory(const char *path, char ***list) { return -errno; FOREACH_DIRENT_ALL(de, d, return -errno) { - dirent_ensure_type(d, de); - if (!dirent_is_file(de)) continue; @@ -713,544 +689,11 @@ int unlink_or_warn(const char *filename) { return 0; } -#endif /* NM_IGNORED */ - -int inotify_add_watch_fd(int fd, int what, uint32_t mask) { - char path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int) + 1]; - int wd; - - /* This is like inotify_add_watch(), except that the file to watch is not referenced by a path, but by an fd */ - xsprintf(path, "/proc/self/fd/%i", what); - - wd = inotify_add_watch(fd, path, mask); - if (wd < 0) - return -errno; - - return wd; -} - -#if 0 /* NM_IGNORED */ -int inotify_add_watch_and_warn(int fd, const char *pathname, uint32_t mask) { - int wd; - - wd = inotify_add_watch(fd, pathname, mask); - if (wd < 0) { - if (errno == ENOSPC) - return log_error_errno(errno, "Failed to add a watch for %s: inotify watch limit reached", pathname); - - return log_error_errno(errno, "Failed to add a watch for %s: %m", pathname); - } - - return wd; -} - -static bool unsafe_transition(const struct stat *a, const struct stat *b) { - /* Returns true if the transition from a to b is safe, i.e. that we never transition from unprivileged to - * privileged files or directories. Why bother? So that unprivileged code can't symlink to privileged files - * making us believe we read something safe even though it isn't safe in the specific context we open it in. */ - - if (a->st_uid == 0) /* Transitioning from privileged to unprivileged is always fine */ - return false; - - return a->st_uid != b->st_uid; /* Otherwise we need to stay within the same UID */ -} - -static int log_unsafe_transition(int a, int b, const char *path, unsigned flags) { - _cleanup_free_ char *n1 = NULL, *n2 = NULL; - - if (!FLAGS_SET(flags, CHASE_WARN)) - return -ENOLINK; - - (void) fd_get_path(a, &n1); - (void) fd_get_path(b, &n2); - - return log_warning_errno(SYNTHETIC_ERRNO(ENOLINK), - "Detected unsafe path transition %s %s %s during canonicalization of %s.", - strna(n1), special_glyph(SPECIAL_GLYPH_ARROW), strna(n2), path); -} - -static int log_autofs_mount_point(int fd, const char *path, unsigned flags) { - _cleanup_free_ char *n1 = NULL; - - if (!FLAGS_SET(flags, CHASE_WARN)) - return -EREMOTE; - - (void) fd_get_path(fd, &n1); - - return log_warning_errno(SYNTHETIC_ERRNO(EREMOTE), - "Detected autofs mount point %s during canonicalization of %s.", - strna(n1), path); -} - -int chase_symlinks(const char *path, const char *original_root, unsigned flags, char **ret_path, int *ret_fd) { - _cleanup_free_ char *buffer = NULL, *done = NULL, *root = NULL; - _cleanup_close_ int fd = -1; - unsigned max_follow = CHASE_SYMLINKS_MAX; /* how many symlinks to follow before giving up and returning ELOOP */ - bool exists = true, append_trail_slash = false; - struct stat previous_stat; - const char *todo; - int r; - - assert(path); - - /* Either the file may be missing, or we return an fd to the final object, but both make no sense */ - if ((flags & CHASE_NONEXISTENT) && ret_fd) - return -EINVAL; - - if ((flags & CHASE_STEP) && ret_fd) - return -EINVAL; - - if (isempty(path)) - return -EINVAL; - - /* This is a lot like canonicalize_file_name(), but takes an additional "root" parameter, that allows following - * symlinks relative to a root directory, instead of the root of the host. - * - * Note that "root" primarily matters if we encounter an absolute symlink. It is also used when following - * relative symlinks to ensure they cannot be used to "escape" the root directory. The path parameter passed is - * assumed to be already prefixed by it, except if the CHASE_PREFIX_ROOT flag is set, in which case it is first - * prefixed accordingly. - * - * Algorithmically this operates on two path buffers: "done" are the components of the path we already - * processed and resolved symlinks, "." and ".." of. "todo" are the components of the path we still need to - * process. On each iteration, we move one component from "todo" to "done", processing it's special meaning - * each time. The "todo" path always starts with at least one slash, the "done" path always ends in no - * slash. We always keep an O_PATH fd to the component we are currently processing, thus keeping lookup races - * to a minimum. - * - * Suggested usage: whenever you want to canonicalize a path, use this function. Pass the absolute path you got - * as-is: fully qualified and relative to your host's root. Optionally, specify the root parameter to tell this - * function what to do when encountering a symlink with an absolute path as directory: prefix it by the - * specified path. - * - * There are five ways to invoke this function: - * - * 1. Without CHASE_STEP or ret_fd: in this case the path is resolved and the normalized path is - * returned in `ret_path`. The return value is < 0 on error. If CHASE_NONEXISTENT is also set, 0 - * is returned if the file doesn't exist, > 0 otherwise. If CHASE_NONEXISTENT is not set, >= 0 is - * returned if the destination was found, -ENOENT if it wasn't. - * - * 2. With ret_fd: in this case the destination is opened after chasing it as O_PATH and this file - * descriptor is returned as return value. This is useful to open files relative to some root - * directory. Note that the returned O_PATH file descriptors must be converted into a regular one (using - * fd_reopen() or such) before it can be used for reading/writing. ret_fd may not be combined with - * CHASE_NONEXISTENT. - * - * 3. With CHASE_STEP: in this case only a single step of the normalization is executed, i.e. only the first - * symlink or ".." component of the path is resolved, and the resulting path is returned. This is useful if - * a caller wants to trace the path through the file system verbosely. Returns < 0 on error, > 0 if the - * path is fully normalized, and == 0 for each normalization step. This may be combined with - * CHASE_NONEXISTENT, in which case 1 is returned when a component is not found. - * - * 4. With CHASE_SAFE: in this case the path must not contain unsafe transitions, i.e. transitions from - * unprivileged to privileged files or directories. In such cases the return value is -ENOLINK. If - * CHASE_WARN is also set, a warning describing the unsafe transition is emitted. - * - * 5. With CHASE_NO_AUTOFS: in this case if an autofs mount point is encountered, path normalization - * is aborted and -EREMOTE is returned. If CHASE_WARN is also set, a warning showing the path of - * the mount point is emitted. - */ - - /* A root directory of "/" or "" is identical to none */ - if (empty_or_root(original_root)) - original_root = NULL; - - if (!original_root && !ret_path && !(flags & (CHASE_NONEXISTENT|CHASE_NO_AUTOFS|CHASE_SAFE|CHASE_STEP)) && ret_fd) { - /* Shortcut the ret_fd case if the caller isn't interested in the actual path and has no root set - * and doesn't care about any of the other special features we provide either. */ - r = open(path, O_PATH|O_CLOEXEC|((flags & CHASE_NOFOLLOW) ? O_NOFOLLOW : 0)); - if (r < 0) - return -errno; - - *ret_fd = r; - return 0; - } - - if (original_root) { - r = path_make_absolute_cwd(original_root, &root); - if (r < 0) - return r; - - /* Simplify the root directory, so that it has no duplicate slashes and nothing at the - * end. While we won't resolve the root path we still simplify it. Note that dropping the - * trailing slash should not change behaviour, since when opening it we specify O_DIRECTORY - * anyway. Moreover at the end of this function after processing everything we'll always turn - * the empty string back to "/". */ - delete_trailing_chars(root, "/"); - path_simplify(root); - - if (flags & CHASE_PREFIX_ROOT) { - /* We don't support relative paths in combination with a root directory */ - if (!path_is_absolute(path)) - return -EINVAL; - - path = prefix_roota(root, path); - } - } - - r = path_make_absolute_cwd(path, &buffer); - if (r < 0) - return r; - - fd = open(root ?: "/", O_CLOEXEC|O_DIRECTORY|O_PATH); - if (fd < 0) - return -errno; - - if (flags & CHASE_SAFE) - if (fstat(fd, &previous_stat) < 0) - return -errno; - - if (flags & CHASE_TRAIL_SLASH) - append_trail_slash = endswith(buffer, "/") || endswith(buffer, "/."); - - if (root) { - /* If we are operating on a root directory, let's take the root directory as it is. */ - - todo = path_startswith(buffer, root); - if (!todo) - return log_full_errno(flags & CHASE_WARN ? LOG_WARNING : LOG_DEBUG, - SYNTHETIC_ERRNO(ECHRNG), - "Specified path '%s' is outside of specified root directory '%s', refusing to resolve.", - path, root); - - done = strdup(root); - } else { - todo = buffer; - done = strdup("/"); - } - - for (;;) { - _cleanup_free_ char *first = NULL; - _cleanup_close_ int child = -1; - struct stat st; - const char *e; - - r = path_find_first_component(&todo, true, &e); - if (r < 0) - return r; - if (r == 0) { /* We reached the end. */ - if (append_trail_slash) - if (!strextend(&done, "/")) - return -ENOMEM; - break; - } - - first = strndup(e, r); - if (!first) - return -ENOMEM; - - /* Two dots? Then chop off the last bit of what we already found out. */ - if (path_equal(first, "..")) { - _cleanup_free_ char *parent = NULL; - _cleanup_close_ int fd_parent = -1; - - /* If we already are at the top, then going up will not change anything. This is in-line with - * how the kernel handles this. */ - if (empty_or_root(done)) - continue; - - parent = dirname_malloc(done); - if (!parent) - return -ENOMEM; - - /* Don't allow this to leave the root dir. */ - if (root && - path_startswith(done, root) && - !path_startswith(parent, root)) - continue; - - free_and_replace(done, parent); - - if (flags & CHASE_STEP) - goto chased_one; - - fd_parent = openat(fd, "..", O_CLOEXEC|O_NOFOLLOW|O_PATH); - if (fd_parent < 0) - return -errno; - - if (flags & CHASE_SAFE) { - if (fstat(fd_parent, &st) < 0) - return -errno; - - if (unsafe_transition(&previous_stat, &st)) - return log_unsafe_transition(fd, fd_parent, path, flags); - - previous_stat = st; - } - - safe_close(fd); - fd = TAKE_FD(fd_parent); - - continue; - } - - /* Otherwise let's see what this is. */ - child = openat(fd, first, O_CLOEXEC|O_NOFOLLOW|O_PATH); - if (child < 0) { - if (errno == ENOENT && - (flags & CHASE_NONEXISTENT) && - (isempty(todo) || path_is_safe(todo))) { - /* If CHASE_NONEXISTENT is set, and the path does not exist, then - * that's OK, return what we got so far. But don't allow this if the - * remaining path contains "../" or something else weird. */ - - if (!path_extend(&done, first, todo)) - return -ENOMEM; - - exists = false; - break; - } - - return -errno; - } - - if (fstat(child, &st) < 0) - return -errno; - if ((flags & CHASE_SAFE) && - unsafe_transition(&previous_stat, &st)) - return log_unsafe_transition(fd, child, path, flags); - - previous_stat = st; - - if ((flags & CHASE_NO_AUTOFS) && - fd_is_fs_type(child, AUTOFS_SUPER_MAGIC) > 0) - return log_autofs_mount_point(child, path, flags); - - if (S_ISLNK(st.st_mode) && !((flags & CHASE_NOFOLLOW) && isempty(todo))) { - _cleanup_free_ char *destination = NULL; - - /* This is a symlink, in this case read the destination. But let's make sure we - * don't follow symlinks without bounds. */ - if (--max_follow <= 0) - return -ELOOP; - - r = readlinkat_malloc(fd, first, &destination); - if (r < 0) - return r; - if (isempty(destination)) - return -EINVAL; - - if (path_is_absolute(destination)) { - - /* An absolute destination. Start the loop from the beginning, but use the root - * directory as base. */ - - safe_close(fd); - fd = open(root ?: "/", O_CLOEXEC|O_DIRECTORY|O_PATH); - if (fd < 0) - return -errno; - - if (flags & CHASE_SAFE) { - if (fstat(fd, &st) < 0) - return -errno; - - if (unsafe_transition(&previous_stat, &st)) - return log_unsafe_transition(child, fd, path, flags); - - previous_stat = st; - } - - /* Note that we do not revalidate the root, we take it as is. */ - r = free_and_strdup(&done, empty_to_root(root)); - if (r < 0) - return r; - } - - /* Prefix what's left to do with what we just read, and start the loop again, but - * remain in the current directory. */ - if (!path_extend(&destination, todo)) - return -ENOMEM; - - free_and_replace(buffer, destination); - todo = buffer; - - if (flags & CHASE_STEP) - goto chased_one; - - continue; - } - - /* If this is not a symlink, then let's just add the name we read to what we already verified. */ - if (!path_extend(&done, first)) - return -ENOMEM; - - /* And iterate again, but go one directory further down. */ - safe_close(fd); - fd = TAKE_FD(child); - } - - if (ret_path) - *ret_path = TAKE_PTR(done); - - if (ret_fd) { - /* Return the O_PATH fd we currently are looking to the caller. It can translate it to a - * proper fd by opening /proc/self/fd/xyz. */ - - assert(fd >= 0); - *ret_fd = TAKE_FD(fd); - } - - if (flags & CHASE_STEP) - return 1; - - return exists; - -chased_one: - if (ret_path) { - const char *e; - - /* todo may contain slashes at the beginning. */ - r = path_find_first_component(&todo, true, &e); - if (r < 0) - return r; - if (r == 0) - *ret_path = TAKE_PTR(done); - else { - char *c; - - c = path_join(done, e); - if (!c) - return -ENOMEM; - - *ret_path = c; - } - } - - return 0; -} - -int chase_symlinks_and_open( - const char *path, - const char *root, - unsigned chase_flags, - int open_flags, - char **ret_path) { - - _cleanup_close_ int path_fd = -1; - _cleanup_free_ char *p = NULL; - int r; - - if (chase_flags & CHASE_NONEXISTENT) - return -EINVAL; - - if (empty_or_root(root) && !ret_path && (chase_flags & (CHASE_NO_AUTOFS|CHASE_SAFE)) == 0) { - /* Shortcut this call if none of the special features of this call are requested */ - r = open(path, open_flags); - if (r < 0) - return -errno; - - return r; - } - - r = chase_symlinks(path, root, chase_flags, ret_path ? &p : NULL, &path_fd); - if (r < 0) - return r; - assert(path_fd >= 0); - - r = fd_reopen(path_fd, open_flags); - if (r < 0) - return r; - - if (ret_path) - *ret_path = TAKE_PTR(p); - - return r; -} - -int chase_symlinks_and_opendir( - const char *path, - const char *root, - unsigned chase_flags, - char **ret_path, - DIR **ret_dir) { - - char procfs_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; - _cleanup_close_ int path_fd = -1; - _cleanup_free_ char *p = NULL; - DIR *d; - int r; - - if (!ret_dir) - return -EINVAL; - if (chase_flags & CHASE_NONEXISTENT) - return -EINVAL; - - if (empty_or_root(root) && !ret_path && (chase_flags & (CHASE_NO_AUTOFS|CHASE_SAFE)) == 0) { - /* Shortcut this call if none of the special features of this call are requested */ - d = opendir(path); - if (!d) - return -errno; - - *ret_dir = d; - return 0; - } - - r = chase_symlinks(path, root, chase_flags, ret_path ? &p : NULL, &path_fd); - if (r < 0) - return r; - assert(path_fd >= 0); - - xsprintf(procfs_path, "/proc/self/fd/%i", path_fd); - d = opendir(procfs_path); - if (!d) - return -errno; - - if (ret_path) - *ret_path = TAKE_PTR(p); - - *ret_dir = d; - return 0; -} - -int chase_symlinks_and_stat( - const char *path, - const char *root, - unsigned chase_flags, - char **ret_path, - struct stat *ret_stat, - int *ret_fd) { - - _cleanup_close_ int path_fd = -1; - _cleanup_free_ char *p = NULL; - int r; - - assert(path); - assert(ret_stat); - - if (chase_flags & CHASE_NONEXISTENT) - return -EINVAL; - - if (empty_or_root(root) && !ret_path && (chase_flags & (CHASE_NO_AUTOFS|CHASE_SAFE)) == 0) { - /* Shortcut this call if none of the special features of this call are requested */ - if (stat(path, ret_stat) < 0) - return -errno; - - return 1; - } - - r = chase_symlinks(path, root, chase_flags, ret_path ? &p : NULL, &path_fd); - if (r < 0) - return r; - assert(path_fd >= 0); - - if (fstat(path_fd, ret_stat) < 0) - return -errno; - - if (ret_path) - *ret_path = TAKE_PTR(p); - if (ret_fd) - *ret_fd = TAKE_FD(path_fd); - - return 1; -} int access_fd(int fd, int mode) { - char p[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(fd) + 1]; - /* Like access() but operates on an already open fd */ - xsprintf(p, "/proc/self/fd/%i", fd); - if (access(p, mode) < 0) { + if (access(FORMAT_PROC_FD_PATH(fd), mode) < 0) { if (errno != ENOENT) return -errno; @@ -1385,115 +828,6 @@ int unlinkat_deallocate(int fd, const char *name, UnlinkDeallocateFlags flags) { return 0; } -#if 0 /* NM_IGNORED */ -int fsync_directory_of_file(int fd) { - _cleanup_free_ char *path = NULL; - _cleanup_close_ int dfd = -1; - struct stat st; - int r; - - assert(fd >= 0); - - /* We only reasonably can do this for regular files and directories, hence check for that */ - if (fstat(fd, &st) < 0) - return -errno; - - if (S_ISREG(st.st_mode)) { - - r = fd_get_path(fd, &path); - if (r < 0) { - log_debug_errno(r, "Failed to query /proc/self/fd/%d%s: %m", - fd, - r == -ENOSYS ? ", ignoring" : ""); - - if (r == -ENOSYS) - /* If /proc is not available, we're most likely running in some - * chroot environment, and syncing the directory is not very - * important in that case. Let's just silently do nothing. */ - return 0; - - return r; - } - - if (!path_is_absolute(path)) - return -EINVAL; - - dfd = open_parent(path, O_CLOEXEC|O_NOFOLLOW, 0); - if (dfd < 0) - return dfd; - - } else if (S_ISDIR(st.st_mode)) { - dfd = openat(fd, "..", O_RDONLY|O_DIRECTORY|O_CLOEXEC, 0); - if (dfd < 0) - return -errno; - } else - return -ENOTTY; - - if (fsync(dfd) < 0) - return -errno; - - return 0; -} -#endif /* NM_IGNORED */ - -int fsync_full(int fd) { - int r, q; - - /* Sync both the file and the directory */ - - r = fsync(fd) < 0 ? -errno : 0; - - q = fsync_directory_of_file(fd); - if (r < 0) /* Return earlier error */ - return r; - if (q == -ENOTTY) /* Ignore if the 'fd' refers to a block device or so which doesn't really have a - * parent dir */ - return 0; - return q; -} - -int fsync_path_at(int at_fd, const char *path) { - _cleanup_close_ int opened_fd = -1; - int fd; - - if (isempty(path)) { - if (at_fd == AT_FDCWD) { - opened_fd = open(".", O_RDONLY|O_DIRECTORY|O_CLOEXEC); - if (opened_fd < 0) - return -errno; - - fd = opened_fd; - } else - fd = at_fd; - } else { - opened_fd = openat(at_fd, path, O_RDONLY|O_CLOEXEC|O_NONBLOCK); - if (opened_fd < 0) - return -errno; - - fd = opened_fd; - } - - if (fsync(fd) < 0) - return -errno; - - return 0; -} - -int syncfs_path(int atfd, const char *path) { - _cleanup_close_ int fd = -1; - - assert(path); - - fd = openat(atfd, path, O_CLOEXEC|O_RDONLY|O_NONBLOCK); - if (fd < 0) - return -errno; - - if (syncfs(fd) < 0) - return -errno; - - return 0; -} - int open_parent(const char *path, int flags, mode_t mode) { _cleanup_free_ char *parent = NULL; int fd, r; @@ -1516,91 +850,6 @@ int open_parent(const char *path, int flags, mode_t mode) { return fd; } - -static int blockdev_is_encrypted(const char *sysfs_path, unsigned depth_left) { - _cleanup_free_ char *p = NULL, *uuids = NULL; - _cleanup_closedir_ DIR *d = NULL; - int r, found_encrypted = false; - - assert(sysfs_path); - - if (depth_left == 0) - return -EINVAL; - - p = path_join(sysfs_path, "dm/uuid"); - if (!p) - return -ENOMEM; - - r = read_one_line_file(p, &uuids); - if (r != -ENOENT) { - if (r < 0) - return r; - - /* The DM device's uuid attribute is prefixed with "CRYPT-" if this is a dm-crypt device. */ - if (startswith(uuids, "CRYPT-")) - return true; - } - - /* Not a dm-crypt device itself. But maybe it is on top of one? Follow the links in the "slaves/" - * subdir. */ - - p = mfree(p); - p = path_join(sysfs_path, "slaves"); - if (!p) - return -ENOMEM; - - d = opendir(p); - if (!d) { - if (errno == ENOENT) /* Doesn't have underlying devices */ - return false; - - return -errno; - } - - for (;;) { - _cleanup_free_ char *q = NULL; - struct dirent *de; - - errno = 0; - de = readdir_no_dot(d); - if (!de) { - if (errno != 0) - return -errno; - - break; /* No more underlying devices */ - } - - q = path_join(p, de->d_name); - if (!q) - return -ENOMEM; - - r = blockdev_is_encrypted(q, depth_left - 1); - if (r < 0) - return r; - if (r == 0) /* we found one that is not encrypted? then propagate that immediately */ - return false; - - found_encrypted = true; - } - - return found_encrypted; -} - -int path_is_encrypted(const char *path) { - char p[SYS_BLOCK_PATH_MAX(NULL)]; - dev_t devt; - int r; - - r = get_block_device(path, &devt); - if (r < 0) - return r; - if (r == 0) /* doesn't have a block device */ - return false; - - xsprintf_sys_block_path(p, NULL, devt); - - return blockdev_is_encrypted(p, 10 /* safety net: maximum recursion depth */); -} #endif /* NM_IGNORED */ int conservative_renameat( diff --git a/src/libnm-systemd-shared/src/basic/fs-util.h b/src/libnm-systemd-shared/src/basic/fs-util.h index 7bac2570..f8a7657a 100644 --- a/src/libnm-systemd-shared/src/basic/fs-util.h +++ b/src/libnm-systemd-shared/src/basic/fs-util.h @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -67,42 +66,6 @@ int var_tmp_dir(const char **ret); int unlink_or_warn(const char *filename); -#define INOTIFY_EVENT_MAX (sizeof(struct inotify_event) + NAME_MAX + 1) - -#define FOREACH_INOTIFY_EVENT(e, buffer, sz) \ - for ((e) = &buffer.ev; \ - (uint8_t*) (e) < (uint8_t*) (buffer.raw) + (sz); \ - (e) = (struct inotify_event*) ((uint8_t*) (e) + sizeof(struct inotify_event) + (e)->len)) - -union inotify_event_buffer { - struct inotify_event ev; - uint8_t raw[INOTIFY_EVENT_MAX]; -}; - -int inotify_add_watch_fd(int fd, int what, uint32_t mask); -int inotify_add_watch_and_warn(int fd, const char *pathname, uint32_t mask); - -enum { - CHASE_PREFIX_ROOT = 1 << 0, /* The specified path will be prefixed by the specified root before beginning the iteration */ - CHASE_NONEXISTENT = 1 << 1, /* It's OK if the path doesn't actually exist. */ - CHASE_NO_AUTOFS = 1 << 2, /* Return -EREMOTE if autofs mount point found */ - CHASE_SAFE = 1 << 3, /* Return -EPERM if we ever traverse from unprivileged to privileged files or directories */ - CHASE_TRAIL_SLASH = 1 << 4, /* Any trailing slash will be preserved */ - CHASE_STEP = 1 << 5, /* Just execute a single step of the normalization */ - CHASE_NOFOLLOW = 1 << 6, /* Do not follow the path's right-most component. With ret_fd, when the path's - * right-most component refers to symlink, return O_PATH fd of the symlink. */ - CHASE_WARN = 1 << 7, /* Emit an appropriate warning when an error is encountered */ -}; - -/* How many iterations to execute before returning -ELOOP */ -#define CHASE_SYMLINKS_MAX 32 - -int chase_symlinks(const char *path_with_prefix, const char *root, unsigned flags, char **ret_path, int *ret_fd); - -int chase_symlinks_and_open(const char *path, const char *root, unsigned chase_flags, int open_flags, char **ret_path); -int chase_symlinks_and_opendir(const char *path, const char *root, unsigned chase_flags, char **ret_path, DIR **ret_dir); -int chase_symlinks_and_stat(const char *path, const char *root, unsigned chase_flags, char **ret_path, struct stat *ret_stat, int *ret_fd); - /* Useful for usage with _cleanup_(), removes a directory and frees the pointer */ static inline char *rmdir_and_free(char *p) { PROTECT_ERRNO; @@ -135,16 +98,8 @@ typedef enum UnlinkDeallocateFlags { int unlinkat_deallocate(int fd, const char *name, UnlinkDeallocateFlags flags); -int fsync_directory_of_file(int fd); -int fsync_full(int fd); -int fsync_path_at(int at_fd, const char *path); - -int syncfs_path(int atfd, const char *path); - int open_parent(const char *path, int flags, mode_t mode); -int path_is_encrypted(const char *path); - int conservative_renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath); static inline int conservative_rename(const char *oldpath, const char *newpath) { return conservative_renameat(AT_FDCWD, oldpath, AT_FDCWD, newpath); diff --git a/src/libnm-systemd-shared/src/basic/hashmap.c b/src/libnm-systemd-shared/src/basic/hashmap.c index 28db939d..ee2a12e8 100644 --- a/src/libnm-systemd-shared/src/basic/hashmap.c +++ b/src/libnm-systemd-shared/src/basic/hashmap.c @@ -114,7 +114,7 @@ assert_cc(IDX_FIRST == _IDX_SWAP_END); assert_cc(IDX_FIRST == _IDX_ITERATOR_FIRST); /* Storage space for the "swap" buckets. - * All entry types can fit into a ordered_hashmap_entry. */ + * All entry types can fit into an ordered_hashmap_entry. */ struct swap_entries { struct ordered_hashmap_entry e[_IDX_SWAP_END - _IDX_SWAP_BEGIN]; }; @@ -403,7 +403,7 @@ static struct hashmap_base_entry* bucket_at_virtual(HashmapBase *h, struct swap_ if (idx < _IDX_SWAP_END) return &bucket_at_swap(swap, idx)->p.b; - assert_not_reached("Invalid index"); + assert_not_reached(); } static dib_raw_t* dib_raw_ptr(HashmapBase *h) { @@ -515,7 +515,7 @@ static void* entry_value(HashmapBase *h, struct hashmap_base_entry *e) { return (void*) e->key; default: - assert_not_reached("Unknown hashmap type"); + assert_not_reached(); } } @@ -1749,7 +1749,7 @@ HashmapBase* _hashmap_copy(HashmapBase *h HASHMAP_DEBUG_PARAMS) { r = set_merge((Set*)copy, (Set*)h); break; default: - assert_not_reached("Unknown hashmap type"); + assert_not_reached(); } if (r < 0) @@ -1763,6 +1763,9 @@ char** _hashmap_get_strv(HashmapBase *h) { Iterator i; unsigned idx, n; + if (!h) + return new0(char*, 1); + sv = new(char*, n_entries(h)+1); if (!sv) return NULL; diff --git a/src/libnm-systemd-shared/src/basic/hashmap.h b/src/libnm-systemd-shared/src/basic/hashmap.h index f7ade2e7..eafc08f6 100644 --- a/src/libnm-systemd-shared/src/basic/hashmap.h +++ b/src/libnm-systemd-shared/src/basic/hashmap.h @@ -224,7 +224,7 @@ static inline int ordered_hashmap_remove_and_replace(OrderedHashmap *h, const vo return hashmap_remove_and_replace(PLAIN_HASHMAP(h), old_key, new_key, value); } -/* Since merging data from a OrderedHashmap into a Hashmap or vice-versa +/* Since merging data from an OrderedHashmap into a Hashmap or vice-versa * should just work, allow this by having looser type-checking here. */ int _hashmap_merge(Hashmap *h, Hashmap *other); #define hashmap_merge(h, other) _hashmap_merge(PLAIN_HASHMAP(h), PLAIN_HASHMAP(other)) diff --git a/src/libnm-systemd-shared/src/basic/hexdecoct.c b/src/libnm-systemd-shared/src/basic/hexdecoct.c index 6eb9343f..381e79ba 100644 --- a/src/libnm-systemd-shared/src/basic/hexdecoct.c +++ b/src/libnm-systemd-shared/src/basic/hexdecoct.c @@ -530,6 +530,16 @@ char base64char(int x) { } #endif /* NM_IGNORED */ +/* This is almost base64char(), but not entirely, as it uses the "url and filename safe" alphabet, + * since we don't want "/" appear in interface names (since interfaces appear in sysfs as filenames). + * See section #5 of RFC 4648. */ +char urlsafe_base64char(int x) { + static const char table[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789-_"; + return table[x & 63]; +} + int unbase64char(char c) { unsigned offset; @@ -560,38 +570,79 @@ int unbase64char(char c) { } #if 0 /* NM_IGNORED */ -ssize_t base64mem(const void *p, size_t l, char **out) { - char *r, *z; +static void maybe_line_break(char **x, char *start, size_t line_break) { + size_t n; + + assert(x); + assert(*x); + assert(start); + assert(*x >= start); + + if (line_break == SIZE_MAX) + return; + + n = *x - start; + + if (n % (line_break + 1) == line_break) + *((*x)++) = '\n'; +} + +ssize_t base64mem_full( + const void *p, + size_t l, + size_t line_break, + char **out) { + const uint8_t *x; + char *r, *z; + size_t m; assert(p || l == 0); assert(out); + assert(line_break > 0); /* three input bytes makes four output bytes, padding is added so we must round up */ - z = r = malloc(4 * (l + 2) / 3 + 1); + m = 4 * (l + 2) / 3 + 1; + + if (line_break != SIZE_MAX) + m += m / line_break; + + z = r = malloc(m); if (!r) return -ENOMEM; for (x = p; x < (const uint8_t*) p + (l / 3) * 3; x += 3) { /* x[0] == XXXXXXXX; x[1] == YYYYYYYY; x[2] == ZZZZZZZZ */ + maybe_line_break(&z, r, line_break); *(z++) = base64char(x[0] >> 2); /* 00XXXXXX */ + maybe_line_break(&z, r, line_break); *(z++) = base64char((x[0] & 3) << 4 | x[1] >> 4); /* 00XXYYYY */ + maybe_line_break(&z, r, line_break); *(z++) = base64char((x[1] & 15) << 2 | x[2] >> 6); /* 00YYYYZZ */ + maybe_line_break(&z, r, line_break); *(z++) = base64char(x[2] & 63); /* 00ZZZZZZ */ } switch (l % 3) { case 2: + maybe_line_break(&z, r, line_break); *(z++) = base64char(x[0] >> 2); /* 00XXXXXX */ + maybe_line_break(&z, r, line_break); *(z++) = base64char((x[0] & 3) << 4 | x[1] >> 4); /* 00XXYYYY */ + maybe_line_break(&z, r, line_break); *(z++) = base64char((x[1] & 15) << 2); /* 00YYYY00 */ + maybe_line_break(&z, r, line_break); *(z++) = '='; break; case 1: + maybe_line_break(&z, r, line_break); *(z++) = base64char(x[0] >> 2); /* 00XXXXXX */ + maybe_line_break(&z, r, line_break); *(z++) = base64char((x[0] & 3) << 4); /* 00XX0000 */ + maybe_line_break(&z, r, line_break); *(z++) = '='; + maybe_line_break(&z, r, line_break); *(z++) = '='; break; @@ -599,6 +650,7 @@ ssize_t base64mem(const void *p, size_t l, char **out) { *z = 0; *out = r; + assert(z >= r); /* Let static analyzers know that the answer is non-negative. */ return z - r; } diff --git a/src/libnm-systemd-shared/src/basic/hexdecoct.h b/src/libnm-systemd-shared/src/basic/hexdecoct.h index 7e2a6892..5218f786 100644 --- a/src/libnm-systemd-shared/src/basic/hexdecoct.h +++ b/src/libnm-systemd-shared/src/basic/hexdecoct.h @@ -27,12 +27,17 @@ char base32hexchar(int x) _const_; int unbase32hexchar(char c) _const_; char base64char(int x) _const_; +char urlsafe_base64char(int x) _const_; int unbase64char(char c) _const_; char *base32hexmem(const void *p, size_t l, bool padding); int unbase32hexmem(const char *p, size_t l, bool padding, void **mem, size_t *len); -ssize_t base64mem(const void *p, size_t l, char **out); +ssize_t base64mem_full(const void *p, size_t l, size_t line_break, char **ret); +static inline ssize_t base64mem(const void *p, size_t l, char **ret) { + return base64mem_full(p, l, SIZE_MAX, ret); +} + int base64_append(char **prefix, int plen, const void *p, size_t l, int margin, int width); diff --git a/src/libnm-systemd-shared/src/basic/hostname-util.c b/src/libnm-systemd-shared/src/basic/hostname-util.c index 8f7679b6..3063cc7c 100644 --- a/src/libnm-systemd-shared/src/basic/hostname-util.c +++ b/src/libnm-systemd-shared/src/basic/hostname-util.c @@ -39,69 +39,42 @@ char* get_default_hostname(void) { return strdup(FALLBACK_HOSTNAME); } -char* gethostname_malloc(void) { +int gethostname_full(GetHostnameFlags flags, char **ret) { + _cleanup_free_ char *buf = NULL, *fallback = NULL; struct utsname u; const char *s; - /* This call tries to return something useful, either the actual hostname - * or it makes something up. The only reason it might fail is OOM. - * It might even return "localhost" if that's set. */ + assert(ret); assert_se(uname(&u) >= 0); s = u.nodename; - if (isempty(s) || streq(s, "(none)")) - return get_default_hostname(); - - return strdup(s); -} - -char* gethostname_short_malloc(void) { - struct utsname u; - const char *s; - _cleanup_free_ char *f = NULL; - - /* Like above, but kills the FQDN part if present. */ - - assert_se(uname(&u) >= 0); - - s = u.nodename; - if (isempty(s) || streq(s, "(none)") || s[0] == '.') { - s = f = get_default_hostname(); + if (isempty(s) || + (!FLAGS_SET(flags, GET_HOSTNAME_ALLOW_NONE) && streq(s, "(none)")) || + (!FLAGS_SET(flags, GET_HOSTNAME_ALLOW_LOCALHOST) && is_localhost(s)) || + (FLAGS_SET(flags, GET_HOSTNAME_SHORT) && s[0] == '.')) { + if (!FLAGS_SET(flags, GET_HOSTNAME_FALLBACK_DEFAULT)) + return -ENXIO; + + s = fallback = get_default_hostname(); if (!s) - return NULL; + return -ENOMEM; - assert(s[0] != '.'); + if (FLAGS_SET(flags, GET_HOSTNAME_SHORT) && s[0] == '.') + return -ENXIO; } - return strndup(s, strcspn(s, ".")); -} -#endif /* NM_IGNORED */ - -int gethostname_strict(char **ret) { - struct utsname u; - char *k; - - /* This call will rather fail than make up a name. It will not return "localhost" either. */ - - assert_se(uname(&u) >= 0); - - if (isempty(u.nodename)) - return -ENXIO; - - if (streq(u.nodename, "(none)")) - return -ENXIO; - - if (is_localhost(u.nodename)) - return -ENXIO; - - k = strdup(u.nodename); - if (!k) + if (FLAGS_SET(flags, GET_HOSTNAME_SHORT)) + buf = strndup(s, strcspn(s, ".")); + else + buf = strdup(s); + if (!buf) return -ENOMEM; - *ret = k; + *ret = TAKE_PTR(buf); return 0; } +#endif /* NM_IGNORED */ bool valid_ldh_char(char c) { /* "LDH" → "Letters, digits, hyphens", as per RFC 5890, Section 2.3.1 */ @@ -168,6 +141,7 @@ bool hostname_is_valid(const char *s, ValidHostnameFlags flags) { return true; } +#if 0 /* NM_IGNORED */ char* hostname_cleanup(char *s) { char *p, *d; bool dot, hyphen; @@ -205,6 +179,7 @@ char* hostname_cleanup(char *s) { return s; } +#endif /* NM_IGNORED */ bool is_localhost(const char *hostname) { assert(hostname); diff --git a/src/libnm-systemd-shared/src/basic/hostname-util.h b/src/libnm-systemd-shared/src/basic/hostname-util.h index c3fc6752..0d1574db 100644 --- a/src/libnm-systemd-shared/src/basic/hostname-util.h +++ b/src/libnm-systemd-shared/src/basic/hostname-util.h @@ -4,13 +4,41 @@ #include #include +#include "env-file.h" #include "macro.h" #include "strv.h" +typedef enum GetHostnameFlags { + GET_HOSTNAME_ALLOW_NONE = 1 << 0, /* accepts "(none)". */ + GET_HOSTNAME_ALLOW_LOCALHOST = 1 << 1, /* accepts "localhost" or friends. */ + GET_HOSTNAME_FALLBACK_DEFAULT = 1 << 2, /* use default hostname if no hostname is set. */ + GET_HOSTNAME_SHORT = 1 << 3, /* kills the FQDN part if present. */ +} GetHostnameFlags; + +int gethostname_full(GetHostnameFlags flags, char **ret); +static inline int gethostname_strict(char **ret) { + return gethostname_full(0, ret); +} + +static inline char* gethostname_malloc(void) { + char *s; + + if (gethostname_full(GET_HOSTNAME_ALLOW_LOCALHOST | GET_HOSTNAME_FALLBACK_DEFAULT, &s) < 0) + return NULL; + + return s; +} + +static inline char* gethostname_short_malloc(void) { + char *s; + + if (gethostname_full(GET_HOSTNAME_ALLOW_LOCALHOST | GET_HOSTNAME_FALLBACK_DEFAULT | GET_HOSTNAME_SHORT, &s) < 0) + return NULL; + + return s; +} + char* get_default_hostname(void); -char* gethostname_malloc(void); -char* gethostname_short_malloc(void); -int gethostname_strict(char **ret); bool valid_ldh_char(char c) _const_; @@ -33,3 +61,7 @@ static inline bool is_outbound_hostname(const char *hostname) { /* This tries to identify the valid syntaxes for the our synthetic "outbound" host. */ return STRCASE_IN_SET(hostname, "_outbound", "_outbound."); } + +static inline int get_pretty_hostname(char **ret) { + return parse_env_file(NULL, "/etc/machine-info", "PRETTY_HOSTNAME", ret); +} diff --git a/src/libnm-systemd-shared/src/basic/in-addr-util.c b/src/libnm-systemd-shared/src/basic/in-addr-util.c index 18c44cf1..bd4dd8fc 100644 --- a/src/libnm-systemd-shared/src/basic/in-addr-util.c +++ b/src/libnm-systemd-shared/src/basic/in-addr-util.c @@ -123,6 +123,12 @@ int in_addr_is_localhost(int family, const union in_addr_union *u) { return -EAFNOSUPPORT; } +bool in6_addr_is_ipv4_mapped_address(const struct in6_addr *a) { + return a->s6_addr32[0] == 0 && + a->s6_addr32[1] == 0 && + a->s6_addr32[2] == htobe32(UINT32_C(0x0000ffff)); +} + bool in4_addr_equal(const struct in_addr *a, const struct in_addr *b) { assert(a); assert(b); @@ -797,7 +803,7 @@ int in_addr_prefix_from_string_auto_internal( k = 0; break; default: - assert_not_reached("Invalid prefixlen mode"); + assert_not_reached(); } if (ret_family) @@ -834,35 +840,6 @@ static int in_addr_data_compare_func(const struct in_addr_data *x, const struct DEFINE_HASH_OPS(in_addr_data_hash_ops, struct in_addr_data, in_addr_data_hash_func, in_addr_data_compare_func); -static void in_addr_prefix_hash_func(const struct in_addr_prefix *a, struct siphash *state) { - assert(a); - assert(state); - - siphash24_compress(&a->family, sizeof(a->family), state); - siphash24_compress(&a->prefixlen, sizeof(a->prefixlen), state); - siphash24_compress(&a->address, FAMILY_ADDRESS_SIZE(a->family), state); -} - -static int in_addr_prefix_compare_func(const struct in_addr_prefix *x, const struct in_addr_prefix *y) { - int r; - - assert(x); - assert(y); - - r = CMP(x->family, y->family); - if (r != 0) - return r; - - r = CMP(x->prefixlen, y->prefixlen); - if (r != 0) - return r; - - return memcmp(&x->address, &y->address, FAMILY_ADDRESS_SIZE(x->family)); -} - -DEFINE_HASH_OPS(in_addr_prefix_hash_ops, struct in_addr_prefix, in_addr_prefix_hash_func, in_addr_prefix_compare_func); -DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(in_addr_prefix_hash_ops_free, struct in_addr_prefix, in_addr_prefix_hash_func, in_addr_prefix_compare_func, free); - void in6_addr_hash_func(const struct in6_addr *addr, struct siphash *state) { assert(addr); assert(state); diff --git a/src/libnm-systemd-shared/src/basic/in-addr-util.h b/src/libnm-systemd-shared/src/basic/in-addr-util.h index 906b3fe9..c74b0d51 100644 --- a/src/libnm-systemd-shared/src/basic/in-addr-util.h +++ b/src/libnm-systemd-shared/src/basic/in-addr-util.h @@ -20,12 +20,6 @@ struct in_addr_data { union in_addr_union address; }; -struct in_addr_prefix { - int family; - uint8_t prefixlen; - union in_addr_union address; -}; - bool in4_addr_is_null(const struct in_addr *a); static inline bool in4_addr_is_set(const struct in_addr *a) { return !in4_addr_is_null(a); @@ -58,6 +52,7 @@ int in_addr_is_localhost(int family, const union in_addr_union *u); bool in4_addr_is_local_multicast(const struct in_addr *a); bool in4_addr_is_non_local(const struct in_addr *a); +bool in6_addr_is_ipv4_mapped_address(const struct in6_addr *a); bool in4_addr_equal(const struct in_addr *a, const struct in_addr *b); bool in6_addr_equal(const struct in6_addr *a, const struct in6_addr *b); @@ -123,8 +118,6 @@ void in6_addr_hash_func(const struct in6_addr *addr, struct siphash *state); int in6_addr_compare_func(const struct in6_addr *a, const struct in6_addr *b); extern const struct hash_ops in_addr_data_hash_ops; -extern const struct hash_ops in_addr_prefix_hash_ops; -extern const struct hash_ops in_addr_prefix_hash_ops_free; extern const struct hash_ops in6_addr_hash_ops; #define IPV4_ADDRESS_FMT_STR "%u.%u.%u.%u" diff --git a/src/libnm-systemd-shared/src/basic/inotify-util.c b/src/libnm-systemd-shared/src/basic/inotify-util.c new file mode 100644 index 00000000..cc2a92ad --- /dev/null +++ b/src/libnm-systemd-shared/src/basic/inotify-util.c @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include "nm-sd-adapt-shared.h" + +#include "fd-util.h" +#include "inotify-util.h" + +int inotify_add_watch_fd(int fd, int what, uint32_t mask) { + int wd; + + /* This is like inotify_add_watch(), except that the file to watch is not referenced by a path, but by an fd */ + wd = inotify_add_watch(fd, FORMAT_PROC_FD_PATH(what), mask); + if (wd < 0) + return -errno; + + return wd; +} + +int inotify_add_watch_and_warn(int fd, const char *pathname, uint32_t mask) { + int wd; + + wd = inotify_add_watch(fd, pathname, mask); + if (wd < 0) { + if (errno == ENOSPC) + return log_error_errno(errno, "Failed to add a watch for %s: inotify watch limit reached", pathname); + + return log_error_errno(errno, "Failed to add a watch for %s: %m", pathname); + } + + return wd; +} diff --git a/src/libnm-systemd-shared/src/basic/inotify-util.h b/src/libnm-systemd-shared/src/basic/inotify-util.h new file mode 100644 index 00000000..88af0868 --- /dev/null +++ b/src/libnm-systemd-shared/src/basic/inotify-util.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include +#include +#include +#include + +#define INOTIFY_EVENT_MAX (offsetof(struct inotify_event, name) + NAME_MAX + 1) + +#define FOREACH_INOTIFY_EVENT(e, buffer, sz) \ + for ((e) = &buffer.ev; \ + (uint8_t*) (e) < (uint8_t*) (buffer.raw) + (sz); \ + (e) = (struct inotify_event*) ((uint8_t*) (e) + sizeof(struct inotify_event) + (e)->len)) + +union inotify_event_buffer { + struct inotify_event ev; + uint8_t raw[INOTIFY_EVENT_MAX]; +}; + +int inotify_add_watch_fd(int fd, int what, uint32_t mask); +int inotify_add_watch_and_warn(int fd, const char *pathname, uint32_t mask); diff --git a/src/libnm-systemd-shared/src/basic/list.h b/src/libnm-systemd-shared/src/basic/list.h index 256b7187..e488fff9 100644 --- a/src/libnm-systemd-shared/src/basic/list.h +++ b/src/libnm-systemd-shared/src/basic/list.h @@ -142,11 +142,8 @@ #define LIST_FOREACH_SAFE(name,i,n,head) \ for ((i) = (head); (i) && (((n) = (i)->name##_next), 1); (i) = (n)) -#define LIST_FOREACH_BEFORE(name,i,p) \ - for ((i) = (p)->name##_prev; (i); (i) = (i)->name##_prev) - -#define LIST_FOREACH_AFTER(name,i,p) \ - for ((i) = (p)->name##_next; (i); (i) = (i)->name##_next) +#define LIST_FOREACH_BACKWARDS(name,i,p) \ + for ((i) = (p); (i); (i) = (i)->name##_prev) /* Iterate through all the members of the list p is included in, but skip over p */ #define LIST_FOREACH_OTHERS(name,i,p) \ diff --git a/src/libnm-systemd-shared/src/basic/log.h b/src/libnm-systemd-shared/src/basic/log.h index 9ed01698..b11eac21 100644 --- a/src/libnm-systemd-shared/src/basic/log.h +++ b/src/libnm-systemd-shared/src/basic/log.h @@ -32,6 +32,15 @@ typedef enum LogTarget{ #define IS_SYNTHETIC_ERRNO(val) ((val) >> 30 & 1) #define ERRNO_VALUE(val) (abs(val) & 255) +/* The callback function to be invoked when syntax warnings are seen + * in the unit files. */ +typedef void (*log_syntax_callback_t)(const char *unit, int level, void *userdata); +void set_log_syntax_callback(log_syntax_callback_t cb, void *userdata); + +static inline void clear_log_syntax_callback(dummy_t *dummy) { + set_log_syntax_callback(/* cb= */ NULL, /* userdata= */ NULL); +} + const char *log_target_to_string(LogTarget target) _const_; LogTarget log_target_from_string(const char *s) _pure_; void log_set_target(LogTarget target); @@ -273,26 +282,24 @@ _noreturn_ void log_assert_failed( #if 0 /* NM_IGNORED */ _noreturn_ void log_assert_failed_unreachable( - const char *text, const char *file, int line, const char *func); #else /* NM_IGNORED */ -#define log_assert_failed_unreachable(text, file, line, func) \ - G_STMT_START \ - { \ - log_internal(LOG_CRIT, \ - 0, \ - file, \ - line, \ - func, \ - "Code should not be reached '%s' at %s:%u, function %s(). Aborting.", \ - text, \ - file, \ - line, \ - func); \ - g_assert_not_reached(); \ - } \ +#define log_assert_failed_unreachable(file, line, func) \ + G_STMT_START \ + { \ + log_internal(LOG_CRIT, \ + 0, \ + file, \ + line, \ + func, \ + "Code should not be reached at %s:%u, function %s(). Aborting.", \ + file, \ + line, \ + func); \ + g_assert_not_reached(); \ + } \ G_STMT_END #endif /* NM_IGNORED */ diff --git a/src/libnm-systemd-shared/src/basic/macro.h b/src/libnm-systemd-shared/src/basic/macro.h index b0852ce5..33d28332 100644 --- a/src/libnm-systemd-shared/src/basic/macro.h +++ b/src/libnm-systemd-shared/src/basic/macro.h @@ -20,30 +20,14 @@ #define _sentinel_ __attribute__((__sentinel__)) #define _destructor_ __attribute__((__destructor__)) #define _deprecated_ __attribute__((__deprecated__)) -#define _packed_ __attribute__((__packed__)) #define _malloc_ __attribute__((__malloc__)) #define _weak_ __attribute__((__weak__)) -#define _likely_(x) (__builtin_expect(!!(x), 1)) -#define _unlikely_(x) (__builtin_expect(!!(x), 0)) #define _public_ __attribute__((__visibility__("default"))) #define _hidden_ __attribute__((__visibility__("hidden"))) #define _weakref_(x) __attribute__((__weakref__(#x))) #define _alignas_(x) __attribute__((__aligned__(__alignof(x)))) #define _alignptr_ __attribute__((__aligned__(sizeof(void*)))) -#if __GNUC__ >= 7 -#define _fallthrough_ __attribute__((__fallthrough__)) -#else -#define _fallthrough_ -#endif -/* Define C11 noreturn without and even on older gcc - * compiler versions */ -#ifndef _noreturn_ -#if __STDC_VERSION__ >= 201112L -#define _noreturn_ _Noreturn -#else -#define _noreturn_ __attribute__((__noreturn__)) -#endif -#endif +#define _warn_unused_result_ __attribute__((__warn_unused_result__)) #if !defined(HAS_FEATURE_MEMORY_SANITIZER) # if defined(__has_feature) @@ -171,6 +155,20 @@ #define ALIGN8_PTR(p) ((void*) ALIGN8((unsigned long) (p))) static inline size_t ALIGN_TO(size_t l, size_t ali) { + /* Check that alignment is exponent of 2 */ +#if SIZE_MAX == UINT_MAX + assert(__builtin_popcount(ali) == 1); +#elif SIZE_MAX == ULONG_MAX + assert(__builtin_popcountl(ali) == 1); +#elif SIZE_MAX == ULLONG_MAX + assert(__builtin_popcountll(ali) == 1); +#else +#error "Unexpected size_t" +#endif + + if (l > SIZE_MAX - (ali - 1)) + return SIZE_MAX; /* indicate overflow */ + return ((l + ali - 1) & ~(ali - 1)); } @@ -217,13 +215,6 @@ static inline size_t GREEDY_ALLOC_ROUND_UP(size_t l) { return m; } -/* - * STRLEN - return the length of a string literal, minus the trailing NUL byte. - * Contrary to strlen(), this is a constant expression. - * @x: a string literal. - */ -#define STRLEN(x) (sizeof(""x"") - 1) - /* * container_of - cast a member of a structure out to the containing structure * @ptr: the pointer to the member. @@ -290,8 +281,8 @@ static inline int __coverity_check_and_return__(int condition) { #define assert(expr) assert_message_se(expr, #expr) #endif -#define assert_not_reached(t) \ - log_assert_failed_unreachable(t, PROJECT_FILE, __LINE__, __PRETTY_FUNCTION__) +#define assert_not_reached() \ + log_assert_failed_unreachable(PROJECT_FILE, __LINE__, __PRETTY_FUNCTION__) #define assert_return(expr, r) \ do { \ @@ -350,15 +341,15 @@ static inline int __coverity_check_and_return__(int condition) { * negative '-' prefix (hence works correctly on signed * types). Includes space for the trailing NUL. */ #define DECIMAL_STR_MAX(type) \ - (2+(sizeof(type) <= 1 ? 3 : \ - sizeof(type) <= 2 ? 5 : \ - sizeof(type) <= 4 ? 10 : \ - sizeof(type) <= 8 ? 20 : sizeof(int[-2*(sizeof(type) > 8)]))) + (2U+(sizeof(type) <= 1 ? 3U : \ + sizeof(type) <= 2 ? 5U : \ + sizeof(type) <= 4 ? 10U : \ + sizeof(type) <= 8 ? 20U : sizeof(int[-2*(sizeof(type) > 8)]))) #define DECIMAL_STR_WIDTH(x) \ ({ \ typeof(x) _x_ = (x); \ - unsigned ans = 1; \ + size_t ans = 1; \ while ((_x_ /= 10) != 0) \ ans++; \ ans; \ @@ -491,4 +482,10 @@ static inline size_t size_add(size_t x, size_t y) { return y >= SIZE_MAX - x ? SIZE_MAX : x + y; } +typedef struct { + int _empty[0]; +} dummy_t; + +assert_cc(sizeof(dummy_t) == 0); + #include "log.h" diff --git a/src/libnm-systemd-shared/src/basic/memory-util.c b/src/libnm-systemd-shared/src/basic/memory-util.c index 7ee7c94e..2d41a26a 100644 --- a/src/libnm-systemd-shared/src/basic/memory-util.c +++ b/src/libnm-systemd-shared/src/basic/memory-util.c @@ -20,26 +20,25 @@ size_t page_size(void) { return pgsz; } -bool memeqzero(const void *data, size_t length) { - /* Does the buffer consist entirely of NULs? +bool memeqbyte(uint8_t byte, const void *data, size_t length) { + /* Does the buffer consist entirely of the same specific byte value? * Copied from https://github.com/systemd/casync/, copied in turn from * https://github.com/rustyrussell/ccan/blob/master/ccan/mem/mem.c#L92, * which is licensed CC-0. */ const uint8_t *p = data; - size_t i; /* Check first 16 bytes manually */ - for (i = 0; i < 16; i++, length--) { + for (size_t i = 0; i < 16; i++, length--) { if (length == 0) return true; - if (p[i]) + if (p[i] != byte) return false; } - /* Now we know first 16 bytes are NUL, memcmp with self. */ - return memcmp(data, p + i, length) == 0; + /* Now we know first 16 bytes match, memcmp() with self. */ + return memcmp(data, p + 16, length) == 0; } #if !HAVE_EXPLICIT_BZERO diff --git a/src/libnm-systemd-shared/src/basic/memory-util.h b/src/libnm-systemd-shared/src/basic/memory-util.h index 0b04278a..9f37431f 100644 --- a/src/libnm-systemd-shared/src/basic/memory-util.h +++ b/src/libnm-systemd-shared/src/basic/memory-util.h @@ -47,7 +47,9 @@ static inline int memcmp_nn(const void *s1, size_t n1, const void *s2, size_t n2 #define zero(x) (memzero(&(x), sizeof(x))) -bool memeqzero(const void *data, size_t length); +bool memeqbyte(uint8_t byte, const void *data, size_t length); + +#define memeqzero(data, length) memeqbyte(0x00, data, length) #define eqzero(x) memeqzero(x, sizeof(x)) @@ -71,6 +73,16 @@ static inline void *memmem_safe(const void *haystack, size_t haystacklen, const return memmem(haystack, haystacklen, needle, needlelen); } +static inline void *mempmem_safe(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen) { + const uint8_t *p; + + p = memmem_safe(haystack, haystacklen, needle, needlelen); + if (!p) + return NULL; + + return (uint8_t*) p + needlelen; +} + #if HAVE_EXPLICIT_BZERO static inline void* explicit_bzero_safe(void *p, size_t l) { if (l > 0) diff --git a/src/libnm-systemd-shared/src/basic/missing_syscall.h b/src/libnm-systemd-shared/src/basic/missing_syscall.h index ac3cab29..aeb994f0 100644 --- a/src/libnm-systemd-shared/src/basic/missing_syscall.h +++ b/src/libnm-systemd-shared/src/basic/missing_syscall.h @@ -43,6 +43,26 @@ static inline int missing_pivot_root(const char *new_root, const char *put_old) /* ======================================================================= */ +#if !HAVE_IOPRIO_GET +static inline int missing_ioprio_get(int which, int who) { + return syscall(__NR_ioprio_get, which, who); +} + +# define ioprio_get missing_ioprio_get +#endif + +/* ======================================================================= */ + +#if !HAVE_IOPRIO_SET +static inline int missing_ioprio_set(int which, int who, int ioprio) { + return syscall(__NR_ioprio_set, which, who, ioprio); +} + +# define ioprio_set missing_ioprio_set +#endif + +/* ======================================================================= */ + #if !HAVE_MEMFD_CREATE static inline int missing_memfd_create(const char *name, unsigned int flags) { # ifdef __NR_memfd_create diff --git a/src/libnm-systemd-shared/src/basic/parse-util.c b/src/libnm-systemd-shared/src/basic/parse-util.c index 13758108..f81bf1da 100644 --- a/src/libnm-systemd-shared/src/basic/parse-util.c +++ b/src/libnm-systemd-shared/src/basic/parse-util.c @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -738,7 +737,7 @@ int parse_oom_score_adjust(const char *s, int *ret) { if (r < 0) return r; - if (v < OOM_SCORE_ADJ_MIN || v > OOM_SCORE_ADJ_MAX) + if (!oom_score_adjust_is_valid(v)) return -ERANGE; *ret = v; @@ -748,13 +747,13 @@ int parse_oom_score_adjust(const char *s, int *ret) { int store_loadavg_fixed_point(unsigned long i, unsigned long f, loadavg_t *ret) { assert(ret); - if (i >= (~0UL << FSHIFT)) + if (i >= (~0UL << LOADAVG_PRECISION_BITS)) return -ERANGE; - i = i << FSHIFT; - f = DIV_ROUND_UP((f << FSHIFT), 100); + i = i << LOADAVG_PRECISION_BITS; + f = DIV_ROUND_UP((f << LOADAVG_PRECISION_BITS), 100); - if (f >= FIXED_1) + if (f >= LOADAVG_FIXED_POINT_1_0) return -ERANGE; *ret = i | f; diff --git a/src/libnm-systemd-shared/src/basic/parse-util.h b/src/libnm-systemd-shared/src/basic/parse-util.h index 16542769..3dc5e140 100644 --- a/src/libnm-systemd-shared/src/basic/parse-util.h +++ b/src/libnm-systemd-shared/src/basic/parse-util.h @@ -3,9 +3,6 @@ #include #include -#if 0 /* NM_IGNORED */ -#include -#endif /* NM_IGNORED */ #include #include #include @@ -138,6 +135,14 @@ int parse_ip_prefix_length(const char *s, int *ret); int parse_oom_score_adjust(const char *s, int *ret); +/* Implement floating point using fixed integers, to improve performance when + * calculating load averages. These macros can be used to extract the integer + * and decimal parts of a value. */ +#define LOADAVG_PRECISION_BITS 11 +#define LOADAVG_FIXED_POINT_1_0 (1 << LOADAVG_PRECISION_BITS) +#define LOADAVG_INT_SIDE(x) ((x) >> LOADAVG_PRECISION_BITS) +#define LOADAVG_DECIMAL_SIDE(x) LOADAVG_INT_SIDE(((x) & (LOADAVG_FIXED_POINT_1_0 - 1)) * 100) + /* Given a Linux load average (e.g. decimal number 34.89 where 34 is passed as i and 89 is passed as f), convert it * to a loadavg_t. */ int store_loadavg_fixed_point(unsigned long i, unsigned long f, loadavg_t *ret); diff --git a/src/libnm-systemd-shared/src/basic/path-util.c b/src/libnm-systemd-shared/src/basic/path-util.c index 55e4d317..92c55048 100644 --- a/src/libnm-systemd-shared/src/basic/path-util.c +++ b/src/libnm-systemd-shared/src/basic/path-util.c @@ -15,6 +15,7 @@ #undef basename #include "alloc-util.h" +#include "chase-symlinks.h" #include "extract-word.h" #include "fd-util.h" #include "fs-util.h" @@ -472,8 +473,10 @@ char *path_startswith_full(const char *path, const char *prefix, bool accept_dot int path_compare(const char *a, const char *b) { int r; - assert(a); - assert(b); + /* Order NULL before non-NULL */ + r = CMP(!!a, !!b); + if (r != 0) + return r; /* A relative path and an absolute path must not compare as equal. * Which one is sorted before the other does not really matter. @@ -520,15 +523,9 @@ int path_compare(const char *a, const char *b) { } } -bool path_equal(const char *a, const char *b) { - return path_compare(a, b) == 0; -} - -#if 0 /* NM_IGNORED */ bool path_equal_or_files_same(const char *a, const char *b, int flags) { return path_equal(a, b) || files_same(a, b, flags) > 0; } -#endif /* NM_IGNORED */ bool path_equal_filename(const char *a, const char *b) { _cleanup_free_ char *a_basename = NULL, *b_basename = NULL; @@ -641,7 +638,11 @@ static int check_x_access(const char *path, int *ret_fd) { return r; r = access_fd(fd, X_OK); - if (r < 0) + if (r == -ENOSYS) { + /* /proc is not mounted. Fallback to access(). */ + if (access(path, X_OK) < 0) + return -errno; + } else if (r < 0) return r; if (ret_fd) @@ -650,31 +651,54 @@ static int check_x_access(const char *path, int *ret_fd) { return 0; } -int find_executable_full(const char *name, bool use_path_envvar, char **ret_filename, int *ret_fd) { - int last_error, r; - const char *p = NULL; +static int find_executable_impl(const char *name, const char *root, char **ret_filename, int *ret_fd) { + _cleanup_close_ int fd = -1; + _cleanup_free_ char *path_name = NULL; + int r; assert(name); - if (is_path(name)) { - _cleanup_close_ int fd = -1; - - r = check_x_access(name, ret_fd ? &fd : NULL); + /* Function chase_symlinks() is invoked only when root is not NULL, as using it regardless of + * root value would alter the behavior of existing callers for example: /bin/sleep would become + * /usr/bin/sleep when find_executables is called. Hence, this function should be invoked when + * needed to avoid unforeseen regression or other complicated changes. */ + if (root) { + r = chase_symlinks(name, + root, + CHASE_PREFIX_ROOT, + &path_name, + /* ret_fd= */ NULL); /* prefix root to name in case full paths are not specified */ if (r < 0) return r; - if (ret_filename) { - r = path_make_absolute_cwd(name, ret_filename); - if (r < 0) - return r; - } + name = path_name; + } - if (ret_fd) - *ret_fd = TAKE_FD(fd); + r = check_x_access(name, ret_fd ? &fd : NULL); + if (r < 0) + return r; - return 0; + if (ret_filename) { + r = path_make_absolute_cwd(name, ret_filename); + if (r < 0) + return r; } + if (ret_fd) + *ret_fd = TAKE_FD(fd); + + return 0; +} + +int find_executable_full(const char *name, const char *root, char **exec_search_path, bool use_path_envvar, char **ret_filename, int *ret_fd) { + int last_error = -ENOENT, r = 0; + const char *p = NULL; + + assert(name); + + if (is_path(name)) + return find_executable_impl(name, root, ret_filename, ret_fd); + if (use_path_envvar) /* Plain getenv, not secure_getenv, because we want to actually allow the user to pick the * binary. */ @@ -682,12 +706,31 @@ int find_executable_full(const char *name, bool use_path_envvar, char **ret_file if (!p) p = DEFAULT_PATH; - last_error = -ENOENT; + if (exec_search_path) { + char **element; + + STRV_FOREACH(element, exec_search_path) { + _cleanup_free_ char *full_path = NULL; + if (!path_is_absolute(*element)) + continue; + full_path = path_join(*element, name); + if (!full_path) + return -ENOMEM; + + r = find_executable_impl(full_path, root, ret_filename, ret_fd); + if (r < 0) { + if (r != -EACCES) + last_error = r; + continue; + } + return 0; + } + return last_error; + } /* Resolve a single-component name to a full path */ for (;;) { _cleanup_free_ char *element = NULL; - _cleanup_close_ int fd = -1; r = extract_first_word(&p, &element, ":", EXTRACT_RELAX|EXTRACT_DONT_COALESCE_SEPARATORS); if (r < 0) @@ -701,7 +744,7 @@ int find_executable_full(const char *name, bool use_path_envvar, char **ret_file if (!path_extend(&element, name)) return -ENOMEM; - r = check_x_access(element, ret_fd ? &fd : NULL); + r = find_executable_impl(element, root, ret_filename, ret_fd); if (r < 0) { /* PATH entries which we don't have access to are ignored, as per tradition. */ if (r != -EACCES) @@ -710,11 +753,6 @@ int find_executable_full(const char *name, bool use_path_envvar, char **ret_file } /* Found it! */ - if (ret_filename) - *ret_filename = path_simplify(TAKE_PTR(element)); - if (ret_fd) - *ret_fd = TAKE_FD(fd); - return 0; } @@ -722,7 +760,7 @@ int find_executable_full(const char *name, bool use_path_envvar, char **ret_file } bool paths_check_timestamp(const char* const* paths, usec_t *timestamp, bool update) { - bool changed = false; + bool changed = false, originally_unset; const char* const* i; assert(timestamp); @@ -730,6 +768,8 @@ bool paths_check_timestamp(const char* const* paths, usec_t *timestamp, bool upd if (!paths) return false; + originally_unset = *timestamp == 0; + STRV_FOREACH(i, paths) { struct stat stats; usec_t u; @@ -739,11 +779,11 @@ bool paths_check_timestamp(const char* const* paths, usec_t *timestamp, bool upd u = timespec_load(&stats.st_mtim); - /* first check */ + /* check first */ if (*timestamp >= u) continue; - log_debug("timestamp of '%s' changed", *i); + log_debug(originally_unset ? "Loaded timestamp for '%s'." : "Timestamp of '%s' changed.", *i); /* update timestamp */ if (update) { diff --git a/src/libnm-systemd-shared/src/basic/path-util.h b/src/libnm-systemd-shared/src/basic/path-util.h index 8a7d5e25..fc41c869 100644 --- a/src/libnm-systemd-shared/src/basic/path-util.h +++ b/src/libnm-systemd-shared/src/basic/path-util.h @@ -64,7 +64,11 @@ static inline char* path_startswith(const char *path, const char *prefix) { return path_startswith_full(path, prefix, true); } int path_compare(const char *a, const char *b) _pure_; -bool path_equal(const char *a, const char *b) _pure_; + +static inline bool path_equal(const char *a, const char *b) { + return path_compare(a, b) == 0; +} + bool path_equal_or_files_same(const char *a, const char *b, int flags); /* Compares only the last portion of the input paths, ie: the filenames */ bool path_equal_filename(const char *a, const char *b); @@ -97,9 +101,9 @@ int path_strv_make_absolute_cwd(char **l); char** path_strv_resolve(char **l, const char *root); char** path_strv_resolve_uniq(char **l, const char *root); -int find_executable_full(const char *name, bool use_path_envvar, char **ret_filename, int *ret_fd); +int find_executable_full(const char *name, const char *root, char **exec_search_path, bool use_path_envvar, char **ret_filename, int *ret_fd); static inline int find_executable(const char *name, char **ret_filename) { - return find_executable_full(name, true, ret_filename, NULL); + return find_executable_full(name, /* root= */ NULL, NULL, true, ret_filename, NULL); } bool paths_check_timestamp(const char* const* paths, usec_t *paths_ts_usec, bool update); diff --git a/src/libnm-systemd-shared/src/basic/prioq.c b/src/libnm-systemd-shared/src/basic/prioq.c index 19a9bc57..2f8bdf0f 100644 --- a/src/libnm-systemd-shared/src/basic/prioq.c +++ b/src/libnm-systemd-shared/src/basic/prioq.c @@ -175,6 +175,16 @@ int prioq_put(Prioq *q, void *data, unsigned *idx) { return 0; } +int prioq_ensure_put(Prioq **q, compare_func_t compare_func, void *data, unsigned *idx) { + int r; + + r = prioq_ensure_allocated(q, compare_func); + if (r < 0) + return r; + + return prioq_put(*q, data, idx); +} + static void remove_item(Prioq *q, struct prioq_item *i) { struct prioq_item *l; diff --git a/src/libnm-systemd-shared/src/basic/prioq.h b/src/libnm-systemd-shared/src/basic/prioq.h index 7c766476..508db880 100644 --- a/src/libnm-systemd-shared/src/basic/prioq.h +++ b/src/libnm-systemd-shared/src/basic/prioq.h @@ -16,6 +16,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Prioq*, prioq_free); int prioq_ensure_allocated(Prioq **q, compare_func_t compare_func); int prioq_put(Prioq *q, void *data, unsigned *idx); +int prioq_ensure_put(Prioq **q, compare_func_t compare_func, void *data, unsigned *idx); int prioq_remove(Prioq *q, void *data, unsigned *idx); int prioq_reshuffle(Prioq *q, void *data, unsigned *idx); diff --git a/src/libnm-systemd-shared/src/basic/process-util.c b/src/libnm-systemd-shared/src/basic/process-util.c index d538dda7..96d0912c 100644 --- a/src/libnm-systemd-shared/src/basic/process-util.c +++ b/src/libnm-systemd-shared/src/basic/process-util.c @@ -31,7 +31,6 @@ #include "fd-util.h" #include "fileio.h" #include "fs-util.h" -#include "ioprio.h" #include "locale-util.h" #include "log.h" #include "macro.h" @@ -649,20 +648,23 @@ int get_process_environ(pid_t pid, char **env) { return 0; } -int get_process_ppid(pid_t pid, pid_t *_ppid) { - int r; +int get_process_ppid(pid_t pid, pid_t *ret) { _cleanup_free_ char *line = NULL; long unsigned ppid; const char *p; + int r; assert(pid >= 0); - assert(_ppid); if (pid == 0 || pid == getpid_cached()) { - *_ppid = getppid(); + if (ret) + *ret = getppid(); return 0; } + if (pid == 1) /* PID 1 has no parent, shortcut this case */ + return -EADDRNOTAVAIL; + p = procfs_file_alloca(pid, "stat"); r = read_one_line_file(p, &line); if (r == -ENOENT) @@ -670,9 +672,8 @@ int get_process_ppid(pid_t pid, pid_t *_ppid) { if (r < 0) return r; - /* Let's skip the pid and comm fields. The latter is enclosed - * in () but does not escape any () in its value, so let's - * skip over it manually */ + /* Let's skip the pid and comm fields. The latter is enclosed in () but does not escape any () in its + * value, so let's skip over it manually */ p = strrchr(line, ')'); if (!p) @@ -686,10 +687,17 @@ int get_process_ppid(pid_t pid, pid_t *_ppid) { &ppid) != 1) return -EIO; - if ((long unsigned) (pid_t) ppid != ppid) + /* If ppid is zero the process has no parent. Which might be the case for PID 1 but also for + * processes originating in other namespaces that are inserted into a pidns. Return a recognizable + * error in this case. */ + if (ppid == 0) + return -EADDRNOTAVAIL; + + if ((pid_t) ppid < 0 || (long unsigned) (pid_t) ppid != ppid) return -ERANGE; - *_ppid = (pid_t) ppid; + if (ret) + *ret = (pid_t) ppid; return 0; } @@ -826,7 +834,7 @@ int wait_for_terminate_with_timeout(pid_t pid, usec_t timeout) { /* Assuming we woke due to the child exiting. */ if (waitid(P_PID, pid, &status, WEXITED|WNOHANG) == 0) { if (status.si_pid == pid) { - /* This is the correct child.*/ + /* This is the correct child. */ if (status.si_code == CLD_EXITED) return (status.si_status == 0) ? 0 : -EPROTO; else @@ -1036,30 +1044,6 @@ bool is_main_thread(void) { } #if 0 /* NM_IGNORED */ -_noreturn_ void freeze(void) { - - log_close(); - - /* Make sure nobody waits for us on a socket anymore */ - (void) close_all_fds(NULL, 0); - - sync(); - - /* Let's not freeze right away, but keep reaping zombies. */ - for (;;) { - int r; - siginfo_t si = {}; - - r = waitid(P_ALL, 0, &si, WEXITED); - if (r < 0 && errno != EINTR) - break; - } - - /* waitid() failed with an unexpected error, things are really borked. Freeze now! */ - for (;;) - pause(); -} - bool oom_score_adjust_is_valid(int oa) { return oa >= OOM_SCORE_ADJ_MIN && oa <= OOM_SCORE_ADJ_MAX; } @@ -1272,14 +1256,14 @@ static void restore_sigsetp(sigset_t **ssp) { int safe_fork_full( const char *name, - const int except_fds[], + int except_fds[], size_t n_except_fds, ForkFlags flags, pid_t *ret_pid) { pid_t original_pid, pid; sigset_t saved_ss, ss; - _cleanup_(restore_sigsetp) sigset_t *saved_ssp = NULL; + _unused_ _cleanup_(restore_sigsetp) sigset_t *saved_ssp = NULL; bool block_signals = false, block_all = false; int prio, r; @@ -1467,7 +1451,7 @@ int safe_fork_full( int namespace_fork( const char *outer_name, const char *inner_name, - const int except_fds[], + int except_fds[], size_t n_except_fds, ForkFlags flags, int pidns_fd, @@ -1483,7 +1467,8 @@ int namespace_fork( * process. This ensures that we are fully a member of the destination namespace, with pidns an all, so that * /proc/self/fd works correctly. */ - r = safe_fork_full(outer_name, except_fds, n_except_fds, (flags|FORK_DEATHSIG) & ~(FORK_REOPEN_LOG|FORK_NEW_MOUNTNS|FORK_MOUNTNS_SLAVE), ret_pid); + r = safe_fork_full(outer_name, except_fds, n_except_fds, + (flags|FORK_DEATHSIG) & ~(FORK_REOPEN_LOG|FORK_NEW_MOUNTNS|FORK_MOUNTNS_SLAVE), ret_pid); if (r < 0) return r; if (r == 0) { @@ -1518,89 +1503,31 @@ int namespace_fork( return 1; } -int fork_agent(const char *name, const int except[], size_t n_except, pid_t *ret_pid, const char *path, ...) { - bool stdout_is_tty, stderr_is_tty; - size_t n, i; - va_list ap; - char **l; - int r; +int set_oom_score_adjust(int value) { + char t[DECIMAL_STR_MAX(int)]; - assert(path); + xsprintf(t, "%i", value); - /* Spawns a temporary TTY agent, making sure it goes away when we go away */ + return write_string_file("/proc/self/oom_score_adj", t, + WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_DISABLE_BUFFER); +} - r = safe_fork_full(name, - except, - n_except, - FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_CLOSE_ALL_FDS|FORK_REOPEN_LOG, - ret_pid); +int get_oom_score_adjust(int *ret) { + _cleanup_free_ char *t; + int r, a; + + r = read_virtual_file("/proc/self/oom_score_adj", SIZE_MAX, &t, NULL); if (r < 0) return r; - if (r > 0) - return 0; - - /* In the child: */ - stdout_is_tty = isatty(STDOUT_FILENO); - stderr_is_tty = isatty(STDERR_FILENO); + delete_trailing_chars(t, WHITESPACE); - if (!stdout_is_tty || !stderr_is_tty) { - int fd; + assert_se(safe_atoi(t, &a) >= 0); + assert_se(oom_score_adjust_is_valid(a)); - /* Detach from stdout/stderr. and reopen - * /dev/tty for them. This is important to - * ensure that when systemctl is started via - * popen() or a similar call that expects to - * read EOF we actually do generate EOF and - * not delay this indefinitely by because we - * keep an unused copy of stdin around. */ - fd = open("/dev/tty", O_WRONLY); - if (fd < 0) { - log_error_errno(errno, "Failed to open /dev/tty: %m"); - _exit(EXIT_FAILURE); - } - - if (!stdout_is_tty && dup2(fd, STDOUT_FILENO) < 0) { - log_error_errno(errno, "Failed to dup2 /dev/tty: %m"); - _exit(EXIT_FAILURE); - } - - if (!stderr_is_tty && dup2(fd, STDERR_FILENO) < 0) { - log_error_errno(errno, "Failed to dup2 /dev/tty: %m"); - _exit(EXIT_FAILURE); - } - - safe_close_above_stdio(fd); - } - - (void) rlimit_nofile_safe(); - - /* Count arguments */ - va_start(ap, path); - for (n = 0; va_arg(ap, char*); n++) - ; - va_end(ap); - - /* Allocate strv */ - l = newa(char*, n + 1); - - /* Fill in arguments */ - va_start(ap, path); - for (i = 0; i <= n; i++) - l[i] = va_arg(ap, char*); - va_end(ap); - - execv(path, l); - _exit(EXIT_FAILURE); -} - -int set_oom_score_adjust(int value) { - char t[DECIMAL_STR_MAX(int)]; - - sprintf(t, "%i", value); - - return write_string_file("/proc/self/oom_score_adj", t, - WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_DISABLE_BUFFER); + if (ret) + *ret = a; + return 0; } int pidfd_get_pid(int fd, pid_t *ret) { diff --git a/src/libnm-systemd-shared/src/basic/process-util.h b/src/libnm-systemd-shared/src/basic/process-util.h index 21e4eb91..bc16d328 100644 --- a/src/libnm-systemd-shared/src/basic/process-util.h +++ b/src/libnm-systemd-shared/src/basic/process-util.h @@ -13,8 +13,8 @@ #include "alloc-util.h" #include "format-util.h" -#include "ioprio.h" #include "macro.h" +#include "missing_ioprio.h" #include "time-util.h" #define procfs_file_alloca(pid, field) \ @@ -82,8 +82,6 @@ int pid_from_same_root_fs(pid_t pid); bool is_main_thread(void); -_noreturn_ void freeze(void); - bool oom_score_adjust_is_valid(int oa); #ifndef PERSONALITY_INVALID @@ -170,17 +168,16 @@ typedef enum ForkFlags { FORK_NEW_USERNS = 1 << 13, /* Run child in its own user namespace */ } ForkFlags; -int safe_fork_full(const char *name, const int except_fds[], size_t n_except_fds, ForkFlags flags, pid_t *ret_pid); +int safe_fork_full(const char *name, int except_fds[], size_t n_except_fds, ForkFlags flags, pid_t *ret_pid); static inline int safe_fork(const char *name, ForkFlags flags, pid_t *ret_pid) { return safe_fork_full(name, NULL, 0, flags, ret_pid); } -int namespace_fork(const char *outer_name, const char *inner_name, const int except_fds[], size_t n_except_fds, ForkFlags flags, int pidns_fd, int mntns_fd, int netns_fd, int userns_fd, int root_fd, pid_t *ret_pid); - -int fork_agent(const char *name, const int except[], size_t n_except, pid_t *pid, const char *path, ...) _sentinel_; +int namespace_fork(const char *outer_name, const char *inner_name, int except_fds[], size_t n_except_fds, ForkFlags flags, int pidns_fd, int mntns_fd, int netns_fd, int userns_fd, int root_fd, pid_t *ret_pid); int set_oom_score_adjust(int value); +int get_oom_score_adjust(int *ret); /* The highest possibly (theoretic) pid_t value on this architecture. */ #define PID_T_MAX ((pid_t) INT32_MAX) diff --git a/src/libnm-systemd-shared/src/basic/random-util.c b/src/libnm-systemd-shared/src/basic/random-util.c index 4af1fff5..063784dc 100644 --- a/src/libnm-systemd-shared/src/basic/random-util.c +++ b/src/libnm-systemd-shared/src/basic/random-util.c @@ -190,7 +190,7 @@ int genuine_random_bytes(void *p, size_t n, RandomFlags flags) { * invocations or so. That's because we don't really care about the quality here. We * generally prefer using RDRAND if the caller allows us to, since this way we won't upset * the kernel's random subsystem by accessing it before the pool is initialized (after all it - * will kmsg log about every attempt to do so)..*/ + * will kmsg log about every attempt to do so). */ for (;;) { unsigned long u; size_t m; diff --git a/src/libnm-systemd-shared/src/basic/set.h b/src/libnm-systemd-shared/src/basic/set.h index 0f867393..5cae1316 100644 --- a/src/libnm-systemd-shared/src/basic/set.h +++ b/src/libnm-systemd-shared/src/basic/set.h @@ -26,7 +26,7 @@ static inline Set* set_free_free(Set *s) { /* no set_free_free_free */ -#define set_copy(s) ((Set*) _hashmap_copy(HASHMAP_BASE(h) HASHMAP_DEBUG_SRC_ARGS)) +#define set_copy(s) ((Set*) _hashmap_copy(HASHMAP_BASE(s) HASHMAP_DEBUG_SRC_ARGS)) int _set_ensure_allocated(Set **s, const struct hash_ops *hash_ops HASHMAP_DEBUG_PARAMS); #define set_ensure_allocated(h, ops) _set_ensure_allocated(h, ops HASHMAP_DEBUG_SRC_ARGS) diff --git a/src/libnm-systemd-shared/src/basic/signal-util.c b/src/libnm-systemd-shared/src/basic/signal-util.c index a31834ab..f96eb4d4 100644 --- a/src/libnm-systemd-shared/src/basic/signal-util.c +++ b/src/libnm-systemd-shared/src/basic/signal-util.c @@ -241,7 +241,6 @@ int signal_from_string(const char *s) { void nop_signal_handler(int sig) { /* nothing here */ } -#endif /* NM_IGNORED */ int signal_is_blocked(int sig) { sigset_t ss; @@ -257,3 +256,39 @@ int signal_is_blocked(int sig) { return r; } + +int pop_pending_signal_internal(int sig, ...) { + sigset_t ss; + va_list ap; + int r; + + if (sig < 0) /* Empty list? */ + return -EINVAL; + + if (sigemptyset(&ss) < 0) + return -errno; + + /* Add first signal (if the signal is zero, we'll silently skip it, to make it easier to build + * parameter lists where some element are sometimes off, similar to how sigset_add_many_ap() handles + * this.) */ + if (sig > 0 && sigaddset(&ss, sig) < 0) + return -errno; + + /* Add all other signals */ + va_start(ap, sig); + r = sigset_add_many_ap(&ss, ap); + va_end(ap); + if (r < 0) + return r; + + r = sigtimedwait(&ss, NULL, &(struct timespec) { 0, 0 }); + if (r < 0) { + if (errno == EAGAIN) + return 0; + + return -errno; + } + + return r; /* Returns the signal popped */ +} +#endif /* NM_IGNORED */ diff --git a/src/libnm-systemd-shared/src/basic/signal-util.h b/src/libnm-systemd-shared/src/basic/signal-util.h index 37271d7a..36372c19 100644 --- a/src/libnm-systemd-shared/src/basic/signal-util.h +++ b/src/libnm-systemd-shared/src/basic/signal-util.h @@ -62,3 +62,6 @@ static inline const char* signal_to_string_with_check(int n) { } int signal_is_blocked(int sig); + +int pop_pending_signal_internal(int sig, ...); +#define pop_pending_signal(...) pop_pending_signal_internal(__VA_ARGS__, -1) diff --git a/src/libnm-systemd-shared/src/basic/socket-util.c b/src/libnm-systemd-shared/src/basic/socket-util.c index da36c280..49a4df44 100644 --- a/src/libnm-systemd-shared/src/basic/socket-util.c +++ b/src/libnm-systemd-shared/src/basic/socket-util.c @@ -112,7 +112,7 @@ int socket_address_verify(const SocketAddress *a, bool strict) { /* If there's no embedded NUL byte, then the size needs to match the whole * structure or the structure with one extra NUL byte suffixed. (Yeah, Linux is awful, * and considers both equivalent: getsockname() even extends sockaddr_un beyond its - * size if the path is non NUL terminated.)*/ + * size if the path is non NUL terminated.) */ if (!IN_SET(a->size, sizeof(a->sockaddr.un.sun_path), sizeof(a->sockaddr.un.sun_path)+1)) return -EINVAL; } @@ -460,23 +460,23 @@ int sockaddr_pretty( if (r < 0) return -ENOMEM; } else { - char a[INET6_ADDRSTRLEN], ifname[IF_NAMESIZE + 1]; + char a[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, &sa->in6.sin6_addr, a, sizeof(a)); - if (sa->in6.sin6_scope_id != 0) - format_ifname_full(sa->in6.sin6_scope_id, ifname, FORMAT_IFNAME_IFINDEX); if (include_port) { - r = asprintf(&p, + if (asprintf(&p, "[%s]:%u%s%s", a, be16toh(sa->in6.sin6_port), sa->in6.sin6_scope_id != 0 ? "%" : "", - sa->in6.sin6_scope_id != 0 ? ifname : ""); - if (r < 0) + FORMAT_IFNAME_FULL(sa->in6.sin6_scope_id, FORMAT_IFNAME_IFINDEX)) < 0) return -ENOMEM; } else { - p = sa->in6.sin6_scope_id != 0 ? strjoin(a, "%", ifname) : strdup(a); + if (sa->in6.sin6_scope_id != 0) + p = strjoin(a, "%", FORMAT_IFNAME_FULL(sa->in6.sin6_scope_id, FORMAT_IFNAME_IFINDEX)); + else + p = strdup(a); if (!p) return -ENOMEM; } @@ -754,6 +754,22 @@ static const char* const ip_tos_table[] = { DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(ip_tos, int, 0xff); #endif /* NM_IGNORED */ +bool ifname_valid_char(char a) { + if ((unsigned char) a >= 127U) + return false; + + if ((unsigned char) a <= 32U) + return false; + + if (IN_SET(a, + ':', /* colons are used by the legacy "alias" interface logic */ + '/', /* slashes cannot work, since we need to use network interfaces in sysfs paths, and in paths slashes are separators */ + '%')) /* %d is used in the kernel's weird foo%d format string naming feature which we really really don't want to ever run into by accident */ + return false; + + return true; +} + bool ifname_valid_full(const char *p, IfnameValidFlags flags) { bool numeric = true; @@ -783,20 +799,11 @@ bool ifname_valid_full(const char *p, IfnameValidFlags flags) { /* Let's refuse "all" and "default" as interface name, to avoid collisions with the special sysctl * directories /proc/sys/net/{ipv4,ipv6}/conf/{all,default} */ - if (STR_IN_SET(p, "all", "default")) + if (!FLAGS_SET(flags, IFNAME_VALID_SPECIAL) && STR_IN_SET(p, "all", "default")) return false; for (const char *t = p; *t; t++) { - if ((unsigned char) *t >= 127U) - return false; - - if ((unsigned char) *t <= 32U) - return false; - - if (IN_SET(*t, - ':', /* colons are used by the legacy "alias" interface logic */ - '/', /* slashes cannot work, since we need to use network interfaces in sysfs paths, and in paths slashes are separators */ - '%')) /* %d is used in the kernel's weird foo%d format string naming feature which we really really don't want to ever run into by accident */ + if (!ifname_valid_char(*t)) return false; numeric = numeric && (*t >= '0' && *t <= '9'); @@ -921,7 +928,7 @@ int getpeergroups(int fd, gid_t **ret) { ssize_t send_one_fd_iov_sa( int transport_fd, int fd, - struct iovec *iov, size_t iovlen, + const struct iovec *iov, size_t iovlen, const struct sockaddr *sa, socklen_t len, int flags) { @@ -929,7 +936,7 @@ ssize_t send_one_fd_iov_sa( struct msghdr mh = { .msg_name = (struct sockaddr*) sa, .msg_namelen = len, - .msg_iov = iov, + .msg_iov = (struct iovec *)iov, .msg_iovlen = iovlen, }; ssize_t k; @@ -1204,7 +1211,7 @@ int sockaddr_un_set_path(struct sockaddr_un *ret, const char *path) { /* Don't allow paths larger than the space in sockaddr_un. Note that we are a tiny bit more restrictive than * the kernel is: we insist on NUL termination (both for abstract namespace and regular file system socket * addresses!), which the kernel doesn't. We do this to reduce chance of incompatibility with other apps that - * do not expect non-NUL terminated file system path*/ + * do not expect non-NUL terminated file system path. */ if (l+1 > sizeof(ret->sun_path)) return -EINVAL; @@ -1238,7 +1245,7 @@ int socket_bind_to_ifname(int fd, const char *ifname) { } int socket_bind_to_ifindex(int fd, int ifindex) { - char ifname[IF_NAMESIZE + 1]; + char ifname[IF_NAMESIZE]; int r; assert(fd >= 0); @@ -1256,8 +1263,9 @@ int socket_bind_to_ifindex(int fd, int ifindex) { return r; /* Fall back to SO_BINDTODEVICE on kernels < 5.0 which didn't have SO_BINDTOIFINDEX */ - if (!format_ifname(ifindex, ifname)) - return -errno; + r = format_ifname(ifindex, ifname); + if (r < 0) + return r; return socket_bind_to_ifname(fd, ifname); } diff --git a/src/libnm-systemd-shared/src/basic/socket-util.h b/src/libnm-systemd-shared/src/basic/socket-util.h index a8a915be..4caa27c8 100644 --- a/src/libnm-systemd-shared/src/basic/socket-util.h +++ b/src/libnm-systemd-shared/src/basic/socket-util.h @@ -137,10 +137,12 @@ int ip_tos_to_string_alloc(int i, char **s); int ip_tos_from_string(const char *s); typedef enum { - IFNAME_VALID_ALTERNATIVE = 1 << 0, - IFNAME_VALID_NUMERIC = 1 << 1, - _IFNAME_VALID_ALL = IFNAME_VALID_ALTERNATIVE | IFNAME_VALID_NUMERIC, + IFNAME_VALID_ALTERNATIVE = 1 << 0, /* Allow "altnames" too */ + IFNAME_VALID_NUMERIC = 1 << 1, /* Allow decimal formatted ifindexes too */ + IFNAME_VALID_SPECIAL = 1 << 2, /* Allow the special names "all" and "default" */ + _IFNAME_VALID_ALL = IFNAME_VALID_ALTERNATIVE | IFNAME_VALID_NUMERIC | IFNAME_VALID_SPECIAL, } IfnameValidFlags; +bool ifname_valid_char(char a); bool ifname_valid_full(const char *p, IfnameValidFlags flags); static inline bool ifname_valid(const char *p) { return ifname_valid_full(p, 0); @@ -154,7 +156,7 @@ int getpeergroups(int fd, gid_t **ret); ssize_t send_one_fd_iov_sa( int transport_fd, int fd, - struct iovec *iov, size_t iovlen, + const struct iovec *iov, size_t iovlen, const struct sockaddr *sa, socklen_t len, int flags); int send_one_fd_sa(int transport_fd, @@ -246,7 +248,7 @@ struct cmsghdr* cmsg_find(struct msghdr *mh, int level, int type, socklen_t leng _len = sizeof(struct sockaddr_vm); \ break; \ default: \ - assert_not_reached("invalid socket family"); \ + assert_not_reached(); \ } \ _len; \ }) @@ -278,6 +280,28 @@ static inline int getsockopt_int(int fd, int level, int optname, int *ret) { int socket_bind_to_ifname(int fd, const char *ifname); int socket_bind_to_ifindex(int fd, int ifindex); +/* Define a 64bit version of timeval/timespec in any case, even on 32bit userspace. */ +struct timeval_large { + uint64_t tvl_sec, tvl_usec; +}; +struct timespec_large { + uint64_t tvl_sec, tvl_nsec; +}; + +/* glibc duplicates timespec/timeval on certain 32bit archs, once in 32bit and once in 64bit. + * See __convert_scm_timestamps() in glibc source code. Hence, we need additional buffer space for them + * to prevent from recvmsg_safe() returning -EXFULL. */ +#define CMSG_SPACE_TIMEVAL \ + ((sizeof(struct timeval) == sizeof(struct timeval_large)) ? \ + CMSG_SPACE(sizeof(struct timeval)) : \ + CMSG_SPACE(sizeof(struct timeval)) + \ + CMSG_SPACE(sizeof(struct timeval_large))) +#define CMSG_SPACE_TIMESPEC \ + ((sizeof(struct timespec) == sizeof(struct timespec_large)) ? \ + CMSG_SPACE(sizeof(struct timespec)) : \ + CMSG_SPACE(sizeof(struct timespec)) + \ + CMSG_SPACE(sizeof(struct timespec_large))) + ssize_t recvmsg_safe(int sockfd, struct msghdr *msg, int flags); int socket_get_family(int fd, int *ret); diff --git a/src/libnm-systemd-shared/src/basic/stat-util.c b/src/libnm-systemd-shared/src/basic/stat-util.c index 5112cbeb..133828bc 100644 --- a/src/libnm-systemd-shared/src/basic/stat-util.c +++ b/src/libnm-systemd-shared/src/basic/stat-util.c @@ -10,10 +10,11 @@ #include #include "alloc-util.h" +#include "chase-symlinks.h" #include "dirent-util.h" +#include "errno-util.h" #include "fd-util.h" #include "fileio.h" -#include "fs-util.h" #include "macro.h" #include "missing_fs.h" #include "missing_magic.h" @@ -159,6 +160,7 @@ int path_is_read_only_fs(const char *path) { return false; } +#endif /* NM_IGNORED */ int files_same(const char *filea, const char *fileb, int flags) { struct stat a, b; @@ -176,6 +178,7 @@ int files_same(const char *filea, const char *fileb, int flags) { a.st_ino == b.st_ino; } +#if 0 /* NM_IGNORED */ bool is_fs_type(const struct statfs *s, statfs_f_type_t magic_value) { assert(s); assert_cc(sizeof(statfs_f_type_t) >= sizeof(s->f_type)); diff --git a/src/libnm-systemd-shared/src/basic/stdio-util.h b/src/libnm-systemd-shared/src/basic/stdio-util.h index d45d3c1a..f3b213c5 100644 --- a/src/libnm-systemd-shared/src/basic/stdio-util.h +++ b/src/libnm-systemd-shared/src/basic/stdio-util.h @@ -11,8 +11,13 @@ #include "macro.h" #include "memory-util.h" -#define snprintf_ok(buf, len, fmt, ...) \ - ((size_t) snprintf(buf, len, fmt, __VA_ARGS__) < (len)) +#define snprintf_ok(buf, len, fmt, ...) \ + ({ \ + char *_buf = (buf); \ + size_t _len = (len); \ + int _snpf = snprintf(_buf, _len, (fmt), __VA_ARGS__); \ + _snpf >= 0 && (size_t) _snpf < _len ? _buf : NULL; \ + }) #define xsprintf(buf, fmt, ...) \ assert_message_se(snprintf_ok(buf, ELEMENTSOF(buf), fmt, __VA_ARGS__), "xsprintf: " #buf "[] must be big enough") @@ -60,7 +65,7 @@ do { \ (void) va_arg(ap, long double); \ break; \ default: \ - assert_not_reached("Unknown format string argument."); \ + assert_not_reached(); \ } \ } \ } while (false) diff --git a/src/libnm-systemd-shared/src/basic/string-util.c b/src/libnm-systemd-shared/src/basic/string-util.c index c991a396..fea22ec8 100644 --- a/src/libnm-systemd-shared/src/basic/string-util.c +++ b/src/libnm-systemd-shared/src/basic/string-util.c @@ -1155,4 +1155,20 @@ int string_contains_word_strv(const char *string, const char *separators, char * *ret_word = found; return !!found; } + +bool streq_skip_trailing_chars(const char *s1, const char *s2, const char *ok) { + if (!s1 && !s2) + return true; + if (!s1 || !s2) + return false; + + if (!ok) + ok = WHITESPACE; + + for (; *s1 && *s2; s1++, s2++) + if (*s1 != *s2) + break; + + return in_charset(s1, ok) && in_charset(s2, ok); +} #endif /* NM_IGNORED */ diff --git a/src/libnm-systemd-shared/src/basic/string-util.h b/src/libnm-systemd-shared/src/basic/string-util.h index 9155e50b..775d694c 100644 --- a/src/libnm-systemd-shared/src/basic/string-util.h +++ b/src/libnm-systemd-shared/src/basic/string-util.h @@ -189,22 +189,6 @@ static inline void strncpy_exact(char *buf, const char *src, size_t buf_len) { } REENABLE_WARNING; -/* Like startswith(), but operates on arbitrary memory blocks */ -static inline void *memory_startswith(const void *p, size_t sz, const char *token) { - assert(token); - - size_t n = strlen(token); - if (sz < n) - return NULL; - - assert(p); - - if (memcmp(p, token, n) != 0) - return NULL; - - return (uint8_t*) p + n; -} - /* Like startswith_no_case(), but operates on arbitrary memory blocks. * It works only for ASCII strings. */ @@ -242,3 +226,5 @@ int string_contains_word_strv(const char *string, const char *separators, char * static inline int string_contains_word(const char *string, const char *separators, const char *word) { return string_contains_word_strv(string, separators, STRV_MAKE(word), NULL); } + +bool streq_skip_trailing_chars(const char *s1, const char *s2, const char *ok); diff --git a/src/libnm-systemd-shared/src/basic/strv.c b/src/libnm-systemd-shared/src/basic/strv.c index e24ef535..1d840923 100644 --- a/src/libnm-systemd-shared/src/basic/strv.c +++ b/src/libnm-systemd-shared/src/basic/strv.c @@ -305,6 +305,24 @@ int strv_split_full(char ***t, const char *s, const char *separators, ExtractFla } #if 0 /* NM_IGNORED */ +int strv_split_and_extend_full(char ***t, const char *s, const char *separators, bool filter_duplicates, ExtractFlags flags) { + _cleanup_strv_free_ char **l = NULL; + int r; + + assert(t); + assert(s); + + r = strv_split_full(&l, s, separators, flags); + if (r < 0) + return r; + + r = strv_extend_strv(t, l, filter_duplicates); + if (r < 0) + return r; + + return (int) strv_length(*t); +} + int strv_split_colon_pairs(char ***t, const char *s) { _cleanup_strv_free_ char **l = NULL; size_t n = 0; @@ -831,6 +849,7 @@ char **strv_reverse(char **l) { return l; } +#if 0 /* NM_IGNORED */ char **strv_shell_escape(char **l, const char *bad) { char **s; @@ -850,6 +869,7 @@ char **strv_shell_escape(char **l, const char *bad) { return l; } +#endif /* NM_IGNORED */ bool strv_fnmatch_full(char* const* patterns, const char *s, int flags, size_t *matched_pos) { for (size_t i = 0; patterns && patterns[i]; i++) diff --git a/src/libnm-systemd-shared/src/basic/strv.h b/src/libnm-systemd-shared/src/basic/strv.h index 911528fa..a56ef941 100644 --- a/src/libnm-systemd-shared/src/basic/strv.h +++ b/src/libnm-systemd-shared/src/basic/strv.h @@ -83,6 +83,9 @@ static inline char **strv_split(const char *s, const char *separators) { return ret; } +int strv_split_and_extend_full(char ***t, const char *s, const char *separators, bool filter_duplicates, ExtractFlags flags); +#define strv_split_and_extend(t, s, sep, dup) strv_split_and_extend_full(t, s, sep, dup, 0) + int strv_split_newlines_full(char ***ret, const char *s, ExtractFlags flags); static inline char **strv_split_newlines(const char *s) { char **ret; @@ -233,9 +236,11 @@ int fputstrv(FILE *f, char * const *l, const char *separator, bool *space); #define strv_free_and_replace(a, b) \ ({ \ - strv_free(a); \ - (a) = (b); \ - (b) = NULL; \ + char ***_a = &(a); \ + char ***_b = &(b); \ + strv_free(*_a); \ + (*_a) = (*_b); \ + (*_b) = NULL; \ 0; \ }) diff --git a/src/libnm-systemd-shared/src/basic/time-util.c b/src/libnm-systemd-shared/src/basic/time-util.c index 4b7042f7..21e7b24a 100644 --- a/src/libnm-systemd-shared/src/basic/time-util.c +++ b/src/libnm-systemd-shared/src/basic/time-util.c @@ -432,48 +432,66 @@ char *format_timestamp_relative(char *buf, size_t l, usec_t t) { s = "left"; } - if (d >= USEC_PER_YEAR) - snprintf(buf, l, USEC_FMT " years " USEC_FMT " months %s", - d / USEC_PER_YEAR, - (d % USEC_PER_YEAR) / USEC_PER_MONTH, s); - else if (d >= USEC_PER_MONTH) - snprintf(buf, l, USEC_FMT " months " USEC_FMT " days %s", - d / USEC_PER_MONTH, - (d % USEC_PER_MONTH) / USEC_PER_DAY, s); - else if (d >= USEC_PER_WEEK) - snprintf(buf, l, USEC_FMT " weeks " USEC_FMT " days %s", - d / USEC_PER_WEEK, - (d % USEC_PER_WEEK) / USEC_PER_DAY, s); - else if (d >= 2*USEC_PER_DAY) - snprintf(buf, l, USEC_FMT " days %s", d / USEC_PER_DAY, s); + if (d >= USEC_PER_YEAR) { + usec_t years = d / USEC_PER_YEAR; + usec_t months = (d % USEC_PER_YEAR) / USEC_PER_MONTH; + + (void) snprintf(buf, l, USEC_FMT " %s " USEC_FMT " %s %s", + years, + years == 1 ? "year" : "years", + months, + months == 1 ? "month" : "months", + s); + } else if (d >= USEC_PER_MONTH) { + usec_t months = d / USEC_PER_MONTH; + usec_t days = (d % USEC_PER_MONTH) / USEC_PER_DAY; + + (void) snprintf(buf, l, USEC_FMT " %s " USEC_FMT " %s %s", + months, + months == 1 ? "month" : "months", + days, + days == 1 ? "day" : "days", + s); + } else if (d >= USEC_PER_WEEK) { + usec_t weeks = d / USEC_PER_WEEK; + usec_t days = (d % USEC_PER_WEEK) / USEC_PER_DAY; + + (void) snprintf(buf, l, USEC_FMT " %s " USEC_FMT " %s %s", + weeks, + weeks == 1 ? "week" : "weeks", + days, + days == 1 ? "day" : "days", + s); + } else if (d >= 2*USEC_PER_DAY) + (void) snprintf(buf, l, USEC_FMT " days %s", d / USEC_PER_DAY, s); else if (d >= 25*USEC_PER_HOUR) - snprintf(buf, l, "1 day " USEC_FMT "h %s", - (d - USEC_PER_DAY) / USEC_PER_HOUR, s); + (void) snprintf(buf, l, "1 day " USEC_FMT "h %s", + (d - USEC_PER_DAY) / USEC_PER_HOUR, s); else if (d >= 6*USEC_PER_HOUR) - snprintf(buf, l, USEC_FMT "h %s", - d / USEC_PER_HOUR, s); + (void) snprintf(buf, l, USEC_FMT "h %s", + d / USEC_PER_HOUR, s); else if (d >= USEC_PER_HOUR) - snprintf(buf, l, USEC_FMT "h " USEC_FMT "min %s", - d / USEC_PER_HOUR, - (d % USEC_PER_HOUR) / USEC_PER_MINUTE, s); + (void) snprintf(buf, l, USEC_FMT "h " USEC_FMT "min %s", + d / USEC_PER_HOUR, + (d % USEC_PER_HOUR) / USEC_PER_MINUTE, s); else if (d >= 5*USEC_PER_MINUTE) - snprintf(buf, l, USEC_FMT "min %s", - d / USEC_PER_MINUTE, s); + (void) snprintf(buf, l, USEC_FMT "min %s", + d / USEC_PER_MINUTE, s); else if (d >= USEC_PER_MINUTE) - snprintf(buf, l, USEC_FMT "min " USEC_FMT "s %s", - d / USEC_PER_MINUTE, - (d % USEC_PER_MINUTE) / USEC_PER_SEC, s); + (void) snprintf(buf, l, USEC_FMT "min " USEC_FMT "s %s", + d / USEC_PER_MINUTE, + (d % USEC_PER_MINUTE) / USEC_PER_SEC, s); else if (d >= USEC_PER_SEC) - snprintf(buf, l, USEC_FMT "s %s", - d / USEC_PER_SEC, s); + (void) snprintf(buf, l, USEC_FMT "s %s", + d / USEC_PER_SEC, s); else if (d >= USEC_PER_MSEC) - snprintf(buf, l, USEC_FMT "ms %s", - d / USEC_PER_MSEC, s); + (void) snprintf(buf, l, USEC_FMT "ms %s", + d / USEC_PER_MSEC, s); else if (d > 0) - snprintf(buf, l, USEC_FMT"us %s", - d, s); + (void) snprintf(buf, l, USEC_FMT"us %s", + d, s); else - snprintf(buf, l, "now"); + (void) snprintf(buf, l, "now"); buf[l-1] = 0; return buf; @@ -539,14 +557,12 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) { /* Let's see if we should shows this in dot notation */ if (t < USEC_PER_MINUTE && b > 0) { - usec_t cc; - signed char j; + signed char j = 0; - j = 0; - for (cc = table[i].usec; cc > 1; cc /= 10) + for (usec_t cc = table[i].usec; cc > 1; cc /= 10) j++; - for (cc = accuracy; cc > 1; cc /= 10) { + for (usec_t cc = accuracy; cc > 1; cc /= 10) { b /= 10; j--; } @@ -1035,7 +1051,7 @@ int parse_time(const char *t, usec_t *usec, usec_t default_unit) { s = extract_multiplier(p + strspn(p, WHITESPACE), &multiplier); if (s == p && *s != '\0') - /* Don't allow '12.34.56', but accept '12.34 .56' or '12.34s.56'*/ + /* Don't allow '12.34.56', but accept '12.34 .56' or '12.34s.56' */ return -EINVAL; p = s; @@ -1063,7 +1079,7 @@ int parse_time(const char *t, usec_t *usec, usec_t default_unit) { r += k; } - /* Don't allow "0.-0", "3.+1", "3. 1", "3.sec" or "3.hoge"*/ + /* Don't allow "0.-0", "3.+1", "3. 1", "3.sec" or "3.hoge" */ if (b == e + 1) return -EINVAL; } @@ -1210,7 +1226,7 @@ int parse_nsec(const char *t, nsec_t *nsec) { s = extract_nsec_multiplier(p + strspn(p, WHITESPACE), &multiplier); if (s == p && *s != '\0') - /* Don't allow '12.34.56', but accept '12.34 .56' or '12.34s.56'*/ + /* Don't allow '12.34.56', but accept '12.34 .56' or '12.34s.56' */ return -EINVAL; p = s; @@ -1238,7 +1254,7 @@ int parse_nsec(const char *t, nsec_t *nsec) { r += k; } - /* Don't allow "0.-0", "3.+1", "3. 1", "3.sec" or "3.hoge"*/ + /* Don't allow "0.-0", "3.+1", "3. 1", "3.sec" or "3.hoge" */ if (b == e + 1) return -EINVAL; } @@ -1249,75 +1265,127 @@ int parse_nsec(const char *t, nsec_t *nsec) { return 0; } -int get_timezones(char ***ret) { +static int get_timezones_from_zone1970_tab(char ***ret) { _cleanup_fclose_ FILE *f = NULL; _cleanup_strv_free_ char **zones = NULL; - size_t n_zones = 0; int r; assert(ret); - zones = strv_new("UTC"); - if (!zones) - return -ENOMEM; + f = fopen("/usr/share/zoneinfo/zone1970.tab", "re"); + if (!f) + return -errno; - n_zones = 1; + for (;;) { + _cleanup_free_ char *line = NULL, *cc = NULL, *co = NULL, *tz = NULL; - f = fopen("/usr/share/zoneinfo/zone1970.tab", "re"); - if (f) { - for (;;) { - _cleanup_free_ char *line = NULL, *w = NULL; - char *p; - size_t k; + r = read_line(f, LONG_LINE_MAX, &line); + if (r < 0) + return r; + if (r == 0) + break; - r = read_line(f, LONG_LINE_MAX, &line); - if (r < 0) - return r; - if (r == 0) - break; + const char *p = line; + + /* Line format is: + * 'country codes' 'coordinates' 'timezone' 'comments' */ + r = extract_many_words(&p, NULL, 0, &cc, &co, &tz, NULL); + if (r < 0) + continue; - p = strstrip(line); + /* Lines that start with # are comments. */ + if (*cc == '#') + continue; + + r = strv_extend(&zones, tz); + if (r < 0) + return r; + } - if (isempty(p) || *p == '#') - continue; + *ret = TAKE_PTR(zones); + return 0; +} - /* Skip over country code */ - p += strcspn(p, WHITESPACE); - p += strspn(p, WHITESPACE); +static int get_timezones_from_tzdata_zi(char ***ret) { + _cleanup_fclose_ FILE *f = NULL; + _cleanup_strv_free_ char **zones = NULL; + int r; - /* Skip over coordinates */ - p += strcspn(p, WHITESPACE); - p += strspn(p, WHITESPACE); + f = fopen("/usr/share/zoneinfo/tzdata.zi", "re"); + if (!f) + return -errno; - /* Found timezone name */ - k = strcspn(p, WHITESPACE); - if (k <= 0) - continue; + for (;;) { + _cleanup_free_ char *line = NULL, *type = NULL, *f1 = NULL, *f2 = NULL; - w = strndup(p, k); - if (!w) - return -ENOMEM; + r = read_line(f, LONG_LINE_MAX, &line); + if (r < 0) + return r; + if (r == 0) + break; - if (!GREEDY_REALLOC(zones, n_zones + 2)) - return -ENOMEM; + const char *p = line; - zones[n_zones++] = TAKE_PTR(w); - zones[n_zones] = NULL; - } + /* The only lines we care about are Zone and Link lines. + * Zone line format is: + * 'Zone' 'timezone' ... + * Link line format is: + * 'Link' 'target' 'alias' + * See 'man zic' for more detail. */ + r = extract_many_words(&p, NULL, 0, &type, &f1, &f2, NULL); + if (r < 0) + continue; - strv_sort(zones); - strv_uniq(zones); + char *tz; + if (IN_SET(*type, 'Z', 'z')) + /* Zone lines have timezone in field 1. */ + tz = f1; + else if (IN_SET(*type, 'L', 'l')) + /* Link lines have timezone in field 2. */ + tz = f2; + else + /* Not a line we care about. */ + continue; - } else if (errno != ENOENT) - return -errno; + r = strv_extend(&zones, tz); + if (r < 0) + return r; + } *ret = TAKE_PTR(zones); + return 0; +} + +int get_timezones(char ***ret) { + _cleanup_strv_free_ char **zones = NULL; + int r; + + assert(ret); + + r = get_timezones_from_tzdata_zi(&zones); + if (r == -ENOENT) { + log_debug_errno(r, "Could not get timezone data from tzdata.zi, using zone1970.tab: %m"); + r = get_timezones_from_zone1970_tab(&zones); + if (r == -ENOENT) + log_debug_errno(r, "Could not get timezone data from zone1970.tab, using UTC: %m"); + } + if (r < 0 && r != -ENOENT) + return r; + /* Always include UTC */ + r = strv_extend(&zones, "UTC"); + if (r < 0) + return -ENOMEM; + + strv_sort(zones); + strv_uniq(zones); + + *ret = TAKE_PTR(zones); return 0; } #endif /* NM_IGNORED */ -bool timezone_is_valid(const char *name, int log_level) { +int verify_timezone(const char *name, int log_level) { bool slash = false; const char *p, *t; _cleanup_close_ int fd = -1; @@ -1325,26 +1393,26 @@ bool timezone_is_valid(const char *name, int log_level) { int r; if (isempty(name)) - return false; + return -EINVAL; /* Always accept "UTC" as valid timezone, since it's the fallback, even if user has no timezones installed. */ if (streq(name, "UTC")) - return true; + return 0; if (name[0] == '/') - return false; + return -EINVAL; for (p = name; *p; p++) { if (!(*p >= '0' && *p <= '9') && !(*p >= 'a' && *p <= 'z') && !(*p >= 'A' && *p <= 'Z') && !IN_SET(*p, '-', '_', '+', '/')) - return false; + return -EINVAL; if (*p == '/') { if (slash) - return false; + return -EINVAL; slash = true; } else @@ -1352,38 +1420,31 @@ bool timezone_is_valid(const char *name, int log_level) { } if (slash) - return false; + return -EINVAL; if (p - name >= PATH_MAX) - return false; + return -ENAMETOOLONG; t = strjoina("/usr/share/zoneinfo/", name); fd = open(t, O_RDONLY|O_CLOEXEC); - if (fd < 0) { - log_full_errno(log_level, errno, "Failed to open timezone file '%s': %m", t); - return false; - } + if (fd < 0) + return log_full_errno(log_level, errno, "Failed to open timezone file '%s': %m", t); r = fd_verify_regular(fd); - if (r < 0) { - log_full_errno(log_level, r, "Timezone file '%s' is not a regular file: %m", t); - return false; - } + if (r < 0) + return log_full_errno(log_level, r, "Timezone file '%s' is not a regular file: %m", t); r = loop_read_exact(fd, buf, 4, false); - if (r < 0) { - log_full_errno(log_level, r, "Failed to read from timezone file '%s': %m", t); - return false; - } + if (r < 0) + return log_full_errno(log_level, r, "Failed to read from timezone file '%s': %m", t); /* Magic from tzfile(5) */ - if (memcmp(buf, "TZif", 4) != 0) { - log_full(log_level, "Timezone file '%s' has wrong magic bytes", t); - return false; - } + if (memcmp(buf, "TZif", 4) != 0) + return log_full_errno(log_level, SYNTHETIC_ERRNO(EBADMSG), + "Timezone file '%s' has wrong magic bytes", t); - return true; + return 0; } bool clock_boottime_supported(void) { @@ -1445,7 +1506,7 @@ int get_timezone(char **ret) { r = readlink_malloc("/etc/localtime", &t); if (r == -ENOENT) { - /* If the symlink does not exist, assume "UTC", like glibc does*/ + /* If the symlink does not exist, assume "UTC", like glibc does */ z = strdup("UTC"); if (!z) return -ENOMEM; diff --git a/src/libnm-systemd-shared/src/basic/time-util.h b/src/libnm-systemd-shared/src/basic/time-util.h index cfde1898..895af882 100644 --- a/src/libnm-systemd-shared/src/basic/time-util.h +++ b/src/libnm-systemd-shared/src/basic/time-util.h @@ -111,20 +111,31 @@ usec_t triple_timestamp_by_clock(triple_timestamp *ts, clockid_t clock); usec_t timespec_load(const struct timespec *ts) _pure_; nsec_t timespec_load_nsec(const struct timespec *ts) _pure_; -struct timespec *timespec_store(struct timespec *ts, usec_t u); -struct timespec *timespec_store_nsec(struct timespec *ts, nsec_t n); +struct timespec* timespec_store(struct timespec *ts, usec_t u); +struct timespec* timespec_store_nsec(struct timespec *ts, nsec_t n); usec_t timeval_load(const struct timeval *tv) _pure_; -struct timeval *timeval_store(struct timeval *tv, usec_t u); +struct timeval* timeval_store(struct timeval *tv, usec_t u); -char *format_timestamp_style(char *buf, size_t l, usec_t t, TimestampStyle style); -char *format_timestamp_relative(char *buf, size_t l, usec_t t); -char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy); +char* format_timestamp_style(char *buf, size_t l, usec_t t, TimestampStyle style) _warn_unused_result_; +char* format_timestamp_relative(char *buf, size_t l, usec_t t) _warn_unused_result_; +char* format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) _warn_unused_result_; -static inline char *format_timestamp(char *buf, size_t l, usec_t t) { +_warn_unused_result_ +static inline char* format_timestamp(char *buf, size_t l, usec_t t) { return format_timestamp_style(buf, l, t, TIMESTAMP_PRETTY); } +/* Note: the lifetime of the compound literal is the immediately surrounding block, + * see C11 §6.5.2.5, and + * https://stackoverflow.com/questions/34880638/compound-literal-lifetime-and-if-blocks */ +#define FORMAT_TIMESTAMP(t) format_timestamp((char[FORMAT_TIMESTAMP_MAX]){}, FORMAT_TIMESTAMP_MAX, t) +#define FORMAT_TIMESTAMP_RELATIVE(t) \ + format_timestamp_relative((char[FORMAT_TIMESTAMP_RELATIVE_MAX]){}, FORMAT_TIMESTAMP_RELATIVE_MAX, t) +#define FORMAT_TIMESPAN(t, accuracy) format_timespan((char[FORMAT_TIMESPAN_MAX]){}, FORMAT_TIMESPAN_MAX, t, accuracy) +#define FORMAT_TIMESTAMP_STYLE(t, style) \ + format_timestamp_style((char[FORMAT_TIMESTAMP_MAX]){}, FORMAT_TIMESTAMP_MAX, t, style) + int parse_timestamp(const char *t, usec_t *usec); int parse_sec(const char *t, usec_t *usec); @@ -134,7 +145,10 @@ int parse_time(const char *t, usec_t *usec, usec_t default_unit); int parse_nsec(const char *t, nsec_t *nsec); int get_timezones(char ***l); -bool timezone_is_valid(const char *name, int log_level); +int verify_timezone(const char *name, int log_level); +static inline bool timezone_is_valid(const char *name, int log_level) { + return verify_timezone(name, log_level) >= 0; +} bool clock_boottime_supported(void); bool clock_supported(clockid_t clock); @@ -153,9 +167,8 @@ usec_t jiffies_to_usec(uint32_t jiffies); bool in_utc_timezone(void); static inline usec_t usec_add(usec_t a, usec_t b) { - - /* Adds two time values, and makes sure USEC_INFINITY as input results as USEC_INFINITY in output, and doesn't - * overflow. */ + /* Adds two time values, and makes sure USEC_INFINITY as input results as USEC_INFINITY in output, + * and doesn't overflow. */ if (a > USEC_INFINITY - b) /* overflow check */ return USEC_INFINITY; @@ -164,7 +177,6 @@ static inline usec_t usec_add(usec_t a, usec_t b) { } static inline usec_t usec_sub_unsigned(usec_t timestamp, usec_t delta) { - if (timestamp == USEC_INFINITY) /* Make sure infinity doesn't degrade */ return USEC_INFINITY; if (timestamp < delta) @@ -181,14 +193,14 @@ static inline usec_t usec_sub_signed(usec_t timestamp, int64_t delta) { } #if SIZEOF_TIME_T == 8 -/* The last second we can format is 31. Dec 9999, 1s before midnight, because otherwise we'd enter 5 digit year - * territory. However, since we want to stay away from this in all timezones we take one day off. */ -#define USEC_TIMESTAMP_FORMATTABLE_MAX ((usec_t) 253402214399000000) + /* The last second we can format is 31. Dec 9999, 1s before midnight, because otherwise we'd enter 5 digit + * year territory. However, since we want to stay away from this in all timezones we take one day off. */ +# define USEC_TIMESTAMP_FORMATTABLE_MAX ((usec_t) 253402214399000000) #elif SIZEOF_TIME_T == 4 /* With a 32bit time_t we can't go beyond 2038... */ -#define USEC_TIMESTAMP_FORMATTABLE_MAX ((usec_t) 2147483647000000) +# define USEC_TIMESTAMP_FORMATTABLE_MAX ((usec_t) 2147483647000000) #else -#error "Yuck, time_t is neither 4 nor 8 bytes wide?" +# error "Yuck, time_t is neither 4 nor 8 bytes wide?" #endif int time_change_fd(void); diff --git a/src/libnm-systemd-shared/src/basic/tmpfile-util.c b/src/libnm-systemd-shared/src/basic/tmpfile-util.c index fd470515..8a6404d3 100644 --- a/src/libnm-systemd-shared/src/basic/tmpfile-util.c +++ b/src/libnm-systemd-shared/src/basic/tmpfile-util.c @@ -305,11 +305,7 @@ int link_tmpfile(int fd, const char *path, const char *target) { if (r < 0) return r; } else { - char proc_fd_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(fd) + 1]; - - xsprintf(proc_fd_path, "/proc/self/fd/%i", fd); - - if (linkat(AT_FDCWD, proc_fd_path, AT_FDCWD, target, AT_SYMLINK_FOLLOW) < 0) + if (linkat(AT_FDCWD, FORMAT_PROC_FD_PATH(fd), AT_FDCWD, target, AT_SYMLINK_FOLLOW) < 0) return -errno; } diff --git a/src/libnm-systemd-shared/src/fundamental/macro-fundamental.h b/src/libnm-systemd-shared/src/fundamental/macro-fundamental.h index 96751860..20d8dabf 100644 --- a/src/libnm-systemd-shared/src/fundamental/macro-fundamental.h +++ b/src/libnm-systemd-shared/src/fundamental/macro-fundamental.h @@ -11,9 +11,26 @@ #define _const_ __attribute__((__const__)) #define _pure_ __attribute__((__pure__)) #define _section_(x) __attribute__((__section__(x))) +#define _packed_ __attribute__((__packed__)) #define _used_ __attribute__((__used__)) #define _unused_ __attribute__((__unused__)) #define _cleanup_(x) __attribute__((__cleanup__(x))) +#define _likely_(x) (__builtin_expect(!!(x), 1)) +#define _unlikely_(x) (__builtin_expect(!!(x), 0)) +#if __GNUC__ >= 7 +#define _fallthrough_ __attribute__((__fallthrough__)) +#else +#define _fallthrough_ +#endif +/* Define C11 noreturn without and even on older gcc + * compiler versions */ +#ifndef _noreturn_ +#if __STDC_VERSION__ >= 201112L +#define _noreturn_ _Noreturn +#else +#define _noreturn_ __attribute__((__noreturn__)) +#endif +#endif #define XSTRINGIFY(x) #x #define STRINGIFY(x) XSTRINGIFY(x) @@ -34,7 +51,14 @@ #define CONCATENATE(x, y) XCONCATENATE(x, y) #ifdef SD_BOOT -#define assert(expr) do {} while (false) + #ifdef NDEBUG + #define assert(expr) + #define assert_not_reached() __builtin_unreachable() + #else + void efi_assert(const char *expr, const char *file, unsigned line, const char *function) _noreturn_; + #define assert(expr) ({ _likely_(expr) ? VOID_0 : efi_assert(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); }) + #define assert_not_reached() efi_assert("Code should not be reached", __FILE__, __LINE__, __PRETTY_FUNCTION__) + #endif #endif #if defined(static_assert) @@ -70,12 +94,29 @@ UNIQ_T(A, aq) > UNIQ_T(B, bq) ? UNIQ_T(A, aq) : UNIQ_T(B, bq); \ }) -/* evaluates to (void) if _A or _B are not constant or of different types */ +#define IS_UNSIGNED_INTEGER_TYPE(type) \ + (__builtin_types_compatible_p(typeof(type), unsigned char) || \ + __builtin_types_compatible_p(typeof(type), unsigned short) || \ + __builtin_types_compatible_p(typeof(type), unsigned) || \ + __builtin_types_compatible_p(typeof(type), unsigned long) || \ + __builtin_types_compatible_p(typeof(type), unsigned long long)) + +#define IS_SIGNED_INTEGER_TYPE(type) \ + (__builtin_types_compatible_p(typeof(type), signed char) || \ + __builtin_types_compatible_p(typeof(type), signed short) || \ + __builtin_types_compatible_p(typeof(type), signed) || \ + __builtin_types_compatible_p(typeof(type), signed long) || \ + __builtin_types_compatible_p(typeof(type), signed long long)) + +/* Evaluates to (void) if _A or _B are not constant or of different types (being integers of different sizes + * is also OK as long as the signedness matches) */ #define CONST_MAX(_A, _B) \ (__builtin_choose_expr( \ __builtin_constant_p(_A) && \ __builtin_constant_p(_B) && \ - __builtin_types_compatible_p(typeof(_A), typeof(_B)), \ + (__builtin_types_compatible_p(typeof(_A), typeof(_B)) || \ + (IS_UNSIGNED_INTEGER_TYPE(_A) && IS_UNSIGNED_INTEGER_TYPE(_B)) || \ + (IS_SIGNED_INTEGER_TYPE(_A) && IS_SIGNED_INTEGER_TYPE(_B))), \ ((_A) > (_B)) ? (_A) : (_B), \ VOID_0)) @@ -216,3 +257,10 @@ (ptr) = NULL; \ _ptr_; \ }) + +/* + * STRLEN - return the length of a string literal, minus the trailing NUL byte. + * Contrary to strlen(), this is a constant expression. + * @x: a string literal. + */ +#define STRLEN(x) (sizeof(""x"") - sizeof(typeof(x[0]))) diff --git a/src/libnm-systemd-shared/src/fundamental/string-util-fundamental.c b/src/libnm-systemd-shared/src/fundamental/string-util-fundamental.c index c1abae6c..f1703926 100644 --- a/src/libnm-systemd-shared/src/fundamental/string-util-fundamental.c +++ b/src/libnm-systemd-shared/src/fundamental/string-util-fundamental.c @@ -79,6 +79,7 @@ sd_char* endswith_no_case(const sd_char *s, const sd_char *postfix) { return (sd_char*) s + sl - pl; } +#if 0 /* NM_IGNORED */ #ifdef SD_BOOT static sd_bool isdigit(sd_char a) { return a >= '0' && a <= '9'; @@ -154,7 +155,7 @@ sd_int strverscmp_improved(const sd_char *a, const sd_char *b) { * Note that except for '~' prefixed segments, a string has more segments is newer. * So, this check must be after the '~' check. */ if (*a == '\0' || *b == '\0') - return strcmp(a, b); + return CMP(*a, *b); /* Handle '-', which separates version and release, e.g 123.4-3.1.fc33.x86_64 */ if (*a == '-' || *b == '-') { @@ -196,9 +197,9 @@ sd_int strverscmp_improved(const sd_char *a, const sd_char *b) { /* Find the leading numeric segments. One may be an empty string. So, * numeric segments are always newer than alpha segments. */ - for (aa = a; *aa != '\0' && isdigit(*aa); aa++) + for (aa = a; isdigit(*aa); aa++) ; - for (bb = b; *bb != '\0' && isdigit(*bb); bb++) + for (bb = b; isdigit(*bb); bb++) ; /* To compare numeric segments without parsing their values, first compare the @@ -213,9 +214,9 @@ sd_int strverscmp_improved(const sd_char *a, const sd_char *b) { return r; } else { /* Find the leading non-numeric segments. */ - for (aa = a; *aa != '\0' && is_alpha(*aa); aa++) + for (aa = a; is_alpha(*aa); aa++) ; - for (bb = b; *bb != '\0' && is_alpha(*bb); bb++) + for (bb = b; is_alpha(*bb); bb++) ; /* Note that the segments are usually not NUL-terminated. */ @@ -234,3 +235,4 @@ sd_int strverscmp_improved(const sd_char *a, const sd_char *b) { b = bb; } } +#endif /* NM_IGNORED */ diff --git a/src/libnm-systemd-shared/src/fundamental/string-util-fundamental.h b/src/libnm-systemd-shared/src/fundamental/string-util-fundamental.h index 407cede4..7455c054 100644 --- a/src/libnm-systemd-shared/src/fundamental/string-util-fundamental.h +++ b/src/libnm-systemd-shared/src/fundamental/string-util-fundamental.h @@ -16,6 +16,7 @@ #define strncmp(a, b, n) StrnCmp((a), (b), (n)) #define strcasecmp(a, b) StriCmp((a), (b)) #define STR_C(str) (L ## str) +#define memcmp(a, b, n) CompareMem(a, b, n) #else #define STR_C(str) (str) #endif @@ -65,3 +66,19 @@ static inline const sd_char *yes_no(sd_bool b) { } sd_int strverscmp_improved(const sd_char *a, const sd_char *b); + +/* Like startswith(), but operates on arbitrary memory blocks */ +static inline void *memory_startswith(const void *p, sd_size_t sz, const sd_char *token) { + assert(token); + + sd_size_t n = strlen(token) * sizeof(sd_char); + if (sz < n) + return NULL; + + assert(p); + + if (memcmp(p, token, n) != 0) + return NULL; + + return (uint8_t*) p + n; +} diff --git a/src/libnm-systemd-shared/src/shared/log-link.h b/src/libnm-systemd-shared/src/shared/log-link.h index 51eaa0c0..5f2b1763 100644 --- a/src/libnm-systemd-shared/src/shared/log-link.h +++ b/src/libnm-systemd-shared/src/shared/log-link.h @@ -17,24 +17,6 @@ log_interface_full_errno_zerook(ifname, level, _error, __VA_ARGS__); \ }) -#define log_interface_prefix_full_errno_zerook(prefix, ifname_expr, error, fmt, ...) \ - ({ \ - int _e = (error); \ - if (DEBUG_LOGGING) \ - log_interface_full_errno_zerook( \ - ifname_expr, \ - LOG_DEBUG, _e, prefix fmt, \ - ##__VA_ARGS__); \ - -ERRNO_VALUE(_e); \ - }) - -#define log_interface_prefix_full_errno(prefix, ifname_expr, error, fmt, ...) \ - ({ \ - int _error = (error); \ - ASSERT_NON_ZERO(_error); \ - log_interface_prefix_full_errno_zerook(prefix, ifname_expr, _error, fmt, ##__VA_ARGS__); \ - }) - /* * The following macros append INTERFACE= to the message. * The macros require a struct named 'Link' which contains 'char *ifname': diff --git a/src/libnm-systemd-shared/src/shared/web-util.c b/src/libnm-systemd-shared/src/shared/web-util.c index 35ba1a2e..85532bdf 100644 --- a/src/libnm-systemd-shared/src/shared/web-util.c +++ b/src/libnm-systemd-shared/src/shared/web-util.c @@ -45,16 +45,29 @@ bool http_etag_is_valid(const char *etag) { /**/ } #if 0 /* NM_IGNORED */ +bool file_url_is_valid(const char *url) { + const char *p; + + if (isempty(url)) + return false; + + p = startswith(url, "file:/"); + if (isempty(p)) + return false; + + return ascii_is_valid(p); +} + bool documentation_url_is_valid(const char *url) { const char *p; if (isempty(url)) return false; - if (http_url_is_valid(url)) + if (http_url_is_valid(url) || file_url_is_valid(url)) return true; - p = STARTSWITH_SET(url, "file:/", "info:", "man:"); + p = STARTSWITH_SET(url, "info:", "man:"); if (isempty(p)) return false; diff --git a/src/libnm-systemd-shared/src/shared/web-util.h b/src/libnm-systemd-shared/src/shared/web-util.h index ec54669f..88b4897b 100644 --- a/src/libnm-systemd-shared/src/shared/web-util.h +++ b/src/libnm-systemd-shared/src/shared/web-util.h @@ -6,6 +6,7 @@ #include "macro.h" bool http_url_is_valid(const char *url) _pure_; +bool file_url_is_valid(const char *url) _pure_; bool documentation_url_is_valid(const char *url) _pure_; diff --git a/src/libnmc-base/nm-vpn-helpers.c b/src/libnmc-base/nm-vpn-helpers.c index 72691e34..99a69276 100644 --- a/src/libnmc-base/nm-vpn-helpers.c +++ b/src/libnmc-base/nm-vpn-helpers.c @@ -236,7 +236,7 @@ nm_vpn_openconnect_authenticate_helper(const char *host, * HOST='1.2.3.4' * FINGERPRINT='sha1:32bac90cf09a722e10ecc1942c67fe2ac8c21e2e' */ - output_v = nm_utils_strsplit_set_with_empty(output, "\r\n"); + output_v = nm_strsplit_set_with_empty(output, "\r\n"); for (iter = output_v; iter && *iter; iter++) { char *s_mutable = (char *) *iter; @@ -746,7 +746,7 @@ fail_invalid_secret: GPtrArray * data_addr = is_v4 ? data_addr_v4 : data_addr_v6; GPtrArray * data_dns_search2 = data_dns_search; - if (data_dns && !data_addr) { + if (!data_addr) { /* When specifying "DNS", we also require an "Address" for the same address * family. That is because a NMSettingIPConfig cannot have @method_disabled * and DNS settings at the same time. @@ -761,11 +761,6 @@ fail_invalid_secret: data_addr ? method_manual : method_disabled, NULL); - /* For WireGuard profiles, always set dns-priority to a negative value, - * so that DNS servers on other profiles get ignored. This is also what - * wg-quick does, by calling `resolvconf -x`. */ - g_object_set(s_ip, NM_SETTING_IP_CONFIG_DNS_PRIORITY, (int) -50, NULL); - if (data_addr) { for (i = 0; i < data_addr->len; i++) nm_setting_ip_config_add_address(s_ip, data_addr->pdata[i]); diff --git a/src/libnmc-base/qrcodegen.c b/src/libnmc-base/qrcodegen.c index 2c40fcb9..0aacdb01 100644 --- a/src/libnmc-base/qrcodegen.c +++ b/src/libnmc-base/qrcodegen.c @@ -28,9 +28,9 @@ #include "qrcodegen.h" #ifndef QRCODEGEN_TEST - #define testable static // Keep functions private +#define testable static // Keep functions private #else - #define testable // Expose private functions +#define testable // Expose private functions #endif /*---- Forward declarations for private functions ----*/ diff --git a/src/libnmc-setting/nm-meta-setting-base-impl.c b/src/libnmc-setting/nm-meta-setting-base-impl.c index a952ced9..8c1ad10e 100644 --- a/src/libnmc-setting/nm-meta-setting-base-impl.c +++ b/src/libnmc-setting/nm-meta-setting-base-impl.c @@ -8,7 +8,7 @@ #include "nm-meta-setting-base.h" #if _NM_META_SETTING_BASE_IMPL_LIBNM - #include "libnm-core-impl/nm-default-libnm-core.h" +#include "libnm-core-impl/nm-default-libnm-core.h" #endif #include "nm-setting-6lowpan.h" @@ -16,6 +16,7 @@ #include "nm-setting-adsl.h" #include "nm-setting-bluetooth.h" #include "nm-setting-bond.h" +#include "nm-setting-bond-port.h" #include "nm-setting-bridge-port.h" #include "nm-setting-bridge.h" #include "nm-setting-cdma.h" @@ -64,7 +65,7 @@ #include "nm-setting-wpan.h" #if _NM_META_SETTING_BASE_IMPL_LIBNM - #include "nm-setting-private.h" +#include "nm-setting-private.h" #endif /*****************************************************************************/ @@ -190,6 +191,13 @@ const NMMetaSettingInfo nm_meta_setting_infos[] = { .setting_name = NM_SETTING_BOND_SETTING_NAME, .get_setting_gtype = nm_setting_bond_get_type, }, + [NM_META_SETTING_TYPE_BOND_PORT] = + { + .meta_type = NM_META_SETTING_TYPE_BOND_PORT, + .setting_priority = NM_SETTING_PRIORITY_AUX, + .setting_name = NM_SETTING_BOND_PORT_SETTING_NAME, + .get_setting_gtype = nm_setting_bond_port_get_type, + }, [NM_META_SETTING_TYPE_BRIDGE] = { .meta_type = NM_META_SETTING_TYPE_BRIDGE, @@ -568,6 +576,7 @@ const NMMetaSettingType nm_meta_setting_types_by_priority[] = { NM_META_SETTING_TYPE_SRIOV, /* NM_SETTING_PRIORITY_AUX */ + NM_META_SETTING_TYPE_BOND_PORT, NM_META_SETTING_TYPE_BRIDGE_PORT, NM_META_SETTING_TYPE_ETHTOOL, NM_META_SETTING_TYPE_MATCH, diff --git a/src/libnmc-setting/nm-meta-setting-base-impl.h b/src/libnmc-setting/nm-meta-setting-base-impl.h index 44bd9024..eba1fb96 100644 --- a/src/libnmc-setting/nm-meta-setting-base-impl.h +++ b/src/libnmc-setting/nm-meta-setting-base-impl.h @@ -110,6 +110,7 @@ typedef enum _nm_packed { NM_META_SETTING_TYPE_ADSL, NM_META_SETTING_TYPE_BLUETOOTH, NM_META_SETTING_TYPE_BOND, + NM_META_SETTING_TYPE_BOND_PORT, NM_META_SETTING_TYPE_BRIDGE, NM_META_SETTING_TYPE_BRIDGE_PORT, NM_META_SETTING_TYPE_CDMA, @@ -159,9 +160,9 @@ typedef enum _nm_packed { } NMMetaSettingType; #if _NM_META_SETTING_BASE_IMPL_LIBNM - #define _NMMetaSettingInfo_Alias _NMMetaSettingInfo +#define _NMMetaSettingInfo_Alias _NMMetaSettingInfo #else - #define _NMMetaSettingInfo_Alias _NMMetaSettingInfoCli +#define _NMMetaSettingInfo_Alias _NMMetaSettingInfoCli #endif struct _NMMetaSettingInfo_Alias { diff --git a/src/libnmc-setting/nm-meta-setting-desc.c b/src/libnmc-setting/nm-meta-setting-desc.c index 1cc5f9c1..5bb2b451 100644 --- a/src/libnmc-setting/nm-meta-setting-desc.c +++ b/src/libnmc-setting/nm-meta-setting-desc.c @@ -191,14 +191,13 @@ _value_strsplit(const char *value, ValueStrsplitMode split_mode, gsize *out_len) /* note that all modes remove empty tokens (",", "a,,b", ",,"). */ switch (split_mode) { case VALUE_STRSPLIT_MODE_OBJLIST: - strv = nm_utils_strsplit_set_full(value, - ESCAPED_TOKENS_DELIMITERS, - NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP); + strv = + nm_strsplit_set_full(value, ESCAPED_TOKENS_DELIMITERS, NM_STRSPLIT_SET_FLAGS_STRSTRIP); break; case VALUE_STRSPLIT_MODE_MULTILIST: - strv = nm_utils_strsplit_set_full(value, - ESCAPED_TOKENS_WITH_SPACES_DELIMTERS, - NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP); + strv = nm_strsplit_set_full(value, + ESCAPED_TOKENS_WITH_SPACES_DELIMTERS, + NM_STRSPLIT_SET_FLAGS_STRSTRIP); break; case VALUE_STRSPLIT_MODE_ESCAPED_TOKENS: strv = nm_utils_escaped_tokens_split(value, ESCAPED_TOKENS_DELIMITERS); @@ -309,7 +308,7 @@ _parse_ip_route(int family, const char *str, GError **error) nm_assert(!error || !*error); str_clean = nm_strstrip_avoid_copy_a(300, str, &str_clean_free); - routev = nm_utils_strsplit_set(str_clean, " \t"); + routev = nm_strsplit_set(str_clean, " \t"); if (!routev) { g_set_error(error, 1, 0, "'%s' is not valid. %s", str, ROUTE_SYNTAX); return NULL; @@ -922,7 +921,7 @@ _get_fcn_gobject_impl(const NMMetaPropertyInfo *property_info, nm_assert(property_info->property_type->set_fcn == _set_fcn_optionlist); strdict = g_value_get_boxed(&val); - keys = nm_utils_strdict_get_keys(strdict, TRUE, NULL); + keys = nm_strdict_get_keys(strdict, TRUE, NULL); if (!keys) return NULL; @@ -1494,7 +1493,7 @@ static gboolean _set_fcn_gobject_mtu(ARGS_SET_FCN) /* Ideally we'll be able to get this from a public header. */ #ifndef IEEE802154_ADDR_LEN - #define IEEE802154_ADDR_LEN 8 +#define IEEE802154_ADDR_LEN 8 #endif static gboolean _set_fcn_gobject_mac(ARGS_SET_FCN) @@ -1702,7 +1701,7 @@ static const char *const *_values_fcn_gobject_enum(ARGS_VALUES_FCN) /* the gobject_enum.value_infos are currently ignored for the list of * values. They only declare additional (hidden) aliases for the setter. */ - v = nm_utils_strv_make_deep_copied(nm_utils_enum_get_values(gtype, min, max)); + v = nm_strv_make_deep_copied(nm_utils_enum_get_values(gtype, min, max)); return (const char *const *) (*out_to_free = v); } @@ -2271,7 +2270,7 @@ static gboolean _set_fcn_gobject_bytes(ARGS_SET_FCN) } /* Otherwise, consider the following format: AA b 0xCc D */ - strv = nm_utils_strsplit_set(value, " \t"); + strv = nm_strsplit_set(value, " \t"); array = g_byte_array_sized_new(NM_PTRARRAY_LEN(strv)); for (iter = strv; iter && *iter; iter++) { int v; @@ -2916,7 +2915,7 @@ static gboolean _set_fcn_dcb_flags(ARGS_SET_FCN) const char *const * iter; /* Check for individual flag numbers */ - strv = nm_utils_strsplit_set(value, " \t,"); + strv = nm_strsplit_set(value, " \t,"); for (iter = strv; iter && *iter; iter++) { t = _nm_utils_ascii_str_to_int64(*iter, 0, 0, DCB_ALL_FLAGS, -1); @@ -2957,7 +2956,7 @@ dcb_parse_uint_array(const char *val, const char *const * iter; gsize i; - items = nm_utils_strsplit_set_with_empty(val, ","); + items = nm_strsplit_set_with_empty(val, ","); if (NM_PTRARRAY_LEN(items) != 8) { g_set_error_literal(error, 1, 0, _("must contain 8 comma-separated numbers")); return FALSE; @@ -3589,7 +3588,7 @@ _multilist_remove_by_value_fcn_ip_config_dhcp_reject_servers(NMSettingIPConfig * gssize idx; strv = nm_setting_ip_config_get_dhcp_reject_servers(setting, &num); - idx = nm_utils_strv_find_first((char **) strv, num, item); + idx = nm_strv_find_first(strv, num, item); if (idx >= 0) nm_setting_ip_config_remove_dhcp_reject_server(setting, idx); return TRUE; @@ -4033,7 +4032,7 @@ static gboolean _set_fcn_wired_s390_subchannels(ARGS_SET_FCN) if (_SET_FCN_DO_RESET_DEFAULT(property_info, modifier, value)) return _gobject_property_reset_default(setting, property_info->property_name); - strv = nm_utils_strsplit_set(value, " ,\t"); + strv = nm_strsplit_set(value, " ,\t"); len = NM_PTRARRAY_LEN(strv); if (len != 2 && len != 3) { g_set_error(error, 1, 0, _("'%s' is not valid; 2 or 3 strings should be provided"), value); @@ -4318,7 +4317,7 @@ static gboolean _set_fcn_ethtool(ARGS_SET_FCN) if (!nmc_string_to_ternary_full(value, NMC_STRING_TO_TERNARY_FLAGS_IGNORE_FOR_DEFAULT, &t, - error)) { + NULL)) { g_set_error(error, NM_UTILS_ERROR, NM_UTILS_ERROR_INVALID_ARGUMENT, @@ -5049,6 +5048,18 @@ static const NMMetaPropertyInfo *const property_infos_BOND[] = { NULL }; +#undef _CURRENT_NM_META_SETTING_TYPE +#define _CURRENT_NM_META_SETTING_TYPE NM_META_SETTING_TYPE_BOND_PORT +static const NMMetaPropertyInfo *const property_infos_BOND_PORT[] = { + PROPERTY_INFO_WITH_DESC (NM_SETTING_BOND_PORT_QUEUE_ID, + .is_cli_option = TRUE, + .property_alias = "queue-id", + .prompt = N_("Queue ID [0]"), + .property_type = &_pt_gobject_int, + ), + NULL +}; + #undef _CURRENT_NM_META_SETTING_TYPE #define _CURRENT_NM_META_SETTING_TYPE NM_META_SETTING_TYPE_BRIDGE static const NMMetaPropertyInfo *const property_infos_BRIDGE[] = { @@ -5462,6 +5473,14 @@ static const NMMetaPropertyInfo *const property_infos_CONNECTION[] = { ), ), ), + PROPERTY_INFO_WITH_DESC (NM_SETTING_CONNECTION_DNS_OVER_TLS, + .property_type = &_pt_gobject_enum, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( + PROPERTY_TYP_DATA_SUBTYPE (gobject_enum, + .get_gtype = nm_setting_connection_dns_over_tls_get_type, + ), + ), + ), PROPERTY_INFO_WITH_DESC (NM_SETTING_CONNECTION_MUD_URL, .property_type = &_pt_gobject_string, .hide_if_default = TRUE, @@ -8114,6 +8133,7 @@ _setting_init_fcn_wireless (ARGS_SETTING_INIT_FCN) #define SETTING_PRETTY_NAME_ADSL N_("ADSL connection") #define SETTING_PRETTY_NAME_BLUETOOTH N_("bluetooth connection") #define SETTING_PRETTY_NAME_BOND N_("Bond device") +#define SETTING_PRETTY_NAME_BOND_PORT N_("Bond port") #define SETTING_PRETTY_NAME_BRIDGE N_("Bridge device") #define SETTING_PRETTY_NAME_BRIDGE_PORT N_("Bridge port") #define SETTING_PRETTY_NAME_CDMA N_("CDMA mobile broadband connection") @@ -8218,6 +8238,7 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = { NM_META_SETTING_VALID_PART_ITEM (ETHTOOL, FALSE), ), ), + SETTING_INFO (BOND_PORT), SETTING_INFO (BRIDGE, .valid_parts = NM_META_SETTING_VALID_PARTS ( NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE), @@ -8498,6 +8519,11 @@ static const NMMetaSettingValidPartItem *const valid_settings_noslave[] = { NULL, }; +static const NMMetaSettingValidPartItem *const valid_settings_slave_bond[] = { + NM_META_SETTING_VALID_PART_ITEM(BOND_PORT, TRUE), + NULL, +}; + static const NMMetaSettingValidPartItem *const valid_settings_slave_bridge[] = { NM_META_SETTING_VALID_PART_ITEM(BRIDGE_PORT, TRUE), NULL, @@ -8527,7 +8553,7 @@ nm_meta_setting_info_valid_parts_for_slave_type(const char *slave_type, const ch } if (nm_streq(slave_type, NM_SETTING_BOND_SETTING_NAME)) { NM_SET_OUT(out_slave_name, "bond-slave"); - return NM_PTRARRAY_EMPTY(const NMMetaSettingValidPartItem *); + return valid_settings_slave_bond; } if (nm_streq(slave_type, NM_SETTING_BRIDGE_SETTING_NAME)) { NM_SET_OUT(out_slave_name, "bridge-slave"); diff --git a/src/libnmc-setting/settings-docs-input.xml b/src/libnmc-setting/settings-docs-input.xml index 2481d1da..3555f302 100644 --- a/src/libnmc-setting/settings-docs-input.xml +++ b/src/libnmc-setting/settings-docs-input.xml @@ -1 +1,434 @@ - \ No newline at end of file + + +Array of TC queueing disciplines. qdisc is a basic block in the +Linux traffic control subsystem + + +Each qdisc can be specified by the following attributes: + + + + +handle HANDLE + + + +specifies the qdisc handle. A qdisc, which potentially can have children, gets +assigned a major number, called a 'handle', leaving the minor number namespace +available for classes. The handle is expressed as '10:'. It is customary to +explicitly assign a handle to qdiscs expected to have children. + + + + + +parent HANDLE + + + +specifies the handle of the parent qdisc the current qdisc must be +attached to. + + + + + +root + + + +specifies that the qdisc is attached to the root of device. + + + + + +KIND + + + +this is the qdisc kind. NetworkManager currently supports the +following kinds: fq_codel, sfq, tbf. Each qdisc kind has a +different set of parameters, described below. There are also some +kinds like pfifo, pfifo_fast, prio supported by NetworkManager +but their parameters are not supported by NetworkManager. + + + + + +Parameters for 'fq_codel': + + + + +limit U32 + + + +the hard limit on the real queue size. When this limit is +reached, incoming packets are dropped. Default is 10240 packets. + + + + + +memory_limit U32 + + + +sets a limit on the total number of bytes that can be queued in +this FQ-CoDel instance. The lower of the packet limit of the +limit parameter and the memory limit will be enforced. Default is +32 MB. + + + + + +flows U32 + + + +the number of flows into which the incoming packets are +classified. Due to the stochastic nature of hashing, multiple +flows may end up being hashed into the same slot. Newer flows +have priority over older ones. This parameter can be set only at +load time since memory has to be allocated for the hash table. +Default value is 1024. + + + + + +target U32 + + + +the acceptable minimum standing/persistent queue delay. This minimum +delay is identified by tracking the local minimum queue delay that packets +experience. The unit of measurement is microsecond(us). Default value is 5ms. + + + + + +interval U32 + + + +used to ensure that the measured minimum delay does not become too stale. +The minimum delay must be experienced in the last epoch of length .B +interval. It should be set on the order of the worst-case RTT +through the bottleneck to give endpoints sufficient time to +react. Default value is 100ms. + + + + + +quantum U32 + + + +the number of bytes used as 'deficit' in the fair queuing +algorithm. Default is set to 1514 bytes which corresponds to the +Ethernet MTU plus the hardware header length of 14 bytes. + + + + + +ecn BOOL + + + +can be used to mark packets instead of dropping them. ecn is turned +on by default. + + + + + +ce_threshold U32 + + + +sets a threshold above which all packets are marked with ECN +Congestion Experienced. This is useful for DCTCP-style congestion +control algorithms that require marking at very shallow queueing +thresholds. + + + + + +Parameters for 'sfq': + + + + +divisor U32 + + + +can be used to set a different hash table size, available +from kernel 2.6.39 onwards. The specified divisor must be +a power of two and cannot be larger than 65536. Default +value: 1024. + + + + + +limit U32 + + + +Upper limit of the SFQ. Can be used to reduce the default +length of 127 packets. + + + + + +depth U32 + + + +Limit of packets per flow. Default to +127 and can be lowered. + + + + + +perturb_period U32 + + + +Interval in seconds for queue algorithm perturbation. +Defaults to 0, which means that no perturbation occurs. Do +not set too low for each perturbation may cause some +packet reordering or losses. Advised value: 60 This value +has no effect when external flow classification is used. +Its better to increase divisor value to lower risk of hash +collisions. + + + + + +quantum U32 + + + +Amount of bytes a flow is allowed to dequeue during a +round of the round robin process. Defaults to the MTU of +the interface which is also the advised value and the +minimum value. + + + + + +flows U32 + + + +Default value is 127. + + + + + +Parameters for 'tbf': + + + + +rate U64 + + + +Bandwidth or rate. These parameters accept a floating +point number, possibly followed by either a unit (both SI +and IEC units supported), or a float followed by a percent +character to specify the rate as a percentage of the +device's speed. + + + + + +burst U32 + + + +Also known as buffer or maxburst. Size of the bucket, in +bytes. This is the maximum amount of bytes that tokens can +be available for instantaneously. In general, larger +shaping rates require a larger buffer. For 10mbit/s on +Intel, you need at least 10kbyte buffer if you want to +reach your configured rate! + + +If your buffer is too small, packets may be dropped +because more tokens arrive per timer tick than fit in your +bucket. The minimum buffer size can be calculated by +dividing the rate by HZ. + + +Token usage calculations are performed using a table which +by default has a resolution of 8 packets. This resolution +can be changed by specifying the cell size with the burst. +For example, to specify a 6000 byte buffer with a 16 byte +cell size, set a burst of 6000/16. You will probably never +have to set this. Must be an integral power of 2. + + + + + +limit U32 + + + +Limit is the number of bytes that can be queued waiting +for tokens to become available. + + + + + +latency U32 + + + +specifies the maximum amount of time a packet can +sit in the TBF. The latency calculation takes into account +the size of the bucket, the rate and possibly the peakrate +(if set). The latency and limit are mutually exclusive. + + + + + + + +Array of TC traffic filters. Traffic control can manage the packet content during +classification by using filters. + + +Each tfilters can be specified by the following attributes: + + + + +handle HANDLE + + + +specifies the tfilters handle. A filter is used by a classful qdisc to determine in which class +a packet will be enqueued. It is important to notice that filters reside within qdiscs. Therefore, +see qdiscs handle for detailed information. + + + + + +parent HANDLE + + + +specifies the handle of the parent qdisc the current qdisc must be +attached to. + + + + + +root + + + +specifies that the qdisc is attached to the root of device. + + + + + +KIND + + + +this is the tfilters kind. NetworkManager currently supports +following kinds: mirred, simple. Each filter kind has a +different set of actions, described below. There are also some +other kinds like matchall, basic, u32 supported by NetworkManager. + + + + + +Actions for 'mirred': + + + + +egress bool + + + +Define whether the packet should exit from the interface. + + + + + +ingress bool + + + +Define whether the packet should come into the interface. + + + + + +mirror bool + + + +Define whether the packet should be copied to the destination space. + + + + + +redirect bool + + + +Define whether the packet should be moved to the destination space. + + + + + +Action for 'simple': + + + + +sdata char[32] + + + +The actual string to print. + + + + + + \ No newline at end of file diff --git a/src/libnmc-setting/settings-docs.h b/src/libnmc-setting/settings-docs.h index 85c5aca1..06346b1e 100644 --- a/src/libnmc-setting/settings-docs.h +++ b/src/libnmc-setting/settings-docs.h @@ -99,7 +99,7 @@ #define DESCRIBE_DOC_NM_SETTING_WIRED_MTU N_("If non-zero, only transmit packets of the specified size or smaller, breaking larger packets up into multiple Ethernet frames.") #define DESCRIBE_DOC_NM_SETTING_WIRED_PORT N_("Specific port type to use if the device supports multiple attachment methods. One of \"tp\" (Twisted Pair), \"aui\" (Attachment Unit Interface), \"bnc\" (Thin Ethernet) or \"mii\" (Media Independent Interface). If the device supports only one port type, this setting is ignored.") #define DESCRIBE_DOC_NM_SETTING_WIRED_S390_NETTYPE N_("s390 network device type; one of \"qeth\", \"lcs\", or \"ctc\", representing the different types of virtual network devices available on s390 systems.") -#define DESCRIBE_DOC_NM_SETTING_WIRED_S390_OPTIONS N_("Dictionary of key/value pairs of s390-specific device options. Both keys and values must be strings. Allowed keys include \"portno\", \"layer2\", \"portname\", \"protocol\", among others. Key names must contain only alphanumeric characters (ie, [a-zA-Z0-9]).") +#define DESCRIBE_DOC_NM_SETTING_WIRED_S390_OPTIONS N_("Dictionary of key/value pairs of s390-specific device options. Both keys and values must be strings. Allowed keys include \"portno\", \"layer2\", \"portname\", \"protocol\", among others. Key names must contain only alphanumeric characters (ie, [a-zA-Z0-9]). Currently, NetworkManager itself does nothing with this information. However, s390utils ships a udev rule which parses this information and applies it to the interface.") #define DESCRIBE_DOC_NM_SETTING_WIRED_S390_SUBCHANNELS N_("Identifies specific subchannels that this network device uses for communication with z/VM or s390 host. Like the \"mac-address\" property for non-z/VM devices, this property can be used to ensure this connection only applies to the network device that uses these subchannels. The list should contain exactly 3 strings, and each string may only be composed of hexadecimal characters and the period (.) character.") #define DESCRIBE_DOC_NM_SETTING_WIRED_SPEED N_("When a value greater than 0 is set, configures the device to use the specified speed. If \"auto-negotiate\" is \"yes\" the specified speed will be the only one advertised during link negotiation: this works only for BASE-T 802.3 specifications and is useful for enforcing gigabit speeds, as in this case link negotiation is mandatory. If the value is unset (0, the default), the link configuration will be either skipped (if \"auto-negotiate\" is \"no\", the default) or will be auto-negotiated (if \"auto-negotiate\" is \"yes\") and the local device will advertise all the supported speeds. In Mbit/s, ie 100 == 100Mbit/s. Must be set together with the \"duplex\" property when non-zero. Before specifying a speed value be sure your device supports it.") #define DESCRIBE_DOC_NM_SETTING_WIRED_WAKE_ON_LAN N_("The NMSettingWiredWakeOnLan options to enable. Not all devices support all options. May be any combination of NM_SETTING_WIRED_WAKE_ON_LAN_PHY (0x2), NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST (0x4), NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST (0x8), NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST (0x10), NM_SETTING_WIRED_WAKE_ON_LAN_ARP (0x20), NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC (0x40) or the special values NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT (0x1) (to use global settings) and NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE (0x8000) (to disable management of Wake-on-LAN in NetworkManager).") @@ -114,6 +114,7 @@ #define DESCRIBE_DOC_NM_SETTING_BLUETOOTH_BDADDR N_("The Bluetooth address of the device.") #define DESCRIBE_DOC_NM_SETTING_BLUETOOTH_TYPE N_("Either \"dun\" for Dial-Up Networking connections or \"panu\" for Personal Area Networking connections to devices supporting the NAP profile.") #define DESCRIBE_DOC_NM_SETTING_BOND_OPTIONS N_("Dictionary of key/value pairs of bonding options. Both keys and values must be strings. Option names must contain only alphanumeric characters (ie, [a-zA-Z0-9]).") +#define DESCRIBE_DOC_NM_SETTING_BOND_PORT_QUEUE_ID N_("The queue ID of this bond port. The maximum value of queue ID is the number of TX queues currently active in device.") #define DESCRIBE_DOC_NM_SETTING_BRIDGE_AGEING_TIME N_("The Ethernet MAC address aging time, in seconds.") #define DESCRIBE_DOC_NM_SETTING_BRIDGE_FORWARD_DELAY N_("The Spanning Tree Protocol (STP) forwarding delay, in seconds.") #define DESCRIBE_DOC_NM_SETTING_BRIDGE_GROUP_ADDRESS N_("If specified, The MAC address of the multicast group this bridge uses for STP. The address must be a link-local address in standard Ethernet MAC address format, ie an address of the form 01:80:C2:00:00:0X, with X in [0, 4..F]. If not specified the default value is 01:80:C2:00:00:00.") @@ -151,10 +152,11 @@ #define DESCRIBE_DOC_NM_SETTING_CDMA_PASSWORD_FLAGS N_("Flags indicating how to handle the \"password\" property.") #define DESCRIBE_DOC_NM_SETTING_CDMA_USERNAME N_("The username used to authenticate with the network, if required. Many providers do not require a username, or accept any username. But if a username is required, it is specified here.") #define DESCRIBE_DOC_NM_SETTING_CONNECTION_AUTH_RETRIES N_("The number of retries for the authentication. Zero means to try indefinitely; -1 means to use a global default. If the global default is not set, the authentication retries for 3 times before failing the connection. Currently, this only applies to 802-1x authentication.") -#define DESCRIBE_DOC_NM_SETTING_CONNECTION_AUTOCONNECT N_("Whether or not the connection should be automatically connected by NetworkManager when the resources for the connection are available. TRUE to automatically activate the connection, FALSE to require manual intervention to activate the connection. Note that autoconnect is not implemented for VPN profiles. See \"secondaries\" as an alternative to automatically connect VPN profiles.") -#define DESCRIBE_DOC_NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY N_("The autoconnect priority. If the connection is set to autoconnect, connections with higher priority will be preferred. Defaults to 0. The higher number means higher priority.") +#define DESCRIBE_DOC_NM_SETTING_CONNECTION_AUTOCONNECT N_("Whether or not the connection should be automatically connected by NetworkManager when the resources for the connection are available. TRUE to automatically activate the connection, FALSE to require manual intervention to activate the connection. Autoconnect happens when the circumstances are suitable. That means for example that the device is currently managed and not active. Autoconnect thus never replaces or competes with an already active profile. Note that autoconnect is not implemented for VPN profiles. See \"secondaries\" as an alternative to automatically connect VPN profiles.") +#define DESCRIBE_DOC_NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY N_("The autoconnect priority in range -999 to 999. If the connection is set to autoconnect, connections with higher priority will be preferred. The higher number means higher priority. Defaults to 0. Note that this property only matters if there are more than one candidate profile to select for autoconnect. In case of equal priority, the profile used most recently is chosen.") #define DESCRIBE_DOC_NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES N_("The number of times a connection should be tried when autoactivating before giving up. Zero means forever, -1 means the global default (4 times if not overridden). Setting this to 1 means to try activation only once before blocking autoconnect. Note that after a timeout, NetworkManager will try to autoconnect again.") #define DESCRIBE_DOC_NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES N_("Whether or not slaves of this connection should be automatically brought up when NetworkManager activates this connection. This only has a real effect for master connections. The properties \"autoconnect\", \"autoconnect-priority\" and \"autoconnect-retries\" are unrelated to this setting. The permitted values are: 0: leave slave connections untouched, 1: activate all the slave connections with this connection, -1: default. If -1 (default) is set, global connection.autoconnect-slaves is read to determine the real value. If it is default as well, this fallbacks to 0.") +#define DESCRIBE_DOC_NM_SETTING_CONNECTION_DNS_OVER_TLS N_("Whether DNSOverTls (dns-over-tls) is enabled for the connection. DNSOverTls is a technology which uses TLS to encrypt dns traffic. The permitted values are: \"yes\" (2) use DNSOverTls and disabled fallback, \"opportunistic\" (1) use DNSOverTls but allow fallback to unencrypted resolution, \"no\" (0) don't ever use DNSOverTls. If unspecified \"default\" depends on the plugin used. Systemd-resolved uses global setting. This feature requires a plugin which supports DNSOverTls. Otherwise, the setting has no effect. One such plugin is dns-systemd-resolved.") #define DESCRIBE_DOC_NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT N_("If greater than zero, delay success of IP addressing until either the timeout is reached, or an IP gateway replies to a ping.") #define DESCRIBE_DOC_NM_SETTING_CONNECTION_ID N_("A human readable unique identifier for the connection, like \"Work Wi-Fi\" or \"T-Mobile 3G\".") #define DESCRIBE_DOC_NM_SETTING_CONNECTION_INTERFACE_NAME N_("The name of the network interface this connection is bound to. If not set, then the connection can be attached to any interface of the appropriate type (subject to restrictions imposed by other settings). For software devices this specifies the name of the created device. For connection types where interface names cannot easily be made persistent (e.g. mobile broadband or USB Ethernet), this property should not be used. Setting this property restricts the interfaces a connection can be used with, and if interface names change or are reordered the connection may be applied to the wrong interface.") @@ -176,7 +178,7 @@ #define DESCRIBE_DOC_NM_SETTING_CONNECTION_WAIT_DEVICE_TIMEOUT N_("Timeout in milliseconds to wait for device at startup. During boot, devices may take a while to be detected by the driver. This property will cause to delay NetworkManager-wait-online.service and nm-online to give the device a chance to appear. This works by waiting for the given timeout until a compatible device for the profile is available and managed. The value 0 means no wait time. The default value is -1, which currently has the same meaning as no wait time.") #define DESCRIBE_DOC_NM_SETTING_CONNECTION_ZONE N_("The trust level of a the connection. Free form case-insensitive string (for example \"Home\", \"Work\", \"Public\"). NULL or unspecified zone means the connection will be placed in the default zone as defined by the firewall. When updating this property on a currently activated connection, the change takes effect immediately.") #define DESCRIBE_DOC_NM_SETTING_DCB_APP_FCOE_FLAGS N_("Specifies the NMSettingDcbFlags for the DCB FCoE application. Flags may be any combination of NM_SETTING_DCB_FLAG_ENABLE (0x1), NM_SETTING_DCB_FLAG_ADVERTISE (0x2), and NM_SETTING_DCB_FLAG_WILLING (0x4).") -#define DESCRIBE_DOC_NM_SETTING_DCB_APP_FCOE_MODE N_("The FCoE controller mode; either \"fabric\" (default) or \"vn2vn\".") +#define DESCRIBE_DOC_NM_SETTING_DCB_APP_FCOE_MODE N_("The FCoE controller mode; either \"fabric\" or \"vn2vn\". Since 1.34, NULL is the default and means \"fabric\". Before 1.34, NULL was rejected as invalid and the default was \"fabric\".") #define DESCRIBE_DOC_NM_SETTING_DCB_APP_FCOE_PRIORITY N_("The highest User Priority (0 - 7) which FCoE frames should use, or -1 for default priority. Only used when the \"app-fcoe-flags\" property includes the NM_SETTING_DCB_FLAG_ENABLE (0x1) flag.") #define DESCRIBE_DOC_NM_SETTING_DCB_APP_FIP_FLAGS N_("Specifies the NMSettingDcbFlags for the DCB FIP application. Flags may be any combination of NM_SETTING_DCB_FLAG_ENABLE (0x1), NM_SETTING_DCB_FLAG_ADVERTISE (0x2), and NM_SETTING_DCB_FLAG_WILLING (0x4).") #define DESCRIBE_DOC_NM_SETTING_DCB_APP_FIP_PRIORITY N_("The highest User Priority (0 - 7) which FIP frames should use, or -1 for default priority. Only used when the \"app-fip-flags\" property includes the NM_SETTING_DCB_FLAG_ENABLE (0x1) flag.") diff --git a/src/libnmc-setting/settings-docs.h.in b/src/libnmc-setting/settings-docs.h.in index 85c5aca1..06346b1e 100644 --- a/src/libnmc-setting/settings-docs.h.in +++ b/src/libnmc-setting/settings-docs.h.in @@ -99,7 +99,7 @@ #define DESCRIBE_DOC_NM_SETTING_WIRED_MTU N_("If non-zero, only transmit packets of the specified size or smaller, breaking larger packets up into multiple Ethernet frames.") #define DESCRIBE_DOC_NM_SETTING_WIRED_PORT N_("Specific port type to use if the device supports multiple attachment methods. One of \"tp\" (Twisted Pair), \"aui\" (Attachment Unit Interface), \"bnc\" (Thin Ethernet) or \"mii\" (Media Independent Interface). If the device supports only one port type, this setting is ignored.") #define DESCRIBE_DOC_NM_SETTING_WIRED_S390_NETTYPE N_("s390 network device type; one of \"qeth\", \"lcs\", or \"ctc\", representing the different types of virtual network devices available on s390 systems.") -#define DESCRIBE_DOC_NM_SETTING_WIRED_S390_OPTIONS N_("Dictionary of key/value pairs of s390-specific device options. Both keys and values must be strings. Allowed keys include \"portno\", \"layer2\", \"portname\", \"protocol\", among others. Key names must contain only alphanumeric characters (ie, [a-zA-Z0-9]).") +#define DESCRIBE_DOC_NM_SETTING_WIRED_S390_OPTIONS N_("Dictionary of key/value pairs of s390-specific device options. Both keys and values must be strings. Allowed keys include \"portno\", \"layer2\", \"portname\", \"protocol\", among others. Key names must contain only alphanumeric characters (ie, [a-zA-Z0-9]). Currently, NetworkManager itself does nothing with this information. However, s390utils ships a udev rule which parses this information and applies it to the interface.") #define DESCRIBE_DOC_NM_SETTING_WIRED_S390_SUBCHANNELS N_("Identifies specific subchannels that this network device uses for communication with z/VM or s390 host. Like the \"mac-address\" property for non-z/VM devices, this property can be used to ensure this connection only applies to the network device that uses these subchannels. The list should contain exactly 3 strings, and each string may only be composed of hexadecimal characters and the period (.) character.") #define DESCRIBE_DOC_NM_SETTING_WIRED_SPEED N_("When a value greater than 0 is set, configures the device to use the specified speed. If \"auto-negotiate\" is \"yes\" the specified speed will be the only one advertised during link negotiation: this works only for BASE-T 802.3 specifications and is useful for enforcing gigabit speeds, as in this case link negotiation is mandatory. If the value is unset (0, the default), the link configuration will be either skipped (if \"auto-negotiate\" is \"no\", the default) or will be auto-negotiated (if \"auto-negotiate\" is \"yes\") and the local device will advertise all the supported speeds. In Mbit/s, ie 100 == 100Mbit/s. Must be set together with the \"duplex\" property when non-zero. Before specifying a speed value be sure your device supports it.") #define DESCRIBE_DOC_NM_SETTING_WIRED_WAKE_ON_LAN N_("The NMSettingWiredWakeOnLan options to enable. Not all devices support all options. May be any combination of NM_SETTING_WIRED_WAKE_ON_LAN_PHY (0x2), NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST (0x4), NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST (0x8), NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST (0x10), NM_SETTING_WIRED_WAKE_ON_LAN_ARP (0x20), NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC (0x40) or the special values NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT (0x1) (to use global settings) and NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE (0x8000) (to disable management of Wake-on-LAN in NetworkManager).") @@ -114,6 +114,7 @@ #define DESCRIBE_DOC_NM_SETTING_BLUETOOTH_BDADDR N_("The Bluetooth address of the device.") #define DESCRIBE_DOC_NM_SETTING_BLUETOOTH_TYPE N_("Either \"dun\" for Dial-Up Networking connections or \"panu\" for Personal Area Networking connections to devices supporting the NAP profile.") #define DESCRIBE_DOC_NM_SETTING_BOND_OPTIONS N_("Dictionary of key/value pairs of bonding options. Both keys and values must be strings. Option names must contain only alphanumeric characters (ie, [a-zA-Z0-9]).") +#define DESCRIBE_DOC_NM_SETTING_BOND_PORT_QUEUE_ID N_("The queue ID of this bond port. The maximum value of queue ID is the number of TX queues currently active in device.") #define DESCRIBE_DOC_NM_SETTING_BRIDGE_AGEING_TIME N_("The Ethernet MAC address aging time, in seconds.") #define DESCRIBE_DOC_NM_SETTING_BRIDGE_FORWARD_DELAY N_("The Spanning Tree Protocol (STP) forwarding delay, in seconds.") #define DESCRIBE_DOC_NM_SETTING_BRIDGE_GROUP_ADDRESS N_("If specified, The MAC address of the multicast group this bridge uses for STP. The address must be a link-local address in standard Ethernet MAC address format, ie an address of the form 01:80:C2:00:00:0X, with X in [0, 4..F]. If not specified the default value is 01:80:C2:00:00:00.") @@ -151,10 +152,11 @@ #define DESCRIBE_DOC_NM_SETTING_CDMA_PASSWORD_FLAGS N_("Flags indicating how to handle the \"password\" property.") #define DESCRIBE_DOC_NM_SETTING_CDMA_USERNAME N_("The username used to authenticate with the network, if required. Many providers do not require a username, or accept any username. But if a username is required, it is specified here.") #define DESCRIBE_DOC_NM_SETTING_CONNECTION_AUTH_RETRIES N_("The number of retries for the authentication. Zero means to try indefinitely; -1 means to use a global default. If the global default is not set, the authentication retries for 3 times before failing the connection. Currently, this only applies to 802-1x authentication.") -#define DESCRIBE_DOC_NM_SETTING_CONNECTION_AUTOCONNECT N_("Whether or not the connection should be automatically connected by NetworkManager when the resources for the connection are available. TRUE to automatically activate the connection, FALSE to require manual intervention to activate the connection. Note that autoconnect is not implemented for VPN profiles. See \"secondaries\" as an alternative to automatically connect VPN profiles.") -#define DESCRIBE_DOC_NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY N_("The autoconnect priority. If the connection is set to autoconnect, connections with higher priority will be preferred. Defaults to 0. The higher number means higher priority.") +#define DESCRIBE_DOC_NM_SETTING_CONNECTION_AUTOCONNECT N_("Whether or not the connection should be automatically connected by NetworkManager when the resources for the connection are available. TRUE to automatically activate the connection, FALSE to require manual intervention to activate the connection. Autoconnect happens when the circumstances are suitable. That means for example that the device is currently managed and not active. Autoconnect thus never replaces or competes with an already active profile. Note that autoconnect is not implemented for VPN profiles. See \"secondaries\" as an alternative to automatically connect VPN profiles.") +#define DESCRIBE_DOC_NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY N_("The autoconnect priority in range -999 to 999. If the connection is set to autoconnect, connections with higher priority will be preferred. The higher number means higher priority. Defaults to 0. Note that this property only matters if there are more than one candidate profile to select for autoconnect. In case of equal priority, the profile used most recently is chosen.") #define DESCRIBE_DOC_NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES N_("The number of times a connection should be tried when autoactivating before giving up. Zero means forever, -1 means the global default (4 times if not overridden). Setting this to 1 means to try activation only once before blocking autoconnect. Note that after a timeout, NetworkManager will try to autoconnect again.") #define DESCRIBE_DOC_NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES N_("Whether or not slaves of this connection should be automatically brought up when NetworkManager activates this connection. This only has a real effect for master connections. The properties \"autoconnect\", \"autoconnect-priority\" and \"autoconnect-retries\" are unrelated to this setting. The permitted values are: 0: leave slave connections untouched, 1: activate all the slave connections with this connection, -1: default. If -1 (default) is set, global connection.autoconnect-slaves is read to determine the real value. If it is default as well, this fallbacks to 0.") +#define DESCRIBE_DOC_NM_SETTING_CONNECTION_DNS_OVER_TLS N_("Whether DNSOverTls (dns-over-tls) is enabled for the connection. DNSOverTls is a technology which uses TLS to encrypt dns traffic. The permitted values are: \"yes\" (2) use DNSOverTls and disabled fallback, \"opportunistic\" (1) use DNSOverTls but allow fallback to unencrypted resolution, \"no\" (0) don't ever use DNSOverTls. If unspecified \"default\" depends on the plugin used. Systemd-resolved uses global setting. This feature requires a plugin which supports DNSOverTls. Otherwise, the setting has no effect. One such plugin is dns-systemd-resolved.") #define DESCRIBE_DOC_NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT N_("If greater than zero, delay success of IP addressing until either the timeout is reached, or an IP gateway replies to a ping.") #define DESCRIBE_DOC_NM_SETTING_CONNECTION_ID N_("A human readable unique identifier for the connection, like \"Work Wi-Fi\" or \"T-Mobile 3G\".") #define DESCRIBE_DOC_NM_SETTING_CONNECTION_INTERFACE_NAME N_("The name of the network interface this connection is bound to. If not set, then the connection can be attached to any interface of the appropriate type (subject to restrictions imposed by other settings). For software devices this specifies the name of the created device. For connection types where interface names cannot easily be made persistent (e.g. mobile broadband or USB Ethernet), this property should not be used. Setting this property restricts the interfaces a connection can be used with, and if interface names change or are reordered the connection may be applied to the wrong interface.") @@ -176,7 +178,7 @@ #define DESCRIBE_DOC_NM_SETTING_CONNECTION_WAIT_DEVICE_TIMEOUT N_("Timeout in milliseconds to wait for device at startup. During boot, devices may take a while to be detected by the driver. This property will cause to delay NetworkManager-wait-online.service and nm-online to give the device a chance to appear. This works by waiting for the given timeout until a compatible device for the profile is available and managed. The value 0 means no wait time. The default value is -1, which currently has the same meaning as no wait time.") #define DESCRIBE_DOC_NM_SETTING_CONNECTION_ZONE N_("The trust level of a the connection. Free form case-insensitive string (for example \"Home\", \"Work\", \"Public\"). NULL or unspecified zone means the connection will be placed in the default zone as defined by the firewall. When updating this property on a currently activated connection, the change takes effect immediately.") #define DESCRIBE_DOC_NM_SETTING_DCB_APP_FCOE_FLAGS N_("Specifies the NMSettingDcbFlags for the DCB FCoE application. Flags may be any combination of NM_SETTING_DCB_FLAG_ENABLE (0x1), NM_SETTING_DCB_FLAG_ADVERTISE (0x2), and NM_SETTING_DCB_FLAG_WILLING (0x4).") -#define DESCRIBE_DOC_NM_SETTING_DCB_APP_FCOE_MODE N_("The FCoE controller mode; either \"fabric\" (default) or \"vn2vn\".") +#define DESCRIBE_DOC_NM_SETTING_DCB_APP_FCOE_MODE N_("The FCoE controller mode; either \"fabric\" or \"vn2vn\". Since 1.34, NULL is the default and means \"fabric\". Before 1.34, NULL was rejected as invalid and the default was \"fabric\".") #define DESCRIBE_DOC_NM_SETTING_DCB_APP_FCOE_PRIORITY N_("The highest User Priority (0 - 7) which FCoE frames should use, or -1 for default priority. Only used when the \"app-fcoe-flags\" property includes the NM_SETTING_DCB_FLAG_ENABLE (0x1) flag.") #define DESCRIBE_DOC_NM_SETTING_DCB_APP_FIP_FLAGS N_("Specifies the NMSettingDcbFlags for the DCB FIP application. Flags may be any combination of NM_SETTING_DCB_FLAG_ENABLE (0x1), NM_SETTING_DCB_FLAG_ADVERTISE (0x2), and NM_SETTING_DCB_FLAG_WILLING (0x4).") #define DESCRIBE_DOC_NM_SETTING_DCB_APP_FIP_PRIORITY N_("The highest User Priority (0 - 7) which FIP frames should use, or -1 for default priority. Only used when the \"app-fip-flags\" property includes the NM_SETTING_DCB_FLAG_ENABLE (0x1) flag.") diff --git a/src/libnmt-newt/nmt-newt-utils.c b/src/libnmt-newt/nmt-newt-utils.c index 480c8194..99bde747 100644 --- a/src/libnmt-newt/nmt-newt-utils.c +++ b/src/libnmt-newt/nmt-newt-utils.c @@ -124,7 +124,7 @@ nmt_newt_parse_colors(const char *s, bool is_newt) gs_free const char **lines = NULL; size_t i; - lines = nm_utils_strsplit_set(s, ";:\n\r\t "); + lines = nm_strsplit_set(s, ";:\n\r\t "); if (!lines) return; diff --git a/src/meson.build b/src/meson.build index 39bfe7ef..ab696915 100644 --- a/src/meson.build +++ b/src/meson.build @@ -93,6 +93,7 @@ if enable_nmtui endif subdir('nmcli') subdir('nm-dispatcher') +subdir('nm-priv-helper') subdir('nm-daemon-helper') subdir('nm-online') if enable_nmtui diff --git a/src/n-acd/src/n-acd-probe.c b/src/n-acd/src/n-acd-probe.c index 2a5c6451..c1ed59ae 100644 --- a/src/n-acd/src/n-acd-probe.c +++ b/src/n-acd/src/n-acd-probe.c @@ -420,7 +420,7 @@ int n_acd_probe_handle_timeout(NAcdProbe *probe) { r = n_acd_send(probe->acd, &probe->ip, NULL); if (r) { - if (r != -N_ACD_E_DROPPED) + if (r != N_ACD_E_DROPPED) return r; /* @@ -475,7 +475,7 @@ int n_acd_probe_handle_timeout(NAcdProbe *probe) { r = n_acd_send(probe->acd, &probe->ip, &probe->ip); if (r) { - if (r != -N_ACD_E_DROPPED) + if (r != N_ACD_E_DROPPED) return r; /* @@ -595,7 +595,7 @@ int n_acd_probe_handle_packet(NAcdProbe *probe, struct ether_arp *packet, bool h if (!rate_limited) { r = n_acd_send(probe->acd, &probe->ip, &probe->ip); if (r) { - if (r != -N_ACD_E_DROPPED) + if (r != N_ACD_E_DROPPED) return r; if (probe->defend == N_ACD_DEFEND_ONCE) { @@ -604,7 +604,7 @@ int n_acd_probe_handle_packet(NAcdProbe *probe, struct ether_arp *packet, bool h } } - if (r != -N_ACD_E_DROPPED) + if (r != N_ACD_E_DROPPED) probe->last_defend = now; } diff --git a/src/nm-cloud-setup/nm-cloud-setup-utils.c b/src/nm-cloud-setup/nm-cloud-setup-utils.c index ed36b4dd..206461e4 100644 --- a/src/nm-cloud-setup/nm-cloud-setup-utils.c +++ b/src/nm-cloud-setup/nm-cloud-setup-utils.c @@ -13,69 +13,6 @@ /*****************************************************************************/ -volatile NMLogLevel _nm_logging_configured_level = LOGL_TRACE; - -void -_nm_logging_enabled_init(const char *level_str) -{ - NMLogLevel level; - - if (!_nm_log_parse_level(level_str, &level)) - level = LOGL_WARN; - else if (level == _LOGL_KEEP) - level = LOGL_WARN; - - _nm_logging_configured_level = level; -} - -void -_nm_log_impl_cs(NMLogLevel level, const char *fmt, ...) -{ - gs_free char *msg = NULL; - va_list ap; - const char * level_str; - gint64 ts; - - va_start(ap, fmt); - msg = g_strdup_vprintf(fmt, ap); - va_end(ap); - - switch (level) { - case LOGL_TRACE: - level_str = ""; - break; - case LOGL_DEBUG: - level_str = ""; - break; - case LOGL_INFO: - level_str = " "; - break; - case LOGL_WARN: - level_str = " "; - break; - default: - nm_assert(level == LOGL_ERR); - level_str = ""; - break; - } - - ts = nm_utils_clock_gettime_nsec(CLOCK_BOOTTIME); - - g_print("[%" G_GINT64_FORMAT ".%05" G_GINT64_FORMAT "] %s %s\n", - ts / NM_UTILS_NSEC_PER_SEC, - (ts / (NM_UTILS_NSEC_PER_SEC / 10000)) % 10000, - level_str, - msg); -} - -void -_nm_utils_monotonic_timestamp_initialized(const struct timespec *tp, - gint64 offset_sec, - gboolean is_boottime) -{} - -/*****************************************************************************/ - G_LOCK_DEFINE_STATIC(_wait_for_objects_lock); static GSList *_wait_for_objects_list; static GSList *_wait_for_objects_iterate_loops; diff --git a/src/nm-cloud-setup/nm-cloud-setup-utils.h b/src/nm-cloud-setup/nm-cloud-setup-utils.h index 3ca7298f..e1502b95 100644 --- a/src/nm-cloud-setup/nm-cloud-setup-utils.h +++ b/src/nm-cloud-setup/nm-cloud-setup-utils.h @@ -3,7 +3,7 @@ #ifndef __NM_CLOUD_SETUP_UTILS_H__ #define __NM_CLOUD_SETUP_UTILS_H__ -#include "libnm-glib-aux/nm-logging-fwd.h" +#include "libnm-glib-aux/nm-logging-base.h" /*****************************************************************************/ @@ -13,26 +13,14 @@ /*****************************************************************************/ -extern volatile NMLogLevel _nm_logging_configured_level; - -static inline gboolean -nm_logging_enabled(NMLogLevel level) -{ - return level >= _nm_logging_configured_level; -} - -void _nm_logging_enabled_init(const char *level_str); - -void _nm_log_impl_cs(NMLogLevel level, const char *fmt, ...) _nm_printf(2, 3); - -#define _nm_log(level, ...) _nm_log_impl_cs((level), __VA_ARGS__); +#define _nm_log(level, ...) _nm_log_simple_printf((level), __VA_ARGS__); #define _NMLOG(level, ...) \ G_STMT_START \ { \ const NMLogLevel _level = (level); \ \ - if (nm_logging_enabled(_level)) { \ + if (_nm_logging_enabled(_level)) { \ _nm_log(_level, __VA_ARGS__); \ } \ } \ @@ -41,7 +29,7 @@ void _nm_log_impl_cs(NMLogLevel level, const char *fmt, ...) _nm_printf(2, 3); /*****************************************************************************/ #ifndef NM_DIST_VERSION - #define NM_DIST_VERSION VERSION +#define NM_DIST_VERSION VERSION #endif /*****************************************************************************/ diff --git a/src/nm-cloud-setup/nmcs-provider-aliyun.c b/src/nm-cloud-setup/nmcs-provider-aliyun.c index 126980fd..7073318c 100644 --- a/src/nm-cloud-setup/nmcs-provider-aliyun.c +++ b/src/nm-cloud-setup/nmcs-provider-aliyun.c @@ -158,9 +158,9 @@ _get_config_fetch_done_cb(NMHttpClient * http_client, switch (fetch_type) { case GET_CONFIG_FETCH_DONE_TYPE_PRIVATE_IPV4S: - s_addrs = nm_utils_strsplit_set_full(g_bytes_get_data(response, NULL), - ",", - NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP); + s_addrs = nm_strsplit_set_full(g_bytes_get_data(response, NULL), + ",", + NM_STRSPLIT_SET_FLAGS_STRSTRIP); len = NM_PTRARRAY_LEN(s_addrs); nm_assert(!config_iface_data->has_ipv4s); nm_assert(!config_iface_data->ipv4s_arr); diff --git a/src/nm-cloud-setup/nmcs-provider-ec2.c b/src/nm-cloud-setup/nmcs-provider-ec2.c index 9fe62518..96b08807 100644 --- a/src/nm-cloud-setup/nmcs-provider-ec2.c +++ b/src/nm-cloud-setup/nmcs-provider-ec2.c @@ -142,9 +142,9 @@ _get_config_fetch_done_cb(NMHttpClient *http_client, gs_free const char **s_addrs = NULL; gsize i, len; - s_addrs = nm_utils_strsplit_set_full(g_bytes_get_data(response, NULL), - "\n", - NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP); + s_addrs = nm_strsplit_set_full(g_bytes_get_data(response, NULL), + "\n", + NM_STRSPLIT_SET_FLAGS_STRSTRIP); len = NM_PTRARRAY_LEN(s_addrs); nm_assert(!config_iface_data->has_ipv4s); diff --git a/src/nm-cloud-setup/tests/test-cloud-setup-general.c b/src/nm-cloud-setup/tests/test-cloud-setup-general.c index 2039ce34..82df4e17 100644 --- a/src/nm-cloud-setup/tests/test-cloud-setup-general.c +++ b/src/nm-cloud-setup/tests/test-cloud-setup-general.c @@ -56,7 +56,7 @@ _test_ri4a(const char *const *addrs_before, const char *const *addrs_new) changed = nmcs_setting_ip_replace_ipv4_addresses(s_ip, (NMIPAddress **) arr->pdata, arr->len); - g_assert_cmpint(changed, !=, nm_utils_strv_equal(addrs_before, addrs_new)); + g_assert_cmpint(changed, !=, nm_strv_equal(addrs_before, addrs_new)); g_assert_cmpint(nm_setting_ip_config_get_num_addresses(s_ip), ==, n); for (i = 0; i < n; i++) { diff --git a/src/nm-daemon-helper/nm-daemon-helper.c b/src/nm-daemon-helper/nm-daemon-helper.c index e91e7184..21a71e3c 100644 --- a/src/nm-daemon-helper/nm-daemon-helper.c +++ b/src/nm-daemon-helper/nm-daemon-helper.c @@ -7,7 +7,7 @@ #include #include #if defined(__GLIBC__) - #include +#include #endif #include "libnm-std-aux/nm-std-aux.h" diff --git a/src/nm-dispatcher/nm-dispatcher.c b/src/nm-dispatcher/nm-dispatcher.c index 5df32959..b29f5aca 100644 --- a/src/nm-dispatcher/nm-dispatcher.c +++ b/src/nm-dispatcher/nm-dispatcher.c @@ -7,38 +7,62 @@ #include "libnm-client-aux-extern/nm-default-client.h" -#include +#include +#include #include -#include #include -#include -#include #include +#include #include -#include -#include +#include +#include #include "libnm-core-aux-extern/nm-dispatcher-api.h" +#include "libnm-glib-aux/nm-dbus-aux.h" +#include "libnm-glib-aux/nm-io-utils.h" +#include "libnm-glib-aux/nm-time-utils.h" #include "nm-dispatcher-utils.h" /*****************************************************************************/ +/* Serves only the purpose to mark environment variables that are honored by + * the application. You can search for this macro, and find what options are supported. */ +#define _ENV(var) ("" var "") + +/*****************************************************************************/ + typedef struct Request Request; -static struct { +typedef struct { GDBusConnection *dbus_connection; - GMainLoop * loop; - gboolean debug; - gboolean persist; - guint quit_id; - guint request_id_counter; - gboolean ever_acquired_name; - bool exit_with_failure; + GCancellable * quit_cancellable; + + bool log_verbose; + bool log_stdout; + + GSource *source_idle_timeout; + + gint64 start_timestamp_msec; + + guint request_id_counter; + guint service_regist_id; + + gboolean persist; Request *current_request; GQueue * requests_waiting; int num_requests_pending; -} gl; + + bool exit_with_failure; + + bool name_requested; + bool reject_new_requests; + + bool shutdown_timeout; + bool shutdown_quitting; +} GlobalData; + +GlobalData gl; typedef struct { Request *request; @@ -49,8 +73,8 @@ typedef struct { char * error; gboolean wait; gboolean dispatched; - guint watch_id; - guint timeout_id; + GSource * watch_source; + GSource * timeout_source; } ScriptInfo; struct Request { @@ -138,7 +162,7 @@ struct Request { } \ G_STMT_END -#define _LOG_X_D_enabled() (gl.debug) +#define _LOG_X_D_enabled() (gl.log_verbose) #define _LOG_X_T_enabled() _LOG_X_D_enabled() #define _LOG_R_D_enabled(request) (_NM_ENSURE_TYPE_CONST(Request *, request)->debug) @@ -187,23 +211,35 @@ request_free(Request *request) g_slice_free(Request, request); } +/*****************************************************************************/ + static gboolean -quit_timeout_cb(gpointer user_data) +_idle_timeout_cb(gpointer user_data) { - gl.quit_id = 0; - g_main_loop_quit(gl.loop); - return G_SOURCE_REMOVE; + nm_clear_g_source_inst(&gl.source_idle_timeout); + gl.shutdown_timeout = TRUE; + return G_SOURCE_CONTINUE; } static void -quit_timeout_reschedule(void) +_idle_timeout_restart(void) { - if (!gl.persist) { - nm_clear_g_source(&gl.quit_id); - gl.quit_id = g_timeout_add_seconds(10, quit_timeout_cb, NULL); - } + nm_clear_g_source_inst(&gl.source_idle_timeout); + + if (gl.persist) + return; + + if (gl.shutdown_quitting) + return; + + if (gl.num_requests_pending > 0) + return; + + gl.source_idle_timeout = nm_g_timeout_add_source(10000, _idle_timeout_cb, NULL); } +/*****************************************************************************/ + /** * next_request: * @@ -251,7 +287,7 @@ next_request(Request *request) * Checks if all the scripts for the request have terminated and in such case * it sends the D-Bus response and releases the request resources. * - * It also decreases @num_requests_pending and possibly does quit_timeout_reschedule(). + * It also decreases @num_requests_pending and possibly does _idle_timeout_restart(). */ static void complete_request(Request *request) @@ -287,10 +323,10 @@ complete_request(Request *request) request_free(request); - g_assert_cmpuint(gl.num_requests_pending, >, 0); + nm_assert(gl.num_requests_pending > 0); if (--gl.num_requests_pending <= 0) { nm_assert(!gl.current_request && !g_queue_peek_head(gl.requests_waiting)); - quit_timeout_reschedule(); + _idle_timeout_restart(); } } @@ -366,8 +402,8 @@ script_watch_cb(GPid pid, int status, gpointer user_data) g_assert(pid == script->pid); - script->watch_id = 0; - nm_clear_g_source(&script->timeout_id); + nm_clear_g_source_inst(&script->watch_source); + nm_clear_g_source_inst(&script->timeout_source); script->request->num_scripts_done++; if (!script->wait) script->request->num_scripts_nowait--; @@ -396,8 +432,8 @@ script_timeout_cb(gpointer user_data) { ScriptInfo *script = user_data; - script->timeout_id = 0; - nm_clear_g_source(&script->watch_id); + nm_clear_g_source_inst(&script->timeout_source); + nm_clear_g_source_inst(&script->watch_source); script->request->num_scripts_done++; if (!script->wait) script->request->num_scripts_nowait--; @@ -418,7 +454,7 @@ again: complete_script(script); - return FALSE; + return G_SOURCE_CONTINUE; } static gboolean @@ -515,8 +551,9 @@ script_dispatch(ScriptInfo *script) return FALSE; } - script->watch_id = g_child_watch_add(script->pid, (GChildWatchFunc) script_watch_cb, script); - script->timeout_id = g_timeout_add_seconds(SCRIPT_TIMEOUT, script_timeout_cb, script); + script->watch_source = nm_g_child_watch_add_source(script->pid, script_watch_cb, script); + script->timeout_source = + nm_g_timeout_add_seconds_source(SCRIPT_TIMEOUT, script_timeout_cb, script); if (!script->wait) request->num_scripts_nowait++; return TRUE; @@ -667,7 +704,7 @@ script_must_wait(const char *path) } static void -_method_call_action(GDBusMethodInvocation *invocation, GVariant *parameters) +_handle_action(GDBusMethodInvocation *invocation, GVariant *parameters) { const char * action; gs_unref_variant GVariant *connection = NULL; @@ -727,7 +764,7 @@ _method_call_action(GDBusMethodInvocation *invocation, GVariant *parameters) request = g_slice_new0(Request); request->request_id = ++gl.request_id_counter; - request->debug = debug || gl.debug; + request->debug = debug || gl.log_verbose; request->context = invocation; request->action = g_strdup(action); @@ -783,9 +820,9 @@ _method_call_action(GDBusMethodInvocation *invocation, GVariant *parameters) return; } - nm_clear_g_source(&gl.quit_id); - gl.num_requests_pending++; + gl.shutdown_timeout = FALSE; + nm_clear_g_source_inst(&gl.source_idle_timeout); for (i = 0; i < request->scripts->len; i++) { ScriptInfo *s = g_ptr_array_index(request->scripts, i); @@ -831,43 +868,49 @@ _method_call_action(GDBusMethodInvocation *invocation, GVariant *parameters) } static void -on_name_acquired(GDBusConnection *connection, const char *name, gpointer user_data) +_handle_ping(GDBusMethodInvocation *invocation, GVariant *parameters) { - gl.ever_acquired_name = TRUE; -} + gs_free char *msg = NULL; + gint64 running_msec; + const char * arg_s; -static void -on_name_lost(GDBusConnection *connection, const char *name, gpointer user_data) -{ - if (!connection) { - if (!gl.ever_acquired_name) { - _LOG_X_W("Could not get the system bus. Make sure the message bus daemon is running!"); - gl.exit_with_failure = TRUE; - } else { - _LOG_X_I("System bus stopped. Exiting"); - } - } else if (!gl.ever_acquired_name) { - _LOG_X_W("Could not acquire the " NM_DISPATCHER_DBUS_SERVICE " service."); - gl.exit_with_failure = TRUE; - } else - _LOG_X_I("Lost the " NM_DISPATCHER_DBUS_SERVICE " name. Exiting"); + g_variant_get(parameters, "(&s)", &arg_s); - g_main_loop_quit(gl.loop); + running_msec = nm_utils_clock_gettime_msec(CLOCK_BOOTTIME) - gl.start_timestamp_msec; + + msg = g_strdup_printf("pid=%lu, unique-name=%s, since=%" G_GINT64_FORMAT ".%03d, pong=%s", + (unsigned long) getpid(), + g_dbus_connection_get_unique_name(gl.dbus_connection), + (gint64) (running_msec / 1000), + (int) (running_msec % 1000), + arg_s); + g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", msg)); } static void -_method_call(GDBusConnection * connection, - const char * sender, - const char * object_path, - const char * interface_name, - const char * method_name, - GVariant * parameters, - GDBusMethodInvocation *invocation, - gpointer user_data) +_bus_method_call(GDBusConnection * connection, + const char * sender, + const char * object_path, + const char * interface_name, + const char * method_name, + GVariant * parameters, + GDBusMethodInvocation *invocation, + gpointer user_data) { + if (gl.reject_new_requests) { + g_dbus_method_invocation_return_error(invocation, + G_DBUS_ERROR, + G_DBUS_ERROR_NO_SERVER, + "Server is exiting"); + return; + } if (nm_streq(interface_name, NM_DISPATCHER_DBUS_INTERFACE)) { if (nm_streq(method_name, "Action")) { - _method_call_action(invocation, parameters); + _handle_action(invocation, parameters); + return; + } + if (nm_streq(method_name, "Ping")) { + _handle_ping(invocation, parameters); return; } } @@ -881,6 +924,10 @@ _method_call(GDBusConnection * connection, static GDBusInterfaceInfo *const interface_info = NM_DEFINE_GDBUS_INTERFACE_INFO( NM_DISPATCHER_DBUS_INTERFACE, .methods = NM_DEFINE_GDBUS_METHOD_INFOS( + NM_DEFINE_GDBUS_METHOD_INFO( + "Ping", + .in_args = NM_DEFINE_GDBUS_ARG_INFOS(NM_DEFINE_GDBUS_ARG_INFO("arg", "s"), ), + .out_args = NM_DEFINE_GDBUS_ARG_INFOS(NM_DEFINE_GDBUS_ARG_INFO("arg", "s"), ), ), NM_DEFINE_GDBUS_METHOD_INFO( "Action", .in_args = NM_DEFINE_GDBUS_ARG_INFOS( @@ -902,9 +949,75 @@ static GDBusInterfaceInfo *const interface_info = NM_DEFINE_GDBUS_INTERFACE_INFO .out_args = NM_DEFINE_GDBUS_ARG_INFOS(NM_DEFINE_GDBUS_ARG_INFO("results", "a(sus)"), ), ), ), ); -static const GDBusInterfaceVTable interface_vtable = { - .method_call = _method_call, -}; +static gboolean +_bus_register_service(void) +{ + static const GDBusInterfaceVTable interface_vtable = { + .method_call = _bus_method_call, + }; + gs_free_error GError * error = NULL; + NMDBusConnectionCallBlockingData data = { + .result = NULL, + }; + gs_unref_variant GVariant *ret = NULL; + guint32 ret_val; + + gl.service_regist_id = + g_dbus_connection_register_object(gl.dbus_connection, + NM_DISPATCHER_DBUS_PATH, + interface_info, + NM_UNCONST_PTR(GDBusInterfaceVTable, &interface_vtable), + NULL, + NULL, + &error); + if (gl.service_regist_id == 0) { + _LOG_X_W("dbus: could not export dispatcher D-Bus interface %s: %s", + NM_DISPATCHER_DBUS_PATH, + error->message); + return FALSE; + } + + _LOG_X_D("dbus: dispatcher D-Bus interface %s registered", NM_DISPATCHER_DBUS_PATH); + + gl.name_requested = TRUE; + + nm_dbus_connection_call_request_name(gl.dbus_connection, + NM_DISPATCHER_DBUS_SERVICE, + DBUS_NAME_FLAG_ALLOW_REPLACEMENT + | DBUS_NAME_FLAG_REPLACE_EXISTING, + 10000, + gl.quit_cancellable, + nm_dbus_connection_call_blocking_callback, + &data); + + /* Note that with D-Bus activation, the first request will already hit us before RequestName + * completes. So when we start iterating the main context, the first request may already come + * in. */ + + ret = nm_dbus_connection_call_blocking(&data, &error); + + if (nm_utils_error_is_cancelled(error)) + return FALSE; + + if (error) { + _LOG_X_W("d-bus: failed to request name %s: %s", + NM_DISPATCHER_DBUS_SERVICE, + error->message); + return FALSE; + } + + g_variant_get(ret, "(u)", &ret_val); + + if (ret_val != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + _LOG_X_W("dbus: request name for %s failed to take name (response %u)", + NM_DISPATCHER_DBUS_SERVICE, + ret_val); + return FALSE; + } + + _LOG_X_D("dbus: request name for %s succeeded", NM_DISPATCHER_DBUS_SERVICE); + return TRUE; +} /*****************************************************************************/ @@ -955,25 +1068,100 @@ logging_shutdown(void) } static gboolean -signal_handler(gpointer user_data) +_signal_callback_term(gpointer user_data) { - int signo = GPOINTER_TO_INT(user_data); + if (!gl.shutdown_quitting) { + gl.shutdown_quitting = TRUE; + _LOG_X_I("Caught signal %d, shutting down...", GPOINTER_TO_INT(user_data)); + g_cancellable_cancel(gl.quit_cancellable); + } + return G_SOURCE_CONTINUE; +} - _LOG_X_I("Caught signal %d, shutting down...", signo); - g_main_loop_quit(gl.loop); +/*****************************************************************************/ - return G_SOURCE_CONTINUE; +static void +_bus_release_name_cb(GObject *source, GAsyncResult *result, gpointer user_data) +{ + nm_assert(gl.num_requests_pending > 0); + gl.reject_new_requests = TRUE; + gl.num_requests_pending--; + g_main_context_wakeup(NULL); +} + +static gboolean +_bus_release_name(void) +{ + int r; + + /* We already requested a name. To exit-on-idle without race, we need to dance. + * See https://lists.freedesktop.org/archives/dbus/2015-May/016671.html . */ + + if (!gl.name_requested) + return FALSE; + + gl.name_requested = FALSE; + gl.shutdown_quitting = TRUE; + + _LOG_X_T("shutdown: release-name"); + + /* we create a fake pending request. */ + gl.num_requests_pending++; + nm_clear_g_source_inst(&gl.source_idle_timeout); + + r = nm_sd_notify("STOPPING=1"); + if (r < 0) + _LOG_X_W("shutdown: sd_notifiy(STOPPING=1) failed: %s", nm_strerror_native(-r)); + else + _LOG_X_T("shutdown: sd_notifiy(STOPPING=1) succeeded"); + + g_dbus_connection_call(gl.dbus_connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, + "ReleaseName", + g_variant_new("(s)", NM_DISPATCHER_DBUS_SERVICE), + G_VARIANT_TYPE("(u)"), + G_DBUS_CALL_FLAGS_NONE, + 10000, + NULL, + _bus_release_name_cb, + NULL); + return TRUE; } +/*****************************************************************************/ + static gboolean -parse_command_line(int *p_argc, char ***p_argv, GError **error) +_initial_setup(int *p_argc, char ***p_argv, GError **error) { GOptionContext *opt_ctx; - GOptionEntry entries[] = { - {"debug", 0, 0, G_OPTION_ARG_NONE, &gl.debug, "Output to console rather than syslog", NULL}, - {"persist", 0, 0, G_OPTION_ARG_NONE, &gl.persist, "Don't quit after a short timeout", NULL}, - {NULL}}; - gboolean success; + gboolean arg_debug = FALSE; + GOptionEntry entries[] = {{ + "debug", + 0, + 0, + G_OPTION_ARG_NONE, + &arg_debug, + "Output to console rather than syslog", + NULL, + }, + { + "persist", + 0, + 0, + G_OPTION_ARG_NONE, + &gl.persist, + "Don't quit after a short timeout", + NULL, + }, + { + NULL, + }}; + gboolean success; + + gl.log_stdout = FALSE; + gl.log_verbose = _nm_utils_ascii_str_to_bool(g_getenv(_ENV("NM_DISPATCHER_DEBUG_LOG")), FALSE); opt_ctx = g_option_context_new(NULL); g_option_context_set_summary(opt_ctx, "Executes scripts upon actions by NetworkManager."); @@ -983,28 +1171,40 @@ parse_command_line(int *p_argc, char ***p_argv, GError **error) g_option_context_free(opt_ctx); + if (success && arg_debug) { + gl.log_stdout = TRUE; + gl.log_verbose = TRUE; + } + return success; } +/*****************************************************************************/ + int main(int argc, char **argv) { - gs_free_error GError *error = NULL; - guint signal_id_term = 0; - guint signal_id_int = 0; - guint dbus_regist_id = 0; - guint dbus_own_name_id = 0; + gs_free_error GError *error = NULL; + GSource * source_term = NULL; + GSource * source_int = NULL; + + signal(SIGPIPE, SIG_IGN); + source_term = + nm_g_unix_signal_add_source(SIGTERM, _signal_callback_term, GINT_TO_POINTER(SIGTERM)); + source_int = + nm_g_unix_signal_add_source(SIGINT, _signal_callback_term, GINT_TO_POINTER(SIGINT)); + + gl.start_timestamp_msec = nm_utils_clock_gettime_msec(CLOCK_BOOTTIME); - if (!parse_command_line(&argc, &argv, &error)) { + gl.quit_cancellable = g_cancellable_new(); + + if (!_initial_setup(&argc, &argv, &error)) { _LOG_X_W("Error parsing command line arguments: %s", error->message); gl.exit_with_failure = TRUE; goto done; } - signal_id_term = g_unix_signal_add(SIGTERM, signal_handler, GINT_TO_POINTER(SIGTERM)); - signal_id_int = g_unix_signal_add(SIGINT, signal_handler, GINT_TO_POINTER(SIGINT)); - - if (gl.debug) { + if (gl.log_stdout) { if (!g_getenv("G_MESSAGES_DEBUG")) { /* we log our regular messages using g_debug() and g_info(). * When we redirect glib logging to syslog, there is no problem. @@ -1015,77 +1215,81 @@ main(int argc, char **argv) } else logging_setup(); - gl.loop = g_main_loop_new(NULL, FALSE); - - gl.dbus_connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); + gl.dbus_connection = nm_g_bus_get_blocking(gl.quit_cancellable, &error); if (!gl.dbus_connection) { - _LOG_X_W("Could not get the system bus (%s). Make sure the message bus daemon is running!", - error->message); - gl.exit_with_failure = TRUE; + if (!nm_utils_error_is_cancelled(error)) { + _LOG_X_W("dbus: failure to get D-Bus connection: %s", error->message); + gl.exit_with_failure = TRUE; + } goto done; } + /* On bus-disconnect, GDBus will raise(SIGTERM), which we handle like a + * regular request to quit. */ + g_dbus_connection_set_exit_on_close(gl.dbus_connection, TRUE); + + _LOG_X_D("dbus: unique name: %s", g_dbus_connection_get_unique_name(gl.dbus_connection)); + gl.requests_waiting = g_queue_new(); - dbus_regist_id = - g_dbus_connection_register_object(gl.dbus_connection, - NM_DISPATCHER_DBUS_PATH, - interface_info, - NM_UNCONST_PTR(GDBusInterfaceVTable, &interface_vtable), - NULL, - NULL, - &error); - if (dbus_regist_id == 0) { - _LOG_X_W("Could not export Dispatcher D-Bus interface: %s", error->message); - gl.exit_with_failure = 1; - goto done; + _idle_timeout_restart(); + + if (!_bus_register_service()) { + /* we failed to start the D-Bus service, and will shut down. However, + * first see whether there are any requests that we should process. + * Even if RequestName fails, we might already have requests pending. */ + if (!g_cancellable_is_cancelled(gl.quit_cancellable)) + gl.exit_with_failure = TRUE; + gl.shutdown_quitting = TRUE; + + if (!gl.name_requested) + gl.reject_new_requests = TRUE; } - dbus_own_name_id = g_bus_own_name_on_connection(gl.dbus_connection, - NM_DISPATCHER_DBUS_SERVICE, - G_BUS_NAME_OWNER_FLAGS_NONE, - on_name_acquired, - on_name_lost, - NULL, - NULL); + while (TRUE) { + if (gl.shutdown_quitting) + _bus_release_name(); - quit_timeout_reschedule(); + if (gl.num_requests_pending > 0) { + /* while we have requests pending, we cannot stop processing them... */ + } else if (gl.shutdown_timeout || gl.shutdown_quitting) { + if (!_bus_release_name()) + break; + } - g_main_loop_run(gl.loop); + g_main_context_iteration(NULL, TRUE); + } done: + gl.shutdown_quitting = TRUE; + g_cancellable_cancel(gl.quit_cancellable); - if (gl.num_requests_pending > 0) { - /* this only happens when we quit due to SIGTERM (not due to the idle timer). - * - * Log a warning about pending scripts. - * - * Maybe we should notify NetworkManager that these scripts are left in an unknown state. - * But this is either a bug of a dispatcher script (not terminating in time). - * - * FIXME(shutdown): Also, currently NetworkManager behaves wrongly on shutdown. - * Note that systemd would not terminate NetworkManager-dispatcher before NetworkManager. - * It's NetworkManager's responsibility to keep running long enough so that all requests - * can complete (with a watchdog timer, and a warning that user provided scripts hang). */ - _LOG_X_W("exiting but there are still %u requests pending", gl.num_requests_pending); + nm_assert(gl.num_requests_pending == 0); + + if (gl.service_regist_id != 0) { + g_dbus_connection_unregister_object(gl.dbus_connection, + nm_steal_int(&gl.service_regist_id)); } - if (dbus_own_name_id != 0) - g_bus_unown_name(nm_steal_int(&dbus_own_name_id)); + nm_clear_pointer(&gl.requests_waiting, g_queue_free); - if (dbus_regist_id != 0) - g_dbus_connection_unregister_object(gl.dbus_connection, nm_steal_int(&dbus_regist_id)); + nm_clear_g_source_inst(&gl.source_idle_timeout); - nm_clear_pointer(&gl.requests_waiting, g_queue_free); + if (gl.dbus_connection) { + g_dbus_connection_flush_sync(gl.dbus_connection, NULL, NULL); + g_clear_object(&gl.dbus_connection); + } - nm_clear_g_source(&signal_id_term); - nm_clear_g_source(&signal_id_int); - nm_clear_g_source(&gl.quit_id); - nm_clear_pointer(&gl.loop, g_main_loop_unref); - g_clear_object(&gl.dbus_connection); + nm_g_main_context_iterate_ready(NULL); - if (!gl.debug) + _LOG_X_T("shutdown: exiting with %s", gl.exit_with_failure ? "failure" : "success"); + + if (gl.log_stdout) logging_shutdown(); + nm_clear_g_source_inst(&source_term); + nm_clear_g_source_inst(&source_int); + g_clear_object(&gl.quit_cancellable); + return gl.exit_with_failure ? 1 : 0; } diff --git a/src/nm-dispatcher/tests/test-dispatcher-envp.c b/src/nm-dispatcher/tests/test-dispatcher-envp.c index 297cfbbd..8a24c426 100644 --- a/src/nm-dispatcher/tests/test-dispatcher-envp.c +++ b/src/nm-dispatcher/tests/test-dispatcher-envp.c @@ -159,7 +159,7 @@ add_uint_array(GKeyFile * kf, if (tmp == NULL) return TRUE; - split = nm_utils_strsplit_set_with_empty(tmp, " "); + split = nm_strsplit_set_with_empty(tmp, " "); if (split) { gs_unref_array GArray *items = NULL; @@ -229,7 +229,7 @@ parse_ip4(GKeyFile *kf, GVariant **out_props, const char *section, GError **erro tmp = g_key_file_get_string(kf, section, "domains", error); if (tmp == NULL) return FALSE; - split = nm_utils_strsplit_set_with_empty(tmp, " "); + split = nm_strsplit_set_with_empty(tmp, " "); if (split) { for (iter = split; *iter; iter++) g_strstrip((char *) *iter); @@ -247,7 +247,7 @@ parse_ip4(GKeyFile *kf, GVariant **out_props, const char *section, GError **erro tmp = g_key_file_get_string(kf, section, "addresses", error); if (tmp == NULL) return FALSE; - split = nm_utils_strsplit_set_with_empty(tmp, ","); + split = nm_strsplit_set_with_empty(tmp, ","); if (split) { gs_unref_ptrarray GPtrArray *addresses = NULL; const char * gateway = NULL; @@ -291,7 +291,7 @@ parse_ip4(GKeyFile *kf, GVariant **out_props, const char *section, GError **erro nm_clear_g_free(&tmp); tmp = g_key_file_get_string(kf, section, "routes", NULL); - split = nm_utils_strsplit_set_with_empty(tmp, ","); + split = nm_strsplit_set_with_empty(tmp, ","); if (split) { gs_unref_ptrarray GPtrArray *routes = NULL; diff --git a/src/nm-initrd-generator/nmi-cmdline-reader.c b/src/nm-initrd-generator/nmi-cmdline-reader.c index a8501336..8fafb08f 100644 --- a/src/nm-initrd-generator/nmi-cmdline-reader.c +++ b/src/nm-initrd-generator/nmi-cmdline-reader.c @@ -364,7 +364,7 @@ reader_read_all_connections_from_fw(Reader *reader, const char *sysfs_dir) gs_free const char ** keys = NULL; ibft = nmi_ibft_read(sysfs_dir); - keys = nm_utils_strdict_get_keys(ibft, TRUE, &length); + keys = nm_strdict_get_keys(ibft, TRUE, &length); for (i = 0; i < length; i++) { gs_unref_object NMConnection *connection = NULL; @@ -394,6 +394,121 @@ reader_read_all_connections_from_fw(Reader *reader, const char *sysfs_dir) reader_add_connection(reader, "ofw", dt_connection); } +#define _strv_is_same_unordered(strv, ...) \ + nm_strv_is_same_unordered(NM_CAST_STRV_CC(strv), -1, NM_MAKE_STRV(__VA_ARGS__), -1) + +static void +_strv_remove(const char **strv, const char *needle) +{ + gssize idx; + gsize len; + gsize i; + + idx = nm_strv_find_first(strv, -1, needle); + if (idx < 0) + return; + + /* Remove element at idx, by shifting the remaining ones + * (including the terminating NULL). */ + len = NM_PTRARRAY_LEN(strv); + for (i = idx; i < len; i++) + strv[i] = strv[i + 1]; +} + +static const char * +_parse_ip_method(const char *kind) +{ + const char *const KINDS[] = { + "none", + "dhcp", + "dhcp6", + "link6", + "auto", + "ibft", + }; + gs_free char * kind_to_free = NULL; + gs_free const char **strv = NULL; + gsize i; + + kind = nm_strstrip_avoid_copy_a(300, kind, &kind_to_free); + + if (nm_str_is_empty(kind)) { + /* Dracut defaults empty/missing to "dhcp". We treat them differently, as it + * depends on whether we have IP addresses too. + * https://github.com/dracutdevs/dracut/blob/3cc9f1c10c67dcdb5254e0eb69f19e9ab22abf20/modules.d/35network-legacy/parse-ip-opts.sh#L62 */ + return "auto"; + } + + for (i = 0; i < G_N_ELEMENTS(KINDS); i++) { + if (nm_streq(kind, KINDS[i])) + return KINDS[i]; + } + + /* the following are (currently) treated as aliases. */ + if (nm_streq(kind, "fw")) + return "ibft"; + if (nm_streq(kind, "single-dhcp")) + return "dhcp"; + if (nm_streq(kind, "off")) + return "none"; + if (nm_streq(kind, "auto6")) + return "dhcp6"; + if (NM_IN_STRSET(kind, "on", "any")) + return "auto"; + + if (!strchr(kind, ',')) + return NULL; + + /* dracut also supports combinations, separated by comma. We don't + * support arbitrary combinations, but accept specific subsets. */ + strv = nm_strsplit_set_full(kind, ",", NM_STRSPLIT_SET_FLAGS_STRSTRIP); + if (!strv) + return NULL; + + /* first normalize the strv array by replacing all entries by their + * normalized kind. */ + for (i = 0; strv[i]; i++) { + strv[i] = _parse_ip_method(strv[i]); + if (!strv[i]) { + /* Unknown key. Not recognized. */ + return NULL; + } + } + + /* sort list and remove duplicates. */ + nm_strv_sort(strv, -1); + nm_strv_cleanup_const(strv, TRUE, TRUE); + + if (nm_strv_find_first(strv, -1, "auto") >= 0) { + /* if "auto" is present, then "dhcp4", "dhcp6", and "local6" is implied. */ + _strv_remove(strv, "dhcp4"); + _strv_remove(strv, "dhcp6"); + _strv_remove(strv, "local6"); + } else if (nm_strv_find_first(strv, -1, "dhcp6") >= 0) { + /* if "dhcp6" is present, then "local6" is implied. */ + _strv_remove(strv, "local6"); + } + + if (strv[0] && !strv[1]) { + /* there is only one value left. It's good. */ + return strv[0]; + } + + /* only certain combinations are allowed... those are listed + * and mapped to a canonical value. + */ + if (_strv_is_same_unordered(strv, "dhcp", "dhcp6")) + return "dhcp4+auto6"; + /* For the moment, this maps to "auto". This might be revisited + * in the future to add new kinds like "dhcp+local6" + */ + if (_strv_is_same_unordered(strv, "dhcp", "local6")) + return "auto"; + + /* undetected. */ + return NULL; +} + static void reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument) { @@ -403,7 +518,8 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument) gs_unref_hashtable GHashTable *ibft = NULL; const char * tmp; const char * tmp2; - const char * kind = NULL; + const char * tmp3; + const char * kind; const char * client_ip = NULL; const char * peer = NULL; const char * gateway_ip = NULL; @@ -432,24 +548,17 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument) tmp = get_word(&argument, ':'); if (!*argument) { /* ip={dhcp|on|any|dhcp6|auto6|link6|ibft} */ - kind = tmp; + kind = _parse_ip_method(tmp); + if (!kind) { + /* invalid method. We treat it as "auto". */ + kind = "auto"; + } } else { tmp2 = get_word(&argument, ':'); - if (NM_IN_STRSET(tmp2, - "none", - "off", - "dhcp", - "single-dhcp", - "on" - "any", - "dhcp6", - "auto", - "auto6", - "link6", - "ibft")) { + if (!nm_str_is_empty(tmp2) && (tmp3 = _parse_ip_method(tmp2))) { /* :{none|off|dhcp|on|any|dhcp6|auto|auto6|link6|ibft} */ iface_spec = tmp; - kind = tmp2; + kind = tmp3; } else { /* :[]:::: */ client_ip = tmp; @@ -466,7 +575,12 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument) netmask = get_word(&argument, ':'); client_hostname = get_word(&argument, ':'); iface_spec = get_word(&argument, ':'); - kind = get_word(&argument, ':'); + tmp2 = get_word(&argument, ':'); + kind = _parse_ip_method(tmp2); + if (!kind) { + /* invalid method. We treat that as "auto". */ + kind = "auto"; + } } if (client_hostname && !nm_sd_hostname_is_valid(client_hostname, FALSE)) @@ -495,7 +609,7 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument) } } - if (iface_spec == NULL && NM_IN_STRSET(kind, "fw", "ibft")) { + if (iface_spec == NULL && nm_streq(kind, "ibft")) { reader_read_all_connections_from_fw(reader, sysfs_dir); return; } @@ -592,7 +706,7 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument) } /* Dynamic IP configuration configured explicitly. */ - if (NM_IN_STRSET(kind, "none", "off")) { + if (nm_streq(kind, "none")) { if (nm_setting_ip_config_get_num_addresses(s_ip6) == 0) { g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, @@ -605,7 +719,7 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument) NM_SETTING_IP4_CONFIG_METHOD_DISABLED, NULL); } - } else if (NM_IN_STRSET(kind, "dhcp", "single-dhcp")) { + } else if (nm_streq(kind, "dhcp")) { g_object_set(s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, @@ -618,7 +732,7 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument) NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); } - } else if (NM_IN_STRSET(kind, "auto6", "dhcp6")) { + } else if (nm_streq(kind, "dhcp6")) { g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, @@ -631,7 +745,17 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument) NM_SETTING_IP4_CONFIG_METHOD_DISABLED, NULL); } - } else if (nm_streq0(kind, "link6")) { + } else if (nm_streq(kind, "dhcp4+auto6")) { + /* Both DHCPv4 and IPv6 autoconf are enabled, and + * each of them is tried for at least IP_REQUIRED_TIMEOUT_MSEC, + * even if the other one completes before. + */ + clear_ip4_required_timeout = FALSE; + g_object_set(s_ip6, + NM_SETTING_IP_CONFIG_REQUIRED_TIMEOUT, + NMI_IP_REQUIRED_TIMEOUT_MSEC, + NULL); + } else if (nm_streq(kind, "link6")) { g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL, @@ -644,7 +768,7 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument) NM_SETTING_IP4_CONFIG_METHOD_DISABLED, NULL); } - } else if (nm_streq0(kind, "ibft")) { + } else if (nm_streq(kind, "ibft")) { NMSettingWired *s_wired; const char * mac = NULL; const char * ifname; @@ -684,6 +808,7 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument) } } } else { + nm_assert(nm_streq(kind, "auto")); clear_ip4_required_timeout = FALSE; } @@ -1059,60 +1184,60 @@ reader_parse_rd_znet(Reader *reader, char *argument, gboolean net_ifnames) static void reader_parse_ethtool(Reader *reader, char *argument) { - const char * interface = NULL; - NMConnection * connection = NULL; - NMSettingWired *s_wired = NULL; - const char * autoneg_str = NULL; - gboolean autoneg = FALSE; - const char * speed_str = NULL; - guint speed = 0; + NMConnection * connection; + NMSettingWired *s_wired; + const char * autoneg_str; + const char * speed_str; + const char * interface; + int autoneg; + guint speed; interface = get_word(&argument, ':'); if (!interface) { - _LOGW(LOGD_CORE, "Impossible to set rd.ethtool options: invalid format"); + _LOGW(LOGD_CORE, "rd.ethtool: interface unspecified. Ignore"); return; } - if (!*argument) { - _LOGW(LOGD_CORE, "Could not find rd.ethtool options to set"); - return; - } - - connection = reader_get_connection(reader, interface, NM_SETTING_WIRED_SETTING_NAME, TRUE); - s_wired = nm_connection_get_setting_wired(connection); - autoneg_str = get_word(&argument, ':'); + speed_str = get_word(&argument, ':'); + + autoneg = -1; if (autoneg_str) { autoneg = _nm_utils_ascii_str_to_bool(autoneg_str, -1); if (autoneg == -1) - _LOGW(LOGD_CORE, - "Invalid value for rd.ethtool.autoneg, rd.ethtool.autoneg was not set"); - else - g_object_set(s_wired, NM_SETTING_WIRED_AUTO_NEGOTIATE, autoneg, NULL); + _LOGW(LOGD_CORE, "rd.ethtool: autoneg invalid. Must be boolean or empty"); } - if (!*argument) - return; - speed_str = get_word(&argument, ':'); + speed = 0; if (speed_str) { - speed = _nm_utils_ascii_str_to_int64(speed_str, 10, 0, G_MAXUINT32, -1); - if (speed == -1) - _LOGW(LOGD_CORE, "Invalid value for rd.ethtool.speed, rd.ethtool.speed was not set"); - else - g_object_set(s_wired, - NM_SETTING_WIRED_SPEED, - speed, - NM_SETTING_WIRED_DUPLEX, - "full", - NULL); + speed = _nm_utils_ascii_str_to_int64(speed_str, 10, 0, G_MAXUINT32, 0); + if (errno) + _LOGW(LOGD_CORE, "rd.ethtool: speed invalid. Must be an integer or empty"); } - if (!*argument) - return; - else + if (speed == 0 && autoneg == FALSE) { _LOGW(LOGD_CORE, - "Invalid extra argument '%s' for rd.ethtool, this value was not set", - argument); + "rd.ethtool: autoneg ignored. Cannot disable autoneg without setting speed"); + } + + connection = reader_get_connection(reader, interface, NM_SETTING_WIRED_SETTING_NAME, TRUE); + + if (autoneg != -1 || speed != 0) { + if (autoneg == -1) + autoneg = FALSE; + s_wired = nm_connection_get_setting_wired(connection); + g_object_set(s_wired, + NM_SETTING_WIRED_AUTO_NEGOTIATE, + (gboolean) autoneg, + NM_SETTING_WIRED_SPEED, + speed, + NM_SETTING_WIRED_DUPLEX, + speed == 0 ? NULL : "full", + NULL); + } + + if (*argument) + _LOGW(LOGD_CORE, "rd.ethtool: extra argument ignored"); } static void @@ -1239,7 +1364,7 @@ nmi_cmdline_reader_parse(const char * sysfs_dir, _nm_utils_ascii_str_to_int64(argument, 10, 1, G_MAXINT32, dhcp_num_tries); } else if (nm_streq(tag, "rd.net.dhcp.vendor-class")) { if (nm_utils_validate_dhcp4_vendor_class_id(argument, NULL)) - nm_utils_strdup_reset(&reader->dhcp4_vci, argument); + nm_strdup_reset(&reader->dhcp4_vci, argument); } else if (nm_streq(tag, "rd.net.timeout.carrier")) { reader->carrier_timeout_sec = _nm_utils_ascii_str_to_int64(argument, 10, 0, G_MAXINT32, 0); diff --git a/src/nm-initrd-generator/tests/test-cmdline-reader.c b/src/nm-initrd-generator/tests/test-cmdline-reader.c index e2a37c58..2cb1b2f4 100644 --- a/src/nm-initrd-generator/tests/test-cmdline-reader.c +++ b/src/nm-initrd-generator/tests/test-cmdline-reader.c @@ -140,7 +140,7 @@ static void test_dhcp_with_hostname(void) { gs_unref_hashtable GHashTable *connections = NULL; - const char *const * ARGV = NM_MAKE_STRV("ip=::::host1::dhcp"); + const char *const * ARGV = NM_MAKE_STRV("ip=::::host1::dhcp,dhcp6"); NMConnection * connection; NMSettingConnection * s_con; NMSettingWired * s_wired; @@ -191,7 +191,7 @@ test_dhcp_with_hostname(void) static void test_dhcp_with_mtu(void) { - const char *const *ARGV0 = NM_MAKE_STRV("ip=:dhcp:1499"); + const char *const *ARGV0 = NM_MAKE_STRV("ip=:dhcp6,dhcp:1499"); const char *const *ARGV1 = NM_MAKE_STRV("ip=::::::dhcp:1499"); const char *const *ARGV[] = {ARGV0, ARGV1}; guint i; @@ -300,7 +300,7 @@ test_dhcp_timeout(void) static void test_if_auto_with_mtu(void) { - const char *const *ARGV = NM_MAKE_STRV("ip=eth0:auto:1666", "="); + const char *const *ARGV = NM_MAKE_STRV("ip=eth0:dhcp,dhcp6:1666", "="); gs_unref_object NMConnection *connection = NULL; NMSettingConnection * s_con; NMSettingWired * s_wired; @@ -324,11 +324,17 @@ test_if_auto_with_mtu(void) g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO); g_assert(!nm_setting_ip_config_get_ignore_auto_dns(s_ip4)); g_assert_cmpint(nm_setting_ip_config_get_dhcp_timeout(s_ip4), ==, 90); + g_assert_cmpint(nm_setting_ip_config_get_required_timeout(s_ip4), + ==, + NMI_IP_REQUIRED_TIMEOUT_MSEC); s_ip6 = nm_connection_get_setting_ip6_config(connection); g_assert(s_ip6); g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_AUTO); g_assert(!nm_setting_ip_config_get_ignore_auto_dns(s_ip6)); + g_assert_cmpint(nm_setting_ip_config_get_required_timeout(s_ip6), + ==, + NMI_IP_REQUIRED_TIMEOUT_MSEC); } static void @@ -2272,203 +2278,145 @@ test_carrier_timeout(void) g_assert_cmpint(carrier_timeout_sec, ==, 20); } -/* Obs1.: this function is implemented as macro, and not as a function, - * to show the correct line in g_assert() debug */ -#define _ethtool_connection_check_and_get(connection) \ - ({ \ - NMSettingWired *_s_wired = NULL; \ - NMConnection * _connection = connection; \ - \ - g_assert(nm_connection_get_setting_connection(_connection)); \ - g_assert(nm_connection_is_type(_connection, NM_SETTING_WIRED_SETTING_NAME)); \ - g_assert(nm_connection_get_setting_ip4_config(_connection)); \ - g_assert(nm_connection_get_setting_ip6_config(_connection)); \ - _s_wired = nm_connection_get_setting_wired(_connection); \ - g_assert(NM_IS_SETTING_WIRED(_s_wired)); \ - \ - _s_wired; \ - }) +#define _ethtool_check_inval(arg) \ + G_STMT_START \ + { \ + gs_unref_hashtable GHashTable *_connections2 = NULL; \ + \ + _connections2 = _parse_cons(NM_MAKE_STRV(arg)); \ + \ + g_test_assert_expected_messages(); \ + \ + g_assert_cmpint(g_hash_table_size(_connections2), ==, 0); \ + } \ + G_STMT_END + +#define _ethtool_check_v(strv, autoneg, speed) \ + G_STMT_START \ + { \ + gs_unref_object NMConnection *_connection = NULL; \ + NMSettingWired * _s_wired; \ + typeof(speed) _speed = speed; \ + \ + _connection = _parse_con(strv, "eth0"); \ + \ + g_test_assert_expected_messages(); \ + \ + g_assert(nm_connection_get_setting_connection(_connection)); \ + g_assert(nm_connection_is_type(_connection, NM_SETTING_WIRED_SETTING_NAME)); \ + g_assert(nm_connection_get_setting_ip4_config(_connection)); \ + g_assert(nm_connection_get_setting_ip6_config(_connection)); \ + _s_wired = nm_connection_get_setting_wired(_connection); \ + g_assert(NM_IS_SETTING_WIRED(_s_wired)); \ + \ + g_assert_cmpint(nm_setting_wired_get_auto_negotiate(_s_wired), ==, (autoneg)); \ + g_assert_cmpint(nm_setting_wired_get_speed(_s_wired), ==, _speed); \ + g_assert_cmpstr(nm_setting_wired_get_duplex(_s_wired), ==, (_speed == 0 ? NULL : "full")); \ + } \ + G_STMT_END + +#define _ethtool_check(arg, autoneg, speed) \ + _ethtool_check_v(NM_MAKE_STRV("" arg ""), (autoneg), (speed)) static void test_rd_ethtool(void) { - const char *const *ARGV = NULL; - NMConnection * connection = NULL; - GHashTable * connections = NULL; - NMSettingWired * s_wired = NULL; + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: interface unspecified. Ignore"); + _ethtool_check_inval("rd.ethtool="); - ARGV = NM_MAKE_STRV("rd.ethtool="); - NMTST_EXPECT_NM_WARN("cmdline-reader: Impossible to set rd.ethtool options: invalid format"); - connections = _parse_cons(ARGV); - g_assert_cmpint(g_hash_table_size(connections), ==, 0); - g_hash_table_unref(connections); - g_test_assert_expected_messages(); + _ethtool_check("rd.ethtool=eth0", FALSE, 0); - ARGV = NM_MAKE_STRV("rd.ethtool=eth0"); - NMTST_EXPECT_NM_WARN("cmdline-reader: Could not find rd.ethtool options to set"); - connections = _parse_cons(ARGV); - g_assert_cmpint(g_hash_table_size(connections), ==, 0); - g_hash_table_unref(connections); - g_test_assert_expected_messages(); + _ethtool_check("rd.ethtool=eth0:", FALSE, 0); - ARGV = NM_MAKE_STRV("rd.ethtool=eth0:"); - NMTST_EXPECT_NM_WARN("cmdline-reader: Could not find rd.ethtool options to set"); - connections = _parse_cons(ARGV); - g_assert_cmpint(g_hash_table_size(connections), ==, 0); - g_hash_table_unref(connections); - g_test_assert_expected_messages(); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: interface unspecified. Ignore"); + _ethtool_check_inval("rd.ethtool=::"); - ARGV = NM_MAKE_STRV("rd.ethtool=::"); - NMTST_EXPECT_NM_WARN("cmdline-reader: Impossible to set rd.ethtool options: invalid format"); - connections = _parse_cons(ARGV); - g_assert_cmpint(g_hash_table_size(connections), ==, 0); - g_test_assert_expected_messages(); - g_hash_table_unref(connections); + _ethtool_check("rd.ethtool=eth0:on", TRUE, 0); + _ethtool_check("rd.ethtool=eth0:on:", TRUE, 0); + _ethtool_check("rd.ethtool=eth0:on::", TRUE, 0); + _ethtool_check("rd.ethtool=eth0:on:0:", TRUE, 0); - ARGV = NM_MAKE_STRV("rd.ethtool=eth0:on"); - connection = _parse_con(ARGV, "eth0"); - s_wired = _ethtool_connection_check_and_get(connection); - g_assert(nm_setting_wired_get_auto_negotiate(s_wired)); - g_object_unref(connection); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg " + "without setting speed"); + _ethtool_check("rd.ethtool=eth0:off", FALSE, 0); - ARGV = NM_MAKE_STRV("rd.ethtool=eth0:off"); - connection = _parse_con(ARGV, "eth0"); - s_wired = _ethtool_connection_check_and_get(connection); - g_assert(!nm_setting_wired_get_auto_negotiate(s_wired)); - g_object_unref(connection); + _ethtool_check("rd.ethtool=eth0:true", TRUE, 0); - ARGV = NM_MAKE_STRV("rd.ethtool=eth0:true"); - connection = _parse_con(ARGV, "eth0"); - s_wired = _ethtool_connection_check_and_get(connection); - g_assert(nm_setting_wired_get_auto_negotiate(s_wired)); - g_object_unref(connection); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg " + "without setting speed"); + _ethtool_check("rd.ethtool=eth0:false", FALSE, 0); - ARGV = NM_MAKE_STRV("rd.ethtool=eth0:false"); - connection = _parse_con(ARGV, "eth0"); - s_wired = _ethtool_connection_check_and_get(connection); - g_assert(!nm_setting_wired_get_auto_negotiate(s_wired)); - g_object_unref(connection); + _ethtool_check("rd.ethtool=eth0:1", TRUE, 0); - ARGV = NM_MAKE_STRV("rd.ethtool=eth0:1"); - connection = _parse_con(ARGV, "eth0"); - s_wired = _ethtool_connection_check_and_get(connection); - g_assert(nm_setting_wired_get_auto_negotiate(s_wired)); - g_object_unref(connection); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg " + "without setting speed"); + _ethtool_check("rd.ethtool=eth0:0", FALSE, 0); - ARGV = NM_MAKE_STRV("rd.ethtool=eth0:0"); - connection = _parse_con(ARGV, "eth0"); - s_wired = _ethtool_connection_check_and_get(connection); - g_assert(!nm_setting_wired_get_auto_negotiate(s_wired)); - g_object_unref(connection); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg invalid. Must be boolean or empty"); + _ethtool_check("rd.ethtool=eth0:randomstring", FALSE, 0); - ARGV = NM_MAKE_STRV("rd.ethtool=eth0:randomstring"); - NMTST_EXPECT_NM_WARN( - "cmdline-reader: Invalid value for rd.ethtool.autoneg, rd.ethtool.autoneg was not set"); - connections = _parse_cons(ARGV); - g_assert_cmpint(g_hash_table_size(connections), ==, 1); - g_test_assert_expected_messages(); - g_hash_table_unref(connections); + _ethtool_check("rd.ethtool=eth0::", FALSE, 0); - ARGV = NM_MAKE_STRV("rd.ethtool=eth0::"); - connections = _parse_cons(ARGV); - g_assert_cmpint(g_hash_table_size(connections), ==, 1); - g_hash_table_unref(connections); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: speed invalid. Must be an integer or empty"); + _ethtool_check("rd.ethtool=eth0::astring", FALSE, 0); - ARGV = NM_MAKE_STRV("rd.ethtool=eth0::astring"); - NMTST_EXPECT_NM_WARN( - "cmdline-reader: Invalid value for rd.ethtool.speed, rd.ethtool.speed was not set"); - connections = _parse_cons(ARGV); - g_assert_cmpint(g_hash_table_size(connections), ==, 1); - g_test_assert_expected_messages(); - g_hash_table_unref(connections); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: speed invalid. Must be an integer or empty"); + _ethtool_check("rd.ethtool=eth0::1000000000000000000000000000000000000", FALSE, 0); - ARGV = NM_MAKE_STRV("rd.ethtool=eth0::1000000000000000000000000000000000000"); - NMTST_EXPECT_NM_WARN( - "cmdline-reader: Invalid value for rd.ethtool.speed, rd.ethtool.speed was not set"); - connections = _parse_cons(ARGV); - g_assert_cmpint(g_hash_table_size(connections), ==, 1); - g_test_assert_expected_messages(); - g_hash_table_unref(connections); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: speed invalid. Must be an integer or empty"); + _ethtool_check("rd.ethtool=eth0::0.67", FALSE, 0); - ARGV = NM_MAKE_STRV("rd.ethtool=eth0::0.67"); - NMTST_EXPECT_NM_WARN( - "cmdline-reader: Invalid value for rd.ethtool.speed, rd.ethtool.speed was not set"); - connections = _parse_cons(ARGV); - g_assert_cmpint(g_hash_table_size(connections), ==, 1); - g_test_assert_expected_messages(); - g_hash_table_unref(connections); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: speed invalid. Must be an integer or empty"); + _ethtool_check("rd.ethtool=eth0::-23", FALSE, 0); - ARGV = NM_MAKE_STRV("rd.ethtool=eth0::-23"); - NMTST_EXPECT_NM_WARN( - "cmdline-reader: Invalid value for rd.ethtool.speed, rd.ethtool.speed was not set"); - connections = _parse_cons(ARGV); - g_assert_cmpint(g_hash_table_size(connections), ==, 1); - g_test_assert_expected_messages(); - g_hash_table_unref(connections); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: speed invalid. Must be an integer or empty"); + _ethtool_check("rd.ethtool=eth0::-23:", FALSE, 0); - ARGV = NM_MAKE_STRV("rd.ethtool=eth0:1:10"); - connection = _parse_con(ARGV, "eth0"); - s_wired = _ethtool_connection_check_and_get(connection); - g_assert(nm_setting_wired_get_auto_negotiate(s_wired)); - g_assert_cmpint(nm_setting_wired_get_speed(s_wired), ==, 10); - g_assert_cmpstr(nm_setting_wired_get_duplex(s_wired), ==, "full"); - g_object_unref(connection); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: speed invalid. Must be an integer or empty"); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: extra argument ignored"); + _ethtool_check("rd.ethtool=eth0::-23::", FALSE, 0); - ARGV = NM_MAKE_STRV("rd.ethtool=eth0::100"); - connection = _parse_con(ARGV, "eth0"); - s_wired = _ethtool_connection_check_and_get(connection); - g_assert(!nm_setting_wired_get_auto_negotiate(s_wired)); - g_assert_cmpint(nm_setting_wired_get_speed(s_wired), ==, 100); - g_assert_cmpstr(nm_setting_wired_get_duplex(s_wired), ==, "full"); - g_object_unref(connection); - - ARGV = NM_MAKE_STRV("rd.ethtool=eth0:::bogus"); - NMTST_EXPECT_NM_WARN( - "cmdline-reader: Invalid extra argument 'bogus' for rd.ethtool, this value was not set"); - connections = _parse_cons(ARGV); - g_assert_cmpint(g_hash_table_size(connections), ==, 1); - g_test_assert_expected_messages(); - g_hash_table_unref(connections); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: speed invalid. Must be an integer or empty"); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: extra argument ignored"); + _ethtool_check("rd.ethtool=eth0::-23::foo", FALSE, 0); - ARGV = NM_MAKE_STRV("rd.ethtool=eth0::10:bogus"); - NMTST_EXPECT_NM_WARN( - "cmdline-reader: Invalid extra argument 'bogus' for rd.ethtool, this value was not set"); - connection = _parse_con(ARGV, "eth0"); - s_wired = _ethtool_connection_check_and_get(connection); - g_assert(!nm_setting_wired_get_auto_negotiate(s_wired)); - g_assert_cmpint(nm_setting_wired_get_speed(s_wired), ==, 10); - g_assert_cmpstr(nm_setting_wired_get_duplex(s_wired), ==, "full"); - g_test_assert_expected_messages(); - g_object_unref(connection); - - ARGV = NM_MAKE_STRV("rd.ethtool=eth0:on:100:bogus"); - NMTST_EXPECT_NM_WARN( - "cmdline-reader: Invalid extra argument 'bogus' for rd.ethtool, this value was not set"); - connection = _parse_con(ARGV, "eth0"); - s_wired = _ethtool_connection_check_and_get(connection); - g_assert(nm_setting_wired_get_auto_negotiate(s_wired)); - g_assert_cmpint(nm_setting_wired_get_speed(s_wired), ==, 100); - g_assert_cmpstr(nm_setting_wired_get_duplex(s_wired), ==, "full"); - g_test_assert_expected_messages(); - g_object_unref(connection); - - ARGV = NM_MAKE_STRV("rd.ethtool=eth0:on:100:bogus"); - NMTST_EXPECT_NM_WARN( - "cmdline-reader: Invalid extra argument 'bogus' for rd.ethtool, this value was not set"); - connection = _parse_con(ARGV, "eth0"); - s_wired = _ethtool_connection_check_and_get(connection); - g_assert(nm_setting_wired_get_auto_negotiate(s_wired)); - g_assert_cmpint(nm_setting_wired_get_speed(s_wired), ==, 100); - g_assert_cmpstr(nm_setting_wired_get_duplex(s_wired), ==, "full"); - g_test_assert_expected_messages(); - g_object_unref(connection); - - ARGV = NM_MAKE_STRV("rd.ethtool=:::"); - NMTST_EXPECT_NM_WARN("cmdline-reader: Impossible to set rd.ethtool options: invalid format"); - connections = _parse_cons(ARGV); - g_assert_cmpint(g_hash_table_size(connections), ==, 0); - g_test_assert_expected_messages(); - g_hash_table_unref(connections); + _ethtool_check("rd.ethtool=eth0:1:10", TRUE, 10); + + _ethtool_check("rd.ethtool=eth0::100", FALSE, 100); + + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: extra argument ignored"); + _ethtool_check("rd.ethtool=eth0:::bogus", FALSE, 0); + + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: extra argument ignored"); + _ethtool_check("rd.ethtool=eth0::10:bogus", FALSE, 10); + + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: extra argument ignored"); + _ethtool_check("rd.ethtool=eth0:on:100:bogus", TRUE, 100); + + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: interface unspecified. Ignore"); + _ethtool_check_inval("rd.ethtool=:::"); + + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg " + "without setting speed"); + _ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:off:0", "rd.ethtool=eth0:on"), TRUE, 0); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg " + "without setting speed"); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg " + "without setting speed"); + _ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:off:0", "rd.ethtool=eth0:off"), FALSE, 0); + _ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:on:0", "rd.ethtool=eth0:on"), TRUE, 0); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg " + "without setting speed"); + _ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:on:0", "rd.ethtool=eth0:off"), FALSE, 0); + _ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:off:100", "rd.ethtool=eth0:on"), TRUE, 0); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg " + "without setting speed"); + _ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:off:100", "rd.ethtool=eth0:off"), FALSE, 0); + _ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:on:100", "rd.ethtool=eth0:on"), TRUE, 0); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg " + "without setting speed"); + _ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:on:100", "rd.ethtool=eth0:off"), FALSE, 0); + _ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:off:100", "rd.ethtool=eth0:"), FALSE, 100); } /*****************************************************************************/ diff --git a/src/nm-priv-helper/meson.build b/src/nm-priv-helper/meson.build new file mode 100644 index 00000000..e9f8a7c3 --- /dev/null +++ b/src/nm-priv-helper/meson.build @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +configure_file( + input: 'org.freedesktop.nm-priv-helper.service.in', + output: '@BASENAME@', + install_dir: dbus_system_bus_services_dir, + configuration: data_conf, +) + +install_data( + 'nm-priv-helper.conf', + install_dir: dbus_conf_dir, +) + +executable( + 'nm-priv-helper', + 'nm-priv-helper.c', + include_directories : [ + src_inc, + top_inc, + ], + dependencies: [ + glib_dep, + ], + link_with: [ + libnm_base, + libnm_log_null, + libnm_glib_aux, + libnm_std_aux, + libc_siphash, + ], + link_args: ldflags_linker_script_binary, + link_depends: linker_script_binary, + install: true, + install_dir: nm_libexecdir, +) diff --git a/src/nm-priv-helper/nm-priv-helper.c b/src/nm-priv-helper/nm-priv-helper.c new file mode 100644 index 00000000..76ca0cab --- /dev/null +++ b/src/nm-priv-helper/nm-priv-helper.c @@ -0,0 +1,696 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include "libnm-glib-aux/nm-default-glib-i18n-prog.h" + +#include + +#include "c-list/src/c-list.h" +#include "libnm-base/nm-priv-helper-utils.h" +#include "libnm-glib-aux/nm-dbus-aux.h" +#include "libnm-glib-aux/nm-io-utils.h" +#include "libnm-glib-aux/nm-logging-base.h" +#include "libnm-glib-aux/nm-shared-utils.h" +#include "libnm-glib-aux/nm-time-utils.h" + +/* nm-priv-helper doesn't link with libnm-core nor libnm-base, but these + * headers can be used independently. */ +#include "libnm-core-public/nm-dbus-interface.h" + +/*****************************************************************************/ + +#define IDLE_TIMEOUT_MSEC 2000 +#define IDLE_TIMEOUT_INFINITY G_MAXINT32 + +/*****************************************************************************/ + +/* Serves only the purpose to mark environment variables that are honored by + * the application. You can search for this macro, and find what options are supported. */ +#define _ENV(var) ("" var "") + +/*****************************************************************************/ + +typedef struct _GlobalData GlobalData; + +typedef struct { + CList pending_jobs_lst; + GlobalData *gl; +} PendingJobData; + +struct _GlobalData { + GDBusConnection *dbus_connection; + GCancellable * quit_cancellable; + + GSource *source_sigterm; + + CList pending_jobs_lst_head; + + GSource *source_idle_timeout; + + char *name_owner; + + gint64 start_timestamp_msec; + + guint name_owner_changed_id; + guint service_regist_id; + + guint32 timeout_msec; + + bool name_owner_initialized; + + /* This is controlled by $NM_PRIV_HELPER_NO_AUTH_FOR_TESTING. It disables authentication + * of the request, so it is ONLY for testing. */ + bool no_auth_for_testing; + + bool name_requested; + bool reject_new_requests; + + bool shutdown_quitting; + bool shutdown_timeout; +}; + +/*****************************************************************************/ + +static void _pending_job_register_object(GlobalData *gl, GObject *obj); + +/*****************************************************************************/ + +#define _nm_log(level, ...) _nm_log_simple_printf((level), __VA_ARGS__) + +#define _NMLOG(level, ...) \ + G_STMT_START \ + { \ + const NMLogLevel _level = (level); \ + \ + if (_nm_logging_enabled(_level)) { \ + _nm_log(_level, __VA_ARGS__); \ + } \ + } \ + G_STMT_END + +/*****************************************************************************/ + +static void +_handle_ping(GlobalData *gl, GDBusMethodInvocation *invocation, const char *arg) +{ + gs_free char *msg = NULL; + gint64 running_msec; + + running_msec = nm_utils_clock_gettime_msec(CLOCK_BOOTTIME) - gl->start_timestamp_msec; + + msg = g_strdup_printf("pid=%lu, unique-name=%s, nm-name-owner=%s, since=%" G_GINT64_FORMAT + ".%03d%s, pong=%s", + (unsigned long) getpid(), + g_dbus_connection_get_unique_name(gl->dbus_connection), + gl->name_owner ?: "(none)", + (gint64) (running_msec / 1000), + (int) (running_msec % 1000), + gl->no_auth_for_testing ? ", no-auth-for-testing" : "", + arg); + g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", msg)); +} + +static void +_handle_get_fd(GlobalData *gl, GDBusMethodInvocation *invocation, guint32 fd_type) +{ + nm_auto_close int fd = -1; + gs_unref_object GUnixFDList *fd_list = NULL; + gs_free_error GError *error = NULL; + + if (fd_type != (NMPrivHelperGetFDType) fd_type) + fd_type = NM_PRIV_HELPER_GET_FD_TYPE_NONE; + + fd = nm_priv_helper_utils_open_fd(fd_type, &error); + if (fd < 0) { + g_dbus_method_invocation_take_error(invocation, g_steal_pointer(&error)); + return; + } + + fd_list = g_unix_fd_list_new_from_array(&fd, 1); + nm_steal_fd(&fd); + + g_dbus_method_invocation_return_value_with_unix_fd_list(invocation, NULL, fd_list); +} + +/*****************************************************************************/ + +static gboolean +_signal_callback_term(gpointer user_data) +{ + GlobalData *gl = user_data; + + _LOGD("sigterm received (%s)", + c_list_is_empty(&gl->pending_jobs_lst_head) ? "quit mainloop" : "cancel operations"); + + gl->shutdown_quitting = TRUE; + g_cancellable_cancel(gl->quit_cancellable); + return G_SOURCE_CONTINUE; +} + +/*****************************************************************************/ + +static GDBusConnection * +_bus_get(GCancellable *cancellable, int *out_exit_code) +{ + gs_free_error GError *error = NULL; + gs_unref_object GDBusConnection *dbus_connection = NULL; + + dbus_connection = nm_g_bus_get_blocking(cancellable, &error); + + if (!dbus_connection) { + gboolean was_cancelled = nm_utils_error_is_cancelled(error); + + NM_SET_OUT(out_exit_code, was_cancelled ? EXIT_SUCCESS : EXIT_FAILURE); + if (!was_cancelled) + _LOGE("dbus: failure to get D-Bus connection: %s", error->message); + return NULL; + } + + /* On bus-disconnect, GDBus will raise(SIGTERM), which we handle like a + * regular request to quit. */ + g_dbus_connection_set_exit_on_close(dbus_connection, TRUE); + + _LOGD("dbus: unique name: %s", g_dbus_connection_get_unique_name(dbus_connection)); + + return g_steal_pointer(&dbus_connection); +} + +/*****************************************************************************/ + +static void +_name_owner_changed_cb(GDBusConnection *connection, + const char * sender_name, + const char * object_path, + const char * interface_name, + const char * signal_name, + GVariant * parameters, + gpointer user_data) +{ + GlobalData *gl = user_data; + const char *new_owner; + + if (!gl->name_owner_initialized) + return; + + if (!g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) + return; + + g_variant_get(parameters, "(&s&s&s)", NULL, NULL, &new_owner); + new_owner = nm_str_not_empty(new_owner); + + _LOGD("%s name-owner changed: %s -> %s", + NM_DBUS_SERVICE, + gl->name_owner ?: "(null)", + new_owner ?: "(null)"); + + nm_strdup_reset(&gl->name_owner, new_owner); +} + +typedef struct { + GlobalData *gl; + char ** p_name_owner; + gboolean is_cancelled; +} BusFindNMNameOwnerData; + +static void +_bus_find_nm_nameowner_cb(const char *name_owner, GError *error, gpointer user_data) +{ + BusFindNMNameOwnerData *data = user_data; + + *data->p_name_owner = nm_strdup_not_empty(name_owner); + data->is_cancelled = nm_utils_error_is_cancelled(error); + data->gl->name_owner_initialized = TRUE; +} + +static gboolean +_bus_find_nm_nameowner(GlobalData *gl) +{ + BusFindNMNameOwnerData data; + guint name_owner_changed_id; + gs_free char * name_owner = NULL; + + name_owner_changed_id = + nm_dbus_connection_signal_subscribe_name_owner_changed(gl->dbus_connection, + NM_DBUS_SERVICE, + _name_owner_changed_cb, + gl, + NULL); + + data = (BusFindNMNameOwnerData){ + .gl = gl, + .is_cancelled = FALSE, + .p_name_owner = &name_owner, + }; + nm_dbus_connection_call_get_name_owner(gl->dbus_connection, + NM_DBUS_SERVICE, + 10000, + gl->quit_cancellable, + _bus_find_nm_nameowner_cb, + &data); + while (!gl->name_owner_initialized) + g_main_context_iteration(NULL, TRUE); + + if (data.is_cancelled) { + g_dbus_connection_signal_unsubscribe(gl->dbus_connection, name_owner_changed_id); + return FALSE; + } + + gl->name_owner_changed_id = name_owner_changed_id; + gl->name_owner = g_steal_pointer(&name_owner); + return TRUE; +} + +/*****************************************************************************/ + +static void +_bus_method_call(GDBusConnection * connection, + const char * sender, + const char * object_path, + const char * interface_name, + const char * method_name, + GVariant * parameters, + GDBusMethodInvocation *invocation, + gpointer user_data) +{ + GlobalData *gl = user_data; + const char *arg_s; + guint32 arg_u; + + nm_assert(nm_streq(object_path, NM_PRIV_HELPER_DBUS_OBJECT_PATH)); + nm_assert(nm_streq(interface_name, NM_PRIV_HELPER_DBUS_IFACE_NAME)); + + if (!gl->no_auth_for_testing && !nm_streq0(sender, gl->name_owner)) { + _LOGT("dbus: request sender=%s, %s%s, ACCESS DENIED", + sender, + method_name, + g_variant_get_type_string(parameters)); + g_dbus_method_invocation_return_error(invocation, + G_DBUS_ERROR, + G_DBUS_ERROR_ACCESS_DENIED, + "Access denied"); + return; + } + + if (gl->reject_new_requests) { + /* after the name was released, we must not accept new requests. This new + * request was probably targeted against the unique-name. But we already + * gave up the well-known name. If we'd accept new request now, they would + * keep the service running indefinitely (and thus preventing the service + * to restart and serve the well-known name. */ + _LOGT("dbus: request sender=%s, %s%s, SERVER SHUTTING DOWN", + sender, + method_name, + g_variant_get_type_string(parameters)); + g_dbus_method_invocation_return_error(invocation, + G_DBUS_ERROR, + G_DBUS_ERROR_NO_SERVER, + "Server is exiting"); + return; + } + + _LOGT("dbus: request sender=%s, %s%s", + sender, + method_name, + g_variant_get_type_string(parameters)); + + if (!nm_streq(interface_name, NM_PRIV_HELPER_DBUS_IFACE_NAME)) + goto out_unknown_method; + + if (nm_streq(method_name, "GetFD")) { + g_variant_get(parameters, "(u)", &arg_u); + _handle_get_fd(gl, invocation, arg_u); + return; + } + if (nm_streq(method_name, "Ping")) { + g_variant_get(parameters, "(&s)", &arg_s); + _handle_ping(gl, invocation, arg_s); + return; + } + +out_unknown_method: + g_dbus_method_invocation_return_error(invocation, + G_DBUS_ERROR, + G_DBUS_ERROR_UNKNOWN_METHOD, + "Unknown method %s", + method_name); +} + +static GDBusInterfaceInfo *const interface_info = NM_DEFINE_GDBUS_INTERFACE_INFO( + NM_PRIV_HELPER_DBUS_IFACE_NAME, + .methods = NM_DEFINE_GDBUS_METHOD_INFOS( + NM_DEFINE_GDBUS_METHOD_INFO( + "Ping", + .in_args = NM_DEFINE_GDBUS_ARG_INFOS(NM_DEFINE_GDBUS_ARG_INFO("arg", "s"), ), + .out_args = NM_DEFINE_GDBUS_ARG_INFOS(NM_DEFINE_GDBUS_ARG_INFO("arg", "s"), ), ), + NM_DEFINE_GDBUS_METHOD_INFO("GetFD", + .in_args = NM_DEFINE_GDBUS_ARG_INFOS( + NM_DEFINE_GDBUS_ARG_INFO("fd_type", "u"), ), ), ), ); + +static gboolean +_bus_register_service(GlobalData *gl) +{ + static const GDBusInterfaceVTable interface_vtable = { + .method_call = _bus_method_call, + }; + gs_free_error GError * error = NULL; + NMDBusConnectionCallBlockingData data = { + .result = NULL, + }; + gs_unref_variant GVariant *ret = NULL; + guint32 ret_val; + + gl->service_regist_id = + g_dbus_connection_register_object(gl->dbus_connection, + NM_PRIV_HELPER_DBUS_OBJECT_PATH, + interface_info, + NM_UNCONST_PTR(GDBusInterfaceVTable, &interface_vtable), + gl, + NULL, + &error); + if (gl->service_regist_id == 0) { + _LOGE("dbus: error registering object %s: %s", + NM_PRIV_HELPER_DBUS_OBJECT_PATH, + error->message); + return FALSE; + } + + _LOGD("dbus: object %s registered", NM_PRIV_HELPER_DBUS_OBJECT_PATH); + + /* regardless whether the request is successful, after we start calling + * RequestName, we remember that we need to ReleaseName it. */ + gl->name_requested = TRUE; + + nm_dbus_connection_call_request_name(gl->dbus_connection, + NM_PRIV_HELPER_DBUS_BUS_NAME, + DBUS_NAME_FLAG_ALLOW_REPLACEMENT + | DBUS_NAME_FLAG_REPLACE_EXISTING, + 10000, + gl->quit_cancellable, + nm_dbus_connection_call_blocking_callback, + &data); + + /* Note that with D-Bus activation, the first request will already hit us before RequestName + * completes. So when we start iterating the main context, the first request may already come + * in. */ + + ret = nm_dbus_connection_call_blocking(&data, &error); + + if (nm_utils_error_is_cancelled(error)) + return FALSE; + + if (error) { + _LOGE("d-bus: failed to request name %s: %s", NM_PRIV_HELPER_DBUS_BUS_NAME, error->message); + return FALSE; + } + + g_variant_get(ret, "(u)", &ret_val); + + if (ret_val != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + _LOGW("dbus: request name for %s failed to take name (response %u)", + NM_PRIV_HELPER_DBUS_BUS_NAME, + ret_val); + return FALSE; + } + + _LOGD("dbus: request name for %s succeeded", NM_PRIV_HELPER_DBUS_BUS_NAME); + return TRUE; +} + +/*****************************************************************************/ + +static gboolean +_idle_timeout_cb(gpointer user_data) +{ + GlobalData *gl = user_data; + + _LOGT("idle-timeout: expired"); + nm_clear_g_source_inst(&gl->source_idle_timeout); + gl->shutdown_timeout = TRUE; + return G_SOURCE_CONTINUE; +} + +static void +_idle_timeout_restart(GlobalData *gl) +{ + nm_clear_g_source_inst(&gl->source_idle_timeout); + + if (gl->shutdown_quitting) + return; + + if (!c_list_is_empty(&gl->pending_jobs_lst_head)) + return; + + if (gl->timeout_msec == IDLE_TIMEOUT_INFINITY) + return; + + nm_assert(gl->timeout_msec < G_MAXINT32); + G_STATIC_ASSERT_EXPR(G_MAXINT32 < G_MAXUINT); + + _LOGT("idle-timeout: start (%u msec)", gl->timeout_msec); + gl->source_idle_timeout = nm_g_timeout_add_source(gl->timeout_msec, _idle_timeout_cb, gl); +} + +/*****************************************************************************/ + +static gboolean +_pending_job_register_object_release_on_idle_cb(gpointer data) +{ + PendingJobData *idle_data = data; + GlobalData * gl = idle_data->gl; + + c_list_unlink_stale(&idle_data->pending_jobs_lst); + nm_g_slice_free(idle_data); + + _idle_timeout_restart(gl); + return G_SOURCE_REMOVE; +} + +static void +_pending_job_register_object_weak_cb(gpointer data, GObject *where_the_object_was) +{ + /* The object might be destroyed on another thread. We need + * to sync with the main GMainContext by scheduling an idle action + * there. */ + nm_g_idle_add(_pending_job_register_object_release_on_idle_cb, data); +} + +static void +_pending_job_register_object(GlobalData *gl, GObject *obj) +{ + PendingJobData *idle_data; + + /* if we just hit the timeout, we can ignore it. */ + gl->shutdown_timeout = FALSE; + + if (nm_clear_g_source_inst(&gl->source_idle_timeout)) + _LOGT("idle-timeout: suspend timeout for pending request"); + + idle_data = g_slice_new(PendingJobData); + + idle_data->gl = gl; + c_list_link_tail(&gl->pending_jobs_lst_head, &idle_data->pending_jobs_lst); + + g_object_weak_ref(obj, _pending_job_register_object_weak_cb, idle_data); +} + +/*****************************************************************************/ + +static void +_bus_release_name_cb(GObject *source, GAsyncResult *result, gpointer user_data) +{ + _nm_unused gs_unref_object GObject *keep_alive_object = NULL; + GlobalData * gl; + + nm_utils_user_data_unpack(user_data, &gl, &keep_alive_object); + + gl->reject_new_requests = TRUE; + g_main_context_wakeup(NULL); +} + +static gboolean +_bus_release_name(GlobalData *gl) +{ + gs_unref_object GObject *keep_alive_object = NULL; + int r; + + /* We already requested a name. To exit-on-idle without race, we need to dance. + * See https://lists.freedesktop.org/archives/dbus/2015-May/016671.html . */ + + if (!gl->name_requested) + return FALSE; + + gl->name_requested = FALSE; + gl->shutdown_quitting = TRUE; + + _LOGT("shutdown: release-name"); + + keep_alive_object = g_object_new(G_TYPE_OBJECT, NULL); + + /* we use the _pending_job_register_object() mechanism to make the loop busy during + * shutdown. */ + _pending_job_register_object(gl, keep_alive_object); + + r = nm_sd_notify("STOPPING=1"); + if (r < 0) + _LOGW("shutdown: sd_notifiy(STOPPING=1) failed: %s", nm_strerror_native(-r)); + else + _LOGT("shutdown: sd_notifiy(STOPPING=1) succeeded"); + + g_dbus_connection_call(gl->dbus_connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, + "ReleaseName", + g_variant_new("(s)", NM_PRIV_HELPER_DBUS_BUS_NAME), + G_VARIANT_TYPE("(u)"), + G_DBUS_CALL_FLAGS_NONE, + 10000, + NULL, + _bus_release_name_cb, + nm_utils_user_data_pack(gl, g_steal_pointer(&keep_alive_object))); + return TRUE; +} + +/*****************************************************************************/ + +static void +_initial_setup(GlobalData *gl) +{ + gl->no_auth_for_testing = + _nm_utils_ascii_str_to_int64(g_getenv(_ENV("NM_PRIV_HELPER_NO_AUTH_FOR_TESTING")), + 0, + 0, + 1, + 0); + gl->timeout_msec = + _nm_utils_ascii_str_to_int64(g_getenv(_ENV("NM_PRIV_HELPER_IDLE_TIMEOUT_MSEC")), + 0, + 0, + G_MAXINT32, + IDLE_TIMEOUT_MSEC); + + gl->quit_cancellable = g_cancellable_new(); + + signal(SIGPIPE, SIG_IGN); + gl->source_sigterm = nm_g_unix_signal_add_source(SIGTERM, _signal_callback_term, gl); +} + +/*****************************************************************************/ + +int +main(int argc, char **argv) +{ + GlobalData _gl = { + .quit_cancellable = NULL, + .pending_jobs_lst_head = C_LIST_INIT(_gl.pending_jobs_lst_head), + }; + GlobalData *const gl = &_gl; + int exit_code; + int r = 0; + + _nm_logging_enabled_init(g_getenv(_ENV("NM_PRIV_HELPER_LOG"))); + + gl->start_timestamp_msec = nm_utils_clock_gettime_msec(CLOCK_BOOTTIME); + + _LOGD("starting nm-priv-helper (%s)", NM_DIST_VERSION); + + _initial_setup(gl); + + if (gl->no_auth_for_testing) { + _LOGW("WARNING: running in debug mode without authentication " + "(NM_PRIV_HELPER_NO_AUTH_FOR_TESTING). "); + } + + if (gl->timeout_msec != IDLE_TIMEOUT_INFINITY) + _LOGT("idle-timeout: %u msec", gl->timeout_msec); + else + _LOGT("idle-timeout: disabled"); + + gl->dbus_connection = _bus_get(gl->quit_cancellable, &r); + if (!gl->dbus_connection) { + exit_code = r; + goto done; + } + + if (!_bus_find_nm_nameowner(gl)) { + /* abort due to cancellation. That is success. */ + exit_code = EXIT_SUCCESS; + goto done; + } + _LOGD("%s name-owner: %s", NM_DBUS_SERVICE, gl->name_owner ?: "(null)"); + + _idle_timeout_restart(gl); + + exit_code = EXIT_SUCCESS; + + if (!_bus_register_service(gl)) { + /* We failed to RequestName, but due to D-Bus activation we + * might have a pending request still (on the unique name). + * Process it below. + * + * Let's fake a shutdown signal, and still process the request below. */ + if (!g_cancellable_is_cancelled(gl->quit_cancellable)) + exit_code = EXIT_FAILURE; + gl->shutdown_quitting = TRUE; + + if (gl->name_requested) { + /* We requested a name, but something went wrong. Below we will release + * the name right away. */ + } else { + /* In case we didn't even went as far to request the name. New requests + * can only come via the unique name, and as we are shutting down, they + * are rejected. */ + gl->reject_new_requests = TRUE; + } + } + + while (TRUE) { + if (gl->shutdown_quitting) + _bus_release_name(gl); + + if (!c_list_is_empty(&gl->pending_jobs_lst_head)) { + /* we must first reply to all requests. No matter what. */ + } else if (gl->shutdown_quitting || gl->shutdown_timeout) { + /* we either hit the idle timeout or received SIGTERM. Note that + * if we received an idle-timeout and the very moment afterwards + * a new request, then _bus_method_call() will clear gl->shutdown_timeout + * (via _pending_job_register_object()). */ + if (!_bus_release_name(gl)) + break; + } + + g_main_context_iteration(NULL, TRUE); + } + +done: + _LOGD("shutdown: cleanup"); + + gl->shutdown_quitting = TRUE; + g_cancellable_cancel(gl->quit_cancellable); + + nm_assert(c_list_is_empty(&gl->pending_jobs_lst_head)); + + if (gl->service_regist_id != 0) { + g_dbus_connection_unregister_object(gl->dbus_connection, + nm_steal_int(&gl->service_regist_id)); + } + if (gl->name_owner_changed_id != 0) { + g_dbus_connection_signal_unsubscribe(gl->dbus_connection, + nm_steal_int(&gl->name_owner_changed_id)); + } + + if (gl->dbus_connection) { + g_dbus_connection_flush_sync(gl->dbus_connection, NULL, NULL); + g_clear_object(&gl->dbus_connection); + } + + nm_g_main_context_iterate_ready(NULL); + + nm_clear_g_free(&gl->name_owner); + + nm_clear_g_source_inst(&gl->source_sigterm); + nm_clear_g_source_inst(&gl->source_idle_timeout); + g_clear_object(&gl->quit_cancellable); + + _LOGD("exit (%d)", exit_code); + return exit_code; +} diff --git a/src/nm-priv-helper/nm-priv-helper.conf b/src/nm-priv-helper/nm-priv-helper.conf new file mode 100644 index 00000000..c56b2007 --- /dev/null +++ b/src/nm-priv-helper/nm-priv-helper.conf @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/src/nm-priv-helper/org.freedesktop.nm-priv-helper.service.in b/src/nm-priv-helper/org.freedesktop.nm-priv-helper.service.in new file mode 100644 index 00000000..0ca30669 --- /dev/null +++ b/src/nm-priv-helper/org.freedesktop.nm-priv-helper.service.in @@ -0,0 +1,5 @@ +[D-BUS Service] +Name=org.freedesktop.nm-priv-helper +Exec=@libexecdir@/nm-priv-helper +User=root +SystemdService=dbus-org.freedesktop.nm-priv-helper.service diff --git a/src/nmcli/agent.c b/src/nmcli/agent.c index a0b23dd1..bdbd6e45 100644 --- a/src/nmcli/agent.c +++ b/src/nmcli/agent.c @@ -7,9 +7,12 @@ #include #include +#if HAVE_EDITLINE_READLINE +#include +#else #include #include - +#endif #include "common.h" #include "utils.h" #include "libnmc-base/nm-secret-agent-simple.h" @@ -51,16 +54,14 @@ usage_agent_all(void) "Runs nmcli as both NetworkManager secret and a polkit agent.\n\n")); } -/* for pre-filling a string to readline prompt */ static char *pre_input_deftext; -static int -set_deftext(void) + +static int set_deftext(_NMC_RL_STARTUPHOOK_ARGS) { if (pre_input_deftext && rl_startup_hook) { rl_insert_text(pre_input_deftext); - g_free(pre_input_deftext); - pre_input_deftext = NULL; - rl_startup_hook = NULL; + nm_clear_g_free(&pre_input_deftext); + rl_startup_hook = NULL; } return 0; } @@ -83,8 +84,8 @@ get_secrets_from_user(const NmcConfig *nmc_config, g_print("%s\n", msg); if (secret->value) { /* Prefill the password if we have it. */ - rl_startup_hook = set_deftext; - pre_input_deftext = g_strdup(secret->value); + rl_startup_hook = set_deftext; + nm_strdup_reset(&pre_input_deftext, secret->value); } if (secret->no_prompt_entry_id) pwd = nmc_readline(nmc_config, "%s: ", secret->pretty_name); diff --git a/src/nmcli/common.c b/src/nmcli/common.c index a01a2f72..d9a981c3 100644 --- a/src/nmcli/common.c +++ b/src/nmcli/common.c @@ -10,9 +10,12 @@ #include #include #include -#include +#if HAVE_EDITLINE_READLINE +#include +#else #include - +#include +#endif #include "libnm-client-aux-extern/nm-libnm-aux.h" #include "libnmc-base/nm-vpn-helpers.h" @@ -291,7 +294,7 @@ static gconstpointer _metagen_dhcp_config_get_fcn(NMC_META_GENERIC_INFO_GET_FCN_ if (!table) goto arr_out; - arr2 = (char **) nm_utils_strdict_get_keys(table, TRUE, &n); + arr2 = (char **) nm_strdict_get_keys(table, TRUE, &n); if (!n) goto arr_out; @@ -708,8 +711,8 @@ get_secrets_from_user(const NmcConfig *nmc_config, continue; } else { /* Prefill the password if we have it. */ - rl_startup_hook = nmc_rl_set_deftext; - nmc_rl_pre_input_deftext = g_strdup(secret->value); + rl_startup_hook = nmc_rl_set_deftext; + nm_strdup_reset(&nmc_rl_pre_input_deftext, secret->value); } } if (msg) @@ -1007,10 +1010,14 @@ nmc_readline_echo(const NmcConfig *nmc_config, gboolean echo_on, const char *pro va_list args; gs_free char *prompt = NULL; char * str; +#if HAVE_READLINE_HISTORY nm_auto_free HISTORY_STATE *saved_history = NULL; HISTORY_STATE passwd_history = { 0, }; +#else + int start, curpos; +#endif va_start(args, prompt_fmt); prompt = g_strdup_vprintf(prompt_fmt, args); @@ -1020,8 +1027,12 @@ nmc_readline_echo(const NmcConfig *nmc_config, gboolean echo_on, const char *pro /* Hide the actual password */ if (!echo_on) { +#if HAVE_READLINE_HISTORY saved_history = history_get_history_state(); history_set_history_state(&passwd_history); +#else + start = where_history(); +#endif /* stifling history is important as it tells readline to * not store anything, otherwise sensitive data could be * leaked */ @@ -1034,7 +1045,13 @@ nmc_readline_echo(const NmcConfig *nmc_config, gboolean echo_on, const char *pro /* Restore the non-hiding behavior */ if (!echo_on) { rl_redisplay_function = rl_redisplay; +#if HAVE_READLINE_HISTORY history_set_history_state(saved_history); +#else + curpos = where_history(); + while (curpos > start) + remove_history(curpos--); +#endif } return str; @@ -1133,17 +1150,14 @@ nmc_rl_gen_func_ifnames(const char *text, int state) return ret; } -/* for pre-filling a string to readline prompt */ char *nmc_rl_pre_input_deftext; -int -nmc_rl_set_deftext(void) +int nmc_rl_set_deftext(_NMC_RL_STARTUPHOOK_ARGS) { if (nmc_rl_pre_input_deftext && rl_startup_hook) { rl_insert_text(nmc_rl_pre_input_deftext); - g_free(nmc_rl_pre_input_deftext); - nmc_rl_pre_input_deftext = NULL; - rl_startup_hook = NULL; + nm_clear_g_free(&nmc_rl_pre_input_deftext); + rl_startup_hook = NULL; } return 0; } @@ -1287,7 +1301,7 @@ call_cmd(NmCli *nmc, GTask *task, const NMCCommand *cmd, int argc, const char *c *call = (CmdCall){ .cmd = cmd, .argc = argc, - .argv = nm_utils_strv_dup(argv, argc, TRUE), + .argv = nm_strv_dup(argv, argc, TRUE), .task = task, }; nmc_client_new_async(NULL, diff --git a/src/nmcli/common.h b/src/nmcli/common.h index a479a455..908dad06 100644 --- a/src/nmcli/common.h +++ b/src/nmcli/common.h @@ -50,9 +50,17 @@ char * nmc_rl_gen_func_ifnames(const char *text, int state); gboolean nmc_get_in_readline(void); void nmc_set_in_readline(gboolean in_readline); +#if HAVE_EDITLINE_READLINE +/* libedit has different signature for rl_startup_hook function */ +#define _NMC_RL_STARTUPHOOK_ARGS const char *c, int i +#else +/* By default the libreadline shall be used */ +#define _NMC_RL_STARTUPHOOK_ARGS void +#endif + /* for pre-filling a string to readline prompt */ extern char *nmc_rl_pre_input_deftext; -int nmc_rl_set_deftext(void); +int nmc_rl_set_deftext(_NMC_RL_STARTUPHOOK_ARGS); char *nmc_parse_lldp_capabilities(guint value); diff --git a/src/nmcli/connections.c b/src/nmcli/connections.c index 9f700cae..5edd33f0 100644 --- a/src/nmcli/connections.c +++ b/src/nmcli/connections.c @@ -11,8 +11,12 @@ #include #include #include +#if HAVE_EDITLINE_READLINE +#include +#else #include #include +#endif #include #include "libnm-glib-aux/nm-dbus-aux.h" @@ -201,24 +205,24 @@ nmc_active_connection_cmp(NMActiveConnection *ac_a, NMActiveConnection *ac_b) conn = nm_active_connection_get_connection(ac_a); s_ip = conn ? nm_connection_get_setting_ip6_config(NM_CONNECTION(conn)) : NULL; if (s_ip - && strcmp(nm_setting_ip_config_get_method(s_ip), NM_SETTING_IP6_CONFIG_METHOD_SHARED) == 0) + && nm_streq(nm_setting_ip_config_get_method(s_ip), NM_SETTING_IP6_CONFIG_METHOD_SHARED)) cmp++; conn = nm_active_connection_get_connection(ac_b); s_ip = conn ? nm_connection_get_setting_ip6_config(NM_CONNECTION(conn)) : NULL; if (s_ip - && strcmp(nm_setting_ip_config_get_method(s_ip), NM_SETTING_IP6_CONFIG_METHOD_SHARED) == 0) + && nm_streq(nm_setting_ip_config_get_method(s_ip), NM_SETTING_IP6_CONFIG_METHOD_SHARED)) cmp--; NM_CMP_RETURN(cmp); conn = nm_active_connection_get_connection(ac_a); s_ip = conn ? nm_connection_get_setting_ip4_config(NM_CONNECTION(conn)) : NULL; if (s_ip - && strcmp(nm_setting_ip_config_get_method(s_ip), NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) + && nm_streq(nm_setting_ip_config_get_method(s_ip), NM_SETTING_IP4_CONFIG_METHOD_SHARED)) cmp++; conn = nm_active_connection_get_connection(ac_b); s_ip = conn ? nm_connection_get_setting_ip4_config(NM_CONNECTION(conn)) : NULL; if (s_ip - && strcmp(nm_setting_ip_config_get_method(s_ip), NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) + && nm_streq(nm_setting_ip_config_get_method(s_ip), NM_SETTING_IP4_CONFIG_METHOD_SHARED)) cmp--; NM_CMP_RETURN(cmp); @@ -870,18 +874,19 @@ const NmcMetaGenericInfo "," NM_SETTING_CDMA_SETTING_NAME "," NM_SETTING_BLUETOOTH_SETTING_NAME \ "," NM_SETTING_OLPC_MESH_SETTING_NAME "," NM_SETTING_VPN_SETTING_NAME \ "," NM_SETTING_INFINIBAND_SETTING_NAME "," NM_SETTING_BOND_SETTING_NAME \ - "," NM_SETTING_VLAN_SETTING_NAME "," NM_SETTING_BRIDGE_SETTING_NAME \ - "," NM_SETTING_BRIDGE_PORT_SETTING_NAME "," NM_SETTING_TEAM_SETTING_NAME \ - "," NM_SETTING_TEAM_PORT_SETTING_NAME "," NM_SETTING_OVS_BRIDGE_SETTING_NAME \ - "," NM_SETTING_OVS_INTERFACE_SETTING_NAME "," NM_SETTING_OVS_PATCH_SETTING_NAME \ - "," NM_SETTING_OVS_PORT_SETTING_NAME "," NM_SETTING_DCB_SETTING_NAME \ - "," NM_SETTING_TUN_SETTING_NAME "," NM_SETTING_IP_TUNNEL_SETTING_NAME \ - "," NM_SETTING_MACSEC_SETTING_NAME "," NM_SETTING_MACVLAN_SETTING_NAME \ - "," NM_SETTING_VXLAN_SETTING_NAME "," NM_SETTING_VRF_SETTING_NAME \ - "," NM_SETTING_WPAN_SETTING_NAME "," NM_SETTING_6LOWPAN_SETTING_NAME \ - "," NM_SETTING_WIREGUARD_SETTING_NAME "," NM_SETTING_PROXY_SETTING_NAME \ - "," NM_SETTING_TC_CONFIG_SETTING_NAME "," NM_SETTING_SRIOV_SETTING_NAME \ - "," NM_SETTING_ETHTOOL_SETTING_NAME "," NM_SETTING_OVS_DPDK_SETTING_NAME \ + "," NM_SETTING_BOND_PORT_SETTING_NAME "," NM_SETTING_VLAN_SETTING_NAME \ + "," NM_SETTING_BRIDGE_SETTING_NAME "," NM_SETTING_BRIDGE_PORT_SETTING_NAME \ + "," NM_SETTING_TEAM_SETTING_NAME "," NM_SETTING_TEAM_PORT_SETTING_NAME \ + "," NM_SETTING_OVS_BRIDGE_SETTING_NAME "," NM_SETTING_OVS_INTERFACE_SETTING_NAME \ + "," NM_SETTING_OVS_PATCH_SETTING_NAME "," NM_SETTING_OVS_PORT_SETTING_NAME \ + "," NM_SETTING_DCB_SETTING_NAME "," NM_SETTING_TUN_SETTING_NAME \ + "," NM_SETTING_IP_TUNNEL_SETTING_NAME "," NM_SETTING_MACSEC_SETTING_NAME \ + "," NM_SETTING_MACVLAN_SETTING_NAME "," NM_SETTING_VXLAN_SETTING_NAME \ + "," NM_SETTING_VRF_SETTING_NAME "," NM_SETTING_WPAN_SETTING_NAME \ + "," NM_SETTING_6LOWPAN_SETTING_NAME "," NM_SETTING_WIREGUARD_SETTING_NAME \ + "," NM_SETTING_PROXY_SETTING_NAME "," NM_SETTING_TC_CONFIG_SETTING_NAME \ + "," NM_SETTING_SRIOV_SETTING_NAME "," NM_SETTING_ETHTOOL_SETTING_NAME \ + "," NM_SETTING_OVS_DPDK_SETTING_NAME \ "," NM_SETTING_HOSTNAME_SETTING_NAME /* NM_SETTING_DUMMY_SETTING_NAME NM_SETTING_WIMAX_SETTING_NAME */ const NmcMetaGenericInfo *const nmc_fields_con_active_details_groups[] = { @@ -1058,7 +1063,8 @@ usage_connection_add(void) " [arp-interval ]\n" " [arp-ip-target ]\n" " [lacp-rate slow (0) | fast (1)]\n\n" - " bond-slave: master \n\n" + " bond-slave: master \n" + " [queue-id <0-65535>]\n\n" " team: [config |]\n\n" " team-slave: master \n" " [config |]\n\n" @@ -1121,6 +1127,7 @@ usage_connection_add(void) " [path-cost <1-65535>]\n" " [hairpin yes|no]\n\n" " team: [config |]\n\n" + " bond: [queue-id <0-65535>]\n\n" " IP_OPTIONS:\n" " [ip4 ] [gw4 ]\n" " [ip6 ] [gw6 ]\n\n")); @@ -1662,7 +1669,7 @@ split_required_fields_for_con_show(const char *input, str1 = g_string_new(NULL); str2 = g_string_new(NULL); - fields = nm_utils_strsplit_set_with_empty(input, ","); + fields = nm_strsplit_set_with_empty(input, ","); for (iter = fields; iter && *iter; iter++) { char * s_mutable = (char *) (*iter); char * dot; @@ -2003,7 +2010,7 @@ parse_preferred_connection_order(const char *order, GError **error) gboolean inverse, unique; guint i; - strv = nm_utils_strsplit_set(order, ":"); + strv = nm_strsplit_set(order, ":"); if (!strv) { g_set_error(error, NMCLI_ERROR, 0, _("incorrect string '%s' of '--order' option"), order); return NULL; @@ -2463,7 +2470,7 @@ find_device_for_connection(NmCli * nmc, g_assert(s_con); con_type = nm_setting_connection_get_connection_type(s_con); - if (strcmp(con_type, NM_SETTING_VPN_SETTING_NAME) == 0) { + if (nm_streq(con_type, NM_SETTING_VPN_SETTING_NAME)) { /* VPN connections */ NMActiveConnection *active = NULL; if (iface) { @@ -2488,8 +2495,9 @@ find_device_for_connection(NmCli * nmc, } } else { /* Other connections */ - NMDevice * found_device = NULL; - const GPtrArray *devices = nm_client_get_devices(nmc->client); + NMDevice * found_device = NULL; + const GPtrArray *devices = nm_client_get_devices(nmc->client); + gboolean found_device_with_name = FALSE; for (i = 0; i < devices->len && !found_device; i++) { NMDevice *dev = g_ptr_array_index(devices, i); @@ -2499,6 +2507,7 @@ find_device_for_connection(NmCli * nmc, if (!nm_streq0(dev_iface, iface)) continue; + found_device_with_name = TRUE; if (!nm_device_connection_compatible(dev, connection, error)) { g_prefix_error(error, _("device '%s' not compatible with connection '%s': "), @@ -2535,12 +2544,21 @@ find_device_for_connection(NmCli * nmc, if (!found_device) { if (iface) { - g_set_error(error, - NMCLI_ERROR, - 0, - _("device '%s' not compatible with connection '%s'"), - iface, - nm_setting_connection_get_id(s_con)); + if (found_device_with_name) { + g_set_error(error, + NMCLI_ERROR, + 0, + _("device '%s' not compatible with connection '%s'"), + iface, + nm_setting_connection_get_id(s_con)); + } else { + g_set_error(error, + NMCLI_ERROR, + 0, + _("device '%s' not found for connection '%s'"), + iface, + nm_setting_connection_get_id(s_con)); + } } else { g_set_error(error, NMCLI_ERROR, @@ -2833,8 +2851,7 @@ nmc_activate_connection(NmCli * nmc, &spec_object, &local); - /* Virtual connection may not have their interfaces created yet */ - if (!device_found && !nm_connection_is_virtual(connection)) { + if (!device_found) { g_set_error(error, NMCLI_ERROR, NMC_RESULT_ERROR_CON_ACTIVATION, "%s", local->message); return FALSE; } @@ -2947,7 +2964,7 @@ do_connection_up(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const argc_ptr = &arg_num; } - if (argc > 0 && strcmp(*argv, "ifname") != 0) { + if (argc > 0 && !nm_streq(*argv, "ifname")) { connection = get_connection(nmc, argc_ptr, argv_ptr, NULL, NULL, NULL, &error); if (!connection) { g_string_printf(nmc->return_text, _("Error: %s."), error->message); @@ -2960,7 +2977,7 @@ do_connection_up(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const if (argc == 1 && nmc->complete) nmc_complete_strings(*argv, "ifname", "ap", "passwd-file"); - if (strcmp(*argv, "ifname") == 0) { + if (nm_streq(*argv, "ifname")) { argc--; argv++; if (!argc) { @@ -2972,7 +2989,7 @@ do_connection_up(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const ifname = *argv; if (argc == 1 && nmc->complete) nmc_complete_device(nmc->client, ifname, ap != NULL); - } else if (strcmp(*argv, "ap") == 0) { + } else if (nm_streq(*argv, "ap")) { argc--; argv++; if (!argc) { @@ -2984,7 +3001,7 @@ do_connection_up(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const ap = *argv; if (argc == 1 && nmc->complete) nmc_complete_bssid(nmc->client, ifname, ap); - } else if (strcmp(*argv, "passwd-file") == 0) { + } else if (nm_streq(*argv, "passwd-file")) { argc--; argv++; if (!argc) { @@ -3652,7 +3669,7 @@ is_setting_mandatory(NMConnection *connection, NMSetting *setting) else item = nm_meta_setting_info_valid_parts_for_slave_type(s_type, NULL); for (; item && *item; item++) { - if (!strcmp(name, (*item)->setting_info->general->setting_name)) + if (nm_streq(name, (*item)->setting_info->general->setting_name)) return (*item)->mandatory; } } @@ -3721,11 +3738,11 @@ normalized_master_for_slave(const GPtrArray *connections, s_con = nm_connection_get_setting_connection(connection); g_assert(s_con); con_type = nm_setting_connection_get_connection_type(s_con); - if (type && g_strcmp0(con_type, type) != 0) + if (type && !nm_streq0(con_type, type)) continue; if (func) { /* There was a prefix; only compare to that type. */ - if (g_strcmp0(master, func(connection)) == 0) { + if (nm_streq0(master, func(connection))) { if (out_type) *out_type = con_type; if (func == nm_connection_get_id) @@ -3738,13 +3755,13 @@ normalized_master_for_slave(const GPtrArray *connections, id = nm_connection_get_id(connection); uuid = nm_connection_get_uuid(connection); ifname = nm_connection_get_interface_name(connection); - if (g_strcmp0(master, uuid) == 0 || g_strcmp0(master, ifname) == 0) { + if (NM_IN_STRSET(master, uuid, ifname)) { out_master = master; if (out_type) *out_type = con_type; break; } - if (!found_by_id && g_strcmp0(master, id) == 0) { + if (!found_by_id && nm_streq0(master, id)) { out_type_by_id = con_type; found_by_id = uuid; } @@ -3777,13 +3794,13 @@ prompt_yes_no(gboolean default_yes, char *delim) if (!delim) delim = ""; - snprintf(prompt, - sizeof(prompt), - "(%s/%s) [%s]%s ", - WORD_YES, - WORD_NO, - default_yes ? WORD_YES : WORD_NO, - delim); + g_snprintf(prompt, + sizeof(prompt), + "(%s/%s) [%s]%s ", + WORD_YES, + WORD_NO, + default_yes ? WORD_YES : WORD_NO, + delim); return prompt; } @@ -4352,10 +4369,11 @@ set_connection_type(NmCli * nmc, } /* ifname is mandatory for all connection types except virtual ones (bond, team, bridge, vlan) */ - if ((strcmp(value, NM_SETTING_BOND_SETTING_NAME) == 0) - || (strcmp(value, NM_SETTING_TEAM_SETTING_NAME) == 0) - || (strcmp(value, NM_SETTING_BRIDGE_SETTING_NAME) == 0) - || (strcmp(value, NM_SETTING_VLAN_SETTING_NAME) == 0)) { + if (NM_IN_STRSET(value, + NM_SETTING_BOND_SETTING_NAME, + NM_SETTING_TEAM_SETTING_NAME, + NM_SETTING_BRIDGE_SETTING_NAME, + NM_SETTING_VLAN_SETTING_NAME)) { disable_options(NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME); } @@ -4386,7 +4404,7 @@ set_connection_iface(NmCli * nmc, { if (value) { /* Special value of '*' means no specific interface name */ - if (strcmp(value, "*") == 0) + if (nm_streq(value, "*")) value = NULL; } @@ -4541,19 +4559,17 @@ set_bluetooth_type(NmCli * nmc, return TRUE; /* 'dun' type requires adding 'gsm' or 'cdma' setting */ - if (!strcmp(value, NM_SETTING_BLUETOOTH_TYPE_DUN) - || !strcmp(value, NM_SETTING_BLUETOOTH_TYPE_DUN "-gsm")) { + if (NM_IN_STRSET(value, NM_SETTING_BLUETOOTH_TYPE_DUN, NM_SETTING_BLUETOOTH_TYPE_DUN "-gsm")) { value = NM_SETTING_BLUETOOTH_TYPE_DUN; setting = nm_meta_setting_info_editor_new_setting( &nm_meta_setting_infos_editor[NM_META_SETTING_TYPE_GSM], NM_META_ACCESSOR_SETTING_INIT_TYPE_CLI); nm_connection_add_setting(con, setting); - } else if (!strcmp(value, NM_SETTING_BLUETOOTH_TYPE_DUN "-cdma")) { + } else if (NM_IN_STRSET(value, NM_SETTING_BLUETOOTH_TYPE_DUN "-cdma")) { value = NM_SETTING_BLUETOOTH_TYPE_DUN; setting = nm_setting_cdma_new(); nm_connection_add_setting(con, setting); - } else if (!strcmp(value, NM_SETTING_BLUETOOTH_TYPE_PANU) - || !strcmp(value, NM_SETTING_BLUETOOTH_TYPE_NAP)) { + } else if (NM_IN_STRSET(value, NM_SETTING_BLUETOOTH_TYPE_PANU, NM_SETTING_BLUETOOTH_TYPE_NAP)) { /* no op */ } else { g_set_error(error, @@ -5605,13 +5621,13 @@ read_properties: g_clear_error(&error); /* Get the arguments from the command line if any */ if (argc && !nmc_process_connection_properties(nmc, connection, &argc, &argv, FALSE, &error)) { - if (g_strcmp0(*argv, "--") == 0 && !seen_dash_dash) { + if (nm_streq0(*argv, "--") && !seen_dash_dash) { /* This is for compatibility with older nmcli that required * options and properties to be separated with "--" */ seen_dash_dash = TRUE; next_arg(nmc, &argc, &argv, NULL); goto read_properties; - } else if (g_strcmp0(*argv, "save") == 0) { + } else if (nm_streq0(*argv, "save")) { /* It would be better if "save" was a separate argument and not * mixed with properties, but there's not much we can do about it now. */ argc--; @@ -5746,6 +5762,9 @@ finish: /*****************************************************************************/ /* Functions for readline TAB completion in editor */ +#if HAVE_EDITLINE_READLINE +#define uuid_display_hook ((void (*)(void)) NULL) +#else static void uuid_display_hook(char **array, int len, int max_len) { @@ -5769,6 +5788,7 @@ uuid_display_hook(char **array, int len, int max_len) rl_display_match_list(array, len, max_len + max + 3); rl_forced_update_display(); } +#endif static char * gen_nmcli_cmds_menu(const char *text, int state) @@ -5990,6 +6010,8 @@ gen_property_names(const char *text, int state) slv_type = NM_SETTING_TEAM_SETTING_NAME; else if (nm_streq0(strv[0], NM_SETTING_BRIDGE_PORT_SETTING_NAME)) slv_type = NM_SETTING_BRIDGE_SETTING_NAME; + else if (nm_streq0(strv[0], NM_SETTING_BOND_PORT_SETTING_NAME)) + slv_type = NM_SETTING_BOND_SETTING_NAME; else slv_type = NULL; valid_settings_slave = nm_meta_setting_info_valid_parts_for_slave_type(slv_type, NULL); @@ -6071,7 +6093,7 @@ _create_vpn_array(const GPtrArray *connections, gboolean uuid) NMConnection *connection = NM_CONNECTION(connections->pdata[c]); const char * type = nm_connection_get_connection_type(connection); - if (g_strcmp0(type, NM_SETTING_VPN_SETTING_NAME) == 0) + if (nm_streq0(type, NM_SETTING_VPN_SETTING_NAME)) array[idx++] = uuid ? nm_connection_get_uuid(connection) : nm_connection_get_id(connection); } @@ -6440,8 +6462,10 @@ gen_property_values(const char *text, int state) return nmc_rl_gen_func_basic(text, state, avals); } +#if !HAVE_EDITLINE_READLINE /* from readline */ extern int rl_complete_with_tilde_expansion; +#endif /* * Attempt to complete on the contents of TEXT. START and END show the @@ -6469,8 +6493,10 @@ nmcli_editor_tab_completion(const char *text, int start, int end) /* Disable default filename completion */ rl_attempted_completion_over = 1; +#if !HAVE_EDITLINE_READLINE /* Enable tilde expansion when filenames are completed */ rl_complete_with_tilde_expansion = 1; +#endif /* Filter out possible ANSI color escape sequences */ prompt_tmp = nmc_filter_out_colors((const char *) rl_prompt); @@ -6479,11 +6505,11 @@ nmcli_editor_tab_completion(const char *text, int start, int end) n1 = strspn(line, " \t"); /* Choose the right generator function */ - if (strcmp(prompt_tmp, EDITOR_PROMPT_CON_TYPE) == 0) + if (nm_streq(prompt_tmp, EDITOR_PROMPT_CON_TYPE)) generator_func = gen_connection_types(text); - else if (strcmp(prompt_tmp, EDITOR_PROMPT_SETTING) == 0) + else if (nm_streq(prompt_tmp, EDITOR_PROMPT_SETTING)) generator_func = gen_setting_names; - else if (strcmp(prompt_tmp, EDITOR_PROMPT_PROPERTY) == 0) + else if (nm_streq(prompt_tmp, EDITOR_PROMPT_PROPERTY)) generator_func = gen_property_names; else if (g_str_has_suffix(rl_prompt, prompt_yes_no(TRUE, NULL)) || g_str_has_suffix(rl_prompt, prompt_yes_no(FALSE, NULL))) @@ -6759,7 +6785,7 @@ parse_editor_main_cmd(const char *cmd, char **cmd_arg) editor_cmd = NMC_EDITOR_MAIN_CMD_ACTIVATE; else if (matches(cmd_arg0, "back")) editor_cmd = NMC_EDITOR_MAIN_CMD_BACK; - else if (matches(cmd_arg0, "help") || strcmp(cmd_arg0, "?") == 0) + else if (matches(cmd_arg0, "help") || nm_streq(cmd_arg0, "?")) editor_cmd = NMC_EDITOR_MAIN_CMD_HELP; else if (matches(cmd_arg0, "quit")) editor_cmd = NMC_EDITOR_MAIN_CMD_QUIT; @@ -6946,7 +6972,7 @@ parse_editor_sub_cmd(const char *cmd, char **cmd_arg) editor_cmd = NMC_EDITOR_SUB_CMD_PRINT; else if (matches(cmd_arg0, "back")) editor_cmd = NMC_EDITOR_SUB_CMD_BACK; - else if (matches(cmd_arg0, "help") || strcmp(cmd_arg0, "?") == 0) + else if (matches(cmd_arg0, "help") || nm_streq(cmd_arg0, "?")) editor_cmd = NMC_EDITOR_SUB_CMD_HELP; else if (matches(cmd_arg0, "quit")) editor_cmd = NMC_EDITOR_SUB_CMD_QUIT; @@ -7356,8 +7382,8 @@ property_edit_submenu(NmCli * nmc, case NMC_EDITOR_SUB_CMD_CHANGE: rl_startup_hook = nmc_rl_set_deftext; - nmc_rl_pre_input_deftext = - nmc_setting_get_property_parsable(curr_setting, prop_name, NULL); + nm_strdup_reset_take(&nmc_rl_pre_input_deftext, + nmc_setting_get_property_parsable(curr_setting, prop_name, NULL)); prop_val_user = nmc_readline(&nmc->nmc_config, _("Edit '%s' value: "), prop_name); if (!nmc_setting_set_property(nmc->client, @@ -8161,12 +8187,12 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty case NMC_EDITOR_MAIN_CMD_VERIFY: /* Verify current setting or the whole connection */ - if (cmd_arg && strcmp(cmd_arg, "all") && strcmp(cmd_arg, "fix")) { + if (cmd_arg && !nm_streq(cmd_arg, "all") && !nm_streq(cmd_arg, "fix")) { g_print(_("Invalid verify option: %s\n"), cmd_arg); break; } - if (menu_ctx.curr_setting && (!cmd_arg || strcmp(cmd_arg, "all") != 0)) { + if (menu_ctx.curr_setting && (!cmd_arg || !nm_streq(cmd_arg, "all"))) { gs_free_error GError *tmp_err = NULL; nm_setting_verify(menu_ctx.curr_setting, NULL, &tmp_err); @@ -8524,7 +8550,7 @@ editor_init_new_connection(NmCli *nmc, NMConnection *connection, const char *sla set_default_interface_name(nmc, s_con); /* Set sensible initial VLAN values */ - if (g_strcmp0(con_type, NM_SETTING_VLAN_SETTING_NAME) == 0) { + if (nm_streq0(con_type, NM_SETTING_VLAN_SETTING_NAME)) { const char *dev_ifname = get_ethernet_device_name(nmc); g_object_set(NM_SETTING_VLAN(base_setting), @@ -9235,10 +9261,11 @@ do_connection_reload(const NMCCommand *cmd, NmCli *nmc, int argc, const char *co static void do_connection_load(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { - GError * error = NULL; - gs_free const char **filenames = NULL; - gs_strfreev char ** failures = NULL; - int i; + GError * error = NULL; + gs_strfreev char **filenames = NULL; + gs_strfreev char **failures = NULL; + gs_free char * current_dir = NULL; + int i; next_arg(nmc, &argc, &argv, NULL); if (argc == 0) { @@ -9252,7 +9279,24 @@ do_connection_load(const NMCCommand *cmd, NmCli *nmc, int argc, const char *cons return; } - filenames = (const char **) nm_utils_strv_dup(argv, argc, FALSE); + filenames = nm_strv_dup(argv, argc, TRUE); + + current_dir = g_get_current_dir(); + if (filenames && current_dir && current_dir[0] == '/' && current_dir[1] != '/') { + for (i = 0; filenames[i]; i++) { + char *f = filenames[i]; + + if (f[0] == '\0' || f[0] == '/') + continue; + + /* Don't use g_canonicalize_filename(), because we want to keep + * the argv argument closely to what the user provided. We will get + * that path back as "failures" below, so don't perform additional + * normalization except prepending the $PWD. */ + filenames[i] = g_build_filename(current_dir, f, NULL); + g_free(f); + } + } nm_client_load_connections(nmc->client, (char **) filenames, &failures, NULL, &error); if (error) { @@ -9311,7 +9355,7 @@ do_connection_import(const NMCCommand *cmd, NmCli *nmc, int argc, const char *co nmc_complete_strings(*argv, type ? NULL : "type", filename ? NULL : "file"); } - if (strcmp(*argv, "type") == 0) { + if (nm_streq(*argv, "type")) { argc--; argv++; if (!argc) { @@ -9333,7 +9377,7 @@ do_connection_import(const NMCCommand *cmd, NmCli *nmc, int argc, const char *co else g_printerr(_("Warning: 'type' already specified, ignoring extra one.\n")); - } else if (strcmp(*argv, "file") == 0) { + } else if (nm_streq(*argv, "file")) { argc--; argv++; if (!argc) { @@ -9465,7 +9509,7 @@ do_connection_export(const NMCCommand *cmd, NmCli *nmc, int argc, const char *co } type = nm_connection_get_connection_type(connection); - if (g_strcmp0(type, NM_SETTING_VPN_SETTING_NAME) != 0) { + if (!nm_streq0(type, NM_SETTING_VPN_SETTING_NAME)) { g_string_printf(nmc->return_text, _("Error: the connection is not VPN.")); nmc->return_value = NMC_RESULT_ERROR_USER_INPUT; goto finish; @@ -9587,7 +9631,7 @@ nmcli_con_tab_completion(const char *text, int start, int end) /* Disable readline's default filename completion */ rl_attempted_completion_over = 1; - if (g_strcmp0(rl_prompt, PROMPT_CONNECTION) == 0) { + if (nm_streq0(rl_prompt, PROMPT_CONNECTION)) { /* Disable appending space after completion */ rl_completion_append_character = '\0'; @@ -9595,18 +9639,20 @@ nmcli_con_tab_completion(const char *text, int start, int end) return NULL; generator_func = gen_func_connection_names; - } else if (g_strcmp0(rl_prompt, PROMPT_CONNECTIONS) == 0) { + } else if (nm_streq0(rl_prompt, PROMPT_CONNECTIONS)) { generator_func = gen_func_connection_names; - } else if (g_strcmp0(rl_prompt, PROMPT_ACTIVE_CONNECTIONS) == 0) { + } else if (nm_streq0(rl_prompt, PROMPT_ACTIVE_CONNECTIONS)) { generator_func = gen_func_active_connection_names; } else if (rl_prompt && g_str_has_prefix(rl_prompt, NM_META_TEXT_PROMPT_VPN_TYPE)) { info = (const NMMetaAbstractInfo *) nm_meta_property_info_vpn_service_type; nmc_tab_completion.words = _meta_abstract_complete(info, text); generator_func = _meta_abstract_generator; - } else if (g_strcmp0(rl_prompt, PROMPT_IMPORT_FILE) == 0) { - rl_attempted_completion_over = 0; + } else if (nm_streq0(rl_prompt, PROMPT_IMPORT_FILE)) { + rl_attempted_completion_over = 0; +#if !HAVE_EDITLINE_READLINE rl_complete_with_tilde_expansion = 1; - } else if (g_strcmp0(rl_prompt, PROMPT_VPN_CONNECTION) == 0) { +#endif + } else if (nm_streq0(rl_prompt, PROMPT_VPN_CONNECTION)) { generator_func = gen_vpn_ids; } diff --git a/src/nmcli/devices.c b/src/nmcli/devices.c index 0cb347f5..d2e472a0 100644 --- a/src/nmcli/devices.c +++ b/src/nmcli/devices.c @@ -9,7 +9,11 @@ #include #include +#if HAVE_EDITLINE_READLINE +#include +#else #include +#endif #include #include "libnm-glib-aux/nm-secret-utils.h" @@ -2539,7 +2543,7 @@ do_device_modify(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *info = (ModifyInfo){ .nmc = nmc, .argc = argc, - .argv = nm_utils_strv_dup(argv, argc, TRUE), + .argv = nm_strv_dup(argv, argc, TRUE), }; nm_device_get_applied_connection_async(device, 0, NULL, modify_get_applied_cb, info); @@ -5020,17 +5024,19 @@ void nmc_command_func_device(const NMCCommand *cmd, NmCli *nmc, int argc, const char *const *argv) { static const NMCCommand cmds[] = { - {"status", do_devices_status, usage_device_status, TRUE, TRUE}, - {"show", do_device_show, usage_device_show, TRUE, TRUE}, {"connect", do_device_connect, usage_device_connect, TRUE, TRUE}, - {"reapply", do_device_reapply, usage_device_reapply, TRUE, TRUE}, {"disconnect", do_devices_disconnect, usage_device_disconnect, TRUE, TRUE}, {"delete", do_devices_delete, usage_device_delete, TRUE, TRUE}, - {"set", do_device_set, usage_device_set, TRUE, TRUE}, - {"monitor", do_devices_monitor, usage_device_monitor, TRUE, TRUE}, - {"wifi", do_device_wifi, usage_device_wifi, FALSE, FALSE}, + {"down", do_devices_disconnect, usage_device_disconnect, TRUE, TRUE}, {"lldp", do_device_lldp, usage_device_lldp, FALSE, FALSE}, + {"monitor", do_devices_monitor, usage_device_monitor, TRUE, TRUE}, {"modify", do_device_modify, usage_device_modify, TRUE, TRUE}, + {"reapply", do_device_reapply, usage_device_reapply, TRUE, TRUE}, + {"status", do_devices_status, usage_device_status, TRUE, TRUE}, + {"set", do_device_set, usage_device_set, TRUE, TRUE}, + {"show", do_device_show, usage_device_show, TRUE, TRUE}, + {"up", do_device_connect, usage_device_connect, TRUE, TRUE}, + {"wifi", do_device_wifi, usage_device_wifi, FALSE, FALSE}, {NULL, do_devices_status, usage, TRUE, TRUE}, }; diff --git a/src/nmcli/general.c b/src/nmcli/general.c index 225d3d8a..d87df17a 100644 --- a/src/nmcli/general.c +++ b/src/nmcli/general.c @@ -7,10 +7,10 @@ #include -#include "libnm-core-aux-intern/nm-common-macros.h" - #include "libnm-glib-aux/nm-dbus-aux.h" #include "libnmc-base/nm-client-utils.h" +#include "libnm-core-aux-extern/nm-libnm-core-aux.h" +#include "libnm-glib-aux/nm-str-buf.h" #include "polkit-agent.h" #include "utils.h" @@ -1392,8 +1392,9 @@ device_overview(NmCli *nmc, NMDevice *device) static void ac_overview(NmCli *nmc, NMActiveConnection *ac) { - GString * outbuf = g_string_sized_new(80); - NMIPConfig *ip; + GString * outbuf = g_string_sized_new(80); + NMIPConfig * ip; + nm_auto_str_buf NMStrBuf str = NM_STR_BUF_INIT(NM_UTILS_GET_NEXT_REALLOC_SIZE_104, FALSE); if (nm_active_connection_get_master(ac)) { g_string_append_printf(outbuf, @@ -1426,7 +1427,11 @@ ac_overview(NmCli *nmc, NMActiveConnection *ac) p = nm_ip_config_get_routes(ip); for (i = 0; i < p->len; i++) { NMIPRoute *a = p->pdata[i]; - g_print("\troute4 %s/%d\n", nm_ip_route_get_dest(a), nm_ip_route_get_prefix(a)); + + nm_str_buf_reset(&str); + _nm_ip_route_to_string(a, &str); + + g_print("\troute4 %s\n", nm_str_buf_get_str(&str)); } } @@ -1444,7 +1449,11 @@ ac_overview(NmCli *nmc, NMActiveConnection *ac) p = nm_ip_config_get_routes(ip); for (i = 0; i < p->len; i++) { NMIPRoute *a = p->pdata[i]; - g_print("\troute6 %s/%d\n", nm_ip_route_get_dest(a), nm_ip_route_get_prefix(a)); + + nm_str_buf_reset(&str); + _nm_ip_route_to_string(a, &str); + + g_print("\troute6 %s\n", nm_str_buf_get_str(&str)); } } diff --git a/src/nmcli/generate-docs-nm-settings-nmcli.xml b/src/nmcli/generate-docs-nm-settings-nmcli.xml index ca5225ba..02fd8800 100644 --- a/src/nmcli/generate-docs-nm-settings-nmcli.xml +++ b/src/nmcli/generate-docs-nm-settings-nmcli.xml @@ -227,7 +227,7 @@ + description="Dictionary of key/value pairs of s390-specific device options. Both keys and values must be strings. Allowed keys include "portno", "layer2", "portname", "protocol", among others. Key names must contain only alphanumeric characters (ie, [a-zA-Z0-9]). Currently, NetworkManager itself does nothing with this information. However, s390utils ships a udev rule which parses this information and applies it to the interface." /> + + + + description="Whether or not the connection should be automatically connected by NetworkManager when the resources for the connection are available. TRUE to automatically activate the connection, FALSE to require manual intervention to activate the connection. Autoconnect happens when the circumstances are suitable. That means for example that the device is currently managed and not active. Autoconnect thus never replaces or competes with an already active profile. Note that autoconnect is not implemented for VPN profiles. See "secondaries" as an alternative to automatically connect VPN profiles." /> + description="The autoconnect priority in range -999 to 999. If the connection is set to autoconnect, connections with higher priority will be preferred. The higher number means higher priority. Defaults to 0. Note that this property only matters if there are more than one candidate profile to select for autoconnect. In case of equal priority, the profile used most recently is chosen." /> + + description="The FCoE controller mode; either "fabric" or "vn2vn". Since 1.34, NULL is the default and means "fabric". Before 1.34, NULL was rejected as invalid and the default was "fabric"." /> + description="Dictionary of key/value pairs of s390-specific device options. Both keys and values must be strings. Allowed keys include "portno", "layer2", "portname", "protocol", among others. Key names must contain only alphanumeric characters (ie, [a-zA-Z0-9]). Currently, NetworkManager itself does nothing with this information. However, s390utils ships a udev rule which parses this information and applies it to the interface." /> + + + + description="Whether or not the connection should be automatically connected by NetworkManager when the resources for the connection are available. TRUE to automatically activate the connection, FALSE to require manual intervention to activate the connection. Autoconnect happens when the circumstances are suitable. That means for example that the device is currently managed and not active. Autoconnect thus never replaces or competes with an already active profile. Note that autoconnect is not implemented for VPN profiles. See "secondaries" as an alternative to automatically connect VPN profiles." /> + description="The autoconnect priority in range -999 to 999. If the connection is set to autoconnect, connections with higher priority will be preferred. The higher number means higher priority. Defaults to 0. Note that this property only matters if there are more than one candidate profile to select for autoconnect. In case of equal priority, the profile used most recently is chosen." /> + + description="The FCoE controller mode; either "fabric" or "vn2vn". Since 1.34, NULL is the default and means "fabric". Before 1.34, NULL was rejected as invalid and the default was "fabric"." /> #include #include -#include +#if HAVE_EDITLINE_READLINE +#include +#else #include #include +#endif #include "libnmc-base/nm-client-utils.h" @@ -28,9 +31,9 @@ #include "settings.h" #if defined(NM_DIST_VERSION) - #define NMCLI_VERSION NM_DIST_VERSION +#define NMCLI_VERSION NM_DIST_VERSION #else - #define NMCLI_VERSION VERSION +#define NMCLI_VERSION VERSION #endif #define _NMC_COLOR_PALETTE_INIT() \ diff --git a/src/nmcli/settings.c b/src/nmcli/settings.c index 6c93c021..f4966400 100644 --- a/src/nmcli/settings.c +++ b/src/nmcli/settings.c @@ -362,7 +362,7 @@ _set_fcn_precheck_connection_secondaries(NMClient * client, char ** iter; gboolean modified = FALSE; - strv0 = nm_utils_strsplit_set(value, " \t,"); + strv0 = nm_strsplit_set(value, " \t,"); if (!strv0) return TRUE; diff --git a/src/nmcli/utils.c b/src/nmcli/utils.c index 6dd93f7b..85768c19 100644 --- a/src/nmcli/utils.c +++ b/src/nmcli/utils.c @@ -495,7 +495,7 @@ nmc_string_to_arg_array(const char *line, gs_free const char **arr0 = NULL; char ** arr; - arr0 = nm_utils_strsplit_set(line ?: "", delim ?: " \t"); + arr0 = nm_strsplit_set(line ?: "", delim ?: " \t"); if (!arr0) arr = g_new0(char *, 1); else diff --git a/src/nmtui/meson.build b/src/nmtui/meson.build index fe440175..e6cac268 100644 --- a/src/nmtui/meson.build +++ b/src/nmtui/meson.build @@ -18,6 +18,7 @@ executable( 'nmt-mac-entry.c', 'nmt-mtu-entry.c', 'nmt-page-bond.c', + 'nmt-page-bond-port.c', 'nmt-page-bridge.c', 'nmt-page-bridge-port.c', 'nmt-page-dsl.c', @@ -31,12 +32,15 @@ executable( 'nmt-page-team-port.c', 'nmt-page-vlan.c', 'nmt-page-wifi.c', + 'nmt-page-wireguard.c', 'nmt-password-dialog.c', 'nmt-password-fields.c', 'nmt-route-editor.c', 'nmt-route-entry.c', 'nmt-route-table.c', 'nmt-slave-list.c', + 'nmt-wireguard-peer-list.c', + 'nmt-wireguard-peer-editor.c', 'nmtui.c', 'nmtui-connect.c', 'nmtui-edit.c', diff --git a/src/nmtui/nm-editor-bindings.c b/src/nmtui/nm-editor-bindings.c index 2b1c4748..59474fba 100644 --- a/src/nmtui/nm-editor-bindings.c +++ b/src/nmtui/nm-editor-bindings.c @@ -576,6 +576,229 @@ nm_editor_bind_ip_route_to_strings(int addr_family, NULL); } +gboolean +peer_transform_to_public_key_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data) +{ + NMWireGuardPeer *peer; + char * string; + + peer = g_value_get_boxed(source_value); + if (peer && nm_wireguard_peer_get_public_key(peer)) { + string = g_strdup(nm_wireguard_peer_get_public_key(peer)); + g_value_take_string(target_value, string); + } else + g_value_set_string(target_value, ""); + return TRUE; +} + +gboolean +peer_transform_to_allowed_ips_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data) +{ + NMWireGuardPeer *peer; + GString * string = NULL; + guint i, len; + + peer = g_value_get_boxed(source_value); + if (!peer) + return TRUE; + + len = nm_wireguard_peer_get_allowed_ips_len(peer); + for (i = 0; i < len; i++) { + if (!string) + string = g_string_new(""); + else + g_string_append_c(string, ','); + g_string_append(string, nm_wireguard_peer_get_allowed_ip(peer, i, NULL)); + } + if (string) + g_value_take_string(target_value, g_string_free(string, FALSE)); + + return TRUE; +} + +gboolean +peer_transform_to_endpoint_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data) +{ + NMWireGuardPeer *peer; + char * string; + + peer = g_value_get_boxed(source_value); + if (peer && nm_wireguard_peer_get_endpoint(peer)) { + string = g_strdup_printf("%s", nm_wireguard_peer_get_endpoint(peer)); + g_value_take_string(target_value, string); + } else + g_value_set_string(target_value, ""); + return TRUE; +} + +gboolean +peer_transform_to_preshared_key_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data) +{ + NMWireGuardPeer *peer; + char * string; + + peer = g_value_get_boxed(source_value); + if (peer && nm_wireguard_peer_get_preshared_key(peer)) { + string = g_strdup_printf("%s", nm_wireguard_peer_get_preshared_key(peer)); + g_value_take_string(target_value, string); + } else + g_value_set_string(target_value, ""); + return TRUE; +} + +gboolean +peer_transform_to_persistent_keepalive_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data) +{ + NMWireGuardPeer *peer; + char * string; + + peer = g_value_get_boxed(source_value); + if (peer && nm_wireguard_peer_get_persistent_keepalive(peer)) { + string = g_strdup_printf("%d", nm_wireguard_peer_get_persistent_keepalive(peer)); + g_value_take_string(target_value, string); + } else + g_value_set_string(target_value, ""); + return TRUE; +} + +gboolean +peer_transform_from_public_key_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data) +{ + NMWireGuardPeer *peer; + const char * text; + + text = g_value_get_string(source_value); + + /* Fetch the original property value */ + g_object_get(g_binding_get_source(binding), + g_binding_get_source_property(binding), + &peer, + NULL); + + nm_wireguard_peer_set_public_key(peer, text, TRUE); + + g_value_take_boxed(target_value, peer); + return TRUE; +} + +gboolean +peer_transform_from_allowed_ips_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data) +{ + NMWireGuardPeer *peer; + const char * text; + char ** strv; + guint i; + + text = g_value_get_string(source_value); + + /* Fetch the original property value */ + g_object_get(g_binding_get_source(binding), + g_binding_get_source_property(binding), + &peer, + NULL); + + nm_wireguard_peer_clear_allowed_ips(peer); + + strv = g_strsplit(text, ",", -1); + for (i = 0; strv && strv[i]; i++) + nm_wireguard_peer_append_allowed_ip(peer, g_strstrip(strv[i]), TRUE); + g_strfreev(strv); + + g_value_take_boxed(target_value, peer); + return TRUE; +} + +gboolean +peer_transform_from_endpoint_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data) +{ + NMWireGuardPeer *peer; + const char * text; + + text = g_value_get_string(source_value); + + /* Fetch the original property value */ + g_object_get(g_binding_get_source(binding), + g_binding_get_source_property(binding), + &peer, + NULL); + + nm_wireguard_peer_set_endpoint(peer, text, TRUE); + + g_value_take_boxed(target_value, peer); + return TRUE; +} + +gboolean +peer_transform_from_preshared_key_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data) +{ + NMWireGuardPeer *peer; + const char * text; + + text = g_value_get_string(source_value); + + /* Fetch the original property value */ + g_object_get(g_binding_get_source(binding), + g_binding_get_source_property(binding), + &peer, + NULL); + + nm_wireguard_peer_set_preshared_key(peer, text && text[0] ? text : NULL, TRUE); + nm_wireguard_peer_set_preshared_key_flags(peer, NM_SETTING_SECRET_FLAG_NONE); + + g_value_take_boxed(target_value, peer); + return TRUE; +} + +gboolean +peer_transform_from_persistent_keepalive_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data) +{ + NMWireGuardPeer *peer; + const char * text; + + text = g_value_get_string(source_value); + + /* Fetch the original property value */ + g_object_get(g_binding_get_source(binding), + g_binding_get_source_property(binding), + &peer, + NULL); + + nm_wireguard_peer_set_persistent_keepalive(peer, atoi(text)); + + g_value_take_boxed(target_value, peer); + return TRUE; +} + /* Wireless security method binding */ typedef struct { NMConnection * connection; diff --git a/src/nmtui/nm-editor-bindings.h b/src/nmtui/nm-editor-bindings.h index 027a59a9..a9bf51ed 100644 --- a/src/nmtui/nm-editor-bindings.h +++ b/src/nmtui/nm-editor-bindings.h @@ -53,4 +53,54 @@ void nm_editor_bind_wireless_security_wep_key(NMSettingWirelessSecurity *s_wsec, void nm_editor_bind_vlan_name(NMSettingVlan *s_vlan, NMSettingConnection *s_con); +gboolean peer_transform_to_public_key_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data); + +gboolean peer_transform_to_allowed_ips_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data); + +gboolean peer_transform_to_endpoint_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data); + +gboolean peer_transform_to_preshared_key_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data); + +gboolean peer_transform_to_persistent_keepalive_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data); + +gboolean peer_transform_from_public_key_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data); + +gboolean peer_transform_from_allowed_ips_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data); + +gboolean peer_transform_from_endpoint_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data); + +gboolean peer_transform_from_preshared_key_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data); + +gboolean peer_transform_from_persistent_keepalive_string(GBinding * binding, + const GValue *source_value, + GValue * target_value, + gpointer user_data); + #endif /* NM_EDITOR_BINDINGS_H */ diff --git a/src/nmtui/nm-editor-utils.c b/src/nmtui/nm-editor-utils.c index c6b03bd8..2b6acbbe 100644 --- a/src/nmtui/nm-editor-utils.c +++ b/src/nmtui/nm-editor-utils.c @@ -16,7 +16,7 @@ #include "nm-editor-utils.h" #if 0 - #include "libnmc-base/nm-vpn-helpers.h" +#include "libnmc-base/nm-vpn-helpers.h" static GSList *vpn_plugins; @@ -66,6 +66,22 @@ bond_connection_setup_func(NMConnection *connection, NMSettingConnection *s_con, } } +static void +wireguard_connection_setup_func(NMConnection * connection, + NMSettingConnection *s_con, + NMSetting * s_hw) +{ + NMSettingIPConfig *s_ip; + + s_ip = (NMSettingIPConfig *) nm_setting_ip4_config_new(); + g_object_set(s_ip, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_DISABLED, NULL); + nm_connection_add_setting(connection, (NMSetting *) s_ip); + + s_ip = (NMSettingIPConfig *) nm_setting_ip6_config_new(); + g_object_set(s_ip, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_DISABLED, NULL); + nm_connection_add_setting(connection, (NMSetting *) s_ip); +} + typedef void (*NMEditorNewConnectionSetupFunc)(NMConnection * connection, NMSettingConnection *s_con, NMSetting * s_hw); @@ -243,6 +259,15 @@ nm_editor_utils_get_connection_type_list(void) } #endif + item = g_new0(NMEditorConnectionTypeDataReal, 1); + item->data.name = _("WireGuard"); + item->data.setting_type = NM_TYPE_SETTING_WIREGUARD; + item->data.device_type = NM_TYPE_DEVICE_WIREGUARD; + item->data.virtual = TRUE; + item->id_format = _("WireGuard connection %d"); + item->connection_setup_func = wireguard_connection_setup_func; + g_ptr_array_add(array, item); + g_ptr_array_sort(array, sort_types); g_ptr_array_add(array, NULL); diff --git a/src/nmtui/nmt-connect-connection-list.c b/src/nmtui/nmt-connect-connection-list.c index 4503dc92..486e1400 100644 --- a/src/nmtui/nmt-connect-connection-list.c +++ b/src/nmtui/nmt-connect-connection-list.c @@ -100,6 +100,7 @@ static const char *device_sort_order[] = {"NMDeviceEthernet", NM_SETTING_TEAM_SETTING_NAME, NM_SETTING_BRIDGE_SETTING_NAME, NM_SETTING_IP_TUNNEL_SETTING_NAME, + NM_SETTING_WIREGUARD_SETTING_NAME, "NMDeviceModem", "NMDeviceBt"}; static const int device_sort_order_len = G_N_ELEMENTS(device_sort_order); diff --git a/src/nmtui/nmt-editor.c b/src/nmtui/nmt-editor.c index 0ef23693..94e9b7a8 100644 --- a/src/nmtui/nmt-editor.c +++ b/src/nmtui/nmt-editor.c @@ -26,6 +26,7 @@ #include "nmt-mtu-entry.h" #include "nmt-page-bond.h" +#include "nmt-page-bond-port.h" #include "nmt-page-bridge.h" #include "nmt-page-bridge-port.h" #include "nmt-page-dsl.h" @@ -39,6 +40,7 @@ #include "nmt-page-team-port.h" #include "nmt-page-vlan.h" #include "nmt-page-wifi.h" +#include "nmt-page-wireguard.h" #include "libnmc-setting/nm-meta-setting-access.h" @@ -372,6 +374,8 @@ nmt_editor_constructed(GObject *object) page = nmt_page_wifi_new(priv->edit_connection, deventry); else if (nm_connection_is_type(priv->edit_connection, NM_SETTING_IP_TUNNEL_SETTING_NAME)) page = nmt_page_ip_tunnel_new(priv->edit_connection, deventry); + else if (nm_connection_is_type(priv->edit_connection, NM_SETTING_WIREGUARD_SETTING_NAME)) + page = nmt_page_wireguard_new(priv->edit_connection, deventry); else g_assert_not_reached(); @@ -384,6 +388,8 @@ nmt_editor_constructed(GObject *object) add_sections_for_page(editor, grid, nmt_page_bridge_port_new(priv->edit_connection)); else if (!strcmp(slave_type, NM_SETTING_TEAM_SETTING_NAME)) add_sections_for_page(editor, grid, nmt_page_team_port_new(priv->edit_connection)); + else if (nm_streq(slave_type, NM_SETTING_BOND_SETTING_NAME)) + add_sections_for_page(editor, grid, nmt_page_bond_port_new(priv->edit_connection)); } else { NmtNewtWidget *section; diff --git a/src/nmtui/nmt-editor.h b/src/nmtui/nmt-editor.h index 49fe89d3..602a61ae 100644 --- a/src/nmtui/nmt-editor.h +++ b/src/nmtui/nmt-editor.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * Copyright (C) 2013 Red Hat, Inc. */ diff --git a/src/nmtui/nmt-page-bond-port.c b/src/nmtui/nmt-page-bond-port.c new file mode 100644 index 00000000..156553c2 --- /dev/null +++ b/src/nmtui/nmt-page-bond-port.c @@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021 Red Hat, Inc. + */ + +/** + * SECTION:nmt-page-bond-port + * @short_description: The editor page for Bond ports + */ + +#include "libnm-client-aux-extern/nm-default-client.h" + +#include "nmt-page-bond-port.h" + +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" + +G_DEFINE_TYPE(NmtPageBondPort, nmt_page_bond_port, NMT_TYPE_EDITOR_PAGE) + +static void +nmt_page_bond_port_init(NmtPageBondPort *bond) +{} + +NmtEditorPage * +nmt_page_bond_port_new(NMConnection *conn) +{ + return g_object_new(NMT_TYPE_PAGE_BOND_PORT, "connection", conn, NULL); +} + +static void +nmt_page_bond_port_constructed(GObject *object) +{ + NmtPageBondPort * bond = NMT_PAGE_BOND_PORT(object); + NmtEditorSection * section; + NmtEditorGrid * grid; + NMSettingBondPort *s_port; + NmtNewtWidget * widget; + NMConnection * conn; + + conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(bond)); + s_port = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_BOND_PORT); + + section = nmt_editor_section_new(_("BOND PORT"), NULL, TRUE); + grid = nmt_editor_section_get_body(section); + + widget = nmt_newt_entry_numeric_new(10, 0, 63); + g_object_bind_property(s_port, + NM_SETTING_BOND_PORT_QUEUE_ID, + widget, + "text", + G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); + nmt_editor_grid_append(grid, _("Queue ID"), widget, NULL); + + nmt_editor_page_add_section(NMT_EDITOR_PAGE(bond), section); + + G_OBJECT_CLASS(nmt_page_bond_port_parent_class)->constructed(object); +} + +static void +nmt_page_bond_port_class_init(NmtPageBondPortClass *bond_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS(bond_class); + + object_class->constructed = nmt_page_bond_port_constructed; +} diff --git a/src/nmtui/nmt-page-bond-port.h b/src/nmtui/nmt-page-bond-port.h new file mode 100644 index 00000000..387acf4c --- /dev/null +++ b/src/nmtui/nmt-page-bond-port.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021 Red Hat, Inc. + */ + +#ifndef NMT_PAGE_BOND_PORT_H +#define NMT_PAGE_BOND_PORT_H + +#include "nmt-editor-page-device.h" + +#define NMT_TYPE_PAGE_BOND_PORT (nmt_page_bond_port_get_type()) +#define NMT_PAGE_BOND_PORT(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), NMT_TYPE_PAGE_BOND_PORT, NmtPageBondPort)) +#define NMT_PAGE_BOND_PORT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), NMT_TYPE_PAGE_BOND_PORT, NmtPageBondPortClass)) +#define NMT_IS_PAGE_BOND_PORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NMT_TYPE_PAGE_BOND_PORT)) +#define NMT_IS_PAGE_BOND_PORT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), NMT_TYPE_PAGE_BOND_PORT)) +#define NMT_PAGE_BOND_PORT_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), NMT_TYPE_PAGE_BOND_PORT, NmtPageBondPortClass)) + +typedef struct { + NmtEditorPage parent; + +} NmtPageBondPort; + +typedef struct { + NmtEditorPageClass parent; + +} NmtPageBondPortClass; + +GType nmt_page_bond_port_get_type(void); + +NmtEditorPage *nmt_page_bond_port_new(NMConnection *conn); + +#endif /* NMT_PAGE_BOND_PORT_H */ diff --git a/src/nmtui/nmt-page-bond.c b/src/nmtui/nmt-page-bond.c index d3fab1ff..aea7949e 100644 --- a/src/nmtui/nmt-page-bond.c +++ b/src/nmtui/nmt-page-bond.c @@ -334,20 +334,11 @@ nmt_page_bond_constructed(GObject *object) NmtNewtWidget * widget, *label; NMConnection * conn; - conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(bond)); - s_bond = nm_connection_get_setting_bond(conn); - if (!s_bond) { - nm_connection_add_setting(conn, nm_setting_bond_new()); - s_bond = nm_connection_get_setting_bond(conn); - } + conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(bond)); + s_bond = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_BOND); priv->s_bond = s_bond; - s_wired = nm_connection_get_setting_wired(conn); - if (!s_wired) { - nm_connection_add_setting(conn, nm_setting_wired_new()); - s_wired = nm_connection_get_setting_wired(conn); - } - + s_wired = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_WIRED); section = nmt_editor_section_new(_("BOND"), NULL, TRUE); grid = nmt_editor_section_get_body(section); diff --git a/src/nmtui/nmt-page-bridge-port.c b/src/nmtui/nmt-page-bridge-port.c index 30163d15..f6c18d7c 100644 --- a/src/nmtui/nmt-page-bridge-port.c +++ b/src/nmtui/nmt-page-bridge-port.c @@ -12,6 +12,8 @@ #include "nmt-page-bridge-port.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" + G_DEFINE_TYPE(NmtPageBridgePort, nmt_page_bridge_port, NMT_TYPE_EDITOR_PAGE) NmtEditorPage * @@ -35,11 +37,7 @@ nmt_page_bridge_port_constructed(GObject *object) NMConnection * conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(bridge)); - s_port = nm_connection_get_setting_bridge_port(conn); - if (!s_port) { - nm_connection_add_setting(conn, nm_setting_bridge_port_new()); - s_port = nm_connection_get_setting_bridge_port(conn); - } + s_port = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_BRIDGE_PORT); section = nmt_editor_section_new(_("BRIDGE PORT"), NULL, TRUE); grid = nmt_editor_section_get_body(section); diff --git a/src/nmtui/nmt-page-bridge.c b/src/nmtui/nmt-page-bridge.c index 52af8db1..684b17bd 100644 --- a/src/nmtui/nmt-page-bridge.c +++ b/src/nmtui/nmt-page-bridge.c @@ -12,6 +12,7 @@ #include "nmt-page-bridge.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "nmt-address-list.h" #include "nmt-slave-list.h" @@ -53,11 +54,7 @@ nmt_page_bridge_constructed(GObject *object) NMConnection * conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(bridge)); - s_bridge = nm_connection_get_setting_bridge(conn); - if (!s_bridge) { - nm_connection_add_setting(conn, nm_setting_bridge_new()); - s_bridge = nm_connection_get_setting_bridge(conn); - } + s_bridge = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_BRIDGE); section = nmt_editor_section_new(_("BRIDGE"), NULL, TRUE); grid = nmt_editor_section_get_body(section); diff --git a/src/nmtui/nmt-page-dsl.c b/src/nmtui/nmt-page-dsl.c index d7e0d144..a0d8cdf4 100644 --- a/src/nmtui/nmt-page-dsl.c +++ b/src/nmtui/nmt-page-dsl.c @@ -11,6 +11,8 @@ #include "libnm-client-aux-extern/nm-default-client.h" #include "nmt-page-dsl.h" + +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "nmt-page-ethernet.h" #include "nmt-page-ppp.h" #include "nmt-password-fields.h" @@ -83,11 +85,7 @@ nmt_page_dsl_constructed(GObject *object) const GSList * sections, *iter; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(dsl)); - s_pppoe = nm_connection_get_setting_pppoe(conn); - if (!s_pppoe) { - nm_connection_add_setting(conn, nm_setting_pppoe_new()); - s_pppoe = nm_connection_get_setting_pppoe(conn); - } + s_pppoe = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_PPPOE); section = build_dsl_section(dsl, s_pppoe); nmt_editor_page_add_section(NMT_EDITOR_PAGE(dsl), section); diff --git a/src/nmtui/nmt-page-ethernet.c b/src/nmtui/nmt-page-ethernet.c index f5dc9119..addbd3f3 100644 --- a/src/nmtui/nmt-page-ethernet.c +++ b/src/nmtui/nmt-page-ethernet.c @@ -15,6 +15,7 @@ #include #include +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "nmt-mac-entry.h" #include "nmt-mtu-entry.h" @@ -42,11 +43,7 @@ nmt_page_ethernet_constructed(GObject *object) NMConnection * conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(ethernet)); - s_wired = nm_connection_get_setting_wired(conn); - if (!s_wired) { - nm_connection_add_setting(conn, nm_setting_wired_new()); - s_wired = nm_connection_get_setting_wired(conn); - } + s_wired = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_WIRED); deventry = nmt_editor_page_device_get_device_entry(NMT_EDITOR_PAGE_DEVICE(object)); g_object_bind_property(s_wired, diff --git a/src/nmtui/nmt-page-infiniband.c b/src/nmtui/nmt-page-infiniband.c index c0e3611b..1216208f 100644 --- a/src/nmtui/nmt-page-infiniband.c +++ b/src/nmtui/nmt-page-infiniband.c @@ -11,6 +11,8 @@ #include "libnm-client-aux-extern/nm-default-client.h" #include "nmt-page-infiniband.h" + +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "nmt-mtu-entry.h" G_DEFINE_TYPE(NmtPageInfiniband, nmt_page_infiniband, NMT_TYPE_EDITOR_PAGE_DEVICE) @@ -46,11 +48,7 @@ nmt_page_infiniband_constructed(GObject *object) NMConnection * conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(infiniband)); - s_ib = nm_connection_get_setting_infiniband(conn); - if (!s_ib) { - nm_connection_add_setting(conn, nm_setting_infiniband_new()); - s_ib = nm_connection_get_setting_infiniband(conn); - } + s_ib = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_INFINIBAND); /* initialize 'transport-mode' if it is NULL */ if (!nm_setting_infiniband_get_transport_mode(s_ib)) { g_object_set(G_OBJECT(s_ib), NM_SETTING_INFINIBAND_TRANSPORT_MODE, "datagram", NULL); diff --git a/src/nmtui/nmt-page-ip-tunnel.c b/src/nmtui/nmt-page-ip-tunnel.c index da6d12b9..96864919 100644 --- a/src/nmtui/nmt-page-ip-tunnel.c +++ b/src/nmtui/nmt-page-ip-tunnel.c @@ -11,6 +11,7 @@ #include "nmt-page-ip-tunnel.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "nmt-device-entry.h" #include "nmt-mtu-entry.h" @@ -102,11 +103,7 @@ nmt_page_ip_tunnel_constructed(GObject *object) GClosure * s2w, *w2s; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(ip_tunnel)); - s_ip_tunnel = nm_connection_get_setting_ip_tunnel(conn); - if (!s_ip_tunnel) { - nm_connection_add_setting(conn, nm_setting_ip_tunnel_new()); - s_ip_tunnel = nm_connection_get_setting_ip_tunnel(conn); - } + s_ip_tunnel = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_IP_TUNNEL); /* Initialize the mode for new connections */ if (nm_setting_ip_tunnel_get_mode(s_ip_tunnel) == NM_IP_TUNNEL_MODE_UNKNOWN) { diff --git a/src/nmtui/nmt-page-ip4.c b/src/nmtui/nmt-page-ip4.c index ecd71447..a7e4bdae 100644 --- a/src/nmtui/nmt-page-ip4.c +++ b/src/nmtui/nmt-page-ip4.c @@ -10,9 +10,11 @@ #include "libnm-client-aux-extern/nm-default-client.h" +#include "nmt-page-ip4.h" + #include -#include "nmt-page-ip4.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "nmt-ip-entry.h" #include "nmt-address-list.h" #include "nmt-route-editor.h" @@ -84,14 +86,13 @@ nmt_page_ip4_constructed(GObject *object) NMConnection * conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(ip4)); - s_ip4 = nm_connection_get_setting_ip4_config(conn); - if (!s_ip4) { - s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); + s_ip4 = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_IP4_CONFIG); + /* initialize 'method' to auto if it is NULL */ + if (!nm_setting_ip_config_get_method(s_ip4)) { g_object_set(G_OBJECT(s_ip4), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - nm_connection_add_setting(conn, (NMSetting *) s_ip4); } widget = nmt_newt_popup_new(ip4methods); diff --git a/src/nmtui/nmt-page-ip6.c b/src/nmtui/nmt-page-ip6.c index f79c553d..0d4de65a 100644 --- a/src/nmtui/nmt-page-ip6.c +++ b/src/nmtui/nmt-page-ip6.c @@ -10,9 +10,11 @@ #include "libnm-client-aux-extern/nm-default-client.h" +#include "nmt-page-ip6.h" + #include -#include "nmt-page-ip6.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "nmt-ip-entry.h" #include "nmt-address-list.h" #include "nmt-route-editor.h" @@ -85,14 +87,13 @@ nmt_page_ip6_constructed(GObject *object) NMConnection * conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(ip6)); - s_ip6 = nm_connection_get_setting_ip6_config(conn); - if (!s_ip6) { - s_ip6 = (NMSettingIPConfig *) nm_setting_ip6_config_new(); + s_ip6 = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_IP6_CONFIG); + /* initialize 'method' to auto if it is NULL */ + if (!nm_setting_ip_config_get_method(s_ip6)) { g_object_set(G_OBJECT(s_ip6), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); - nm_connection_add_setting(conn, (NMSetting *) s_ip6); } widget = nmt_newt_popup_new(ip6methods); diff --git a/src/nmtui/nmt-page-team-port.c b/src/nmtui/nmt-page-team-port.c index 13bb84f0..c1f3cbc6 100644 --- a/src/nmtui/nmt-page-team-port.c +++ b/src/nmtui/nmt-page-team-port.c @@ -12,6 +12,8 @@ #include "nmt-page-team-port.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" + G_DEFINE_TYPE(NmtPageTeamPort, nmt_page_team_port, NMT_TYPE_EDITOR_PAGE) #define NMT_PAGE_TEAM_PORT_GET_PRIVATE(o) \ @@ -63,12 +65,8 @@ nmt_page_team_port_constructed(GObject *object) NmtNewtWidget * widget; NMConnection * conn; - conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(team)); - s_port = nm_connection_get_setting_team_port(conn); - if (!s_port) { - nm_connection_add_setting(conn, nm_setting_team_port_new()); - s_port = nm_connection_get_setting_team_port(conn); - } + conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(team)); + s_port = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_TEAM_PORT); priv->s_port = s_port; section = nmt_editor_section_new(_("TEAM PORT"), NULL, TRUE); diff --git a/src/nmtui/nmt-page-team.c b/src/nmtui/nmt-page-team.c index 3cda1257..d61c06c5 100644 --- a/src/nmtui/nmt-page-team.c +++ b/src/nmtui/nmt-page-team.c @@ -12,6 +12,7 @@ #include "nmt-page-team.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "nmt-slave-list.h" G_DEFINE_TYPE(NmtPageTeam, nmt_page_team, NMT_TYPE_EDITOR_PAGE_DEVICE) @@ -111,12 +112,8 @@ nmt_page_team_constructed(GObject *object) NmtNewtWidget * widget; NMConnection * conn; - conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(team)); - s_team = nm_connection_get_setting_team(conn); - if (!s_team) { - nm_connection_add_setting(conn, nm_setting_team_new()); - s_team = nm_connection_get_setting_team(conn); - } + conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(team)); + s_team = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_TEAM); priv->s_team = s_team; section = nmt_editor_section_new(_("TEAM"), NULL, TRUE); diff --git a/src/nmtui/nmt-page-vlan.c b/src/nmtui/nmt-page-vlan.c index 299a7267..5baf9756 100644 --- a/src/nmtui/nmt-page-vlan.c +++ b/src/nmtui/nmt-page-vlan.c @@ -10,11 +10,12 @@ #include "libnm-client-aux-extern/nm-default-client.h" -#include "nm-editor-bindings.h" +#include "nmt-page-vlan.h" #include -#include "nmt-page-vlan.h" +#include "nm-editor-bindings.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "nmt-device-entry.h" #include "nmt-mac-entry.h" #include "nmt-mtu-entry.h" @@ -49,17 +50,9 @@ nmt_page_vlan_constructed(GObject *object) NmtNewtWidget * widget, *parent, *id_entry; NMConnection * conn; - conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(vlan)); - s_vlan = nm_connection_get_setting_vlan(conn); - if (!s_vlan) { - nm_connection_add_setting(conn, nm_setting_vlan_new()); - s_vlan = nm_connection_get_setting_vlan(conn); - } - s_wired = nm_connection_get_setting_wired(conn); - if (!s_wired) { - nm_connection_add_setting(conn, nm_setting_wired_new()); - s_wired = nm_connection_get_setting_wired(conn); - } + conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(vlan)); + s_vlan = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_VLAN); + s_wired = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_WIRED); section = nmt_editor_section_new(_("VLAN"), NULL, TRUE); grid = nmt_editor_section_get_body(section); diff --git a/src/nmtui/nmt-page-wifi.c b/src/nmtui/nmt-page-wifi.c index 247a0e4e..1a476b02 100644 --- a/src/nmtui/nmt-page-wifi.c +++ b/src/nmtui/nmt-page-wifi.c @@ -14,10 +14,12 @@ #include "libnm-client-aux-extern/nm-default-client.h" +#include "nmt-page-wifi.h" + #include #include -#include "nmt-page-wifi.h" +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "nmt-mac-entry.h" #include "nmt-mtu-entry.h" #include "nmt-password-fields.h" @@ -164,13 +166,8 @@ nmt_page_wifi_constructed(GObject *object) NMConnection * conn; conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(wifi)); - s_wireless = nm_connection_get_setting_wireless(conn); - if (!s_wireless) { - nm_connection_add_setting(conn, nm_setting_wireless_new()); - s_wireless = nm_connection_get_setting_wireless(conn); - } - - s_wsec = nm_connection_get_setting_wireless_security(conn); + s_wireless = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_WIRELESS); + s_wsec = nm_connection_get_setting_wireless_security(conn); if (!s_wsec) { /* It makes things simpler if we always have a * NMSettingWirelessSecurity; we'll hold a ref on one, and add diff --git a/src/nmtui/nmt-page-wireguard.c b/src/nmtui/nmt-page-wireguard.c new file mode 100644 index 00000000..30a984e0 --- /dev/null +++ b/src/nmtui/nmt-page-wireguard.c @@ -0,0 +1,121 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2021 Red Hat, Inc. + */ +/** + * SECTION:nmt-page-wireguard + * @short_description: The editor page for WireGuard connections + */ + +#include "libnm-client-aux-extern/nm-default-client.h" + +#include "nmt-page-wireguard.h" + +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" +#include "nmt-device-entry.h" +#include "nmt-mtu-entry.h" +#include "nmt-wireguard-peer-list.h" + +G_DEFINE_TYPE(NmtPageWireGuard, nmt_page_wireguard, NMT_TYPE_EDITOR_PAGE_DEVICE) + +#define NMT_PAGE_WIREGUARD_GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE((o), NMT_TYPE_PAGE_WIREGUARD, NmtPageWireGuardPrivate)) + +typedef struct { + NmtWireguardPeerList *peers; +} NmtPageWireGuardPrivate; + +NmtEditorPage * +nmt_page_wireguard_new(NMConnection *conn, NmtDeviceEntry *deventry) +{ + return g_object_new(NMT_TYPE_PAGE_WIREGUARD, + "connection", + conn, + "device-entry", + deventry, + NULL); +} + +static void +nmt_page_wireguard_init(NmtPageWireGuard *wireguard) +{} + +static void +nmt_page_wireguard_constructed(GObject *object) +{ + NmtPageWireGuard * wireguard = NMT_PAGE_WIREGUARD(object); + NmtPageWireGuardPrivate *priv = NMT_PAGE_WIREGUARD_GET_PRIVATE(wireguard); + NmtEditorSection * section; + NmtEditorGrid * grid; + NMSettingWireGuard * s_wireguard; + NmtNewtWidget * widget; + NMConnection * conn; + + conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(wireguard)); + s_wireguard = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_WIREGUARD); + + section = nmt_editor_section_new(_("WireGuard"), NULL, TRUE); + grid = nmt_editor_section_get_body(section); + + widget = nmt_newt_entry_new(40, 0); + nmt_editor_grid_append(grid, _("Private key"), widget, NULL); + g_object_bind_property(s_wireguard, + NM_SETTING_WIREGUARD_PRIVATE_KEY, + widget, + "text", + G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); + + widget = nmt_newt_entry_new(40, 0); + nmt_editor_grid_append(grid, _("Listen port"), widget, NULL); + g_object_bind_property(s_wireguard, + NM_SETTING_WIREGUARD_LISTEN_PORT, + widget, + "text", + G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); + + widget = nmt_newt_entry_new(40, 0); + nmt_editor_grid_append(grid, _("Fwmark"), widget, NULL); + g_object_bind_property(s_wireguard, + NM_SETTING_WIREGUARD_FWMARK, + widget, + "text", + G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); + + widget = nmt_mtu_entry_new(); + nmt_editor_grid_append(grid, _("MTU"), widget, NULL); + g_object_bind_property(s_wireguard, + NM_SETTING_WIREGUARD_MTU, + widget, + "mtu", + G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); + + widget = nmt_newt_checkbox_new(_("Add peer routes")); + nmt_editor_grid_append(grid, NULL, widget, NULL); + g_object_bind_property(s_wireguard, + NM_SETTING_WIREGUARD_PEER_ROUTES, + widget, + "active", + G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); + + widget = nmt_newt_separator_new(); + nmt_editor_grid_append(grid, _("Peers"), widget, NULL); + nmt_editor_grid_set_row_flags(grid, widget, NMT_EDITOR_GRID_ROW_LABEL_ALIGN_LEFT); + + widget = nmt_wireguard_peer_list_new(s_wireguard); + nmt_editor_grid_append(grid, NULL, widget, NULL); + priv->peers = NMT_WIREGUARD_PEER_LIST(widget); + + nmt_editor_page_add_section(NMT_EDITOR_PAGE(wireguard), section); + + G_OBJECT_CLASS(nmt_page_wireguard_parent_class)->constructed(object); +} + +static void +nmt_page_wireguard_class_init(NmtPageWireGuardClass *wireguard_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS(wireguard_class); + + g_type_class_add_private(wireguard_class, sizeof(NmtPageWireGuardPrivate)); + + object_class->constructed = nmt_page_wireguard_constructed; +} diff --git a/src/nmtui/nmt-page-wireguard.h b/src/nmtui/nmt-page-wireguard.h new file mode 100644 index 00000000..8e39139c --- /dev/null +++ b/src/nmtui/nmt-page-wireguard.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2021 Red Hat, Inc. + */ + +#ifndef NMT_PAGE_WIREGUARD_H +#define NMT_PAGE_WIREGUARD_H + +#include "nmt-editor-page-device.h" + +#define NMT_TYPE_PAGE_WIREGUARD (nmt_page_wireguard_get_type()) +#define NMT_PAGE_WIREGUARD(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), NMT_TYPE_PAGE_WIREGUARD, NmtPageWireGuard)) +#define NMT_PAGE_WIREGUARD_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), NMT_TYPE_PAGE_WIREGUARD, NmtPageWireGuardClass)) +#define NMT_IS_PAGE_WIREGUARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NMT_TYPE_PAGE_WIREGUARD)) +#define NMT_IS_PAGE_WIREGUARD_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), NMT_TYPE_PAGE_WIREGUARD)) +#define NMT_PAGE_WIREGUARD_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), NMT_TYPE_PAGE_WIREGUARD, NmtPageWireGuardClass)) + +typedef struct { + NmtEditorPageDevice parent; +} NmtPageWireGuard; + +typedef struct { + NmtEditorPageDeviceClass parent; +} NmtPageWireGuardClass; + +GType nmt_page_wireguard_get_type(void); + +NmtEditorPage *nmt_page_wireguard_new(NMConnection *conn, NmtDeviceEntry *deventry); + +#endif /* NMT_PAGE_WIREGUARD_H */ diff --git a/src/nmtui/nmt-wireguard-peer-editor.c b/src/nmtui/nmt-wireguard-peer-editor.c new file mode 100644 index 00000000..810bdf69 --- /dev/null +++ b/src/nmtui/nmt-wireguard-peer-editor.c @@ -0,0 +1,247 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2021 Red Hat, Inc. + */ +/** + * SECTION:nmt-wireguard-peer-editor + * @short_description: The editor page for Peer connections + */ + +#include "libnm-client-aux-extern/nm-default-client.h" + +#include "nmt-wireguard-peer-editor.h" +#include "nmt-page-wireguard.h" + +#include "nmt-device-entry.h" +#include "nmt-mtu-entry.h" +#include "nmt-wireguard-peer-list.h" + +#include "nm-editor-bindings.h" + +G_DEFINE_TYPE(NmtWireguardPeerEditor, nmt_wireguard_peer_editor, NMT_TYPE_NEWT_FORM) + +#define NMT_WIREGUARD_PEER_EDITOR_GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE((o), \ + NMT_TYPE_WIREGUARD_PEER_EDITOR, \ + NmtWireguardPeerEditorPrivate)) + +typedef struct { + NMSettingWireGuard *orig_setting; + NMSettingWireGuard *edit_setting; + NMWireGuardPeer * peer; + NmtNewtEntry * private_key; +} NmtWireguardPeerEditorPrivate; + +enum { + PROP_0, + + PROP_SETTING, + PROP_PEER, + PROP_PUBLIC_KEY, + + LAST_PROP +}; + +NmtNewtForm * +nmt_wireguard_peer_editor_new(NMSettingWireGuard *setting, NMWireGuardPeer *peer) +{ + return g_object_new(NMT_TYPE_WIREGUARD_PEER_EDITOR, "setting", setting, "peer", peer, NULL); +} + +static void +nmt_wireguard_peer_editor_init(NmtWireguardPeerEditor *peer) +{} + +static void +save_peer_and_exit(NmtNewtButton *button, gpointer user_data) +{ + NmtWireguardPeerEditor * editor = user_data; + NmtWireguardPeerEditorPrivate *priv = NMT_WIREGUARD_PEER_EDITOR_GET_PRIVATE(editor); + + nm_setting_wireguard_append_peer(priv->orig_setting, priv->peer); + + nmt_newt_form_quit(NMT_NEWT_FORM(editor)); +} + +static void +nmt_wireguard_peer_editor_constructed(GObject *object) +{ + NmtWireguardPeerEditor *peer = NMT_WIREGUARD_PEER_EDITOR(object); + NmtEditorSection * section; + NmtEditorGrid * grid; + NmtNewtWidget * widget, *label; + NmtNewtWidget * buttons, *ok, *cancel; + + if (G_OBJECT_CLASS(nmt_wireguard_peer_editor_parent_class)->constructed) + G_OBJECT_CLASS(nmt_wireguard_peer_editor_parent_class)->constructed(object); + + section = nmt_editor_section_new(_("Peer"), NULL, TRUE); + grid = nmt_editor_section_get_body(section); + + widget = nmt_newt_entry_new(40, 0); + nmt_editor_grid_append(grid, _("Public key"), widget, NULL); + g_object_bind_property_full(object, + "peer", + widget, + "text", + G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL, + peer_transform_to_public_key_string, + peer_transform_from_public_key_string, + NULL, + NULL); + + widget = nmt_newt_entry_new(40, 0); + nmt_editor_grid_append(grid, _("Allowed IPs"), widget, NULL); + g_object_bind_property_full(peer, + "peer", + widget, + "text", + G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL, + peer_transform_to_allowed_ips_string, + peer_transform_from_allowed_ips_string, + NULL, + NULL); + + widget = nmt_newt_entry_new(40, 0); + nmt_editor_grid_append(grid, _("Endpoint"), widget, NULL); + g_object_bind_property_full(peer, + "peer", + widget, + "text", + G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL, + peer_transform_to_endpoint_string, + peer_transform_from_endpoint_string, + NULL, + NULL); + + widget = nmt_newt_entry_new(40, 0); + nmt_editor_grid_append(grid, _("Preshared key"), widget, NULL); + g_object_bind_property_full(peer, + "peer", + widget, + "text", + G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL, + peer_transform_to_preshared_key_string, + peer_transform_from_preshared_key_string, + NULL, + NULL); + + widget = nmt_newt_entry_numeric_new(10, 0, G_MAXINT); + label = nmt_newt_label_new(C_("seconds", "seconds")); + nmt_editor_grid_append(grid, _("Persistent keepalive"), widget, label); + g_object_bind_property_full(peer, + "peer", + widget, + "text", + G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL, + peer_transform_to_persistent_keepalive_string, + peer_transform_from_persistent_keepalive_string, + NULL, + NULL); + + buttons = nmt_newt_grid_new(); + nmt_editor_grid_append(grid, NULL, buttons, NULL); + nmt_newt_widget_set_padding(buttons, 0, 1, 0, 0); + + cancel = g_object_ref_sink(nmt_newt_button_new(_("Cancel"))); + nmt_newt_widget_set_exit_on_activate(cancel, TRUE); + nmt_newt_grid_add(NMT_NEWT_GRID(buttons), cancel, 0, 0); + nmt_newt_grid_set_flags(NMT_NEWT_GRID(buttons), + cancel, + NMT_NEWT_GRID_EXPAND_X | NMT_NEWT_GRID_ANCHOR_RIGHT + | NMT_NEWT_GRID_FILL_Y); + + ok = g_object_ref_sink(nmt_newt_button_new(_("OK"))); + g_signal_connect(ok, "clicked", G_CALLBACK(save_peer_and_exit), peer); + nmt_newt_grid_add(NMT_NEWT_GRID(buttons), ok, 1, 0); + nmt_newt_widget_set_padding(ok, 1, 0, 0, 0); + g_object_bind_property(NMT_NEWT_GRID(buttons), "valid", ok, "sensitive", G_BINDING_SYNC_CREATE); + + nmt_newt_form_set_content(NMT_NEWT_FORM(peer), NMT_NEWT_WIDGET(section)); +} + +static void +nmt_wireguard_peer_editor_set_property(GObject * object, + guint prop_id, + const GValue *value, + GParamSpec * pspec) +{ + NmtWireguardPeerEditorPrivate *priv = NMT_WIREGUARD_PEER_EDITOR_GET_PRIVATE(object); + + switch (prop_id) { + case PROP_SETTING: + priv->orig_setting = g_value_dup_object(value); + priv->edit_setting = + NM_SETTING_WIREGUARD(nm_setting_duplicate(NM_SETTING(priv->orig_setting))); + break; + case PROP_PEER: + priv->peer = g_value_dup_boxed(value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +nmt_wireguard_peer_editor_get_property(GObject * object, + guint prop_id, + GValue * value, + GParamSpec *pspec) +{ + NmtWireguardPeerEditorPrivate *priv = NMT_WIREGUARD_PEER_EDITOR_GET_PRIVATE(object); + + switch (prop_id) { + case PROP_SETTING: + g_value_set_object(value, priv->edit_setting); + break; + case PROP_PEER: + g_value_set_boxed(value, priv->peer); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +nmt_wireguard_peer_editor_class_init(NmtWireguardPeerEditorClass *peer_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS(peer_class); + + g_type_class_add_private(peer_class, sizeof(NmtWireguardPeerEditorPrivate)); + + /* virtual methods */ + object_class->constructed = nmt_wireguard_peer_editor_constructed; + object_class->set_property = nmt_wireguard_peer_editor_set_property; + object_class->get_property = nmt_wireguard_peer_editor_get_property; + + /* properties */ + + /** + * NmtPeerPage:setting: + * + * The page's #NMSettingWireGuard. + */ + g_object_class_install_property( + object_class, + PROP_SETTING, + g_param_spec_object("setting", + "", + "", + NM_TYPE_SETTING_WIREGUARD, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + + /** + * NmtPeerPage:peer: + * + * The page's #NMWireGuardPeer. + */ + g_object_class_install_property(object_class, + PROP_PEER, + g_param_spec_boxed("peer", + "", + "", + nm_wireguard_peer_get_type(), + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); +} diff --git a/src/nmtui/nmt-wireguard-peer-editor.h b/src/nmtui/nmt-wireguard-peer-editor.h new file mode 100644 index 00000000..ffe76c8c --- /dev/null +++ b/src/nmtui/nmt-wireguard-peer-editor.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2021 Red Hat, Inc. + */ + +#ifndef NMT_WIREGUARD_PEER_EDITOR_H +#define NMT_WIREGUARD_PEER_EDITOR_H + +#include "libnmt-newt/nmt-newt.h" + +#define NMT_TYPE_WIREGUARD_PEER_EDITOR (nmt_wireguard_peer_editor_get_type()) +#define NMT_WIREGUARD_PEER_EDITOR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), NMT_TYPE_WIREGUARD_PEER_EDITOR, NmtWireguardPeerEditor)) +#define NMT_WIREGUARD_PEER_EDITOR_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), NMT_TYPE_WIREGUARD_PEER_EDITOR, NmtWireguardPeerEditorClass)) +#define NMT_IS_WIREGUARD_PEER_EDITOR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), NMT_TYPE_WIREGUARD_PEER_EDITOR)) +#define NMT_IS_WIREGUARD_PEER_EDITOR_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), NMT_TYPE_WIREGUARD_PEER_EDITOR)) +#define NMT_WIREGUARD_PEER_EDITOR_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), NMT_TYPE_WIREGUARD_PEER_EDITOR, NmtWireguardPeerEditorClass)) + +typedef struct { + NmtNewtForm parent; +} NmtWireguardPeerEditor; + +typedef struct { + NmtNewtFormClass parent; +} NmtWireguardPeerEditorClass; + +GType nmt_wireguard_peer_editor_get_type(void); + +NmtNewtForm *nmt_wireguard_peer_editor_new(NMSettingWireGuard *setting, NMWireGuardPeer *peer); + +#endif /* NMT_WIREGUARD_PEER_EDITOR_H */ diff --git a/src/nmtui/nmt-wireguard-peer-list.c b/src/nmtui/nmt-wireguard-peer-list.c new file mode 100644 index 00000000..03f3ef9a --- /dev/null +++ b/src/nmtui/nmt-wireguard-peer-list.c @@ -0,0 +1,451 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2021 Red Hat, Inc. + */ + +/** + * SECTION:nmt-wireguard-peer-list: + * @short_description: An editable list of a connection's peers + * + * #NmtWireguardPeerList implements an #NmtNewtGrid for the + * peers of a connection. + */ + +#include "libnm-client-aux-extern/nm-default-client.h" + +#include "nmtui.h" +#include "nmt-wireguard-peer-list.h" +#include "nmt-wireguard-peer-editor.h" + +G_DEFINE_TYPE(NmtWireguardPeerList, nmt_wireguard_peer_list, NMT_TYPE_NEWT_GRID) + +#define NMT_WIREGUARD_PEER_LIST_GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE((o), NMT_TYPE_WIREGUARD_PEER_LIST, NmtWireguardPeerListPrivate)) + +typedef struct { + NMSettingWireGuard *setting; + GSList * peers; + + NmtNewtListbox * listbox; + NmtNewtButtonBox *buttons; + + NmtNewtWidget *add; + NmtNewtWidget *edit; + NmtNewtWidget *delete; +} NmtWireguardPeerListPrivate; + +enum { + PROP_0, + + PROP_SETTING, + PROP_PEERS, + PROP_NUM_PEERS, + + LAST_PROP +}; + +enum { + ADD_PEER, + EDIT_PEER, + REMOVE_PEER, + + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = {0}; + +/** + * nmt_wireguard_peer_list_new: + * @master: the master #NMSettingWireGuard whose peers are being listed + * + * Creates a new #NmtWireguardPeerList. + * + * Returns: a new #NmtWireguardPeerList. + */ +NmtNewtWidget * +nmt_wireguard_peer_list_new(NMSettingWireGuard *setting) +{ + return g_object_new(NMT_TYPE_WIREGUARD_PEER_LIST, "setting", setting, NULL); +} + +static void +add_clicked(NmtNewtButton *button, gpointer list) +{ + g_signal_emit(list, signals[ADD_PEER], 0); +} + +static void +edit_clicked(NmtNewtButton *button, gpointer list) +{ + g_signal_emit(list, signals[EDIT_PEER], 0); +} + +static void +delete_clicked(NmtNewtButton *button, gpointer list) +{ + g_signal_emit(list, signals[REMOVE_PEER], 0); +} + +static void +listbox_activated(NmtNewtWidget *listbox, gpointer list) +{ + NmtWireguardPeerListPrivate *priv = NMT_WIREGUARD_PEER_LIST_GET_PRIVATE(list); + + edit_clicked(NMT_NEWT_BUTTON(priv->edit), list); +} + +static void +nmt_wireguard_peer_list_init(NmtWireguardPeerList *list) +{ + NmtWireguardPeerListPrivate *priv = NMT_WIREGUARD_PEER_LIST_GET_PRIVATE(list); + NmtNewtWidget * listbox, *buttons; + NmtNewtGrid * grid = NMT_NEWT_GRID(list); + + listbox = g_object_new(NMT_TYPE_NEWT_LISTBOX, + "flags", + NMT_NEWT_LISTBOX_SCROLL | NMT_NEWT_LISTBOX_BORDER, + "skip-null-keys", + TRUE, + NULL); + priv->listbox = NMT_NEWT_LISTBOX(listbox); + nmt_newt_grid_add(grid, listbox, 0, 0); + nmt_newt_grid_set_flags(grid, + listbox, + NMT_NEWT_GRID_FILL_X | NMT_NEWT_GRID_FILL_Y | NMT_NEWT_GRID_EXPAND_X + | NMT_NEWT_GRID_EXPAND_Y); + g_signal_connect(priv->listbox, "activated", G_CALLBACK(listbox_activated), list); + + buttons = nmt_newt_button_box_new(NMT_NEWT_BUTTON_BOX_VERTICAL); + priv->buttons = NMT_NEWT_BUTTON_BOX(buttons); + nmt_newt_grid_add(grid, buttons, 1, 0); + nmt_newt_widget_set_padding(buttons, 1, 1, 0, 1); + nmt_newt_grid_set_flags(grid, + buttons, + NMT_NEWT_GRID_FILL_X | NMT_NEWT_GRID_FILL_Y | NMT_NEWT_GRID_EXPAND_Y); + + priv->add = nmt_newt_button_box_add_start(priv->buttons, _("Add")); + g_signal_connect(priv->add, "clicked", G_CALLBACK(add_clicked), list); + + priv->edit = nmt_newt_button_box_add_start(priv->buttons, _("Edit...")); + g_signal_connect(priv->edit, "clicked", G_CALLBACK(edit_clicked), list); + + priv->delete = nmt_newt_button_box_add_start(priv->buttons, _("Delete")); + g_signal_connect(priv->delete, "clicked", G_CALLBACK(delete_clicked), list); +} + +static void nmt_wireguard_peer_list_rebuild(NmtWireguardPeerList *list); + +static void +rebuild_on_peer_changed(gpointer list) +{ + nmt_wireguard_peer_list_rebuild(list); +} + +static void +free_peers(NmtWireguardPeerList *list) +{ + NmtWireguardPeerListPrivate *priv = NMT_WIREGUARD_PEER_LIST_GET_PRIVATE(list); + + g_slist_free(priv->peers); + priv->peers = NULL; +} + +static void +nmt_wireguard_peer_list_finalize(GObject *object) +{ + NmtWireguardPeerListPrivate *priv = NMT_WIREGUARD_PEER_LIST_GET_PRIVATE(object); + + free_peers(NMT_WIREGUARD_PEER_LIST(object)); + g_object_unref(priv->setting); + g_object_unref(priv->peers); + + G_OBJECT_CLASS(nmt_wireguard_peer_list_parent_class)->finalize(object); +} + +static void +nmt_wireguard_peer_list_add_peer(NmtWireguardPeerList *list) +{ + NmtWireguardPeerListPrivate *priv = NMT_WIREGUARD_PEER_LIST_GET_PRIVATE(list); + NMWireGuardPeer * peer = nm_wireguard_peer_new(); + NmtNewtForm * editor; + + editor = nmt_wireguard_peer_editor_new(priv->setting, peer); + + if (!editor) + return; + + nmt_newt_form_run_sync(editor); + g_object_unref(editor); + rebuild_on_peer_changed(list); +} + +static void +nmt_wireguard_peer_list_edit_peer(NmtWireguardPeerList *list) +{ + NmtWireguardPeerListPrivate *priv = NMT_WIREGUARD_PEER_LIST_GET_PRIVATE(list); + NMWireGuardPeer * orig_peer, *edit_peer; + NmtNewtForm * editor; + int selected_row; + + selected_row = nmt_newt_listbox_get_active(priv->listbox); + + if (selected_row >= 0) { + orig_peer = nm_setting_wireguard_get_peer(priv->setting, (guint) selected_row); + edit_peer = nm_wireguard_peer_new_clone(orig_peer, TRUE); + editor = nmt_wireguard_peer_editor_new(priv->setting, edit_peer); + if (!editor) + return; + nmt_newt_form_run_sync(editor); + g_object_unref(editor); + rebuild_on_peer_changed(list); + } +} + +static void +nmt_wireguard_peer_list_remove_peer(NmtWireguardPeerList *list) +{ + NmtWireguardPeerListPrivate *priv = NMT_WIREGUARD_PEER_LIST_GET_PRIVATE(list); + int selected_row; + + selected_row = nmt_newt_listbox_get_active(priv->listbox); + + if (selected_row >= 0) { + nm_setting_wireguard_remove_peer(priv->setting, (guint) selected_row); + rebuild_on_peer_changed(list); + } +} + +static void +nmt_wireguard_peer_list_set_property(GObject * object, + guint prop_id, + const GValue *value, + GParamSpec * pspec) +{ + NmtWireguardPeerListPrivate *priv = NMT_WIREGUARD_PEER_LIST_GET_PRIVATE(object); + + switch (prop_id) { + case PROP_SETTING: + priv->setting = g_value_get_pointer(value); + break; + case PROP_PEERS: + priv->peers = g_value_get_pointer(value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +nmt_wireguard_peer_list_get_property(GObject * object, + guint prop_id, + GValue * value, + GParamSpec *pspec) +{ + NmtWireguardPeerListPrivate *priv = NMT_WIREGUARD_PEER_LIST_GET_PRIVATE(object); + GPtrArray * peers; + GSList * iter; + + switch (prop_id) { + case PROP_SETTING: + g_value_set_pointer(value, priv->setting); + break; + case PROP_PEERS: + peers = g_ptr_array_new_with_free_func(g_object_unref); + for (iter = priv->peers; iter; iter = iter->next) + g_ptr_array_add(peers, g_object_ref(iter->data)); + g_value_take_boxed(value, peers); + break; + case PROP_NUM_PEERS: + g_value_set_int(value, g_slist_length(priv->peers)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void +nmt_wireguard_peer_list_rebuild(NmtWireguardPeerList *list) +{ + NmtWireguardPeerListPrivate *priv = NMT_WIREGUARD_PEER_LIST_GET_PRIVATE(list); + GSList * iter; + NMWireGuardPeer * peer, *selected_peer; + int i, row, selected_row, num; + NMSettingWireGuard * setting = priv->setting; + + selected_row = nmt_newt_listbox_get_active(priv->listbox); + selected_peer = nmt_newt_listbox_get_active_key(priv->listbox); + + free_peers(list); + num = nm_setting_wireguard_get_peers_len(setting); + for (i = 0; i < num; i++) { + peer = nm_setting_wireguard_get_peer(setting, i); + priv->peers = g_slist_append(priv->peers, peer); + } + g_object_notify(G_OBJECT(list), "peers"); + g_object_notify(G_OBJECT(list), "num-peers"); + + nmt_newt_component_set_sensitive(NMT_NEWT_COMPONENT(priv->edit), priv->peers != NULL); + nmt_newt_component_set_sensitive(NMT_NEWT_COMPONENT(priv->delete), priv->peers != NULL); + + nmt_newt_listbox_clear(priv->listbox); + + for (iter = priv->peers, row = 0; iter; iter = iter->next, row++) { + peer = iter->data; + nmt_newt_listbox_append(priv->listbox, nm_wireguard_peer_get_public_key(peer), peer); + if (peer == selected_peer) + selected_row = row; + } + if (selected_row >= row) + selected_row = row - 1; + nmt_newt_listbox_set_active(priv->listbox, selected_row); +} + +static void +rebuild_on_peers_changed(GObject *object, GParamSpec *pspec, gpointer list) +{ + nmt_wireguard_peer_list_rebuild(list); +} + +static void +nmt_wireguard_peer_list_constructed(GObject *object) +{ + NmtWireguardPeerList *list = NMT_WIREGUARD_PEER_LIST(object); + + g_signal_connect(nm_client, + "notify::" NM_CLIENT_CONNECTIONS, + G_CALLBACK(rebuild_on_peers_changed), + list); + + nmt_wireguard_peer_list_rebuild(list); + + G_OBJECT_CLASS(nmt_wireguard_peer_list_parent_class)->constructed(object); +} + +static void +nmt_wireguard_peer_list_class_init(NmtWireguardPeerListClass *list_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS(list_class); + + g_type_class_add_private(list_class, sizeof(NmtWireguardPeerListPrivate)); + + /* virtual methods */ + object_class->constructed = nmt_wireguard_peer_list_constructed; + object_class->set_property = nmt_wireguard_peer_list_set_property; + object_class->get_property = nmt_wireguard_peer_list_get_property; + object_class->finalize = nmt_wireguard_peer_list_finalize; + + list_class->add_peer = nmt_wireguard_peer_list_add_peer; + list_class->edit_peer = nmt_wireguard_peer_list_edit_peer; + list_class->remove_peer = nmt_wireguard_peer_list_remove_peer; + + /* signals */ + + /** + * NmtWireguardPeerList::add-connection: + * @list: the #NmtWireguardPeerList + * + * Emitted when the user clicks the list's "Add" button. + */ + signals[ADD_PEER] = g_signal_new("add-peer", + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(NmtWireguardPeerListClass, add_peer), + NULL, + NULL, + NULL, + G_TYPE_NONE, + 0); + + /** + * NmtWireguardPeerList::edit-connection: + * @list: the #NmtWireguardPeerList + * @connection: the connection to edit + * + * Emitted when the user clicks the list's "Edit" button, or + * hits "Return" on the listbox. + */ + signals[EDIT_PEER] = g_signal_new("edit-peer", + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(NmtWireguardPeerListClass, edit_peer), + NULL, + NULL, + NULL, + G_TYPE_NONE, + 0); + + /** + * NmtWireguardPeerList::remove-connection: + * @list: the #NmtWireguardPeerList + * @connection: the connection to remove + * + * Emitted when the user clicks the list's "Delete" button. + */ + signals[REMOVE_PEER] = g_signal_new("remove-peer", + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(NmtWireguardPeerListClass, remove_peer), + NULL, + NULL, + NULL, + G_TYPE_NONE, + 0); + + /* properties */ + + /** + * NmtWireguardPeerListFilter: + * @list: the #NmtWireguardPeerList + * @connection: an #NMConnection + * @user_data: the user data + * + * Decides whether @connection should be displayed in @list. + * + * Returns: %TRUE or %FALSE + */ + /** + * NmtWireguardPeerList:connection-filter: + * + * A callback function for filtering which connections appear in + * the list. + */ + g_object_class_install_property( + object_class, + PROP_SETTING, + g_param_spec_pointer("setting", + "", + "", + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + + /** + * NmtWireguardPeerList:connections: + * + * The list of connections in the widget. + * + * Element-Type: #NMConnection + */ + g_object_class_install_property(object_class, + PROP_PEERS, + g_param_spec_boxed("peers", + "", + "", + G_TYPE_PTR_ARRAY, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + /** + * NmtWireguardPeerList:num-connections: + * + * The number of connections in the widget. + */ + g_object_class_install_property(object_class, + PROP_NUM_PEERS, + g_param_spec_int("num-peers", + "", + "", + 0, + G_MAXINT, + 0, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); +} diff --git a/src/nmtui/nmt-wireguard-peer-list.h b/src/nmtui/nmt-wireguard-peer-list.h new file mode 100644 index 00000000..de3faf12 --- /dev/null +++ b/src/nmtui/nmt-wireguard-peer-list.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2021 Red Hat, Inc. + */ + +#ifndef NMT_WIREGUARD_PEER_LIST_H +#define NMT_WIREGUARD_PEER_LIST_H + +#include "libnmt-newt/nmt-newt.h" +#include "nmtui-edit.h" + +#define NMT_TYPE_WIREGUARD_PEER_LIST (nmt_wireguard_peer_list_get_type()) +#define NMT_WIREGUARD_PEER_LIST(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), NMT_TYPE_WIREGUARD_PEER_LIST, NmtWireguardPeerList)) +#define NMT_WIREGUARD_PEER_LIST_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), NMT_TYPE_WIREGUARD_PEER_LIST, NmtWireguardPeerListClass)) +#define NMT_IS_WIREGUARD_PEER_LIST(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), NMT_TYPE_WIREGUARD_PEER_LIST)) +#define NMT_IS_WIREGUARD_PEER_LIST_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), NMT_TYPE_WIREGUARD_PEER_LIST)) +#define NMT_WIREGUARD_PEER_LIST_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), NMT_TYPE_WIREGUARD_PEER_LIST, NmtWireguardPeerListClass)) + +typedef struct { + NmtNewtGrid parent; + +} NmtWireguardPeerList; + +typedef struct { + NmtNewtGridClass parent; + + /* signals */ + void (*add_peer)(NmtWireguardPeerList *list); + void (*edit_peer)(NmtWireguardPeerList *list); + void (*remove_peer)(NmtWireguardPeerList *list); +} NmtWireguardPeerListClass; + +GType nmt_wireguard_peer_list_get_type(void); + +NmtNewtWidget *nmt_wireguard_peer_list_new(NMSettingWireGuard *setting); + +#endif /* NMT_WIREGUARD_PEER_LIST_H */ diff --git a/src/nmtui/nmtui.c b/src/nmtui/nmtui.c index 5edf70e5..897e0911 100644 --- a/src/nmtui/nmtui.c +++ b/src/nmtui/nmtui.c @@ -283,7 +283,7 @@ main(int argc, char **argv) startup_data.argc = argc; startup_data.argv = argv; - g_idle_add(idle_run_subprogram, &startup_data); + nm_g_idle_add(idle_run_subprogram, &startup_data); loop = g_main_loop_new(NULL, FALSE); g_main_loop_run(loop); g_main_loop_unref(loop); diff --git a/src/tests/client/test-client.check-on-disk/test_002.expected b/src/tests/client/test-client.check-on-disk/test_002.expected index 3ed99bf3..3f3f45e1 100644 --- a/src/tests/client/test-client.check-on-disk/test_002.expected +++ b/src/tests/client/test-client.check-on-disk/test_002.expected @@ -502,12 +502,12 @@ NAME UUID TYPE DEVICE con-1 5fcfd6d7-1e63-3332-8826-a7eda103792d ethernet -- <<< -size: 1266 +size: 1319 location: src/tests/client/test-client.py:test_002()/23 cmd: $NMCLI c s con-1 lang: C returncode: 0 -stdout: 1138 bytes +stdout: 1191 bytes >>> connection.id: con-1 connection.uuid: 5fcfd6d7-1e63-3332-8826-a7eda103792d @@ -532,15 +532,16 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 <<< -size: 1278 +size: 1331 location: src/tests/client/test-client.py:test_002()/24 cmd: $NMCLI c s con-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 1140 bytes +stdout: 1193 bytes >>> connection.id: con-1 connection.uuid: 5fcfd6d7-1e63-3332-8826-a7eda103792d @@ -565,6 +566,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 <<< diff --git a/src/tests/client/test-client.check-on-disk/test_003.expected b/src/tests/client/test-client.check-on-disk/test_003.expected index 42b9b524..beb58fe4 100644 --- a/src/tests/client/test-client.check-on-disk/test_003.expected +++ b/src/tests/client/test-client.check-on-disk/test_003.expected @@ -182,12 +182,12 @@ id path uuid <<< -size: 4644 +size: 4697 location: src/tests/client/test-client.py:test_003()/14 cmd: $NMCLI con s con-gsm1 lang: C returncode: 0 -stdout: 4511 bytes +stdout: 4564 bytes >>> connection.id: con-gsm1 connection.uuid: UUID-con-gsm1-REPLACED-REPLACED-REPL @@ -212,6 +212,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -290,12 +291,12 @@ proxy.pac-url: -- proxy.pac-script: -- <<< -size: 4674 +size: 4727 location: src/tests/client/test-client.py:test_003()/15 cmd: $NMCLI con s con-gsm1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 4531 bytes +stdout: 4584 bytes >>> connection.id: con-gsm1 connection.uuid: UUID-con-gsm1-REPLACED-REPLACED-REPL @@ -320,6 +321,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -398,14 +400,14 @@ proxy.pac-url: -- proxy.pac-script: -- <<< -size: 483 +size: 486 location: src/tests/client/test-client.py:test_003()/16 cmd: $NMCLI -g all con s con-gsm1 lang: C returncode: 0 -stdout: 344 bytes +stdout: 347 bytes >>> -connection:con-gsm1:UUID-con-gsm1-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:con-gsm1:UUID-con-gsm1-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 ipv4:auto::: :0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: serial:5:8:even:1:100 @@ -413,14 +415,14 @@ gsm:no::::0:xyz.con-gsm1:::0:no::::auto proxy:none:no:: <<< -size: 493 +size: 496 location: src/tests/client/test-client.py:test_003()/17 cmd: $NMCLI -g all con s con-gsm1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 344 bytes +stdout: 347 bytes >>> -connection:con-gsm1:UUID-con-gsm1-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:con-gsm1:UUID-con-gsm1-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 ipv4:auto::: :0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: serial:5:8:even:1:100 @@ -428,12 +430,12 @@ gsm:no::::0:xyz.con-gsm1:::0:no::::auto proxy:none:no:: <<< -size: 4632 +size: 4685 location: src/tests/client/test-client.py:test_003()/18 cmd: $NMCLI con s con-gsm2 lang: C returncode: 0 -stdout: 4499 bytes +stdout: 4552 bytes >>> connection.id: con-gsm2 connection.uuid: UUID-con-gsm2-REPLACED-REPLACED-REPL @@ -458,6 +460,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -536,12 +539,12 @@ proxy.pac-url: -- proxy.pac-script: -- <<< -size: 4662 +size: 4715 location: src/tests/client/test-client.py:test_003()/19 cmd: $NMCLI con s con-gsm2 lang: pl_PL.UTF-8 returncode: 0 -stdout: 4519 bytes +stdout: 4572 bytes >>> connection.id: con-gsm2 connection.uuid: UUID-con-gsm2-REPLACED-REPLACED-REPL @@ -566,6 +569,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -644,14 +648,14 @@ proxy.pac-url: -- proxy.pac-script: -- <<< -size: 471 +size: 474 location: src/tests/client/test-client.py:test_003()/20 cmd: $NMCLI -g all con s con-gsm2 lang: C returncode: 0 -stdout: 332 bytes +stdout: 335 bytes >>> -connection:con-gsm2:UUID-con-gsm2-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:con-gsm2:UUID-con-gsm2-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 ipv4:auto::: :0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: serial:5:8:even:1:100 @@ -659,14 +663,14 @@ gsm:no::::0::::0:no::::auto proxy:none:no:: <<< -size: 481 +size: 484 location: src/tests/client/test-client.py:test_003()/21 cmd: $NMCLI -g all con s con-gsm2 lang: pl_PL.UTF-8 returncode: 0 -stdout: 332 bytes +stdout: 335 bytes >>> -connection:con-gsm2:UUID-con-gsm2-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:con-gsm2:UUID-con-gsm2-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 ipv4:auto::: :0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: serial:5:8:even:1:100 @@ -674,12 +678,12 @@ gsm:no::::0::::0:no::::auto proxy:none:no:: <<< -size: 4632 +size: 4685 location: src/tests/client/test-client.py:test_003()/22 cmd: $NMCLI con s con-gsm3 lang: C returncode: 0 -stdout: 4499 bytes +stdout: 4552 bytes >>> connection.id: con-gsm3 connection.uuid: UUID-con-gsm3-REPLACED-REPLACED-REPL @@ -704,6 +708,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -782,12 +787,12 @@ proxy.pac-url: -- proxy.pac-script: -- <<< -size: 4662 +size: 4715 location: src/tests/client/test-client.py:test_003()/23 cmd: $NMCLI con s con-gsm3 lang: pl_PL.UTF-8 returncode: 0 -stdout: 4519 bytes +stdout: 4572 bytes >>> connection.id: con-gsm3 connection.uuid: UUID-con-gsm3-REPLACED-REPLACED-REPL @@ -812,6 +817,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -890,14 +896,14 @@ proxy.pac-url: -- proxy.pac-script: -- <<< -size: 472 +size: 475 location: src/tests/client/test-client.py:test_003()/24 cmd: $NMCLI -g all con s con-gsm3 lang: C returncode: 0 -stdout: 333 bytes +stdout: 336 bytes >>> -connection:con-gsm3:UUID-con-gsm3-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:con-gsm3:UUID-con-gsm3-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 ipv4:auto::: :0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: serial:5:8:even:1:100 @@ -905,14 +911,14 @@ gsm:no::::0: :::0:no::::auto proxy:none:no:: <<< -size: 482 +size: 485 location: src/tests/client/test-client.py:test_003()/25 cmd: $NMCLI -g all con s con-gsm3 lang: pl_PL.UTF-8 returncode: 0 -stdout: 333 bytes +stdout: 336 bytes >>> -connection:con-gsm3:UUID-con-gsm3-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:con-gsm3:UUID-con-gsm3-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 ipv4:auto::: :0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: serial:5:8:even:1:100 @@ -1060,12 +1066,12 @@ UUID NAME UUID-ethernet-REPLACED-REPLACED-REPL ethernet <<< -size: 4470 +size: 4523 location: src/tests/client/test-client.py:test_003()/37 cmd: $NMCLI -f ALL con s ethernet lang: C returncode: 0 -stdout: 4330 bytes +stdout: 4383 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -1090,6 +1096,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -1164,12 +1171,12 @@ proxy.pac-url: -- proxy.pac-script: -- <<< -size: 4498 +size: 4551 location: src/tests/client/test-client.py:test_003()/38 cmd: $NMCLI -f ALL con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 4348 bytes +stdout: 4401 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -1194,6 +1201,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -1288,12 +1296,12 @@ stdout: 51 bytes GENERAL.STATE: aktywowano <<< -size: 5172 +size: 5225 location: src/tests/client/test-client.py:test_003()/41 cmd: $NMCLI con s ethernet lang: C returncode: 0 -stdout: 5039 bytes +stdout: 5092 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -1318,6 +1326,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -1405,12 +1414,12 @@ GENERAL.ZONE: -- GENERAL.MASTER-PATH: -- <<< -size: 5204 +size: 5257 location: src/tests/client/test-client.py:test_003()/42 cmd: $NMCLI con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 5061 bytes +stdout: 5114 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -1435,6 +1444,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -2008,12 +2018,12 @@ UUID NAME UUID-ethernet-REPLACED-REPLACED-REPL ethernet <<< -size: 4470 +size: 4523 location: src/tests/client/test-client.py:test_003()/62 cmd: $NMCLI -f ALL con s ethernet lang: C returncode: 0 -stdout: 4330 bytes +stdout: 4383 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -2038,6 +2048,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -2112,12 +2123,12 @@ proxy.pac-url: -- proxy.pac-script: -- <<< -size: 4498 +size: 4551 location: src/tests/client/test-client.py:test_003()/63 cmd: $NMCLI -f ALL con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 4348 bytes +stdout: 4401 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -2142,6 +2153,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -2240,12 +2252,12 @@ GENERAL.STATE: aktywowano GENERAL.STATE: aktywowano <<< -size: 5882 +size: 5935 location: src/tests/client/test-client.py:test_003()/66 cmd: $NMCLI con s ethernet lang: C returncode: 0 -stdout: 5749 bytes +stdout: 5802 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -2270,6 +2282,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -2371,12 +2384,12 @@ GENERAL.ZONE: -- GENERAL.MASTER-PATH: -- <<< -size: 5918 +size: 5971 location: src/tests/client/test-client.py:test_003()/67 cmd: $NMCLI con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 5775 bytes +stdout: 5828 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -2401,6 +2414,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -2840,8 +2854,82 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[2]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- CONNECTIONS.AVAILABLE-CONNECTIONS[3]:UUID-ethernet-REPLACED-REPLACED-REPL | ethernet <<< -size: 2713 +size: 759 location: src/tests/client/test-client.py:test_003()/76 +cmd: $NMCLI +lang: C +returncode: 0 +stdout: 641 bytes +>>> +eth0: connected to ethernet + "eth0" + ethernet (virtual), C0:61:AE:26:4D:D7, hw + +eth1: connected to ethernet + "eth1" + ethernet (virtual), 33:9A:18:81:EB:DC, hw + +wlan0: unavailable + "wlan0" + wifi (virtual), DC:39:87:BA:3E:5D, hw + +wlan1: unavailable + "wlan1" + wifi (virtual), AC:4E:5B:7B:57:49, hw + +wlan1: unavailable + "wlan1" + wifi (virtual), 24:C4:52:BC:3D:37, hw + +DNS configuration: + servers: 1.2.3.4 5.6.7.8 + +Use "nmcli device show" to get complete information about known devices and +"nmcli connection show" to get an overview on active connection profiles. + +Consult nmcli(1) and nmcli-examples(7) manual pages for complete usage details. + +<<< +size: 834 +location: src/tests/client/test-client.py:test_003()/77 +cmd: $NMCLI +lang: pl_PL.UTF-8 +returncode: 0 +stdout: 706 bytes +>>> +eth0: połączono do ethernet + "eth0" + ethernet (virtual), C0:61:AE:26:4D:D7, sprzęt + +eth1: połączono do ethernet + "eth1" + ethernet (virtual), 33:9A:18:81:EB:DC, sprzęt + +wlan0: niedostępne + "wlan0" + wifi (virtual), DC:39:87:BA:3E:5D, sprzęt + +wlan1: niedostępne + "wlan1" + wifi (virtual), AC:4E:5B:7B:57:49, sprzęt + +wlan1: niedostępne + "wlan1" + wifi (virtual), 24:C4:52:BC:3D:37, sprzęt + +DNS configuration: + servers: 1.2.3.4 5.6.7.8 + +Polecenie „nmcli device show” wyświetli pełne informacje o znanych +urządzeniach, a „nmcli connection show” wyświetli przegląd aktywnych +profili połączeń. + +Strony podręcznika nmcli(1) i nmcli-examples(7) zawierają pełne informacje +o użyciu. + +<<< +size: 2713 +location: src/tests/client/test-client.py:test_003()/78 cmd: $NMCLI -f ALL con lang: C returncode: 0 @@ -2858,7 +2946,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 never <<< size: 2739 -location: src/tests/client/test-client.py:test_003()/77 +location: src/tests/client/test-client.py:test_003()/79 cmd: $NMCLI -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -2875,7 +2963,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 nigdy <<< size: 470 -location: src/tests/client/test-client.py:test_003()/78 +location: src/tests/client/test-client.py:test_003()/80 cmd: $NMCLI -f UUID,TYPE con lang: C returncode: 0 @@ -2891,7 +2979,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 480 -location: src/tests/client/test-client.py:test_003()/79 +location: src/tests/client/test-client.py:test_003()/81 cmd: $NMCLI -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -2906,12 +2994,12 @@ UUID-con-gsm3-REPLACED-REPLACED-REPL gsm UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< -size: 5885 -location: src/tests/client/test-client.py:test_003()/80 +size: 5938 +location: src/tests/client/test-client.py:test_003()/82 cmd: $NMCLI con s ethernet lang: C returncode: 0 -stdout: 5752 bytes +stdout: 5805 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -2936,6 +3024,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -3037,12 +3126,12 @@ GENERAL.ZONE: -- GENERAL.MASTER-PATH: -- <<< -size: 5922 -location: src/tests/client/test-client.py:test_003()/81 +size: 5975 +location: src/tests/client/test-client.py:test_003()/83 cmd: $NMCLI con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 5779 bytes +stdout: 5832 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -3067,6 +3156,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -3168,12 +3258,12 @@ GENERAL.ZONE: -- GENERAL.MASTER-PATH: -- <<< -size: 5215 -location: src/tests/client/test-client.py:test_003()/82 +size: 5268 +location: src/tests/client/test-client.py:test_003()/84 cmd: $NMCLI c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 -stdout: 5042 bytes +stdout: 5095 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -3198,6 +3288,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -3285,12 +3376,12 @@ GENERAL.ZONE: -- GENERAL.MASTER-PATH: -- <<< -size: 5248 -location: src/tests/client/test-client.py:test_003()/83 +size: 5301 +location: src/tests/client/test-client.py:test_003()/85 cmd: $NMCLI c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5065 bytes +stdout: 5118 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -3315,6 +3406,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -3403,7 +3495,7 @@ GENERAL.MASTER-PATH: -- <<< size: 3792 -location: src/tests/client/test-client.py:test_003()/84 +location: src/tests/client/test-client.py:test_003()/86 cmd: $NMCLI -f all dev show eth0 lang: C returncode: 0 @@ -3475,7 +3567,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: UUID-ethernet-REPLACED-REPLACED-REPL | e <<< size: 3830 -location: src/tests/client/test-client.py:test_003()/85 +location: src/tests/client/test-client.py:test_003()/87 cmd: $NMCLI -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -3547,7 +3639,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: UUID-ethernet-REPLACED-REPLACED-REPL | e <<< size: 2995 -location: src/tests/client/test-client.py:test_003()/86 +location: src/tests/client/test-client.py:test_003()/88 cmd: $NMCLI --color yes -f ALL con lang: C returncode: 0 @@ -3564,7 +3656,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 never <<< size: 3021 -location: src/tests/client/test-client.py:test_003()/87 +location: src/tests/client/test-client.py:test_003()/89 cmd: $NMCLI --color yes -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -3581,7 +3673,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 nigdy <<< size: 500 -location: src/tests/client/test-client.py:test_003()/88 +location: src/tests/client/test-client.py:test_003()/90 cmd: $NMCLI --color yes -f UUID,TYPE con lang: C returncode: 0 @@ -3597,7 +3689,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 510 -location: src/tests/client/test-client.py:test_003()/89 +location: src/tests/client/test-client.py:test_003()/91 cmd: $NMCLI --color yes -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -3612,12 +3704,12 @@ UUID-con-gsm3-REPLACED-REPLACED-REPL gsm UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< -size: 5897 -location: src/tests/client/test-client.py:test_003()/90 +size: 5950 +location: src/tests/client/test-client.py:test_003()/92 cmd: $NMCLI --color yes con s ethernet lang: C returncode: 0 -stdout: 5752 bytes +stdout: 5805 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -3642,6 +3734,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -3743,12 +3836,12 @@ GENERAL.ZONE: -- GENERAL.MASTER-PATH: -- <<< -size: 5934 -location: src/tests/client/test-client.py:test_003()/91 +size: 5987 +location: src/tests/client/test-client.py:test_003()/93 cmd: $NMCLI --color yes con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 5779 bytes +stdout: 5832 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -3773,6 +3866,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -3874,12 +3968,12 @@ GENERAL.ZONE: -- GENERAL.MASTER-PATH: -- <<< -size: 5227 -location: src/tests/client/test-client.py:test_003()/92 +size: 5280 +location: src/tests/client/test-client.py:test_003()/94 cmd: $NMCLI --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 -stdout: 5042 bytes +stdout: 5095 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -3904,6 +3998,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -3991,12 +4086,12 @@ GENERAL.ZONE: -- GENERAL.MASTER-PATH: -- <<< -size: 5260 -location: src/tests/client/test-client.py:test_003()/93 +size: 5313 +location: src/tests/client/test-client.py:test_003()/95 cmd: $NMCLI --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5065 bytes +stdout: 5118 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -4021,6 +4116,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -4109,7 +4205,7 @@ GENERAL.MASTER-PATH: -- <<< size: 3804 -location: src/tests/client/test-client.py:test_003()/94 +location: src/tests/client/test-client.py:test_003()/96 cmd: $NMCLI --color yes -f all dev show eth0 lang: C returncode: 0 @@ -4181,7 +4277,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: UUID-ethernet-REPLACED-REPLACED-REPL | e <<< size: 3842 -location: src/tests/client/test-client.py:test_003()/95 +location: src/tests/client/test-client.py:test_003()/97 cmd: $NMCLI --color yes -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -4253,7 +4349,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: UUID-ethernet-REPLACED-REPLACED-REPL | e <<< size: 3199 -location: src/tests/client/test-client.py:test_003()/96 +location: src/tests/client/test-client.py:test_003()/98 cmd: $NMCLI --pretty -f ALL con lang: C returncode: 0 @@ -4274,7 +4370,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 never <<< size: 3247 -location: src/tests/client/test-client.py:test_003()/97 +location: src/tests/client/test-client.py:test_003()/99 cmd: $NMCLI --pretty -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -4294,8 +4390,8 @@ con-gsm3 UUID-con-gsm3-REPLACED-REPLACED-REPL gsm 0 nigdy con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 nigdy tak 0 nie /org/freedesktop/NetworkManager/Settings/Connection/2 nie -- -- -- -- /etc/NetworkManager/system-connections/con-xx1 <<< -size: 681 -location: src/tests/client/test-client.py:test_003()/98 +size: 682 +location: src/tests/client/test-client.py:test_003()/100 cmd: $NMCLI --pretty -f UUID,TYPE con lang: C returncode: 0 @@ -4314,8 +4410,8 @@ UUID-con-gsm3-REPLACED-REPLACED-REPL gsm UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< -size: 711 -location: src/tests/client/test-client.py:test_003()/99 +size: 712 +location: src/tests/client/test-client.py:test_003()/101 cmd: $NMCLI --pretty -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -4334,12 +4430,12 @@ UUID-con-gsm3-REPLACED-REPLACED-REPL gsm UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< -size: 7140 -location: src/tests/client/test-client.py:test_003()/100 +size: 7193 +location: src/tests/client/test-client.py:test_003()/102 cmd: $NMCLI --pretty con s ethernet lang: C returncode: 0 -stdout: 6997 bytes +stdout: 7050 bytes >>> =============================================================================== Connection profile details (ethernet) @@ -4367,6 +4463,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- 802-3-ethernet.port: -- @@ -4481,12 +4578,12 @@ GENERAL.MASTER-PATH: -- ------------------------------------------------------------------------------- <<< -size: 7196 -location: src/tests/client/test-client.py:test_003()/101 +size: 7249 +location: src/tests/client/test-client.py:test_003()/103 cmd: $NMCLI --pretty con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 7043 bytes +stdout: 7096 bytes >>> =============================================================================== Szczegóły profilu połączenia (ethernet) @@ -4514,6 +4611,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- 802-3-ethernet.port: -- @@ -4628,12 +4726,12 @@ GENERAL.MASTER-PATH: -- ------------------------------------------------------------------------------- <<< -size: 6157 -location: src/tests/client/test-client.py:test_003()/102 +size: 6210 +location: src/tests/client/test-client.py:test_003()/104 cmd: $NMCLI --pretty c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 -stdout: 5974 bytes +stdout: 6027 bytes >>> =============================================================================== Connection profile details (ethernet) @@ -4661,6 +4759,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- 802-3-ethernet.port: -- @@ -4757,12 +4856,12 @@ GENERAL.MASTER-PATH: -- ------------------------------------------------------------------------------- <<< -size: 6202 -location: src/tests/client/test-client.py:test_003()/103 +size: 6255 +location: src/tests/client/test-client.py:test_003()/105 cmd: $NMCLI --pretty c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 6009 bytes +stdout: 6062 bytes >>> =============================================================================== Szczegóły profilu połączenia (ethernet) @@ -4790,6 +4889,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- 802-3-ethernet.port: -- @@ -4887,7 +4987,7 @@ GENERAL.MASTER-PATH: -- <<< size: 4733 -location: src/tests/client/test-client.py:test_003()/104 +location: src/tests/client/test-client.py:test_003()/106 cmd: $NMCLI --pretty -f all dev show eth0 lang: C returncode: 0 @@ -4971,7 +5071,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: UUID-ethernet-REPLACED-REPLACED-REPL | e <<< size: 4777 -location: src/tests/client/test-client.py:test_003()/105 +location: src/tests/client/test-client.py:test_003()/107 cmd: $NMCLI --pretty -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -5055,7 +5155,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: UUID-ethernet-REPLACED-REPLACED-REPL | e <<< size: 3482 -location: src/tests/client/test-client.py:test_003()/106 +location: src/tests/client/test-client.py:test_003()/108 cmd: $NMCLI --pretty --color yes -f ALL con lang: C returncode: 0 @@ -5076,7 +5176,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 never <<< size: 3530 -location: src/tests/client/test-client.py:test_003()/107 +location: src/tests/client/test-client.py:test_003()/109 cmd: $NMCLI --pretty --color yes -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -5097,7 +5197,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 nigdy <<< size: 712 -location: src/tests/client/test-client.py:test_003()/108 +location: src/tests/client/test-client.py:test_003()/110 cmd: $NMCLI --pretty --color yes -f UUID,TYPE con lang: C returncode: 0 @@ -5117,7 +5217,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 742 -location: src/tests/client/test-client.py:test_003()/109 +location: src/tests/client/test-client.py:test_003()/111 cmd: $NMCLI --pretty --color yes -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -5136,12 +5236,12 @@ UUID-con-gsm3-REPLACED-REPLACED-REPL gsm UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< -size: 7152 -location: src/tests/client/test-client.py:test_003()/110 +size: 7205 +location: src/tests/client/test-client.py:test_003()/112 cmd: $NMCLI --pretty --color yes con s ethernet lang: C returncode: 0 -stdout: 6997 bytes +stdout: 7050 bytes >>> =============================================================================== Connection profile details (ethernet) @@ -5169,6 +5269,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- 802-3-ethernet.port: -- @@ -5283,12 +5384,12 @@ GENERAL.MASTER-PATH: -- ------------------------------------------------------------------------------- <<< -size: 7208 -location: src/tests/client/test-client.py:test_003()/111 +size: 7261 +location: src/tests/client/test-client.py:test_003()/113 cmd: $NMCLI --pretty --color yes con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 7043 bytes +stdout: 7096 bytes >>> =============================================================================== Szczegóły profilu połączenia (ethernet) @@ -5316,6 +5417,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- 802-3-ethernet.port: -- @@ -5430,12 +5532,12 @@ GENERAL.MASTER-PATH: -- ------------------------------------------------------------------------------- <<< -size: 6169 -location: src/tests/client/test-client.py:test_003()/112 +size: 6222 +location: src/tests/client/test-client.py:test_003()/114 cmd: $NMCLI --pretty --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 -stdout: 5974 bytes +stdout: 6027 bytes >>> =============================================================================== Connection profile details (ethernet) @@ -5463,6 +5565,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- 802-3-ethernet.port: -- @@ -5559,12 +5662,12 @@ GENERAL.MASTER-PATH: -- ------------------------------------------------------------------------------- <<< -size: 6214 -location: src/tests/client/test-client.py:test_003()/113 +size: 6267 +location: src/tests/client/test-client.py:test_003()/115 cmd: $NMCLI --pretty --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 6009 bytes +stdout: 6062 bytes >>> =============================================================================== Szczegóły profilu połączenia (ethernet) @@ -5592,6 +5695,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- 802-3-ethernet.port: -- @@ -5689,7 +5793,7 @@ GENERAL.MASTER-PATH: -- <<< size: 4745 -location: src/tests/client/test-client.py:test_003()/114 +location: src/tests/client/test-client.py:test_003()/116 cmd: $NMCLI --pretty --color yes -f all dev show eth0 lang: C returncode: 0 @@ -5773,7 +5877,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: UUID-ethernet-REPLACED-REPLACED-REPL | e <<< size: 4789 -location: src/tests/client/test-client.py:test_003()/115 +location: src/tests/client/test-client.py:test_003()/117 cmd: $NMCLI --pretty --color yes -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -5857,7 +5961,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: UUID-ethernet-REPLACED-REPLACED-REPL | e <<< size: 1534 -location: src/tests/client/test-client.py:test_003()/116 +location: src/tests/client/test-client.py:test_003()/118 cmd: $NMCLI --terse -f ALL con lang: C returncode: 0 @@ -5873,7 +5977,7 @@ con-xx1:UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet:0:never:yes:0:no:/or <<< size: 1544 -location: src/tests/client/test-client.py:test_003()/117 +location: src/tests/client/test-client.py:test_003()/119 cmd: $NMCLI --terse -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -5889,7 +5993,7 @@ con-xx1:UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet:0:never:yes:0:no:/or <<< size: 422 -location: src/tests/client/test-client.py:test_003()/118 +location: src/tests/client/test-client.py:test_003()/120 cmd: $NMCLI --terse -f UUID,TYPE con lang: C returncode: 0 @@ -5904,7 +6008,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet <<< size: 432 -location: src/tests/client/test-client.py:test_003()/119 +location: src/tests/client/test-client.py:test_003()/121 cmd: $NMCLI --terse -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -5918,12 +6022,12 @@ UUID-con-gsm3-REPLACED-REPLACED-REPL:gsm UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet <<< -size: 3166 -location: src/tests/client/test-client.py:test_003()/120 +size: 3193 +location: src/tests/client/test-client.py:test_003()/122 cmd: $NMCLI --terse con s ethernet lang: C returncode: 0 -stdout: 3024 bytes +stdout: 3051 bytes >>> connection.id:ethernet connection.uuid:UUID-ethernet-REPLACED-REPLACED-REPL @@ -5948,6 +6052,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 802-3-ethernet.port: 802-3-ethernet.speed:0 @@ -6049,12 +6154,12 @@ GENERAL.ZONE: GENERAL.MASTER-PATH: <<< -size: 3176 -location: src/tests/client/test-client.py:test_003()/121 +size: 3203 +location: src/tests/client/test-client.py:test_003()/123 cmd: $NMCLI --terse con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 3024 bytes +stdout: 3051 bytes >>> connection.id:ethernet connection.uuid:UUID-ethernet-REPLACED-REPLACED-REPL @@ -6079,6 +6184,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 802-3-ethernet.port: 802-3-ethernet.speed:0 @@ -6180,12 +6286,12 @@ GENERAL.ZONE: GENERAL.MASTER-PATH: <<< -size: 2816 -location: src/tests/client/test-client.py:test_003()/122 +size: 2843 +location: src/tests/client/test-client.py:test_003()/124 cmd: $NMCLI --terse c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 -stdout: 2634 bytes +stdout: 2661 bytes >>> connection.id:ethernet connection.uuid:UUID-ethernet-REPLACED-REPLACED-REPL @@ -6210,6 +6316,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 802-3-ethernet.port: 802-3-ethernet.speed:0 @@ -6297,12 +6404,12 @@ GENERAL.ZONE: GENERAL.MASTER-PATH: <<< -size: 2826 -location: src/tests/client/test-client.py:test_003()/123 +size: 2853 +location: src/tests/client/test-client.py:test_003()/125 cmd: $NMCLI --terse c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 2634 bytes +stdout: 2661 bytes >>> connection.id:ethernet connection.uuid:UUID-ethernet-REPLACED-REPLACED-REPL @@ -6327,6 +6434,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 802-3-ethernet.port: 802-3-ethernet.speed:0 @@ -6415,7 +6523,7 @@ GENERAL.MASTER-PATH: <<< size: 2426 -location: src/tests/client/test-client.py:test_003()/124 +location: src/tests/client/test-client.py:test_003()/126 cmd: $NMCLI --terse -f all dev show eth0 lang: C returncode: 0 @@ -6487,7 +6595,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]:UUID-ethernet-REPLACED-REPLACED-REPL | ethe <<< size: 2436 -location: src/tests/client/test-client.py:test_003()/125 +location: src/tests/client/test-client.py:test_003()/127 cmd: $NMCLI --terse -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -6559,7 +6667,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]:UUID-ethernet-REPLACED-REPLACED-REPL | ethe <<< size: 1816 -location: src/tests/client/test-client.py:test_003()/126 +location: src/tests/client/test-client.py:test_003()/128 cmd: $NMCLI --terse --color yes -f ALL con lang: C returncode: 0 @@ -6575,7 +6683,7 @@ con-xx1:UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet:0:never:yes:0:no:/or <<< size: 1826 -location: src/tests/client/test-client.py:test_003()/127 +location: src/tests/client/test-client.py:test_003()/129 cmd: $NMCLI --terse --color yes -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -6591,7 +6699,7 @@ con-xx1:UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet:0:never:yes:0:no:/or <<< size: 452 -location: src/tests/client/test-client.py:test_003()/128 +location: src/tests/client/test-client.py:test_003()/130 cmd: $NMCLI --terse --color yes -f UUID,TYPE con lang: C returncode: 0 @@ -6606,7 +6714,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet <<< size: 462 -location: src/tests/client/test-client.py:test_003()/129 +location: src/tests/client/test-client.py:test_003()/131 cmd: $NMCLI --terse --color yes -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -6620,12 +6728,12 @@ UUID-con-gsm3-REPLACED-REPLACED-REPL:gsm UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet <<< -size: 3178 -location: src/tests/client/test-client.py:test_003()/130 +size: 3205 +location: src/tests/client/test-client.py:test_003()/132 cmd: $NMCLI --terse --color yes con s ethernet lang: C returncode: 0 -stdout: 3024 bytes +stdout: 3051 bytes >>> connection.id:ethernet connection.uuid:UUID-ethernet-REPLACED-REPLACED-REPL @@ -6650,6 +6758,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 802-3-ethernet.port: 802-3-ethernet.speed:0 @@ -6751,12 +6860,12 @@ GENERAL.ZONE: GENERAL.MASTER-PATH: <<< -size: 3188 -location: src/tests/client/test-client.py:test_003()/131 +size: 3215 +location: src/tests/client/test-client.py:test_003()/133 cmd: $NMCLI --terse --color yes con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 3024 bytes +stdout: 3051 bytes >>> connection.id:ethernet connection.uuid:UUID-ethernet-REPLACED-REPLACED-REPL @@ -6781,6 +6890,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 802-3-ethernet.port: 802-3-ethernet.speed:0 @@ -6882,12 +6992,12 @@ GENERAL.ZONE: GENERAL.MASTER-PATH: <<< -size: 2828 -location: src/tests/client/test-client.py:test_003()/132 +size: 2855 +location: src/tests/client/test-client.py:test_003()/134 cmd: $NMCLI --terse --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 -stdout: 2634 bytes +stdout: 2661 bytes >>> connection.id:ethernet connection.uuid:UUID-ethernet-REPLACED-REPLACED-REPL @@ -6912,6 +7022,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 802-3-ethernet.port: 802-3-ethernet.speed:0 @@ -6999,12 +7110,12 @@ GENERAL.ZONE: GENERAL.MASTER-PATH: <<< -size: 2838 -location: src/tests/client/test-client.py:test_003()/133 +size: 2865 +location: src/tests/client/test-client.py:test_003()/135 cmd: $NMCLI --terse --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 2634 bytes +stdout: 2661 bytes >>> connection.id:ethernet connection.uuid:UUID-ethernet-REPLACED-REPLACED-REPL @@ -7029,6 +7140,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 802-3-ethernet.port: 802-3-ethernet.speed:0 @@ -7117,7 +7229,7 @@ GENERAL.MASTER-PATH: <<< size: 2438 -location: src/tests/client/test-client.py:test_003()/134 +location: src/tests/client/test-client.py:test_003()/136 cmd: $NMCLI --terse --color yes -f all dev show eth0 lang: C returncode: 0 @@ -7189,7 +7301,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]:UUID-ethernet-REPLACED-REPLACED-REPL | ethe <<< size: 2448 -location: src/tests/client/test-client.py:test_003()/135 +location: src/tests/client/test-client.py:test_003()/137 cmd: $NMCLI --terse --color yes -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -7261,7 +7373,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]:UUID-ethernet-REPLACED-REPLACED-REPL | ethe <<< size: 2729 -location: src/tests/client/test-client.py:test_003()/136 +location: src/tests/client/test-client.py:test_003()/138 cmd: $NMCLI --mode tabular -f ALL con lang: C returncode: 0 @@ -7278,7 +7390,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 never <<< size: 2755 -location: src/tests/client/test-client.py:test_003()/137 +location: src/tests/client/test-client.py:test_003()/139 cmd: $NMCLI --mode tabular -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -7295,7 +7407,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 nigdy <<< size: 486 -location: src/tests/client/test-client.py:test_003()/138 +location: src/tests/client/test-client.py:test_003()/140 cmd: $NMCLI --mode tabular -f UUID,TYPE con lang: C returncode: 0 @@ -7311,7 +7423,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 496 -location: src/tests/client/test-client.py:test_003()/139 +location: src/tests/client/test-client.py:test_003()/141 cmd: $NMCLI --mode tabular -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -7326,15 +7438,15 @@ UUID-con-gsm3-REPLACED-REPLACED-REPL gsm UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< -size: 3965 -location: src/tests/client/test-client.py:test_003()/140 +size: 3993 +location: src/tests/client/test-client.py:test_003()/142 cmd: $NMCLI --mode tabular con s ethernet lang: C returncode: 0 -stdout: 3816 bytes +stdout: 3844 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name port speed duplex auto-negotiate mac-address cloned-mac-address generate-mac-address-mask mac-address-blacklist mtu s390-subchannels s390-nettype s390-options wake-on-lan wake-on-lan-password accept-all-mac-addresses 802-3-ethernet -- 0 -- no -- -- -- -- auto -- -- -- default -- -1 (default) @@ -7357,15 +7469,15 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deac <<< -size: 3999 -location: src/tests/client/test-client.py:test_003()/141 +size: 4027 +location: src/tests/client/test-client.py:test_003()/143 cmd: $NMCLI --mode tabular con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 3840 bytes +stdout: 3868 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name port speed duplex auto-negotiate mac-address cloned-mac-address generate-mac-address-mask mac-address-blacklist mtu s390-subchannels s390-nettype s390-options wake-on-lan wake-on-lan-password accept-all-mac-addresses 802-3-ethernet -- 0 -- nie -- -- -- -- automatyczne -- -- -- default -- -1 (default) @@ -7388,15 +7500,15 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deza <<< -size: 3503 -location: src/tests/client/test-client.py:test_003()/142 +size: 3531 +location: src/tests/client/test-client.py:test_003()/144 cmd: $NMCLI --mode tabular c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 -stdout: 3314 bytes +stdout: 3342 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name port speed duplex auto-negotiate mac-address cloned-mac-address generate-mac-address-mask mac-address-blacklist mtu s390-subchannels s390-nettype s390-options wake-on-lan wake-on-lan-password accept-all-mac-addresses 802-3-ethernet -- 0 -- no -- -- -- -- auto -- -- -- default -- -1 (default) @@ -7415,15 +7527,15 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deac <<< -size: 3535 -location: src/tests/client/test-client.py:test_003()/143 +size: 3563 +location: src/tests/client/test-client.py:test_003()/145 cmd: $NMCLI --mode tabular c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 3336 bytes +stdout: 3364 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name port speed duplex auto-negotiate mac-address cloned-mac-address generate-mac-address-mask mac-address-blacklist mtu s390-subchannels s390-nettype s390-options wake-on-lan wake-on-lan-password accept-all-mac-addresses 802-3-ethernet -- 0 -- nie -- -- -- -- automatyczne -- -- -- default -- -1 (default) @@ -7443,7 +7555,7 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deza <<< size: 3207 -location: src/tests/client/test-client.py:test_003()/144 +location: src/tests/client/test-client.py:test_003()/146 cmd: $NMCLI --mode tabular -f all dev show eth0 lang: C returncode: 0 @@ -7478,7 +7590,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{1,2,6} 5fcfd6 <<< size: 3237 -location: src/tests/client/test-client.py:test_003()/145 +location: src/tests/client/test-client.py:test_003()/147 cmd: $NMCLI --mode tabular -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -7513,7 +7625,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{1,2,6} 5fcfd6 <<< size: 3011 -location: src/tests/client/test-client.py:test_003()/146 +location: src/tests/client/test-client.py:test_003()/148 cmd: $NMCLI --mode tabular --color yes -f ALL con lang: C returncode: 0 @@ -7530,7 +7642,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 never <<< size: 3037 -location: src/tests/client/test-client.py:test_003()/147 +location: src/tests/client/test-client.py:test_003()/149 cmd: $NMCLI --mode tabular --color yes -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -7547,7 +7659,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 nigdy <<< size: 516 -location: src/tests/client/test-client.py:test_003()/148 +location: src/tests/client/test-client.py:test_003()/150 cmd: $NMCLI --mode tabular --color yes -f UUID,TYPE con lang: C returncode: 0 @@ -7563,7 +7675,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 526 -location: src/tests/client/test-client.py:test_003()/149 +location: src/tests/client/test-client.py:test_003()/151 cmd: $NMCLI --mode tabular --color yes -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -7578,15 +7690,15 @@ UUID-con-gsm3-REPLACED-REPLACED-REPL gsm UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< -size: 3977 -location: src/tests/client/test-client.py:test_003()/150 +size: 4005 +location: src/tests/client/test-client.py:test_003()/152 cmd: $NMCLI --mode tabular --color yes con s ethernet lang: C returncode: 0 -stdout: 3816 bytes +stdout: 3844 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name port speed duplex auto-negotiate mac-address cloned-mac-address generate-mac-address-mask mac-address-blacklist mtu s390-subchannels s390-nettype s390-options wake-on-lan wake-on-lan-password accept-all-mac-addresses 802-3-ethernet -- 0 -- no -- -- -- -- auto -- -- -- default -- -1 (default) @@ -7609,15 +7721,15 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deac <<< -size: 4011 -location: src/tests/client/test-client.py:test_003()/151 +size: 4039 +location: src/tests/client/test-client.py:test_003()/153 cmd: $NMCLI --mode tabular --color yes con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 3840 bytes +stdout: 3868 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name port speed duplex auto-negotiate mac-address cloned-mac-address generate-mac-address-mask mac-address-blacklist mtu s390-subchannels s390-nettype s390-options wake-on-lan wake-on-lan-password accept-all-mac-addresses 802-3-ethernet -- 0 -- nie -- -- -- -- automatyczne -- -- -- default -- -1 (default) @@ -7640,15 +7752,15 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deza <<< -size: 3515 -location: src/tests/client/test-client.py:test_003()/152 +size: 3543 +location: src/tests/client/test-client.py:test_003()/154 cmd: $NMCLI --mode tabular --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 -stdout: 3314 bytes +stdout: 3342 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name port speed duplex auto-negotiate mac-address cloned-mac-address generate-mac-address-mask mac-address-blacklist mtu s390-subchannels s390-nettype s390-options wake-on-lan wake-on-lan-password accept-all-mac-addresses 802-3-ethernet -- 0 -- no -- -- -- -- auto -- -- -- default -- -1 (default) @@ -7667,15 +7779,15 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deac <<< -size: 3547 -location: src/tests/client/test-client.py:test_003()/153 +size: 3575 +location: src/tests/client/test-client.py:test_003()/155 cmd: $NMCLI --mode tabular --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 3336 bytes +stdout: 3364 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name port speed duplex auto-negotiate mac-address cloned-mac-address generate-mac-address-mask mac-address-blacklist mtu s390-subchannels s390-nettype s390-options wake-on-lan wake-on-lan-password accept-all-mac-addresses 802-3-ethernet -- 0 -- nie -- -- -- -- automatyczne -- -- -- default -- -1 (default) @@ -7695,7 +7807,7 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deza <<< size: 3219 -location: src/tests/client/test-client.py:test_003()/154 +location: src/tests/client/test-client.py:test_003()/156 cmd: $NMCLI --mode tabular --color yes -f all dev show eth0 lang: C returncode: 0 @@ -7730,7 +7842,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{1,2,6} 5fcfd6 <<< size: 3249 -location: src/tests/client/test-client.py:test_003()/155 +location: src/tests/client/test-client.py:test_003()/157 cmd: $NMCLI --mode tabular --color yes -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -7765,7 +7877,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{1,2,6} 5fcfd6 <<< size: 3215 -location: src/tests/client/test-client.py:test_003()/156 +location: src/tests/client/test-client.py:test_003()/158 cmd: $NMCLI --mode tabular --pretty -f ALL con lang: C returncode: 0 @@ -7786,7 +7898,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 never <<< size: 3263 -location: src/tests/client/test-client.py:test_003()/157 +location: src/tests/client/test-client.py:test_003()/159 cmd: $NMCLI --mode tabular --pretty -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -7807,7 +7919,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 nigdy <<< size: 697 -location: src/tests/client/test-client.py:test_003()/158 +location: src/tests/client/test-client.py:test_003()/160 cmd: $NMCLI --mode tabular --pretty -f UUID,TYPE con lang: C returncode: 0 @@ -7827,7 +7939,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 727 -location: src/tests/client/test-client.py:test_003()/159 +location: src/tests/client/test-client.py:test_003()/161 cmd: $NMCLI --mode tabular --pretty -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -7846,19 +7958,19 @@ UUID-con-gsm3-REPLACED-REPLACED-REPL gsm UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< -size: 6431 -location: src/tests/client/test-client.py:test_003()/160 +size: 6473 +location: src/tests/client/test-client.py:test_003()/162 cmd: $NMCLI --mode tabular --pretty con s ethernet lang: C returncode: 0 -stdout: 6273 bytes +stdout: 6315 bytes >>> ========================================= Connection profile details (ethernet) ========================================= -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name port speed duplex auto-negotiate mac-address cloned-mac-address generate-mac-address-mask mac-address-blacklist mtu s390-subchannels s390-nettype s390-options wake-on-lan wake-on-lan-password accept-all-mac-addresses --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -7893,19 +8005,19 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deac <<< -size: 6525 -location: src/tests/client/test-client.py:test_003()/161 +size: 6567 +location: src/tests/client/test-client.py:test_003()/163 cmd: $NMCLI --mode tabular --pretty con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 6357 bytes +stdout: 6399 bytes >>> =========================================== Szczegóły profilu połączenia (ethernet) =========================================== -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name port speed duplex auto-negotiate mac-address cloned-mac-address generate-mac-address-mask mac-address-blacklist mtu s390-subchannels s390-nettype s390-options wake-on-lan wake-on-lan-password accept-all-mac-addresses ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -7940,19 +8052,19 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deza <<< -size: 5507 -location: src/tests/client/test-client.py:test_003()/162 +size: 5549 +location: src/tests/client/test-client.py:test_003()/164 cmd: $NMCLI --mode tabular --pretty c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 -stdout: 5309 bytes +stdout: 5351 bytes >>> ========================================= Connection profile details (ethernet) ========================================= -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name port speed duplex auto-negotiate mac-address cloned-mac-address generate-mac-address-mask mac-address-blacklist mtu s390-subchannels s390-nettype s390-options wake-on-lan wake-on-lan-password accept-all-mac-addresses --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -7979,19 +8091,19 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deac <<< -size: 5579 -location: src/tests/client/test-client.py:test_003()/163 +size: 5621 +location: src/tests/client/test-client.py:test_003()/165 cmd: $NMCLI --mode tabular --pretty c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5371 bytes +stdout: 5413 bytes >>> =========================================== Szczegóły profilu połączenia (ethernet) =========================================== -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name port speed duplex auto-negotiate mac-address cloned-mac-address generate-mac-address-mask mac-address-blacklist mtu s390-subchannels s390-nettype s390-options wake-on-lan wake-on-lan-password accept-all-mac-addresses ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -8019,7 +8131,7 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deza <<< size: 4823 -location: src/tests/client/test-client.py:test_003()/164 +location: src/tests/client/test-client.py:test_003()/166 cmd: $NMCLI --mode tabular --pretty -f all dev show eth0 lang: C returncode: 0 @@ -8066,7 +8178,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{1,2,6} 5fcfd6 <<< size: 4889 -location: src/tests/client/test-client.py:test_003()/165 +location: src/tests/client/test-client.py:test_003()/167 cmd: $NMCLI --mode tabular --pretty -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -8113,7 +8225,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{1,2,6} 5fcfd6 <<< size: 3497 -location: src/tests/client/test-client.py:test_003()/166 +location: src/tests/client/test-client.py:test_003()/168 cmd: $NMCLI --mode tabular --pretty --color yes -f ALL con lang: C returncode: 0 @@ -8134,7 +8246,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 never <<< size: 3545 -location: src/tests/client/test-client.py:test_003()/167 +location: src/tests/client/test-client.py:test_003()/169 cmd: $NMCLI --mode tabular --pretty --color yes -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -8155,7 +8267,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 nigdy <<< size: 727 -location: src/tests/client/test-client.py:test_003()/168 +location: src/tests/client/test-client.py:test_003()/170 cmd: $NMCLI --mode tabular --pretty --color yes -f UUID,TYPE con lang: C returncode: 0 @@ -8175,7 +8287,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 757 -location: src/tests/client/test-client.py:test_003()/169 +location: src/tests/client/test-client.py:test_003()/171 cmd: $NMCLI --mode tabular --pretty --color yes -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -8194,19 +8306,19 @@ UUID-con-gsm3-REPLACED-REPLACED-REPL gsm UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< -size: 6443 -location: src/tests/client/test-client.py:test_003()/170 +size: 6485 +location: src/tests/client/test-client.py:test_003()/172 cmd: $NMCLI --mode tabular --pretty --color yes con s ethernet lang: C returncode: 0 -stdout: 6273 bytes +stdout: 6315 bytes >>> ========================================= Connection profile details (ethernet) ========================================= -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name port speed duplex auto-negotiate mac-address cloned-mac-address generate-mac-address-mask mac-address-blacklist mtu s390-subchannels s390-nettype s390-options wake-on-lan wake-on-lan-password accept-all-mac-addresses --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -8241,19 +8353,19 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deac <<< -size: 6537 -location: src/tests/client/test-client.py:test_003()/171 +size: 6579 +location: src/tests/client/test-client.py:test_003()/173 cmd: $NMCLI --mode tabular --pretty --color yes con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 6357 bytes +stdout: 6399 bytes >>> =========================================== Szczegóły profilu połączenia (ethernet) =========================================== -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name port speed duplex auto-negotiate mac-address cloned-mac-address generate-mac-address-mask mac-address-blacklist mtu s390-subchannels s390-nettype s390-options wake-on-lan wake-on-lan-password accept-all-mac-addresses ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -8288,19 +8400,19 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deza <<< -size: 5519 -location: src/tests/client/test-client.py:test_003()/172 +size: 5561 +location: src/tests/client/test-client.py:test_003()/174 cmd: $NMCLI --mode tabular --pretty --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 -stdout: 5309 bytes +stdout: 5351 bytes >>> ========================================= Connection profile details (ethernet) ========================================= -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name port speed duplex auto-negotiate mac-address cloned-mac-address generate-mac-address-mask mac-address-blacklist mtu s390-subchannels s390-nettype s390-options wake-on-lan wake-on-lan-password accept-all-mac-addresses --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -8327,19 +8439,19 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deac <<< -size: 5591 -location: src/tests/client/test-client.py:test_003()/173 +size: 5633 +location: src/tests/client/test-client.py:test_003()/175 cmd: $NMCLI --mode tabular --pretty --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5371 bytes +stdout: 5413 bytes >>> =========================================== Szczegóły profilu połączenia (ethernet) =========================================== -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection ethernet UUID-ethernet-REPLACED-REPLACED-REPL -- 802-3-ethernet -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name port speed duplex auto-negotiate mac-address cloned-mac-address generate-mac-address-mask mac-address-blacklist mtu s390-subchannels s390-nettype s390-options wake-on-lan wake-on-lan-password accept-all-mac-addresses ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -8367,7 +8479,7 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deza <<< size: 4835 -location: src/tests/client/test-client.py:test_003()/174 +location: src/tests/client/test-client.py:test_003()/176 cmd: $NMCLI --mode tabular --pretty --color yes -f all dev show eth0 lang: C returncode: 0 @@ -8414,7 +8526,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{1,2,6} 5fcfd6 <<< size: 4901 -location: src/tests/client/test-client.py:test_003()/175 +location: src/tests/client/test-client.py:test_003()/177 cmd: $NMCLI --mode tabular --pretty --color yes -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -8461,7 +8573,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{1,2,6} 5fcfd6 <<< size: 1549 -location: src/tests/client/test-client.py:test_003()/176 +location: src/tests/client/test-client.py:test_003()/178 cmd: $NMCLI --mode tabular --terse -f ALL con lang: C returncode: 0 @@ -8477,7 +8589,7 @@ con-xx1:UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet:0:never:yes:0:no:/or <<< size: 1559 -location: src/tests/client/test-client.py:test_003()/177 +location: src/tests/client/test-client.py:test_003()/179 cmd: $NMCLI --mode tabular --terse -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -8493,7 +8605,7 @@ con-xx1:UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet:0:never:yes:0:no:/or <<< size: 437 -location: src/tests/client/test-client.py:test_003()/178 +location: src/tests/client/test-client.py:test_003()/180 cmd: $NMCLI --mode tabular --terse -f UUID,TYPE con lang: C returncode: 0 @@ -8508,7 +8620,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet <<< size: 447 -location: src/tests/client/test-client.py:test_003()/179 +location: src/tests/client/test-client.py:test_003()/181 cmd: $NMCLI --mode tabular --terse -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -8522,14 +8634,14 @@ UUID-con-gsm3-REPLACED-REPLACED-REPL:gsm UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet <<< -size: 865 -location: src/tests/client/test-client.py:test_003()/180 +size: 868 +location: src/tests/client/test-client.py:test_003()/182 cmd: $NMCLI --mode tabular --terse con s ethernet lang: C returncode: 0 -stdout: 709 bytes +stdout: 712 bytes >>> -connection:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL::802-3-ethernet::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL::802-3-ethernet::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 802-3-ethernet::0::no:::::auto::::default::-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: @@ -8539,14 +8651,14 @@ GENERAL:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:eth1:eth1:activated:no:no: GENERAL:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:eth0:eth0:deactivating:no:no::no:/org/freedesktop/NetworkManager/ActiveConnection/1:/org/freedesktop/NetworkManager/Settings/Connection/6:: <<< -size: 875 -location: src/tests/client/test-client.py:test_003()/181 +size: 878 +location: src/tests/client/test-client.py:test_003()/183 cmd: $NMCLI --mode tabular --terse con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 709 bytes +stdout: 712 bytes >>> -connection:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL::802-3-ethernet::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL::802-3-ethernet::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 802-3-ethernet::0::no:::::auto::::default::-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: @@ -8556,14 +8668,14 @@ GENERAL:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:eth1:eth1:activated:no:no: GENERAL:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:eth0:eth0:deactivating:no:no::no:/org/freedesktop/NetworkManager/ActiveConnection/1:/org/freedesktop/NetworkManager/Settings/Connection/6:: <<< -size: 713 -location: src/tests/client/test-client.py:test_003()/182 +size: 716 +location: src/tests/client/test-client.py:test_003()/184 cmd: $NMCLI --mode tabular --terse c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 -stdout: 517 bytes +stdout: 520 bytes >>> -connection:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL::802-3-ethernet::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL::802-3-ethernet::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 802-3-ethernet::0::no:::::auto::::default::-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: @@ -8571,14 +8683,14 @@ proxy:none:no:: GENERAL:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:eth0:eth0:deactivating:no:no::no:/org/freedesktop/NetworkManager/ActiveConnection/1:/org/freedesktop/NetworkManager/Settings/Connection/6:: <<< -size: 723 -location: src/tests/client/test-client.py:test_003()/183 +size: 726 +location: src/tests/client/test-client.py:test_003()/185 cmd: $NMCLI --mode tabular --terse c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 517 bytes +stdout: 520 bytes >>> -connection:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL::802-3-ethernet::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL::802-3-ethernet::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 802-3-ethernet::0::no:::::auto::::default::-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: @@ -8587,7 +8699,7 @@ GENERAL:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:eth0:eth0:deactivating:no: <<< size: 1451 -location: src/tests/client/test-client.py:test_003()/184 +location: src/tests/client/test-client.py:test_003()/186 cmd: $NMCLI --mode tabular --terse -f all dev show eth0 lang: C returncode: 0 @@ -8605,7 +8717,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{1,2,6}:5fcfd6d7 <<< size: 1461 -location: src/tests/client/test-client.py:test_003()/185 +location: src/tests/client/test-client.py:test_003()/187 cmd: $NMCLI --mode tabular --terse -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -8623,7 +8735,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{1,2,6}:5fcfd6d7 <<< size: 1831 -location: src/tests/client/test-client.py:test_003()/186 +location: src/tests/client/test-client.py:test_003()/188 cmd: $NMCLI --mode tabular --terse --color yes -f ALL con lang: C returncode: 0 @@ -8639,7 +8751,7 @@ con-xx1:UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet:0:never:yes:0:no:/or <<< size: 1841 -location: src/tests/client/test-client.py:test_003()/187 +location: src/tests/client/test-client.py:test_003()/189 cmd: $NMCLI --mode tabular --terse --color yes -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -8655,7 +8767,7 @@ con-xx1:UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet:0:never:yes:0:no:/or <<< size: 467 -location: src/tests/client/test-client.py:test_003()/188 +location: src/tests/client/test-client.py:test_003()/190 cmd: $NMCLI --mode tabular --terse --color yes -f UUID,TYPE con lang: C returncode: 0 @@ -8670,7 +8782,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet <<< size: 477 -location: src/tests/client/test-client.py:test_003()/189 +location: src/tests/client/test-client.py:test_003()/191 cmd: $NMCLI --mode tabular --terse --color yes -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -8684,14 +8796,14 @@ UUID-con-gsm3-REPLACED-REPLACED-REPL:gsm UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet <<< -size: 877 -location: src/tests/client/test-client.py:test_003()/190 +size: 880 +location: src/tests/client/test-client.py:test_003()/192 cmd: $NMCLI --mode tabular --terse --color yes con s ethernet lang: C returncode: 0 -stdout: 709 bytes +stdout: 712 bytes >>> -connection:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL::802-3-ethernet::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL::802-3-ethernet::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 802-3-ethernet::0::no:::::auto::::default::-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: @@ -8701,14 +8813,14 @@ GENERAL:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:eth1:eth1:activated:no:no: GENERAL:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:eth0:eth0:deactivating:no:no::no:/org/freedesktop/NetworkManager/ActiveConnection/1:/org/freedesktop/NetworkManager/Settings/Connection/6:: <<< -size: 887 -location: src/tests/client/test-client.py:test_003()/191 +size: 890 +location: src/tests/client/test-client.py:test_003()/193 cmd: $NMCLI --mode tabular --terse --color yes con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 709 bytes +stdout: 712 bytes >>> -connection:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL::802-3-ethernet::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL::802-3-ethernet::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 802-3-ethernet::0::no:::::auto::::default::-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: @@ -8718,14 +8830,14 @@ GENERAL:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:eth1:eth1:activated:no:no: GENERAL:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:eth0:eth0:deactivating:no:no::no:/org/freedesktop/NetworkManager/ActiveConnection/1:/org/freedesktop/NetworkManager/Settings/Connection/6:: <<< -size: 725 -location: src/tests/client/test-client.py:test_003()/192 +size: 728 +location: src/tests/client/test-client.py:test_003()/194 cmd: $NMCLI --mode tabular --terse --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 -stdout: 517 bytes +stdout: 520 bytes >>> -connection:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL::802-3-ethernet::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL::802-3-ethernet::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 802-3-ethernet::0::no:::::auto::::default::-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: @@ -8733,14 +8845,14 @@ proxy:none:no:: GENERAL:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:eth0:eth0:deactivating:no:no::no:/org/freedesktop/NetworkManager/ActiveConnection/1:/org/freedesktop/NetworkManager/Settings/Connection/6:: <<< -size: 735 -location: src/tests/client/test-client.py:test_003()/193 +size: 738 +location: src/tests/client/test-client.py:test_003()/195 cmd: $NMCLI --mode tabular --terse --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 517 bytes +stdout: 520 bytes >>> -connection:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL::802-3-ethernet::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL::802-3-ethernet::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 802-3-ethernet::0::no:::::auto::::default::-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: @@ -8749,7 +8861,7 @@ GENERAL:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:eth0:eth0:deactivating:no: <<< size: 1463 -location: src/tests/client/test-client.py:test_003()/194 +location: src/tests/client/test-client.py:test_003()/196 cmd: $NMCLI --mode tabular --terse --color yes -f all dev show eth0 lang: C returncode: 0 @@ -8767,7 +8879,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{1,2,6}:5fcfd6d7 <<< size: 1473 -location: src/tests/client/test-client.py:test_003()/195 +location: src/tests/client/test-client.py:test_003()/197 cmd: $NMCLI --mode tabular --terse --color yes -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -8785,7 +8897,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{1,2,6}:5fcfd6d7 <<< size: 5763 -location: src/tests/client/test-client.py:test_003()/196 +location: src/tests/client/test-client.py:test_003()/198 cmd: $NMCLI --mode multiline -f ALL con lang: C returncode: 0 @@ -8899,7 +9011,7 @@ FILENAME: /etc/NetworkManager/system-connections/c <<< size: 5791 -location: src/tests/client/test-client.py:test_003()/197 +location: src/tests/client/test-client.py:test_003()/199 cmd: $NMCLI --mode multiline -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -9013,7 +9125,7 @@ FILENAME: /etc/NetworkManager/system-connections/c <<< size: 893 -location: src/tests/client/test-client.py:test_003()/198 +location: src/tests/client/test-client.py:test_003()/200 cmd: $NMCLI --mode multiline -f UUID,TYPE con lang: C returncode: 0 @@ -9034,7 +9146,7 @@ TYPE: ethernet <<< size: 903 -location: src/tests/client/test-client.py:test_003()/199 +location: src/tests/client/test-client.py:test_003()/201 cmd: $NMCLI --mode multiline -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -9054,12 +9166,12 @@ UUID: UUID-con-xx1-REPLACED-REPLACED-REPLA TYPE: ethernet <<< -size: 5903 -location: src/tests/client/test-client.py:test_003()/200 +size: 5956 +location: src/tests/client/test-client.py:test_003()/202 cmd: $NMCLI --mode multiline con s ethernet lang: C returncode: 0 -stdout: 5752 bytes +stdout: 5805 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -9084,6 +9196,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -9185,12 +9298,12 @@ GENERAL.ZONE: -- GENERAL.MASTER-PATH: -- <<< -size: 5940 -location: src/tests/client/test-client.py:test_003()/201 +size: 5993 +location: src/tests/client/test-client.py:test_003()/203 cmd: $NMCLI --mode multiline con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 5779 bytes +stdout: 5832 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -9215,6 +9328,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -9316,12 +9430,12 @@ GENERAL.ZONE: -- GENERAL.MASTER-PATH: -- <<< -size: 5233 -location: src/tests/client/test-client.py:test_003()/202 +size: 5286 +location: src/tests/client/test-client.py:test_003()/204 cmd: $NMCLI --mode multiline c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 -stdout: 5042 bytes +stdout: 5095 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -9346,6 +9460,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -9433,12 +9548,12 @@ GENERAL.ZONE: -- GENERAL.MASTER-PATH: -- <<< -size: 5266 -location: src/tests/client/test-client.py:test_003()/203 +size: 5319 +location: src/tests/client/test-client.py:test_003()/205 cmd: $NMCLI --mode multiline c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5065 bytes +stdout: 5118 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -9463,6 +9578,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -9551,7 +9667,7 @@ GENERAL.MASTER-PATH: -- <<< size: 3810 -location: src/tests/client/test-client.py:test_003()/204 +location: src/tests/client/test-client.py:test_003()/206 cmd: $NMCLI --mode multiline -f all dev show eth0 lang: C returncode: 0 @@ -9623,7 +9739,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: UUID-ethernet-REPLACED-REPLACED-REPL | e <<< size: 3848 -location: src/tests/client/test-client.py:test_003()/205 +location: src/tests/client/test-client.py:test_003()/207 cmd: $NMCLI --mode multiline -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -9695,7 +9811,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: UUID-ethernet-REPLACED-REPLACED-REPL | e <<< size: 6045 -location: src/tests/client/test-client.py:test_003()/206 +location: src/tests/client/test-client.py:test_003()/208 cmd: $NMCLI --mode multiline --color yes -f ALL con lang: C returncode: 0 @@ -9809,7 +9925,7 @@ FILENAME: /etc/NetworkManager/system-connections/c <<< size: 6073 -location: src/tests/client/test-client.py:test_003()/207 +location: src/tests/client/test-client.py:test_003()/209 cmd: $NMCLI --mode multiline --color yes -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -9923,7 +10039,7 @@ FILENAME: /etc/NetworkManager/system-connections/c <<< size: 923 -location: src/tests/client/test-client.py:test_003()/208 +location: src/tests/client/test-client.py:test_003()/210 cmd: $NMCLI --mode multiline --color yes -f UUID,TYPE con lang: C returncode: 0 @@ -9944,7 +10060,7 @@ TYPE: ethernet <<< size: 933 -location: src/tests/client/test-client.py:test_003()/209 +location: src/tests/client/test-client.py:test_003()/211 cmd: $NMCLI --mode multiline --color yes -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -9964,12 +10080,12 @@ UUID: UUID-con-xx1-REPLACED-REPLACED-REPLA TYPE: ethernet <<< -size: 5915 -location: src/tests/client/test-client.py:test_003()/210 +size: 5968 +location: src/tests/client/test-client.py:test_003()/212 cmd: $NMCLI --mode multiline --color yes con s ethernet lang: C returncode: 0 -stdout: 5752 bytes +stdout: 5805 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -9994,6 +10110,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -10095,12 +10212,12 @@ GENERAL.ZONE: -- GENERAL.MASTER-PATH: -- <<< -size: 5952 -location: src/tests/client/test-client.py:test_003()/211 +size: 6005 +location: src/tests/client/test-client.py:test_003()/213 cmd: $NMCLI --mode multiline --color yes con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 5779 bytes +stdout: 5832 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -10125,6 +10242,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -10226,12 +10344,12 @@ GENERAL.ZONE: -- GENERAL.MASTER-PATH: -- <<< -size: 5245 -location: src/tests/client/test-client.py:test_003()/212 +size: 5298 +location: src/tests/client/test-client.py:test_003()/214 cmd: $NMCLI --mode multiline --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 -stdout: 5042 bytes +stdout: 5095 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -10256,6 +10374,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -10343,12 +10462,12 @@ GENERAL.ZONE: -- GENERAL.MASTER-PATH: -- <<< -size: 5278 -location: src/tests/client/test-client.py:test_003()/213 +size: 5331 +location: src/tests/client/test-client.py:test_003()/215 cmd: $NMCLI --mode multiline --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5065 bytes +stdout: 5118 bytes >>> connection.id: ethernet connection.uuid: UUID-ethernet-REPLACED-REPLACED-REPL @@ -10373,6 +10492,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-3-ethernet.port: -- 802-3-ethernet.speed: 0 @@ -10461,7 +10581,7 @@ GENERAL.MASTER-PATH: -- <<< size: 3822 -location: src/tests/client/test-client.py:test_003()/214 +location: src/tests/client/test-client.py:test_003()/216 cmd: $NMCLI --mode multiline --color yes -f all dev show eth0 lang: C returncode: 0 @@ -10533,7 +10653,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: UUID-ethernet-REPLACED-REPLACED-REPL | e <<< size: 3860 -location: src/tests/client/test-client.py:test_003()/215 +location: src/tests/client/test-client.py:test_003()/217 cmd: $NMCLI --mode multiline --color yes -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -10605,7 +10725,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: UUID-ethernet-REPLACED-REPLACED-REPL | e <<< size: 6549 -location: src/tests/client/test-client.py:test_003()/216 +location: src/tests/client/test-client.py:test_003()/218 cmd: $NMCLI --mode multiline --pretty -f ALL con lang: C returncode: 0 @@ -10729,7 +10849,7 @@ FILENAME: /etc/NetworkManager/system-connections/c <<< size: 6583 -location: src/tests/client/test-client.py:test_003()/217 +location: src/tests/client/test-client.py:test_003()/219 cmd: $NMCLI --mode multiline --pretty -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -10853,7 +10973,7 @@ FILENAME: /etc/NetworkManager/system-connections/c <<< size: 1600 -location: src/tests/client/test-client.py:test_003()/218 +location: src/tests/client/test-client.py:test_003()/220 cmd: $NMCLI --mode multiline --pretty -f UUID,TYPE con lang: C returncode: 0 @@ -10883,7 +11003,7 @@ TYPE: ethernet <<< size: 1616 -location: src/tests/client/test-client.py:test_003()/219 +location: src/tests/client/test-client.py:test_003()/221 cmd: $NMCLI --mode multiline --pretty -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -10912,12 +11032,12 @@ TYPE: ethernet ------------------------------------------------------------------------------- <<< -size: 7157 -location: src/tests/client/test-client.py:test_003()/220 +size: 7210 +location: src/tests/client/test-client.py:test_003()/222 cmd: $NMCLI --mode multiline --pretty con s ethernet lang: C returncode: 0 -stdout: 6997 bytes +stdout: 7050 bytes >>> =============================================================================== Connection profile details (ethernet) @@ -10945,6 +11065,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- 802-3-ethernet.port: -- @@ -11059,12 +11180,12 @@ GENERAL.MASTER-PATH: -- ------------------------------------------------------------------------------- <<< -size: 7213 -location: src/tests/client/test-client.py:test_003()/221 +size: 7266 +location: src/tests/client/test-client.py:test_003()/223 cmd: $NMCLI --mode multiline --pretty con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 7043 bytes +stdout: 7096 bytes >>> =============================================================================== Szczegóły profilu połączenia (ethernet) @@ -11092,6 +11213,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- 802-3-ethernet.port: -- @@ -11206,12 +11328,12 @@ GENERAL.MASTER-PATH: -- ------------------------------------------------------------------------------- <<< -size: 6174 -location: src/tests/client/test-client.py:test_003()/222 +size: 6227 +location: src/tests/client/test-client.py:test_003()/224 cmd: $NMCLI --mode multiline --pretty c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 -stdout: 5974 bytes +stdout: 6027 bytes >>> =============================================================================== Connection profile details (ethernet) @@ -11239,6 +11361,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- 802-3-ethernet.port: -- @@ -11335,12 +11458,12 @@ GENERAL.MASTER-PATH: -- ------------------------------------------------------------------------------- <<< -size: 6219 -location: src/tests/client/test-client.py:test_003()/223 +size: 6272 +location: src/tests/client/test-client.py:test_003()/225 cmd: $NMCLI --mode multiline --pretty c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 6009 bytes +stdout: 6062 bytes >>> =============================================================================== Szczegóły profilu połączenia (ethernet) @@ -11368,6 +11491,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- 802-3-ethernet.port: -- @@ -11465,7 +11589,7 @@ GENERAL.MASTER-PATH: -- <<< size: 4750 -location: src/tests/client/test-client.py:test_003()/224 +location: src/tests/client/test-client.py:test_003()/226 cmd: $NMCLI --mode multiline --pretty -f all dev show eth0 lang: C returncode: 0 @@ -11549,7 +11673,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: UUID-ethernet-REPLACED-REPLACED-REPL | e <<< size: 4794 -location: src/tests/client/test-client.py:test_003()/225 +location: src/tests/client/test-client.py:test_003()/227 cmd: $NMCLI --mode multiline --pretty -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -11633,7 +11757,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: UUID-ethernet-REPLACED-REPLACED-REPL | e <<< size: 6831 -location: src/tests/client/test-client.py:test_003()/226 +location: src/tests/client/test-client.py:test_003()/228 cmd: $NMCLI --mode multiline --pretty --color yes -f ALL con lang: C returncode: 0 @@ -11757,7 +11881,7 @@ FILENAME: /etc/NetworkManager/system-connections/c <<< size: 6865 -location: src/tests/client/test-client.py:test_003()/227 +location: src/tests/client/test-client.py:test_003()/229 cmd: $NMCLI --mode multiline --pretty --color yes -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -11881,7 +12005,7 @@ FILENAME: /etc/NetworkManager/system-connections/c <<< size: 1630 -location: src/tests/client/test-client.py:test_003()/228 +location: src/tests/client/test-client.py:test_003()/230 cmd: $NMCLI --mode multiline --pretty --color yes -f UUID,TYPE con lang: C returncode: 0 @@ -11911,7 +12035,7 @@ TYPE: ethernet <<< size: 1646 -location: src/tests/client/test-client.py:test_003()/229 +location: src/tests/client/test-client.py:test_003()/231 cmd: $NMCLI --mode multiline --pretty --color yes -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -11940,12 +12064,12 @@ TYPE: ethernet ------------------------------------------------------------------------------- <<< -size: 7169 -location: src/tests/client/test-client.py:test_003()/230 +size: 7222 +location: src/tests/client/test-client.py:test_003()/232 cmd: $NMCLI --mode multiline --pretty --color yes con s ethernet lang: C returncode: 0 -stdout: 6997 bytes +stdout: 7050 bytes >>> =============================================================================== Connection profile details (ethernet) @@ -11973,6 +12097,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- 802-3-ethernet.port: -- @@ -12087,12 +12212,12 @@ GENERAL.MASTER-PATH: -- ------------------------------------------------------------------------------- <<< -size: 7225 -location: src/tests/client/test-client.py:test_003()/231 +size: 7278 +location: src/tests/client/test-client.py:test_003()/233 cmd: $NMCLI --mode multiline --pretty --color yes con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 7043 bytes +stdout: 7096 bytes >>> =============================================================================== Szczegóły profilu połączenia (ethernet) @@ -12120,6 +12245,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- 802-3-ethernet.port: -- @@ -12234,12 +12360,12 @@ GENERAL.MASTER-PATH: -- ------------------------------------------------------------------------------- <<< -size: 6186 -location: src/tests/client/test-client.py:test_003()/232 +size: 6239 +location: src/tests/client/test-client.py:test_003()/234 cmd: $NMCLI --mode multiline --pretty --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 -stdout: 5974 bytes +stdout: 6027 bytes >>> =============================================================================== Connection profile details (ethernet) @@ -12267,6 +12393,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- 802-3-ethernet.port: -- @@ -12363,12 +12490,12 @@ GENERAL.MASTER-PATH: -- ------------------------------------------------------------------------------- <<< -size: 6231 -location: src/tests/client/test-client.py:test_003()/233 +size: 6284 +location: src/tests/client/test-client.py:test_003()/235 cmd: $NMCLI --mode multiline --pretty --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 6009 bytes +stdout: 6062 bytes >>> =============================================================================== Szczegóły profilu połączenia (ethernet) @@ -12396,6 +12523,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- 802-3-ethernet.port: -- @@ -12493,7 +12621,7 @@ GENERAL.MASTER-PATH: -- <<< size: 4762 -location: src/tests/client/test-client.py:test_003()/234 +location: src/tests/client/test-client.py:test_003()/236 cmd: $NMCLI --mode multiline --pretty --color yes -f all dev show eth0 lang: C returncode: 0 @@ -12577,7 +12705,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: UUID-ethernet-REPLACED-REPLACED-REPL | e <<< size: 4806 -location: src/tests/client/test-client.py:test_003()/235 +location: src/tests/client/test-client.py:test_003()/237 cmd: $NMCLI --mode multiline --pretty --color yes -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -12661,7 +12789,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: UUID-ethernet-REPLACED-REPLACED-REPL | e <<< size: 2524 -location: src/tests/client/test-client.py:test_003()/236 +location: src/tests/client/test-client.py:test_003()/238 cmd: $NMCLI --mode multiline --terse -f ALL con lang: C returncode: 0 @@ -12775,7 +12903,7 @@ FILENAME:/etc/NetworkManager/system-connections/con-xx1 <<< size: 2534 -location: src/tests/client/test-client.py:test_003()/237 +location: src/tests/client/test-client.py:test_003()/239 cmd: $NMCLI --mode multiline --terse -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -12889,7 +13017,7 @@ FILENAME:/etc/NetworkManager/system-connections/con-xx1 <<< size: 499 -location: src/tests/client/test-client.py:test_003()/238 +location: src/tests/client/test-client.py:test_003()/240 cmd: $NMCLI --mode multiline --terse -f UUID,TYPE con lang: C returncode: 0 @@ -12910,7 +13038,7 @@ TYPE:802-3-ethernet <<< size: 509 -location: src/tests/client/test-client.py:test_003()/239 +location: src/tests/client/test-client.py:test_003()/241 cmd: $NMCLI --mode multiline --terse -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -12930,12 +13058,12 @@ UUID:UUID-con-xx1-REPLACED-REPLACED-REPLA TYPE:802-3-ethernet <<< -size: 3183 -location: src/tests/client/test-client.py:test_003()/240 +size: 3210 +location: src/tests/client/test-client.py:test_003()/242 cmd: $NMCLI --mode multiline --terse con s ethernet lang: C returncode: 0 -stdout: 3024 bytes +stdout: 3051 bytes >>> connection.id:ethernet connection.uuid:UUID-ethernet-REPLACED-REPLACED-REPL @@ -12960,6 +13088,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 802-3-ethernet.port: 802-3-ethernet.speed:0 @@ -13061,12 +13190,12 @@ GENERAL.ZONE: GENERAL.MASTER-PATH: <<< -size: 3193 -location: src/tests/client/test-client.py:test_003()/241 +size: 3220 +location: src/tests/client/test-client.py:test_003()/243 cmd: $NMCLI --mode multiline --terse con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 3024 bytes +stdout: 3051 bytes >>> connection.id:ethernet connection.uuid:UUID-ethernet-REPLACED-REPLACED-REPL @@ -13091,6 +13220,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 802-3-ethernet.port: 802-3-ethernet.speed:0 @@ -13192,12 +13322,12 @@ GENERAL.ZONE: GENERAL.MASTER-PATH: <<< -size: 2833 -location: src/tests/client/test-client.py:test_003()/242 +size: 2860 +location: src/tests/client/test-client.py:test_003()/244 cmd: $NMCLI --mode multiline --terse c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 -stdout: 2634 bytes +stdout: 2661 bytes >>> connection.id:ethernet connection.uuid:UUID-ethernet-REPLACED-REPLACED-REPL @@ -13222,6 +13352,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 802-3-ethernet.port: 802-3-ethernet.speed:0 @@ -13309,12 +13440,12 @@ GENERAL.ZONE: GENERAL.MASTER-PATH: <<< -size: 2843 -location: src/tests/client/test-client.py:test_003()/243 +size: 2870 +location: src/tests/client/test-client.py:test_003()/245 cmd: $NMCLI --mode multiline --terse c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 2634 bytes +stdout: 2661 bytes >>> connection.id:ethernet connection.uuid:UUID-ethernet-REPLACED-REPLACED-REPL @@ -13339,6 +13470,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 802-3-ethernet.port: 802-3-ethernet.speed:0 @@ -13427,7 +13559,7 @@ GENERAL.MASTER-PATH: <<< size: 2443 -location: src/tests/client/test-client.py:test_003()/244 +location: src/tests/client/test-client.py:test_003()/246 cmd: $NMCLI --mode multiline --terse -f all dev show eth0 lang: C returncode: 0 @@ -13499,7 +13631,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]:UUID-ethernet-REPLACED-REPLACED-REPL | ethe <<< size: 2453 -location: src/tests/client/test-client.py:test_003()/245 +location: src/tests/client/test-client.py:test_003()/247 cmd: $NMCLI --mode multiline --terse -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -13571,7 +13703,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]:UUID-ethernet-REPLACED-REPLACED-REPL | ethe <<< size: 2806 -location: src/tests/client/test-client.py:test_003()/246 +location: src/tests/client/test-client.py:test_003()/248 cmd: $NMCLI --mode multiline --terse --color yes -f ALL con lang: C returncode: 0 @@ -13685,7 +13817,7 @@ FILENAME:/etc/NetworkManager/system-connections/con-xx1 <<< size: 2816 -location: src/tests/client/test-client.py:test_003()/247 +location: src/tests/client/test-client.py:test_003()/249 cmd: $NMCLI --mode multiline --terse --color yes -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -13799,7 +13931,7 @@ FILENAME:/etc/NetworkManager/system-connections/con-xx1 <<< size: 529 -location: src/tests/client/test-client.py:test_003()/248 +location: src/tests/client/test-client.py:test_003()/250 cmd: $NMCLI --mode multiline --terse --color yes -f UUID,TYPE con lang: C returncode: 0 @@ -13820,7 +13952,7 @@ TYPE:802-3-ethernet <<< size: 539 -location: src/tests/client/test-client.py:test_003()/249 +location: src/tests/client/test-client.py:test_003()/251 cmd: $NMCLI --mode multiline --terse --color yes -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -13840,12 +13972,12 @@ UUID:UUID-con-xx1-REPLACED-REPLACED-REPLA TYPE:802-3-ethernet <<< -size: 3195 -location: src/tests/client/test-client.py:test_003()/250 +size: 3222 +location: src/tests/client/test-client.py:test_003()/252 cmd: $NMCLI --mode multiline --terse --color yes con s ethernet lang: C returncode: 0 -stdout: 3024 bytes +stdout: 3051 bytes >>> connection.id:ethernet connection.uuid:UUID-ethernet-REPLACED-REPLACED-REPL @@ -13870,6 +14002,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 802-3-ethernet.port: 802-3-ethernet.speed:0 @@ -13971,12 +14104,12 @@ GENERAL.ZONE: GENERAL.MASTER-PATH: <<< -size: 3205 -location: src/tests/client/test-client.py:test_003()/251 +size: 3232 +location: src/tests/client/test-client.py:test_003()/253 cmd: $NMCLI --mode multiline --terse --color yes con s ethernet lang: pl_PL.UTF-8 returncode: 0 -stdout: 3024 bytes +stdout: 3051 bytes >>> connection.id:ethernet connection.uuid:UUID-ethernet-REPLACED-REPLACED-REPL @@ -14001,6 +14134,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 802-3-ethernet.port: 802-3-ethernet.speed:0 @@ -14102,12 +14236,12 @@ GENERAL.ZONE: GENERAL.MASTER-PATH: <<< -size: 2845 -location: src/tests/client/test-client.py:test_003()/252 +size: 2872 +location: src/tests/client/test-client.py:test_003()/254 cmd: $NMCLI --mode multiline --terse --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 -stdout: 2634 bytes +stdout: 2661 bytes >>> connection.id:ethernet connection.uuid:UUID-ethernet-REPLACED-REPLACED-REPL @@ -14132,6 +14266,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 802-3-ethernet.port: 802-3-ethernet.speed:0 @@ -14219,12 +14354,12 @@ GENERAL.ZONE: GENERAL.MASTER-PATH: <<< -size: 2855 -location: src/tests/client/test-client.py:test_003()/253 +size: 2882 +location: src/tests/client/test-client.py:test_003()/255 cmd: $NMCLI --mode multiline --terse --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 2634 bytes +stdout: 2661 bytes >>> connection.id:ethernet connection.uuid:UUID-ethernet-REPLACED-REPLACED-REPL @@ -14249,6 +14384,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 802-3-ethernet.port: 802-3-ethernet.speed:0 @@ -14337,7 +14473,7 @@ GENERAL.MASTER-PATH: <<< size: 2455 -location: src/tests/client/test-client.py:test_003()/254 +location: src/tests/client/test-client.py:test_003()/256 cmd: $NMCLI --mode multiline --terse --color yes -f all dev show eth0 lang: C returncode: 0 @@ -14409,7 +14545,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]:UUID-ethernet-REPLACED-REPLACED-REPL | ethe <<< size: 2465 -location: src/tests/client/test-client.py:test_003()/255 +location: src/tests/client/test-client.py:test_003()/257 cmd: $NMCLI --mode multiline --terse --color yes -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -14481,7 +14617,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]:UUID-ethernet-REPLACED-REPLACED-REPL | ethe <<< size: 2714 -location: src/tests/client/test-client.py:test_003()/256 +location: src/tests/client/test-client.py:test_003()/258 cmd: $NMCLI -f ALL con lang: C returncode: 0 @@ -14498,7 +14634,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 never <<< size: 2740 -location: src/tests/client/test-client.py:test_003()/257 +location: src/tests/client/test-client.py:test_003()/259 cmd: $NMCLI -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -14515,7 +14651,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 nigdy <<< size: 423 -location: src/tests/client/test-client.py:test_003()/258 +location: src/tests/client/test-client.py:test_003()/260 cmd: $NMCLI -f UUID,TYPE con lang: C returncode: 0 @@ -14530,7 +14666,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 433 -location: src/tests/client/test-client.py:test_003()/259 +location: src/tests/client/test-client.py:test_003()/261 cmd: $NMCLI -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -14545,7 +14681,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 179 -location: src/tests/client/test-client.py:test_003()/260 +location: src/tests/client/test-client.py:test_003()/262 cmd: $NMCLI con s ethernet lang: C returncode: 10 @@ -14555,7 +14691,7 @@ Error: ethernet - no such connection profile. <<< size: 201 -location: src/tests/client/test-client.py:test_003()/261 +location: src/tests/client/test-client.py:test_003()/263 cmd: $NMCLI con s ethernet lang: pl_PL.UTF-8 returncode: 10 @@ -14565,7 +14701,7 @@ Błąd: ethernet — nie ma takiego profilu połączenia. <<< size: 885 -location: src/tests/client/test-client.py:test_003()/262 +location: src/tests/client/test-client.py:test_003()/264 cmd: $NMCLI c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 @@ -14587,7 +14723,7 @@ GENERAL.MASTER-PATH: -- <<< size: 900 -location: src/tests/client/test-client.py:test_003()/263 +location: src/tests/client/test-client.py:test_003()/265 cmd: $NMCLI c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 @@ -14609,7 +14745,7 @@ GENERAL.MASTER-PATH: -- <<< size: 3813 -location: src/tests/client/test-client.py:test_003()/264 +location: src/tests/client/test-client.py:test_003()/266 cmd: $NMCLI -f all dev show eth0 lang: C returncode: 0 @@ -14681,7 +14817,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/NetworkMa <<< size: 3853 -location: src/tests/client/test-client.py:test_003()/265 +location: src/tests/client/test-client.py:test_003()/267 cmd: $NMCLI -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -14753,7 +14889,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/Network <<< size: 2996 -location: src/tests/client/test-client.py:test_003()/266 +location: src/tests/client/test-client.py:test_003()/268 cmd: $NMCLI --color yes -f ALL con lang: C returncode: 0 @@ -14770,7 +14906,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 never <<< size: 3022 -location: src/tests/client/test-client.py:test_003()/267 +location: src/tests/client/test-client.py:test_003()/269 cmd: $NMCLI --color yes -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -14787,7 +14923,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 nigdy <<< size: 435 -location: src/tests/client/test-client.py:test_003()/268 +location: src/tests/client/test-client.py:test_003()/270 cmd: $NMCLI --color yes -f UUID,TYPE con lang: C returncode: 0 @@ -14802,7 +14938,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 445 -location: src/tests/client/test-client.py:test_003()/269 +location: src/tests/client/test-client.py:test_003()/271 cmd: $NMCLI --color yes -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -14817,7 +14953,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 191 -location: src/tests/client/test-client.py:test_003()/270 +location: src/tests/client/test-client.py:test_003()/272 cmd: $NMCLI --color yes con s ethernet lang: C returncode: 10 @@ -14827,7 +14963,7 @@ Error: ethernet - no such connection profile. <<< size: 213 -location: src/tests/client/test-client.py:test_003()/271 +location: src/tests/client/test-client.py:test_003()/273 cmd: $NMCLI --color yes con s ethernet lang: pl_PL.UTF-8 returncode: 10 @@ -14837,7 +14973,7 @@ Błąd: ethernet — nie ma takiego profilu połączenia. <<< size: 897 -location: src/tests/client/test-client.py:test_003()/272 +location: src/tests/client/test-client.py:test_003()/274 cmd: $NMCLI --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 @@ -14859,7 +14995,7 @@ GENERAL.MASTER-PATH: -- <<< size: 912 -location: src/tests/client/test-client.py:test_003()/273 +location: src/tests/client/test-client.py:test_003()/275 cmd: $NMCLI --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 @@ -14881,7 +15017,7 @@ GENERAL.MASTER-PATH: -- <<< size: 3825 -location: src/tests/client/test-client.py:test_003()/274 +location: src/tests/client/test-client.py:test_003()/276 cmd: $NMCLI --color yes -f all dev show eth0 lang: C returncode: 0 @@ -14953,7 +15089,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/NetworkMa <<< size: 3865 -location: src/tests/client/test-client.py:test_003()/275 +location: src/tests/client/test-client.py:test_003()/277 cmd: $NMCLI --color yes -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -15025,7 +15161,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/Network <<< size: 3200 -location: src/tests/client/test-client.py:test_003()/276 +location: src/tests/client/test-client.py:test_003()/278 cmd: $NMCLI --pretty -f ALL con lang: C returncode: 0 @@ -15046,7 +15182,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 never <<< size: 3248 -location: src/tests/client/test-client.py:test_003()/277 +location: src/tests/client/test-client.py:test_003()/279 cmd: $NMCLI --pretty -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -15067,7 +15203,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 nigdy <<< size: 634 -location: src/tests/client/test-client.py:test_003()/278 +location: src/tests/client/test-client.py:test_003()/280 cmd: $NMCLI --pretty -f UUID,TYPE con lang: C returncode: 0 @@ -15086,7 +15222,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 664 -location: src/tests/client/test-client.py:test_003()/279 +location: src/tests/client/test-client.py:test_003()/281 cmd: $NMCLI --pretty -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -15105,7 +15241,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 188 -location: src/tests/client/test-client.py:test_003()/280 +location: src/tests/client/test-client.py:test_003()/282 cmd: $NMCLI --pretty con s ethernet lang: C returncode: 10 @@ -15115,7 +15251,7 @@ Error: ethernet - no such connection profile. <<< size: 210 -location: src/tests/client/test-client.py:test_003()/281 +location: src/tests/client/test-client.py:test_003()/283 cmd: $NMCLI --pretty con s ethernet lang: pl_PL.UTF-8 returncode: 10 @@ -15125,7 +15261,7 @@ Błąd: ethernet — nie ma takiego profilu połączenia. <<< size: 1421 -location: src/tests/client/test-client.py:test_003()/282 +location: src/tests/client/test-client.py:test_003()/284 cmd: $NMCLI --pretty c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 @@ -15154,7 +15290,7 @@ GENERAL.MASTER-PATH: -- <<< size: 1448 -location: src/tests/client/test-client.py:test_003()/283 +location: src/tests/client/test-client.py:test_003()/285 cmd: $NMCLI --pretty c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 @@ -15183,7 +15319,7 @@ GENERAL.MASTER-PATH: -- <<< size: 4753 -location: src/tests/client/test-client.py:test_003()/284 +location: src/tests/client/test-client.py:test_003()/286 cmd: $NMCLI --pretty -f all dev show eth0 lang: C returncode: 0 @@ -15267,7 +15403,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/NetworkMa <<< size: 4799 -location: src/tests/client/test-client.py:test_003()/285 +location: src/tests/client/test-client.py:test_003()/287 cmd: $NMCLI --pretty -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -15351,7 +15487,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/Network <<< size: 3482 -location: src/tests/client/test-client.py:test_003()/286 +location: src/tests/client/test-client.py:test_003()/288 cmd: $NMCLI --pretty --color yes -f ALL con lang: C returncode: 0 @@ -15372,7 +15508,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 never <<< size: 3530 -location: src/tests/client/test-client.py:test_003()/287 +location: src/tests/client/test-client.py:test_003()/289 cmd: $NMCLI --pretty --color yes -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -15393,7 +15529,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 nigdy <<< size: 646 -location: src/tests/client/test-client.py:test_003()/288 +location: src/tests/client/test-client.py:test_003()/290 cmd: $NMCLI --pretty --color yes -f UUID,TYPE con lang: C returncode: 0 @@ -15412,7 +15548,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 676 -location: src/tests/client/test-client.py:test_003()/289 +location: src/tests/client/test-client.py:test_003()/291 cmd: $NMCLI --pretty --color yes -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -15431,7 +15567,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 200 -location: src/tests/client/test-client.py:test_003()/290 +location: src/tests/client/test-client.py:test_003()/292 cmd: $NMCLI --pretty --color yes con s ethernet lang: C returncode: 10 @@ -15441,7 +15577,7 @@ Error: ethernet - no such connection profile. <<< size: 222 -location: src/tests/client/test-client.py:test_003()/291 +location: src/tests/client/test-client.py:test_003()/293 cmd: $NMCLI --pretty --color yes con s ethernet lang: pl_PL.UTF-8 returncode: 10 @@ -15451,7 +15587,7 @@ Błąd: ethernet — nie ma takiego profilu połączenia. <<< size: 1433 -location: src/tests/client/test-client.py:test_003()/292 +location: src/tests/client/test-client.py:test_003()/294 cmd: $NMCLI --pretty --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 @@ -15480,7 +15616,7 @@ GENERAL.MASTER-PATH: -- <<< size: 1460 -location: src/tests/client/test-client.py:test_003()/293 +location: src/tests/client/test-client.py:test_003()/295 cmd: $NMCLI --pretty --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 @@ -15509,7 +15645,7 @@ GENERAL.MASTER-PATH: -- <<< size: 4765 -location: src/tests/client/test-client.py:test_003()/294 +location: src/tests/client/test-client.py:test_003()/296 cmd: $NMCLI --pretty --color yes -f all dev show eth0 lang: C returncode: 0 @@ -15593,7 +15729,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/NetworkMa <<< size: 4811 -location: src/tests/client/test-client.py:test_003()/295 +location: src/tests/client/test-client.py:test_003()/297 cmd: $NMCLI --pretty --color yes -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -15677,7 +15813,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/Network <<< size: 1510 -location: src/tests/client/test-client.py:test_003()/296 +location: src/tests/client/test-client.py:test_003()/298 cmd: $NMCLI --terse -f ALL con lang: C returncode: 0 @@ -15693,7 +15829,7 @@ con-xx1:UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet:0:never:yes:0:no:/or <<< size: 1520 -location: src/tests/client/test-client.py:test_003()/297 +location: src/tests/client/test-client.py:test_003()/299 cmd: $NMCLI --terse -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -15709,7 +15845,7 @@ con-xx1:UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet:0:never:yes:0:no:/or <<< size: 370 -location: src/tests/client/test-client.py:test_003()/298 +location: src/tests/client/test-client.py:test_003()/300 cmd: $NMCLI --terse -f UUID,TYPE con lang: C returncode: 0 @@ -15723,7 +15859,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet <<< size: 380 -location: src/tests/client/test-client.py:test_003()/299 +location: src/tests/client/test-client.py:test_003()/301 cmd: $NMCLI --terse -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -15737,7 +15873,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet <<< size: 187 -location: src/tests/client/test-client.py:test_003()/300 +location: src/tests/client/test-client.py:test_003()/302 cmd: $NMCLI --terse con s ethernet lang: C returncode: 10 @@ -15747,7 +15883,7 @@ Error: ethernet - no such connection profile. <<< size: 209 -location: src/tests/client/test-client.py:test_003()/301 +location: src/tests/client/test-client.py:test_003()/303 cmd: $NMCLI --terse con s ethernet lang: pl_PL.UTF-8 returncode: 10 @@ -15757,7 +15893,7 @@ Błąd: ethernet — nie ma takiego profilu połączenia. <<< size: 573 -location: src/tests/client/test-client.py:test_003()/302 +location: src/tests/client/test-client.py:test_003()/304 cmd: $NMCLI --terse c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 @@ -15779,7 +15915,7 @@ GENERAL.MASTER-PATH: <<< size: 583 -location: src/tests/client/test-client.py:test_003()/303 +location: src/tests/client/test-client.py:test_003()/305 cmd: $NMCLI --terse c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 @@ -15801,7 +15937,7 @@ GENERAL.MASTER-PATH: <<< size: 2446 -location: src/tests/client/test-client.py:test_003()/304 +location: src/tests/client/test-client.py:test_003()/306 cmd: $NMCLI --terse -f all dev show eth0 lang: C returncode: 0 @@ -15873,7 +16009,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/NetworkManag <<< size: 2456 -location: src/tests/client/test-client.py:test_003()/305 +location: src/tests/client/test-client.py:test_003()/307 cmd: $NMCLI --terse -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -15945,7 +16081,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/NetworkManag <<< size: 1792 -location: src/tests/client/test-client.py:test_003()/306 +location: src/tests/client/test-client.py:test_003()/308 cmd: $NMCLI --terse --color yes -f ALL con lang: C returncode: 0 @@ -15961,7 +16097,7 @@ con-xx1:UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet:0:never:yes:0:no:/or <<< size: 1802 -location: src/tests/client/test-client.py:test_003()/307 +location: src/tests/client/test-client.py:test_003()/309 cmd: $NMCLI --terse --color yes -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -15977,7 +16113,7 @@ con-xx1:UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet:0:never:yes:0:no:/or <<< size: 382 -location: src/tests/client/test-client.py:test_003()/308 +location: src/tests/client/test-client.py:test_003()/310 cmd: $NMCLI --terse --color yes -f UUID,TYPE con lang: C returncode: 0 @@ -15991,7 +16127,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet <<< size: 392 -location: src/tests/client/test-client.py:test_003()/309 +location: src/tests/client/test-client.py:test_003()/311 cmd: $NMCLI --terse --color yes -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -16005,7 +16141,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet <<< size: 199 -location: src/tests/client/test-client.py:test_003()/310 +location: src/tests/client/test-client.py:test_003()/312 cmd: $NMCLI --terse --color yes con s ethernet lang: C returncode: 10 @@ -16015,7 +16151,7 @@ Error: ethernet - no such connection profile. <<< size: 221 -location: src/tests/client/test-client.py:test_003()/311 +location: src/tests/client/test-client.py:test_003()/313 cmd: $NMCLI --terse --color yes con s ethernet lang: pl_PL.UTF-8 returncode: 10 @@ -16025,7 +16161,7 @@ Błąd: ethernet — nie ma takiego profilu połączenia. <<< size: 585 -location: src/tests/client/test-client.py:test_003()/312 +location: src/tests/client/test-client.py:test_003()/314 cmd: $NMCLI --terse --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 @@ -16047,7 +16183,7 @@ GENERAL.MASTER-PATH: <<< size: 595 -location: src/tests/client/test-client.py:test_003()/313 +location: src/tests/client/test-client.py:test_003()/315 cmd: $NMCLI --terse --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 @@ -16069,7 +16205,7 @@ GENERAL.MASTER-PATH: <<< size: 2458 -location: src/tests/client/test-client.py:test_003()/314 +location: src/tests/client/test-client.py:test_003()/316 cmd: $NMCLI --terse --color yes -f all dev show eth0 lang: C returncode: 0 @@ -16141,7 +16277,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/NetworkManag <<< size: 2468 -location: src/tests/client/test-client.py:test_003()/315 +location: src/tests/client/test-client.py:test_003()/317 cmd: $NMCLI --terse --color yes -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -16213,7 +16349,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/NetworkManag <<< size: 2729 -location: src/tests/client/test-client.py:test_003()/316 +location: src/tests/client/test-client.py:test_003()/318 cmd: $NMCLI --mode tabular -f ALL con lang: C returncode: 0 @@ -16230,7 +16366,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 never <<< size: 2755 -location: src/tests/client/test-client.py:test_003()/317 +location: src/tests/client/test-client.py:test_003()/319 cmd: $NMCLI --mode tabular -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -16247,7 +16383,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 nigdy <<< size: 438 -location: src/tests/client/test-client.py:test_003()/318 +location: src/tests/client/test-client.py:test_003()/320 cmd: $NMCLI --mode tabular -f UUID,TYPE con lang: C returncode: 0 @@ -16262,7 +16398,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 448 -location: src/tests/client/test-client.py:test_003()/319 +location: src/tests/client/test-client.py:test_003()/321 cmd: $NMCLI --mode tabular -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -16277,7 +16413,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 194 -location: src/tests/client/test-client.py:test_003()/320 +location: src/tests/client/test-client.py:test_003()/322 cmd: $NMCLI --mode tabular con s ethernet lang: C returncode: 10 @@ -16287,7 +16423,7 @@ Error: ethernet - no such connection profile. <<< size: 216 -location: src/tests/client/test-client.py:test_003()/321 +location: src/tests/client/test-client.py:test_003()/323 cmd: $NMCLI --mode tabular con s ethernet lang: pl_PL.UTF-8 returncode: 10 @@ -16297,7 +16433,7 @@ Błąd: ethernet — nie ma takiego profilu połączenia. <<< size: 695 -location: src/tests/client/test-client.py:test_003()/322 +location: src/tests/client/test-client.py:test_003()/324 cmd: $NMCLI --mode tabular c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 @@ -16309,7 +16445,7 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deac <<< size: 709 -location: src/tests/client/test-client.py:test_003()/323 +location: src/tests/client/test-client.py:test_003()/325 cmd: $NMCLI --mode tabular c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 @@ -16321,7 +16457,7 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deza <<< size: 3247 -location: src/tests/client/test-client.py:test_003()/324 +location: src/tests/client/test-client.py:test_003()/326 cmd: $NMCLI --mode tabular -f all dev show eth0 lang: C returncode: 0 @@ -16356,7 +16492,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{1,2,6} 5fcfd6 <<< size: 3281 -location: src/tests/client/test-client.py:test_003()/325 +location: src/tests/client/test-client.py:test_003()/327 cmd: $NMCLI --mode tabular -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -16391,7 +16527,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{1,2,6} 5fcfd6 <<< size: 3011 -location: src/tests/client/test-client.py:test_003()/326 +location: src/tests/client/test-client.py:test_003()/328 cmd: $NMCLI --mode tabular --color yes -f ALL con lang: C returncode: 0 @@ -16408,7 +16544,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 never <<< size: 3037 -location: src/tests/client/test-client.py:test_003()/327 +location: src/tests/client/test-client.py:test_003()/329 cmd: $NMCLI --mode tabular --color yes -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -16425,7 +16561,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 nigdy <<< size: 450 -location: src/tests/client/test-client.py:test_003()/328 +location: src/tests/client/test-client.py:test_003()/330 cmd: $NMCLI --mode tabular --color yes -f UUID,TYPE con lang: C returncode: 0 @@ -16440,7 +16576,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 460 -location: src/tests/client/test-client.py:test_003()/329 +location: src/tests/client/test-client.py:test_003()/331 cmd: $NMCLI --mode tabular --color yes -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -16455,7 +16591,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 206 -location: src/tests/client/test-client.py:test_003()/330 +location: src/tests/client/test-client.py:test_003()/332 cmd: $NMCLI --mode tabular --color yes con s ethernet lang: C returncode: 10 @@ -16465,7 +16601,7 @@ Error: ethernet - no such connection profile. <<< size: 228 -location: src/tests/client/test-client.py:test_003()/331 +location: src/tests/client/test-client.py:test_003()/333 cmd: $NMCLI --mode tabular --color yes con s ethernet lang: pl_PL.UTF-8 returncode: 10 @@ -16475,7 +16611,7 @@ Błąd: ethernet — nie ma takiego profilu połączenia. <<< size: 707 -location: src/tests/client/test-client.py:test_003()/332 +location: src/tests/client/test-client.py:test_003()/334 cmd: $NMCLI --mode tabular --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 @@ -16487,7 +16623,7 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deac <<< size: 721 -location: src/tests/client/test-client.py:test_003()/333 +location: src/tests/client/test-client.py:test_003()/335 cmd: $NMCLI --mode tabular --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 @@ -16499,7 +16635,7 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deza <<< size: 3259 -location: src/tests/client/test-client.py:test_003()/334 +location: src/tests/client/test-client.py:test_003()/336 cmd: $NMCLI --mode tabular --color yes -f all dev show eth0 lang: C returncode: 0 @@ -16534,7 +16670,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{1,2,6} 5fcfd6 <<< size: 3293 -location: src/tests/client/test-client.py:test_003()/335 +location: src/tests/client/test-client.py:test_003()/337 cmd: $NMCLI --mode tabular --color yes -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -16569,7 +16705,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{1,2,6} 5fcfd6 <<< size: 3215 -location: src/tests/client/test-client.py:test_003()/336 +location: src/tests/client/test-client.py:test_003()/338 cmd: $NMCLI --mode tabular --pretty -f ALL con lang: C returncode: 0 @@ -16590,7 +16726,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 never <<< size: 3263 -location: src/tests/client/test-client.py:test_003()/337 +location: src/tests/client/test-client.py:test_003()/339 cmd: $NMCLI --mode tabular --pretty -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -16611,7 +16747,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 nigdy <<< size: 649 -location: src/tests/client/test-client.py:test_003()/338 +location: src/tests/client/test-client.py:test_003()/340 cmd: $NMCLI --mode tabular --pretty -f UUID,TYPE con lang: C returncode: 0 @@ -16630,7 +16766,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 679 -location: src/tests/client/test-client.py:test_003()/339 +location: src/tests/client/test-client.py:test_003()/341 cmd: $NMCLI --mode tabular --pretty -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -16649,7 +16785,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 203 -location: src/tests/client/test-client.py:test_003()/340 +location: src/tests/client/test-client.py:test_003()/342 cmd: $NMCLI --mode tabular --pretty con s ethernet lang: C returncode: 10 @@ -16659,7 +16795,7 @@ Error: ethernet - no such connection profile. <<< size: 225 -location: src/tests/client/test-client.py:test_003()/341 +location: src/tests/client/test-client.py:test_003()/343 cmd: $NMCLI --mode tabular --pretty con s ethernet lang: pl_PL.UTF-8 returncode: 10 @@ -16669,7 +16805,7 @@ Błąd: ethernet — nie ma takiego profilu połączenia. <<< size: 1261 -location: src/tests/client/test-client.py:test_003()/342 +location: src/tests/client/test-client.py:test_003()/344 cmd: $NMCLI --mode tabular --pretty c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 @@ -16688,7 +16824,7 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deac <<< size: 1306 -location: src/tests/client/test-client.py:test_003()/343 +location: src/tests/client/test-client.py:test_003()/345 cmd: $NMCLI --mode tabular --pretty c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 @@ -16707,7 +16843,7 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deza <<< size: 4883 -location: src/tests/client/test-client.py:test_003()/344 +location: src/tests/client/test-client.py:test_003()/346 cmd: $NMCLI --mode tabular --pretty -f all dev show eth0 lang: C returncode: 0 @@ -16754,7 +16890,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{1,2,6} 5fcfd6 <<< size: 4955 -location: src/tests/client/test-client.py:test_003()/345 +location: src/tests/client/test-client.py:test_003()/347 cmd: $NMCLI --mode tabular --pretty -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -16801,7 +16937,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{1,2,6} 5fcfd6 <<< size: 3497 -location: src/tests/client/test-client.py:test_003()/346 +location: src/tests/client/test-client.py:test_003()/348 cmd: $NMCLI --mode tabular --pretty --color yes -f ALL con lang: C returncode: 0 @@ -16822,7 +16958,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 never <<< size: 3545 -location: src/tests/client/test-client.py:test_003()/347 +location: src/tests/client/test-client.py:test_003()/349 cmd: $NMCLI --mode tabular --pretty --color yes -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -16843,7 +16979,7 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet 0 nigdy <<< size: 661 -location: src/tests/client/test-client.py:test_003()/348 +location: src/tests/client/test-client.py:test_003()/350 cmd: $NMCLI --mode tabular --pretty --color yes -f UUID,TYPE con lang: C returncode: 0 @@ -16862,7 +16998,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 691 -location: src/tests/client/test-client.py:test_003()/349 +location: src/tests/client/test-client.py:test_003()/351 cmd: $NMCLI --mode tabular --pretty --color yes -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -16881,7 +17017,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA ethernet <<< size: 215 -location: src/tests/client/test-client.py:test_003()/350 +location: src/tests/client/test-client.py:test_003()/352 cmd: $NMCLI --mode tabular --pretty --color yes con s ethernet lang: C returncode: 10 @@ -16891,7 +17027,7 @@ Error: ethernet - no such connection profile. <<< size: 237 -location: src/tests/client/test-client.py:test_003()/351 +location: src/tests/client/test-client.py:test_003()/353 cmd: $NMCLI --mode tabular --pretty --color yes con s ethernet lang: pl_PL.UTF-8 returncode: 10 @@ -16901,7 +17037,7 @@ Błąd: ethernet — nie ma takiego profilu połączenia. <<< size: 1273 -location: src/tests/client/test-client.py:test_003()/352 +location: src/tests/client/test-client.py:test_003()/354 cmd: $NMCLI --mode tabular --pretty --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 @@ -16920,7 +17056,7 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deac <<< size: 1318 -location: src/tests/client/test-client.py:test_003()/353 +location: src/tests/client/test-client.py:test_003()/355 cmd: $NMCLI --mode tabular --pretty --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 @@ -16939,7 +17075,7 @@ GENERAL ethernet UUID-ethernet-REPLACED-REPLACED-REPL eth0 eth0 deza <<< size: 4895 -location: src/tests/client/test-client.py:test_003()/354 +location: src/tests/client/test-client.py:test_003()/356 cmd: $NMCLI --mode tabular --pretty --color yes -f all dev show eth0 lang: C returncode: 0 @@ -16986,7 +17122,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{1,2,6} 5fcfd6 <<< size: 4967 -location: src/tests/client/test-client.py:test_003()/355 +location: src/tests/client/test-client.py:test_003()/357 cmd: $NMCLI --mode tabular --pretty --color yes -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -17033,7 +17169,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{1,2,6} 5fcfd6 <<< size: 1525 -location: src/tests/client/test-client.py:test_003()/356 +location: src/tests/client/test-client.py:test_003()/358 cmd: $NMCLI --mode tabular --terse -f ALL con lang: C returncode: 0 @@ -17049,7 +17185,7 @@ con-xx1:UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet:0:never:yes:0:no:/or <<< size: 1535 -location: src/tests/client/test-client.py:test_003()/357 +location: src/tests/client/test-client.py:test_003()/359 cmd: $NMCLI --mode tabular --terse -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -17065,7 +17201,7 @@ con-xx1:UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet:0:never:yes:0:no:/or <<< size: 385 -location: src/tests/client/test-client.py:test_003()/358 +location: src/tests/client/test-client.py:test_003()/360 cmd: $NMCLI --mode tabular --terse -f UUID,TYPE con lang: C returncode: 0 @@ -17079,7 +17215,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet <<< size: 395 -location: src/tests/client/test-client.py:test_003()/359 +location: src/tests/client/test-client.py:test_003()/361 cmd: $NMCLI --mode tabular --terse -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -17093,7 +17229,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet <<< size: 202 -location: src/tests/client/test-client.py:test_003()/360 +location: src/tests/client/test-client.py:test_003()/362 cmd: $NMCLI --mode tabular --terse con s ethernet lang: C returncode: 10 @@ -17103,7 +17239,7 @@ Error: ethernet - no such connection profile. <<< size: 224 -location: src/tests/client/test-client.py:test_003()/361 +location: src/tests/client/test-client.py:test_003()/363 cmd: $NMCLI --mode tabular --terse con s ethernet lang: pl_PL.UTF-8 returncode: 10 @@ -17113,7 +17249,7 @@ Błąd: ethernet — nie ma takiego profilu połączenia. <<< size: 390 -location: src/tests/client/test-client.py:test_003()/362 +location: src/tests/client/test-client.py:test_003()/364 cmd: $NMCLI --mode tabular --terse c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 @@ -17123,7 +17259,7 @@ GENERAL:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:eth0:eth0:deactivating:no: <<< size: 400 -location: src/tests/client/test-client.py:test_003()/363 +location: src/tests/client/test-client.py:test_003()/365 cmd: $NMCLI --mode tabular --terse c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 @@ -17133,7 +17269,7 @@ GENERAL:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:eth0:eth0:deactivating:no: <<< size: 1471 -location: src/tests/client/test-client.py:test_003()/364 +location: src/tests/client/test-client.py:test_003()/366 cmd: $NMCLI --mode tabular --terse -f all dev show eth0 lang: C returncode: 0 @@ -17151,7 +17287,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{1,2,6}:5fcfd6d7 <<< size: 1481 -location: src/tests/client/test-client.py:test_003()/365 +location: src/tests/client/test-client.py:test_003()/367 cmd: $NMCLI --mode tabular --terse -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -17169,7 +17305,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{1,2,6}:5fcfd6d7 <<< size: 1807 -location: src/tests/client/test-client.py:test_003()/366 +location: src/tests/client/test-client.py:test_003()/368 cmd: $NMCLI --mode tabular --terse --color yes -f ALL con lang: C returncode: 0 @@ -17185,7 +17321,7 @@ con-xx1:UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet:0:never:yes:0:no:/or <<< size: 1817 -location: src/tests/client/test-client.py:test_003()/367 +location: src/tests/client/test-client.py:test_003()/369 cmd: $NMCLI --mode tabular --terse --color yes -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -17201,7 +17337,7 @@ con-xx1:UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet:0:never:yes:0:no:/or <<< size: 397 -location: src/tests/client/test-client.py:test_003()/368 +location: src/tests/client/test-client.py:test_003()/370 cmd: $NMCLI --mode tabular --terse --color yes -f UUID,TYPE con lang: C returncode: 0 @@ -17215,7 +17351,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet <<< size: 407 -location: src/tests/client/test-client.py:test_003()/369 +location: src/tests/client/test-client.py:test_003()/371 cmd: $NMCLI --mode tabular --terse --color yes -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -17229,7 +17365,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA:802-3-ethernet <<< size: 214 -location: src/tests/client/test-client.py:test_003()/370 +location: src/tests/client/test-client.py:test_003()/372 cmd: $NMCLI --mode tabular --terse --color yes con s ethernet lang: C returncode: 10 @@ -17239,7 +17375,7 @@ Error: ethernet - no such connection profile. <<< size: 236 -location: src/tests/client/test-client.py:test_003()/371 +location: src/tests/client/test-client.py:test_003()/373 cmd: $NMCLI --mode tabular --terse --color yes con s ethernet lang: pl_PL.UTF-8 returncode: 10 @@ -17249,7 +17385,7 @@ Błąd: ethernet — nie ma takiego profilu połączenia. <<< size: 402 -location: src/tests/client/test-client.py:test_003()/372 +location: src/tests/client/test-client.py:test_003()/374 cmd: $NMCLI --mode tabular --terse --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 @@ -17259,7 +17395,7 @@ GENERAL:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:eth0:eth0:deactivating:no: <<< size: 412 -location: src/tests/client/test-client.py:test_003()/373 +location: src/tests/client/test-client.py:test_003()/375 cmd: $NMCLI --mode tabular --terse --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 @@ -17269,7 +17405,7 @@ GENERAL:ethernet:UUID-ethernet-REPLACED-REPLACED-REPL:eth0:eth0:deactivating:no: <<< size: 1483 -location: src/tests/client/test-client.py:test_003()/374 +location: src/tests/client/test-client.py:test_003()/376 cmd: $NMCLI --mode tabular --terse --color yes -f all dev show eth0 lang: C returncode: 0 @@ -17287,7 +17423,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{1,2,6}:5fcfd6d7 <<< size: 1493 -location: src/tests/client/test-client.py:test_003()/375 +location: src/tests/client/test-client.py:test_003()/377 cmd: $NMCLI --mode tabular --terse --color yes -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -17305,7 +17441,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{1,2,6}:5fcfd6d7 <<< size: 5759 -location: src/tests/client/test-client.py:test_003()/376 +location: src/tests/client/test-client.py:test_003()/378 cmd: $NMCLI --mode multiline -f ALL con lang: C returncode: 0 @@ -17419,7 +17555,7 @@ FILENAME: /etc/NetworkManager/system-connections/c <<< size: 5785 -location: src/tests/client/test-client.py:test_003()/377 +location: src/tests/client/test-client.py:test_003()/379 cmd: $NMCLI --mode multiline -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -17533,7 +17669,7 @@ FILENAME: /etc/NetworkManager/system-connections/c <<< size: 767 -location: src/tests/client/test-client.py:test_003()/378 +location: src/tests/client/test-client.py:test_003()/380 cmd: $NMCLI --mode multiline -f UUID,TYPE con lang: C returncode: 0 @@ -17552,7 +17688,7 @@ TYPE: ethernet <<< size: 777 -location: src/tests/client/test-client.py:test_003()/379 +location: src/tests/client/test-client.py:test_003()/381 cmd: $NMCLI --mode multiline -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -17571,7 +17707,7 @@ TYPE: ethernet <<< size: 196 -location: src/tests/client/test-client.py:test_003()/380 +location: src/tests/client/test-client.py:test_003()/382 cmd: $NMCLI --mode multiline con s ethernet lang: C returncode: 10 @@ -17581,7 +17717,7 @@ Error: ethernet - no such connection profile. <<< size: 218 -location: src/tests/client/test-client.py:test_003()/381 +location: src/tests/client/test-client.py:test_003()/383 cmd: $NMCLI --mode multiline con s ethernet lang: pl_PL.UTF-8 returncode: 10 @@ -17591,7 +17727,7 @@ Błąd: ethernet — nie ma takiego profilu połączenia. <<< size: 902 -location: src/tests/client/test-client.py:test_003()/382 +location: src/tests/client/test-client.py:test_003()/384 cmd: $NMCLI --mode multiline c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 @@ -17613,7 +17749,7 @@ GENERAL.MASTER-PATH: -- <<< size: 917 -location: src/tests/client/test-client.py:test_003()/383 +location: src/tests/client/test-client.py:test_003()/385 cmd: $NMCLI --mode multiline c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 @@ -17635,7 +17771,7 @@ GENERAL.MASTER-PATH: -- <<< size: 3830 -location: src/tests/client/test-client.py:test_003()/384 +location: src/tests/client/test-client.py:test_003()/386 cmd: $NMCLI --mode multiline -f all dev show eth0 lang: C returncode: 0 @@ -17707,7 +17843,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/NetworkMa <<< size: 3870 -location: src/tests/client/test-client.py:test_003()/385 +location: src/tests/client/test-client.py:test_003()/387 cmd: $NMCLI --mode multiline -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -17779,7 +17915,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/Network <<< size: 6041 -location: src/tests/client/test-client.py:test_003()/386 +location: src/tests/client/test-client.py:test_003()/388 cmd: $NMCLI --mode multiline --color yes -f ALL con lang: C returncode: 0 @@ -17893,7 +18029,7 @@ FILENAME: /etc/NetworkManager/system-connections/c <<< size: 6067 -location: src/tests/client/test-client.py:test_003()/387 +location: src/tests/client/test-client.py:test_003()/389 cmd: $NMCLI --mode multiline --color yes -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -18007,7 +18143,7 @@ FILENAME: /etc/NetworkManager/system-connections/c <<< size: 779 -location: src/tests/client/test-client.py:test_003()/388 +location: src/tests/client/test-client.py:test_003()/390 cmd: $NMCLI --mode multiline --color yes -f UUID,TYPE con lang: C returncode: 0 @@ -18026,7 +18162,7 @@ TYPE: ethernet <<< size: 789 -location: src/tests/client/test-client.py:test_003()/389 +location: src/tests/client/test-client.py:test_003()/391 cmd: $NMCLI --mode multiline --color yes -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -18045,7 +18181,7 @@ TYPE: ethernet <<< size: 208 -location: src/tests/client/test-client.py:test_003()/390 +location: src/tests/client/test-client.py:test_003()/392 cmd: $NMCLI --mode multiline --color yes con s ethernet lang: C returncode: 10 @@ -18055,7 +18191,7 @@ Error: ethernet - no such connection profile. <<< size: 230 -location: src/tests/client/test-client.py:test_003()/391 +location: src/tests/client/test-client.py:test_003()/393 cmd: $NMCLI --mode multiline --color yes con s ethernet lang: pl_PL.UTF-8 returncode: 10 @@ -18065,7 +18201,7 @@ Błąd: ethernet — nie ma takiego profilu połączenia. <<< size: 914 -location: src/tests/client/test-client.py:test_003()/392 +location: src/tests/client/test-client.py:test_003()/394 cmd: $NMCLI --mode multiline --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 @@ -18087,7 +18223,7 @@ GENERAL.MASTER-PATH: -- <<< size: 929 -location: src/tests/client/test-client.py:test_003()/393 +location: src/tests/client/test-client.py:test_003()/395 cmd: $NMCLI --mode multiline --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 @@ -18109,7 +18245,7 @@ GENERAL.MASTER-PATH: -- <<< size: 3842 -location: src/tests/client/test-client.py:test_003()/394 +location: src/tests/client/test-client.py:test_003()/396 cmd: $NMCLI --mode multiline --color yes -f all dev show eth0 lang: C returncode: 0 @@ -18181,7 +18317,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/NetworkMa <<< size: 3882 -location: src/tests/client/test-client.py:test_003()/395 +location: src/tests/client/test-client.py:test_003()/397 cmd: $NMCLI --mode multiline --color yes -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -18253,7 +18389,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/Network <<< size: 6545 -location: src/tests/client/test-client.py:test_003()/396 +location: src/tests/client/test-client.py:test_003()/398 cmd: $NMCLI --mode multiline --pretty -f ALL con lang: C returncode: 0 @@ -18377,7 +18513,7 @@ FILENAME: /etc/NetworkManager/system-connections/c <<< size: 6577 -location: src/tests/client/test-client.py:test_003()/397 +location: src/tests/client/test-client.py:test_003()/399 cmd: $NMCLI --mode multiline --pretty -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -18501,7 +18637,7 @@ FILENAME: /etc/NetworkManager/system-connections/c <<< size: 1394 -location: src/tests/client/test-client.py:test_003()/398 +location: src/tests/client/test-client.py:test_003()/400 cmd: $NMCLI --mode multiline --pretty -f UUID,TYPE con lang: C returncode: 0 @@ -18528,7 +18664,7 @@ TYPE: ethernet <<< size: 1410 -location: src/tests/client/test-client.py:test_003()/399 +location: src/tests/client/test-client.py:test_003()/401 cmd: $NMCLI --mode multiline --pretty -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -18555,7 +18691,7 @@ TYPE: ethernet <<< size: 205 -location: src/tests/client/test-client.py:test_003()/400 +location: src/tests/client/test-client.py:test_003()/402 cmd: $NMCLI --mode multiline --pretty con s ethernet lang: C returncode: 10 @@ -18565,7 +18701,7 @@ Error: ethernet - no such connection profile. <<< size: 227 -location: src/tests/client/test-client.py:test_003()/401 +location: src/tests/client/test-client.py:test_003()/403 cmd: $NMCLI --mode multiline --pretty con s ethernet lang: pl_PL.UTF-8 returncode: 10 @@ -18575,7 +18711,7 @@ Błąd: ethernet — nie ma takiego profilu połączenia. <<< size: 1438 -location: src/tests/client/test-client.py:test_003()/402 +location: src/tests/client/test-client.py:test_003()/404 cmd: $NMCLI --mode multiline --pretty c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 @@ -18604,7 +18740,7 @@ GENERAL.MASTER-PATH: -- <<< size: 1465 -location: src/tests/client/test-client.py:test_003()/403 +location: src/tests/client/test-client.py:test_003()/405 cmd: $NMCLI --mode multiline --pretty c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 @@ -18633,7 +18769,7 @@ GENERAL.MASTER-PATH: -- <<< size: 4770 -location: src/tests/client/test-client.py:test_003()/404 +location: src/tests/client/test-client.py:test_003()/406 cmd: $NMCLI --mode multiline --pretty -f all dev show eth0 lang: C returncode: 0 @@ -18717,7 +18853,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/NetworkMa <<< size: 4816 -location: src/tests/client/test-client.py:test_003()/405 +location: src/tests/client/test-client.py:test_003()/407 cmd: $NMCLI --mode multiline --pretty -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -18801,7 +18937,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/Network <<< size: 6827 -location: src/tests/client/test-client.py:test_003()/406 +location: src/tests/client/test-client.py:test_003()/408 cmd: $NMCLI --mode multiline --pretty --color yes -f ALL con lang: C returncode: 0 @@ -18925,7 +19061,7 @@ FILENAME: /etc/NetworkManager/system-connections/c <<< size: 6859 -location: src/tests/client/test-client.py:test_003()/407 +location: src/tests/client/test-client.py:test_003()/409 cmd: $NMCLI --mode multiline --pretty --color yes -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -19049,7 +19185,7 @@ FILENAME: /etc/NetworkManager/system-connections/c <<< size: 1406 -location: src/tests/client/test-client.py:test_003()/408 +location: src/tests/client/test-client.py:test_003()/410 cmd: $NMCLI --mode multiline --pretty --color yes -f UUID,TYPE con lang: C returncode: 0 @@ -19076,7 +19212,7 @@ TYPE: ethernet <<< size: 1422 -location: src/tests/client/test-client.py:test_003()/409 +location: src/tests/client/test-client.py:test_003()/411 cmd: $NMCLI --mode multiline --pretty --color yes -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -19103,7 +19239,7 @@ TYPE: ethernet <<< size: 217 -location: src/tests/client/test-client.py:test_003()/410 +location: src/tests/client/test-client.py:test_003()/412 cmd: $NMCLI --mode multiline --pretty --color yes con s ethernet lang: C returncode: 10 @@ -19113,7 +19249,7 @@ Error: ethernet - no such connection profile. <<< size: 239 -location: src/tests/client/test-client.py:test_003()/411 +location: src/tests/client/test-client.py:test_003()/413 cmd: $NMCLI --mode multiline --pretty --color yes con s ethernet lang: pl_PL.UTF-8 returncode: 10 @@ -19123,7 +19259,7 @@ Błąd: ethernet — nie ma takiego profilu połączenia. <<< size: 1450 -location: src/tests/client/test-client.py:test_003()/412 +location: src/tests/client/test-client.py:test_003()/414 cmd: $NMCLI --mode multiline --pretty --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 @@ -19152,7 +19288,7 @@ GENERAL.MASTER-PATH: -- <<< size: 1477 -location: src/tests/client/test-client.py:test_003()/413 +location: src/tests/client/test-client.py:test_003()/415 cmd: $NMCLI --mode multiline --pretty --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 @@ -19181,7 +19317,7 @@ GENERAL.MASTER-PATH: -- <<< size: 4782 -location: src/tests/client/test-client.py:test_003()/414 +location: src/tests/client/test-client.py:test_003()/416 cmd: $NMCLI --mode multiline --pretty --color yes -f all dev show eth0 lang: C returncode: 0 @@ -19265,7 +19401,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/NetworkMa <<< size: 4828 -location: src/tests/client/test-client.py:test_003()/415 +location: src/tests/client/test-client.py:test_003()/417 cmd: $NMCLI --mode multiline --pretty --color yes -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -19349,7 +19485,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/Network <<< size: 2500 -location: src/tests/client/test-client.py:test_003()/416 +location: src/tests/client/test-client.py:test_003()/418 cmd: $NMCLI --mode multiline --terse -f ALL con lang: C returncode: 0 @@ -19463,7 +19599,7 @@ FILENAME:/etc/NetworkManager/system-connections/con-xx1 <<< size: 2510 -location: src/tests/client/test-client.py:test_003()/417 +location: src/tests/client/test-client.py:test_003()/419 cmd: $NMCLI --mode multiline --terse -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -19577,7 +19713,7 @@ FILENAME:/etc/NetworkManager/system-connections/con-xx1 <<< size: 437 -location: src/tests/client/test-client.py:test_003()/418 +location: src/tests/client/test-client.py:test_003()/420 cmd: $NMCLI --mode multiline --terse -f UUID,TYPE con lang: C returncode: 0 @@ -19596,7 +19732,7 @@ TYPE:802-3-ethernet <<< size: 447 -location: src/tests/client/test-client.py:test_003()/419 +location: src/tests/client/test-client.py:test_003()/421 cmd: $NMCLI --mode multiline --terse -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -19615,7 +19751,7 @@ TYPE:802-3-ethernet <<< size: 204 -location: src/tests/client/test-client.py:test_003()/420 +location: src/tests/client/test-client.py:test_003()/422 cmd: $NMCLI --mode multiline --terse con s ethernet lang: C returncode: 10 @@ -19625,7 +19761,7 @@ Error: ethernet - no such connection profile. <<< size: 226 -location: src/tests/client/test-client.py:test_003()/421 +location: src/tests/client/test-client.py:test_003()/423 cmd: $NMCLI --mode multiline --terse con s ethernet lang: pl_PL.UTF-8 returncode: 10 @@ -19635,7 +19771,7 @@ Błąd: ethernet — nie ma takiego profilu połączenia. <<< size: 590 -location: src/tests/client/test-client.py:test_003()/422 +location: src/tests/client/test-client.py:test_003()/424 cmd: $NMCLI --mode multiline --terse c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 @@ -19657,7 +19793,7 @@ GENERAL.MASTER-PATH: <<< size: 600 -location: src/tests/client/test-client.py:test_003()/423 +location: src/tests/client/test-client.py:test_003()/425 cmd: $NMCLI --mode multiline --terse c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 @@ -19679,7 +19815,7 @@ GENERAL.MASTER-PATH: <<< size: 2463 -location: src/tests/client/test-client.py:test_003()/424 +location: src/tests/client/test-client.py:test_003()/426 cmd: $NMCLI --mode multiline --terse -f all dev show eth0 lang: C returncode: 0 @@ -19751,7 +19887,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/NetworkManag <<< size: 2473 -location: src/tests/client/test-client.py:test_003()/425 +location: src/tests/client/test-client.py:test_003()/427 cmd: $NMCLI --mode multiline --terse -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -19823,7 +19959,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/NetworkManag <<< size: 2782 -location: src/tests/client/test-client.py:test_003()/426 +location: src/tests/client/test-client.py:test_003()/428 cmd: $NMCLI --mode multiline --terse --color yes -f ALL con lang: C returncode: 0 @@ -19937,7 +20073,7 @@ FILENAME:/etc/NetworkManager/system-connections/con-xx1 <<< size: 2792 -location: src/tests/client/test-client.py:test_003()/427 +location: src/tests/client/test-client.py:test_003()/429 cmd: $NMCLI --mode multiline --terse --color yes -f ALL con lang: pl_PL.UTF-8 returncode: 0 @@ -20051,7 +20187,7 @@ FILENAME:/etc/NetworkManager/system-connections/con-xx1 <<< size: 449 -location: src/tests/client/test-client.py:test_003()/428 +location: src/tests/client/test-client.py:test_003()/430 cmd: $NMCLI --mode multiline --terse --color yes -f UUID,TYPE con lang: C returncode: 0 @@ -20070,7 +20206,7 @@ TYPE:802-3-ethernet <<< size: 459 -location: src/tests/client/test-client.py:test_003()/429 +location: src/tests/client/test-client.py:test_003()/431 cmd: $NMCLI --mode multiline --terse --color yes -f UUID,TYPE con lang: pl_PL.UTF-8 returncode: 0 @@ -20089,7 +20225,7 @@ TYPE:802-3-ethernet <<< size: 216 -location: src/tests/client/test-client.py:test_003()/430 +location: src/tests/client/test-client.py:test_003()/432 cmd: $NMCLI --mode multiline --terse --color yes con s ethernet lang: C returncode: 10 @@ -20099,7 +20235,7 @@ Error: ethernet - no such connection profile. <<< size: 238 -location: src/tests/client/test-client.py:test_003()/431 +location: src/tests/client/test-client.py:test_003()/433 cmd: $NMCLI --mode multiline --terse --color yes con s ethernet lang: pl_PL.UTF-8 returncode: 10 @@ -20109,7 +20245,7 @@ Błąd: ethernet — nie ma takiego profilu połączenia. <<< size: 602 -location: src/tests/client/test-client.py:test_003()/432 +location: src/tests/client/test-client.py:test_003()/434 cmd: $NMCLI --mode multiline --terse --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: C returncode: 0 @@ -20131,7 +20267,7 @@ GENERAL.MASTER-PATH: <<< size: 612 -location: src/tests/client/test-client.py:test_003()/433 +location: src/tests/client/test-client.py:test_003()/435 cmd: $NMCLI --mode multiline --terse --color yes c s /org/freedesktop/NetworkManager/ActiveConnection/1 lang: pl_PL.UTF-8 returncode: 0 @@ -20153,7 +20289,7 @@ GENERAL.MASTER-PATH: <<< size: 2475 -location: src/tests/client/test-client.py:test_003()/434 +location: src/tests/client/test-client.py:test_003()/436 cmd: $NMCLI --mode multiline --terse --color yes -f all dev show eth0 lang: C returncode: 0 @@ -20225,7 +20361,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[3]: | /org/freedesktop/NetworkManag <<< size: 2485 -location: src/tests/client/test-client.py:test_003()/435 +location: src/tests/client/test-client.py:test_003()/437 cmd: $NMCLI --mode multiline --terse --color yes -f all dev show eth0 lang: pl_PL.UTF-8 returncode: 0 diff --git a/src/tests/client/test-client.check-on-disk/test_004.expected b/src/tests/client/test-client.check-on-disk/test_004.expected index efa818f8..25d4f424 100644 --- a/src/tests/client/test-client.check-on-disk/test_004.expected +++ b/src/tests/client/test-client.check-on-disk/test_004.expected @@ -58,12 +58,12 @@ location: src/tests/client/test-client.py:test_004()/7 cmd: $NMCLI connection mod con-xx1 ipv4.addresses 192.168.77.5/24 ipv4.routes '2.3.4.5/32 192.168.77.1' ipv6.addresses 1:2:3:4::6/64 ipv6.routes 1:2:3:4:5:6::5/128 lang: C returncode: 0 -size: 4712 +size: 4765 location: src/tests/client/test-client.py:test_004()/8 cmd: $NMCLI con s con-xx1 lang: C returncode: 0 -stdout: 4581 bytes +stdout: 4634 bytes >>> connection.id: con-xx1 connection.uuid: UUID-con-xx1-REPLACED-REPLACED-REPLA @@ -88,6 +88,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-11-wireless.ssid: foobar 802-11-wireless.mode: infrastructure @@ -165,12 +166,12 @@ proxy.pac-url: -- proxy.pac-script: -- <<< -size: 4740 +size: 4793 location: src/tests/client/test-client.py:test_004()/9 cmd: $NMCLI con s con-xx1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 4599 bytes +stdout: 4652 bytes >>> connection.id: con-xx1 connection.uuid: UUID-con-xx1-REPLACED-REPLACED-REPLA @@ -195,6 +196,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 802-11-wireless.ssid: foobar 802-11-wireless.mode: infrastructure @@ -308,12 +310,12 @@ con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP vpn -- con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA wifi -- <<< -size: 4126 +size: 4179 location: src/tests/client/test-client.py:test_004()/13 cmd: $NMCLI con s con-vpn-1 lang: C returncode: 0 -stdout: 3992 bytes +stdout: 4045 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -338,6 +340,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -403,12 +406,12 @@ proxy.pac-url: -- proxy.pac-script: -- <<< -size: 4146 +size: 4199 location: src/tests/client/test-client.py:test_004()/14 cmd: $NMCLI con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 4002 bytes +stdout: 4055 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -433,6 +436,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -570,12 +574,12 @@ con-xx1 UUID-con-xx1-REPLACED-REPLACED-REPLA wifi wlan0 con-1 5fcfd6d7-1e63-3332-8826-a7eda103792d ethernet -- <<< -size: 5254 +size: 5307 location: src/tests/client/test-client.py:test_004()/21 cmd: $NMCLI con s con-vpn-1 lang: C returncode: 0 -stdout: 5120 bytes +stdout: 5173 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -600,6 +604,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -686,12 +691,12 @@ VPN.CFG[2]: key2 = val2 VPN.CFG[3]: key3 = val3 <<< -size: 5280 +size: 5333 location: src/tests/client/test-client.py:test_004()/22 cmd: $NMCLI con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5136 bytes +stdout: 5189 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -716,6 +721,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -802,12 +808,94 @@ VPN.CFG[2]: key2 = val2 VPN.CFG[3]: key3 = val3 <<< -size: 5260 +size: 786 location: src/tests/client/test-client.py:test_004()/23 +cmd: $NMCLI +lang: C +returncode: 0 +stdout: 668 bytes +>>> +con-vpn-1 VPN connection + VPN + +wlan0: connected to con-vpn-1 + "wlan0" + wifi (virtual), 13:E0:74:85:7C:D9, hw + VPN + +eth0: unavailable + "eth0" + ethernet (virtual), AB:B7:BF:E2:48:E8, hw + +eth1: unavailable + "eth1" + ethernet (virtual), E7:78:B1:93:2B:22, hw + +wlan1: unavailable + "wlan1" + wifi (virtual), 21:E9:64:81:8C:A8, hw + +wlan1: unavailable + "wlan1" + wifi (virtual), 71:52:AD:63:5C:7C, hw + +DNS configuration: + servers: 1.2.3.4 5.6.7.8 + +Use "nmcli device show" to get complete information about known devices and +"nmcli connection show" to get an overview on active connection profiles. + +Consult nmcli(1) and nmcli-examples(7) manual pages for complete usage details. + +<<< +size: 862 +location: src/tests/client/test-client.py:test_004()/24 +cmd: $NMCLI +lang: pl_PL.UTF-8 +returncode: 0 +stdout: 734 bytes +>>> +Połączenie VPN con-vpn-1 + VPN + +wlan0: połączono do con-vpn-1 + "wlan0" + wifi (virtual), 13:E0:74:85:7C:D9, sprzęt + VPN + +eth0: niedostępne + "eth0" + ethernet (virtual), AB:B7:BF:E2:48:E8, sprzęt + +eth1: niedostępne + "eth1" + ethernet (virtual), E7:78:B1:93:2B:22, sprzęt + +wlan1: niedostępne + "wlan1" + wifi (virtual), 21:E9:64:81:8C:A8, sprzęt + +wlan1: niedostępne + "wlan1" + wifi (virtual), 71:52:AD:63:5C:7C, sprzęt + +DNS configuration: + servers: 1.2.3.4 5.6.7.8 + +Polecenie „nmcli device show” wyświetli pełne informacje o znanych +urządzeniach, a „nmcli connection show” wyświetli przegląd aktywnych +profili połączeń. + +Strony podręcznika nmcli(1) i nmcli-examples(7) zawierają pełne informacje +o użyciu. + +<<< +size: 5313 +location: src/tests/client/test-client.py:test_004()/25 cmd: $NMCLI con s con-vpn-1 lang: C returncode: 0 -stdout: 5126 bytes +stdout: 5179 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -832,6 +920,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -918,12 +1007,12 @@ VPN.CFG[2]: key2 = val2 VPN.CFG[3]: key3 = val3 <<< -size: 5290 -location: src/tests/client/test-client.py:test_004()/24 +size: 5343 +location: src/tests/client/test-client.py:test_004()/26 cmd: $NMCLI con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5146 bytes +stdout: 5199 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -948,6 +1037,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -1034,12 +1124,12 @@ VPN.CFG[2]: key2 = val2 VPN.CFG[3]: key3 = val3 <<< -size: 5260 -location: src/tests/client/test-client.py:test_004()/25 +size: 5313 +location: src/tests/client/test-client.py:test_004()/27 cmd: $NMCLI con s con-vpn-1 lang: C returncode: 0 -stdout: 5126 bytes +stdout: 5179 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -1064,6 +1154,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -1150,12 +1241,12 @@ VPN.CFG[2]: key2 = val2 VPN.CFG[3]: key3 = val3 <<< -size: 5290 -location: src/tests/client/test-client.py:test_004()/26 +size: 5343 +location: src/tests/client/test-client.py:test_004()/28 cmd: $NMCLI con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5146 bytes +stdout: 5199 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -1180,6 +1271,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -1266,12 +1358,12 @@ VPN.CFG[2]: key2 = val2 VPN.CFG[3]: key3 = val3 <<< -size: 4133 -location: src/tests/client/test-client.py:test_004()/27 +size: 4186 +location: src/tests/client/test-client.py:test_004()/29 cmd: $NMCLI -f ALL con s con-vpn-1 lang: C returncode: 0 -stdout: 3992 bytes +stdout: 4045 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -1296,6 +1388,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -1361,12 +1454,12 @@ proxy.pac-url: -- proxy.pac-script: -- <<< -size: 4153 -location: src/tests/client/test-client.py:test_004()/28 +size: 4206 +location: src/tests/client/test-client.py:test_004()/30 cmd: $NMCLI -f ALL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 4002 bytes +stdout: 4055 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -1391,6 +1484,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -1457,7 +1551,7 @@ proxy.pac-script: -- <<< size: 474 -location: src/tests/client/test-client.py:test_004()/29 +location: src/tests/client/test-client.py:test_004()/31 cmd: $NMCLI -f VPN con s con-vpn-1 lang: C returncode: 0 @@ -1472,7 +1566,7 @@ vpn.timeout: 0 <<< size: 485 -location: src/tests/client/test-client.py:test_004()/30 +location: src/tests/client/test-client.py:test_004()/32 cmd: $NMCLI -f VPN con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -1487,7 +1581,7 @@ vpn.timeout: 0 <<< size: 857 -location: src/tests/client/test-client.py:test_004()/31 +location: src/tests/client/test-client.py:test_004()/33 cmd: $NMCLI -f GENERAL con s con-vpn-1 lang: C returncode: 0 @@ -1509,7 +1603,7 @@ GENERAL.MASTER-PATH: -- <<< size: 870 -location: src/tests/client/test-client.py:test_004()/32 +location: src/tests/client/test-client.py:test_004()/34 cmd: $NMCLI -f GENERAL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -1531,7 +1625,7 @@ GENERAL.MASTER-PATH: -- <<< size: 381 -location: src/tests/client/test-client.py:test_004()/33 +location: src/tests/client/test-client.py:test_004()/35 cmd: $NMCLI dev s lang: C returncode: 0 @@ -1546,7 +1640,7 @@ wlan1 wifi unavailable -- <<< size: 397 -location: src/tests/client/test-client.py:test_004()/34 +location: src/tests/client/test-client.py:test_004()/36 cmd: $NMCLI dev s lang: pl_PL.UTF-8 returncode: 0 @@ -1561,7 +1655,7 @@ wlan1 wifi niedostępne -- <<< size: 1408 -location: src/tests/client/test-client.py:test_004()/35 +location: src/tests/client/test-client.py:test_004()/37 cmd: $NMCLI -f all dev status lang: C returncode: 0 @@ -1576,7 +1670,7 @@ wlan1 wifi unavailable unknown unknown /org/freedesk <<< size: 1424 -location: src/tests/client/test-client.py:test_004()/36 +location: src/tests/client/test-client.py:test_004()/38 cmd: $NMCLI -f all dev status lang: pl_PL.UTF-8 returncode: 0 @@ -1591,7 +1685,7 @@ wlan1 wifi niedostępne nieznane nieznane /org/freedes <<< size: 8042 -location: src/tests/client/test-client.py:test_004()/37 +location: src/tests/client/test-client.py:test_004()/39 cmd: $NMCLI dev show lang: C returncode: 0 @@ -1737,7 +1831,7 @@ IP6.DOMAIN[1]: sear6.fo.x.y <<< size: 8074 -location: src/tests/client/test-client.py:test_004()/38 +location: src/tests/client/test-client.py:test_004()/40 cmd: $NMCLI dev show lang: pl_PL.UTF-8 returncode: 0 @@ -1883,7 +1977,7 @@ IP6.DOMAIN[1]: sear6.fo.x.y <<< size: 22653 -location: src/tests/client/test-client.py:test_004()/39 +location: src/tests/client/test-client.py:test_004()/41 cmd: $NMCLI -f all dev show lang: C returncode: 0 @@ -2312,7 +2406,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 22821 -location: src/tests/client/test-client.py:test_004()/40 +location: src/tests/client/test-client.py:test_004()/42 cmd: $NMCLI -f all dev show lang: pl_PL.UTF-8 returncode: 0 @@ -2741,7 +2835,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 1495 -location: src/tests/client/test-client.py:test_004()/41 +location: src/tests/client/test-client.py:test_004()/43 cmd: $NMCLI dev show wlan0 lang: C returncode: 0 @@ -2774,7 +2868,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 1507 -location: src/tests/client/test-client.py:test_004()/42 +location: src/tests/client/test-client.py:test_004()/44 cmd: $NMCLI dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -2807,7 +2901,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 5406 -location: src/tests/client/test-client.py:test_004()/43 +location: src/tests/client/test-client.py:test_004()/45 cmd: $NMCLI -f all dev show wlan0 lang: C returncode: 0 @@ -2918,7 +3012,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 5467 -location: src/tests/client/test-client.py:test_004()/44 +location: src/tests/client/test-client.py:test_004()/46 cmd: $NMCLI -f all dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -3029,7 +3123,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 2171 -location: src/tests/client/test-client.py:test_004()/45 +location: src/tests/client/test-client.py:test_004()/47 cmd: $NMCLI -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -3078,7 +3172,7 @@ WIFI-PROPERTIES.IBSS-RSN: no <<< size: 2198 -location: src/tests/client/test-client.py:test_004()/46 +location: src/tests/client/test-client.py:test_004()/48 cmd: $NMCLI -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -3127,7 +3221,7 @@ WIFI-PROPERTIES.IBSS-RSN: nie <<< size: 2171 -location: src/tests/client/test-client.py:test_004()/47 +location: src/tests/client/test-client.py:test_004()/49 cmd: $NMCLI -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -3176,7 +3270,7 @@ WIFI-PROPERTIES.IBSS-RSN: no <<< size: 2198 -location: src/tests/client/test-client.py:test_004()/48 +location: src/tests/client/test-client.py:test_004()/50 cmd: $NMCLI -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -3225,7 +3319,7 @@ WIFI-PROPERTIES.IBSS-RSN: nie <<< size: 512 -location: src/tests/client/test-client.py:test_004()/49 +location: src/tests/client/test-client.py:test_004()/51 cmd: $NMCLI -f DEVICE,TYPE,DBUS-PATH dev lang: C returncode: 0 @@ -3240,7 +3334,7 @@ wlan1 wifi /org/freedesktop/NetworkManager/Devices/5 <<< size: 522 -location: src/tests/client/test-client.py:test_004()/50 +location: src/tests/client/test-client.py:test_004()/52 cmd: $NMCLI -f DEVICE,TYPE,DBUS-PATH dev lang: pl_PL.UTF-8 returncode: 0 @@ -3255,7 +3349,7 @@ wlan1 wifi /org/freedesktop/NetworkManager/Devices/5 <<< size: 1982 -location: src/tests/client/test-client.py:test_004()/51 +location: src/tests/client/test-client.py:test_004()/53 cmd: $NMCLI -f ALL device wifi list lang: C returncode: 0 @@ -3273,7 +3367,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 2050 -location: src/tests/client/test-client.py:test_004()/52 +location: src/tests/client/test-client.py:test_004()/54 cmd: $NMCLI -f ALL device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -3291,7 +3385,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 737 -location: src/tests/client/test-client.py:test_004()/53 +location: src/tests/client/test-client.py:test_004()/55 cmd: $NMCLI -f COMMON device wifi list lang: C returncode: 0 @@ -3309,7 +3403,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY <<< size: 797 -location: src/tests/client/test-client.py:test_004()/54 +location: src/tests/client/test-client.py:test_004()/56 cmd: $NMCLI -f COMMON device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -3327,7 +3421,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY <<< size: 2095 -location: src/tests/client/test-client.py:test_004()/55 +location: src/tests/client/test-client.py:test_004()/57 cmd: $NMCLI -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: C returncode: 0 @@ -3345,7 +3439,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 2163 -location: src/tests/client/test-client.py:test_004()/56 +location: src/tests/client/test-client.py:test_004()/58 cmd: $NMCLI -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -3363,7 +3457,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 735 -location: src/tests/client/test-client.py:test_004()/57 +location: src/tests/client/test-client.py:test_004()/59 cmd: $NMCLI -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -3376,7 +3470,7 @@ AP[1] wlan0-ap-2 776C616E302D61702D32 C0:E2:BE:E8:EF:B6 Infra 1 2412 MH <<< size: 763 -location: src/tests/client/test-client.py:test_004()/58 +location: src/tests/client/test-client.py:test_004()/60 cmd: $NMCLI -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -3389,7 +3483,7 @@ AP[1] wlan0-ap-2 776C616E302D61702D32 C0:E2:BE:E8:EF:B6 Infrastruktura 1 <<< size: 346 -location: src/tests/client/test-client.py:test_004()/59 +location: src/tests/client/test-client.py:test_004()/61 cmd: $NMCLI -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -3402,7 +3496,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SEC <<< size: 372 -location: src/tests/client/test-client.py:test_004()/60 +location: src/tests/client/test-client.py:test_004()/62 cmd: $NMCLI -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -3415,7 +3509,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BA <<< size: 848 -location: src/tests/client/test-client.py:test_004()/61 +location: src/tests/client/test-client.py:test_004()/63 cmd: $NMCLI -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -3428,7 +3522,7 @@ AP[1] wlan0-ap-2 776C616E302D61702D32 C0:E2:BE:E8:EF:B6 Infra 1 2412 MH <<< size: 876 -location: src/tests/client/test-client.py:test_004()/62 +location: src/tests/client/test-client.py:test_004()/64 cmd: $NMCLI -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -3441,7 +3535,7 @@ AP[1] wlan0-ap-2 776C616E302D61702D32 C0:E2:BE:E8:EF:B6 Infrastruktura 1 <<< size: 5409 -location: src/tests/client/test-client.py:test_004()/63 +location: src/tests/client/test-client.py:test_004()/65 cmd: $NMCLI -f ALL device show wlan0 lang: C returncode: 0 @@ -3552,7 +3646,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 5470 -location: src/tests/client/test-client.py:test_004()/64 +location: src/tests/client/test-client.py:test_004()/66 cmd: $NMCLI -f ALL device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -3663,7 +3757,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 1508 -location: src/tests/client/test-client.py:test_004()/65 +location: src/tests/client/test-client.py:test_004()/67 cmd: $NMCLI -f COMMON device show wlan0 lang: C returncode: 0 @@ -3696,7 +3790,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 1520 -location: src/tests/client/test-client.py:test_004()/66 +location: src/tests/client/test-client.py:test_004()/68 cmd: $NMCLI -f COMMON device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -3729,7 +3823,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 5373 -location: src/tests/client/test-client.py:test_004()/67 +location: src/tests/client/test-client.py:test_004()/69 cmd: $NMCLI -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: C returncode: 0 @@ -3836,7 +3930,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 5432 -location: src/tests/client/test-client.py:test_004()/68 +location: src/tests/client/test-client.py:test_004()/70 cmd: $NMCLI -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -3943,7 +4037,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 1432 -location: src/tests/client/test-client.py:test_004()/69 +location: src/tests/client/test-client.py:test_004()/71 cmd: $NMCLI dev lldp list ifname eth0 lang: C returncode: 0 @@ -3973,7 +4067,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES: 40 (wlan-access-point,telephone) <<< size: 1442 -location: src/tests/client/test-client.py:test_004()/70 +location: src/tests/client/test-client.py:test_004()/72 cmd: $NMCLI dev lldp list ifname eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -4003,7 +4097,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES: 40 (wlan-access-point,telephone) <<< size: 1064 -location: src/tests/client/test-client.py:test_004()/71 +location: src/tests/client/test-client.py:test_004()/73 cmd: $NMCLI -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: C returncode: 0 @@ -4027,7 +4121,7 @@ connection.interface-name: -- <<< size: 1074 -location: src/tests/client/test-client.py:test_004()/72 +location: src/tests/client/test-client.py:test_004()/74 cmd: $NMCLI -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: pl_PL.UTF-8 returncode: 0 @@ -4050,12 +4144,12 @@ connection.type: 802-11-wireless connection.interface-name: -- <<< -size: 5272 -location: src/tests/client/test-client.py:test_004()/73 +size: 5325 +location: src/tests/client/test-client.py:test_004()/75 cmd: $NMCLI --color yes con s con-vpn-1 lang: C returncode: 0 -stdout: 5126 bytes +stdout: 5179 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -4080,6 +4174,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -4166,12 +4261,12 @@ VPN.CFG[2]: key2 = val2 VPN.CFG[3]: key3 = val3 <<< -size: 5302 -location: src/tests/client/test-client.py:test_004()/74 +size: 5355 +location: src/tests/client/test-client.py:test_004()/76 cmd: $NMCLI --color yes con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5146 bytes +stdout: 5199 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -4196,6 +4291,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -4282,12 +4378,12 @@ VPN.CFG[2]: key2 = val2 VPN.CFG[3]: key3 = val3 <<< -size: 5272 -location: src/tests/client/test-client.py:test_004()/75 +size: 5325 +location: src/tests/client/test-client.py:test_004()/77 cmd: $NMCLI --color yes con s con-vpn-1 lang: C returncode: 0 -stdout: 5126 bytes +stdout: 5179 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -4312,6 +4408,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -4398,12 +4495,12 @@ VPN.CFG[2]: key2 = val2 VPN.CFG[3]: key3 = val3 <<< -size: 5302 -location: src/tests/client/test-client.py:test_004()/76 +size: 5355 +location: src/tests/client/test-client.py:test_004()/78 cmd: $NMCLI --color yes con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5146 bytes +stdout: 5199 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -4428,6 +4525,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -4514,12 +4612,12 @@ VPN.CFG[2]: key2 = val2 VPN.CFG[3]: key3 = val3 <<< -size: 4145 -location: src/tests/client/test-client.py:test_004()/77 +size: 4198 +location: src/tests/client/test-client.py:test_004()/79 cmd: $NMCLI --color yes -f ALL con s con-vpn-1 lang: C returncode: 0 -stdout: 3992 bytes +stdout: 4045 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -4544,6 +4642,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -4609,12 +4708,12 @@ proxy.pac-url: -- proxy.pac-script: -- <<< -size: 4165 -location: src/tests/client/test-client.py:test_004()/78 +size: 4218 +location: src/tests/client/test-client.py:test_004()/80 cmd: $NMCLI --color yes -f ALL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 4002 bytes +stdout: 4055 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -4639,6 +4738,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -4705,7 +4805,7 @@ proxy.pac-script: -- <<< size: 486 -location: src/tests/client/test-client.py:test_004()/79 +location: src/tests/client/test-client.py:test_004()/81 cmd: $NMCLI --color yes -f VPN con s con-vpn-1 lang: C returncode: 0 @@ -4720,7 +4820,7 @@ vpn.timeout: 0 <<< size: 497 -location: src/tests/client/test-client.py:test_004()/80 +location: src/tests/client/test-client.py:test_004()/82 cmd: $NMCLI --color yes -f VPN con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -4735,7 +4835,7 @@ vpn.timeout: 0 <<< size: 869 -location: src/tests/client/test-client.py:test_004()/81 +location: src/tests/client/test-client.py:test_004()/83 cmd: $NMCLI --color yes -f GENERAL con s con-vpn-1 lang: C returncode: 0 @@ -4757,7 +4857,7 @@ GENERAL.MASTER-PATH: -- <<< size: 882 -location: src/tests/client/test-client.py:test_004()/82 +location: src/tests/client/test-client.py:test_004()/84 cmd: $NMCLI --color yes -f GENERAL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -4779,7 +4879,7 @@ GENERAL.MASTER-PATH: -- <<< size: 557 -location: src/tests/client/test-client.py:test_004()/83 +location: src/tests/client/test-client.py:test_004()/85 cmd: $NMCLI --color yes dev s lang: C returncode: 0 @@ -4794,7 +4894,7 @@ DEVICE TYPE STATE CONNECTION <<< size: 573 -location: src/tests/client/test-client.py:test_004()/84 +location: src/tests/client/test-client.py:test_004()/86 cmd: $NMCLI --color yes dev s lang: pl_PL.UTF-8 returncode: 0 @@ -4809,7 +4909,7 @@ DEVICE TYPE STATE CONNECTION <<< size: 1789 -location: src/tests/client/test-client.py:test_004()/85 +location: src/tests/client/test-client.py:test_004()/87 cmd: $NMCLI --color yes -f all dev status lang: C returncode: 0 @@ -4824,7 +4924,7 @@ DEVICE TYPE STATE IP4-CONNECTIVITY IP6-CONNECTIVITY DBUS-PATH <<< size: 1805 -location: src/tests/client/test-client.py:test_004()/86 +location: src/tests/client/test-client.py:test_004()/88 cmd: $NMCLI --color yes -f all dev status lang: pl_PL.UTF-8 returncode: 0 @@ -4839,7 +4939,7 @@ DEVICE TYPE STATE IP4-CONNECTIVITY IP6-CONNECTIVITY DBUS-PATH <<< size: 8054 -location: src/tests/client/test-client.py:test_004()/87 +location: src/tests/client/test-client.py:test_004()/89 cmd: $NMCLI --color yes dev show lang: C returncode: 0 @@ -4985,7 +5085,7 @@ IP6.DOMAIN[1]: sear6.fo.x.y <<< size: 8086 -location: src/tests/client/test-client.py:test_004()/88 +location: src/tests/client/test-client.py:test_004()/90 cmd: $NMCLI --color yes dev show lang: pl_PL.UTF-8 returncode: 0 @@ -5131,7 +5231,7 @@ IP6.DOMAIN[1]: sear6.fo.x.y <<< size: 22989 -location: src/tests/client/test-client.py:test_004()/89 +location: src/tests/client/test-client.py:test_004()/91 cmd: $NMCLI --color yes -f all dev show lang: C returncode: 0 @@ -5560,7 +5660,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 23157 -location: src/tests/client/test-client.py:test_004()/90 +location: src/tests/client/test-client.py:test_004()/92 cmd: $NMCLI --color yes -f all dev show lang: pl_PL.UTF-8 returncode: 0 @@ -5989,7 +6089,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 1507 -location: src/tests/client/test-client.py:test_004()/91 +location: src/tests/client/test-client.py:test_004()/93 cmd: $NMCLI --color yes dev show wlan0 lang: C returncode: 0 @@ -6022,7 +6122,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 1519 -location: src/tests/client/test-client.py:test_004()/92 +location: src/tests/client/test-client.py:test_004()/94 cmd: $NMCLI --color yes dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -6055,7 +6155,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 5661 -location: src/tests/client/test-client.py:test_004()/93 +location: src/tests/client/test-client.py:test_004()/95 cmd: $NMCLI --color yes -f all dev show wlan0 lang: C returncode: 0 @@ -6166,7 +6266,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 5722 -location: src/tests/client/test-client.py:test_004()/94 +location: src/tests/client/test-client.py:test_004()/96 cmd: $NMCLI --color yes -f all dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -6277,7 +6377,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 2183 -location: src/tests/client/test-client.py:test_004()/95 +location: src/tests/client/test-client.py:test_004()/97 cmd: $NMCLI --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -6326,7 +6426,7 @@ WIFI-PROPERTIES.IBSS-RSN: no <<< size: 2210 -location: src/tests/client/test-client.py:test_004()/96 +location: src/tests/client/test-client.py:test_004()/98 cmd: $NMCLI --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -6375,7 +6475,7 @@ WIFI-PROPERTIES.IBSS-RSN: nie <<< size: 2183 -location: src/tests/client/test-client.py:test_004()/97 +location: src/tests/client/test-client.py:test_004()/99 cmd: $NMCLI --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -6423,8 +6523,8 @@ WIFI-PROPERTIES.MESH: no WIFI-PROPERTIES.IBSS-RSN: no <<< -size: 2210 -location: src/tests/client/test-client.py:test_004()/98 +size: 2211 +location: src/tests/client/test-client.py:test_004()/100 cmd: $NMCLI --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -6472,8 +6572,8 @@ WIFI-PROPERTIES.MESH: nie WIFI-PROPERTIES.IBSS-RSN: nie <<< -size: 647 -location: src/tests/client/test-client.py:test_004()/99 +size: 648 +location: src/tests/client/test-client.py:test_004()/101 cmd: $NMCLI --color yes -f DEVICE,TYPE,DBUS-PATH dev lang: C returncode: 0 @@ -6488,7 +6588,7 @@ DEVICE TYPE DBUS-PATH <<< size: 658 -location: src/tests/client/test-client.py:test_004()/100 +location: src/tests/client/test-client.py:test_004()/102 cmd: $NMCLI --color yes -f DEVICE,TYPE,DBUS-PATH dev lang: pl_PL.UTF-8 returncode: 0 @@ -6503,7 +6603,7 @@ DEVICE TYPE DBUS-PATH <<< size: 2607 -location: src/tests/client/test-client.py:test_004()/101 +location: src/tests/client/test-client.py:test_004()/103 cmd: $NMCLI --color yes -f ALL device wifi list lang: C returncode: 0 @@ -6521,7 +6621,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 2675 -location: src/tests/client/test-client.py:test_004()/102 +location: src/tests/client/test-client.py:test_004()/104 cmd: $NMCLI --color yes -f ALL device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -6539,7 +6639,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 1074 -location: src/tests/client/test-client.py:test_004()/103 +location: src/tests/client/test-client.py:test_004()/105 cmd: $NMCLI --color yes -f COMMON device wifi list lang: C returncode: 0 @@ -6557,7 +6657,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY <<< size: 1134 -location: src/tests/client/test-client.py:test_004()/104 +location: src/tests/client/test-client.py:test_004()/106 cmd: $NMCLI --color yes -f COMMON device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -6575,7 +6675,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY <<< size: 2720 -location: src/tests/client/test-client.py:test_004()/105 +location: src/tests/client/test-client.py:test_004()/107 cmd: $NMCLI --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: C returncode: 0 @@ -6593,7 +6693,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 2788 -location: src/tests/client/test-client.py:test_004()/106 +location: src/tests/client/test-client.py:test_004()/108 cmd: $NMCLI --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -6611,7 +6711,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 901 -location: src/tests/client/test-client.py:test_004()/107 +location: src/tests/client/test-client.py:test_004()/109 cmd: $NMCLI --color yes -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -6624,7 +6724,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ <<< size: 929 -location: src/tests/client/test-client.py:test_004()/108 +location: src/tests/client/test-client.py:test_004()/110 cmd: $NMCLI --color yes -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -6637,7 +6737,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN <<< size: 440 -location: src/tests/client/test-client.py:test_004()/109 +location: src/tests/client/test-client.py:test_004()/111 cmd: $NMCLI --color yes -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -6650,7 +6750,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SEC <<< size: 466 -location: src/tests/client/test-client.py:test_004()/110 +location: src/tests/client/test-client.py:test_004()/112 cmd: $NMCLI --color yes -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -6663,7 +6763,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BA <<< size: 1014 -location: src/tests/client/test-client.py:test_004()/111 +location: src/tests/client/test-client.py:test_004()/113 cmd: $NMCLI --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -6676,7 +6776,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ <<< size: 1042 -location: src/tests/client/test-client.py:test_004()/112 +location: src/tests/client/test-client.py:test_004()/114 cmd: $NMCLI --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -6689,7 +6789,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN <<< size: 5665 -location: src/tests/client/test-client.py:test_004()/113 +location: src/tests/client/test-client.py:test_004()/115 cmd: $NMCLI --color yes -f ALL device show wlan0 lang: C returncode: 0 @@ -6800,7 +6900,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 5726 -location: src/tests/client/test-client.py:test_004()/114 +location: src/tests/client/test-client.py:test_004()/116 cmd: $NMCLI --color yes -f ALL device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -6911,7 +7011,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 1521 -location: src/tests/client/test-client.py:test_004()/115 +location: src/tests/client/test-client.py:test_004()/117 cmd: $NMCLI --color yes -f COMMON device show wlan0 lang: C returncode: 0 @@ -6944,7 +7044,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 1533 -location: src/tests/client/test-client.py:test_004()/116 +location: src/tests/client/test-client.py:test_004()/118 cmd: $NMCLI --color yes -f COMMON device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -6977,7 +7077,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 5629 -location: src/tests/client/test-client.py:test_004()/117 +location: src/tests/client/test-client.py:test_004()/119 cmd: $NMCLI --color yes -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: C returncode: 0 @@ -7084,7 +7184,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 5688 -location: src/tests/client/test-client.py:test_004()/118 +location: src/tests/client/test-client.py:test_004()/120 cmd: $NMCLI --color yes -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -7191,7 +7291,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 1445 -location: src/tests/client/test-client.py:test_004()/119 +location: src/tests/client/test-client.py:test_004()/121 cmd: $NMCLI --color yes dev lldp list ifname eth0 lang: C returncode: 0 @@ -7221,7 +7321,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES: 40 (wlan-access-point,telephone) <<< size: 1455 -location: src/tests/client/test-client.py:test_004()/120 +location: src/tests/client/test-client.py:test_004()/122 cmd: $NMCLI --color yes dev lldp list ifname eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -7251,7 +7351,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES: 40 (wlan-access-point,telephone) <<< size: 1077 -location: src/tests/client/test-client.py:test_004()/121 +location: src/tests/client/test-client.py:test_004()/123 cmd: $NMCLI --color yes -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: C returncode: 0 @@ -7275,7 +7375,7 @@ connection.interface-name: -- <<< size: 1087 -location: src/tests/client/test-client.py:test_004()/122 +location: src/tests/client/test-client.py:test_004()/124 cmd: $NMCLI --color yes -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: pl_PL.UTF-8 returncode: 0 @@ -7298,12 +7398,12 @@ connection.type: 802-11-wireless connection.interface-name: -- <<< -size: 6282 -location: src/tests/client/test-client.py:test_004()/123 +size: 6335 +location: src/tests/client/test-client.py:test_004()/125 cmd: $NMCLI --pretty con s con-vpn-1 lang: C returncode: 0 -stdout: 6138 bytes +stdout: 6191 bytes >>> =============================================================================== Connection profile details (con-vpn-1) @@ -7331,6 +7431,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -7427,12 +7528,12 @@ VPN.CFG[3]: key3 = val3 ------------------------------------------------------------------------------- <<< -size: 6324 -location: src/tests/client/test-client.py:test_004()/124 +size: 6377 +location: src/tests/client/test-client.py:test_004()/126 cmd: $NMCLI --pretty con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 6170 bytes +stdout: 6223 bytes >>> =============================================================================== Szczegóły profilu połączenia (con-vpn-1) @@ -7460,6 +7561,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -7556,12 +7658,12 @@ VPN.CFG[3]: key3 = val3 ------------------------------------------------------------------------------- <<< -size: 6282 -location: src/tests/client/test-client.py:test_004()/125 +size: 6335 +location: src/tests/client/test-client.py:test_004()/127 cmd: $NMCLI --pretty con s con-vpn-1 lang: C returncode: 0 -stdout: 6138 bytes +stdout: 6191 bytes >>> =============================================================================== Connection profile details (con-vpn-1) @@ -7589,6 +7691,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -7685,12 +7788,12 @@ VPN.CFG[3]: key3 = val3 ------------------------------------------------------------------------------- <<< -size: 6324 -location: src/tests/client/test-client.py:test_004()/126 +size: 6377 +location: src/tests/client/test-client.py:test_004()/128 cmd: $NMCLI --pretty con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 6170 bytes +stdout: 6223 bytes >>> =============================================================================== Szczegóły profilu połączenia (con-vpn-1) @@ -7718,6 +7821,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -7814,12 +7918,12 @@ VPN.CFG[3]: key3 = val3 ------------------------------------------------------------------------------- <<< -size: 4762 -location: src/tests/client/test-client.py:test_004()/127 +size: 4815 +location: src/tests/client/test-client.py:test_004()/129 cmd: $NMCLI --pretty -f ALL con s con-vpn-1 lang: C returncode: 0 -stdout: 4611 bytes +stdout: 4664 bytes >>> =============================================================================== Connection profile details (con-vpn-1) @@ -7847,6 +7951,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -7917,12 +8022,12 @@ proxy.pac-script: -- ------------------------------------------------------------------------------- <<< -size: 4787 -location: src/tests/client/test-client.py:test_004()/128 +size: 4840 +location: src/tests/client/test-client.py:test_004()/130 cmd: $NMCLI --pretty -f ALL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 4626 bytes +stdout: 4679 bytes >>> =============================================================================== Szczegóły profilu połączenia (con-vpn-1) @@ -7950,6 +8055,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -8021,7 +8127,7 @@ proxy.pac-script: -- <<< size: 783 -location: src/tests/client/test-client.py:test_004()/129 +location: src/tests/client/test-client.py:test_004()/131 cmd: $NMCLI --pretty -f VPN con s con-vpn-1 lang: C returncode: 0 @@ -8040,7 +8146,7 @@ vpn.timeout: 0 <<< size: 799 -location: src/tests/client/test-client.py:test_004()/130 +location: src/tests/client/test-client.py:test_004()/132 cmd: $NMCLI --pretty -f VPN con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -8059,7 +8165,7 @@ vpn.timeout: 0 <<< size: 1181 -location: src/tests/client/test-client.py:test_004()/131 +location: src/tests/client/test-client.py:test_004()/133 cmd: $NMCLI --pretty -f GENERAL con s con-vpn-1 lang: C returncode: 0 @@ -8085,7 +8191,7 @@ GENERAL.MASTER-PATH: -- <<< size: 1201 -location: src/tests/client/test-client.py:test_004()/132 +location: src/tests/client/test-client.py:test_004()/134 cmd: $NMCLI --pretty -f GENERAL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -8111,7 +8217,7 @@ GENERAL.MASTER-PATH: -- <<< size: 520 -location: src/tests/client/test-client.py:test_004()/133 +location: src/tests/client/test-client.py:test_004()/135 cmd: $NMCLI --pretty dev s lang: C returncode: 0 @@ -8130,7 +8236,7 @@ wlan1 wifi unavailable -- <<< size: 529 -location: src/tests/client/test-client.py:test_004()/134 +location: src/tests/client/test-client.py:test_004()/136 cmd: $NMCLI --pretty dev s lang: pl_PL.UTF-8 returncode: 0 @@ -8149,7 +8255,7 @@ wlan1 wifi niedostępne -- <<< size: 1716 -location: src/tests/client/test-client.py:test_004()/135 +location: src/tests/client/test-client.py:test_004()/137 cmd: $NMCLI --pretty -f all dev status lang: C returncode: 0 @@ -8168,7 +8274,7 @@ wlan1 wifi unavailable unknown unknown /org/freedesk <<< size: 1725 -location: src/tests/client/test-client.py:test_004()/136 +location: src/tests/client/test-client.py:test_004()/138 cmd: $NMCLI --pretty -f all dev status lang: pl_PL.UTF-8 returncode: 0 @@ -8187,7 +8293,7 @@ wlan1 wifi niedostępne nieznane nieznane /org/freedes <<< size: 12868 -location: src/tests/client/test-client.py:test_004()/137 +location: src/tests/client/test-client.py:test_004()/139 cmd: $NMCLI --pretty dev show lang: C returncode: 0 @@ -8395,7 +8501,7 @@ IP6.DOMAIN[1]: sear6.fo.x.y <<< size: 12933 -location: src/tests/client/test-client.py:test_004()/138 +location: src/tests/client/test-client.py:test_004()/140 cmd: $NMCLI --pretty dev show lang: pl_PL.UTF-8 returncode: 0 @@ -8603,7 +8709,7 @@ IP6.DOMAIN[1]: sear6.fo.x.y <<< size: 27638 -location: src/tests/client/test-client.py:test_004()/139 +location: src/tests/client/test-client.py:test_004()/141 cmd: $NMCLI --pretty -f all dev show lang: C returncode: 0 @@ -9096,7 +9202,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 27839 -location: src/tests/client/test-client.py:test_004()/140 +location: src/tests/client/test-client.py:test_004()/142 cmd: $NMCLI --pretty -f all dev show lang: pl_PL.UTF-8 returncode: 0 @@ -9589,7 +9695,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 2436 -location: src/tests/client/test-client.py:test_004()/141 +location: src/tests/client/test-client.py:test_004()/143 cmd: $NMCLI --pretty dev show wlan0 lang: C returncode: 0 @@ -9634,7 +9740,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 2455 -location: src/tests/client/test-client.py:test_004()/142 +location: src/tests/client/test-client.py:test_004()/144 cmd: $NMCLI --pretty dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -9679,7 +9785,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 6587 -location: src/tests/client/test-client.py:test_004()/143 +location: src/tests/client/test-client.py:test_004()/145 cmd: $NMCLI --pretty -f all dev show wlan0 lang: C returncode: 0 @@ -9805,7 +9911,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 6655 -location: src/tests/client/test-client.py:test_004()/144 +location: src/tests/client/test-client.py:test_004()/146 cmd: $NMCLI --pretty -f all dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -9931,7 +10037,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 2632 -location: src/tests/client/test-client.py:test_004()/145 +location: src/tests/client/test-client.py:test_004()/147 cmd: $NMCLI --pretty -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -9986,7 +10092,7 @@ WIFI-PROPERTIES.IBSS-RSN: no <<< size: 2666 -location: src/tests/client/test-client.py:test_004()/146 +location: src/tests/client/test-client.py:test_004()/148 cmd: $NMCLI --pretty -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -10041,7 +10147,7 @@ WIFI-PROPERTIES.IBSS-RSN: nie <<< size: 2632 -location: src/tests/client/test-client.py:test_004()/147 +location: src/tests/client/test-client.py:test_004()/149 cmd: $NMCLI --pretty -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -10096,7 +10202,7 @@ WIFI-PROPERTIES.IBSS-RSN: no <<< size: 2666 -location: src/tests/client/test-client.py:test_004()/148 +location: src/tests/client/test-client.py:test_004()/150 cmd: $NMCLI --pretty -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -10151,7 +10257,7 @@ WIFI-PROPERTIES.IBSS-RSN: nie <<< size: 669 -location: src/tests/client/test-client.py:test_004()/149 +location: src/tests/client/test-client.py:test_004()/151 cmd: $NMCLI --pretty -f DEVICE,TYPE,DBUS-PATH dev lang: C returncode: 0 @@ -10170,7 +10276,7 @@ wlan1 wifi /org/freedesktop/NetworkManager/Devices/5 <<< size: 672 -location: src/tests/client/test-client.py:test_004()/150 +location: src/tests/client/test-client.py:test_004()/152 cmd: $NMCLI --pretty -f DEVICE,TYPE,DBUS-PATH dev lang: pl_PL.UTF-8 returncode: 0 @@ -10189,7 +10295,7 @@ wlan1 wifi /org/freedesktop/NetworkManager/Devices/5 <<< size: 3024 -location: src/tests/client/test-client.py:test_004()/151 +location: src/tests/client/test-client.py:test_004()/153 cmd: $NMCLI --pretty -f ALL device wifi list lang: C returncode: 0 @@ -10219,7 +10325,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 3262 -location: src/tests/client/test-client.py:test_004()/152 +location: src/tests/client/test-client.py:test_004()/154 cmd: $NMCLI --pretty -f ALL device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -10249,7 +10355,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 1317 -location: src/tests/client/test-client.py:test_004()/153 +location: src/tests/client/test-client.py:test_004()/155 cmd: $NMCLI --pretty -f COMMON device wifi list lang: C returncode: 0 @@ -10279,7 +10385,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY <<< size: 1547 -location: src/tests/client/test-client.py:test_004()/154 +location: src/tests/client/test-client.py:test_004()/156 cmd: $NMCLI --pretty -f COMMON device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -10309,7 +10415,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY <<< size: 3137 -location: src/tests/client/test-client.py:test_004()/155 +location: src/tests/client/test-client.py:test_004()/157 cmd: $NMCLI --pretty -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: C returncode: 0 @@ -10339,7 +10445,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 3375 -location: src/tests/client/test-client.py:test_004()/156 +location: src/tests/client/test-client.py:test_004()/158 cmd: $NMCLI --pretty -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -10369,7 +10475,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 1139 -location: src/tests/client/test-client.py:test_004()/157 +location: src/tests/client/test-client.py:test_004()/159 cmd: $NMCLI --pretty -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -10386,7 +10492,7 @@ AP[1] wlan0-ap-2 776C616E302D61702D32 C0:E2:BE:E8:EF:B6 Infra 1 2412 MH <<< size: 1227 -location: src/tests/client/test-client.py:test_004()/158 +location: src/tests/client/test-client.py:test_004()/160 cmd: $NMCLI --pretty -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -10403,7 +10509,7 @@ AP[1] wlan0-ap-2 776C616E302D61702D32 C0:E2:BE:E8:EF:B6 Infrastruktura 1 <<< size: 554 -location: src/tests/client/test-client.py:test_004()/159 +location: src/tests/client/test-client.py:test_004()/161 cmd: $NMCLI --pretty -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -10420,7 +10526,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SEC <<< size: 639 -location: src/tests/client/test-client.py:test_004()/160 +location: src/tests/client/test-client.py:test_004()/162 cmd: $NMCLI --pretty -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -10437,7 +10543,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BA <<< size: 1252 -location: src/tests/client/test-client.py:test_004()/161 +location: src/tests/client/test-client.py:test_004()/163 cmd: $NMCLI --pretty -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -10454,7 +10560,7 @@ AP[1] wlan0-ap-2 776C616E302D61702D32 C0:E2:BE:E8:EF:B6 Infra 1 2412 MH <<< size: 1340 -location: src/tests/client/test-client.py:test_004()/162 +location: src/tests/client/test-client.py:test_004()/164 cmd: $NMCLI --pretty -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -10471,7 +10577,7 @@ AP[1] wlan0-ap-2 776C616E302D61702D32 C0:E2:BE:E8:EF:B6 Infrastruktura 1 <<< size: 6590 -location: src/tests/client/test-client.py:test_004()/163 +location: src/tests/client/test-client.py:test_004()/165 cmd: $NMCLI --pretty -f ALL device show wlan0 lang: C returncode: 0 @@ -10597,7 +10703,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 6658 -location: src/tests/client/test-client.py:test_004()/164 +location: src/tests/client/test-client.py:test_004()/166 cmd: $NMCLI --pretty -f ALL device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -10723,7 +10829,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 2449 -location: src/tests/client/test-client.py:test_004()/165 +location: src/tests/client/test-client.py:test_004()/167 cmd: $NMCLI --pretty -f COMMON device show wlan0 lang: C returncode: 0 @@ -10768,7 +10874,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 2468 -location: src/tests/client/test-client.py:test_004()/166 +location: src/tests/client/test-client.py:test_004()/168 cmd: $NMCLI --pretty -f COMMON device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -10813,7 +10919,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 6474 -location: src/tests/client/test-client.py:test_004()/167 +location: src/tests/client/test-client.py:test_004()/169 cmd: $NMCLI --pretty -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: C returncode: 0 @@ -10934,7 +11040,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 6540 -location: src/tests/client/test-client.py:test_004()/168 +location: src/tests/client/test-client.py:test_004()/170 cmd: $NMCLI --pretty -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -11055,7 +11161,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 1896 -location: src/tests/client/test-client.py:test_004()/169 +location: src/tests/client/test-client.py:test_004()/171 cmd: $NMCLI --pretty dev lldp list ifname eth0 lang: C returncode: 0 @@ -11091,7 +11197,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES: 40 (wlan-access-point,telephone) <<< size: 1910 -location: src/tests/client/test-client.py:test_004()/170 +location: src/tests/client/test-client.py:test_004()/172 cmd: $NMCLI --pretty dev lldp list ifname eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -11127,7 +11233,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES: 40 (wlan-access-point,telephone) <<< size: 2769 -location: src/tests/client/test-client.py:test_004()/171 +location: src/tests/client/test-client.py:test_004()/173 cmd: $NMCLI --pretty -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: C returncode: 0 @@ -11173,7 +11279,7 @@ connection.interface-name: -- <<< size: 2794 -location: src/tests/client/test-client.py:test_004()/172 +location: src/tests/client/test-client.py:test_004()/174 cmd: $NMCLI --pretty -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: pl_PL.UTF-8 returncode: 0 @@ -11218,12 +11324,12 @@ connection.interface-name: -- ------------------------------------------------------------------------------- <<< -size: 6294 -location: src/tests/client/test-client.py:test_004()/173 +size: 6347 +location: src/tests/client/test-client.py:test_004()/175 cmd: $NMCLI --pretty --color yes con s con-vpn-1 lang: C returncode: 0 -stdout: 6138 bytes +stdout: 6191 bytes >>> =============================================================================== Connection profile details (con-vpn-1) @@ -11251,6 +11357,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -11347,12 +11454,12 @@ VPN.CFG[3]: key3 = val3 ------------------------------------------------------------------------------- <<< -size: 6336 -location: src/tests/client/test-client.py:test_004()/174 +size: 6389 +location: src/tests/client/test-client.py:test_004()/176 cmd: $NMCLI --pretty --color yes con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 6170 bytes +stdout: 6223 bytes >>> =============================================================================== Szczegóły profilu połączenia (con-vpn-1) @@ -11380,6 +11487,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -11476,12 +11584,12 @@ VPN.CFG[3]: key3 = val3 ------------------------------------------------------------------------------- <<< -size: 6294 -location: src/tests/client/test-client.py:test_004()/175 +size: 6347 +location: src/tests/client/test-client.py:test_004()/177 cmd: $NMCLI --pretty --color yes con s con-vpn-1 lang: C returncode: 0 -stdout: 6138 bytes +stdout: 6191 bytes >>> =============================================================================== Connection profile details (con-vpn-1) @@ -11509,6 +11617,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -11605,12 +11714,12 @@ VPN.CFG[3]: key3 = val3 ------------------------------------------------------------------------------- <<< -size: 6336 -location: src/tests/client/test-client.py:test_004()/176 +size: 6389 +location: src/tests/client/test-client.py:test_004()/178 cmd: $NMCLI --pretty --color yes con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 6170 bytes +stdout: 6223 bytes >>> =============================================================================== Szczegóły profilu połączenia (con-vpn-1) @@ -11638,6 +11747,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -11734,12 +11844,12 @@ VPN.CFG[3]: key3 = val3 ------------------------------------------------------------------------------- <<< -size: 4774 -location: src/tests/client/test-client.py:test_004()/177 +size: 4827 +location: src/tests/client/test-client.py:test_004()/179 cmd: $NMCLI --pretty --color yes -f ALL con s con-vpn-1 lang: C returncode: 0 -stdout: 4611 bytes +stdout: 4664 bytes >>> =============================================================================== Connection profile details (con-vpn-1) @@ -11767,6 +11877,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -11837,12 +11948,12 @@ proxy.pac-script: -- ------------------------------------------------------------------------------- <<< -size: 4799 -location: src/tests/client/test-client.py:test_004()/178 +size: 4852 +location: src/tests/client/test-client.py:test_004()/180 cmd: $NMCLI --pretty --color yes -f ALL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 4626 bytes +stdout: 4679 bytes >>> =============================================================================== Szczegóły profilu połączenia (con-vpn-1) @@ -11870,6 +11981,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -11941,7 +12053,7 @@ proxy.pac-script: -- <<< size: 795 -location: src/tests/client/test-client.py:test_004()/179 +location: src/tests/client/test-client.py:test_004()/181 cmd: $NMCLI --pretty --color yes -f VPN con s con-vpn-1 lang: C returncode: 0 @@ -11960,7 +12072,7 @@ vpn.timeout: 0 <<< size: 811 -location: src/tests/client/test-client.py:test_004()/180 +location: src/tests/client/test-client.py:test_004()/182 cmd: $NMCLI --pretty --color yes -f VPN con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -11979,7 +12091,7 @@ vpn.timeout: 0 <<< size: 1193 -location: src/tests/client/test-client.py:test_004()/181 +location: src/tests/client/test-client.py:test_004()/183 cmd: $NMCLI --pretty --color yes -f GENERAL con s con-vpn-1 lang: C returncode: 0 @@ -12005,7 +12117,7 @@ GENERAL.MASTER-PATH: -- <<< size: 1213 -location: src/tests/client/test-client.py:test_004()/182 +location: src/tests/client/test-client.py:test_004()/184 cmd: $NMCLI --pretty --color yes -f GENERAL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -12031,7 +12143,7 @@ GENERAL.MASTER-PATH: -- <<< size: 696 -location: src/tests/client/test-client.py:test_004()/183 +location: src/tests/client/test-client.py:test_004()/185 cmd: $NMCLI --pretty --color yes dev s lang: C returncode: 0 @@ -12050,7 +12162,7 @@ DEVICE TYPE STATE CONNECTION <<< size: 705 -location: src/tests/client/test-client.py:test_004()/184 +location: src/tests/client/test-client.py:test_004()/186 cmd: $NMCLI --pretty --color yes dev s lang: pl_PL.UTF-8 returncode: 0 @@ -12069,7 +12181,7 @@ DEVICE TYPE STATE CONNECTION <<< size: 2097 -location: src/tests/client/test-client.py:test_004()/185 +location: src/tests/client/test-client.py:test_004()/187 cmd: $NMCLI --pretty --color yes -f all dev status lang: C returncode: 0 @@ -12088,7 +12200,7 @@ DEVICE TYPE STATE IP4-CONNECTIVITY IP6-CONNECTIVITY DBUS-PATH <<< size: 2106 -location: src/tests/client/test-client.py:test_004()/186 +location: src/tests/client/test-client.py:test_004()/188 cmd: $NMCLI --pretty --color yes -f all dev status lang: pl_PL.UTF-8 returncode: 0 @@ -12107,7 +12219,7 @@ DEVICE TYPE STATE IP4-CONNECTIVITY IP6-CONNECTIVITY DBUS-PATH <<< size: 12880 -location: src/tests/client/test-client.py:test_004()/187 +location: src/tests/client/test-client.py:test_004()/189 cmd: $NMCLI --pretty --color yes dev show lang: C returncode: 0 @@ -12315,7 +12427,7 @@ IP6.DOMAIN[1]: sear6.fo.x.y <<< size: 12945 -location: src/tests/client/test-client.py:test_004()/188 +location: src/tests/client/test-client.py:test_004()/190 cmd: $NMCLI --pretty --color yes dev show lang: pl_PL.UTF-8 returncode: 0 @@ -12523,7 +12635,7 @@ IP6.DOMAIN[1]: sear6.fo.x.y <<< size: 27974 -location: src/tests/client/test-client.py:test_004()/189 +location: src/tests/client/test-client.py:test_004()/191 cmd: $NMCLI --pretty --color yes -f all dev show lang: C returncode: 0 @@ -13016,7 +13128,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 28175 -location: src/tests/client/test-client.py:test_004()/190 +location: src/tests/client/test-client.py:test_004()/192 cmd: $NMCLI --pretty --color yes -f all dev show lang: pl_PL.UTF-8 returncode: 0 @@ -13509,7 +13621,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 2448 -location: src/tests/client/test-client.py:test_004()/191 +location: src/tests/client/test-client.py:test_004()/193 cmd: $NMCLI --pretty --color yes dev show wlan0 lang: C returncode: 0 @@ -13554,7 +13666,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 2467 -location: src/tests/client/test-client.py:test_004()/192 +location: src/tests/client/test-client.py:test_004()/194 cmd: $NMCLI --pretty --color yes dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -13599,7 +13711,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 6842 -location: src/tests/client/test-client.py:test_004()/193 +location: src/tests/client/test-client.py:test_004()/195 cmd: $NMCLI --pretty --color yes -f all dev show wlan0 lang: C returncode: 0 @@ -13725,7 +13837,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 6910 -location: src/tests/client/test-client.py:test_004()/194 +location: src/tests/client/test-client.py:test_004()/196 cmd: $NMCLI --pretty --color yes -f all dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -13851,7 +13963,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 2644 -location: src/tests/client/test-client.py:test_004()/195 +location: src/tests/client/test-client.py:test_004()/197 cmd: $NMCLI --pretty --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -13906,7 +14018,7 @@ WIFI-PROPERTIES.IBSS-RSN: no <<< size: 2678 -location: src/tests/client/test-client.py:test_004()/196 +location: src/tests/client/test-client.py:test_004()/198 cmd: $NMCLI --pretty --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -13961,7 +14073,7 @@ WIFI-PROPERTIES.IBSS-RSN: nie <<< size: 2644 -location: src/tests/client/test-client.py:test_004()/197 +location: src/tests/client/test-client.py:test_004()/199 cmd: $NMCLI --pretty --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -14016,7 +14128,7 @@ WIFI-PROPERTIES.IBSS-RSN: no <<< size: 2678 -location: src/tests/client/test-client.py:test_004()/198 +location: src/tests/client/test-client.py:test_004()/200 cmd: $NMCLI --pretty --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -14071,7 +14183,7 @@ WIFI-PROPERTIES.IBSS-RSN: nie <<< size: 804 -location: src/tests/client/test-client.py:test_004()/199 +location: src/tests/client/test-client.py:test_004()/201 cmd: $NMCLI --pretty --color yes -f DEVICE,TYPE,DBUS-PATH dev lang: C returncode: 0 @@ -14090,7 +14202,7 @@ DEVICE TYPE DBUS-PATH <<< size: 807 -location: src/tests/client/test-client.py:test_004()/200 +location: src/tests/client/test-client.py:test_004()/202 cmd: $NMCLI --pretty --color yes -f DEVICE,TYPE,DBUS-PATH dev lang: pl_PL.UTF-8 returncode: 0 @@ -14109,7 +14221,7 @@ DEVICE TYPE DBUS-PATH <<< size: 3648 -location: src/tests/client/test-client.py:test_004()/201 +location: src/tests/client/test-client.py:test_004()/203 cmd: $NMCLI --pretty --color yes -f ALL device wifi list lang: C returncode: 0 @@ -14139,7 +14251,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 3886 -location: src/tests/client/test-client.py:test_004()/202 +location: src/tests/client/test-client.py:test_004()/204 cmd: $NMCLI --pretty --color yes -f ALL device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -14169,7 +14281,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 1653 -location: src/tests/client/test-client.py:test_004()/203 +location: src/tests/client/test-client.py:test_004()/205 cmd: $NMCLI --pretty --color yes -f COMMON device wifi list lang: C returncode: 0 @@ -14199,7 +14311,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY <<< size: 1883 -location: src/tests/client/test-client.py:test_004()/204 +location: src/tests/client/test-client.py:test_004()/206 cmd: $NMCLI --pretty --color yes -f COMMON device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -14229,7 +14341,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY <<< size: 3761 -location: src/tests/client/test-client.py:test_004()/205 +location: src/tests/client/test-client.py:test_004()/207 cmd: $NMCLI --pretty --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: C returncode: 0 @@ -14259,7 +14371,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 3999 -location: src/tests/client/test-client.py:test_004()/206 +location: src/tests/client/test-client.py:test_004()/208 cmd: $NMCLI --pretty --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -14289,7 +14401,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 1305 -location: src/tests/client/test-client.py:test_004()/207 +location: src/tests/client/test-client.py:test_004()/209 cmd: $NMCLI --pretty --color yes -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -14306,7 +14418,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ <<< size: 1392 -location: src/tests/client/test-client.py:test_004()/208 +location: src/tests/client/test-client.py:test_004()/210 cmd: $NMCLI --pretty --color yes -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -14323,7 +14435,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN <<< size: 647 -location: src/tests/client/test-client.py:test_004()/209 +location: src/tests/client/test-client.py:test_004()/211 cmd: $NMCLI --pretty --color yes -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -14340,7 +14452,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SEC <<< size: 732 -location: src/tests/client/test-client.py:test_004()/210 +location: src/tests/client/test-client.py:test_004()/212 cmd: $NMCLI --pretty --color yes -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -14357,7 +14469,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BA <<< size: 1418 -location: src/tests/client/test-client.py:test_004()/211 +location: src/tests/client/test-client.py:test_004()/213 cmd: $NMCLI --pretty --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -14374,7 +14486,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ <<< size: 1505 -location: src/tests/client/test-client.py:test_004()/212 +location: src/tests/client/test-client.py:test_004()/214 cmd: $NMCLI --pretty --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -14391,7 +14503,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN <<< size: 6845 -location: src/tests/client/test-client.py:test_004()/213 +location: src/tests/client/test-client.py:test_004()/215 cmd: $NMCLI --pretty --color yes -f ALL device show wlan0 lang: C returncode: 0 @@ -14517,7 +14629,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 6913 -location: src/tests/client/test-client.py:test_004()/214 +location: src/tests/client/test-client.py:test_004()/216 cmd: $NMCLI --pretty --color yes -f ALL device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -14643,7 +14755,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 2461 -location: src/tests/client/test-client.py:test_004()/215 +location: src/tests/client/test-client.py:test_004()/217 cmd: $NMCLI --pretty --color yes -f COMMON device show wlan0 lang: C returncode: 0 @@ -14688,7 +14800,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 2480 -location: src/tests/client/test-client.py:test_004()/216 +location: src/tests/client/test-client.py:test_004()/218 cmd: $NMCLI --pretty --color yes -f COMMON device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -14733,7 +14845,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 6729 -location: src/tests/client/test-client.py:test_004()/217 +location: src/tests/client/test-client.py:test_004()/219 cmd: $NMCLI --pretty --color yes -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: C returncode: 0 @@ -14854,7 +14966,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 6795 -location: src/tests/client/test-client.py:test_004()/218 +location: src/tests/client/test-client.py:test_004()/220 cmd: $NMCLI --pretty --color yes -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -14975,7 +15087,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 1908 -location: src/tests/client/test-client.py:test_004()/219 +location: src/tests/client/test-client.py:test_004()/221 cmd: $NMCLI --pretty --color yes dev lldp list ifname eth0 lang: C returncode: 0 @@ -15011,7 +15123,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES: 40 (wlan-access-point,telephone) <<< size: 1922 -location: src/tests/client/test-client.py:test_004()/220 +location: src/tests/client/test-client.py:test_004()/222 cmd: $NMCLI --pretty --color yes dev lldp list ifname eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -15047,7 +15159,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES: 40 (wlan-access-point,telephone) <<< size: 2781 -location: src/tests/client/test-client.py:test_004()/221 +location: src/tests/client/test-client.py:test_004()/223 cmd: $NMCLI --pretty --color yes -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: C returncode: 0 @@ -15093,7 +15205,7 @@ connection.interface-name: -- <<< size: 2806 -location: src/tests/client/test-client.py:test_004()/222 +location: src/tests/client/test-client.py:test_004()/224 cmd: $NMCLI --pretty --color yes -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: pl_PL.UTF-8 returncode: 0 @@ -15138,12 +15250,12 @@ connection.interface-name: -- ------------------------------------------------------------------------------- <<< -size: 2655 -location: src/tests/client/test-client.py:test_004()/223 +size: 2682 +location: src/tests/client/test-client.py:test_004()/225 cmd: $NMCLI --terse con s con-vpn-1 lang: C returncode: 0 -stdout: 2512 bytes +stdout: 2539 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -15168,6 +15280,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -15254,12 +15367,12 @@ VPN.CFG[2]:key2 = val2 VPN.CFG[3]:key3 = val3 <<< -size: 2665 -location: src/tests/client/test-client.py:test_004()/224 +size: 2692 +location: src/tests/client/test-client.py:test_004()/226 cmd: $NMCLI --terse con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 2512 bytes +stdout: 2539 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -15284,6 +15397,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -15370,12 +15484,12 @@ VPN.CFG[2]:key2 = val2 VPN.CFG[3]:key3 = val3 <<< -size: 2655 -location: src/tests/client/test-client.py:test_004()/225 +size: 2682 +location: src/tests/client/test-client.py:test_004()/227 cmd: $NMCLI --terse con s con-vpn-1 lang: C returncode: 0 -stdout: 2512 bytes +stdout: 2539 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -15400,6 +15514,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -15486,12 +15601,12 @@ VPN.CFG[2]:key2 = val2 VPN.CFG[3]:key3 = val3 <<< -size: 2665 -location: src/tests/client/test-client.py:test_004()/226 +size: 2692 +location: src/tests/client/test-client.py:test_004()/228 cmd: $NMCLI --terse con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 2512 bytes +stdout: 2539 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -15516,6 +15631,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -15602,12 +15718,12 @@ VPN.CFG[2]:key2 = val2 VPN.CFG[3]:key3 = val3 <<< -size: 2080 -location: src/tests/client/test-client.py:test_004()/227 +size: 2107 +location: src/tests/client/test-client.py:test_004()/229 cmd: $NMCLI --terse -f ALL con s con-vpn-1 lang: C returncode: 0 -stdout: 1930 bytes +stdout: 1957 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -15632,6 +15748,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -15697,12 +15814,12 @@ proxy.pac-url: proxy.pac-script: <<< -size: 2090 -location: src/tests/client/test-client.py:test_004()/228 +size: 2117 +location: src/tests/client/test-client.py:test_004()/230 cmd: $NMCLI --terse -f ALL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 1930 bytes +stdout: 1957 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -15727,6 +15844,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -15793,7 +15911,7 @@ proxy.pac-script: <<< size: 320 -location: src/tests/client/test-client.py:test_004()/229 +location: src/tests/client/test-client.py:test_004()/231 cmd: $NMCLI --terse -f VPN con s con-vpn-1 lang: C returncode: 0 @@ -15808,7 +15926,7 @@ vpn.timeout:0 <<< size: 330 -location: src/tests/client/test-client.py:test_004()/230 +location: src/tests/client/test-client.py:test_004()/232 cmd: $NMCLI --terse -f VPN con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -15823,7 +15941,7 @@ vpn.timeout:0 <<< size: 546 -location: src/tests/client/test-client.py:test_004()/231 +location: src/tests/client/test-client.py:test_004()/233 cmd: $NMCLI --terse -f GENERAL con s con-vpn-1 lang: C returncode: 0 @@ -15845,7 +15963,7 @@ GENERAL.MASTER-PATH: <<< size: 556 -location: src/tests/client/test-client.py:test_004()/232 +location: src/tests/client/test-client.py:test_004()/234 cmd: $NMCLI --terse -f GENERAL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -15867,7 +15985,7 @@ GENERAL.MASTER-PATH: <<< size: 265 -location: src/tests/client/test-client.py:test_004()/233 +location: src/tests/client/test-client.py:test_004()/235 cmd: $NMCLI --terse dev s lang: C returncode: 0 @@ -15881,7 +15999,7 @@ wlan1:wifi:unavailable: <<< size: 275 -location: src/tests/client/test-client.py:test_004()/234 +location: src/tests/client/test-client.py:test_004()/236 cmd: $NMCLI --terse dev s lang: pl_PL.UTF-8 returncode: 0 @@ -15895,7 +16013,7 @@ wlan1:wifi:unavailable: <<< size: 663 -location: src/tests/client/test-client.py:test_004()/235 +location: src/tests/client/test-client.py:test_004()/237 cmd: $NMCLI --terse -f all dev status lang: C returncode: 0 @@ -15909,7 +16027,7 @@ wlan1:wifi:unavailable:unknown:unknown:/org/freedesktop/NetworkManager/Devices/5 <<< size: 673 -location: src/tests/client/test-client.py:test_004()/236 +location: src/tests/client/test-client.py:test_004()/238 cmd: $NMCLI --terse -f all dev status lang: pl_PL.UTF-8 returncode: 0 @@ -15923,7 +16041,7 @@ wlan1:wifi:unavailable:unknown:unknown:/org/freedesktop/NetworkManager/Devices/5 <<< size: 4535 -location: src/tests/client/test-client.py:test_004()/237 +location: src/tests/client/test-client.py:test_004()/239 cmd: $NMCLI --terse dev show lang: C returncode: 0 @@ -16069,7 +16187,7 @@ IP6.DOMAIN[1]:sear6.fo.x.y <<< size: 4545 -location: src/tests/client/test-client.py:test_004()/238 +location: src/tests/client/test-client.py:test_004()/240 cmd: $NMCLI --terse dev show lang: pl_PL.UTF-8 returncode: 0 @@ -16215,7 +16333,7 @@ IP6.DOMAIN[1]:sear6.fo.x.y <<< size: 13121 -location: src/tests/client/test-client.py:test_004()/239 +location: src/tests/client/test-client.py:test_004()/241 cmd: $NMCLI --terse -f all dev show lang: C returncode: 0 @@ -16644,7 +16762,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 13167 -location: src/tests/client/test-client.py:test_004()/240 +location: src/tests/client/test-client.py:test_004()/242 cmd: $NMCLI --terse -f all dev show lang: pl_PL.UTF-8 returncode: 0 @@ -17073,7 +17191,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 879 -location: src/tests/client/test-client.py:test_004()/241 +location: src/tests/client/test-client.py:test_004()/243 cmd: $NMCLI --terse dev show wlan0 lang: C returncode: 0 @@ -17106,7 +17224,7 @@ IP6.DOMAIN[6]:sear6.foo4.bar <<< size: 889 -location: src/tests/client/test-client.py:test_004()/242 +location: src/tests/client/test-client.py:test_004()/244 cmd: $NMCLI --terse dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -17139,7 +17257,7 @@ IP6.DOMAIN[6]:sear6.foo4.bar <<< size: 3017 -location: src/tests/client/test-client.py:test_004()/243 +location: src/tests/client/test-client.py:test_004()/245 cmd: $NMCLI --terse -f all dev show wlan0 lang: C returncode: 0 @@ -17250,7 +17368,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 3054 -location: src/tests/client/test-client.py:test_004()/244 +location: src/tests/client/test-client.py:test_004()/246 cmd: $NMCLI --terse -f all dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -17361,7 +17479,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 1319 -location: src/tests/client/test-client.py:test_004()/245 +location: src/tests/client/test-client.py:test_004()/247 cmd: $NMCLI --terse -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -17410,7 +17528,7 @@ WIFI-PROPERTIES.IBSS-RSN:no <<< size: 1329 -location: src/tests/client/test-client.py:test_004()/246 +location: src/tests/client/test-client.py:test_004()/248 cmd: $NMCLI --terse -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -17459,7 +17577,7 @@ WIFI-PROPERTIES.IBSS-RSN:no <<< size: 1319 -location: src/tests/client/test-client.py:test_004()/247 +location: src/tests/client/test-client.py:test_004()/249 cmd: $NMCLI --terse -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -17508,7 +17626,7 @@ WIFI-PROPERTIES.IBSS-RSN:no <<< size: 1329 -location: src/tests/client/test-client.py:test_004()/248 +location: src/tests/client/test-client.py:test_004()/250 cmd: $NMCLI --terse -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -17557,7 +17675,7 @@ WIFI-PROPERTIES.IBSS-RSN:no <<< size: 426 -location: src/tests/client/test-client.py:test_004()/249 +location: src/tests/client/test-client.py:test_004()/251 cmd: $NMCLI --terse -f DEVICE,TYPE,DBUS-PATH dev lang: C returncode: 0 @@ -17571,7 +17689,7 @@ wlan1:wifi:/org/freedesktop/NetworkManager/Devices/5 <<< size: 436 -location: src/tests/client/test-client.py:test_004()/250 +location: src/tests/client/test-client.py:test_004()/252 cmd: $NMCLI --terse -f DEVICE,TYPE,DBUS-PATH dev lang: pl_PL.UTF-8 returncode: 0 @@ -17585,7 +17703,7 @@ wlan1:wifi:/org/freedesktop/NetworkManager/Devices/5 <<< size: 1084 -location: src/tests/client/test-client.py:test_004()/251 +location: src/tests/client/test-client.py:test_004()/253 cmd: $NMCLI --terse -f ALL device wifi list lang: C returncode: 0 @@ -17600,7 +17718,7 @@ AP[1]:wlan1-ap-4:776C616E312D61702D34:94\:2B\:E8\:F6\:D2\:86:Infra:1:2412 MHz:54 <<< size: 1142 -location: src/tests/client/test-client.py:test_004()/252 +location: src/tests/client/test-client.py:test_004()/254 cmd: $NMCLI --terse -f ALL device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -17615,7 +17733,7 @@ AP[1]:wlan1-ap-4:776C616E312D61702D34:94\:2B\:E8\:F6\:D2\:86:Infrastruktura:1:24 <<< size: 433 -location: src/tests/client/test-client.py:test_004()/253 +location: src/tests/client/test-client.py:test_004()/255 cmd: $NMCLI --terse -f COMMON device wifi list lang: C returncode: 0 @@ -17630,7 +17748,7 @@ stdout: 280 bytes <<< size: 479 -location: src/tests/client/test-client.py:test_004()/254 +location: src/tests/client/test-client.py:test_004()/256 cmd: $NMCLI --terse -f COMMON device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -17645,7 +17763,7 @@ stdout: 316 bytes <<< size: 1197 -location: src/tests/client/test-client.py:test_004()/255 +location: src/tests/client/test-client.py:test_004()/257 cmd: $NMCLI --terse -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: C returncode: 0 @@ -17660,7 +17778,7 @@ AP[1]:wlan1-ap-4:776C616E312D61702D34:94\:2B\:E8\:F6\:D2\:86:Infra:1:2412 MHz:54 <<< size: 1255 -location: src/tests/client/test-client.py:test_004()/256 +location: src/tests/client/test-client.py:test_004()/258 cmd: $NMCLI --terse -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -17675,7 +17793,7 @@ AP[1]:wlan1-ap-4:776C616E312D61702D34:94\:2B\:E8\:F6\:D2\:86:Infrastruktura:1:24 <<< size: 431 -location: src/tests/client/test-client.py:test_004()/257 +location: src/tests/client/test-client.py:test_004()/259 cmd: $NMCLI --terse -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -17687,7 +17805,7 @@ AP[1]:wlan0-ap-2:776C616E302D61702D32:C0\:E2\:BE\:E8\:EF\:B6:Infra:1:2412 MHz:54 <<< size: 453 -location: src/tests/client/test-client.py:test_004()/258 +location: src/tests/client/test-client.py:test_004()/260 cmd: $NMCLI --terse -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -17699,7 +17817,7 @@ AP[1]:wlan0-ap-2:776C616E302D61702D32:C0\:E2\:BE\:E8\:EF\:B6:Infrastruktura:1:24 <<< size: 250 -location: src/tests/client/test-client.py:test_004()/259 +location: src/tests/client/test-client.py:test_004()/261 cmd: $NMCLI --terse -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -17711,7 +17829,7 @@ stdout: 74 bytes <<< size: 269 -location: src/tests/client/test-client.py:test_004()/260 +location: src/tests/client/test-client.py:test_004()/262 cmd: $NMCLI --terse -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -17723,7 +17841,7 @@ stdout: 83 bytes <<< size: 544 -location: src/tests/client/test-client.py:test_004()/261 +location: src/tests/client/test-client.py:test_004()/263 cmd: $NMCLI --terse -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -17735,7 +17853,7 @@ AP[1]:wlan0-ap-2:776C616E302D61702D32:C0\:E2\:BE\:E8\:EF\:B6:Infra:1:2412 MHz:54 <<< size: 566 -location: src/tests/client/test-client.py:test_004()/262 +location: src/tests/client/test-client.py:test_004()/264 cmd: $NMCLI --terse -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -17747,7 +17865,7 @@ AP[1]:wlan0-ap-2:776C616E302D61702D32:C0\:E2\:BE\:E8\:EF\:B6:Infrastruktura:1:24 <<< size: 3020 -location: src/tests/client/test-client.py:test_004()/263 +location: src/tests/client/test-client.py:test_004()/265 cmd: $NMCLI --terse -f ALL device show wlan0 lang: C returncode: 0 @@ -17858,7 +17976,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 3057 -location: src/tests/client/test-client.py:test_004()/264 +location: src/tests/client/test-client.py:test_004()/266 cmd: $NMCLI --terse -f ALL device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -17969,7 +18087,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 892 -location: src/tests/client/test-client.py:test_004()/265 +location: src/tests/client/test-client.py:test_004()/267 cmd: $NMCLI --terse -f COMMON device show wlan0 lang: C returncode: 0 @@ -18002,7 +18120,7 @@ IP6.DOMAIN[6]:sear6.foo4.bar <<< size: 902 -location: src/tests/client/test-client.py:test_004()/266 +location: src/tests/client/test-client.py:test_004()/268 cmd: $NMCLI --terse -f COMMON device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -18035,7 +18153,7 @@ IP6.DOMAIN[6]:sear6.foo4.bar <<< size: 3052 -location: src/tests/client/test-client.py:test_004()/267 +location: src/tests/client/test-client.py:test_004()/269 cmd: $NMCLI --terse -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: C returncode: 0 @@ -18142,7 +18260,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 3089 -location: src/tests/client/test-client.py:test_004()/268 +location: src/tests/client/test-client.py:test_004()/270 cmd: $NMCLI --terse -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -18249,7 +18367,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 1134 -location: src/tests/client/test-client.py:test_004()/269 +location: src/tests/client/test-client.py:test_004()/271 cmd: $NMCLI --terse dev lldp list ifname eth0 lang: C returncode: 0 @@ -18279,7 +18397,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES:40 (wlan-access-point,telephone) <<< size: 1144 -location: src/tests/client/test-client.py:test_004()/270 +location: src/tests/client/test-client.py:test_004()/272 cmd: $NMCLI --terse dev lldp list ifname eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -18309,7 +18427,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES:40 (wlan-access-point,telephone) <<< size: 775 -location: src/tests/client/test-client.py:test_004()/271 +location: src/tests/client/test-client.py:test_004()/273 cmd: $NMCLI --terse -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: C returncode: 0 @@ -18333,7 +18451,7 @@ connection.interface-name: <<< size: 785 -location: src/tests/client/test-client.py:test_004()/272 +location: src/tests/client/test-client.py:test_004()/274 cmd: $NMCLI --terse -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: pl_PL.UTF-8 returncode: 0 @@ -18356,12 +18474,12 @@ connection.type:802-11-wireless connection.interface-name: <<< -size: 2667 -location: src/tests/client/test-client.py:test_004()/273 +size: 2694 +location: src/tests/client/test-client.py:test_004()/275 cmd: $NMCLI --terse --color yes con s con-vpn-1 lang: C returncode: 0 -stdout: 2512 bytes +stdout: 2539 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -18386,6 +18504,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -18472,12 +18591,12 @@ VPN.CFG[2]:key2 = val2 VPN.CFG[3]:key3 = val3 <<< -size: 2677 -location: src/tests/client/test-client.py:test_004()/274 +size: 2704 +location: src/tests/client/test-client.py:test_004()/276 cmd: $NMCLI --terse --color yes con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 2512 bytes +stdout: 2539 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -18502,6 +18621,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -18588,12 +18708,12 @@ VPN.CFG[2]:key2 = val2 VPN.CFG[3]:key3 = val3 <<< -size: 2667 -location: src/tests/client/test-client.py:test_004()/275 +size: 2694 +location: src/tests/client/test-client.py:test_004()/277 cmd: $NMCLI --terse --color yes con s con-vpn-1 lang: C returncode: 0 -stdout: 2512 bytes +stdout: 2539 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -18618,6 +18738,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -18704,12 +18825,12 @@ VPN.CFG[2]:key2 = val2 VPN.CFG[3]:key3 = val3 <<< -size: 2677 -location: src/tests/client/test-client.py:test_004()/276 +size: 2704 +location: src/tests/client/test-client.py:test_004()/278 cmd: $NMCLI --terse --color yes con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 2512 bytes +stdout: 2539 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -18734,6 +18855,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -18820,12 +18942,12 @@ VPN.CFG[2]:key2 = val2 VPN.CFG[3]:key3 = val3 <<< -size: 2092 -location: src/tests/client/test-client.py:test_004()/277 +size: 2119 +location: src/tests/client/test-client.py:test_004()/279 cmd: $NMCLI --terse --color yes -f ALL con s con-vpn-1 lang: C returncode: 0 -stdout: 1930 bytes +stdout: 1957 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -18850,6 +18972,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -18915,12 +19038,12 @@ proxy.pac-url: proxy.pac-script: <<< -size: 2102 -location: src/tests/client/test-client.py:test_004()/278 +size: 2129 +location: src/tests/client/test-client.py:test_004()/280 cmd: $NMCLI --terse --color yes -f ALL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 1930 bytes +stdout: 1957 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -18945,6 +19068,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -19011,7 +19135,7 @@ proxy.pac-script: <<< size: 332 -location: src/tests/client/test-client.py:test_004()/279 +location: src/tests/client/test-client.py:test_004()/281 cmd: $NMCLI --terse --color yes -f VPN con s con-vpn-1 lang: C returncode: 0 @@ -19026,7 +19150,7 @@ vpn.timeout:0 <<< size: 342 -location: src/tests/client/test-client.py:test_004()/280 +location: src/tests/client/test-client.py:test_004()/282 cmd: $NMCLI --terse --color yes -f VPN con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -19041,7 +19165,7 @@ vpn.timeout:0 <<< size: 558 -location: src/tests/client/test-client.py:test_004()/281 +location: src/tests/client/test-client.py:test_004()/283 cmd: $NMCLI --terse --color yes -f GENERAL con s con-vpn-1 lang: C returncode: 0 @@ -19063,7 +19187,7 @@ GENERAL.MASTER-PATH: <<< size: 568 -location: src/tests/client/test-client.py:test_004()/282 +location: src/tests/client/test-client.py:test_004()/284 cmd: $NMCLI --terse --color yes -f GENERAL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -19085,7 +19209,7 @@ GENERAL.MASTER-PATH: <<< size: 441 -location: src/tests/client/test-client.py:test_004()/283 +location: src/tests/client/test-client.py:test_004()/285 cmd: $NMCLI --terse --color yes dev s lang: C returncode: 0 @@ -19099,7 +19223,7 @@ stdout: 297 bytes <<< size: 451 -location: src/tests/client/test-client.py:test_004()/284 +location: src/tests/client/test-client.py:test_004()/286 cmd: $NMCLI --terse --color yes dev s lang: pl_PL.UTF-8 returncode: 0 @@ -19113,7 +19237,7 @@ stdout: 297 bytes <<< size: 1044 -location: src/tests/client/test-client.py:test_004()/285 +location: src/tests/client/test-client.py:test_004()/287 cmd: $NMCLI --terse --color yes -f all dev status lang: C returncode: 0 @@ -19127,7 +19251,7 @@ stdout: 888 bytes <<< size: 1054 -location: src/tests/client/test-client.py:test_004()/286 +location: src/tests/client/test-client.py:test_004()/288 cmd: $NMCLI --terse --color yes -f all dev status lang: pl_PL.UTF-8 returncode: 0 @@ -19141,7 +19265,7 @@ stdout: 888 bytes <<< size: 4547 -location: src/tests/client/test-client.py:test_004()/287 +location: src/tests/client/test-client.py:test_004()/289 cmd: $NMCLI --terse --color yes dev show lang: C returncode: 0 @@ -19287,7 +19411,7 @@ IP6.DOMAIN[1]:sear6.fo.x.y <<< size: 4557 -location: src/tests/client/test-client.py:test_004()/288 +location: src/tests/client/test-client.py:test_004()/290 cmd: $NMCLI --terse --color yes dev show lang: pl_PL.UTF-8 returncode: 0 @@ -19433,7 +19557,7 @@ IP6.DOMAIN[1]:sear6.fo.x.y <<< size: 13457 -location: src/tests/client/test-client.py:test_004()/289 +location: src/tests/client/test-client.py:test_004()/291 cmd: $NMCLI --terse --color yes -f all dev show lang: C returncode: 0 @@ -19862,7 +19986,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 13503 -location: src/tests/client/test-client.py:test_004()/290 +location: src/tests/client/test-client.py:test_004()/292 cmd: $NMCLI --terse --color yes -f all dev show lang: pl_PL.UTF-8 returncode: 0 @@ -20291,7 +20415,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 891 -location: src/tests/client/test-client.py:test_004()/291 +location: src/tests/client/test-client.py:test_004()/293 cmd: $NMCLI --terse --color yes dev show wlan0 lang: C returncode: 0 @@ -20324,7 +20448,7 @@ IP6.DOMAIN[6]:sear6.foo4.bar <<< size: 901 -location: src/tests/client/test-client.py:test_004()/292 +location: src/tests/client/test-client.py:test_004()/294 cmd: $NMCLI --terse --color yes dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -20357,7 +20481,7 @@ IP6.DOMAIN[6]:sear6.foo4.bar <<< size: 3272 -location: src/tests/client/test-client.py:test_004()/293 +location: src/tests/client/test-client.py:test_004()/295 cmd: $NMCLI --terse --color yes -f all dev show wlan0 lang: C returncode: 0 @@ -20468,7 +20592,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 3309 -location: src/tests/client/test-client.py:test_004()/294 +location: src/tests/client/test-client.py:test_004()/296 cmd: $NMCLI --terse --color yes -f all dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -20579,7 +20703,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 1331 -location: src/tests/client/test-client.py:test_004()/295 +location: src/tests/client/test-client.py:test_004()/297 cmd: $NMCLI --terse --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -20628,7 +20752,7 @@ WIFI-PROPERTIES.IBSS-RSN:no <<< size: 1341 -location: src/tests/client/test-client.py:test_004()/296 +location: src/tests/client/test-client.py:test_004()/298 cmd: $NMCLI --terse --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -20677,7 +20801,7 @@ WIFI-PROPERTIES.IBSS-RSN:no <<< size: 1331 -location: src/tests/client/test-client.py:test_004()/297 +location: src/tests/client/test-client.py:test_004()/299 cmd: $NMCLI --terse --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -20726,7 +20850,7 @@ WIFI-PROPERTIES.IBSS-RSN:no <<< size: 1341 -location: src/tests/client/test-client.py:test_004()/298 +location: src/tests/client/test-client.py:test_004()/300 cmd: $NMCLI --terse --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -20775,7 +20899,7 @@ WIFI-PROPERTIES.IBSS-RSN:no <<< size: 561 -location: src/tests/client/test-client.py:test_004()/299 +location: src/tests/client/test-client.py:test_004()/301 cmd: $NMCLI --terse --color yes -f DEVICE,TYPE,DBUS-PATH dev lang: C returncode: 0 @@ -20789,7 +20913,7 @@ stdout: 394 bytes <<< size: 571 -location: src/tests/client/test-client.py:test_004()/300 +location: src/tests/client/test-client.py:test_004()/302 cmd: $NMCLI --terse --color yes -f DEVICE,TYPE,DBUS-PATH dev lang: pl_PL.UTF-8 returncode: 0 @@ -20803,7 +20927,7 @@ stdout: 394 bytes <<< size: 1709 -location: src/tests/client/test-client.py:test_004()/301 +location: src/tests/client/test-client.py:test_004()/303 cmd: $NMCLI --terse --color yes -f ALL device wifi list lang: C returncode: 0 @@ -20818,7 +20942,7 @@ stdout: 1546 bytes <<< size: 1767 -location: src/tests/client/test-client.py:test_004()/302 +location: src/tests/client/test-client.py:test_004()/304 cmd: $NMCLI --terse --color yes -f ALL device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -20833,7 +20957,7 @@ stdout: 1594 bytes <<< size: 769 -location: src/tests/client/test-client.py:test_004()/303 +location: src/tests/client/test-client.py:test_004()/305 cmd: $NMCLI --terse --color yes -f COMMON device wifi list lang: C returncode: 0 @@ -20848,7 +20972,7 @@ stdout: 604 bytes <<< size: 815 -location: src/tests/client/test-client.py:test_004()/304 +location: src/tests/client/test-client.py:test_004()/306 cmd: $NMCLI --terse --color yes -f COMMON device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -20863,7 +20987,7 @@ stdout: 640 bytes <<< size: 1822 -location: src/tests/client/test-client.py:test_004()/305 +location: src/tests/client/test-client.py:test_004()/307 cmd: $NMCLI --terse --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: C returncode: 0 @@ -20878,7 +21002,7 @@ stdout: 1546 bytes <<< size: 1880 -location: src/tests/client/test-client.py:test_004()/306 +location: src/tests/client/test-client.py:test_004()/308 cmd: $NMCLI --terse --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -20893,7 +21017,7 @@ stdout: 1594 bytes <<< size: 596 -location: src/tests/client/test-client.py:test_004()/307 +location: src/tests/client/test-client.py:test_004()/309 cmd: $NMCLI --terse --color yes -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -20905,7 +21029,7 @@ stdout: 410 bytes <<< size: 618 -location: src/tests/client/test-client.py:test_004()/308 +location: src/tests/client/test-client.py:test_004()/310 cmd: $NMCLI --terse --color yes -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -20917,7 +21041,7 @@ stdout: 422 bytes <<< size: 344 -location: src/tests/client/test-client.py:test_004()/309 +location: src/tests/client/test-client.py:test_004()/311 cmd: $NMCLI --terse --color yes -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -20929,7 +21053,7 @@ stdout: 155 bytes <<< size: 363 -location: src/tests/client/test-client.py:test_004()/310 +location: src/tests/client/test-client.py:test_004()/312 cmd: $NMCLI --terse --color yes -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -20941,7 +21065,7 @@ stdout: 164 bytes <<< size: 709 -location: src/tests/client/test-client.py:test_004()/311 +location: src/tests/client/test-client.py:test_004()/313 cmd: $NMCLI --terse --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -20953,7 +21077,7 @@ stdout: 410 bytes <<< size: 731 -location: src/tests/client/test-client.py:test_004()/312 +location: src/tests/client/test-client.py:test_004()/314 cmd: $NMCLI --terse --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -20965,7 +21089,7 @@ stdout: 422 bytes <<< size: 3275 -location: src/tests/client/test-client.py:test_004()/313 +location: src/tests/client/test-client.py:test_004()/315 cmd: $NMCLI --terse --color yes -f ALL device show wlan0 lang: C returncode: 0 @@ -21076,7 +21200,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 3312 -location: src/tests/client/test-client.py:test_004()/314 +location: src/tests/client/test-client.py:test_004()/316 cmd: $NMCLI --terse --color yes -f ALL device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -21187,7 +21311,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 904 -location: src/tests/client/test-client.py:test_004()/315 +location: src/tests/client/test-client.py:test_004()/317 cmd: $NMCLI --terse --color yes -f COMMON device show wlan0 lang: C returncode: 0 @@ -21220,7 +21344,7 @@ IP6.DOMAIN[6]:sear6.foo4.bar <<< size: 914 -location: src/tests/client/test-client.py:test_004()/316 +location: src/tests/client/test-client.py:test_004()/318 cmd: $NMCLI --terse --color yes -f COMMON device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -21253,7 +21377,7 @@ IP6.DOMAIN[6]:sear6.foo4.bar <<< size: 3307 -location: src/tests/client/test-client.py:test_004()/317 +location: src/tests/client/test-client.py:test_004()/319 cmd: $NMCLI --terse --color yes -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: C returncode: 0 @@ -21360,7 +21484,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 3344 -location: src/tests/client/test-client.py:test_004()/318 +location: src/tests/client/test-client.py:test_004()/320 cmd: $NMCLI --terse --color yes -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -21467,7 +21591,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 1146 -location: src/tests/client/test-client.py:test_004()/319 +location: src/tests/client/test-client.py:test_004()/321 cmd: $NMCLI --terse --color yes dev lldp list ifname eth0 lang: C returncode: 0 @@ -21497,7 +21621,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES:40 (wlan-access-point,telephone) <<< size: 1156 -location: src/tests/client/test-client.py:test_004()/320 +location: src/tests/client/test-client.py:test_004()/322 cmd: $NMCLI --terse --color yes dev lldp list ifname eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -21527,7 +21651,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES:40 (wlan-access-point,telephone) <<< size: 787 -location: src/tests/client/test-client.py:test_004()/321 +location: src/tests/client/test-client.py:test_004()/323 cmd: $NMCLI --terse --color yes -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: C returncode: 0 @@ -21551,7 +21675,7 @@ connection.interface-name: <<< size: 797 -location: src/tests/client/test-client.py:test_004()/322 +location: src/tests/client/test-client.py:test_004()/324 cmd: $NMCLI --terse --color yes -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: pl_PL.UTF-8 returncode: 0 @@ -21574,15 +21698,15 @@ connection.type:802-11-wireless connection.interface-name: <<< -size: 3454 -location: src/tests/client/test-client.py:test_004()/323 +size: 3482 +location: src/tests/client/test-client.py:test_004()/325 cmd: $NMCLI --mode tabular con s con-vpn-1 lang: C returncode: 0 -stdout: 3304 bytes +stdout: 3332 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers ipv4 auto -- -- -- 0 -- -- -- -1 0 (unspec) -- no no -- -- 0 (default) yes -- -- 0x0 (none) no yes -1 (default) -1 (default) -- -- @@ -21603,15 +21727,15 @@ NAME TYPE USERNAME GATEWAY BANNER VPN-STATE VPN openvpn -- -- *** VPN connection con-vpn-1 *** 5 - VPN connected key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 3477 -location: src/tests/client/test-client.py:test_004()/324 +size: 3505 +location: src/tests/client/test-client.py:test_004()/326 cmd: $NMCLI --mode tabular con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 3317 bytes +stdout: 3345 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers ipv4 auto -- -- -- 0 -- -- -- -1 0 (unspec) -- nie nie -- -- 0 (default) tak -- -- 0x0 (none) nie tak -1 (default) -1 (default) -- -- @@ -21632,15 +21756,15 @@ NAME TYPE USERNAME GATEWAY BANNER VPN-STATE VPN openvpn -- -- *** VPN connection con-vpn-1 *** 5 — Połączono z VPN key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 3454 -location: src/tests/client/test-client.py:test_004()/325 +size: 3482 +location: src/tests/client/test-client.py:test_004()/327 cmd: $NMCLI --mode tabular con s con-vpn-1 lang: C returncode: 0 -stdout: 3304 bytes +stdout: 3332 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers ipv4 auto -- -- -- 0 -- -- -- -1 0 (unspec) -- no no -- -- 0 (default) yes -- -- 0x0 (none) no yes -1 (default) -1 (default) -- -- @@ -21661,15 +21785,15 @@ NAME TYPE USERNAME GATEWAY BANNER VPN-STATE VPN openvpn -- -- *** VPN connection con-vpn-1 *** 5 - VPN connected key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 3477 -location: src/tests/client/test-client.py:test_004()/326 +size: 3505 +location: src/tests/client/test-client.py:test_004()/328 cmd: $NMCLI --mode tabular con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 3317 bytes +stdout: 3345 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers ipv4 auto -- -- -- 0 -- -- -- -1 0 (unspec) -- nie nie -- -- 0 (default) tak -- -- 0x0 (none) nie tak -1 (default) -1 (default) -- -- @@ -21690,15 +21814,15 @@ NAME TYPE USERNAME GATEWAY BANNER VPN-STATE VPN openvpn -- -- *** VPN connection con-vpn-1 *** 5 — Połączono z VPN key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 2702 -location: src/tests/client/test-client.py:test_004()/327 +size: 2730 +location: src/tests/client/test-client.py:test_004()/329 cmd: $NMCLI --mode tabular -f ALL con s con-vpn-1 lang: C returncode: 0 -stdout: 2545 bytes +stdout: 2573 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers ipv4 auto -- -- -- 0 -- -- -- -1 0 (unspec) -- no no -- -- 0 (default) yes -- -- 0x0 (none) no yes -1 (default) -1 (default) -- -- @@ -21714,15 +21838,15 @@ proxy none no -- -- <<< -size: 2714 -location: src/tests/client/test-client.py:test_004()/328 +size: 2742 +location: src/tests/client/test-client.py:test_004()/330 cmd: $NMCLI --mode tabular -f ALL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 2547 bytes +stdout: 2575 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers ipv4 auto -- -- -- 0 -- -- -- -1 0 (unspec) -- nie nie -- -- 0 (default) tak -- -- 0x0 (none) nie tak -1 (default) -1 (default) -- -- @@ -21739,7 +21863,7 @@ proxy none nie -- -- <<< size: 410 -location: src/tests/client/test-client.py:test_004()/329 +location: src/tests/client/test-client.py:test_004()/331 cmd: $NMCLI --mode tabular -f VPN con s con-vpn-1 lang: C returncode: 0 @@ -21750,7 +21874,7 @@ vpn org.freedesktop.NetworkManager.openvpn -- key1 = val1, key2 = val <<< size: 420 -location: src/tests/client/test-client.py:test_004()/330 +location: src/tests/client/test-client.py:test_004()/332 cmd: $NMCLI --mode tabular -f VPN con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -21761,7 +21885,7 @@ vpn org.freedesktop.NetworkManager.openvpn -- key1 = val1, key2 = val <<< size: 662 -location: src/tests/client/test-client.py:test_004()/331 +location: src/tests/client/test-client.py:test_004()/333 cmd: $NMCLI --mode tabular -f GENERAL con s con-vpn-1 lang: C returncode: 0 @@ -21772,7 +21896,7 @@ GENERAL con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP wlan0 wlan0 act <<< size: 674 -location: src/tests/client/test-client.py:test_004()/332 +location: src/tests/client/test-client.py:test_004()/334 cmd: $NMCLI --mode tabular -f GENERAL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -21783,7 +21907,7 @@ GENERAL con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP wlan0 wlan0 akt <<< size: 397 -location: src/tests/client/test-client.py:test_004()/333 +location: src/tests/client/test-client.py:test_004()/335 cmd: $NMCLI --mode tabular dev s lang: C returncode: 0 @@ -21798,7 +21922,7 @@ wlan1 wifi unavailable -- <<< size: 413 -location: src/tests/client/test-client.py:test_004()/334 +location: src/tests/client/test-client.py:test_004()/336 cmd: $NMCLI --mode tabular dev s lang: pl_PL.UTF-8 returncode: 0 @@ -21813,7 +21937,7 @@ wlan1 wifi niedostępne -- <<< size: 1424 -location: src/tests/client/test-client.py:test_004()/335 +location: src/tests/client/test-client.py:test_004()/337 cmd: $NMCLI --mode tabular -f all dev status lang: C returncode: 0 @@ -21828,7 +21952,7 @@ wlan1 wifi unavailable unknown unknown /org/freedesk <<< size: 1440 -location: src/tests/client/test-client.py:test_004()/336 +location: src/tests/client/test-client.py:test_004()/338 cmd: $NMCLI --mode tabular -f all dev status lang: pl_PL.UTF-8 returncode: 0 @@ -21843,7 +21967,7 @@ wlan1 wifi niedostępne nieznane nieznane /org/freedes <<< size: 6557 -location: src/tests/client/test-client.py:test_004()/337 +location: src/tests/client/test-client.py:test_004()/339 cmd: $NMCLI --mode tabular dev show lang: C returncode: 0 @@ -21992,7 +22116,7 @@ IP6 2001:a::88ca:3654:96b:ab44/89 -- dst = 2001:a::cc8b:7c09:4673:bbb0 <<< size: 6581 -location: src/tests/client/test-client.py:test_004()/338 +location: src/tests/client/test-client.py:test_004()/340 cmd: $NMCLI --mode tabular dev show lang: pl_PL.UTF-8 returncode: 0 @@ -22141,7 +22265,7 @@ IP6 2001:a::88ca:3654:96b:ab44/89 -- dst = 2001:a::cc8b:7c09:4673:bbb0 <<< size: 16269 -location: src/tests/client/test-client.py:test_004()/339 +location: src/tests/client/test-client.py:test_004()/341 cmd: $NMCLI --mode tabular -f all dev show lang: C returncode: 0 @@ -22294,7 +22418,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 16425 -location: src/tests/client/test-client.py:test_004()/340 +location: src/tests/client/test-client.py:test_004()/342 cmd: $NMCLI --mode tabular -f all dev show lang: pl_PL.UTF-8 returncode: 0 @@ -22447,7 +22571,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 1167 -location: src/tests/client/test-client.py:test_004()/341 +location: src/tests/client/test-client.py:test_004()/343 cmd: $NMCLI --mode tabular dev show wlan0 lang: C returncode: 0 @@ -22482,7 +22606,7 @@ IP6 -- -- dst = 2001:a::dd5b:aa7b:b4a2:e42/102, nh = ::, mt = 250 <<< size: 1179 -location: src/tests/client/test-client.py:test_004()/342 +location: src/tests/client/test-client.py:test_004()/344 cmd: $NMCLI --mode tabular dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -22517,7 +22641,7 @@ IP6 -- -- dst = 2001:a::dd5b:aa7b:b4a2:e42/102, nh = ::, mt = 250 <<< size: 3355 -location: src/tests/client/test-client.py:test_004()/343 +location: src/tests/client/test-client.py:test_004()/345 cmd: $NMCLI --mode tabular -f all dev show wlan0 lang: C returncode: 0 @@ -22557,7 +22681,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 3419 -location: src/tests/client/test-client.py:test_004()/344 +location: src/tests/client/test-client.py:test_004()/346 cmd: $NMCLI --mode tabular -f all dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -22597,7 +22721,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 1377 -location: src/tests/client/test-client.py:test_004()/345 +location: src/tests/client/test-client.py:test_004()/347 cmd: $NMCLI --mode tabular -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -22614,7 +22738,7 @@ WIFI-PROPERTIES yes yes yes yes yes yes yes unknown unknown no <<< size: 1405 -location: src/tests/client/test-client.py:test_004()/346 +location: src/tests/client/test-client.py:test_004()/348 cmd: $NMCLI --mode tabular -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -22631,7 +22755,7 @@ WIFI-PROPERTIES tak tak tak tak tak tak tak nieznane nieznane nie <<< size: 1377 -location: src/tests/client/test-client.py:test_004()/347 +location: src/tests/client/test-client.py:test_004()/349 cmd: $NMCLI --mode tabular -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -22648,7 +22772,7 @@ WIFI-PROPERTIES yes yes yes yes yes yes yes unknown unknown no <<< size: 1405 -location: src/tests/client/test-client.py:test_004()/348 +location: src/tests/client/test-client.py:test_004()/350 cmd: $NMCLI --mode tabular -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -22665,7 +22789,7 @@ WIFI-PROPERTIES tak tak tak tak tak tak tak nieznane nieznane nie <<< size: 528 -location: src/tests/client/test-client.py:test_004()/349 +location: src/tests/client/test-client.py:test_004()/351 cmd: $NMCLI --mode tabular -f DEVICE,TYPE,DBUS-PATH dev lang: C returncode: 0 @@ -22680,7 +22804,7 @@ wlan1 wifi /org/freedesktop/NetworkManager/Devices/5 <<< size: 538 -location: src/tests/client/test-client.py:test_004()/350 +location: src/tests/client/test-client.py:test_004()/352 cmd: $NMCLI --mode tabular -f DEVICE,TYPE,DBUS-PATH dev lang: pl_PL.UTF-8 returncode: 0 @@ -22695,7 +22819,7 @@ wlan1 wifi /org/freedesktop/NetworkManager/Devices/5 <<< size: 1998 -location: src/tests/client/test-client.py:test_004()/351 +location: src/tests/client/test-client.py:test_004()/353 cmd: $NMCLI --mode tabular -f ALL device wifi list lang: C returncode: 0 @@ -22713,7 +22837,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 2066 -location: src/tests/client/test-client.py:test_004()/352 +location: src/tests/client/test-client.py:test_004()/354 cmd: $NMCLI --mode tabular -f ALL device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -22731,7 +22855,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 753 -location: src/tests/client/test-client.py:test_004()/353 +location: src/tests/client/test-client.py:test_004()/355 cmd: $NMCLI --mode tabular -f COMMON device wifi list lang: C returncode: 0 @@ -22749,7 +22873,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY <<< size: 813 -location: src/tests/client/test-client.py:test_004()/354 +location: src/tests/client/test-client.py:test_004()/356 cmd: $NMCLI --mode tabular -f COMMON device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -22767,7 +22891,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY <<< size: 2111 -location: src/tests/client/test-client.py:test_004()/355 +location: src/tests/client/test-client.py:test_004()/357 cmd: $NMCLI --mode tabular -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: C returncode: 0 @@ -22785,7 +22909,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 2179 -location: src/tests/client/test-client.py:test_004()/356 +location: src/tests/client/test-client.py:test_004()/358 cmd: $NMCLI --mode tabular -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -22803,7 +22927,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 751 -location: src/tests/client/test-client.py:test_004()/357 +location: src/tests/client/test-client.py:test_004()/359 cmd: $NMCLI --mode tabular -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -22816,7 +22940,7 @@ AP[1] wlan0-ap-2 776C616E302D61702D32 C0:E2:BE:E8:EF:B6 Infra 1 2412 MH <<< size: 779 -location: src/tests/client/test-client.py:test_004()/358 +location: src/tests/client/test-client.py:test_004()/360 cmd: $NMCLI --mode tabular -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -22829,7 +22953,7 @@ AP[1] wlan0-ap-2 776C616E302D61702D32 C0:E2:BE:E8:EF:B6 Infrastruktura 1 <<< size: 362 -location: src/tests/client/test-client.py:test_004()/359 +location: src/tests/client/test-client.py:test_004()/361 cmd: $NMCLI --mode tabular -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -22842,7 +22966,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SEC <<< size: 388 -location: src/tests/client/test-client.py:test_004()/360 +location: src/tests/client/test-client.py:test_004()/362 cmd: $NMCLI --mode tabular -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -22855,7 +22979,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BA <<< size: 864 -location: src/tests/client/test-client.py:test_004()/361 +location: src/tests/client/test-client.py:test_004()/363 cmd: $NMCLI --mode tabular -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -22868,7 +22992,7 @@ AP[1] wlan0-ap-2 776C616E302D61702D32 C0:E2:BE:E8:EF:B6 Infra 1 2412 MH <<< size: 892 -location: src/tests/client/test-client.py:test_004()/362 +location: src/tests/client/test-client.py:test_004()/364 cmd: $NMCLI --mode tabular -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -22881,7 +23005,7 @@ AP[1] wlan0-ap-2 776C616E302D61702D32 C0:E2:BE:E8:EF:B6 Infrastruktura 1 <<< size: 3358 -location: src/tests/client/test-client.py:test_004()/363 +location: src/tests/client/test-client.py:test_004()/365 cmd: $NMCLI --mode tabular -f ALL device show wlan0 lang: C returncode: 0 @@ -22921,7 +23045,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 3422 -location: src/tests/client/test-client.py:test_004()/364 +location: src/tests/client/test-client.py:test_004()/366 cmd: $NMCLI --mode tabular -f ALL device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -22961,7 +23085,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 1180 -location: src/tests/client/test-client.py:test_004()/365 +location: src/tests/client/test-client.py:test_004()/367 cmd: $NMCLI --mode tabular -f COMMON device show wlan0 lang: C returncode: 0 @@ -22996,7 +23120,7 @@ IP6 -- -- dst = 2001:a::dd5b:aa7b:b4a2:e42/102, nh = ::, mt = 250 <<< size: 1192 -location: src/tests/client/test-client.py:test_004()/366 +location: src/tests/client/test-client.py:test_004()/368 cmd: $NMCLI --mode tabular -f COMMON device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -23031,7 +23155,7 @@ IP6 -- -- dst = 2001:a::dd5b:aa7b:b4a2:e42/102, nh = ::, mt = 250 <<< size: 3395 -location: src/tests/client/test-client.py:test_004()/367 +location: src/tests/client/test-client.py:test_004()/369 cmd: $NMCLI --mode tabular -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: C returncode: 0 @@ -23068,7 +23192,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 3459 -location: src/tests/client/test-client.py:test_004()/368 +location: src/tests/client/test-client.py:test_004()/370 cmd: $NMCLI --mode tabular -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -23105,7 +23229,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 1143 -location: src/tests/client/test-client.py:test_004()/369 +location: src/tests/client/test-client.py:test_004()/371 cmd: $NMCLI --mode tabular dev lldp list ifname eth0 lang: C returncode: 0 @@ -23118,7 +23242,7 @@ eth0 00:11:22:33:44:22 port1 GigabitEthernet #3 test3.example. <<< size: 1153 -location: src/tests/client/test-client.py:test_004()/370 +location: src/tests/client/test-client.py:test_004()/372 cmd: $NMCLI --mode tabular dev lldp list ifname eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -23131,7 +23255,7 @@ eth0 00:11:22:33:44:22 port1 GigabitEthernet #3 test3.example. <<< size: 868 -location: src/tests/client/test-client.py:test_004()/371 +location: src/tests/client/test-client.py:test_004()/373 cmd: $NMCLI --mode tabular -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: C returncode: 0 @@ -23180,7 +23304,7 @@ interface-name <<< size: 878 -location: src/tests/client/test-client.py:test_004()/372 +location: src/tests/client/test-client.py:test_004()/374 cmd: $NMCLI --mode tabular -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: pl_PL.UTF-8 returncode: 0 @@ -23228,15 +23352,15 @@ interface-name <<< -size: 3466 -location: src/tests/client/test-client.py:test_004()/373 +size: 3494 +location: src/tests/client/test-client.py:test_004()/375 cmd: $NMCLI --mode tabular --color yes con s con-vpn-1 lang: C returncode: 0 -stdout: 3304 bytes +stdout: 3332 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers ipv4 auto -- -- -- 0 -- -- -- -1 0 (unspec) -- no no -- -- 0 (default) yes -- -- 0x0 (none) no yes -1 (default) -1 (default) -- -- @@ -23257,15 +23381,15 @@ NAME TYPE USERNAME GATEWAY BANNER VPN-STATE VPN openvpn -- -- *** VPN connection con-vpn-1 *** 5 - VPN connected key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 3489 -location: src/tests/client/test-client.py:test_004()/374 +size: 3517 +location: src/tests/client/test-client.py:test_004()/376 cmd: $NMCLI --mode tabular --color yes con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 3317 bytes +stdout: 3345 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers ipv4 auto -- -- -- 0 -- -- -- -1 0 (unspec) -- nie nie -- -- 0 (default) tak -- -- 0x0 (none) nie tak -1 (default) -1 (default) -- -- @@ -23286,15 +23410,15 @@ NAME TYPE USERNAME GATEWAY BANNER VPN-STATE VPN openvpn -- -- *** VPN connection con-vpn-1 *** 5 — Połączono z VPN key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 3466 -location: src/tests/client/test-client.py:test_004()/375 +size: 3494 +location: src/tests/client/test-client.py:test_004()/377 cmd: $NMCLI --mode tabular --color yes con s con-vpn-1 lang: C returncode: 0 -stdout: 3304 bytes +stdout: 3332 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers ipv4 auto -- -- -- 0 -- -- -- -1 0 (unspec) -- no no -- -- 0 (default) yes -- -- 0x0 (none) no yes -1 (default) -1 (default) -- -- @@ -23315,15 +23439,15 @@ NAME TYPE USERNAME GATEWAY BANNER VPN-STATE VPN openvpn -- -- *** VPN connection con-vpn-1 *** 5 - VPN connected key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 3489 -location: src/tests/client/test-client.py:test_004()/376 +size: 3517 +location: src/tests/client/test-client.py:test_004()/378 cmd: $NMCLI --mode tabular --color yes con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 3317 bytes +stdout: 3345 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers ipv4 auto -- -- -- 0 -- -- -- -1 0 (unspec) -- nie nie -- -- 0 (default) tak -- -- 0x0 (none) nie tak -1 (default) -1 (default) -- -- @@ -23344,15 +23468,15 @@ NAME TYPE USERNAME GATEWAY BANNER VPN-STATE VPN openvpn -- -- *** VPN connection con-vpn-1 *** 5 — Połączono z VPN key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 2714 -location: src/tests/client/test-client.py:test_004()/377 +size: 2742 +location: src/tests/client/test-client.py:test_004()/379 cmd: $NMCLI --mode tabular --color yes -f ALL con s con-vpn-1 lang: C returncode: 0 -stdout: 2545 bytes +stdout: 2573 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers ipv4 auto -- -- -- 0 -- -- -- -1 0 (unspec) -- no no -- -- 0 (default) yes -- -- 0x0 (none) no yes -1 (default) -1 (default) -- -- @@ -23368,15 +23492,15 @@ proxy none no -- -- <<< -size: 2726 -location: src/tests/client/test-client.py:test_004()/378 +size: 2754 +location: src/tests/client/test-client.py:test_004()/380 cmd: $NMCLI --mode tabular --color yes -f ALL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 2547 bytes +stdout: 2575 bytes >>> -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers ipv4 auto -- -- -- 0 -- -- -- -1 0 (unspec) -- nie nie -- -- 0 (default) tak -- -- 0x0 (none) nie tak -1 (default) -1 (default) -- -- @@ -23393,7 +23517,7 @@ proxy none nie -- -- <<< size: 422 -location: src/tests/client/test-client.py:test_004()/379 +location: src/tests/client/test-client.py:test_004()/381 cmd: $NMCLI --mode tabular --color yes -f VPN con s con-vpn-1 lang: C returncode: 0 @@ -23404,7 +23528,7 @@ vpn org.freedesktop.NetworkManager.openvpn -- key1 = val1, key2 = val <<< size: 432 -location: src/tests/client/test-client.py:test_004()/380 +location: src/tests/client/test-client.py:test_004()/382 cmd: $NMCLI --mode tabular --color yes -f VPN con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -23415,7 +23539,7 @@ vpn org.freedesktop.NetworkManager.openvpn -- key1 = val1, key2 = val <<< size: 674 -location: src/tests/client/test-client.py:test_004()/381 +location: src/tests/client/test-client.py:test_004()/383 cmd: $NMCLI --mode tabular --color yes -f GENERAL con s con-vpn-1 lang: C returncode: 0 @@ -23426,7 +23550,7 @@ GENERAL con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP wlan0 wlan0 act <<< size: 686 -location: src/tests/client/test-client.py:test_004()/382 +location: src/tests/client/test-client.py:test_004()/384 cmd: $NMCLI --mode tabular --color yes -f GENERAL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -23437,7 +23561,7 @@ GENERAL con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP wlan0 wlan0 akt <<< size: 573 -location: src/tests/client/test-client.py:test_004()/383 +location: src/tests/client/test-client.py:test_004()/385 cmd: $NMCLI --mode tabular --color yes dev s lang: C returncode: 0 @@ -23452,7 +23576,7 @@ DEVICE TYPE STATE CONNECTION <<< size: 589 -location: src/tests/client/test-client.py:test_004()/384 +location: src/tests/client/test-client.py:test_004()/386 cmd: $NMCLI --mode tabular --color yes dev s lang: pl_PL.UTF-8 returncode: 0 @@ -23467,7 +23591,7 @@ DEVICE TYPE STATE CONNECTION <<< size: 1805 -location: src/tests/client/test-client.py:test_004()/385 +location: src/tests/client/test-client.py:test_004()/387 cmd: $NMCLI --mode tabular --color yes -f all dev status lang: C returncode: 0 @@ -23482,7 +23606,7 @@ DEVICE TYPE STATE IP4-CONNECTIVITY IP6-CONNECTIVITY DBUS-PATH <<< size: 1821 -location: src/tests/client/test-client.py:test_004()/386 +location: src/tests/client/test-client.py:test_004()/388 cmd: $NMCLI --mode tabular --color yes -f all dev status lang: pl_PL.UTF-8 returncode: 0 @@ -23497,7 +23621,7 @@ DEVICE TYPE STATE IP4-CONNECTIVITY IP6-CONNECTIVITY DBUS-PATH <<< size: 6569 -location: src/tests/client/test-client.py:test_004()/387 +location: src/tests/client/test-client.py:test_004()/389 cmd: $NMCLI --mode tabular --color yes dev show lang: C returncode: 0 @@ -23646,7 +23770,7 @@ IP6 2001:a::88ca:3654:96b:ab44/89 -- dst = 2001:a::cc8b:7c09:4673:bbb0 <<< size: 6593 -location: src/tests/client/test-client.py:test_004()/388 +location: src/tests/client/test-client.py:test_004()/390 cmd: $NMCLI --mode tabular --color yes dev show lang: pl_PL.UTF-8 returncode: 0 @@ -23795,7 +23919,7 @@ IP6 2001:a::88ca:3654:96b:ab44/89 -- dst = 2001:a::cc8b:7c09:4673:bbb0 <<< size: 16641 -location: src/tests/client/test-client.py:test_004()/389 +location: src/tests/client/test-client.py:test_004()/391 cmd: $NMCLI --mode tabular --color yes -f all dev show lang: C returncode: 0 @@ -23948,7 +24072,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 16797 -location: src/tests/client/test-client.py:test_004()/390 +location: src/tests/client/test-client.py:test_004()/392 cmd: $NMCLI --mode tabular --color yes -f all dev show lang: pl_PL.UTF-8 returncode: 0 @@ -24101,7 +24225,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 1179 -location: src/tests/client/test-client.py:test_004()/391 +location: src/tests/client/test-client.py:test_004()/393 cmd: $NMCLI --mode tabular --color yes dev show wlan0 lang: C returncode: 0 @@ -24136,7 +24260,7 @@ IP6 -- -- dst = 2001:a::dd5b:aa7b:b4a2:e42/102, nh = ::, mt = 250 <<< size: 1191 -location: src/tests/client/test-client.py:test_004()/392 +location: src/tests/client/test-client.py:test_004()/394 cmd: $NMCLI --mode tabular --color yes dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -24171,7 +24295,7 @@ IP6 -- -- dst = 2001:a::dd5b:aa7b:b4a2:e42/102, nh = ::, mt = 250 <<< size: 3637 -location: src/tests/client/test-client.py:test_004()/393 +location: src/tests/client/test-client.py:test_004()/395 cmd: $NMCLI --mode tabular --color yes -f all dev show wlan0 lang: C returncode: 0 @@ -24211,7 +24335,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 3701 -location: src/tests/client/test-client.py:test_004()/394 +location: src/tests/client/test-client.py:test_004()/396 cmd: $NMCLI --mode tabular --color yes -f all dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -24251,7 +24375,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 1389 -location: src/tests/client/test-client.py:test_004()/395 +location: src/tests/client/test-client.py:test_004()/397 cmd: $NMCLI --mode tabular --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -24268,7 +24392,7 @@ WIFI-PROPERTIES yes yes yes yes yes yes yes unknown unknown no <<< size: 1417 -location: src/tests/client/test-client.py:test_004()/396 +location: src/tests/client/test-client.py:test_004()/398 cmd: $NMCLI --mode tabular --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -24285,7 +24409,7 @@ WIFI-PROPERTIES tak tak tak tak tak tak tak nieznane nieznane nie <<< size: 1389 -location: src/tests/client/test-client.py:test_004()/397 +location: src/tests/client/test-client.py:test_004()/399 cmd: $NMCLI --mode tabular --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -24302,7 +24426,7 @@ WIFI-PROPERTIES yes yes yes yes yes yes yes unknown unknown no <<< size: 1417 -location: src/tests/client/test-client.py:test_004()/398 +location: src/tests/client/test-client.py:test_004()/400 cmd: $NMCLI --mode tabular --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -24319,7 +24443,7 @@ WIFI-PROPERTIES tak tak tak tak tak tak tak nieznane nieznane nie <<< size: 663 -location: src/tests/client/test-client.py:test_004()/399 +location: src/tests/client/test-client.py:test_004()/401 cmd: $NMCLI --mode tabular --color yes -f DEVICE,TYPE,DBUS-PATH dev lang: C returncode: 0 @@ -24334,7 +24458,7 @@ DEVICE TYPE DBUS-PATH <<< size: 673 -location: src/tests/client/test-client.py:test_004()/400 +location: src/tests/client/test-client.py:test_004()/402 cmd: $NMCLI --mode tabular --color yes -f DEVICE,TYPE,DBUS-PATH dev lang: pl_PL.UTF-8 returncode: 0 @@ -24349,7 +24473,7 @@ DEVICE TYPE DBUS-PATH <<< size: 2622 -location: src/tests/client/test-client.py:test_004()/401 +location: src/tests/client/test-client.py:test_004()/403 cmd: $NMCLI --mode tabular --color yes -f ALL device wifi list lang: C returncode: 0 @@ -24367,7 +24491,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 2690 -location: src/tests/client/test-client.py:test_004()/402 +location: src/tests/client/test-client.py:test_004()/404 cmd: $NMCLI --mode tabular --color yes -f ALL device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -24385,7 +24509,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 1089 -location: src/tests/client/test-client.py:test_004()/403 +location: src/tests/client/test-client.py:test_004()/405 cmd: $NMCLI --mode tabular --color yes -f COMMON device wifi list lang: C returncode: 0 @@ -24403,7 +24527,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY <<< size: 1149 -location: src/tests/client/test-client.py:test_004()/404 +location: src/tests/client/test-client.py:test_004()/406 cmd: $NMCLI --mode tabular --color yes -f COMMON device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -24421,7 +24545,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY <<< size: 2735 -location: src/tests/client/test-client.py:test_004()/405 +location: src/tests/client/test-client.py:test_004()/407 cmd: $NMCLI --mode tabular --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: C returncode: 0 @@ -24439,7 +24563,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 2803 -location: src/tests/client/test-client.py:test_004()/406 +location: src/tests/client/test-client.py:test_004()/408 cmd: $NMCLI --mode tabular --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -24457,7 +24581,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 916 -location: src/tests/client/test-client.py:test_004()/407 +location: src/tests/client/test-client.py:test_004()/409 cmd: $NMCLI --mode tabular --color yes -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -24470,7 +24594,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ <<< size: 944 -location: src/tests/client/test-client.py:test_004()/408 +location: src/tests/client/test-client.py:test_004()/410 cmd: $NMCLI --mode tabular --color yes -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -24483,7 +24607,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN <<< size: 455 -location: src/tests/client/test-client.py:test_004()/409 +location: src/tests/client/test-client.py:test_004()/411 cmd: $NMCLI --mode tabular --color yes -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -24496,7 +24620,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SEC <<< size: 481 -location: src/tests/client/test-client.py:test_004()/410 +location: src/tests/client/test-client.py:test_004()/412 cmd: $NMCLI --mode tabular --color yes -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -24509,7 +24633,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BA <<< size: 1029 -location: src/tests/client/test-client.py:test_004()/411 +location: src/tests/client/test-client.py:test_004()/413 cmd: $NMCLI --mode tabular --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -24522,7 +24646,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ <<< size: 1057 -location: src/tests/client/test-client.py:test_004()/412 +location: src/tests/client/test-client.py:test_004()/414 cmd: $NMCLI --mode tabular --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -24535,7 +24659,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN <<< size: 3640 -location: src/tests/client/test-client.py:test_004()/413 +location: src/tests/client/test-client.py:test_004()/415 cmd: $NMCLI --mode tabular --color yes -f ALL device show wlan0 lang: C returncode: 0 @@ -24575,7 +24699,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 3704 -location: src/tests/client/test-client.py:test_004()/414 +location: src/tests/client/test-client.py:test_004()/416 cmd: $NMCLI --mode tabular --color yes -f ALL device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -24615,7 +24739,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 1192 -location: src/tests/client/test-client.py:test_004()/415 +location: src/tests/client/test-client.py:test_004()/417 cmd: $NMCLI --mode tabular --color yes -f COMMON device show wlan0 lang: C returncode: 0 @@ -24650,7 +24774,7 @@ IP6 -- -- dst = 2001:a::dd5b:aa7b:b4a2:e42/102, nh = ::, mt = 250 <<< size: 1204 -location: src/tests/client/test-client.py:test_004()/416 +location: src/tests/client/test-client.py:test_004()/418 cmd: $NMCLI --mode tabular --color yes -f COMMON device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -24685,7 +24809,7 @@ IP6 -- -- dst = 2001:a::dd5b:aa7b:b4a2:e42/102, nh = ::, mt = 250 <<< size: 3677 -location: src/tests/client/test-client.py:test_004()/417 +location: src/tests/client/test-client.py:test_004()/419 cmd: $NMCLI --mode tabular --color yes -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: C returncode: 0 @@ -24722,7 +24846,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 3741 -location: src/tests/client/test-client.py:test_004()/418 +location: src/tests/client/test-client.py:test_004()/420 cmd: $NMCLI --mode tabular --color yes -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -24759,7 +24883,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 1155 -location: src/tests/client/test-client.py:test_004()/419 +location: src/tests/client/test-client.py:test_004()/421 cmd: $NMCLI --mode tabular --color yes dev lldp list ifname eth0 lang: C returncode: 0 @@ -24772,7 +24896,7 @@ eth0 00:11:22:33:44:22 port1 GigabitEthernet #3 test3.example. <<< size: 1165 -location: src/tests/client/test-client.py:test_004()/420 +location: src/tests/client/test-client.py:test_004()/422 cmd: $NMCLI --mode tabular --color yes dev lldp list ifname eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -24785,7 +24909,7 @@ eth0 00:11:22:33:44:22 port1 GigabitEthernet #3 test3.example. <<< size: 880 -location: src/tests/client/test-client.py:test_004()/421 +location: src/tests/client/test-client.py:test_004()/423 cmd: $NMCLI --mode tabular --color yes -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: C returncode: 0 @@ -24834,7 +24958,7 @@ interface-name <<< size: 890 -location: src/tests/client/test-client.py:test_004()/422 +location: src/tests/client/test-client.py:test_004()/424 cmd: $NMCLI --mode tabular --color yes -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: pl_PL.UTF-8 returncode: 0 @@ -24882,19 +25006,19 @@ interface-name <<< -size: 5457 -location: src/tests/client/test-client.py:test_004()/423 +size: 5499 +location: src/tests/client/test-client.py:test_004()/425 cmd: $NMCLI --mode tabular --pretty con s con-vpn-1 lang: C returncode: 0 -stdout: 5298 bytes +stdout: 5340 bytes >>> ========================================== Connection profile details (con-vpn-1) ========================================== -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -24924,19 +25048,19 @@ NAME TYPE USERNAME GATEWAY BANNER VPN-STATE VPN openvpn -- -- *** VPN connection con-vpn-1 *** 5 - VPN connected key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 5513 -location: src/tests/client/test-client.py:test_004()/424 +size: 5555 +location: src/tests/client/test-client.py:test_004()/426 cmd: $NMCLI --mode tabular --pretty con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5344 bytes +stdout: 5386 bytes >>> ============================================ Szczegóły profilu połączenia (con-vpn-1) ============================================ -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -24966,19 +25090,19 @@ NAME TYPE USERNAME GATEWAY BANNER VPN-STATE VPN openvpn -- -- *** VPN connection con-vpn-1 *** 5 — Połączono z VPN key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 5457 -location: src/tests/client/test-client.py:test_004()/425 +size: 5499 +location: src/tests/client/test-client.py:test_004()/427 cmd: $NMCLI --mode tabular --pretty con s con-vpn-1 lang: C returncode: 0 -stdout: 5298 bytes +stdout: 5340 bytes >>> ========================================== Connection profile details (con-vpn-1) ========================================== -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -25008,19 +25132,19 @@ NAME TYPE USERNAME GATEWAY BANNER VPN-STATE VPN openvpn -- -- *** VPN connection con-vpn-1 *** 5 - VPN connected key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 5513 -location: src/tests/client/test-client.py:test_004()/426 +size: 5555 +location: src/tests/client/test-client.py:test_004()/428 cmd: $NMCLI --mode tabular --pretty con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5344 bytes +stdout: 5386 bytes >>> ============================================ Szczegóły profilu połączenia (con-vpn-1) ============================================ -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -25050,19 +25174,19 @@ NAME TYPE USERNAME GATEWAY BANNER VPN-STATE VPN openvpn -- -- *** VPN connection con-vpn-1 *** 5 — Połączono z VPN key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 4113 -location: src/tests/client/test-client.py:test_004()/427 +size: 4155 +location: src/tests/client/test-client.py:test_004()/429 cmd: $NMCLI --mode tabular --pretty -f ALL con s con-vpn-1 lang: C returncode: 0 -stdout: 3947 bytes +stdout: 3989 bytes >>> ========================================== Connection profile details (con-vpn-1) ========================================== -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -25082,19 +25206,19 @@ proxy none no -- -- <<< -size: 4136 -location: src/tests/client/test-client.py:test_004()/428 +size: 4178 +location: src/tests/client/test-client.py:test_004()/430 cmd: $NMCLI --mode tabular --pretty -f ALL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 3960 bytes +stdout: 4002 bytes >>> ============================================ Szczegóły profilu połączenia (con-vpn-1) ============================================ -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -25115,7 +25239,7 @@ proxy none nie -- -- <<< size: 674 -location: src/tests/client/test-client.py:test_004()/429 +location: src/tests/client/test-client.py:test_004()/431 cmd: $NMCLI --mode tabular --pretty -f VPN con s con-vpn-1 lang: C returncode: 0 @@ -25130,7 +25254,7 @@ vpn org.freedesktop.NetworkManager.openvpn -- key1 = val1, key2 = val <<< size: 694 -location: src/tests/client/test-client.py:test_004()/430 +location: src/tests/client/test-client.py:test_004()/432 cmd: $NMCLI --mode tabular --pretty -f VPN con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -25145,7 +25269,7 @@ vpn org.freedesktop.NetworkManager.openvpn -- key1 = val1, key2 = val <<< size: 1134 -location: src/tests/client/test-client.py:test_004()/431 +location: src/tests/client/test-client.py:test_004()/433 cmd: $NMCLI --mode tabular --pretty -f GENERAL con s con-vpn-1 lang: C returncode: 0 @@ -25160,7 +25284,7 @@ GENERAL con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP wlan0 wlan0 act <<< size: 1166 -location: src/tests/client/test-client.py:test_004()/432 +location: src/tests/client/test-client.py:test_004()/434 cmd: $NMCLI --mode tabular --pretty -f GENERAL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -25175,7 +25299,7 @@ GENERAL con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP wlan0 wlan0 akt <<< size: 535 -location: src/tests/client/test-client.py:test_004()/433 +location: src/tests/client/test-client.py:test_004()/435 cmd: $NMCLI --mode tabular --pretty dev s lang: C returncode: 0 @@ -25194,7 +25318,7 @@ wlan1 wifi unavailable -- <<< size: 544 -location: src/tests/client/test-client.py:test_004()/434 +location: src/tests/client/test-client.py:test_004()/436 cmd: $NMCLI --mode tabular --pretty dev s lang: pl_PL.UTF-8 returncode: 0 @@ -25213,7 +25337,7 @@ wlan1 wifi niedostępne -- <<< size: 1731 -location: src/tests/client/test-client.py:test_004()/435 +location: src/tests/client/test-client.py:test_004()/437 cmd: $NMCLI --mode tabular --pretty -f all dev status lang: C returncode: 0 @@ -25232,7 +25356,7 @@ wlan1 wifi unavailable unknown unknown /org/freedesk <<< size: 1740 -location: src/tests/client/test-client.py:test_004()/436 +location: src/tests/client/test-client.py:test_004()/438 cmd: $NMCLI --mode tabular --pretty -f all dev status lang: pl_PL.UTF-8 returncode: 0 @@ -25251,7 +25375,7 @@ wlan1 wifi niedostępne nieznane nieznane /org/freedes <<< size: 10187 -location: src/tests/client/test-client.py:test_004()/437 +location: src/tests/client/test-client.py:test_004()/439 cmd: $NMCLI --mode tabular --pretty dev show lang: C returncode: 0 @@ -25462,7 +25586,7 @@ IP6 2001:a::88ca:3654:96b:ab44/89 -- dst = 2001:a::cc8b:7c09:4673:bbb0 <<< size: 10358 -location: src/tests/client/test-client.py:test_004()/438 +location: src/tests/client/test-client.py:test_004()/440 cmd: $NMCLI --mode tabular --pretty dev show lang: pl_PL.UTF-8 returncode: 0 @@ -25673,7 +25797,7 @@ IP6 2001:a::88ca:3654:96b:ab44/89 -- dst = 2001:a::cc8b:7c09:4673:bbb0 <<< size: 24690 -location: src/tests/client/test-client.py:test_004()/439 +location: src/tests/client/test-client.py:test_004()/441 cmd: $NMCLI --mode tabular --pretty -f all dev show lang: C returncode: 0 @@ -25889,7 +26013,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 25045 -location: src/tests/client/test-client.py:test_004()/440 +location: src/tests/client/test-client.py:test_004()/442 cmd: $NMCLI --mode tabular --pretty -f all dev show lang: pl_PL.UTF-8 returncode: 0 @@ -26105,7 +26229,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 1769 -location: src/tests/client/test-client.py:test_004()/441 +location: src/tests/client/test-client.py:test_004()/443 cmd: $NMCLI --mode tabular --pretty dev show wlan0 lang: C returncode: 0 @@ -26152,7 +26276,7 @@ IP6 -- -- dst = 2001:a::dd5b:aa7b:b4a2:e42/102, nh = ::, mt = 250 <<< size: 1810 -location: src/tests/client/test-client.py:test_004()/442 +location: src/tests/client/test-client.py:test_004()/444 cmd: $NMCLI --mode tabular --pretty dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -26199,7 +26323,7 @@ IP6 -- -- dst = 2001:a::dd5b:aa7b:b4a2:e42/102, nh = ::, mt = 250 <<< size: 4953 -location: src/tests/client/test-client.py:test_004()/443 +location: src/tests/client/test-client.py:test_004()/445 cmd: $NMCLI --mode tabular --pretty -f all dev show wlan0 lang: C returncode: 0 @@ -26252,7 +26376,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 5061 -location: src/tests/client/test-client.py:test_004()/444 +location: src/tests/client/test-client.py:test_004()/446 cmd: $NMCLI --mode tabular --pretty -f all dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -26305,7 +26429,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 2060 -location: src/tests/client/test-client.py:test_004()/445 +location: src/tests/client/test-client.py:test_004()/447 cmd: $NMCLI --mode tabular --pretty -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -26328,7 +26452,7 @@ WIFI-PROPERTIES yes yes yes yes yes yes yes unknown unknown no <<< size: 2125 -location: src/tests/client/test-client.py:test_004()/446 +location: src/tests/client/test-client.py:test_004()/448 cmd: $NMCLI --mode tabular --pretty -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -26351,7 +26475,7 @@ WIFI-PROPERTIES tak tak tak tak tak tak tak nieznane nieznane nie <<< size: 2060 -location: src/tests/client/test-client.py:test_004()/447 +location: src/tests/client/test-client.py:test_004()/449 cmd: $NMCLI --mode tabular --pretty -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -26374,7 +26498,7 @@ WIFI-PROPERTIES yes yes yes yes yes yes yes unknown unknown no <<< size: 2125 -location: src/tests/client/test-client.py:test_004()/448 +location: src/tests/client/test-client.py:test_004()/450 cmd: $NMCLI --mode tabular --pretty -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -26397,7 +26521,7 @@ WIFI-PROPERTIES tak tak tak tak tak tak tak nieznane nieznane nie <<< size: 684 -location: src/tests/client/test-client.py:test_004()/449 +location: src/tests/client/test-client.py:test_004()/451 cmd: $NMCLI --mode tabular --pretty -f DEVICE,TYPE,DBUS-PATH dev lang: C returncode: 0 @@ -26416,7 +26540,7 @@ wlan1 wifi /org/freedesktop/NetworkManager/Devices/5 <<< size: 687 -location: src/tests/client/test-client.py:test_004()/450 +location: src/tests/client/test-client.py:test_004()/452 cmd: $NMCLI --mode tabular --pretty -f DEVICE,TYPE,DBUS-PATH dev lang: pl_PL.UTF-8 returncode: 0 @@ -26435,7 +26559,7 @@ wlan1 wifi /org/freedesktop/NetworkManager/Devices/5 <<< size: 3039 -location: src/tests/client/test-client.py:test_004()/451 +location: src/tests/client/test-client.py:test_004()/453 cmd: $NMCLI --mode tabular --pretty -f ALL device wifi list lang: C returncode: 0 @@ -26465,7 +26589,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 3277 -location: src/tests/client/test-client.py:test_004()/452 +location: src/tests/client/test-client.py:test_004()/454 cmd: $NMCLI --mode tabular --pretty -f ALL device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -26495,7 +26619,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 1332 -location: src/tests/client/test-client.py:test_004()/453 +location: src/tests/client/test-client.py:test_004()/455 cmd: $NMCLI --mode tabular --pretty -f COMMON device wifi list lang: C returncode: 0 @@ -26525,7 +26649,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY <<< size: 1562 -location: src/tests/client/test-client.py:test_004()/454 +location: src/tests/client/test-client.py:test_004()/456 cmd: $NMCLI --mode tabular --pretty -f COMMON device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -26555,7 +26679,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY <<< size: 3152 -location: src/tests/client/test-client.py:test_004()/455 +location: src/tests/client/test-client.py:test_004()/457 cmd: $NMCLI --mode tabular --pretty -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: C returncode: 0 @@ -26585,7 +26709,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 3390 -location: src/tests/client/test-client.py:test_004()/456 +location: src/tests/client/test-client.py:test_004()/458 cmd: $NMCLI --mode tabular --pretty -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -26615,7 +26739,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 1154 -location: src/tests/client/test-client.py:test_004()/457 +location: src/tests/client/test-client.py:test_004()/459 cmd: $NMCLI --mode tabular --pretty -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -26632,7 +26756,7 @@ AP[1] wlan0-ap-2 776C616E302D61702D32 C0:E2:BE:E8:EF:B6 Infra 1 2412 MH <<< size: 1242 -location: src/tests/client/test-client.py:test_004()/458 +location: src/tests/client/test-client.py:test_004()/460 cmd: $NMCLI --mode tabular --pretty -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -26649,7 +26773,7 @@ AP[1] wlan0-ap-2 776C616E302D61702D32 C0:E2:BE:E8:EF:B6 Infrastruktura 1 <<< size: 569 -location: src/tests/client/test-client.py:test_004()/459 +location: src/tests/client/test-client.py:test_004()/461 cmd: $NMCLI --mode tabular --pretty -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -26666,7 +26790,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SEC <<< size: 654 -location: src/tests/client/test-client.py:test_004()/460 +location: src/tests/client/test-client.py:test_004()/462 cmd: $NMCLI --mode tabular --pretty -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -26683,7 +26807,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BA <<< size: 1267 -location: src/tests/client/test-client.py:test_004()/461 +location: src/tests/client/test-client.py:test_004()/463 cmd: $NMCLI --mode tabular --pretty -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -26700,7 +26824,7 @@ AP[1] wlan0-ap-2 776C616E302D61702D32 C0:E2:BE:E8:EF:B6 Infra 1 2412 MH <<< size: 1355 -location: src/tests/client/test-client.py:test_004()/462 +location: src/tests/client/test-client.py:test_004()/464 cmd: $NMCLI --mode tabular --pretty -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -26717,7 +26841,7 @@ AP[1] wlan0-ap-2 776C616E302D61702D32 C0:E2:BE:E8:EF:B6 Infrastruktura 1 <<< size: 4956 -location: src/tests/client/test-client.py:test_004()/463 +location: src/tests/client/test-client.py:test_004()/465 cmd: $NMCLI --mode tabular --pretty -f ALL device show wlan0 lang: C returncode: 0 @@ -26770,7 +26894,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 5064 -location: src/tests/client/test-client.py:test_004()/464 +location: src/tests/client/test-client.py:test_004()/466 cmd: $NMCLI --mode tabular --pretty -f ALL device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -26823,7 +26947,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 1782 -location: src/tests/client/test-client.py:test_004()/465 +location: src/tests/client/test-client.py:test_004()/467 cmd: $NMCLI --mode tabular --pretty -f COMMON device show wlan0 lang: C returncode: 0 @@ -26870,7 +26994,7 @@ IP6 -- -- dst = 2001:a::dd5b:aa7b:b4a2:e42/102, nh = ::, mt = 250 <<< size: 1823 -location: src/tests/client/test-client.py:test_004()/466 +location: src/tests/client/test-client.py:test_004()/468 cmd: $NMCLI --mode tabular --pretty -f COMMON device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -26917,7 +27041,7 @@ IP6 -- -- dst = 2001:a::dd5b:aa7b:b4a2:e42/102, nh = ::, mt = 250 <<< size: 4942 -location: src/tests/client/test-client.py:test_004()/467 +location: src/tests/client/test-client.py:test_004()/469 cmd: $NMCLI --mode tabular --pretty -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: C returncode: 0 @@ -26966,7 +27090,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 5050 -location: src/tests/client/test-client.py:test_004()/468 +location: src/tests/client/test-client.py:test_004()/470 cmd: $NMCLI --mode tabular --pretty -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -27015,7 +27139,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 1529 -location: src/tests/client/test-client.py:test_004()/469 +location: src/tests/client/test-client.py:test_004()/471 cmd: $NMCLI --mode tabular --pretty dev lldp list ifname eth0 lang: C returncode: 0 @@ -27032,7 +27156,7 @@ eth0 00:11:22:33:44:22 port1 GigabitEthernet #3 test3.example. <<< size: 1553 -location: src/tests/client/test-client.py:test_004()/470 +location: src/tests/client/test-client.py:test_004()/472 cmd: $NMCLI --mode tabular --pretty dev lldp list ifname eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -27049,7 +27173,7 @@ eth0 00:11:22:33:44:22 port1 GigabitEthernet #3 test3.example. <<< size: 1493 -location: src/tests/client/test-client.py:test_004()/471 +location: src/tests/client/test-client.py:test_004()/473 cmd: $NMCLI --mode tabular --pretty -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: C returncode: 0 @@ -27120,7 +27244,7 @@ interface-name <<< size: 1533 -location: src/tests/client/test-client.py:test_004()/472 +location: src/tests/client/test-client.py:test_004()/474 cmd: $NMCLI --mode tabular --pretty -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: pl_PL.UTF-8 returncode: 0 @@ -27190,19 +27314,19 @@ interface-name <<< -size: 5469 -location: src/tests/client/test-client.py:test_004()/473 +size: 5511 +location: src/tests/client/test-client.py:test_004()/475 cmd: $NMCLI --mode tabular --pretty --color yes con s con-vpn-1 lang: C returncode: 0 -stdout: 5298 bytes +stdout: 5340 bytes >>> ========================================== Connection profile details (con-vpn-1) ========================================== -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -27232,19 +27356,19 @@ NAME TYPE USERNAME GATEWAY BANNER VPN-STATE VPN openvpn -- -- *** VPN connection con-vpn-1 *** 5 - VPN connected key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 5525 -location: src/tests/client/test-client.py:test_004()/474 +size: 5567 +location: src/tests/client/test-client.py:test_004()/476 cmd: $NMCLI --mode tabular --pretty --color yes con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5344 bytes +stdout: 5386 bytes >>> ============================================ Szczegóły profilu połączenia (con-vpn-1) ============================================ -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -27274,19 +27398,19 @@ NAME TYPE USERNAME GATEWAY BANNER VPN-STATE VPN openvpn -- -- *** VPN connection con-vpn-1 *** 5 — Połączono z VPN key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 5469 -location: src/tests/client/test-client.py:test_004()/475 +size: 5511 +location: src/tests/client/test-client.py:test_004()/477 cmd: $NMCLI --mode tabular --pretty --color yes con s con-vpn-1 lang: C returncode: 0 -stdout: 5298 bytes +stdout: 5340 bytes >>> ========================================== Connection profile details (con-vpn-1) ========================================== -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -27316,19 +27440,19 @@ NAME TYPE USERNAME GATEWAY BANNER VPN-STATE VPN openvpn -- -- *** VPN connection con-vpn-1 *** 5 - VPN connected key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 5525 -location: src/tests/client/test-client.py:test_004()/476 +size: 5567 +location: src/tests/client/test-client.py:test_004()/478 cmd: $NMCLI --mode tabular --pretty --color yes con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5344 bytes +stdout: 5386 bytes >>> ============================================ Szczegóły profilu połączenia (con-vpn-1) ============================================ -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -27358,19 +27482,19 @@ NAME TYPE USERNAME GATEWAY BANNER VPN-STATE VPN openvpn -- -- *** VPN connection con-vpn-1 *** 5 — Połączono z VPN key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 4125 -location: src/tests/client/test-client.py:test_004()/477 +size: 4167 +location: src/tests/client/test-client.py:test_004()/479 cmd: $NMCLI --mode tabular --pretty --color yes -f ALL con s con-vpn-1 lang: C returncode: 0 -stdout: 3947 bytes +stdout: 3989 bytes >>> ========================================== Connection profile details (con-vpn-1) ========================================== -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- yes 0 -1 (default) 0 (default) -1 0 no -- -- -- -- -1 (default) -- 0 unknown default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -27390,19 +27514,19 @@ proxy none no -- -- <<< -size: 4148 -location: src/tests/client/test-client.py:test_004()/478 +size: 4190 +location: src/tests/client/test-client.py:test_004()/480 cmd: $NMCLI --mode tabular --pretty --color yes -f ALL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 3960 bytes +stdout: 4002 bytes >>> ============================================ Szczegóły profilu połączenia (con-vpn-1) ============================================ -name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr wait-device-timeout ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 +name id uuid stable-id type interface-name autoconnect autoconnect-priority autoconnect-retries multi-connect auth-retries timestamp read-only permissions zone master slave-type autoconnect-slaves secondaries gateway-ping-timeout metered lldp mdns llmnr dns-over-tls wait-device-timeout +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +connection con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP -- vpn -- tak 0 -1 (default) 0 (default) -1 0 nie -- -- -- -- -1 (default) -- 0 nieznane default -1 (default) -1 (default) -1 (default) -1 name method dns dns-search dns-options dns-priority addresses gateway routes route-metric route-table routing-rules ignore-auto-routes ignore-auto-dns dhcp-client-id dhcp-iaid dhcp-timeout dhcp-send-hostname dhcp-hostname dhcp-fqdn dhcp-hostname-flags never-default may-fail required-timeout dad-timeout dhcp-vendor-class-identifier dhcp-reject-servers --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -27423,7 +27547,7 @@ proxy none nie -- -- <<< size: 686 -location: src/tests/client/test-client.py:test_004()/479 +location: src/tests/client/test-client.py:test_004()/481 cmd: $NMCLI --mode tabular --pretty --color yes -f VPN con s con-vpn-1 lang: C returncode: 0 @@ -27438,7 +27562,7 @@ vpn org.freedesktop.NetworkManager.openvpn -- key1 = val1, key2 = val <<< size: 706 -location: src/tests/client/test-client.py:test_004()/480 +location: src/tests/client/test-client.py:test_004()/482 cmd: $NMCLI --mode tabular --pretty --color yes -f VPN con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -27453,7 +27577,7 @@ vpn org.freedesktop.NetworkManager.openvpn -- key1 = val1, key2 = val <<< size: 1146 -location: src/tests/client/test-client.py:test_004()/481 +location: src/tests/client/test-client.py:test_004()/483 cmd: $NMCLI --mode tabular --pretty --color yes -f GENERAL con s con-vpn-1 lang: C returncode: 0 @@ -27468,7 +27592,7 @@ GENERAL con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP wlan0 wlan0 act <<< size: 1178 -location: src/tests/client/test-client.py:test_004()/482 +location: src/tests/client/test-client.py:test_004()/484 cmd: $NMCLI --mode tabular --pretty --color yes -f GENERAL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -27483,7 +27607,7 @@ GENERAL con-vpn-1 UUID-con-vpn-1-REPLACED-REPLACED-REP wlan0 wlan0 akt <<< size: 711 -location: src/tests/client/test-client.py:test_004()/483 +location: src/tests/client/test-client.py:test_004()/485 cmd: $NMCLI --mode tabular --pretty --color yes dev s lang: C returncode: 0 @@ -27502,7 +27626,7 @@ DEVICE TYPE STATE CONNECTION <<< size: 720 -location: src/tests/client/test-client.py:test_004()/484 +location: src/tests/client/test-client.py:test_004()/486 cmd: $NMCLI --mode tabular --pretty --color yes dev s lang: pl_PL.UTF-8 returncode: 0 @@ -27521,7 +27645,7 @@ DEVICE TYPE STATE CONNECTION <<< size: 2112 -location: src/tests/client/test-client.py:test_004()/485 +location: src/tests/client/test-client.py:test_004()/487 cmd: $NMCLI --mode tabular --pretty --color yes -f all dev status lang: C returncode: 0 @@ -27540,7 +27664,7 @@ DEVICE TYPE STATE IP4-CONNECTIVITY IP6-CONNECTIVITY DBUS-PATH <<< size: 2121 -location: src/tests/client/test-client.py:test_004()/486 +location: src/tests/client/test-client.py:test_004()/488 cmd: $NMCLI --mode tabular --pretty --color yes -f all dev status lang: pl_PL.UTF-8 returncode: 0 @@ -27559,7 +27683,7 @@ DEVICE TYPE STATE IP4-CONNECTIVITY IP6-CONNECTIVITY DBUS-PATH <<< size: 10199 -location: src/tests/client/test-client.py:test_004()/487 +location: src/tests/client/test-client.py:test_004()/489 cmd: $NMCLI --mode tabular --pretty --color yes dev show lang: C returncode: 0 @@ -27770,7 +27894,7 @@ IP6 2001:a::88ca:3654:96b:ab44/89 -- dst = 2001:a::cc8b:7c09:4673:bbb0 <<< size: 10370 -location: src/tests/client/test-client.py:test_004()/488 +location: src/tests/client/test-client.py:test_004()/490 cmd: $NMCLI --mode tabular --pretty --color yes dev show lang: pl_PL.UTF-8 returncode: 0 @@ -27981,7 +28105,7 @@ IP6 2001:a::88ca:3654:96b:ab44/89 -- dst = 2001:a::cc8b:7c09:4673:bbb0 <<< size: 25062 -location: src/tests/client/test-client.py:test_004()/489 +location: src/tests/client/test-client.py:test_004()/491 cmd: $NMCLI --mode tabular --pretty --color yes -f all dev show lang: C returncode: 0 @@ -28197,7 +28321,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 25417 -location: src/tests/client/test-client.py:test_004()/490 +location: src/tests/client/test-client.py:test_004()/492 cmd: $NMCLI --mode tabular --pretty --color yes -f all dev show lang: pl_PL.UTF-8 returncode: 0 @@ -28413,7 +28537,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 1781 -location: src/tests/client/test-client.py:test_004()/491 +location: src/tests/client/test-client.py:test_004()/493 cmd: $NMCLI --mode tabular --pretty --color yes dev show wlan0 lang: C returncode: 0 @@ -28460,7 +28584,7 @@ IP6 -- -- dst = 2001:a::dd5b:aa7b:b4a2:e42/102, nh = ::, mt = 250 <<< size: 1822 -location: src/tests/client/test-client.py:test_004()/492 +location: src/tests/client/test-client.py:test_004()/494 cmd: $NMCLI --mode tabular --pretty --color yes dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -28507,7 +28631,7 @@ IP6 -- -- dst = 2001:a::dd5b:aa7b:b4a2:e42/102, nh = ::, mt = 250 <<< size: 5235 -location: src/tests/client/test-client.py:test_004()/493 +location: src/tests/client/test-client.py:test_004()/495 cmd: $NMCLI --mode tabular --pretty --color yes -f all dev show wlan0 lang: C returncode: 0 @@ -28560,7 +28684,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 5343 -location: src/tests/client/test-client.py:test_004()/494 +location: src/tests/client/test-client.py:test_004()/496 cmd: $NMCLI --mode tabular --pretty --color yes -f all dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -28613,7 +28737,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 2072 -location: src/tests/client/test-client.py:test_004()/495 +location: src/tests/client/test-client.py:test_004()/497 cmd: $NMCLI --mode tabular --pretty --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -28636,7 +28760,7 @@ WIFI-PROPERTIES yes yes yes yes yes yes yes unknown unknown no <<< size: 2137 -location: src/tests/client/test-client.py:test_004()/496 +location: src/tests/client/test-client.py:test_004()/498 cmd: $NMCLI --mode tabular --pretty --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -28659,7 +28783,7 @@ WIFI-PROPERTIES tak tak tak tak tak tak tak nieznane nieznane nie <<< size: 2072 -location: src/tests/client/test-client.py:test_004()/497 +location: src/tests/client/test-client.py:test_004()/499 cmd: $NMCLI --mode tabular --pretty --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -28682,7 +28806,7 @@ WIFI-PROPERTIES yes yes yes yes yes yes yes unknown unknown no <<< size: 2137 -location: src/tests/client/test-client.py:test_004()/498 +location: src/tests/client/test-client.py:test_004()/500 cmd: $NMCLI --mode tabular --pretty --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -28705,7 +28829,7 @@ WIFI-PROPERTIES tak tak tak tak tak tak tak nieznane nieznane nie <<< size: 819 -location: src/tests/client/test-client.py:test_004()/499 +location: src/tests/client/test-client.py:test_004()/501 cmd: $NMCLI --mode tabular --pretty --color yes -f DEVICE,TYPE,DBUS-PATH dev lang: C returncode: 0 @@ -28724,7 +28848,7 @@ DEVICE TYPE DBUS-PATH <<< size: 822 -location: src/tests/client/test-client.py:test_004()/500 +location: src/tests/client/test-client.py:test_004()/502 cmd: $NMCLI --mode tabular --pretty --color yes -f DEVICE,TYPE,DBUS-PATH dev lang: pl_PL.UTF-8 returncode: 0 @@ -28743,7 +28867,7 @@ DEVICE TYPE DBUS-PATH <<< size: 3663 -location: src/tests/client/test-client.py:test_004()/501 +location: src/tests/client/test-client.py:test_004()/503 cmd: $NMCLI --mode tabular --pretty --color yes -f ALL device wifi list lang: C returncode: 0 @@ -28773,7 +28897,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 3901 -location: src/tests/client/test-client.py:test_004()/502 +location: src/tests/client/test-client.py:test_004()/504 cmd: $NMCLI --mode tabular --pretty --color yes -f ALL device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -28803,7 +28927,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 1668 -location: src/tests/client/test-client.py:test_004()/503 +location: src/tests/client/test-client.py:test_004()/505 cmd: $NMCLI --mode tabular --pretty --color yes -f COMMON device wifi list lang: C returncode: 0 @@ -28833,7 +28957,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY <<< size: 1898 -location: src/tests/client/test-client.py:test_004()/504 +location: src/tests/client/test-client.py:test_004()/506 cmd: $NMCLI --mode tabular --pretty --color yes -f COMMON device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -28863,7 +28987,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY <<< size: 3776 -location: src/tests/client/test-client.py:test_004()/505 +location: src/tests/client/test-client.py:test_004()/507 cmd: $NMCLI --mode tabular --pretty --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: C returncode: 0 @@ -28893,7 +29017,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 4014 -location: src/tests/client/test-client.py:test_004()/506 +location: src/tests/client/test-client.py:test_004()/508 cmd: $NMCLI --mode tabular --pretty --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -28923,7 +29047,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ RATE SIGNAL BARS SECURITY WPA <<< size: 1320 -location: src/tests/client/test-client.py:test_004()/507 +location: src/tests/client/test-client.py:test_004()/509 cmd: $NMCLI --mode tabular --pretty --color yes -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -28940,7 +29064,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ <<< size: 1407 -location: src/tests/client/test-client.py:test_004()/508 +location: src/tests/client/test-client.py:test_004()/510 cmd: $NMCLI --mode tabular --pretty --color yes -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -28957,7 +29081,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN <<< size: 662 -location: src/tests/client/test-client.py:test_004()/509 +location: src/tests/client/test-client.py:test_004()/511 cmd: $NMCLI --mode tabular --pretty --color yes -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -28974,7 +29098,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SEC <<< size: 747 -location: src/tests/client/test-client.py:test_004()/510 +location: src/tests/client/test-client.py:test_004()/512 cmd: $NMCLI --mode tabular --pretty --color yes -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -28991,7 +29115,7 @@ IN-USE BSSID SSID MODE CHAN RATE SIGNAL BA <<< size: 1433 -location: src/tests/client/test-client.py:test_004()/511 +location: src/tests/client/test-client.py:test_004()/513 cmd: $NMCLI --mode tabular --pretty --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -29008,7 +29132,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN FREQ <<< size: 1520 -location: src/tests/client/test-client.py:test_004()/512 +location: src/tests/client/test-client.py:test_004()/514 cmd: $NMCLI --mode tabular --pretty --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -29025,7 +29149,7 @@ NAME SSID SSID-HEX BSSID MODE CHAN <<< size: 5238 -location: src/tests/client/test-client.py:test_004()/513 +location: src/tests/client/test-client.py:test_004()/515 cmd: $NMCLI --mode tabular --pretty --color yes -f ALL device show wlan0 lang: C returncode: 0 @@ -29078,7 +29202,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 5346 -location: src/tests/client/test-client.py:test_004()/514 +location: src/tests/client/test-client.py:test_004()/516 cmd: $NMCLI --mode tabular --pretty --color yes -f ALL device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -29131,7 +29255,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 1794 -location: src/tests/client/test-client.py:test_004()/515 +location: src/tests/client/test-client.py:test_004()/517 cmd: $NMCLI --mode tabular --pretty --color yes -f COMMON device show wlan0 lang: C returncode: 0 @@ -29178,7 +29302,7 @@ IP6 -- -- dst = 2001:a::dd5b:aa7b:b4a2:e42/102, nh = ::, mt = 250 <<< size: 1835 -location: src/tests/client/test-client.py:test_004()/516 +location: src/tests/client/test-client.py:test_004()/518 cmd: $NMCLI --mode tabular --pretty --color yes -f COMMON device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -29225,7 +29349,7 @@ IP6 -- -- dst = 2001:a::dd5b:aa7b:b4a2:e42/102, nh = ::, mt = 250 <<< size: 5224 -location: src/tests/client/test-client.py:test_004()/517 +location: src/tests/client/test-client.py:test_004()/519 cmd: $NMCLI --mode tabular --pretty --color yes -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: C returncode: 0 @@ -29274,7 +29398,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 5332 -location: src/tests/client/test-client.py:test_004()/518 +location: src/tests/client/test-client.py:test_004()/520 cmd: $NMCLI --mode tabular --pretty --color yes -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -29323,7 +29447,7 @@ CONNECTIONS /org/freedesktop/NetworkManager/Settings/Connection/{2} UUID-con-x <<< size: 1541 -location: src/tests/client/test-client.py:test_004()/519 +location: src/tests/client/test-client.py:test_004()/521 cmd: $NMCLI --mode tabular --pretty --color yes dev lldp list ifname eth0 lang: C returncode: 0 @@ -29340,7 +29464,7 @@ eth0 00:11:22:33:44:22 port1 GigabitEthernet #3 test3.example. <<< size: 1565 -location: src/tests/client/test-client.py:test_004()/520 +location: src/tests/client/test-client.py:test_004()/522 cmd: $NMCLI --mode tabular --pretty --color yes dev lldp list ifname eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -29357,7 +29481,7 @@ eth0 00:11:22:33:44:22 port1 GigabitEthernet #3 test3.example. <<< size: 1505 -location: src/tests/client/test-client.py:test_004()/521 +location: src/tests/client/test-client.py:test_004()/523 cmd: $NMCLI --mode tabular --pretty --color yes -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: C returncode: 0 @@ -29428,7 +29552,7 @@ interface-name <<< size: 1545 -location: src/tests/client/test-client.py:test_004()/522 +location: src/tests/client/test-client.py:test_004()/524 cmd: $NMCLI --mode tabular --pretty --color yes -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: pl_PL.UTF-8 returncode: 0 @@ -29498,14 +29622,14 @@ interface-name <<< -size: 820 -location: src/tests/client/test-client.py:test_004()/523 +size: 823 +location: src/tests/client/test-client.py:test_004()/525 cmd: $NMCLI --mode tabular --terse con s con-vpn-1 lang: C returncode: 0 -stdout: 663 bytes +stdout: 666 bytes >>> -connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: vpn:org.freedesktop.NetworkManager.openvpn::key1 = val1, key2 = val2, key3 = val3::no:0 @@ -29514,14 +29638,14 @@ GENERAL:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP:wlan0:wlan0:activated:no: VPN:openvpn:::*** VPN connection con-vpn-1 ***:5 - VPN connected:key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 830 -location: src/tests/client/test-client.py:test_004()/524 +size: 833 +location: src/tests/client/test-client.py:test_004()/526 cmd: $NMCLI --mode tabular --terse con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 663 bytes +stdout: 666 bytes >>> -connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: vpn:org.freedesktop.NetworkManager.openvpn::key1 = val1, key2 = val2, key3 = val3::no:0 @@ -29530,14 +29654,14 @@ GENERAL:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP:wlan0:wlan0:activated:no: VPN:openvpn:::*** VPN connection con-vpn-1 ***:5 - VPN connected:key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 820 -location: src/tests/client/test-client.py:test_004()/525 +size: 823 +location: src/tests/client/test-client.py:test_004()/527 cmd: $NMCLI --mode tabular --terse con s con-vpn-1 lang: C returncode: 0 -stdout: 663 bytes +stdout: 666 bytes >>> -connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: vpn:org.freedesktop.NetworkManager.openvpn::key1 = val1, key2 = val2, key3 = val3::no:0 @@ -29546,14 +29670,14 @@ GENERAL:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP:wlan0:wlan0:activated:no: VPN:openvpn:::*** VPN connection con-vpn-1 ***:5 - VPN connected:key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 830 -location: src/tests/client/test-client.py:test_004()/526 +size: 833 +location: src/tests/client/test-client.py:test_004()/528 cmd: $NMCLI --mode tabular --terse con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 663 bytes +stdout: 666 bytes >>> -connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: vpn:org.freedesktop.NetworkManager.openvpn::key1 = val1, key2 = val2, key3 = val3::no:0 @@ -29562,28 +29686,28 @@ GENERAL:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP:wlan0:wlan0:activated:no: VPN:openvpn:::*** VPN connection con-vpn-1 ***:5 - VPN connected:key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 527 -location: src/tests/client/test-client.py:test_004()/527 +size: 530 +location: src/tests/client/test-client.py:test_004()/529 cmd: $NMCLI --mode tabular --terse -f ALL con s con-vpn-1 lang: C returncode: 0 -stdout: 363 bytes +stdout: 366 bytes >>> -connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: vpn:org.freedesktop.NetworkManager.openvpn::key1 = val1, key2 = val2, key3 = val3::no:0 proxy:none:no:: <<< -size: 537 -location: src/tests/client/test-client.py:test_004()/528 +size: 540 +location: src/tests/client/test-client.py:test_004()/530 cmd: $NMCLI --mode tabular --terse -f ALL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 363 bytes +stdout: 366 bytes >>> -connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: vpn:org.freedesktop.NetworkManager.openvpn::key1 = val1, key2 = val2, key3 = val3::no:0 @@ -29591,7 +29715,7 @@ proxy:none:no:: <<< size: 259 -location: src/tests/client/test-client.py:test_004()/529 +location: src/tests/client/test-client.py:test_004()/531 cmd: $NMCLI --mode tabular --terse -f VPN con s con-vpn-1 lang: C returncode: 0 @@ -29601,7 +29725,7 @@ vpn:org.freedesktop.NetworkManager.openvpn::key1 = val1, key2 = val2, key3 = val <<< size: 269 -location: src/tests/client/test-client.py:test_004()/530 +location: src/tests/client/test-client.py:test_004()/532 cmd: $NMCLI --mode tabular --terse -f VPN con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -29611,7 +29735,7 @@ vpn:org.freedesktop.NetworkManager.openvpn::key1 = val1, key2 = val2, key3 = val <<< size: 363 -location: src/tests/client/test-client.py:test_004()/531 +location: src/tests/client/test-client.py:test_004()/533 cmd: $NMCLI --mode tabular --terse -f GENERAL con s con-vpn-1 lang: C returncode: 0 @@ -29621,7 +29745,7 @@ GENERAL:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP:wlan0:wlan0:activated:no: <<< size: 373 -location: src/tests/client/test-client.py:test_004()/532 +location: src/tests/client/test-client.py:test_004()/534 cmd: $NMCLI --mode tabular --terse -f GENERAL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -29631,7 +29755,7 @@ GENERAL:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP:wlan0:wlan0:activated:no: <<< size: 280 -location: src/tests/client/test-client.py:test_004()/533 +location: src/tests/client/test-client.py:test_004()/535 cmd: $NMCLI --mode tabular --terse dev s lang: C returncode: 0 @@ -29645,7 +29769,7 @@ wlan1:wifi:unavailable: <<< size: 290 -location: src/tests/client/test-client.py:test_004()/534 +location: src/tests/client/test-client.py:test_004()/536 cmd: $NMCLI --mode tabular --terse dev s lang: pl_PL.UTF-8 returncode: 0 @@ -29659,7 +29783,7 @@ wlan1:wifi:unavailable: <<< size: 678 -location: src/tests/client/test-client.py:test_004()/535 +location: src/tests/client/test-client.py:test_004()/537 cmd: $NMCLI --mode tabular --terse -f all dev status lang: C returncode: 0 @@ -29673,7 +29797,7 @@ wlan1:wifi:unavailable:unknown:unknown:/org/freedesktop/NetworkManager/Devices/5 <<< size: 688 -location: src/tests/client/test-client.py:test_004()/536 +location: src/tests/client/test-client.py:test_004()/538 cmd: $NMCLI --mode tabular --terse -f all dev status lang: pl_PL.UTF-8 returncode: 0 @@ -29687,7 +29811,7 @@ wlan1:wifi:unavailable:unknown:unknown:/org/freedesktop/NetworkManager/Devices/5 <<< size: 3101 -location: src/tests/client/test-client.py:test_004()/537 +location: src/tests/client/test-client.py:test_004()/539 cmd: $NMCLI --mode tabular --terse dev show lang: C returncode: 0 @@ -29747,7 +29871,7 @@ IP6:2001\:a\:\:88ca\:3654\:96b\:ab44/89::dst = 2001\:a\:\:cc8b\:7c09\:4673\:bbb0 <<< size: 3111 -location: src/tests/client/test-client.py:test_004()/538 +location: src/tests/client/test-client.py:test_004()/540 cmd: $NMCLI --mode tabular --terse dev show lang: pl_PL.UTF-8 returncode: 0 @@ -29807,7 +29931,7 @@ IP6:2001\:a\:\:88ca\:3654\:96b\:ab44/89::dst = 2001\:a\:\:cc8b\:7c09\:4673\:bbb0 <<< size: 6818 -location: src/tests/client/test-client.py:test_004()/539 +location: src/tests/client/test-client.py:test_004()/541 cmd: $NMCLI --mode tabular --terse -f all dev show lang: C returncode: 0 @@ -29869,7 +29993,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{2}:UUID-con-xx1 <<< size: 6864 -location: src/tests/client/test-client.py:test_004()/540 +location: src/tests/client/test-client.py:test_004()/542 cmd: $NMCLI --mode tabular --terse -f all dev show lang: pl_PL.UTF-8 returncode: 0 @@ -29931,7 +30055,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{2}:UUID-con-xx1 <<< size: 603 -location: src/tests/client/test-client.py:test_004()/541 +location: src/tests/client/test-client.py:test_004()/543 cmd: $NMCLI --mode tabular --terse dev show wlan0 lang: C returncode: 0 @@ -29949,7 +30073,7 @@ IP6:::dst = 2001\:a\:\:dd5b\:aa7b\:b4a2\:e42/102, nh = \:\:, mt = 2504159086::se <<< size: 613 -location: src/tests/client/test-client.py:test_004()/542 +location: src/tests/client/test-client.py:test_004()/544 cmd: $NMCLI --mode tabular --terse dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -29967,7 +30091,7 @@ IP6:::dst = 2001\:a\:\:dd5b\:aa7b\:b4a2\:e42/102, nh = \:\:, mt = 2504159086::se <<< size: 1507 -location: src/tests/client/test-client.py:test_004()/543 +location: src/tests/client/test-client.py:test_004()/545 cmd: $NMCLI --mode tabular --terse -f all dev show wlan0 lang: C returncode: 0 @@ -29988,7 +30112,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{2}:UUID-con-xx1 <<< size: 1544 -location: src/tests/client/test-client.py:test_004()/544 +location: src/tests/client/test-client.py:test_004()/546 cmd: $NMCLI --mode tabular --terse -f all dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -30009,7 +30133,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{2}:UUID-con-xx1 <<< size: 616 -location: src/tests/client/test-client.py:test_004()/545 +location: src/tests/client/test-client.py:test_004()/547 cmd: $NMCLI --mode tabular --terse -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -30021,7 +30145,7 @@ WIFI-PROPERTIES:yes:yes:yes:yes:yes:yes:yes:unknown:unknown:no:no <<< size: 626 -location: src/tests/client/test-client.py:test_004()/546 +location: src/tests/client/test-client.py:test_004()/548 cmd: $NMCLI --mode tabular --terse -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -30033,7 +30157,7 @@ WIFI-PROPERTIES:yes:yes:yes:yes:yes:yes:yes:unknown:unknown:no:no <<< size: 616 -location: src/tests/client/test-client.py:test_004()/547 +location: src/tests/client/test-client.py:test_004()/549 cmd: $NMCLI --mode tabular --terse -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -30045,7 +30169,7 @@ WIFI-PROPERTIES:yes:yes:yes:yes:yes:yes:yes:unknown:unknown:no:no <<< size: 626 -location: src/tests/client/test-client.py:test_004()/548 +location: src/tests/client/test-client.py:test_004()/550 cmd: $NMCLI --mode tabular --terse -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -30057,7 +30181,7 @@ WIFI-PROPERTIES:yes:yes:yes:yes:yes:yes:yes:unknown:unknown:no:no <<< size: 441 -location: src/tests/client/test-client.py:test_004()/549 +location: src/tests/client/test-client.py:test_004()/551 cmd: $NMCLI --mode tabular --terse -f DEVICE,TYPE,DBUS-PATH dev lang: C returncode: 0 @@ -30071,7 +30195,7 @@ wlan1:wifi:/org/freedesktop/NetworkManager/Devices/5 <<< size: 451 -location: src/tests/client/test-client.py:test_004()/550 +location: src/tests/client/test-client.py:test_004()/552 cmd: $NMCLI --mode tabular --terse -f DEVICE,TYPE,DBUS-PATH dev lang: pl_PL.UTF-8 returncode: 0 @@ -30085,7 +30209,7 @@ wlan1:wifi:/org/freedesktop/NetworkManager/Devices/5 <<< size: 1099 -location: src/tests/client/test-client.py:test_004()/551 +location: src/tests/client/test-client.py:test_004()/553 cmd: $NMCLI --mode tabular --terse -f ALL device wifi list lang: C returncode: 0 @@ -30100,7 +30224,7 @@ AP[1]:wlan1-ap-4:776C616E312D61702D34:94\:2B\:E8\:F6\:D2\:86:Infra:1:2412 MHz:54 <<< size: 1157 -location: src/tests/client/test-client.py:test_004()/552 +location: src/tests/client/test-client.py:test_004()/554 cmd: $NMCLI --mode tabular --terse -f ALL device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -30115,7 +30239,7 @@ AP[1]:wlan1-ap-4:776C616E312D61702D34:94\:2B\:E8\:F6\:D2\:86:Infrastruktura:1:24 <<< size: 448 -location: src/tests/client/test-client.py:test_004()/553 +location: src/tests/client/test-client.py:test_004()/555 cmd: $NMCLI --mode tabular --terse -f COMMON device wifi list lang: C returncode: 0 @@ -30130,7 +30254,7 @@ stdout: 280 bytes <<< size: 494 -location: src/tests/client/test-client.py:test_004()/554 +location: src/tests/client/test-client.py:test_004()/556 cmd: $NMCLI --mode tabular --terse -f COMMON device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -30145,7 +30269,7 @@ stdout: 316 bytes <<< size: 1212 -location: src/tests/client/test-client.py:test_004()/555 +location: src/tests/client/test-client.py:test_004()/557 cmd: $NMCLI --mode tabular --terse -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: C returncode: 0 @@ -30160,7 +30284,7 @@ AP[1]:wlan1-ap-4:776C616E312D61702D34:94\:2B\:E8\:F6\:D2\:86:Infra:1:2412 MHz:54 <<< size: 1270 -location: src/tests/client/test-client.py:test_004()/556 +location: src/tests/client/test-client.py:test_004()/558 cmd: $NMCLI --mode tabular --terse -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -30175,7 +30299,7 @@ AP[1]:wlan1-ap-4:776C616E312D61702D34:94\:2B\:E8\:F6\:D2\:86:Infrastruktura:1:24 <<< size: 446 -location: src/tests/client/test-client.py:test_004()/557 +location: src/tests/client/test-client.py:test_004()/559 cmd: $NMCLI --mode tabular --terse -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -30187,7 +30311,7 @@ AP[1]:wlan0-ap-2:776C616E302D61702D32:C0\:E2\:BE\:E8\:EF\:B6:Infra:1:2412 MHz:54 <<< size: 468 -location: src/tests/client/test-client.py:test_004()/558 +location: src/tests/client/test-client.py:test_004()/560 cmd: $NMCLI --mode tabular --terse -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -30199,7 +30323,7 @@ AP[1]:wlan0-ap-2:776C616E302D61702D32:C0\:E2\:BE\:E8\:EF\:B6:Infrastruktura:1:24 <<< size: 265 -location: src/tests/client/test-client.py:test_004()/559 +location: src/tests/client/test-client.py:test_004()/561 cmd: $NMCLI --mode tabular --terse -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -30211,7 +30335,7 @@ stdout: 74 bytes <<< size: 284 -location: src/tests/client/test-client.py:test_004()/560 +location: src/tests/client/test-client.py:test_004()/562 cmd: $NMCLI --mode tabular --terse -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -30223,7 +30347,7 @@ stdout: 83 bytes <<< size: 559 -location: src/tests/client/test-client.py:test_004()/561 +location: src/tests/client/test-client.py:test_004()/563 cmd: $NMCLI --mode tabular --terse -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -30235,7 +30359,7 @@ AP[1]:wlan0-ap-2:776C616E302D61702D32:C0\:E2\:BE\:E8\:EF\:B6:Infra:1:2412 MHz:54 <<< size: 581 -location: src/tests/client/test-client.py:test_004()/562 +location: src/tests/client/test-client.py:test_004()/564 cmd: $NMCLI --mode tabular --terse -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -30247,7 +30371,7 @@ AP[1]:wlan0-ap-2:776C616E302D61702D32:C0\:E2\:BE\:E8\:EF\:B6:Infrastruktura:1:24 <<< size: 1510 -location: src/tests/client/test-client.py:test_004()/563 +location: src/tests/client/test-client.py:test_004()/565 cmd: $NMCLI --mode tabular --terse -f ALL device show wlan0 lang: C returncode: 0 @@ -30268,7 +30392,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{2}:UUID-con-xx1 <<< size: 1547 -location: src/tests/client/test-client.py:test_004()/564 +location: src/tests/client/test-client.py:test_004()/566 cmd: $NMCLI --mode tabular --terse -f ALL device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -30289,7 +30413,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{2}:UUID-con-xx1 <<< size: 616 -location: src/tests/client/test-client.py:test_004()/565 +location: src/tests/client/test-client.py:test_004()/567 cmd: $NMCLI --mode tabular --terse -f COMMON device show wlan0 lang: C returncode: 0 @@ -30307,7 +30431,7 @@ IP6:::dst = 2001\:a\:\:dd5b\:aa7b\:b4a2\:e42/102, nh = \:\:, mt = 2504159086::se <<< size: 626 -location: src/tests/client/test-client.py:test_004()/566 +location: src/tests/client/test-client.py:test_004()/568 cmd: $NMCLI --mode tabular --terse -f COMMON device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -30325,7 +30449,7 @@ IP6:::dst = 2001\:a\:\:dd5b\:aa7b\:b4a2\:e42/102, nh = \:\:, mt = 2504159086::se <<< size: 1618 -location: src/tests/client/test-client.py:test_004()/567 +location: src/tests/client/test-client.py:test_004()/569 cmd: $NMCLI --mode tabular --terse -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: C returncode: 0 @@ -30345,7 +30469,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{2}:UUID-con-xx1 <<< size: 1655 -location: src/tests/client/test-client.py:test_004()/568 +location: src/tests/client/test-client.py:test_004()/570 cmd: $NMCLI --mode tabular --terse -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -30365,7 +30489,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{2}:UUID-con-xx1 <<< size: 630 -location: src/tests/client/test-client.py:test_004()/569 +location: src/tests/client/test-client.py:test_004()/571 cmd: $NMCLI --mode tabular --terse dev lldp list ifname eth0 lang: C returncode: 0 @@ -30377,7 +30501,7 @@ eth0:00\:11\:22\:33\:44\:22:port1:GigabitEthernet #3:test3.example.com:Test syst <<< size: 640 -location: src/tests/client/test-client.py:test_004()/570 +location: src/tests/client/test-client.py:test_004()/572 cmd: $NMCLI --mode tabular --terse dev lldp list ifname eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -30389,7 +30513,7 @@ eth0:00\:11\:22\:33\:44\:22:port1:GigabitEthernet #3:test3.example.com:Test syst <<< size: 560 -location: src/tests/client/test-client.py:test_004()/571 +location: src/tests/client/test-client.py:test_004()/573 cmd: $NMCLI --mode tabular --terse -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: C returncode: 0 @@ -30413,7 +30537,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA <<< size: 570 -location: src/tests/client/test-client.py:test_004()/572 +location: src/tests/client/test-client.py:test_004()/574 cmd: $NMCLI --mode tabular --terse -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: pl_PL.UTF-8 returncode: 0 @@ -30436,14 +30560,14 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA <<< -size: 832 -location: src/tests/client/test-client.py:test_004()/573 +size: 835 +location: src/tests/client/test-client.py:test_004()/575 cmd: $NMCLI --mode tabular --terse --color yes con s con-vpn-1 lang: C returncode: 0 -stdout: 663 bytes +stdout: 666 bytes >>> -connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: vpn:org.freedesktop.NetworkManager.openvpn::key1 = val1, key2 = val2, key3 = val3::no:0 @@ -30452,14 +30576,14 @@ GENERAL:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP:wlan0:wlan0:activated:no: VPN:openvpn:::*** VPN connection con-vpn-1 ***:5 - VPN connected:key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 842 -location: src/tests/client/test-client.py:test_004()/574 +size: 845 +location: src/tests/client/test-client.py:test_004()/576 cmd: $NMCLI --mode tabular --terse --color yes con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 663 bytes +stdout: 666 bytes >>> -connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: vpn:org.freedesktop.NetworkManager.openvpn::key1 = val1, key2 = val2, key3 = val3::no:0 @@ -30468,14 +30592,14 @@ GENERAL:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP:wlan0:wlan0:activated:no: VPN:openvpn:::*** VPN connection con-vpn-1 ***:5 - VPN connected:key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 832 -location: src/tests/client/test-client.py:test_004()/575 +size: 835 +location: src/tests/client/test-client.py:test_004()/577 cmd: $NMCLI --mode tabular --terse --color yes con s con-vpn-1 lang: C returncode: 0 -stdout: 663 bytes +stdout: 666 bytes >>> -connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: vpn:org.freedesktop.NetworkManager.openvpn::key1 = val1, key2 = val2, key3 = val3::no:0 @@ -30484,14 +30608,14 @@ GENERAL:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP:wlan0:wlan0:activated:no: VPN:openvpn:::*** VPN connection con-vpn-1 ***:5 - VPN connected:key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 842 -location: src/tests/client/test-client.py:test_004()/576 +size: 845 +location: src/tests/client/test-client.py:test_004()/578 cmd: $NMCLI --mode tabular --terse --color yes con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 663 bytes +stdout: 666 bytes >>> -connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: vpn:org.freedesktop.NetworkManager.openvpn::key1 = val1, key2 = val2, key3 = val3::no:0 @@ -30500,28 +30624,28 @@ GENERAL:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP:wlan0:wlan0:activated:no: VPN:openvpn:::*** VPN connection con-vpn-1 ***:5 - VPN connected:key1 = val1 | key2 = val2 | key3 = val3 <<< -size: 539 -location: src/tests/client/test-client.py:test_004()/577 +size: 542 +location: src/tests/client/test-client.py:test_004()/579 cmd: $NMCLI --mode tabular --terse --color yes -f ALL con s con-vpn-1 lang: C returncode: 0 -stdout: 363 bytes +stdout: 366 bytes >>> -connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: vpn:org.freedesktop.NetworkManager.openvpn::key1 = val1, key2 = val2, key3 = val3::no:0 proxy:none:no:: <<< -size: 549 -location: src/tests/client/test-client.py:test_004()/578 +size: 552 +location: src/tests/client/test-client.py:test_004()/580 cmd: $NMCLI --mode tabular --terse --color yes -f ALL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 363 bytes +stdout: 366 bytes >>> -connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1 +connection:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP::vpn::yes:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:-1 ipv4:auto::::0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1:: ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:stable-privacy:0:::0:yes::0x0: vpn:org.freedesktop.NetworkManager.openvpn::key1 = val1, key2 = val2, key3 = val3::no:0 @@ -30529,7 +30653,7 @@ proxy:none:no:: <<< size: 271 -location: src/tests/client/test-client.py:test_004()/579 +location: src/tests/client/test-client.py:test_004()/581 cmd: $NMCLI --mode tabular --terse --color yes -f VPN con s con-vpn-1 lang: C returncode: 0 @@ -30539,7 +30663,7 @@ vpn:org.freedesktop.NetworkManager.openvpn::key1 = val1, key2 = val2, key3 = val <<< size: 281 -location: src/tests/client/test-client.py:test_004()/580 +location: src/tests/client/test-client.py:test_004()/582 cmd: $NMCLI --mode tabular --terse --color yes -f VPN con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -30549,7 +30673,7 @@ vpn:org.freedesktop.NetworkManager.openvpn::key1 = val1, key2 = val2, key3 = val <<< size: 375 -location: src/tests/client/test-client.py:test_004()/581 +location: src/tests/client/test-client.py:test_004()/583 cmd: $NMCLI --mode tabular --terse --color yes -f GENERAL con s con-vpn-1 lang: C returncode: 0 @@ -30559,7 +30683,7 @@ GENERAL:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP:wlan0:wlan0:activated:no: <<< size: 385 -location: src/tests/client/test-client.py:test_004()/582 +location: src/tests/client/test-client.py:test_004()/584 cmd: $NMCLI --mode tabular --terse --color yes -f GENERAL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -30569,7 +30693,7 @@ GENERAL:con-vpn-1:UUID-con-vpn-1-REPLACED-REPLACED-REP:wlan0:wlan0:activated:no: <<< size: 456 -location: src/tests/client/test-client.py:test_004()/583 +location: src/tests/client/test-client.py:test_004()/585 cmd: $NMCLI --mode tabular --terse --color yes dev s lang: C returncode: 0 @@ -30583,7 +30707,7 @@ stdout: 297 bytes <<< size: 466 -location: src/tests/client/test-client.py:test_004()/584 +location: src/tests/client/test-client.py:test_004()/586 cmd: $NMCLI --mode tabular --terse --color yes dev s lang: pl_PL.UTF-8 returncode: 0 @@ -30597,7 +30721,7 @@ stdout: 297 bytes <<< size: 1059 -location: src/tests/client/test-client.py:test_004()/585 +location: src/tests/client/test-client.py:test_004()/587 cmd: $NMCLI --mode tabular --terse --color yes -f all dev status lang: C returncode: 0 @@ -30611,7 +30735,7 @@ stdout: 888 bytes <<< size: 1069 -location: src/tests/client/test-client.py:test_004()/586 +location: src/tests/client/test-client.py:test_004()/588 cmd: $NMCLI --mode tabular --terse --color yes -f all dev status lang: pl_PL.UTF-8 returncode: 0 @@ -30625,7 +30749,7 @@ stdout: 888 bytes <<< size: 3113 -location: src/tests/client/test-client.py:test_004()/587 +location: src/tests/client/test-client.py:test_004()/589 cmd: $NMCLI --mode tabular --terse --color yes dev show lang: C returncode: 0 @@ -30685,7 +30809,7 @@ IP6:2001\:a\:\:88ca\:3654\:96b\:ab44/89::dst = 2001\:a\:\:cc8b\:7c09\:4673\:bbb0 <<< size: 3123 -location: src/tests/client/test-client.py:test_004()/588 +location: src/tests/client/test-client.py:test_004()/590 cmd: $NMCLI --mode tabular --terse --color yes dev show lang: pl_PL.UTF-8 returncode: 0 @@ -30745,7 +30869,7 @@ IP6:2001\:a\:\:88ca\:3654\:96b\:ab44/89::dst = 2001\:a\:\:cc8b\:7c09\:4673\:bbb0 <<< size: 7190 -location: src/tests/client/test-client.py:test_004()/589 +location: src/tests/client/test-client.py:test_004()/591 cmd: $NMCLI --mode tabular --terse --color yes -f all dev show lang: C returncode: 0 @@ -30807,7 +30931,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{2}:UUID-con-xx1 <<< size: 7236 -location: src/tests/client/test-client.py:test_004()/590 +location: src/tests/client/test-client.py:test_004()/592 cmd: $NMCLI --mode tabular --terse --color yes -f all dev show lang: pl_PL.UTF-8 returncode: 0 @@ -30869,7 +30993,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{2}:UUID-con-xx1 <<< size: 615 -location: src/tests/client/test-client.py:test_004()/591 +location: src/tests/client/test-client.py:test_004()/593 cmd: $NMCLI --mode tabular --terse --color yes dev show wlan0 lang: C returncode: 0 @@ -30887,7 +31011,7 @@ IP6:::dst = 2001\:a\:\:dd5b\:aa7b\:b4a2\:e42/102, nh = \:\:, mt = 2504159086::se <<< size: 625 -location: src/tests/client/test-client.py:test_004()/592 +location: src/tests/client/test-client.py:test_004()/594 cmd: $NMCLI --mode tabular --terse --color yes dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -30905,7 +31029,7 @@ IP6:::dst = 2001\:a\:\:dd5b\:aa7b\:b4a2\:e42/102, nh = \:\:, mt = 2504159086::se <<< size: 1789 -location: src/tests/client/test-client.py:test_004()/593 +location: src/tests/client/test-client.py:test_004()/595 cmd: $NMCLI --mode tabular --terse --color yes -f all dev show wlan0 lang: C returncode: 0 @@ -30926,7 +31050,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{2}:UUID-con-xx1 <<< size: 1826 -location: src/tests/client/test-client.py:test_004()/594 +location: src/tests/client/test-client.py:test_004()/596 cmd: $NMCLI --mode tabular --terse --color yes -f all dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -30947,7 +31071,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{2}:UUID-con-xx1 <<< size: 628 -location: src/tests/client/test-client.py:test_004()/595 +location: src/tests/client/test-client.py:test_004()/597 cmd: $NMCLI --mode tabular --terse --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -30959,7 +31083,7 @@ WIFI-PROPERTIES:yes:yes:yes:yes:yes:yes:yes:unknown:unknown:no:no <<< size: 638 -location: src/tests/client/test-client.py:test_004()/596 +location: src/tests/client/test-client.py:test_004()/598 cmd: $NMCLI --mode tabular --terse --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -30971,7 +31095,7 @@ WIFI-PROPERTIES:yes:yes:yes:yes:yes:yes:yes:unknown:unknown:no:no <<< size: 628 -location: src/tests/client/test-client.py:test_004()/597 +location: src/tests/client/test-client.py:test_004()/599 cmd: $NMCLI --mode tabular --terse --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -30983,7 +31107,7 @@ WIFI-PROPERTIES:yes:yes:yes:yes:yes:yes:yes:unknown:unknown:no:no <<< size: 638 -location: src/tests/client/test-client.py:test_004()/598 +location: src/tests/client/test-client.py:test_004()/600 cmd: $NMCLI --mode tabular --terse --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -30995,7 +31119,7 @@ WIFI-PROPERTIES:yes:yes:yes:yes:yes:yes:yes:unknown:unknown:no:no <<< size: 576 -location: src/tests/client/test-client.py:test_004()/599 +location: src/tests/client/test-client.py:test_004()/601 cmd: $NMCLI --mode tabular --terse --color yes -f DEVICE,TYPE,DBUS-PATH dev lang: C returncode: 0 @@ -31009,7 +31133,7 @@ stdout: 394 bytes <<< size: 586 -location: src/tests/client/test-client.py:test_004()/600 +location: src/tests/client/test-client.py:test_004()/602 cmd: $NMCLI --mode tabular --terse --color yes -f DEVICE,TYPE,DBUS-PATH dev lang: pl_PL.UTF-8 returncode: 0 @@ -31023,7 +31147,7 @@ stdout: 394 bytes <<< size: 1724 -location: src/tests/client/test-client.py:test_004()/601 +location: src/tests/client/test-client.py:test_004()/603 cmd: $NMCLI --mode tabular --terse --color yes -f ALL device wifi list lang: C returncode: 0 @@ -31038,7 +31162,7 @@ stdout: 1546 bytes <<< size: 1782 -location: src/tests/client/test-client.py:test_004()/602 +location: src/tests/client/test-client.py:test_004()/604 cmd: $NMCLI --mode tabular --terse --color yes -f ALL device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -31053,7 +31177,7 @@ stdout: 1594 bytes <<< size: 784 -location: src/tests/client/test-client.py:test_004()/603 +location: src/tests/client/test-client.py:test_004()/605 cmd: $NMCLI --mode tabular --terse --color yes -f COMMON device wifi list lang: C returncode: 0 @@ -31068,7 +31192,7 @@ stdout: 604 bytes <<< size: 830 -location: src/tests/client/test-client.py:test_004()/604 +location: src/tests/client/test-client.py:test_004()/606 cmd: $NMCLI --mode tabular --terse --color yes -f COMMON device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -31083,7 +31207,7 @@ stdout: 640 bytes <<< size: 1837 -location: src/tests/client/test-client.py:test_004()/605 +location: src/tests/client/test-client.py:test_004()/607 cmd: $NMCLI --mode tabular --terse --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: C returncode: 0 @@ -31098,7 +31222,7 @@ stdout: 1546 bytes <<< size: 1895 -location: src/tests/client/test-client.py:test_004()/606 +location: src/tests/client/test-client.py:test_004()/608 cmd: $NMCLI --mode tabular --terse --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -31113,7 +31237,7 @@ stdout: 1594 bytes <<< size: 611 -location: src/tests/client/test-client.py:test_004()/607 +location: src/tests/client/test-client.py:test_004()/609 cmd: $NMCLI --mode tabular --terse --color yes -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -31125,7 +31249,7 @@ stdout: 410 bytes <<< size: 633 -location: src/tests/client/test-client.py:test_004()/608 +location: src/tests/client/test-client.py:test_004()/610 cmd: $NMCLI --mode tabular --terse --color yes -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -31137,7 +31261,7 @@ stdout: 422 bytes <<< size: 359 -location: src/tests/client/test-client.py:test_004()/609 +location: src/tests/client/test-client.py:test_004()/611 cmd: $NMCLI --mode tabular --terse --color yes -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -31149,7 +31273,7 @@ stdout: 155 bytes <<< size: 378 -location: src/tests/client/test-client.py:test_004()/610 +location: src/tests/client/test-client.py:test_004()/612 cmd: $NMCLI --mode tabular --terse --color yes -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -31161,7 +31285,7 @@ stdout: 164 bytes <<< size: 724 -location: src/tests/client/test-client.py:test_004()/611 +location: src/tests/client/test-client.py:test_004()/613 cmd: $NMCLI --mode tabular --terse --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -31173,7 +31297,7 @@ stdout: 410 bytes <<< size: 746 -location: src/tests/client/test-client.py:test_004()/612 +location: src/tests/client/test-client.py:test_004()/614 cmd: $NMCLI --mode tabular --terse --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -31185,7 +31309,7 @@ stdout: 422 bytes <<< size: 1792 -location: src/tests/client/test-client.py:test_004()/613 +location: src/tests/client/test-client.py:test_004()/615 cmd: $NMCLI --mode tabular --terse --color yes -f ALL device show wlan0 lang: C returncode: 0 @@ -31206,7 +31330,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{2}:UUID-con-xx1 <<< size: 1829 -location: src/tests/client/test-client.py:test_004()/614 +location: src/tests/client/test-client.py:test_004()/616 cmd: $NMCLI --mode tabular --terse --color yes -f ALL device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -31227,7 +31351,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{2}:UUID-con-xx1 <<< size: 628 -location: src/tests/client/test-client.py:test_004()/615 +location: src/tests/client/test-client.py:test_004()/617 cmd: $NMCLI --mode tabular --terse --color yes -f COMMON device show wlan0 lang: C returncode: 0 @@ -31245,7 +31369,7 @@ IP6:::dst = 2001\:a\:\:dd5b\:aa7b\:b4a2\:e42/102, nh = \:\:, mt = 2504159086::se <<< size: 638 -location: src/tests/client/test-client.py:test_004()/616 +location: src/tests/client/test-client.py:test_004()/618 cmd: $NMCLI --mode tabular --terse --color yes -f COMMON device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -31263,7 +31387,7 @@ IP6:::dst = 2001\:a\:\:dd5b\:aa7b\:b4a2\:e42/102, nh = \:\:, mt = 2504159086::se <<< size: 1900 -location: src/tests/client/test-client.py:test_004()/617 +location: src/tests/client/test-client.py:test_004()/619 cmd: $NMCLI --mode tabular --terse --color yes -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: C returncode: 0 @@ -31283,7 +31407,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{2}:UUID-con-xx1 <<< size: 1937 -location: src/tests/client/test-client.py:test_004()/618 +location: src/tests/client/test-client.py:test_004()/620 cmd: $NMCLI --mode tabular --terse --color yes -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -31303,7 +31427,7 @@ CONNECTIONS:/org/freedesktop/NetworkManager/Settings/Connection/{2}:UUID-con-xx1 <<< size: 642 -location: src/tests/client/test-client.py:test_004()/619 +location: src/tests/client/test-client.py:test_004()/621 cmd: $NMCLI --mode tabular --terse --color yes dev lldp list ifname eth0 lang: C returncode: 0 @@ -31315,7 +31439,7 @@ eth0:00\:11\:22\:33\:44\:22:port1:GigabitEthernet #3:test3.example.com:Test syst <<< size: 652 -location: src/tests/client/test-client.py:test_004()/620 +location: src/tests/client/test-client.py:test_004()/622 cmd: $NMCLI --mode tabular --terse --color yes dev lldp list ifname eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -31327,7 +31451,7 @@ eth0:00\:11\:22\:33\:44\:22:port1:GigabitEthernet #3:test3.example.com:Test syst <<< size: 572 -location: src/tests/client/test-client.py:test_004()/621 +location: src/tests/client/test-client.py:test_004()/623 cmd: $NMCLI --mode tabular --terse --color yes -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: C returncode: 0 @@ -31351,7 +31475,7 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA <<< size: 582 -location: src/tests/client/test-client.py:test_004()/622 +location: src/tests/client/test-client.py:test_004()/624 cmd: $NMCLI --mode tabular --terse --color yes -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: pl_PL.UTF-8 returncode: 0 @@ -31374,12 +31498,12 @@ UUID-con-xx1-REPLACED-REPLACED-REPLA <<< -size: 5278 -location: src/tests/client/test-client.py:test_004()/623 +size: 5331 +location: src/tests/client/test-client.py:test_004()/625 cmd: $NMCLI --mode multiline con s con-vpn-1 lang: C returncode: 0 -stdout: 5126 bytes +stdout: 5179 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -31404,6 +31528,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -31490,12 +31615,12 @@ VPN.CFG[2]: key2 = val2 VPN.CFG[3]: key3 = val3 <<< -size: 5308 -location: src/tests/client/test-client.py:test_004()/624 +size: 5361 +location: src/tests/client/test-client.py:test_004()/626 cmd: $NMCLI --mode multiline con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5146 bytes +stdout: 5199 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -31520,6 +31645,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -31606,12 +31732,12 @@ VPN.CFG[2]: key2 = val2 VPN.CFG[3]: key3 = val3 <<< -size: 5278 -location: src/tests/client/test-client.py:test_004()/625 +size: 5331 +location: src/tests/client/test-client.py:test_004()/627 cmd: $NMCLI --mode multiline con s con-vpn-1 lang: C returncode: 0 -stdout: 5126 bytes +stdout: 5179 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -31636,6 +31762,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -31722,12 +31849,12 @@ VPN.CFG[2]: key2 = val2 VPN.CFG[3]: key3 = val3 <<< -size: 5308 -location: src/tests/client/test-client.py:test_004()/626 +size: 5361 +location: src/tests/client/test-client.py:test_004()/628 cmd: $NMCLI --mode multiline con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5146 bytes +stdout: 5199 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -31752,6 +31879,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -31838,12 +31966,12 @@ VPN.CFG[2]: key2 = val2 VPN.CFG[3]: key3 = val3 <<< -size: 4151 -location: src/tests/client/test-client.py:test_004()/627 +size: 4204 +location: src/tests/client/test-client.py:test_004()/629 cmd: $NMCLI --mode multiline -f ALL con s con-vpn-1 lang: C returncode: 0 -stdout: 3992 bytes +stdout: 4045 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -31868,6 +31996,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -31933,12 +32062,12 @@ proxy.pac-url: -- proxy.pac-script: -- <<< -size: 4171 -location: src/tests/client/test-client.py:test_004()/628 +size: 4224 +location: src/tests/client/test-client.py:test_004()/630 cmd: $NMCLI --mode multiline -f ALL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 4002 bytes +stdout: 4055 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -31963,6 +32092,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -32029,7 +32159,7 @@ proxy.pac-script: -- <<< size: 492 -location: src/tests/client/test-client.py:test_004()/629 +location: src/tests/client/test-client.py:test_004()/631 cmd: $NMCLI --mode multiline -f VPN con s con-vpn-1 lang: C returncode: 0 @@ -32044,7 +32174,7 @@ vpn.timeout: 0 <<< size: 503 -location: src/tests/client/test-client.py:test_004()/630 +location: src/tests/client/test-client.py:test_004()/632 cmd: $NMCLI --mode multiline -f VPN con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -32059,7 +32189,7 @@ vpn.timeout: 0 <<< size: 875 -location: src/tests/client/test-client.py:test_004()/631 +location: src/tests/client/test-client.py:test_004()/633 cmd: $NMCLI --mode multiline -f GENERAL con s con-vpn-1 lang: C returncode: 0 @@ -32081,7 +32211,7 @@ GENERAL.MASTER-PATH: -- <<< size: 888 -location: src/tests/client/test-client.py:test_004()/632 +location: src/tests/client/test-client.py:test_004()/634 cmd: $NMCLI --mode multiline -f GENERAL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -32103,7 +32233,7 @@ GENERAL.MASTER-PATH: -- <<< size: 1082 -location: src/tests/client/test-client.py:test_004()/633 +location: src/tests/client/test-client.py:test_004()/635 cmd: $NMCLI --mode multiline dev s lang: C returncode: 0 @@ -32132,7 +32262,7 @@ CONNECTION: -- <<< size: 1098 -location: src/tests/client/test-client.py:test_004()/634 +location: src/tests/client/test-client.py:test_004()/636 cmd: $NMCLI --mode multiline dev s lang: pl_PL.UTF-8 returncode: 0 @@ -32161,7 +32291,7 @@ CONNECTION: -- <<< size: 2497 -location: src/tests/client/test-client.py:test_004()/635 +location: src/tests/client/test-client.py:test_004()/637 cmd: $NMCLI --mode multiline -f all dev status lang: C returncode: 0 @@ -32215,7 +32345,7 @@ CON-PATH: -- <<< size: 2523 -location: src/tests/client/test-client.py:test_004()/636 +location: src/tests/client/test-client.py:test_004()/638 cmd: $NMCLI --mode multiline -f all dev status lang: pl_PL.UTF-8 returncode: 0 @@ -32269,7 +32399,7 @@ CON-PATH: -- <<< size: 8060 -location: src/tests/client/test-client.py:test_004()/637 +location: src/tests/client/test-client.py:test_004()/639 cmd: $NMCLI --mode multiline dev show lang: C returncode: 0 @@ -32415,7 +32545,7 @@ IP6.DOMAIN[1]: sear6.fo.x.y <<< size: 8092 -location: src/tests/client/test-client.py:test_004()/638 +location: src/tests/client/test-client.py:test_004()/640 cmd: $NMCLI --mode multiline dev show lang: pl_PL.UTF-8 returncode: 0 @@ -32561,7 +32691,7 @@ IP6.DOMAIN[1]: sear6.fo.x.y <<< size: 22671 -location: src/tests/client/test-client.py:test_004()/639 +location: src/tests/client/test-client.py:test_004()/641 cmd: $NMCLI --mode multiline -f all dev show lang: C returncode: 0 @@ -32990,7 +33120,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 22839 -location: src/tests/client/test-client.py:test_004()/640 +location: src/tests/client/test-client.py:test_004()/642 cmd: $NMCLI --mode multiline -f all dev show lang: pl_PL.UTF-8 returncode: 0 @@ -33419,7 +33549,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 1513 -location: src/tests/client/test-client.py:test_004()/641 +location: src/tests/client/test-client.py:test_004()/643 cmd: $NMCLI --mode multiline dev show wlan0 lang: C returncode: 0 @@ -33452,7 +33582,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 1525 -location: src/tests/client/test-client.py:test_004()/642 +location: src/tests/client/test-client.py:test_004()/644 cmd: $NMCLI --mode multiline dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -33485,7 +33615,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 5424 -location: src/tests/client/test-client.py:test_004()/643 +location: src/tests/client/test-client.py:test_004()/645 cmd: $NMCLI --mode multiline -f all dev show wlan0 lang: C returncode: 0 @@ -33596,7 +33726,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 5485 -location: src/tests/client/test-client.py:test_004()/644 +location: src/tests/client/test-client.py:test_004()/646 cmd: $NMCLI --mode multiline -f all dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -33707,7 +33837,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 2189 -location: src/tests/client/test-client.py:test_004()/645 +location: src/tests/client/test-client.py:test_004()/647 cmd: $NMCLI --mode multiline -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -33756,7 +33886,7 @@ WIFI-PROPERTIES.IBSS-RSN: no <<< size: 2216 -location: src/tests/client/test-client.py:test_004()/646 +location: src/tests/client/test-client.py:test_004()/648 cmd: $NMCLI --mode multiline -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -33805,7 +33935,7 @@ WIFI-PROPERTIES.IBSS-RSN: nie <<< size: 2189 -location: src/tests/client/test-client.py:test_004()/647 +location: src/tests/client/test-client.py:test_004()/649 cmd: $NMCLI --mode multiline -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -33854,7 +33984,7 @@ WIFI-PROPERTIES.IBSS-RSN: no <<< size: 2216 -location: src/tests/client/test-client.py:test_004()/648 +location: src/tests/client/test-client.py:test_004()/650 cmd: $NMCLI --mode multiline -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -33903,7 +34033,7 @@ WIFI-PROPERTIES.IBSS-RSN: nie <<< size: 1035 -location: src/tests/client/test-client.py:test_004()/649 +location: src/tests/client/test-client.py:test_004()/651 cmd: $NMCLI --mode multiline -f DEVICE,TYPE,DBUS-PATH dev lang: C returncode: 0 @@ -33927,7 +34057,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Devices/ <<< size: 1045 -location: src/tests/client/test-client.py:test_004()/650 +location: src/tests/client/test-client.py:test_004()/652 cmd: $NMCLI --mode multiline -f DEVICE,TYPE,DBUS-PATH dev lang: pl_PL.UTF-8 returncode: 0 @@ -33951,7 +34081,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Devices/ <<< size: 3794 -location: src/tests/client/test-client.py:test_004()/651 +location: src/tests/client/test-client.py:test_004()/653 cmd: $NMCLI --mode multiline -f ALL device wifi list lang: C returncode: 0 @@ -34030,7 +34160,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/AccessPo <<< size: 3852 -location: src/tests/client/test-client.py:test_004()/652 +location: src/tests/client/test-client.py:test_004()/654 cmd: $NMCLI --mode multiline -f ALL device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -34109,7 +34239,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/AccessPo <<< size: 1863 -location: src/tests/client/test-client.py:test_004()/653 +location: src/tests/client/test-client.py:test_004()/655 cmd: $NMCLI --mode multiline -f COMMON device wifi list lang: C returncode: 0 @@ -34156,7 +34286,7 @@ SECURITY: WPA1 WPA2 <<< size: 1909 -location: src/tests/client/test-client.py:test_004()/654 +location: src/tests/client/test-client.py:test_004()/656 cmd: $NMCLI --mode multiline -f COMMON device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -34203,7 +34333,7 @@ SECURITY: WPA1 WPA2 <<< size: 3907 -location: src/tests/client/test-client.py:test_004()/655 +location: src/tests/client/test-client.py:test_004()/657 cmd: $NMCLI --mode multiline -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: C returncode: 0 @@ -34282,7 +34412,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/AccessPo <<< size: 3965 -location: src/tests/client/test-client.py:test_004()/656 +location: src/tests/client/test-client.py:test_004()/658 cmd: $NMCLI --mode multiline -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -34361,7 +34491,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/AccessPo <<< size: 1115 -location: src/tests/client/test-client.py:test_004()/657 +location: src/tests/client/test-client.py:test_004()/659 cmd: $NMCLI --mode multiline -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -34389,7 +34519,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/AccessPo <<< size: 1137 -location: src/tests/client/test-client.py:test_004()/658 +location: src/tests/client/test-client.py:test_004()/660 cmd: $NMCLI --mode multiline -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -34417,7 +34547,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/AccessPo <<< size: 615 -location: src/tests/client/test-client.py:test_004()/659 +location: src/tests/client/test-client.py:test_004()/661 cmd: $NMCLI --mode multiline -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -34437,7 +34567,7 @@ SECURITY: WPA1 WPA2 <<< size: 634 -location: src/tests/client/test-client.py:test_004()/660 +location: src/tests/client/test-client.py:test_004()/662 cmd: $NMCLI --mode multiline -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -34457,7 +34587,7 @@ SECURITY: WPA1 WPA2 <<< size: 1228 -location: src/tests/client/test-client.py:test_004()/661 +location: src/tests/client/test-client.py:test_004()/663 cmd: $NMCLI --mode multiline -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -34485,7 +34615,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/AccessPo <<< size: 1250 -location: src/tests/client/test-client.py:test_004()/662 +location: src/tests/client/test-client.py:test_004()/664 cmd: $NMCLI --mode multiline -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -34513,7 +34643,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/AccessPo <<< size: 5427 -location: src/tests/client/test-client.py:test_004()/663 +location: src/tests/client/test-client.py:test_004()/665 cmd: $NMCLI --mode multiline -f ALL device show wlan0 lang: C returncode: 0 @@ -34624,7 +34754,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 5488 -location: src/tests/client/test-client.py:test_004()/664 +location: src/tests/client/test-client.py:test_004()/666 cmd: $NMCLI --mode multiline -f ALL device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -34735,7 +34865,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 1526 -location: src/tests/client/test-client.py:test_004()/665 +location: src/tests/client/test-client.py:test_004()/667 cmd: $NMCLI --mode multiline -f COMMON device show wlan0 lang: C returncode: 0 @@ -34768,7 +34898,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 1538 -location: src/tests/client/test-client.py:test_004()/666 +location: src/tests/client/test-client.py:test_004()/668 cmd: $NMCLI --mode multiline -f COMMON device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -34801,7 +34931,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 5391 -location: src/tests/client/test-client.py:test_004()/667 +location: src/tests/client/test-client.py:test_004()/669 cmd: $NMCLI --mode multiline -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: C returncode: 0 @@ -34908,7 +35038,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 5450 -location: src/tests/client/test-client.py:test_004()/668 +location: src/tests/client/test-client.py:test_004()/670 cmd: $NMCLI --mode multiline -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -35015,7 +35145,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 1450 -location: src/tests/client/test-client.py:test_004()/669 +location: src/tests/client/test-client.py:test_004()/671 cmd: $NMCLI --mode multiline dev lldp list ifname eth0 lang: C returncode: 0 @@ -35045,7 +35175,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES: 40 (wlan-access-point,telephone) <<< size: 1460 -location: src/tests/client/test-client.py:test_004()/670 +location: src/tests/client/test-client.py:test_004()/672 cmd: $NMCLI --mode multiline dev lldp list ifname eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -35075,7 +35205,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES: 40 (wlan-access-point,telephone) <<< size: 1082 -location: src/tests/client/test-client.py:test_004()/671 +location: src/tests/client/test-client.py:test_004()/673 cmd: $NMCLI --mode multiline -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: C returncode: 0 @@ -35099,7 +35229,7 @@ connection.interface-name: -- <<< size: 1092 -location: src/tests/client/test-client.py:test_004()/672 +location: src/tests/client/test-client.py:test_004()/674 cmd: $NMCLI --mode multiline -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: pl_PL.UTF-8 returncode: 0 @@ -35122,12 +35252,12 @@ connection.type: 802-11-wireless connection.interface-name: -- <<< -size: 5290 -location: src/tests/client/test-client.py:test_004()/673 +size: 5343 +location: src/tests/client/test-client.py:test_004()/675 cmd: $NMCLI --mode multiline --color yes con s con-vpn-1 lang: C returncode: 0 -stdout: 5126 bytes +stdout: 5179 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -35152,6 +35282,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -35238,12 +35369,12 @@ VPN.CFG[2]: key2 = val2 VPN.CFG[3]: key3 = val3 <<< -size: 5320 -location: src/tests/client/test-client.py:test_004()/674 +size: 5373 +location: src/tests/client/test-client.py:test_004()/676 cmd: $NMCLI --mode multiline --color yes con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5146 bytes +stdout: 5199 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -35268,6 +35399,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -35354,12 +35486,12 @@ VPN.CFG[2]: key2 = val2 VPN.CFG[3]: key3 = val3 <<< -size: 5290 -location: src/tests/client/test-client.py:test_004()/675 +size: 5343 +location: src/tests/client/test-client.py:test_004()/677 cmd: $NMCLI --mode multiline --color yes con s con-vpn-1 lang: C returncode: 0 -stdout: 5126 bytes +stdout: 5179 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -35384,6 +35516,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -35470,12 +35603,12 @@ VPN.CFG[2]: key2 = val2 VPN.CFG[3]: key3 = val3 <<< -size: 5320 -location: src/tests/client/test-client.py:test_004()/676 +size: 5373 +location: src/tests/client/test-client.py:test_004()/678 cmd: $NMCLI --mode multiline --color yes con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5146 bytes +stdout: 5199 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -35500,6 +35633,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -35586,12 +35720,12 @@ VPN.CFG[2]: key2 = val2 VPN.CFG[3]: key3 = val3 <<< -size: 4163 -location: src/tests/client/test-client.py:test_004()/677 +size: 4216 +location: src/tests/client/test-client.py:test_004()/679 cmd: $NMCLI --mode multiline --color yes -f ALL con s con-vpn-1 lang: C returncode: 0 -stdout: 3992 bytes +stdout: 4045 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -35616,6 +35750,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -35681,12 +35816,12 @@ proxy.pac-url: -- proxy.pac-script: -- <<< -size: 4183 -location: src/tests/client/test-client.py:test_004()/678 +size: 4236 +location: src/tests/client/test-client.py:test_004()/680 cmd: $NMCLI --mode multiline --color yes -f ALL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 4002 bytes +stdout: 4055 bytes >>> connection.id: con-vpn-1 connection.uuid: UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -35711,6 +35846,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ipv4.method: auto ipv4.dns: -- @@ -35777,7 +35913,7 @@ proxy.pac-script: -- <<< size: 504 -location: src/tests/client/test-client.py:test_004()/679 +location: src/tests/client/test-client.py:test_004()/681 cmd: $NMCLI --mode multiline --color yes -f VPN con s con-vpn-1 lang: C returncode: 0 @@ -35792,7 +35928,7 @@ vpn.timeout: 0 <<< size: 515 -location: src/tests/client/test-client.py:test_004()/680 +location: src/tests/client/test-client.py:test_004()/682 cmd: $NMCLI --mode multiline --color yes -f VPN con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -35807,7 +35943,7 @@ vpn.timeout: 0 <<< size: 887 -location: src/tests/client/test-client.py:test_004()/681 +location: src/tests/client/test-client.py:test_004()/683 cmd: $NMCLI --mode multiline --color yes -f GENERAL con s con-vpn-1 lang: C returncode: 0 @@ -35829,7 +35965,7 @@ GENERAL.MASTER-PATH: -- <<< size: 900 -location: src/tests/client/test-client.py:test_004()/682 +location: src/tests/client/test-client.py:test_004()/684 cmd: $NMCLI --mode multiline --color yes -f GENERAL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -35851,7 +35987,7 @@ GENERAL.MASTER-PATH: -- <<< size: 1259 -location: src/tests/client/test-client.py:test_004()/683 +location: src/tests/client/test-client.py:test_004()/685 cmd: $NMCLI --mode multiline --color yes dev s lang: C returncode: 0 @@ -35880,7 +36016,7 @@ CONNECTION: -- <<< size: 1275 -location: src/tests/client/test-client.py:test_004()/684 +location: src/tests/client/test-client.py:test_004()/686 cmd: $NMCLI --mode multiline --color yes dev s lang: pl_PL.UTF-8 returncode: 0 @@ -35909,7 +36045,7 @@ CONNECTION: -- <<< size: 2878 -location: src/tests/client/test-client.py:test_004()/685 +location: src/tests/client/test-client.py:test_004()/687 cmd: $NMCLI --mode multiline --color yes -f all dev status lang: C returncode: 0 @@ -35963,7 +36099,7 @@ CON-PATH: -- <<< size: 2904 -location: src/tests/client/test-client.py:test_004()/686 +location: src/tests/client/test-client.py:test_004()/688 cmd: $NMCLI --mode multiline --color yes -f all dev status lang: pl_PL.UTF-8 returncode: 0 @@ -36017,7 +36153,7 @@ CON-PATH: -- <<< size: 8072 -location: src/tests/client/test-client.py:test_004()/687 +location: src/tests/client/test-client.py:test_004()/689 cmd: $NMCLI --mode multiline --color yes dev show lang: C returncode: 0 @@ -36163,7 +36299,7 @@ IP6.DOMAIN[1]: sear6.fo.x.y <<< size: 8104 -location: src/tests/client/test-client.py:test_004()/688 +location: src/tests/client/test-client.py:test_004()/690 cmd: $NMCLI --mode multiline --color yes dev show lang: pl_PL.UTF-8 returncode: 0 @@ -36309,7 +36445,7 @@ IP6.DOMAIN[1]: sear6.fo.x.y <<< size: 23007 -location: src/tests/client/test-client.py:test_004()/689 +location: src/tests/client/test-client.py:test_004()/691 cmd: $NMCLI --mode multiline --color yes -f all dev show lang: C returncode: 0 @@ -36738,7 +36874,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 23175 -location: src/tests/client/test-client.py:test_004()/690 +location: src/tests/client/test-client.py:test_004()/692 cmd: $NMCLI --mode multiline --color yes -f all dev show lang: pl_PL.UTF-8 returncode: 0 @@ -37167,7 +37303,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 1525 -location: src/tests/client/test-client.py:test_004()/691 +location: src/tests/client/test-client.py:test_004()/693 cmd: $NMCLI --mode multiline --color yes dev show wlan0 lang: C returncode: 0 @@ -37200,7 +37336,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 1537 -location: src/tests/client/test-client.py:test_004()/692 +location: src/tests/client/test-client.py:test_004()/694 cmd: $NMCLI --mode multiline --color yes dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -37233,7 +37369,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 5679 -location: src/tests/client/test-client.py:test_004()/693 +location: src/tests/client/test-client.py:test_004()/695 cmd: $NMCLI --mode multiline --color yes -f all dev show wlan0 lang: C returncode: 0 @@ -37344,7 +37480,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 5740 -location: src/tests/client/test-client.py:test_004()/694 +location: src/tests/client/test-client.py:test_004()/696 cmd: $NMCLI --mode multiline --color yes -f all dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -37455,7 +37591,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 2201 -location: src/tests/client/test-client.py:test_004()/695 +location: src/tests/client/test-client.py:test_004()/697 cmd: $NMCLI --mode multiline --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -37504,7 +37640,7 @@ WIFI-PROPERTIES.IBSS-RSN: no <<< size: 2228 -location: src/tests/client/test-client.py:test_004()/696 +location: src/tests/client/test-client.py:test_004()/698 cmd: $NMCLI --mode multiline --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -37553,7 +37689,7 @@ WIFI-PROPERTIES.IBSS-RSN: nie <<< size: 2201 -location: src/tests/client/test-client.py:test_004()/697 +location: src/tests/client/test-client.py:test_004()/699 cmd: $NMCLI --mode multiline --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -37602,7 +37738,7 @@ WIFI-PROPERTIES.IBSS-RSN: no <<< size: 2228 -location: src/tests/client/test-client.py:test_004()/698 +location: src/tests/client/test-client.py:test_004()/700 cmd: $NMCLI --mode multiline --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -37651,7 +37787,7 @@ WIFI-PROPERTIES.IBSS-RSN: nie <<< size: 1170 -location: src/tests/client/test-client.py:test_004()/699 +location: src/tests/client/test-client.py:test_004()/701 cmd: $NMCLI --mode multiline --color yes -f DEVICE,TYPE,DBUS-PATH dev lang: C returncode: 0 @@ -37675,7 +37811,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Devi <<< size: 1180 -location: src/tests/client/test-client.py:test_004()/700 +location: src/tests/client/test-client.py:test_004()/702 cmd: $NMCLI --mode multiline --color yes -f DEVICE,TYPE,DBUS-PATH dev lang: pl_PL.UTF-8 returncode: 0 @@ -37699,7 +37835,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Devi <<< size: 4418 -location: src/tests/client/test-client.py:test_004()/701 +location: src/tests/client/test-client.py:test_004()/703 cmd: $NMCLI --mode multiline --color yes -f ALL device wifi list lang: C returncode: 0 @@ -37778,7 +37914,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Acc <<< size: 4476 -location: src/tests/client/test-client.py:test_004()/702 +location: src/tests/client/test-client.py:test_004()/704 cmd: $NMCLI --mode multiline --color yes -f ALL device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -37857,7 +37993,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Acc <<< size: 2199 -location: src/tests/client/test-client.py:test_004()/703 +location: src/tests/client/test-client.py:test_004()/705 cmd: $NMCLI --mode multiline --color yes -f COMMON device wifi list lang: C returncode: 0 @@ -37904,7 +38040,7 @@ SECURITY: WPA1 WPA2 <<< size: 2245 -location: src/tests/client/test-client.py:test_004()/704 +location: src/tests/client/test-client.py:test_004()/706 cmd: $NMCLI --mode multiline --color yes -f COMMON device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -37951,7 +38087,7 @@ SECURITY: WPA1 WPA2 <<< size: 4531 -location: src/tests/client/test-client.py:test_004()/705 +location: src/tests/client/test-client.py:test_004()/707 cmd: $NMCLI --mode multiline --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: C returncode: 0 @@ -38030,7 +38166,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Acc <<< size: 4589 -location: src/tests/client/test-client.py:test_004()/706 +location: src/tests/client/test-client.py:test_004()/708 cmd: $NMCLI --mode multiline --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -38109,7 +38245,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Acc <<< size: 1281 -location: src/tests/client/test-client.py:test_004()/707 +location: src/tests/client/test-client.py:test_004()/709 cmd: $NMCLI --mode multiline --color yes -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -38137,7 +38273,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Acc <<< size: 1303 -location: src/tests/client/test-client.py:test_004()/708 +location: src/tests/client/test-client.py:test_004()/710 cmd: $NMCLI --mode multiline --color yes -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -38165,7 +38301,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Acc <<< size: 708 -location: src/tests/client/test-client.py:test_004()/709 +location: src/tests/client/test-client.py:test_004()/711 cmd: $NMCLI --mode multiline --color yes -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -38185,7 +38321,7 @@ SECURITY: WPA1 WPA2 <<< size: 727 -location: src/tests/client/test-client.py:test_004()/710 +location: src/tests/client/test-client.py:test_004()/712 cmd: $NMCLI --mode multiline --color yes -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -38205,7 +38341,7 @@ SECURITY: WPA1 WPA2 <<< size: 1394 -location: src/tests/client/test-client.py:test_004()/711 +location: src/tests/client/test-client.py:test_004()/713 cmd: $NMCLI --mode multiline --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -38233,7 +38369,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Acc <<< size: 1416 -location: src/tests/client/test-client.py:test_004()/712 +location: src/tests/client/test-client.py:test_004()/714 cmd: $NMCLI --mode multiline --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -38261,7 +38397,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Acc <<< size: 5682 -location: src/tests/client/test-client.py:test_004()/713 +location: src/tests/client/test-client.py:test_004()/715 cmd: $NMCLI --mode multiline --color yes -f ALL device show wlan0 lang: C returncode: 0 @@ -38372,7 +38508,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 5743 -location: src/tests/client/test-client.py:test_004()/714 +location: src/tests/client/test-client.py:test_004()/716 cmd: $NMCLI --mode multiline --color yes -f ALL device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -38483,7 +38619,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 1538 -location: src/tests/client/test-client.py:test_004()/715 +location: src/tests/client/test-client.py:test_004()/717 cmd: $NMCLI --mode multiline --color yes -f COMMON device show wlan0 lang: C returncode: 0 @@ -38516,7 +38652,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 1550 -location: src/tests/client/test-client.py:test_004()/716 +location: src/tests/client/test-client.py:test_004()/718 cmd: $NMCLI --mode multiline --color yes -f COMMON device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -38549,7 +38685,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 5646 -location: src/tests/client/test-client.py:test_004()/717 +location: src/tests/client/test-client.py:test_004()/719 cmd: $NMCLI --mode multiline --color yes -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: C returncode: 0 @@ -38656,7 +38792,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 5705 -location: src/tests/client/test-client.py:test_004()/718 +location: src/tests/client/test-client.py:test_004()/720 cmd: $NMCLI --mode multiline --color yes -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -38763,7 +38899,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 1462 -location: src/tests/client/test-client.py:test_004()/719 +location: src/tests/client/test-client.py:test_004()/721 cmd: $NMCLI --mode multiline --color yes dev lldp list ifname eth0 lang: C returncode: 0 @@ -38793,7 +38929,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES: 40 (wlan-access-point,telephone) <<< size: 1472 -location: src/tests/client/test-client.py:test_004()/720 +location: src/tests/client/test-client.py:test_004()/722 cmd: $NMCLI --mode multiline --color yes dev lldp list ifname eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -38823,7 +38959,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES: 40 (wlan-access-point,telephone) <<< size: 1094 -location: src/tests/client/test-client.py:test_004()/721 +location: src/tests/client/test-client.py:test_004()/723 cmd: $NMCLI --mode multiline --color yes -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: C returncode: 0 @@ -38847,7 +38983,7 @@ connection.interface-name: -- <<< size: 1104 -location: src/tests/client/test-client.py:test_004()/722 +location: src/tests/client/test-client.py:test_004()/724 cmd: $NMCLI --mode multiline --color yes -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: pl_PL.UTF-8 returncode: 0 @@ -38870,12 +39006,12 @@ connection.type: 802-11-wireless connection.interface-name: -- <<< -size: 6299 -location: src/tests/client/test-client.py:test_004()/723 +size: 6352 +location: src/tests/client/test-client.py:test_004()/725 cmd: $NMCLI --mode multiline --pretty con s con-vpn-1 lang: C returncode: 0 -stdout: 6138 bytes +stdout: 6191 bytes >>> =============================================================================== Connection profile details (con-vpn-1) @@ -38903,6 +39039,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -38999,12 +39136,12 @@ VPN.CFG[3]: key3 = val3 ------------------------------------------------------------------------------- <<< -size: 6341 -location: src/tests/client/test-client.py:test_004()/724 +size: 6394 +location: src/tests/client/test-client.py:test_004()/726 cmd: $NMCLI --mode multiline --pretty con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 6170 bytes +stdout: 6223 bytes >>> =============================================================================== Szczegóły profilu połączenia (con-vpn-1) @@ -39032,6 +39169,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -39128,12 +39266,12 @@ VPN.CFG[3]: key3 = val3 ------------------------------------------------------------------------------- <<< -size: 6299 -location: src/tests/client/test-client.py:test_004()/725 +size: 6352 +location: src/tests/client/test-client.py:test_004()/727 cmd: $NMCLI --mode multiline --pretty con s con-vpn-1 lang: C returncode: 0 -stdout: 6138 bytes +stdout: 6191 bytes >>> =============================================================================== Connection profile details (con-vpn-1) @@ -39161,6 +39299,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -39257,12 +39396,12 @@ VPN.CFG[3]: key3 = val3 ------------------------------------------------------------------------------- <<< -size: 6341 -location: src/tests/client/test-client.py:test_004()/726 +size: 6394 +location: src/tests/client/test-client.py:test_004()/728 cmd: $NMCLI --mode multiline --pretty con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 6170 bytes +stdout: 6223 bytes >>> =============================================================================== Szczegóły profilu połączenia (con-vpn-1) @@ -39290,6 +39429,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -39386,12 +39526,12 @@ VPN.CFG[3]: key3 = val3 ------------------------------------------------------------------------------- <<< -size: 4779 -location: src/tests/client/test-client.py:test_004()/727 +size: 4832 +location: src/tests/client/test-client.py:test_004()/729 cmd: $NMCLI --mode multiline --pretty -f ALL con s con-vpn-1 lang: C returncode: 0 -stdout: 4611 bytes +stdout: 4664 bytes >>> =============================================================================== Connection profile details (con-vpn-1) @@ -39419,6 +39559,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -39489,12 +39630,12 @@ proxy.pac-script: -- ------------------------------------------------------------------------------- <<< -size: 4804 -location: src/tests/client/test-client.py:test_004()/728 +size: 4857 +location: src/tests/client/test-client.py:test_004()/730 cmd: $NMCLI --mode multiline --pretty -f ALL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 4626 bytes +stdout: 4679 bytes >>> =============================================================================== Szczegóły profilu połączenia (con-vpn-1) @@ -39522,6 +39663,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -39593,7 +39735,7 @@ proxy.pac-script: -- <<< size: 800 -location: src/tests/client/test-client.py:test_004()/729 +location: src/tests/client/test-client.py:test_004()/731 cmd: $NMCLI --mode multiline --pretty -f VPN con s con-vpn-1 lang: C returncode: 0 @@ -39612,7 +39754,7 @@ vpn.timeout: 0 <<< size: 816 -location: src/tests/client/test-client.py:test_004()/730 +location: src/tests/client/test-client.py:test_004()/732 cmd: $NMCLI --mode multiline --pretty -f VPN con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -39631,7 +39773,7 @@ vpn.timeout: 0 <<< size: 1198 -location: src/tests/client/test-client.py:test_004()/731 +location: src/tests/client/test-client.py:test_004()/733 cmd: $NMCLI --mode multiline --pretty -f GENERAL con s con-vpn-1 lang: C returncode: 0 @@ -39657,7 +39799,7 @@ GENERAL.MASTER-PATH: -- <<< size: 1218 -location: src/tests/client/test-client.py:test_004()/732 +location: src/tests/client/test-client.py:test_004()/734 cmd: $NMCLI --mode multiline --pretty -f GENERAL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -39683,7 +39825,7 @@ GENERAL.MASTER-PATH: -- <<< size: 1701 -location: src/tests/client/test-client.py:test_004()/733 +location: src/tests/client/test-client.py:test_004()/735 cmd: $NMCLI --mode multiline --pretty dev s lang: C returncode: 0 @@ -39720,7 +39862,7 @@ CONNECTION: -- <<< size: 1717 -location: src/tests/client/test-client.py:test_004()/734 +location: src/tests/client/test-client.py:test_004()/736 cmd: $NMCLI --mode multiline --pretty dev s lang: pl_PL.UTF-8 returncode: 0 @@ -39757,7 +39899,7 @@ CONNECTION: -- <<< size: 3115 -location: src/tests/client/test-client.py:test_004()/735 +location: src/tests/client/test-client.py:test_004()/737 cmd: $NMCLI --mode multiline --pretty -f all dev status lang: C returncode: 0 @@ -39819,7 +39961,7 @@ CON-PATH: -- <<< size: 3141 -location: src/tests/client/test-client.py:test_004()/736 +location: src/tests/client/test-client.py:test_004()/738 cmd: $NMCLI --mode multiline --pretty -f all dev status lang: pl_PL.UTF-8 returncode: 0 @@ -39881,7 +40023,7 @@ CON-PATH: -- <<< size: 12885 -location: src/tests/client/test-client.py:test_004()/737 +location: src/tests/client/test-client.py:test_004()/739 cmd: $NMCLI --mode multiline --pretty dev show lang: C returncode: 0 @@ -40089,7 +40231,7 @@ IP6.DOMAIN[1]: sear6.fo.x.y <<< size: 12950 -location: src/tests/client/test-client.py:test_004()/738 +location: src/tests/client/test-client.py:test_004()/740 cmd: $NMCLI --mode multiline --pretty dev show lang: pl_PL.UTF-8 returncode: 0 @@ -40297,7 +40439,7 @@ IP6.DOMAIN[1]: sear6.fo.x.y <<< size: 27655 -location: src/tests/client/test-client.py:test_004()/739 +location: src/tests/client/test-client.py:test_004()/741 cmd: $NMCLI --mode multiline --pretty -f all dev show lang: C returncode: 0 @@ -40790,7 +40932,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 27856 -location: src/tests/client/test-client.py:test_004()/740 +location: src/tests/client/test-client.py:test_004()/742 cmd: $NMCLI --mode multiline --pretty -f all dev show lang: pl_PL.UTF-8 returncode: 0 @@ -41283,7 +41425,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 2453 -location: src/tests/client/test-client.py:test_004()/741 +location: src/tests/client/test-client.py:test_004()/743 cmd: $NMCLI --mode multiline --pretty dev show wlan0 lang: C returncode: 0 @@ -41328,7 +41470,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 2472 -location: src/tests/client/test-client.py:test_004()/742 +location: src/tests/client/test-client.py:test_004()/744 cmd: $NMCLI --mode multiline --pretty dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -41373,7 +41515,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 6604 -location: src/tests/client/test-client.py:test_004()/743 +location: src/tests/client/test-client.py:test_004()/745 cmd: $NMCLI --mode multiline --pretty -f all dev show wlan0 lang: C returncode: 0 @@ -41499,7 +41641,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 6672 -location: src/tests/client/test-client.py:test_004()/744 +location: src/tests/client/test-client.py:test_004()/746 cmd: $NMCLI --mode multiline --pretty -f all dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -41625,7 +41767,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 2649 -location: src/tests/client/test-client.py:test_004()/745 +location: src/tests/client/test-client.py:test_004()/747 cmd: $NMCLI --mode multiline --pretty -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -41680,7 +41822,7 @@ WIFI-PROPERTIES.IBSS-RSN: no <<< size: 2683 -location: src/tests/client/test-client.py:test_004()/746 +location: src/tests/client/test-client.py:test_004()/748 cmd: $NMCLI --mode multiline --pretty -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -41735,7 +41877,7 @@ WIFI-PROPERTIES.IBSS-RSN: nie <<< size: 2649 -location: src/tests/client/test-client.py:test_004()/747 +location: src/tests/client/test-client.py:test_004()/749 cmd: $NMCLI --mode multiline --pretty -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -41790,7 +41932,7 @@ WIFI-PROPERTIES.IBSS-RSN: no <<< size: 2683 -location: src/tests/client/test-client.py:test_004()/748 +location: src/tests/client/test-client.py:test_004()/750 cmd: $NMCLI --mode multiline --pretty -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -41845,7 +41987,7 @@ WIFI-PROPERTIES.IBSS-RSN: nie <<< size: 1654 -location: src/tests/client/test-client.py:test_004()/749 +location: src/tests/client/test-client.py:test_004()/751 cmd: $NMCLI --mode multiline --pretty -f DEVICE,TYPE,DBUS-PATH dev lang: C returncode: 0 @@ -41877,7 +42019,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Devices/ <<< size: 1664 -location: src/tests/client/test-client.py:test_004()/750 +location: src/tests/client/test-client.py:test_004()/752 cmd: $NMCLI --mode multiline --pretty -f DEVICE,TYPE,DBUS-PATH dev lang: pl_PL.UTF-8 returncode: 0 @@ -41909,7 +42051,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Devices/ <<< size: 4759 -location: src/tests/client/test-client.py:test_004()/751 +location: src/tests/client/test-client.py:test_004()/753 cmd: $NMCLI --mode multiline --pretty -f ALL device wifi list lang: C returncode: 0 @@ -42001,7 +42143,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/AccessPo <<< size: 4835 -location: src/tests/client/test-client.py:test_004()/752 +location: src/tests/client/test-client.py:test_004()/754 cmd: $NMCLI --mode multiline --pretty -f ALL device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -42093,7 +42235,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/AccessPo <<< size: 2828 -location: src/tests/client/test-client.py:test_004()/753 +location: src/tests/client/test-client.py:test_004()/755 cmd: $NMCLI --mode multiline --pretty -f COMMON device wifi list lang: C returncode: 0 @@ -42153,7 +42295,7 @@ SECURITY: WPA1 WPA2 <<< size: 2892 -location: src/tests/client/test-client.py:test_004()/754 +location: src/tests/client/test-client.py:test_004()/756 cmd: $NMCLI --mode multiline --pretty -f COMMON device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -42213,7 +42355,7 @@ SECURITY: WPA1 WPA2 <<< size: 4872 -location: src/tests/client/test-client.py:test_004()/755 +location: src/tests/client/test-client.py:test_004()/757 cmd: $NMCLI --mode multiline --pretty -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: C returncode: 0 @@ -42305,7 +42447,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/AccessPo <<< size: 4948 -location: src/tests/client/test-client.py:test_004()/756 +location: src/tests/client/test-client.py:test_004()/758 cmd: $NMCLI --mode multiline --pretty -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -42397,7 +42539,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/AccessPo <<< size: 1417 -location: src/tests/client/test-client.py:test_004()/757 +location: src/tests/client/test-client.py:test_004()/759 cmd: $NMCLI --mode multiline --pretty -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -42429,7 +42571,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/AccessPo <<< size: 1445 -location: src/tests/client/test-client.py:test_004()/758 +location: src/tests/client/test-client.py:test_004()/760 cmd: $NMCLI --mode multiline --pretty -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -42461,7 +42603,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/AccessPo <<< size: 916 -location: src/tests/client/test-client.py:test_004()/759 +location: src/tests/client/test-client.py:test_004()/761 cmd: $NMCLI --mode multiline --pretty -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -42485,7 +42627,7 @@ SECURITY: WPA1 WPA2 <<< size: 941 -location: src/tests/client/test-client.py:test_004()/760 +location: src/tests/client/test-client.py:test_004()/762 cmd: $NMCLI --mode multiline --pretty -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -42509,7 +42651,7 @@ SECURITY: WPA1 WPA2 <<< size: 1530 -location: src/tests/client/test-client.py:test_004()/761 +location: src/tests/client/test-client.py:test_004()/763 cmd: $NMCLI --mode multiline --pretty -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -42541,7 +42683,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/AccessPo <<< size: 1558 -location: src/tests/client/test-client.py:test_004()/762 +location: src/tests/client/test-client.py:test_004()/764 cmd: $NMCLI --mode multiline --pretty -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -42573,7 +42715,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/AccessPo <<< size: 6607 -location: src/tests/client/test-client.py:test_004()/763 +location: src/tests/client/test-client.py:test_004()/765 cmd: $NMCLI --mode multiline --pretty -f ALL device show wlan0 lang: C returncode: 0 @@ -42699,7 +42841,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 6675 -location: src/tests/client/test-client.py:test_004()/764 +location: src/tests/client/test-client.py:test_004()/766 cmd: $NMCLI --mode multiline --pretty -f ALL device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -42825,7 +42967,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 2466 -location: src/tests/client/test-client.py:test_004()/765 +location: src/tests/client/test-client.py:test_004()/767 cmd: $NMCLI --mode multiline --pretty -f COMMON device show wlan0 lang: C returncode: 0 @@ -42870,7 +43012,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 2485 -location: src/tests/client/test-client.py:test_004()/766 +location: src/tests/client/test-client.py:test_004()/768 cmd: $NMCLI --mode multiline --pretty -f COMMON device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -42915,7 +43057,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 6491 -location: src/tests/client/test-client.py:test_004()/767 +location: src/tests/client/test-client.py:test_004()/769 cmd: $NMCLI --mode multiline --pretty -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: C returncode: 0 @@ -43036,7 +43178,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 6557 -location: src/tests/client/test-client.py:test_004()/768 +location: src/tests/client/test-client.py:test_004()/770 cmd: $NMCLI --mode multiline --pretty -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -43157,7 +43299,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 1913 -location: src/tests/client/test-client.py:test_004()/769 +location: src/tests/client/test-client.py:test_004()/771 cmd: $NMCLI --mode multiline --pretty dev lldp list ifname eth0 lang: C returncode: 0 @@ -43193,7 +43335,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES: 40 (wlan-access-point,telephone) <<< size: 1927 -location: src/tests/client/test-client.py:test_004()/770 +location: src/tests/client/test-client.py:test_004()/772 cmd: $NMCLI --mode multiline --pretty dev lldp list ifname eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -43229,7 +43371,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES: 40 (wlan-access-point,telephone) <<< size: 2786 -location: src/tests/client/test-client.py:test_004()/771 +location: src/tests/client/test-client.py:test_004()/773 cmd: $NMCLI --mode multiline --pretty -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: C returncode: 0 @@ -43275,7 +43417,7 @@ connection.interface-name: -- <<< size: 2811 -location: src/tests/client/test-client.py:test_004()/772 +location: src/tests/client/test-client.py:test_004()/774 cmd: $NMCLI --mode multiline --pretty -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: pl_PL.UTF-8 returncode: 0 @@ -43320,12 +43462,12 @@ connection.interface-name: -- ------------------------------------------------------------------------------- <<< -size: 6311 -location: src/tests/client/test-client.py:test_004()/773 +size: 6364 +location: src/tests/client/test-client.py:test_004()/775 cmd: $NMCLI --mode multiline --pretty --color yes con s con-vpn-1 lang: C returncode: 0 -stdout: 6138 bytes +stdout: 6191 bytes >>> =============================================================================== Connection profile details (con-vpn-1) @@ -43353,6 +43495,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -43449,12 +43592,12 @@ VPN.CFG[3]: key3 = val3 ------------------------------------------------------------------------------- <<< -size: 6353 -location: src/tests/client/test-client.py:test_004()/774 +size: 6406 +location: src/tests/client/test-client.py:test_004()/776 cmd: $NMCLI --mode multiline --pretty --color yes con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 6170 bytes +stdout: 6223 bytes >>> =============================================================================== Szczegóły profilu połączenia (con-vpn-1) @@ -43482,6 +43625,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -43578,12 +43722,12 @@ VPN.CFG[3]: key3 = val3 ------------------------------------------------------------------------------- <<< -size: 6311 -location: src/tests/client/test-client.py:test_004()/775 +size: 6364 +location: src/tests/client/test-client.py:test_004()/777 cmd: $NMCLI --mode multiline --pretty --color yes con s con-vpn-1 lang: C returncode: 0 -stdout: 6138 bytes +stdout: 6191 bytes >>> =============================================================================== Connection profile details (con-vpn-1) @@ -43611,6 +43755,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -43707,12 +43852,12 @@ VPN.CFG[3]: key3 = val3 ------------------------------------------------------------------------------- <<< -size: 6353 -location: src/tests/client/test-client.py:test_004()/776 +size: 6406 +location: src/tests/client/test-client.py:test_004()/778 cmd: $NMCLI --mode multiline --pretty --color yes con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 6170 bytes +stdout: 6223 bytes >>> =============================================================================== Szczegóły profilu połączenia (con-vpn-1) @@ -43740,6 +43885,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -43836,12 +43982,12 @@ VPN.CFG[3]: key3 = val3 ------------------------------------------------------------------------------- <<< -size: 4791 -location: src/tests/client/test-client.py:test_004()/777 +size: 4844 +location: src/tests/client/test-client.py:test_004()/779 cmd: $NMCLI --mode multiline --pretty --color yes -f ALL con s con-vpn-1 lang: C returncode: 0 -stdout: 4611 bytes +stdout: 4664 bytes >>> =============================================================================== Connection profile details (con-vpn-1) @@ -43869,6 +44015,7 @@ connection.metered: unknown connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -43939,12 +44086,12 @@ proxy.pac-script: -- ------------------------------------------------------------------------------- <<< -size: 4816 -location: src/tests/client/test-client.py:test_004()/778 +size: 4869 +location: src/tests/client/test-client.py:test_004()/780 cmd: $NMCLI --mode multiline --pretty --color yes -f ALL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 4626 bytes +stdout: 4679 bytes >>> =============================================================================== Szczegóły profilu połączenia (con-vpn-1) @@ -43972,6 +44119,7 @@ connection.metered: nieznane connection.lldp: default connection.mdns: -1 (default) connection.llmnr: -1 (default) +connection.dns-over-tls: -1 (default) connection.wait-device-timeout: -1 ------------------------------------------------------------------------------- ipv4.method: auto @@ -44043,7 +44191,7 @@ proxy.pac-script: -- <<< size: 812 -location: src/tests/client/test-client.py:test_004()/779 +location: src/tests/client/test-client.py:test_004()/781 cmd: $NMCLI --mode multiline --pretty --color yes -f VPN con s con-vpn-1 lang: C returncode: 0 @@ -44062,7 +44210,7 @@ vpn.timeout: 0 <<< size: 828 -location: src/tests/client/test-client.py:test_004()/780 +location: src/tests/client/test-client.py:test_004()/782 cmd: $NMCLI --mode multiline --pretty --color yes -f VPN con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -44081,7 +44229,7 @@ vpn.timeout: 0 <<< size: 1210 -location: src/tests/client/test-client.py:test_004()/781 +location: src/tests/client/test-client.py:test_004()/783 cmd: $NMCLI --mode multiline --pretty --color yes -f GENERAL con s con-vpn-1 lang: C returncode: 0 @@ -44107,7 +44255,7 @@ GENERAL.MASTER-PATH: -- <<< size: 1230 -location: src/tests/client/test-client.py:test_004()/782 +location: src/tests/client/test-client.py:test_004()/784 cmd: $NMCLI --mode multiline --pretty --color yes -f GENERAL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -44133,7 +44281,7 @@ GENERAL.MASTER-PATH: -- <<< size: 1877 -location: src/tests/client/test-client.py:test_004()/783 +location: src/tests/client/test-client.py:test_004()/785 cmd: $NMCLI --mode multiline --pretty --color yes dev s lang: C returncode: 0 @@ -44170,7 +44318,7 @@ CONNECTION: -- <<< size: 1893 -location: src/tests/client/test-client.py:test_004()/784 +location: src/tests/client/test-client.py:test_004()/786 cmd: $NMCLI --mode multiline --pretty --color yes dev s lang: pl_PL.UTF-8 returncode: 0 @@ -44207,7 +44355,7 @@ CONNECTION: -- <<< size: 3496 -location: src/tests/client/test-client.py:test_004()/785 +location: src/tests/client/test-client.py:test_004()/787 cmd: $NMCLI --mode multiline --pretty --color yes -f all dev status lang: C returncode: 0 @@ -44269,7 +44417,7 @@ CON-PATH: -- <<< size: 3522 -location: src/tests/client/test-client.py:test_004()/786 +location: src/tests/client/test-client.py:test_004()/788 cmd: $NMCLI --mode multiline --pretty --color yes -f all dev status lang: pl_PL.UTF-8 returncode: 0 @@ -44331,7 +44479,7 @@ CON-PATH: -- <<< size: 12897 -location: src/tests/client/test-client.py:test_004()/787 +location: src/tests/client/test-client.py:test_004()/789 cmd: $NMCLI --mode multiline --pretty --color yes dev show lang: C returncode: 0 @@ -44539,7 +44687,7 @@ IP6.DOMAIN[1]: sear6.fo.x.y <<< size: 12962 -location: src/tests/client/test-client.py:test_004()/788 +location: src/tests/client/test-client.py:test_004()/790 cmd: $NMCLI --mode multiline --pretty --color yes dev show lang: pl_PL.UTF-8 returncode: 0 @@ -44747,7 +44895,7 @@ IP6.DOMAIN[1]: sear6.fo.x.y <<< size: 27991 -location: src/tests/client/test-client.py:test_004()/789 +location: src/tests/client/test-client.py:test_004()/791 cmd: $NMCLI --mode multiline --pretty --color yes -f all dev show lang: C returncode: 0 @@ -45240,7 +45388,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 28192 -location: src/tests/client/test-client.py:test_004()/790 +location: src/tests/client/test-client.py:test_004()/792 cmd: $NMCLI --mode multiline --pretty --color yes -f all dev show lang: pl_PL.UTF-8 returncode: 0 @@ -45733,7 +45881,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 2465 -location: src/tests/client/test-client.py:test_004()/791 +location: src/tests/client/test-client.py:test_004()/793 cmd: $NMCLI --mode multiline --pretty --color yes dev show wlan0 lang: C returncode: 0 @@ -45778,7 +45926,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 2484 -location: src/tests/client/test-client.py:test_004()/792 +location: src/tests/client/test-client.py:test_004()/794 cmd: $NMCLI --mode multiline --pretty --color yes dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -45823,7 +45971,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 6859 -location: src/tests/client/test-client.py:test_004()/793 +location: src/tests/client/test-client.py:test_004()/795 cmd: $NMCLI --mode multiline --pretty --color yes -f all dev show wlan0 lang: C returncode: 0 @@ -45949,7 +46097,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 6927 -location: src/tests/client/test-client.py:test_004()/794 +location: src/tests/client/test-client.py:test_004()/796 cmd: $NMCLI --mode multiline --pretty --color yes -f all dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -46075,7 +46223,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 2661 -location: src/tests/client/test-client.py:test_004()/795 +location: src/tests/client/test-client.py:test_004()/797 cmd: $NMCLI --mode multiline --pretty --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -46130,7 +46278,7 @@ WIFI-PROPERTIES.IBSS-RSN: no <<< size: 2695 -location: src/tests/client/test-client.py:test_004()/796 +location: src/tests/client/test-client.py:test_004()/798 cmd: $NMCLI --mode multiline --pretty --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -46185,7 +46333,7 @@ WIFI-PROPERTIES.IBSS-RSN: nie <<< size: 2661 -location: src/tests/client/test-client.py:test_004()/797 +location: src/tests/client/test-client.py:test_004()/799 cmd: $NMCLI --mode multiline --pretty --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -46240,7 +46388,7 @@ WIFI-PROPERTIES.IBSS-RSN: no <<< size: 2695 -location: src/tests/client/test-client.py:test_004()/798 +location: src/tests/client/test-client.py:test_004()/800 cmd: $NMCLI --mode multiline --pretty --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -46295,7 +46443,7 @@ WIFI-PROPERTIES.IBSS-RSN: nie <<< size: 1789 -location: src/tests/client/test-client.py:test_004()/799 +location: src/tests/client/test-client.py:test_004()/801 cmd: $NMCLI --mode multiline --pretty --color yes -f DEVICE,TYPE,DBUS-PATH dev lang: C returncode: 0 @@ -46327,7 +46475,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Devi <<< size: 1799 -location: src/tests/client/test-client.py:test_004()/800 +location: src/tests/client/test-client.py:test_004()/802 cmd: $NMCLI --mode multiline --pretty --color yes -f DEVICE,TYPE,DBUS-PATH dev lang: pl_PL.UTF-8 returncode: 0 @@ -46359,7 +46507,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Devi <<< size: 5383 -location: src/tests/client/test-client.py:test_004()/801 +location: src/tests/client/test-client.py:test_004()/803 cmd: $NMCLI --mode multiline --pretty --color yes -f ALL device wifi list lang: C returncode: 0 @@ -46451,7 +46599,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Acc <<< size: 5459 -location: src/tests/client/test-client.py:test_004()/802 +location: src/tests/client/test-client.py:test_004()/804 cmd: $NMCLI --mode multiline --pretty --color yes -f ALL device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -46543,7 +46691,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Acc <<< size: 3164 -location: src/tests/client/test-client.py:test_004()/803 +location: src/tests/client/test-client.py:test_004()/805 cmd: $NMCLI --mode multiline --pretty --color yes -f COMMON device wifi list lang: C returncode: 0 @@ -46603,7 +46751,7 @@ SECURITY: WPA1 WPA2 <<< size: 3228 -location: src/tests/client/test-client.py:test_004()/804 +location: src/tests/client/test-client.py:test_004()/806 cmd: $NMCLI --mode multiline --pretty --color yes -f COMMON device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -46663,7 +46811,7 @@ SECURITY: WPA1 WPA2 <<< size: 5496 -location: src/tests/client/test-client.py:test_004()/805 +location: src/tests/client/test-client.py:test_004()/807 cmd: $NMCLI --mode multiline --pretty --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: C returncode: 0 @@ -46755,7 +46903,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Acc <<< size: 5572 -location: src/tests/client/test-client.py:test_004()/806 +location: src/tests/client/test-client.py:test_004()/808 cmd: $NMCLI --mode multiline --pretty --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -46847,7 +46995,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Acc <<< size: 1582 -location: src/tests/client/test-client.py:test_004()/807 +location: src/tests/client/test-client.py:test_004()/809 cmd: $NMCLI --mode multiline --pretty --color yes -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -46879,7 +47027,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Acc <<< size: 1610 -location: src/tests/client/test-client.py:test_004()/808 +location: src/tests/client/test-client.py:test_004()/810 cmd: $NMCLI --mode multiline --pretty --color yes -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -46911,7 +47059,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Acc <<< size: 1009 -location: src/tests/client/test-client.py:test_004()/809 +location: src/tests/client/test-client.py:test_004()/811 cmd: $NMCLI --mode multiline --pretty --color yes -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -46935,7 +47083,7 @@ SECURITY: WPA1 WPA2 <<< size: 1034 -location: src/tests/client/test-client.py:test_004()/810 +location: src/tests/client/test-client.py:test_004()/812 cmd: $NMCLI --mode multiline --pretty --color yes -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -46959,7 +47107,7 @@ SECURITY: WPA1 WPA2 <<< size: 1695 -location: src/tests/client/test-client.py:test_004()/811 +location: src/tests/client/test-client.py:test_004()/813 cmd: $NMCLI --mode multiline --pretty --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -46991,7 +47139,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Acc <<< size: 1723 -location: src/tests/client/test-client.py:test_004()/812 +location: src/tests/client/test-client.py:test_004()/814 cmd: $NMCLI --mode multiline --pretty --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -47023,7 +47171,7 @@ DBUS-PATH: /org/freedesktop/NetworkManager/Acc <<< size: 6862 -location: src/tests/client/test-client.py:test_004()/813 +location: src/tests/client/test-client.py:test_004()/815 cmd: $NMCLI --mode multiline --pretty --color yes -f ALL device show wlan0 lang: C returncode: 0 @@ -47149,7 +47297,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 6930 -location: src/tests/client/test-client.py:test_004()/814 +location: src/tests/client/test-client.py:test_004()/816 cmd: $NMCLI --mode multiline --pretty --color yes -f ALL device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -47275,7 +47423,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 2478 -location: src/tests/client/test-client.py:test_004()/815 +location: src/tests/client/test-client.py:test_004()/817 cmd: $NMCLI --mode multiline --pretty --color yes -f COMMON device show wlan0 lang: C returncode: 0 @@ -47320,7 +47468,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 2497 -location: src/tests/client/test-client.py:test_004()/816 +location: src/tests/client/test-client.py:test_004()/818 cmd: $NMCLI --mode multiline --pretty --color yes -f COMMON device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -47365,7 +47513,7 @@ IP6.DOMAIN[6]: sear6.foo4.bar <<< size: 6746 -location: src/tests/client/test-client.py:test_004()/817 +location: src/tests/client/test-client.py:test_004()/819 cmd: $NMCLI --mode multiline --pretty --color yes -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: C returncode: 0 @@ -47486,7 +47634,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 6812 -location: src/tests/client/test-client.py:test_004()/818 +location: src/tests/client/test-client.py:test_004()/820 cmd: $NMCLI --mode multiline --pretty --color yes -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -47607,7 +47755,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | c <<< size: 1925 -location: src/tests/client/test-client.py:test_004()/819 +location: src/tests/client/test-client.py:test_004()/821 cmd: $NMCLI --mode multiline --pretty --color yes dev lldp list ifname eth0 lang: C returncode: 0 @@ -47643,7 +47791,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES: 40 (wlan-access-point,telephone) <<< size: 1939 -location: src/tests/client/test-client.py:test_004()/820 +location: src/tests/client/test-client.py:test_004()/822 cmd: $NMCLI --mode multiline --pretty --color yes dev lldp list ifname eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -47679,7 +47827,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES: 40 (wlan-access-point,telephone) <<< size: 2798 -location: src/tests/client/test-client.py:test_004()/821 +location: src/tests/client/test-client.py:test_004()/823 cmd: $NMCLI --mode multiline --pretty --color yes -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: C returncode: 0 @@ -47725,7 +47873,7 @@ connection.interface-name: -- <<< size: 2823 -location: src/tests/client/test-client.py:test_004()/822 +location: src/tests/client/test-client.py:test_004()/824 cmd: $NMCLI --mode multiline --pretty --color yes -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: pl_PL.UTF-8 returncode: 0 @@ -47770,12 +47918,12 @@ connection.interface-name: -- ------------------------------------------------------------------------------- <<< -size: 2672 -location: src/tests/client/test-client.py:test_004()/823 +size: 2699 +location: src/tests/client/test-client.py:test_004()/825 cmd: $NMCLI --mode multiline --terse con s con-vpn-1 lang: C returncode: 0 -stdout: 2512 bytes +stdout: 2539 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -47800,6 +47948,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -47886,12 +48035,12 @@ VPN.CFG[2]:key2 = val2 VPN.CFG[3]:key3 = val3 <<< -size: 2682 -location: src/tests/client/test-client.py:test_004()/824 +size: 2709 +location: src/tests/client/test-client.py:test_004()/826 cmd: $NMCLI --mode multiline --terse con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 2512 bytes +stdout: 2539 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -47916,6 +48065,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -48002,12 +48152,12 @@ VPN.CFG[2]:key2 = val2 VPN.CFG[3]:key3 = val3 <<< -size: 2672 -location: src/tests/client/test-client.py:test_004()/825 +size: 2699 +location: src/tests/client/test-client.py:test_004()/827 cmd: $NMCLI --mode multiline --terse con s con-vpn-1 lang: C returncode: 0 -stdout: 2512 bytes +stdout: 2539 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -48032,6 +48182,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -48118,12 +48269,12 @@ VPN.CFG[2]:key2 = val2 VPN.CFG[3]:key3 = val3 <<< -size: 2682 -location: src/tests/client/test-client.py:test_004()/826 +size: 2709 +location: src/tests/client/test-client.py:test_004()/828 cmd: $NMCLI --mode multiline --terse con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 2512 bytes +stdout: 2539 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -48148,6 +48299,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -48234,12 +48386,12 @@ VPN.CFG[2]:key2 = val2 VPN.CFG[3]:key3 = val3 <<< -size: 2097 -location: src/tests/client/test-client.py:test_004()/827 +size: 2124 +location: src/tests/client/test-client.py:test_004()/829 cmd: $NMCLI --mode multiline --terse -f ALL con s con-vpn-1 lang: C returncode: 0 -stdout: 1930 bytes +stdout: 1957 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -48264,6 +48416,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -48329,12 +48482,12 @@ proxy.pac-url: proxy.pac-script: <<< -size: 2107 -location: src/tests/client/test-client.py:test_004()/828 +size: 2134 +location: src/tests/client/test-client.py:test_004()/830 cmd: $NMCLI --mode multiline --terse -f ALL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 1930 bytes +stdout: 1957 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -48359,6 +48512,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -48425,7 +48579,7 @@ proxy.pac-script: <<< size: 337 -location: src/tests/client/test-client.py:test_004()/829 +location: src/tests/client/test-client.py:test_004()/831 cmd: $NMCLI --mode multiline --terse -f VPN con s con-vpn-1 lang: C returncode: 0 @@ -48440,7 +48594,7 @@ vpn.timeout:0 <<< size: 347 -location: src/tests/client/test-client.py:test_004()/830 +location: src/tests/client/test-client.py:test_004()/832 cmd: $NMCLI --mode multiline --terse -f VPN con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -48455,7 +48609,7 @@ vpn.timeout:0 <<< size: 563 -location: src/tests/client/test-client.py:test_004()/831 +location: src/tests/client/test-client.py:test_004()/833 cmd: $NMCLI --mode multiline --terse -f GENERAL con s con-vpn-1 lang: C returncode: 0 @@ -48477,7 +48631,7 @@ GENERAL.MASTER-PATH: <<< size: 573 -location: src/tests/client/test-client.py:test_004()/832 +location: src/tests/client/test-client.py:test_004()/834 cmd: $NMCLI --mode multiline --terse -f GENERAL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -48499,7 +48653,7 @@ GENERAL.MASTER-PATH: <<< size: 427 -location: src/tests/client/test-client.py:test_004()/833 +location: src/tests/client/test-client.py:test_004()/835 cmd: $NMCLI --mode multiline --terse dev s lang: C returncode: 0 @@ -48528,7 +48682,7 @@ CONNECTION: <<< size: 437 -location: src/tests/client/test-client.py:test_004()/834 +location: src/tests/client/test-client.py:test_004()/836 cmd: $NMCLI --mode multiline --terse dev s lang: pl_PL.UTF-8 returncode: 0 @@ -48557,7 +48711,7 @@ CONNECTION: <<< size: 1135 -location: src/tests/client/test-client.py:test_004()/835 +location: src/tests/client/test-client.py:test_004()/837 cmd: $NMCLI --mode multiline --terse -f all dev status lang: C returncode: 0 @@ -48611,7 +48765,7 @@ CON-PATH: <<< size: 1145 -location: src/tests/client/test-client.py:test_004()/836 +location: src/tests/client/test-client.py:test_004()/838 cmd: $NMCLI --mode multiline --terse -f all dev status lang: pl_PL.UTF-8 returncode: 0 @@ -48665,7 +48819,7 @@ CON-PATH: <<< size: 4552 -location: src/tests/client/test-client.py:test_004()/837 +location: src/tests/client/test-client.py:test_004()/839 cmd: $NMCLI --mode multiline --terse dev show lang: C returncode: 0 @@ -48811,7 +48965,7 @@ IP6.DOMAIN[1]:sear6.fo.x.y <<< size: 4562 -location: src/tests/client/test-client.py:test_004()/838 +location: src/tests/client/test-client.py:test_004()/840 cmd: $NMCLI --mode multiline --terse dev show lang: pl_PL.UTF-8 returncode: 0 @@ -48957,7 +49111,7 @@ IP6.DOMAIN[1]:sear6.fo.x.y <<< size: 13138 -location: src/tests/client/test-client.py:test_004()/839 +location: src/tests/client/test-client.py:test_004()/841 cmd: $NMCLI --mode multiline --terse -f all dev show lang: C returncode: 0 @@ -49386,7 +49540,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 13184 -location: src/tests/client/test-client.py:test_004()/840 +location: src/tests/client/test-client.py:test_004()/842 cmd: $NMCLI --mode multiline --terse -f all dev show lang: pl_PL.UTF-8 returncode: 0 @@ -49815,7 +49969,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 896 -location: src/tests/client/test-client.py:test_004()/841 +location: src/tests/client/test-client.py:test_004()/843 cmd: $NMCLI --mode multiline --terse dev show wlan0 lang: C returncode: 0 @@ -49848,7 +50002,7 @@ IP6.DOMAIN[6]:sear6.foo4.bar <<< size: 906 -location: src/tests/client/test-client.py:test_004()/842 +location: src/tests/client/test-client.py:test_004()/844 cmd: $NMCLI --mode multiline --terse dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -49881,7 +50035,7 @@ IP6.DOMAIN[6]:sear6.foo4.bar <<< size: 3034 -location: src/tests/client/test-client.py:test_004()/843 +location: src/tests/client/test-client.py:test_004()/845 cmd: $NMCLI --mode multiline --terse -f all dev show wlan0 lang: C returncode: 0 @@ -49992,7 +50146,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 3071 -location: src/tests/client/test-client.py:test_004()/844 +location: src/tests/client/test-client.py:test_004()/846 cmd: $NMCLI --mode multiline --terse -f all dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -50103,7 +50257,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 1336 -location: src/tests/client/test-client.py:test_004()/845 +location: src/tests/client/test-client.py:test_004()/847 cmd: $NMCLI --mode multiline --terse -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -50152,7 +50306,7 @@ WIFI-PROPERTIES.IBSS-RSN:no <<< size: 1346 -location: src/tests/client/test-client.py:test_004()/846 +location: src/tests/client/test-client.py:test_004()/848 cmd: $NMCLI --mode multiline --terse -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -50201,7 +50355,7 @@ WIFI-PROPERTIES.IBSS-RSN:no <<< size: 1336 -location: src/tests/client/test-client.py:test_004()/847 +location: src/tests/client/test-client.py:test_004()/849 cmd: $NMCLI --mode multiline --terse -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -50250,7 +50404,7 @@ WIFI-PROPERTIES.IBSS-RSN:no <<< size: 1346 -location: src/tests/client/test-client.py:test_004()/848 +location: src/tests/client/test-client.py:test_004()/850 cmd: $NMCLI --mode multiline --terse -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -50299,7 +50453,7 @@ WIFI-PROPERTIES.IBSS-RSN:no <<< size: 553 -location: src/tests/client/test-client.py:test_004()/849 +location: src/tests/client/test-client.py:test_004()/851 cmd: $NMCLI --mode multiline --terse -f DEVICE,TYPE,DBUS-PATH dev lang: C returncode: 0 @@ -50323,7 +50477,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/Devices/5 <<< size: 563 -location: src/tests/client/test-client.py:test_004()/850 +location: src/tests/client/test-client.py:test_004()/852 cmd: $NMCLI --mode multiline --terse -f DEVICE,TYPE,DBUS-PATH dev lang: pl_PL.UTF-8 returncode: 0 @@ -50347,7 +50501,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/Devices/5 <<< size: 1550 -location: src/tests/client/test-client.py:test_004()/851 +location: src/tests/client/test-client.py:test_004()/853 cmd: $NMCLI --mode multiline --terse -f ALL device wifi list lang: C returncode: 0 @@ -50426,7 +50580,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/AccessPoint/4 <<< size: 1608 -location: src/tests/client/test-client.py:test_004()/852 +location: src/tests/client/test-client.py:test_004()/854 cmd: $NMCLI --mode multiline --terse -f ALL device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -50505,7 +50659,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/AccessPoint/4 <<< size: 646 -location: src/tests/client/test-client.py:test_004()/853 +location: src/tests/client/test-client.py:test_004()/855 cmd: $NMCLI --mode multiline --terse -f COMMON device wifi list lang: C returncode: 0 @@ -50552,7 +50706,7 @@ SECURITY:WPA1 WPA2 <<< size: 692 -location: src/tests/client/test-client.py:test_004()/854 +location: src/tests/client/test-client.py:test_004()/856 cmd: $NMCLI --mode multiline --terse -f COMMON device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -50599,7 +50753,7 @@ SECURITY:WPA1 WPA2 <<< size: 1663 -location: src/tests/client/test-client.py:test_004()/855 +location: src/tests/client/test-client.py:test_004()/857 cmd: $NMCLI --mode multiline --terse -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: C returncode: 0 @@ -50678,7 +50832,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/AccessPoint/4 <<< size: 1721 -location: src/tests/client/test-client.py:test_004()/856 +location: src/tests/client/test-client.py:test_004()/858 cmd: $NMCLI --mode multiline --terse -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -50757,7 +50911,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/AccessPoint/4 <<< size: 560 -location: src/tests/client/test-client.py:test_004()/857 +location: src/tests/client/test-client.py:test_004()/859 cmd: $NMCLI --mode multiline --terse -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -50785,7 +50939,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/AccessPoint/2 <<< size: 582 -location: src/tests/client/test-client.py:test_004()/858 +location: src/tests/client/test-client.py:test_004()/860 cmd: $NMCLI --mode multiline --terse -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -50813,7 +50967,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/AccessPoint/2 <<< size: 317 -location: src/tests/client/test-client.py:test_004()/859 +location: src/tests/client/test-client.py:test_004()/861 cmd: $NMCLI --mode multiline --terse -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -50833,7 +50987,7 @@ SECURITY:WPA1 WPA2 <<< size: 336 -location: src/tests/client/test-client.py:test_004()/860 +location: src/tests/client/test-client.py:test_004()/862 cmd: $NMCLI --mode multiline --terse -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -50853,7 +51007,7 @@ SECURITY:WPA1 WPA2 <<< size: 673 -location: src/tests/client/test-client.py:test_004()/861 +location: src/tests/client/test-client.py:test_004()/863 cmd: $NMCLI --mode multiline --terse -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -50881,7 +51035,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/AccessPoint/2 <<< size: 695 -location: src/tests/client/test-client.py:test_004()/862 +location: src/tests/client/test-client.py:test_004()/864 cmd: $NMCLI --mode multiline --terse -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -50909,7 +51063,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/AccessPoint/2 <<< size: 3037 -location: src/tests/client/test-client.py:test_004()/863 +location: src/tests/client/test-client.py:test_004()/865 cmd: $NMCLI --mode multiline --terse -f ALL device show wlan0 lang: C returncode: 0 @@ -51020,7 +51174,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 3074 -location: src/tests/client/test-client.py:test_004()/864 +location: src/tests/client/test-client.py:test_004()/866 cmd: $NMCLI --mode multiline --terse -f ALL device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -51131,7 +51285,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 909 -location: src/tests/client/test-client.py:test_004()/865 +location: src/tests/client/test-client.py:test_004()/867 cmd: $NMCLI --mode multiline --terse -f COMMON device show wlan0 lang: C returncode: 0 @@ -51164,7 +51318,7 @@ IP6.DOMAIN[6]:sear6.foo4.bar <<< size: 919 -location: src/tests/client/test-client.py:test_004()/866 +location: src/tests/client/test-client.py:test_004()/868 cmd: $NMCLI --mode multiline --terse -f COMMON device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -51197,7 +51351,7 @@ IP6.DOMAIN[6]:sear6.foo4.bar <<< size: 3069 -location: src/tests/client/test-client.py:test_004()/867 +location: src/tests/client/test-client.py:test_004()/869 cmd: $NMCLI --mode multiline --terse -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: C returncode: 0 @@ -51304,7 +51458,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 3106 -location: src/tests/client/test-client.py:test_004()/868 +location: src/tests/client/test-client.py:test_004()/870 cmd: $NMCLI --mode multiline --terse -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -51411,7 +51565,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 1151 -location: src/tests/client/test-client.py:test_004()/869 +location: src/tests/client/test-client.py:test_004()/871 cmd: $NMCLI --mode multiline --terse dev lldp list ifname eth0 lang: C returncode: 0 @@ -51441,7 +51595,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES:40 (wlan-access-point,telephone) <<< size: 1161 -location: src/tests/client/test-client.py:test_004()/870 +location: src/tests/client/test-client.py:test_004()/872 cmd: $NMCLI --mode multiline --terse dev lldp list ifname eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -51471,7 +51625,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES:40 (wlan-access-point,telephone) <<< size: 792 -location: src/tests/client/test-client.py:test_004()/871 +location: src/tests/client/test-client.py:test_004()/873 cmd: $NMCLI --mode multiline --terse -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: C returncode: 0 @@ -51495,7 +51649,7 @@ connection.interface-name: <<< size: 802 -location: src/tests/client/test-client.py:test_004()/872 +location: src/tests/client/test-client.py:test_004()/874 cmd: $NMCLI --mode multiline --terse -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: pl_PL.UTF-8 returncode: 0 @@ -51518,12 +51672,12 @@ connection.type:802-11-wireless connection.interface-name: <<< -size: 2684 -location: src/tests/client/test-client.py:test_004()/873 +size: 2711 +location: src/tests/client/test-client.py:test_004()/875 cmd: $NMCLI --mode multiline --terse --color yes con s con-vpn-1 lang: C returncode: 0 -stdout: 2512 bytes +stdout: 2539 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -51548,6 +51702,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -51634,12 +51789,12 @@ VPN.CFG[2]:key2 = val2 VPN.CFG[3]:key3 = val3 <<< -size: 2694 -location: src/tests/client/test-client.py:test_004()/874 +size: 2721 +location: src/tests/client/test-client.py:test_004()/876 cmd: $NMCLI --mode multiline --terse --color yes con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 2512 bytes +stdout: 2539 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -51664,6 +51819,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -51750,12 +51906,12 @@ VPN.CFG[2]:key2 = val2 VPN.CFG[3]:key3 = val3 <<< -size: 2684 -location: src/tests/client/test-client.py:test_004()/875 +size: 2711 +location: src/tests/client/test-client.py:test_004()/877 cmd: $NMCLI --mode multiline --terse --color yes con s con-vpn-1 lang: C returncode: 0 -stdout: 2512 bytes +stdout: 2539 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -51780,6 +51936,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -51866,12 +52023,12 @@ VPN.CFG[2]:key2 = val2 VPN.CFG[3]:key3 = val3 <<< -size: 2694 -location: src/tests/client/test-client.py:test_004()/876 +size: 2721 +location: src/tests/client/test-client.py:test_004()/878 cmd: $NMCLI --mode multiline --terse --color yes con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 2512 bytes +stdout: 2539 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -51896,6 +52053,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -51982,12 +52140,12 @@ VPN.CFG[2]:key2 = val2 VPN.CFG[3]:key3 = val3 <<< -size: 2109 -location: src/tests/client/test-client.py:test_004()/877 +size: 2136 +location: src/tests/client/test-client.py:test_004()/879 cmd: $NMCLI --mode multiline --terse --color yes -f ALL con s con-vpn-1 lang: C returncode: 0 -stdout: 1930 bytes +stdout: 1957 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -52012,6 +52170,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -52077,12 +52236,12 @@ proxy.pac-url: proxy.pac-script: <<< -size: 2119 -location: src/tests/client/test-client.py:test_004()/878 +size: 2146 +location: src/tests/client/test-client.py:test_004()/880 cmd: $NMCLI --mode multiline --terse --color yes -f ALL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 1930 bytes +stdout: 1957 bytes >>> connection.id:con-vpn-1 connection.uuid:UUID-con-vpn-1-REPLACED-REPLACED-REP @@ -52107,6 +52266,7 @@ connection.metered:unknown connection.lldp:default connection.mdns:-1 connection.llmnr:-1 +connection.dns-over-tls:-1 connection.wait-device-timeout:-1 ipv4.method:auto ipv4.dns: @@ -52173,7 +52333,7 @@ proxy.pac-script: <<< size: 349 -location: src/tests/client/test-client.py:test_004()/879 +location: src/tests/client/test-client.py:test_004()/881 cmd: $NMCLI --mode multiline --terse --color yes -f VPN con s con-vpn-1 lang: C returncode: 0 @@ -52188,7 +52348,7 @@ vpn.timeout:0 <<< size: 359 -location: src/tests/client/test-client.py:test_004()/880 +location: src/tests/client/test-client.py:test_004()/882 cmd: $NMCLI --mode multiline --terse --color yes -f VPN con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -52203,7 +52363,7 @@ vpn.timeout:0 <<< size: 575 -location: src/tests/client/test-client.py:test_004()/881 +location: src/tests/client/test-client.py:test_004()/883 cmd: $NMCLI --mode multiline --terse --color yes -f GENERAL con s con-vpn-1 lang: C returncode: 0 @@ -52225,7 +52385,7 @@ GENERAL.MASTER-PATH: <<< size: 585 -location: src/tests/client/test-client.py:test_004()/882 +location: src/tests/client/test-client.py:test_004()/884 cmd: $NMCLI --mode multiline --terse --color yes -f GENERAL con s con-vpn-1 lang: pl_PL.UTF-8 returncode: 0 @@ -52247,7 +52407,7 @@ GENERAL.MASTER-PATH: <<< size: 603 -location: src/tests/client/test-client.py:test_004()/883 +location: src/tests/client/test-client.py:test_004()/885 cmd: $NMCLI --mode multiline --terse --color yes dev s lang: C returncode: 0 @@ -52276,7 +52436,7 @@ CONNECTION: <<< size: 613 -location: src/tests/client/test-client.py:test_004()/884 +location: src/tests/client/test-client.py:test_004()/886 cmd: $NMCLI --mode multiline --terse --color yes dev s lang: pl_PL.UTF-8 returncode: 0 @@ -52305,7 +52465,7 @@ CONNECTION: <<< size: 1517 -location: src/tests/client/test-client.py:test_004()/885 +location: src/tests/client/test-client.py:test_004()/887 cmd: $NMCLI --mode multiline --terse --color yes -f all dev status lang: C returncode: 0 @@ -52359,7 +52519,7 @@ CON-PATH: <<< size: 1527 -location: src/tests/client/test-client.py:test_004()/886 +location: src/tests/client/test-client.py:test_004()/888 cmd: $NMCLI --mode multiline --terse --color yes -f all dev status lang: pl_PL.UTF-8 returncode: 0 @@ -52413,7 +52573,7 @@ CON-PATH: <<< size: 4564 -location: src/tests/client/test-client.py:test_004()/887 +location: src/tests/client/test-client.py:test_004()/889 cmd: $NMCLI --mode multiline --terse --color yes dev show lang: C returncode: 0 @@ -52559,7 +52719,7 @@ IP6.DOMAIN[1]:sear6.fo.x.y <<< size: 4574 -location: src/tests/client/test-client.py:test_004()/888 +location: src/tests/client/test-client.py:test_004()/890 cmd: $NMCLI --mode multiline --terse --color yes dev show lang: pl_PL.UTF-8 returncode: 0 @@ -52705,7 +52865,7 @@ IP6.DOMAIN[1]:sear6.fo.x.y <<< size: 13474 -location: src/tests/client/test-client.py:test_004()/889 +location: src/tests/client/test-client.py:test_004()/891 cmd: $NMCLI --mode multiline --terse --color yes -f all dev show lang: C returncode: 0 @@ -53134,7 +53294,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 13520 -location: src/tests/client/test-client.py:test_004()/890 +location: src/tests/client/test-client.py:test_004()/892 cmd: $NMCLI --mode multiline --terse --color yes -f all dev show lang: pl_PL.UTF-8 returncode: 0 @@ -53563,7 +53723,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 908 -location: src/tests/client/test-client.py:test_004()/891 +location: src/tests/client/test-client.py:test_004()/893 cmd: $NMCLI --mode multiline --terse --color yes dev show wlan0 lang: C returncode: 0 @@ -53596,7 +53756,7 @@ IP6.DOMAIN[6]:sear6.foo4.bar <<< size: 918 -location: src/tests/client/test-client.py:test_004()/892 +location: src/tests/client/test-client.py:test_004()/894 cmd: $NMCLI --mode multiline --terse --color yes dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -53629,7 +53789,7 @@ IP6.DOMAIN[6]:sear6.foo4.bar <<< size: 3289 -location: src/tests/client/test-client.py:test_004()/893 +location: src/tests/client/test-client.py:test_004()/895 cmd: $NMCLI --mode multiline --terse --color yes -f all dev show wlan0 lang: C returncode: 0 @@ -53740,7 +53900,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 3326 -location: src/tests/client/test-client.py:test_004()/894 +location: src/tests/client/test-client.py:test_004()/896 cmd: $NMCLI --mode multiline --terse --color yes -f all dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -53851,7 +54011,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 1348 -location: src/tests/client/test-client.py:test_004()/895 +location: src/tests/client/test-client.py:test_004()/897 cmd: $NMCLI --mode multiline --terse --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -53900,7 +54060,7 @@ WIFI-PROPERTIES.IBSS-RSN:no <<< size: 1358 -location: src/tests/client/test-client.py:test_004()/896 +location: src/tests/client/test-client.py:test_004()/898 cmd: $NMCLI --mode multiline --terse --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -53949,7 +54109,7 @@ WIFI-PROPERTIES.IBSS-RSN:no <<< size: 1348 -location: src/tests/client/test-client.py:test_004()/897 +location: src/tests/client/test-client.py:test_004()/899 cmd: $NMCLI --mode multiline --terse --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: C returncode: 0 @@ -53998,7 +54158,7 @@ WIFI-PROPERTIES.IBSS-RSN:no <<< size: 1358 -location: src/tests/client/test-client.py:test_004()/898 +location: src/tests/client/test-client.py:test_004()/900 cmd: $NMCLI --mode multiline --terse --color yes -f GENERAL,GENERAL.HWADDR,WIFI-PROPERTIES dev show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -54047,7 +54207,7 @@ WIFI-PROPERTIES.IBSS-RSN:no <<< size: 688 -location: src/tests/client/test-client.py:test_004()/899 +location: src/tests/client/test-client.py:test_004()/901 cmd: $NMCLI --mode multiline --terse --color yes -f DEVICE,TYPE,DBUS-PATH dev lang: C returncode: 0 @@ -54071,7 +54231,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/Devices/5 <<< size: 698 -location: src/tests/client/test-client.py:test_004()/900 +location: src/tests/client/test-client.py:test_004()/902 cmd: $NMCLI --mode multiline --terse --color yes -f DEVICE,TYPE,DBUS-PATH dev lang: pl_PL.UTF-8 returncode: 0 @@ -54095,7 +54255,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/Devices/5 <<< size: 2174 -location: src/tests/client/test-client.py:test_004()/901 +location: src/tests/client/test-client.py:test_004()/903 cmd: $NMCLI --mode multiline --terse --color yes -f ALL device wifi list lang: C returncode: 0 @@ -54174,7 +54334,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/AccessPoint/4 <<< size: 2232 -location: src/tests/client/test-client.py:test_004()/902 +location: src/tests/client/test-client.py:test_004()/904 cmd: $NMCLI --mode multiline --terse --color yes -f ALL device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -54253,7 +54413,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/AccessPoint/4 <<< size: 982 -location: src/tests/client/test-client.py:test_004()/903 +location: src/tests/client/test-client.py:test_004()/905 cmd: $NMCLI --mode multiline --terse --color yes -f COMMON device wifi list lang: C returncode: 0 @@ -54300,7 +54460,7 @@ SECURITY:WPA1 WPA2 <<< size: 1028 -location: src/tests/client/test-client.py:test_004()/904 +location: src/tests/client/test-client.py:test_004()/906 cmd: $NMCLI --mode multiline --terse --color yes -f COMMON device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -54347,7 +54507,7 @@ SECURITY:WPA1 WPA2 <<< size: 2287 -location: src/tests/client/test-client.py:test_004()/905 +location: src/tests/client/test-client.py:test_004()/907 cmd: $NMCLI --mode multiline --terse --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: C returncode: 0 @@ -54426,7 +54586,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/AccessPoint/4 <<< size: 2345 -location: src/tests/client/test-client.py:test_004()/906 +location: src/tests/client/test-client.py:test_004()/908 cmd: $NMCLI --mode multiline --terse --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list lang: pl_PL.UTF-8 returncode: 0 @@ -54505,7 +54665,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/AccessPoint/4 <<< size: 725 -location: src/tests/client/test-client.py:test_004()/907 +location: src/tests/client/test-client.py:test_004()/909 cmd: $NMCLI --mode multiline --terse --color yes -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -54533,7 +54693,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/AccessPoint/2 <<< size: 747 -location: src/tests/client/test-client.py:test_004()/908 +location: src/tests/client/test-client.py:test_004()/910 cmd: $NMCLI --mode multiline --terse --color yes -f ALL device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -54561,7 +54721,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/AccessPoint/2 <<< size: 410 -location: src/tests/client/test-client.py:test_004()/909 +location: src/tests/client/test-client.py:test_004()/911 cmd: $NMCLI --mode multiline --terse --color yes -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -54581,7 +54741,7 @@ SECURITY:WPA1 WPA2 <<< size: 429 -location: src/tests/client/test-client.py:test_004()/910 +location: src/tests/client/test-client.py:test_004()/912 cmd: $NMCLI --mode multiline --terse --color yes -f COMMON device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -54601,7 +54761,7 @@ SECURITY:WPA1 WPA2 <<< size: 838 -location: src/tests/client/test-client.py:test_004()/911 +location: src/tests/client/test-client.py:test_004()/913 cmd: $NMCLI --mode multiline --terse --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: C returncode: 0 @@ -54629,7 +54789,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/AccessPoint/2 <<< size: 860 -location: src/tests/client/test-client.py:test_004()/912 +location: src/tests/client/test-client.py:test_004()/914 cmd: $NMCLI --mode multiline --terse --color yes -f NAME,SSID,SSID-HEX,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,WPA-FLAGS,RSN-FLAGS,DEVICE,ACTIVE,IN-USE,DBUS-PATH device wifi list bssid C0:E2:BE:E8:EF:B6 lang: pl_PL.UTF-8 returncode: 0 @@ -54657,7 +54817,7 @@ DBUS-PATH:/org/freedesktop/NetworkManager/AccessPoint/2 <<< size: 3292 -location: src/tests/client/test-client.py:test_004()/913 +location: src/tests/client/test-client.py:test_004()/915 cmd: $NMCLI --mode multiline --terse --color yes -f ALL device show wlan0 lang: C returncode: 0 @@ -54768,7 +54928,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 3329 -location: src/tests/client/test-client.py:test_004()/914 +location: src/tests/client/test-client.py:test_004()/916 cmd: $NMCLI --mode multiline --terse --color yes -f ALL device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -54879,7 +55039,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 921 -location: src/tests/client/test-client.py:test_004()/915 +location: src/tests/client/test-client.py:test_004()/917 cmd: $NMCLI --mode multiline --terse --color yes -f COMMON device show wlan0 lang: C returncode: 0 @@ -54912,7 +55072,7 @@ IP6.DOMAIN[6]:sear6.foo4.bar <<< size: 931 -location: src/tests/client/test-client.py:test_004()/916 +location: src/tests/client/test-client.py:test_004()/918 cmd: $NMCLI --mode multiline --terse --color yes -f COMMON device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -54945,7 +55105,7 @@ IP6.DOMAIN[6]:sear6.foo4.bar <<< size: 3324 -location: src/tests/client/test-client.py:test_004()/917 +location: src/tests/client/test-client.py:test_004()/919 cmd: $NMCLI --mode multiline --terse --color yes -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: C returncode: 0 @@ -55052,7 +55212,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 3361 -location: src/tests/client/test-client.py:test_004()/918 +location: src/tests/client/test-client.py:test_004()/920 cmd: $NMCLI --mode multiline --terse --color yes -f GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4,DHCP4,IP6,DHCP6,BOND,TEAM,BRIDGE,VLAN,BLUETOOTH,CONNECTIONS device show wlan0 lang: pl_PL.UTF-8 returncode: 0 @@ -55159,7 +55319,7 @@ CONNECTIONS.AVAILABLE-CONNECTIONS[1]:UUID-con-xx1-REPLACED-REPLACED-REPLA | con- <<< size: 1163 -location: src/tests/client/test-client.py:test_004()/919 +location: src/tests/client/test-client.py:test_004()/921 cmd: $NMCLI --mode multiline --terse --color yes dev lldp list ifname eth0 lang: C returncode: 0 @@ -55189,7 +55349,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES:40 (wlan-access-point,telephone) <<< size: 1173 -location: src/tests/client/test-client.py:test_004()/920 +location: src/tests/client/test-client.py:test_004()/922 cmd: $NMCLI --mode multiline --terse --color yes dev lldp list ifname eth0 lang: pl_PL.UTF-8 returncode: 0 @@ -55219,7 +55379,7 @@ NEIGHBOR[2].SYSTEM-CAPABILITIES:40 (wlan-access-point,telephone) <<< size: 804 -location: src/tests/client/test-client.py:test_004()/921 +location: src/tests/client/test-client.py:test_004()/923 cmd: $NMCLI --mode multiline --terse --color yes -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: C returncode: 0 @@ -55243,7 +55403,7 @@ connection.interface-name: <<< size: 814 -location: src/tests/client/test-client.py:test_004()/922 +location: src/tests/client/test-client.py:test_004()/924 cmd: $NMCLI --mode multiline --terse --color yes -f connection.id,connection.uuid,connection.type,connection.interface-name,802-3-ethernet.mac-address,vpn.user-name connection show 5fcfd6d7-1e63-3332-8826-a7eda103792d UUID-con-vpn-1-REPLACED-REPLACED-REP UUID-con-xx1-REPLACED-REPLACED-REPLA lang: pl_PL.UTF-8 returncode: 0 diff --git a/src/tests/client/test-client.py b/src/tests/client/test-client.py index 97f1abd9..d025d12e 100755 --- a/src/tests/client/test-client.py +++ b/src/tests/client/test-client.py @@ -16,28 +16,33 @@ from __future__ import print_function # When adjusting the tests, or when making changes to nmcli that intentionally # change the output, the expected output must be regenerated. # -# $ make install -# # (step not required every time) -# # The test also compare the translated output, hence, the translation -# # file must be installed at the configured --prefix. -# # You don't need to type `make install` every time, but a suitable version -# # of translations must be installed. In practice, the tests only care about -# # Polish (pl) translations. -# # The important part is that translations work. Test -# # $ LANG=pl_PL.UTF-8 ./src/nmcli/nmcli --version -# # also ensure that `locale -a` reports the Polish locale. -# # -# # How to get that right depends on your distro. First check that -# # `LANG=pl_PL.UTF-8 /usr/bin/nmcli --version` gives you Polish output -# # and that it works in principle. -# # Then install NetworkManager in the configured prefix (make install) -# # and verify that ./src/nmcli/nmcli also gives you Polish. +# For that, you'd setup your system correctly (see below) and then simply: +# # $ NM_TEST_REGENERATE=1 make check-local-tests-client -# # Set NM_TEST_REGENERATE=1 to regenerate all files. +# # Or `NM_TEST_REGENERATE=1 make check -j 10` # $ git diff ... ; git add ... -# # (optional step) -# # Inspect what changed, and whether it makes sense. Then commit changes -# # to git. +# # The previous step regenerated the expected output. Review the changes +# # and consider whether they are correct. Then commit the changes to git. +# +# Setup: For regenerating the output, the translations must work. First: +# +# 1) LANG=pl_PL.UTF-8 /usr/bin/nmcli --version +# # Ensure that Polish output works for the system-installed nmcli. +# # If not, you should ensure that `locale -a` reports the Polish +# # locale. If that is not the case, how to enable the locale depends on +# # your distro. +# # +# # On Debian, you might do: +# # sed -i 's/^# \(pl_PL.UTF-8 .*\)$/\1/p' /etc/locale.gen +# # locale-gen pl_PL.UTF-8 +# +# 2) LANG=pl_PL.UTF-8 ./src/nmcli/nmcli --version +# # Ensure that the built nmcli has Polish locale working. If not, +# # you probably need to first `make install` the application at the +# # correct prefix. Take care to configure the build with the desired +# # prefix, like `./configure --prefix=/opt/tmp`. Usually, you want to avoid +# # using /usr as prefix, because that might overwrite files from your +# # package management system. # ############################################################################### # @@ -1367,6 +1372,8 @@ class TestNmcli(NmTestBase): dbus.UInt32(NM.ActiveConnectionState.DEACTIVATING), ) + self.call_nmcli_l([], replace_stdout=replace_uuids) + for i in [0, 1]: if i == 1: self.async_wait() @@ -1498,6 +1505,8 @@ class TestNmcli(NmTestBase): [c[1] for c in self.srv.findConnections()], replace_uuids ) + self.call_nmcli_l([], replace_stdout=replace_uuids) + for mode in Util.iter_nmcli_output_modes(): self.call_nmcli_l( -- cgit 1.3.0-6-gf8a5