diff options
| author | Michael Biebl <biebl@debian.org> | 2019-02-26 19:01:41 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2019-02-26 19:01:41 +0100 |
| commit | 964ae8cc391520440cf5aa13e2b9cc34850ea6c2 (patch) | |
| tree | 50da9ecaee7fbb612ec18f9e24f7dec215bf7861 /src/platform | |
| parent | 3626b425d1bc017fdc6f1ea0cfd329d1e1681641 (diff) | |
New upstream version 1.14.6 upstream/1.14.6
Diffstat (limited to 'src/platform')
| -rw-r--r-- | src/platform/nm-fake-platform.c | 1 | ||||
| -rw-r--r-- | src/platform/nm-linux-platform.c | 23 | ||||
| -rw-r--r-- | src/platform/nm-platform-utils.c | 1 | ||||
| -rw-r--r-- | src/platform/nm-platform.c | 49 | ||||
| -rw-r--r-- | src/platform/nm-platform.h | 21 | ||||
| -rw-r--r-- | src/platform/nmp-object.c | 1 | ||||
| -rw-r--r-- | src/platform/tests/test-common.c | 2 | ||||
| -rw-r--r-- | src/platform/tests/test-common.h | 3 | ||||
| -rw-r--r-- | src/platform/wifi/nm-wifi-utils-nl80211.c | 1 | ||||
| -rw-r--r-- | src/platform/wpan/nm-wpan-utils.c | 2 |
10 files changed, 67 insertions, 37 deletions
diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c index 82f9e2fb..ef69b391 100644 --- a/src/platform/nm-fake-platform.c +++ b/src/platform/nm-fake-platform.c @@ -26,6 +26,7 @@ #include <unistd.h> #include <netinet/icmp6.h> #include <netinet/in.h> +#include <linux/if.h> #include <linux/rtnetlink.h> #include "nm-utils.h" diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index e73d5d8c..c0224fff 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -2031,7 +2031,7 @@ _wireguard_update_from_peers_nla (CList *peers, } } if (tb[WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL]) - peer_c->data.persistent_keepalive_interval = nla_get_u64 (tb[WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL]); + peer_c->data.persistent_keepalive_interval = nla_get_u16 (tb[WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL]); if (tb[WGPEER_A_LAST_HANDSHAKE_TIME]) nla_memcpy (&peer_c->data.last_handshake_time, tb[WGPEER_A_LAST_HANDSHAKE_TIME], sizeof (peer_c->data.last_handshake_time)); if (tb[WGPEER_A_RX_BYTES]) @@ -5737,12 +5737,13 @@ static gboolean link_set_sriov_params (NMPlatform *platform, int ifindex, guint num_vfs, - int autoprobe) + NMTernary autoprobe) { nm_auto_pop_netns NMPNetns *netns = NULL; nm_auto_close int dirfd = -1; - gboolean current_autoprobe; - guint total, current_num; + int current_autoprobe; + guint total; + gint64 current_num; char ifname[IFNAMSIZ]; char buf[64]; @@ -5775,14 +5776,14 @@ link_set_sriov_params (NMPlatform *platform, NMP_SYSCTL_PATHID_NETDIR (dirfd, ifname, "device/sriov_numvfs"), - 10, 0, G_MAXUINT, 0); + 10, 0, G_MAXUINT, -1); current_autoprobe = nm_platform_sysctl_get_int_checked (platform, NMP_SYSCTL_PATHID_NETDIR (dirfd, ifname, "device/sriov_drivers_autoprobe"), - 10, 0, G_MAXUINT, 0); + 10, 0, 1, -1); if ( current_num == num_vfs - && (autoprobe == -1 || current_autoprobe == autoprobe)) + && (autoprobe == NM_TERNARY_DEFAULT || current_autoprobe == autoprobe)) return TRUE; if (current_num != 0) { @@ -5800,14 +5801,14 @@ link_set_sriov_params (NMPlatform *platform, if (num_vfs == 0) return TRUE; - if ( autoprobe >= 0 + if ( NM_IN_SET (autoprobe, NM_TERNARY_TRUE, NM_TERNARY_FALSE) && current_autoprobe != autoprobe && !nm_platform_sysctl_set (NM_PLATFORM_GET, NMP_SYSCTL_PATHID_NETDIR (dirfd, ifname, "device/sriov_drivers_autoprobe"), - nm_sprintf_buf (buf, "%d", autoprobe))) { - _LOGW ("link: couldn't set SR-IOV drivers-autoprobe to %d: %s", autoprobe, strerror (errno)); + nm_sprintf_buf (buf, "%d", (int) autoprobe))) { + _LOGW ("link: couldn't set SR-IOV drivers-autoprobe to %d: %s", (int) autoprobe, strerror (errno)); return FALSE; } @@ -7044,7 +7045,7 @@ ip6_address_add (NMPlatform *platform, ifindex, &addr, plen, - &peer_addr, + IN6_IS_ADDR_UNSPECIFIED (&peer_addr) ? NULL : &peer_addr, flags, RT_SCOPE_UNIVERSE, lifetime, diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c index 216b1547..cc43b27f 100644 --- a/src/platform/nm-platform-utils.c +++ b/src/platform/nm-platform-utils.c @@ -29,6 +29,7 @@ #include <linux/ethtool.h> #include <linux/sockios.h> #include <linux/mii.h> +#include <linux/if.h> #include <linux/version.h> #include <linux/rtnetlink.h> #include <fcntl.h> diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 7ddcf41a..757a0f43 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -31,6 +31,7 @@ #include <netdb.h> #include <string.h> #include <linux/ip.h> +#include <linux/if.h> #include <linux/if_tun.h> #include <linux/if_tunnel.h> #include <linux/rtnetlink.h> @@ -1192,13 +1193,29 @@ nm_platform_link_refresh (NMPlatform *self, int ifindex) return TRUE; } -static guint -_link_get_flags (NMPlatform *self, int ifindex) +int +nm_platform_link_get_ifi_flags (NMPlatform *self, + int ifindex, + guint requested_flags) { const NMPlatformLink *pllink; - pllink = nm_platform_link_get (self, ifindex); - return pllink ? pllink->n_ifi_flags : IFF_NOARP; + _CHECK_SELF (self, klass, -EINVAL); + + if (ifindex <= 0) + return -EINVAL; + + /* include invisible links (only in netlink, not udev). */ + pllink = NMP_OBJECT_CAST_LINK (nm_platform_link_get_obj (self, ifindex, FALSE)); + if (!pllink) + return -ENODEV; + + /* Errors are signaled as negative values. That means, you cannot request + * the most significant bit (2^31) with this API. Assert against that. */ + nm_assert ((int) requested_flags >= 0); + nm_assert (requested_flags < (guint) G_MAXINT); + + return (int) (pllink->n_ifi_flags & requested_flags); } /** @@ -1211,9 +1228,7 @@ _link_get_flags (NMPlatform *self, int ifindex) gboolean nm_platform_link_is_up (NMPlatform *self, int ifindex) { - _CHECK_SELF (self, klass, FALSE); - - return NM_FLAGS_HAS (_link_get_flags (self, ifindex), IFF_UP); + return nm_platform_link_get_ifi_flags (self, ifindex, IFF_UP) == IFF_UP; } /** @@ -1244,9 +1259,15 @@ nm_platform_link_is_connected (NMPlatform *self, int ifindex) gboolean nm_platform_link_uses_arp (NMPlatform *self, int ifindex) { - _CHECK_SELF (self, klass, FALSE); + int f; + + f = nm_platform_link_get_ifi_flags (self, ifindex, IFF_NOARP); - return !NM_FLAGS_HAS (_link_get_flags (self, ifindex), IFF_NOARP); + if (f < 0) + return FALSE; + if (f == IFF_NOARP) + return FALSE; + return TRUE; } /** @@ -1468,25 +1489,25 @@ nm_platform_link_supports_sriov (NMPlatform *self, int ifindex) * @self: platform instance * @ifindex: the index of the interface to change * @num_vfs: the number of VFs to create - * @autoprobe: -1 to keep the current autoprobe-drivers value, - * or {0,1} to set a new value + * @autoprobe: the new autoprobe-drivers value (pass + * %NM_TERNARY_DEFAULT to keep current value) */ gboolean nm_platform_link_set_sriov_params (NMPlatform *self, int ifindex, guint num_vfs, - int autoprobe) + NMTernary autoprobe) { _CHECK_SELF (self, klass, FALSE); g_return_val_if_fail (ifindex > 0, FALSE); - g_return_val_if_fail (NM_IN_SET (autoprobe, -1, 0, 1), FALSE); _LOGD ("link: setting %u total VFs and autoprobe %d for %s (%d)", num_vfs, - autoprobe, + (int) autoprobe, nm_strquote_a (25, nm_platform_link_get_name (self, ifindex)), ifindex); + return klass->link_set_sriov_params (self, ifindex, num_vfs, autoprobe); } diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 11495aff..7e91f1f3 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -21,12 +21,6 @@ #ifndef __NETWORKMANAGER_PLATFORM_H__ #define __NETWORKMANAGER_PLATFORM_H__ -#include <netinet/in.h> -#include <linux/if.h> -#include <linux/if_addr.h> -#include <linux/if_link.h> -#include <linux/ip6_tunnel.h> - #include "nm-dbus-interface.h" #include "nm-core-types-internal.h" @@ -53,6 +47,12 @@ /*****************************************************************************/ +/* IFNAMSIZ is both defined in <linux/if.h> and <net/if.h>. In the past, these + * headers conflicted, so we cannot simply include either of them in a header-file.*/ +#define NMP_IFNAMSIZ 16 + +/*****************************************************************************/ + struct udev_device; typedef gboolean (*NMPObjectPredicateFunc) (const NMPObject *obj, @@ -208,7 +208,7 @@ typedef enum { struct _NMPlatformLink { __NMPlatformObject_COMMON; - char name[IFNAMSIZ]; + char name[NMP_IFNAMSIZ]; NMLinkType type; /* rtnl_link_get_type(), IFLA_INFO_KIND. */ @@ -355,7 +355,7 @@ struct _NMPlatformIP4Address { * */ in_addr_t peer_address; /* PTP peer address */ - char label[IFNAMSIZ]; + char label[NMP_IFNAMSIZ]; }; /** @@ -1105,12 +1105,12 @@ const char *nm_platform_error_to_string (NMPlatformError error, ((const char *) NULL), -1, (path) #define NMP_SYSCTL_PATHID_NETDIR_unsafe(dirfd, ifname, path) \ - nm_sprintf_bufa (NM_STRLEN ("net:/sys/class/net//\0") + IFNAMSIZ + strlen (path), \ + nm_sprintf_bufa (NM_STRLEN ("net:/sys/class/net//\0") + NMP_IFNAMSIZ + strlen (path), \ "net:/sys/class/net/%s/%s", (ifname), (path)), \ (dirfd), (path) #define NMP_SYSCTL_PATHID_NETDIR(dirfd, ifname, path) \ - nm_sprintf_bufa (NM_STRLEN ("net:/sys/class/net//"path"/\0") + IFNAMSIZ, \ + nm_sprintf_bufa (NM_STRLEN ("net:/sys/class/net//"path"/\0") + NMP_IFNAMSIZ, \ "net:/sys/class/net/%s/%s", (ifname), path), \ (dirfd), (""path"") @@ -1165,6 +1165,7 @@ int nm_platform_link_get_ifindex (NMPlatform *self, const char *name); const char *nm_platform_link_get_name (NMPlatform *self, int ifindex); NMLinkType nm_platform_link_get_type (NMPlatform *self, int ifindex); gboolean nm_platform_link_is_software (NMPlatform *self, int ifindex); +int nm_platform_link_get_ifi_flags (NMPlatform *self, int ifindex, guint requested_flags); 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); diff --git a/src/platform/nmp-object.c b/src/platform/nmp-object.c index fdc27440..f7fa6cb3 100644 --- a/src/platform/nmp-object.c +++ b/src/platform/nmp-object.c @@ -24,6 +24,7 @@ #include <unistd.h> #include <linux/rtnetlink.h> +#include <linux/if.h> #include <libudev.h> #include "nm-utils.h" diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c index 3dedbd10..1cb2f516 100644 --- a/src/platform/tests/test-common.c +++ b/src/platform/tests/test-common.c @@ -787,8 +787,6 @@ nmtstp_ip_address_assert_lifetime (const NMPlatformIPAddress *addr, if (lft == NM_PLATFORM_LIFETIME_PERMANENT) g_assert_cmpint (adr, ==, NM_PLATFORM_LIFETIME_PERMANENT); else { - g_assert_cmpint (adr, <=, lft); - g_assert_cmpint (offset, <=, adr); g_assert_cmpint (adr - offset, <=, lft + CHECK_LIFETIME_MAX_DIFF); g_assert_cmpint (adr - offset, >=, lft - CHECK_LIFETIME_MAX_DIFF); } diff --git a/src/platform/tests/test-common.h b/src/platform/tests/test-common.h index 1baadfa1..7e81baea 100644 --- a/src/platform/tests/test-common.h +++ b/src/platform/tests/test-common.h @@ -21,6 +21,9 @@ #include <syslog.h> #include <string.h> #include <arpa/inet.h> +#include <linux/if.h> +#include <linux/if_link.h> +#include <linux/ip6_tunnel.h> #include "platform/nm-platform.h" #include "platform/nmp-object.h" diff --git a/src/platform/wifi/nm-wifi-utils-nl80211.c b/src/platform/wifi/nm-wifi-utils-nl80211.c index b3bb2bb6..39e3f971 100644 --- a/src/platform/wifi/nm-wifi-utils-nl80211.c +++ b/src/platform/wifi/nm-wifi-utils-nl80211.c @@ -30,6 +30,7 @@ #include <net/ethernet.h> #include <unistd.h> #include <linux/nl80211.h> +#include <linux/if.h> #include "platform/nm-netlink.h" #include "nm-wifi-utils-private.h" diff --git a/src/platform/wpan/nm-wpan-utils.c b/src/platform/wpan/nm-wpan-utils.c index 0544539a..882c4eec 100644 --- a/src/platform/wpan/nm-wpan-utils.c +++ b/src/platform/wpan/nm-wpan-utils.c @@ -21,6 +21,8 @@ #include "nm-wpan-utils.h" +#include <linux/if.h> + #include "platform/linux/nl802154.h" #include "platform/nm-netlink.h" |