Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

Breno Leitao says:

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

The commit 95d06e92a4019 ("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: Jakub Kicinski <kuba@kernel.org>

+20 -21
+2 -3
drivers/net/vxlan/vxlan_vnifilter.c
··· 411 411 struct tunnel_msg *tmsg; 412 412 struct net_device *dev; 413 413 414 - if (cb->nlh->nlmsg_len < nlmsg_msg_size(sizeof(struct tunnel_msg))) { 414 + tmsg = nlmsg_payload(cb->nlh, sizeof(*tmsg)); 415 + if (!tmsg) { 415 416 NL_SET_ERR_MSG(cb->extack, "Invalid msg length"); 416 417 return -EINVAL; 417 418 } 418 - 419 - tmsg = nlmsg_data(cb->nlh); 420 419 421 420 if (tmsg->flags & ~TUNNEL_MSG_VALID_USER_FLAGS) { 422 421 NL_SET_ERR_MSG(cb->extack, "Invalid tunnelmsg flags in ancillary header");
+2 -2
net/ipv4/devinet.c
··· 1792 1792 struct ifaddrmsg *ifm; 1793 1793 int err, i; 1794 1794 1795 - if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifm))) { 1795 + ifm = nlmsg_payload(nlh, sizeof(*ifm)); 1796 + if (!ifm) { 1796 1797 NL_SET_ERR_MSG(extack, "ipv4: Invalid header for address dump request"); 1797 1798 return -EINVAL; 1798 1799 } 1799 1800 1800 - ifm = nlmsg_data(nlh); 1801 1801 if (ifm->ifa_prefixlen || ifm->ifa_flags || ifm->ifa_scope) { 1802 1802 NL_SET_ERR_MSG(extack, "ipv4: Invalid values in header for address dump request"); 1803 1803 return -EINVAL;
+2 -2
net/ipv4/fib_frontend.c
··· 948 948 if (filter->rtnl_held) 949 949 ASSERT_RTNL(); 950 950 951 - if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*rtm))) { 951 + rtm = nlmsg_payload(nlh, sizeof(*rtm)); 952 + if (!rtm) { 952 953 NL_SET_ERR_MSG(extack, "Invalid header for FIB dump request"); 953 954 return -EINVAL; 954 955 } 955 956 956 - rtm = nlmsg_data(nlh); 957 957 if (rtm->rtm_dst_len || rtm->rtm_src_len || rtm->rtm_tos || 958 958 rtm->rtm_scope) { 959 959 NL_SET_ERR_MSG(extack, "Invalid values in header for FIB dump request");
+4 -4
net/ipv4/ipmr.c
··· 2511 2511 struct rtmsg *rtm; 2512 2512 int i, err; 2513 2513 2514 - if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*rtm))) { 2514 + rtm = nlmsg_payload(nlh, sizeof(*rtm)); 2515 + if (!rtm) { 2515 2516 NL_SET_ERR_MSG(extack, "ipv4: Invalid header for multicast route get request"); 2516 2517 return -EINVAL; 2517 2518 } ··· 2521 2520 return nlmsg_parse_deprecated(nlh, sizeof(*rtm), tb, RTA_MAX, 2522 2521 rtm_ipv4_policy, extack); 2523 2522 2524 - rtm = nlmsg_data(nlh); 2525 2523 if ((rtm->rtm_src_len && rtm->rtm_src_len != 32) || 2526 2524 (rtm->rtm_dst_len && rtm->rtm_dst_len != 32) || 2527 2525 rtm->rtm_tos || rtm->rtm_table || rtm->rtm_protocol || ··· 2836 2836 { 2837 2837 struct ifinfomsg *ifm; 2838 2838 2839 - if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifm))) { 2839 + ifm = nlmsg_payload(nlh, sizeof(*ifm)); 2840 + if (!ifm) { 2840 2841 NL_SET_ERR_MSG(extack, "ipv4: Invalid header for ipmr link dump"); 2841 2842 return -EINVAL; 2842 2843 } ··· 2847 2846 return -EINVAL; 2848 2847 } 2849 2848 2850 - ifm = nlmsg_data(nlh); 2851 2849 if (ifm->__ifi_pad || ifm->ifi_type || ifm->ifi_flags || 2852 2850 ifm->ifi_change || ifm->ifi_index) { 2853 2851 NL_SET_ERR_MSG(extack, "Invalid values in header for ipmr link dump request");
+2 -2
net/ipv4/route.c
··· 3205 3205 struct rtmsg *rtm; 3206 3206 int i, err; 3207 3207 3208 - if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*rtm))) { 3208 + rtm = nlmsg_payload(nlh, sizeof(*rtm)); 3209 + if (!rtm) { 3209 3210 NL_SET_ERR_MSG(extack, 3210 3211 "ipv4: Invalid header for route get request"); 3211 3212 return -EINVAL; ··· 3216 3215 return nlmsg_parse_deprecated(nlh, sizeof(*rtm), tb, RTA_MAX, 3217 3216 rtm_ipv4_policy, extack); 3218 3217 3219 - rtm = nlmsg_data(nlh); 3220 3218 if ((rtm->rtm_src_len && rtm->rtm_src_len != 32) || 3221 3219 (rtm->rtm_dst_len && rtm->rtm_dst_len != 32) || 3222 3220 rtm->rtm_table || rtm->rtm_protocol ||
+2 -2
net/ipv6/addrconf.c
··· 6112 6112 { 6113 6113 struct ifinfomsg *ifm; 6114 6114 6115 - if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifm))) { 6115 + ifm = nlmsg_payload(nlh, sizeof(*ifm)); 6116 + if (!ifm) { 6116 6117 NL_SET_ERR_MSG_MOD(extack, "Invalid header for link dump request"); 6117 6118 return -EINVAL; 6118 6119 } ··· 6123 6122 return -EINVAL; 6124 6123 } 6125 6124 6126 - ifm = nlmsg_data(nlh); 6127 6125 if (ifm->__ifi_pad || ifm->ifi_type || ifm->ifi_flags || 6128 6126 ifm->ifi_change || ifm->ifi_index) { 6129 6127 NL_SET_ERR_MSG_MOD(extack, "Invalid values in header for dump request");
+4 -4
net/ipv6/addrlabel.c
··· 473 473 { 474 474 struct ifaddrlblmsg *ifal; 475 475 476 - if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifal))) { 476 + ifal = nlmsg_payload(nlh, sizeof(*ifal)); 477 + if (!ifal) { 477 478 NL_SET_ERR_MSG_MOD(extack, "Invalid header for address label dump request"); 478 479 return -EINVAL; 479 480 } 480 481 481 - ifal = nlmsg_data(nlh); 482 482 if (ifal->__ifal_reserved || ifal->ifal_prefixlen || 483 483 ifal->ifal_flags || ifal->ifal_index || ifal->ifal_seq) { 484 484 NL_SET_ERR_MSG_MOD(extack, "Invalid values in header for address label dump request"); ··· 543 543 struct ifaddrlblmsg *ifal; 544 544 int i, err; 545 545 546 - if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifal))) { 546 + ifal = nlmsg_payload(nlh, sizeof(*ifal)); 547 + if (!ifal) { 547 548 NL_SET_ERR_MSG_MOD(extack, "Invalid header for addrlabel get request"); 548 549 return -EINVAL; 549 550 } ··· 553 552 return nlmsg_parse_deprecated(nlh, sizeof(*ifal), tb, 554 553 IFAL_MAX, ifal_policy, extack); 555 554 556 - ifal = nlmsg_data(nlh); 557 555 if (ifal->__ifal_reserved || ifal->ifal_flags || ifal->ifal_seq) { 558 556 NL_SET_ERR_MSG_MOD(extack, "Invalid values in header for addrlabel get request"); 559 557 return -EINVAL;
+2 -2
net/ipv6/route.c
··· 6029 6029 struct rtmsg *rtm; 6030 6030 int i, err; 6031 6031 6032 - if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*rtm))) { 6032 + rtm = nlmsg_payload(nlh, sizeof(*rtm)); 6033 + if (!rtm) { 6033 6034 NL_SET_ERR_MSG_MOD(extack, 6034 6035 "Invalid header for get route request"); 6035 6036 return -EINVAL; ··· 6040 6039 return nlmsg_parse_deprecated(nlh, sizeof(*rtm), tb, RTA_MAX, 6041 6040 rtm_ipv6_policy, extack); 6042 6041 6043 - rtm = nlmsg_data(nlh); 6044 6042 if ((rtm->rtm_src_len && rtm->rtm_src_len != 128) || 6045 6043 (rtm->rtm_dst_len && rtm->rtm_dst_len != 128) || 6046 6044 rtm->rtm_table || rtm->rtm_protocol || rtm->rtm_scope ||