about summary refs log tree commit diff
path: root/src/libnm-platform/nm-platform.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnm-platform/nm-platform.h')
-rw-r--r--src/libnm-platform/nm-platform.h110
1 files changed, 74 insertions, 36 deletions
diff --git a/src/libnm-platform/nm-platform.h b/src/libnm-platform/nm-platform.h
index aeea5c42..996f84b8 100644
--- a/src/libnm-platform/nm-platform.h
+++ b/src/libnm-platform/nm-platform.h
@@ -175,8 +175,15 @@ typedef struct {
     bool    prio_has : 1;
 } NMPlatformLinkBondPort;
 
+typedef struct {
+    guint32 path_cost;
+    guint16 priority;
+    bool    hairpin;
+} NMPlatformLinkBridgePort;
+
 typedef union {
-    NMPlatformLinkBondPort bond;
+    NMPlatformLinkBondPort   bond;
+    NMPlatformLinkBridgePort bridge;
 } NMPlatformLinkPortData;
 
 struct _NMPlatformLink {
@@ -437,18 +444,27 @@ struct _NMPlatformIP4Route {
      * pref_src must match, unless set to 0.0.0.0 to match any. */
     in_addr_t pref_src;
 
-    /* This is the weight of for the first next-hop, in case of n_nexthops > 1.
+    /* This is the weight of for the first next-hop.
      *
-     * If n_nexthops is zero, this value is undefined (should be zero).
-     * If n_nexthops is 1, this also doesn't matter, but it's usually set to
-     * zero.
-     * If n_nexthops is greater or equal to one, this is the weight of
-     * the first hop.
+     * For multi-hop routes (n_nexthops > 1) this is the weight of the first
+     * hop. Note that the valid range is from 1-256. Zero is treated the same
+     * as 1 (for NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID comparison).
      *
-     * Note that upper layers (nm_utils_ip_route_attribute_to_platform()) use this flag to indicate
-     * whether this is a multihop route. Single-hop, non-ECMP routes will have a weight of zero.
+     * For routes without next-hop (e.g. blackhole type), the weight is
+     * meaningless. It should be set to zero. NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID
+     * will treat it as zero.
      *
-     * The valid range for weight in kernel is 1-256. */
+     * For single-hop routes, in kernel they don't have a weight. That means,
+     * all routes in the platform cache have a weight of zero. For tracking
+     * purposes, we find it useful that upper layers have single-hop routes
+     * with a positive weight. Such routes can never exist in kernel. Trying
+     * to add such a route will somewhat work, because
+     * nm_platform_ip_route_normalize() normalizes the weight to zero
+     * (effectively adding another route, according to
+     * NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID). A lookup in the platform cache with
+     * such a route will not yield a result. It does not exist there. If you
+     * want to find such a route, normalize it first.
+     */
     guint16 weight;
 
     /* rtm_tos (iproute2: tos)
@@ -697,13 +713,11 @@ typedef struct {
 typedef struct {
     int       ifindex;
     in_addr_t gateway;
-    /* The valid range for weight is 1-256. Single hop routes in kernel
-     * don't have a weight, we assign them weight zero (to indicate the
-     * weight is missing).
+
+    /* The weight of the next hop. The valid range for weight is 1-256.
      *
-     * Upper layers (nm_utils_ip_route_attribute_to_platform()) care about
-     * the distinction of unset weight (no-ECMP). They express no-ECMP as
-     * zero.
+     * Zero is allowed too, but treated as 1 (by
+     * NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID comparison).
      */
     guint16 weight;
 
@@ -829,6 +843,14 @@ typedef struct {
 } _nm_alignas(NMPlatformObject) NMPlatformLnkGre;
 
 typedef struct {
+    int         port1;
+    int         port2;
+    NMEtherAddr supervision_address;
+    guint8      multicast_spec;
+    bool        prp : 1;
+} _nm_alignas(NMPlatformObject) NMPlatformLnkHsr;
+
+typedef struct {
     int         p_key;
     const char *mode;
 } _nm_alignas(NMPlatformObject) NMPlatformLnkInfiniband;
@@ -1009,14 +1031,6 @@ typedef struct {
 
 /*****************************************************************************/
 
-typedef struct _NMPlatformCsmeConnInfo {
-    guint8      ssid[32];
-    guint32     channel;
-    NMEtherAddr addr;
-    guint8      sta_cipher;
-    guint8      auth_mode;
-} NMPlatformCsmeConnInfo;
-
 typedef enum {
     NM_PLATFORM_KERNEL_SUPPORT_TYPE_FRA_L3MDEV,
     NM_PLATFORM_KERNEL_SUPPORT_TYPE_FRA_UID_RANGE,
@@ -1242,10 +1256,6 @@ typedef struct {
     gboolean (*wifi_set_wake_on_wlan)(NMPlatform                  *self,
                                       int                          ifindex,
                                       _NMSettingWirelessWakeOnWLan wowl);
-    gboolean (*wifi_get_csme_conn_info)(NMPlatform             *self,
-                                        int                     ifindex,
-                                        NMPlatformCsmeConnInfo *out_conn_info);
-    gboolean (*wifi_get_device_from_csme)(NMPlatform *self, int ifindex);
 
     guint32 (*mesh_get_channel)(NMPlatform *self, int ifindex);
     gboolean (*mesh_set_channel)(NMPlatform *self, int ifindex, guint32 channel);
@@ -1641,7 +1651,7 @@ const NMPlatformLink *nm_platform_link_get_by_address(NMPlatform   *self,
                                                       gconstpointer address,
                                                       size_t        length);
 
-GPtrArray *nm_platform_link_get_all(NMPlatform *self, gboolean sort_by_name);
+GPtrArray *nm_platform_link_get_all(NMPlatform *self);
 
 int nm_platform_link_add(NMPlatform            *self,
                          NMLinkType             type,
@@ -1748,6 +1758,17 @@ nm_platform_link_gre_add(NMPlatform             *self,
 }
 
 static inline int
+nm_platform_link_hsr_add(NMPlatform             *self,
+                         const char             *name,
+                         const NMPlatformLnkHsr *props,
+                         const NMPlatformLink  **out_link)
+{
+    g_return_val_if_fail(props, -NME_BUG);
+
+    return nm_platform_link_add(self, NM_LINK_TYPE_HSR, name, 0, NULL, 0, 0, props, out_link);
+}
+
+static inline int
 nm_platform_link_sit_add(NMPlatform             *self,
                          const char             *name,
                          const NMPlatformLnkSit *props,
@@ -1946,9 +1967,9 @@ int nm_platform_link_get_master(NMPlatform *self, int slave);
 
 gboolean nm_platform_link_can_assume(NMPlatform *self, int ifindex);
 
-gboolean    nm_platform_link_get_unmanaged(NMPlatform *self, int ifindex, gboolean *unmanaged);
-gboolean    nm_platform_link_supports_slaves(NMPlatform *self, int ifindex);
-const char *nm_platform_link_get_type_name(NMPlatform *self, int ifindex);
+NMOptionBool nm_platform_link_get_unmanaged(NMPlatform *self, int ifindex);
+gboolean     nm_platform_link_supports_slaves(NMPlatform *self, int ifindex);
+const char  *nm_platform_link_get_type_name(NMPlatform *self, int ifindex);
 
 gboolean nm_platform_link_refresh(NMPlatform *self, int ifindex);
 void     nm_platform_process_events(NMPlatform *self);
@@ -1983,6 +2004,7 @@ gboolean nm_platform_link_change(NMPlatform               *self,
                                  int                       ifindex,
                                  NMPlatformLinkProps      *props,
                                  NMPlatformLinkBondPort   *bond_port,
+                                 NMPlatformLinkBridgePort *bridge_port,
                                  NMPlatformLinkChangeFlags flags);
 
 gboolean    nm_platform_link_get_udev_property(NMPlatform  *self,
@@ -2065,6 +2087,8 @@ const NMPlatformLnkGre *
 nm_platform_link_get_lnk_gre(NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
 const NMPlatformLnkGre *
 nm_platform_link_get_lnk_gretap(NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
+const NMPlatformLnkHsr *
+nm_platform_link_get_lnk_hsr(NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
 const NMPlatformLnkIp6Tnl *
 nm_platform_link_get_lnk_ip6tnl(NMPlatform *self, int ifindex, const NMPlatformLink **out_link);
 const NMPlatformLnkIp6Tnl *
@@ -2146,10 +2170,6 @@ void nm_platform_wifi_indicate_addressing_running(NMPlatform *self, int ifindex,
 _NMSettingWirelessWakeOnWLan nm_platform_wifi_get_wake_on_wlan(NMPlatform *self, int ifindex);
 gboolean
 nm_platform_wifi_set_wake_on_wlan(NMPlatform *self, int ifindex, _NMSettingWirelessWakeOnWLan wowl);
-gboolean nm_platform_wifi_get_csme_conn_info(NMPlatform             *self,
-                                             int                     ifindex,
-                                             NMPlatformCsmeConnInfo *out_conn_info);
-gboolean nm_platform_wifi_get_device_from_csme(NMPlatform *self, int ifindex);
 
 guint32  nm_platform_mesh_get_channel(NMPlatform *self, int ifindex);
 gboolean nm_platform_mesh_set_channel(NMPlatform *self, int ifindex, guint32 channel);
@@ -2391,6 +2411,7 @@ const char *nm_platform_link_to_string(const NMPlatformLink *link, char *buf, gs
 const char *nm_platform_lnk_bond_to_string(const NMPlatformLnkBond *lnk, char *buf, gsize len);
 const char *nm_platform_lnk_bridge_to_string(const NMPlatformLnkBridge *lnk, char *buf, gsize len);
 const char *nm_platform_lnk_gre_to_string(const NMPlatformLnkGre *lnk, char *buf, gsize len);
+const char *nm_platform_lnk_hsr_to_string(const NMPlatformLnkHsr *lnk, char *buf, gsize len);
 const char *
 nm_platform_lnk_infiniband_to_string(const NMPlatformLnkInfiniband *lnk, char *buf, gsize len);
 const char *nm_platform_lnk_ip6tnl_to_string(const NMPlatformLnkIp6Tnl *lnk, char *buf, gsize len);
@@ -2444,6 +2465,7 @@ int nm_platform_link_cmp(const NMPlatformLink *a, const NMPlatformLink *b);
 int nm_platform_lnk_bond_cmp(const NMPlatformLnkBond *a, const NMPlatformLnkBond *b);
 int nm_platform_lnk_bridge_cmp(const NMPlatformLnkBridge *a, const NMPlatformLnkBridge *b);
 int nm_platform_lnk_gre_cmp(const NMPlatformLnkGre *a, const NMPlatformLnkGre *b);
+int nm_platform_lnk_hsr_cmp(const NMPlatformLnkHsr *a, const NMPlatformLnkHsr *b);
 int nm_platform_lnk_infiniband_cmp(const NMPlatformLnkInfiniband *a,
                                    const NMPlatformLnkInfiniband *b);
 int nm_platform_lnk_ip6tnl_cmp(const NMPlatformLnkIp6Tnl *a, const NMPlatformLnkIp6Tnl *b);
@@ -2484,8 +2506,11 @@ int nm_platform_mptcp_addr_cmp(const NMPlatformMptcpAddr *a, const NMPlatformMpt
 
 void nm_platform_link_hash_update(const NMPlatformLink *obj, NMHashState *h);
 void nm_platform_link_bond_port_hash_update(const NMPlatformLinkBondPort *obj, NMHashState *h);
+void nm_platform_link_bridge_port_hash_update(const NMPlatformLinkBridgePort *obj, NMHashState *h);
 int  nm_platform_link_bond_port_cmp(const NMPlatformLinkBondPort *a,
                                     const NMPlatformLinkBondPort *b);
+int  nm_platform_link_bridge_port_cmp(const NMPlatformLinkBridgePort *a,
+                                      const NMPlatformLinkBridgePort *b);
 void nm_platform_ip4_route_hash_update(const NMPlatformIP4Route *obj,
                                        NMPlatformIPRouteCmpType  cmp_type,
                                        NMHashState              *h);
@@ -2512,6 +2537,7 @@ void nm_platform_routing_rule_hash_update(const NMPlatformRoutingRule *obj,
 void nm_platform_lnk_bond_hash_update(const NMPlatformLnkBond *obj, NMHashState *h);
 void nm_platform_lnk_bridge_hash_update(const NMPlatformLnkBridge *obj, NMHashState *h);
 void nm_platform_lnk_gre_hash_update(const NMPlatformLnkGre *obj, NMHashState *h);
+void nm_platform_lnk_hsr_hash_update(const NMPlatformLnkHsr *obj, NMHashState *h);
 void nm_platform_lnk_infiniband_hash_update(const NMPlatformLnkInfiniband *obj, NMHashState *h);
 void nm_platform_lnk_ip6tnl_hash_update(const NMPlatformLnkIp6Tnl *obj, NMHashState *h);
 void nm_platform_lnk_ipip_hash_update(const NMPlatformLnkIpIp *obj, NMHashState *h);
@@ -2572,12 +2598,24 @@ gboolean nm_platform_ethtool_get_link_ring(NMPlatform *self, int ifindex, NMEtht
 gboolean
 nm_platform_ethtool_set_ring(NMPlatform *self, int ifindex, const NMEthtoolRingState *ring);
 
+gboolean nm_platform_ethtool_get_link_channels(NMPlatform             *self,
+                                               int                     ifindex,
+                                               NMEthtoolChannelsState *channels);
+
+gboolean nm_platform_ethtool_set_channels(NMPlatform                   *self,
+                                          int                           ifindex,
+                                          const NMEthtoolChannelsState *channels);
+
 gboolean
 nm_platform_ethtool_get_link_pause(NMPlatform *self, int ifindex, NMEthtoolPauseState *pause);
 
+gboolean nm_platform_ethtool_get_link_eee(NMPlatform *self, int ifindex, NMEthtoolEEEState *eee);
+
 gboolean
 nm_platform_ethtool_set_pause(NMPlatform *self, int ifindex, const NMEthtoolPauseState *pause);
 
+gboolean nm_platform_ethtool_set_eee(NMPlatform *self, int ifindex, const NMEthtoolEEEState *eee);
+
 void nm_platform_ip4_dev_route_blacklist_set(NMPlatform *self,
                                              int         ifindex,
                                              GPtrArray  *ip4_dev_route_blacklist);