Commit 522b93f6 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'adopting-nlmsg_payload-in-ipv4-ipv6'

Breno Leitao says:

====================
Adopting nlmsg_payload() in IPv4/IPv6

The commit 95d06e92 ("netlink: Introduce nlmsg_payload helper")
introduced the nlmsg_payload() helper function.

This patchset aims to replace manual implementations with the
nlmsg_payload() helper in IPv4 and IPv6 files, one file per patch.
====================

Link: https://patch.msgid.link/20250415-nlmsg_v2-v1-0-a1c75d493fd7@debian.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents da59ceed 9b1097a4
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -411,13 +411,12 @@ static int vxlan_vnifilter_dump(struct sk_buff *skb, struct netlink_callback *cb
	struct tunnel_msg *tmsg;
	struct net_device *dev;

	if (cb->nlh->nlmsg_len < nlmsg_msg_size(sizeof(struct tunnel_msg))) {
	tmsg = nlmsg_payload(cb->nlh, sizeof(*tmsg));
	if (!tmsg) {
		NL_SET_ERR_MSG(cb->extack, "Invalid msg length");
		return -EINVAL;
	}

	tmsg = nlmsg_data(cb->nlh);

	if (tmsg->flags & ~TUNNEL_MSG_VALID_USER_FLAGS) {
		NL_SET_ERR_MSG(cb->extack, "Invalid tunnelmsg flags in ancillary header");
		return -EINVAL;
+2 −2
Original line number Diff line number Diff line
@@ -1792,12 +1792,12 @@ static int inet_valid_dump_ifaddr_req(const struct nlmsghdr *nlh,
	struct ifaddrmsg *ifm;
	int err, i;

	if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifm))) {
	ifm = nlmsg_payload(nlh, sizeof(*ifm));
	if (!ifm) {
		NL_SET_ERR_MSG(extack, "ipv4: Invalid header for address dump request");
		return -EINVAL;
	}

	ifm = nlmsg_data(nlh);
	if (ifm->ifa_prefixlen || ifm->ifa_flags || ifm->ifa_scope) {
		NL_SET_ERR_MSG(extack, "ipv4: Invalid values in header for address dump request");
		return -EINVAL;
+2 −2
Original line number Diff line number Diff line
@@ -948,12 +948,12 @@ int ip_valid_fib_dump_req(struct net *net, const struct nlmsghdr *nlh,
	if (filter->rtnl_held)
		ASSERT_RTNL();

	if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*rtm))) {
	rtm = nlmsg_payload(nlh, sizeof(*rtm));
	if (!rtm) {
		NL_SET_ERR_MSG(extack, "Invalid header for FIB dump request");
		return -EINVAL;
	}

	rtm = nlmsg_data(nlh);
	if (rtm->rtm_dst_len || rtm->rtm_src_len  || rtm->rtm_tos   ||
	    rtm->rtm_scope) {
		NL_SET_ERR_MSG(extack, "Invalid values in header for FIB dump request");
+4 −4
Original line number Diff line number Diff line
@@ -2511,7 +2511,8 @@ static int ipmr_rtm_valid_getroute_req(struct sk_buff *skb,
	struct rtmsg *rtm;
	int i, err;

	if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*rtm))) {
	rtm = nlmsg_payload(nlh, sizeof(*rtm));
	if (!rtm) {
		NL_SET_ERR_MSG(extack, "ipv4: Invalid header for multicast route get request");
		return -EINVAL;
	}
@@ -2520,7 +2521,6 @@ static int ipmr_rtm_valid_getroute_req(struct sk_buff *skb,
		return nlmsg_parse_deprecated(nlh, sizeof(*rtm), tb, RTA_MAX,
					      rtm_ipv4_policy, extack);

	rtm = nlmsg_data(nlh);
	if ((rtm->rtm_src_len && rtm->rtm_src_len != 32) ||
	    (rtm->rtm_dst_len && rtm->rtm_dst_len != 32) ||
	    rtm->rtm_tos || rtm->rtm_table || rtm->rtm_protocol ||
@@ -2836,7 +2836,8 @@ static int ipmr_valid_dumplink(const struct nlmsghdr *nlh,
{
	struct ifinfomsg *ifm;

	if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifm))) {
	ifm = nlmsg_payload(nlh, sizeof(*ifm));
	if (!ifm) {
		NL_SET_ERR_MSG(extack, "ipv4: Invalid header for ipmr link dump");
		return -EINVAL;
	}
@@ -2846,7 +2847,6 @@ static int ipmr_valid_dumplink(const struct nlmsghdr *nlh,
		return -EINVAL;
	}

	ifm = nlmsg_data(nlh);
	if (ifm->__ifi_pad || ifm->ifi_type || ifm->ifi_flags ||
	    ifm->ifi_change || ifm->ifi_index) {
		NL_SET_ERR_MSG(extack, "Invalid values in header for ipmr link dump request");
+2 −2
Original line number Diff line number Diff line
@@ -3205,7 +3205,8 @@ static int inet_rtm_valid_getroute_req(struct sk_buff *skb,
	struct rtmsg *rtm;
	int i, err;

	if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*rtm))) {
	rtm = nlmsg_payload(nlh, sizeof(*rtm));
	if (!rtm) {
		NL_SET_ERR_MSG(extack,
			       "ipv4: Invalid header for route get request");
		return -EINVAL;
@@ -3215,7 +3216,6 @@ static int inet_rtm_valid_getroute_req(struct sk_buff *skb,
		return nlmsg_parse_deprecated(nlh, sizeof(*rtm), tb, RTA_MAX,
					      rtm_ipv4_policy, extack);

	rtm = nlmsg_data(nlh);
	if ((rtm->rtm_src_len && rtm->rtm_src_len != 32) ||
	    (rtm->rtm_dst_len && rtm->rtm_dst_len != 32) ||
	    rtm->rtm_table || rtm->rtm_protocol ||
Loading