mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-25 12:00:39 +02:00
all: pass pointer to "struct NMUtilsIPv6IfaceId" to functions instead of struct
While NMUtilsIPv6IfaceId is only 8 bytes large, it seems unidiomatic to pass the plain struct around. With a "const NMUtilsIPv6IfaceId *" argument it is more clear what the meaning of this is. Change to use pointers.
This commit is contained in:
parent
bcd2c99aab
commit
4b6e119010
7 changed files with 25 additions and 26 deletions
|
|
@ -2745,7 +2745,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;
|
||||
|
|
@ -2761,7 +2761,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;
|
||||
}
|
||||
|
|
@ -7346,7 +7346,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);
|
||||
}
|
||||
}
|
||||
|
|
@ -9259,7 +9259,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -10360,7 +10360,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";
|
||||
}
|
||||
|
||||
|
|
@ -16050,7 +16050,7 @@ 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);
|
||||
|
|
|
|||
|
|
@ -498,7 +498,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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -140,9 +140,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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -198,8 +198,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,
|
||||
|
|
|
|||
|
|
@ -371,8 +371,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);
|
||||
|
|
@ -380,7 +380,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,
|
||||
|
|
|
|||
|
|
@ -4068,7 +4068,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;
|
||||
|
|
@ -4086,11 +4086,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);
|
||||
}
|
||||
|
||||
|
|
@ -7487,7 +7485,7 @@ link_set_inet6_addr_gen_mode(NMPlatform *platform, int ifindex, guint8 mode)
|
|||
}
|
||||
|
||||
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];
|
||||
|
|
@ -7497,7 +7495,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);
|
||||
|
|
|
|||
|
|
@ -1600,7 +1600,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);
|
||||
|
||||
|
|
@ -5602,7 +5602,7 @@ nm_platform_link_to_string(const NMPlatformLink *link, char *buf, gsize len)
|
|||
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 ?: "",
|
||||
|
|
|
|||
|
|
@ -1111,7 +1111,7 @@ typedef struct {
|
|||
unsigned flags_set);
|
||||
|
||||
int (*link_set_inet6_addr_gen_mode)(NMPlatform *self, int ifindex, guint8 enabled);
|
||||
gboolean (*link_set_token)(NMPlatform *self, int ifindex, NMUtilsIPv6IfaceId iid);
|
||||
gboolean (*link_set_token)(NMPlatform *self, int ifindex, const NMUtilsIPv6IfaceId *iid);
|
||||
|
||||
gboolean (*link_get_permanent_address_ethtool)(NMPlatform * self,
|
||||
int ifindex,
|
||||
|
|
@ -1870,8 +1870,9 @@ 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_inet6_addr_gen_mode(NMPlatform *self, int ifindex, guint8 mode);
|
||||
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_set_ipv6_token(NMPlatform *self, int ifindex, const NMUtilsIPv6IfaceId *iid);
|
||||
|
||||
gboolean nm_platform_link_get_permanent_address_ethtool(NMPlatform * self,
|
||||
int ifindex,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue