mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 16:50:16 +01:00
platform: add change-flags argument to platform's link_wireguard_change()
We will need more flags. WireGuard internal tools solve this by embedding the change flags inside the structure that corresponds to NMPlatformLnkWireGuard. We don't do that, NMPlatformLnkWireGuard is only for containing the information about the link.
This commit is contained in:
parent
c3751a25a1
commit
2ed01e2e34
4 changed files with 21 additions and 11 deletions
|
|
@ -2372,7 +2372,7 @@ _wireguard_create_change_nlmsgs (NMPlatform *platform,
|
|||
const NMPlatformLnkWireGuard *lnk_wireguard,
|
||||
const NMPWireGuardPeer *peers,
|
||||
guint peers_len,
|
||||
gboolean replace_peers,
|
||||
NMPlatformWireGuardChangeFlags change_flags,
|
||||
GPtrArray **out_msgs)
|
||||
{
|
||||
gs_unref_ptrarray GPtrArray *msgs = NULL;
|
||||
|
|
@ -2422,8 +2422,11 @@ again:
|
|||
NLA_PUT_U16 (msg, WGDEVICE_A_LISTEN_PORT, lnk_wireguard->listen_port);
|
||||
NLA_PUT_U32 (msg, WGDEVICE_A_FWMARK, lnk_wireguard->fwmark);
|
||||
|
||||
NLA_PUT_U32 (msg, WGDEVICE_A_FLAGS,
|
||||
replace_peers ? WGDEVICE_F_REPLACE_PEERS : ((guint32) 0u));
|
||||
NLA_PUT_U32 (msg,
|
||||
WGDEVICE_A_FLAGS,
|
||||
NM_FLAGS_HAS (change_flags, NM_PLATFORM_WIREGUARD_CHANGE_FLAG_REPLACE_PEERS)
|
||||
? WGDEVICE_F_REPLACE_PEERS
|
||||
: ((guint32) 0u));
|
||||
}
|
||||
|
||||
if (peers_len == 0)
|
||||
|
|
@ -2554,7 +2557,7 @@ link_wireguard_change (NMPlatform *platform,
|
|||
const NMPlatformLnkWireGuard *lnk_wireguard,
|
||||
const NMPWireGuardPeer *peers,
|
||||
guint peers_len,
|
||||
gboolean replace_peers)
|
||||
NMPlatformWireGuardChangeFlags change_flags)
|
||||
{
|
||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||
gs_unref_ptrarray GPtrArray *msgs = NULL;
|
||||
|
|
@ -2572,7 +2575,7 @@ link_wireguard_change (NMPlatform *platform,
|
|||
lnk_wireguard,
|
||||
peers,
|
||||
peers_len,
|
||||
replace_peers,
|
||||
change_flags,
|
||||
&msgs);
|
||||
if (r < 0) {
|
||||
_LOGW ("wireguard: set-device, cannot construct netlink message: %s", nm_strerror (r));
|
||||
|
|
|
|||
|
|
@ -1996,7 +1996,7 @@ nm_platform_link_wireguard_change (NMPlatform *self,
|
|||
const NMPlatformLnkWireGuard *lnk_wireguard,
|
||||
const NMPWireGuardPeer *peers,
|
||||
guint peers_len,
|
||||
gboolean replace_peers)
|
||||
NMPlatformWireGuardChangeFlags change_flags)
|
||||
{
|
||||
_CHECK_SELF (self, klass, -NME_BUG);
|
||||
|
||||
|
|
@ -2027,7 +2027,9 @@ nm_platform_link_wireguard_change (NMPlatform *self,
|
|||
nm_platform_lnk_wireguard_to_string (lnk_wireguard, buf_lnk, sizeof (buf_lnk)),
|
||||
peers_len,
|
||||
buf_peers,
|
||||
replace_peers ? " (replace-peers)" : " (update-peers)");
|
||||
NM_FLAGS_HAS (change_flags, NM_PLATFORM_WIREGUARD_CHANGE_FLAG_REPLACE_PEERS)
|
||||
? " (replace-peers)"
|
||||
: " (update-peers)");
|
||||
}
|
||||
|
||||
return klass->link_wireguard_change (self,
|
||||
|
|
@ -2035,7 +2037,7 @@ nm_platform_link_wireguard_change (NMPlatform *self,
|
|||
lnk_wireguard,
|
||||
peers,
|
||||
peers_len,
|
||||
replace_peers);
|
||||
change_flags);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -753,6 +753,11 @@ typedef enum {
|
|||
NM_PLATFORM_KERNEL_SUPPORT_RTA_PREF = (1LL << 2),
|
||||
} NMPlatformKernelSupportFlags;
|
||||
|
||||
typedef enum {
|
||||
NM_PLATFORM_WIREGUARD_CHANGE_FLAG_NONE = 0,
|
||||
NM_PLATFORM_WIREGUARD_CHANGE_FLAG_REPLACE_PEERS = (1LL << 0),
|
||||
} NMPlatformWireGuardChangeFlags;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
struct _NMPlatformPrivate;
|
||||
|
|
@ -831,7 +836,7 @@ typedef struct {
|
|||
const NMPlatformLnkWireGuard *lnk_wireguard,
|
||||
const struct _NMPWireGuardPeer *peers,
|
||||
guint peers_len,
|
||||
gboolean replace_peers);
|
||||
NMPlatformWireGuardChangeFlags change_flags);
|
||||
|
||||
gboolean (*vlan_add) (NMPlatform *, const char *name, int parent, int vlanid, guint32 vlanflags, const NMPlatformLink **out_link);
|
||||
gboolean (*link_vlan_change) (NMPlatform *self,
|
||||
|
|
@ -1394,7 +1399,7 @@ int nm_platform_link_wireguard_change (NMPlatform *self,
|
|||
const NMPlatformLnkWireGuard *lnk_wireguard,
|
||||
const struct _NMPWireGuardPeer *peers,
|
||||
guint peers_len,
|
||||
gboolean replace_peers);
|
||||
NMPlatformWireGuardChangeFlags change_flags);
|
||||
|
||||
const NMPlatformIP6Address *nm_platform_ip6_address_get (NMPlatform *self, int ifindex, struct in6_addr address);
|
||||
|
||||
|
|
|
|||
|
|
@ -913,7 +913,7 @@ _test_wireguard_change (NMPlatform *platform,
|
|||
&lnk_wireguard,
|
||||
(const NMPWireGuardPeer *) peers->data,
|
||||
peers->len,
|
||||
TRUE);
|
||||
NM_PLATFORM_WIREGUARD_CHANGE_FLAG_REPLACE_PEERS);
|
||||
g_assert (NMTST_NM_ERR_SUCCESS (r));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue