summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-06-21 22:01:24 +0200
committerThomas Haller <thaller@redhat.com>2022-06-23 20:36:53 +0200
commit59f577df561657ae062d7573137a2d9637bf9cfc (patch)
tree4c6b7446e2ea03e43432c6bfd57bf43d9992db72
parent80afc691d54b3d8a22e129e598320bba07af92e5 (diff)
platform/netlink: add const modifier to netlink header pointers
They are not supposed to be modified.
-rw-r--r--src/libnm-platform/nm-linux-platform.c20
-rw-r--r--src/libnm-platform/nm-netlink.c2
-rw-r--r--src/libnm-platform/nm-netlink.h2
3 files changed, 12 insertions, 12 deletions
diff --git a/src/libnm-platform/nm-linux-platform.c b/src/libnm-platform/nm-linux-platform.c
index e7f773cd8a..3c7f381748 100644
--- a/src/libnm-platform/nm-linux-platform.c
+++ b/src/libnm-platform/nm-linux-platform.c
@@ -2924,10 +2924,10 @@ _nmp_link_address_set(NMPLinkAddress *dst, const struct nlattr *nla)
/* Copied and heavily modified from libnl3's link_msg_parser(). */
static NMPObject *
-_new_from_nl_link(NMPlatform *platform,
- const NMPCache *cache,
- struct nlmsghdr *nlh,
- gboolean id_only)
+_new_from_nl_link(NMPlatform *platform,
+ const NMPCache *cache,
+ const struct nlmsghdr *nlh,
+ gboolean id_only)
{
static const struct nla_policy policy[] = {
[IFLA_IFNAME] = {.type = NLA_STRING, .maxlen = IFNAMSIZ},
@@ -3275,7 +3275,7 @@ _new_from_nl_link(NMPlatform *platform,
/* Copied and heavily modified from libnl3's addr_msg_parser(). */
static NMPObject *
-_new_from_nl_addr(struct nlmsghdr *nlh, gboolean id_only)
+_new_from_nl_addr(const struct nlmsghdr *nlh, gboolean id_only)
{
static const struct nla_policy policy[] = {
[IFA_LABEL] = {.type = NLA_STRING, .maxlen = IFNAMSIZ},
@@ -3390,7 +3390,7 @@ _new_from_nl_addr(struct nlmsghdr *nlh, gboolean id_only)
/* Copied and heavily modified from libnl3's rtnl_route_parse() and parse_multipath(). */
static NMPObject *
-_new_from_nl_route(struct nlmsghdr *nlh, gboolean id_only, ParseNlmsgIter *parse_nlmsg_iter)
+_new_from_nl_route(const struct nlmsghdr *nlh, gboolean id_only, ParseNlmsgIter *parse_nlmsg_iter)
{
static const struct nla_policy policy[] = {
[RTA_TABLE] = {.type = NLA_U32},
@@ -3698,7 +3698,7 @@ rta_multipath_done:
}
static NMPObject *
-_new_from_nl_routing_rule(struct nlmsghdr *nlh, gboolean id_only)
+_new_from_nl_routing_rule(const struct nlmsghdr *nlh, gboolean id_only)
{
static const struct nla_policy policy[] = {
[FRA_UNSPEC] = {},
@@ -3974,7 +3974,7 @@ psched_tick_to_time(NMPlatform *platform, guint32 tick)
}
static NMPObject *
-_new_from_nl_qdisc(NMPlatform *platform, struct nlmsghdr *nlh, gboolean id_only)
+_new_from_nl_qdisc(NMPlatform *platform, const struct nlmsghdr *nlh, gboolean id_only)
{
static const struct nla_policy policy[] = {
[TCA_KIND] = {.type = NLA_STRING},
@@ -4087,7 +4087,7 @@ _new_from_nl_qdisc(NMPlatform *platform, struct nlmsghdr *nlh, gboolean id_only)
}
static NMPObject *
-_new_from_nl_tfilter(NMPlatform *platform, struct nlmsghdr *nlh, gboolean id_only)
+_new_from_nl_tfilter(NMPlatform *platform, const struct nlmsghdr *nlh, gboolean id_only)
{
static const struct nla_policy policy[] = {
[TCA_KIND] = {.type = NLA_STRING},
@@ -4138,7 +4138,7 @@ nmp_object_new_from_nl(NMPlatform *platform,
gboolean id_only,
ParseNlmsgIter *parse_nlmsg_iter)
{
- struct nlmsghdr *msghdr;
+ const struct nlmsghdr *msghdr;
if (nlmsg_get_proto(msg) != NETLINK_ROUTE)
return NULL;
diff --git a/src/libnm-platform/nm-netlink.c b/src/libnm-platform/nm-netlink.c
index 1760628d2e..03064bdcde 100644
--- a/src/libnm-platform/nm-netlink.c
+++ b/src/libnm-platform/nm-netlink.c
@@ -402,7 +402,7 @@ nlmsg_append(struct nl_msg *n, const void *data, size_t len, int pad)
/*****************************************************************************/
int
-nlmsg_parse(struct nlmsghdr *nlh,
+nlmsg_parse(const struct nlmsghdr *nlh,
int hdrlen,
struct nlattr *tb[],
int maxtype,
diff --git a/src/libnm-platform/nm-netlink.h b/src/libnm-platform/nm-netlink.h
index 08fd63bfcb..4f68742f12 100644
--- a/src/libnm-platform/nm-netlink.h
+++ b/src/libnm-platform/nm-netlink.h
@@ -465,7 +465,7 @@ nlmsg_find_attr(struct nlmsghdr *nlh, int hdrlen, int attrtype)
return nla_find(nlmsg_attrdata(nlh, hdrlen), nlmsg_attrlen(nlh, hdrlen), attrtype);
}
-int nlmsg_parse(struct nlmsghdr *nlh,
+int nlmsg_parse(const struct nlmsghdr *nlh,
int hdrlen,
struct nlattr *tb[],
int maxtype,